Skip to content

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

License

Notifications You must be signed in to change notification settings

FutuCopy/futucopy-api-dotnet

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)

API Reference

Method Description Endpoint
GetHealthAsync() Check API health status 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
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
FlattenAllAsync() Flatten all positions and disable all copy rules POST /api/v1/trading/flatten-all
BuyMarketAsync(id, qty) Place a market BUY order POST /api/v1/trading/buy-market
SellMarketAsync(id, qty) Place a market SELL order POST /api/v1/trading/sell-market

Supported Brokerages

FutuCopy supports trade copying across these futures brokerages:

  • Rithmic
  • Tradovate
  • NinjaTrader
  • ProjectX
  • dxFeed

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}");
}

// 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);
}

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

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages