Skip to content

Repository files navigation

FutuCopy API Client for .NET

NuGet License: MIT

The official .NET client library for the FutuCopy Trade Copier API. Build custom dashboards, analytics tools, and automation for your futures trading accounts.

FutuCopy is a cloud trade copier for futures prop traders, supporting Rithmic, Tradovate, NinjaTrader, ProjectX, and dxFeed brokerages with ultra-low latency.

Features

  • Accounts -- Monitor balances, equity, and PnL across all connected brokerage accounts
  • Positions -- Real-time open position data with unrealized PnL
  • Orders -- Query order history with status filtering (live, filled, canceled, rejected)
  • Connections -- Check brokerage connection status
  • Trade Copy -- View leader/follower copy-trading configurations
  • Risk Management -- Access account risk status (profit targets, loss limits) and trailing-drawdown metrics (drawdown floor, available drawdown)
  • Order Placement -- Submit market, limit, stop, and bracket orders, with optional client reference IDs
  • Copy Control -- Toggle leaders and individual followers, flatten positions, and cancel working orders

API Reference

Accounts & market data

Method Description Endpoint
GetHealthAsync() Check API health status (no auth required) GET /api/v1/health
GetAccountsAsync() List all trading accounts with positions and orders GET /api/v1/accounts
GetAccountAsync(id) Get account detail with risk status GET /api/v1/accounts/{id}
GetConnectionsAsync() List brokerage connections and status GET /api/v1/connections
GetTradeCopyConfigsAsync() List copy-trading leader/follower configurations GET /api/v1/tradecopy
GetFuturesContractsAsync() List available futures contracts GET /api/v1/futurescontracts

Copy-trading control

Method Description Endpoint
EnableTradeCopyAsync(id) Enable copy trading for a leader POST /api/v1/trading/enable
DisableTradeCopyAsync(id) Disable copy trading for a leader POST /api/v1/trading/disable
EnableFollowersAsync(ids) Enable copy trading for specific followers POST /api/v1/trading/followers/enable
DisableFollowersAsync(ids) Disable copy trading for specific followers POST /api/v1/trading/followers/disable
FlattenAllAsync() Flatten all positions and disable all copy rules POST /api/v1/trading/flatten-all
FlattenOnlyAsync(id?) Flatten positions and cancel orders, then restore copy rules POST /api/v1/trading/flatten-only
CancelAllOrdersAsync(id?) Cancel all working orders (positions and copy rules untouched) POST /api/v1/trading/cancel-all-orders

Order placement

Method Description Endpoint
BuyMarketAsync(id, qty, [apiOrderId]) Place a market BUY order POST /api/v1/trading/buy-market
SellMarketAsync(id, qty, [apiOrderId]) Place a market SELL order POST /api/v1/trading/sell-market
BuyLimitAsync(id, qty, limitPrice, [apiOrderId]) Place a limit BUY order POST /api/v1/trading/buy-limit
SellLimitAsync(id, qty, limitPrice, [apiOrderId]) Place a limit SELL order POST /api/v1/trading/sell-limit
BuyStopAsync(id, qty, stopPrice, [apiOrderId]) Place a stop-market BUY order POST /api/v1/trading/buy-stop
SellStopAsync(id, qty, stopPrice, [apiOrderId]) Place a stop-market SELL order POST /api/v1/trading/sell-stop
PlaceBracketOrderAsync(...) Market entry with stop-loss and profit-target brackets POST /api/v1/trading/place-bracket-order
PlaceEntryWithBracketOrderAsync(...) Limit/stop entry with attached stop-loss and profit-target brackets POST /api/v1/trading/place-entry-with-bracket-order

Order management

Method Description Endpoint
CancelOrderAsync(orderId) Cancel a single order by ID POST /api/v1/trading/cancel-order
GetOrderByApiOrderIdAsync(apiOrderId) Get leader and follower order status by client reference ID GET /api/v1/orders/{apiOrderId}

Order-placement methods accept an optional apiOrderId -- a client-provided reference ID (max 64 chars) used for retry de-duplication and for later lookup via GetOrderByApiOrderIdAsync.

Supported Brokerages

FutuCopy supports trade copying across these futures brokerages:

  • Rithmic -- Used by Apex, Topstep, and other major prop trading firms
  • Tradovate -- Popular commission-free futures trading platform
  • NinjaTrader -- Industry-standard futures and forex trading platform
  • ProjectX -- Modern futures trading platform for active traders
  • dxFeed -- Institutional-grade market data and trading infrastructure

All brokerages support real-time position sync and ultra-low copy latency. Learn more at futucopy.com.

Installation

dotnet add package FutuCopy.Api.Client

Quick Start

Standalone Usage

using FutuCopy.Api.Client;

using var client = new FutuCopyClient("https://your-server.futucopy.com", "fc_pk_your_api_key_here");

// Check API health
var health = await client.GetHealthAsync();
Console.WriteLine($"API Status: {health.Status}, Version: {health.Version}");

// List all accounts (includes positions and orders)
var accounts = await client.GetAccountsAsync();
foreach (var account in accounts)
{
    Console.WriteLine($"{account.AccountName}: Balance={account.Balance:C}, PnL={account.DailyPnL:C}");
    Console.WriteLine($"  Positions: {account.Positions.Count}, Orders: {account.Orders.Count}");

    // Trailing-drawdown metrics (null when the broker exposes no drawdown rule)
    if (account.AvailableDrawdown is { } available)
        Console.WriteLine($"  Drawdown floor: {account.DrawdownFloor:C}, available: {available:C}");
}

// Get detailed account info with positions and orders
var detail = await client.GetAccountAsync(accountId: 1);
foreach (var position in detail.Positions)
{
    Console.WriteLine($"{position.Symbol}: {position.Quantity} @ {position.AveragePrice}, PnL={position.UnrealizedPnL:C}");
}

Dependency Injection (ASP.NET Core, Worker Services)

// In Program.cs
builder.Services.AddFutuCopy(options =>
{
    options.ApiKey = builder.Configuration["FutuCopy:ApiKey"]!;
    options.BaseUrl = builder.Configuration["FutuCopy:BaseUrl"]!; // your dedicated instance URL
});

// In your service or controller
public class TradingDashboard(IFutuCopyClient futuCopy)
{
    public async Task<AccountResponse> GetAccount(int id)
        => await futuCopy.GetAccountAsync(id);
}

Placing Orders

// Market order with a client reference ID (enables retry de-duplication and lookup)
var order = await client.BuyMarketAsync(tradeCopyLeaderId: 1, quantity: 2, apiOrderId: "my-ref-001");
Console.WriteLine($"Submitted: {order.Success}, OrderId: {order.OrderId}");

// Limit and stop orders
await client.SellLimitAsync(tradeCopyLeaderId: 1, quantity: 1, limitPrice: 6050.25m);
await client.BuyStopAsync(tradeCopyLeaderId: 1, quantity: 1, stopPrice: 6075.00m);

// Bracket order: market entry with a 20-tick stop-loss and 40-tick profit target
var bracket = await client.PlaceBracketOrderAsync(
    tradeCopyLeaderId: 1,
    quantity: 1,
    stopLossTicks: 20,
    profitTargetTicks: 40,
    apiOrderId: "bracket-001");

// Look up leader + follower status by the client reference ID
var status = await client.GetOrderByApiOrderIdAsync("bracket-001");
Console.WriteLine($"Leader status: {status.LeaderOrder?.Status}, followers: {status.FollowerOrders.Count}");

// Cancel a single order, or cancel all working orders for a leader
await client.CancelOrderAsync(order.OrderId!);
await client.CancelAllOrdersAsync(tradeCopyLeaderId: 1);

Error Handling

The client throws typed exceptions for different error scenarios:

using FutuCopy.Api.Client.Exceptions;

try
{
    var account = await client.GetAccountAsync(999);
}
catch (FutuCopyAuthenticationException ex)
{
    // 401 - Invalid or missing API key
    Console.WriteLine($"Auth failed: {ex.Error?.Code}");
}
catch (FutuCopyNotFoundException ex)
{
    // 404 - Account not found
    Console.WriteLine($"Not found: {ex.Error?.Message}");
}
catch (FutuCopyRateLimitException)
{
    // 429 - Too many requests
}
catch (FutuCopyApiException ex)
{
    // Other API errors
    Console.WriteLine($"API error {ex.StatusCode}: {ex.Message}, RequestId: {ex.RequestId}");
}

Configuration

var client = new FutuCopyClient("https://your-server.futucopy.com", "fc_pk_your_key", new FutuCopyClientOptions
{
    Timeout = TimeSpan.FromSeconds(30) // default
});

When using DI, you can chain additional HttpClient configuration:

builder.Services.AddFutuCopy(options =>
{
    options.ApiKey = builder.Configuration["FutuCopy:ApiKey"]!;
})
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler
{
    // Custom handler settings (proxy, certificates, etc.)
});

Authentication

  1. Log in to your FutuCopy dashboard
  2. Navigate to Pro Server > API Access
  3. Generate an API key (format: fc_pk_...)

Security: Never hardcode API keys in source code. Use environment variables, user secrets, or a configuration provider:

options.ApiKey = Environment.GetEnvironmentVariable("FUTUCOPY_API_KEY")!;

Requirements

  • .NET 10.0 or later
  • FutuCopy Pro plan with API access enabled
  • API key (format: fc_pk_*)

Links

Disclaimer

This software is provided for informational and development purposes. Trading futures involves substantial risk of loss and is not suitable for all investors. FutuCopy is not responsible for any trading losses incurred through the use of this software or API. Past performance is not indicative of future results. Use at your own risk.

See futucopy.com for full terms of service.

License

MIT License -- see LICENSE for details.

About

Official .NET client library for the FutuCopy Trade Copier API. Futures copy trading for Rithmic, Tradovate, NinjaTrader, ProjectX, and dxFeed

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages