Exchange-agnostic interfaces for futures and derivatives trading
The shared futures interfaces expose a consistent, exchange-agnostic API surface for perpetual and delivery futures trading. Each interface is implemented by one or more exchange clients and can be retrieved from IExchangeRestClient filtered by trading mode.
// Single exchange, filtered by trading modeIFuturesTickerRestClient? client = restClient.GetFuturesTickerClient(TradingMode.PerpetualLinear, "Binance");// All exchanges supporting linear perpetualsIEnumerable<IFuturesTickerRestClient> clients = restClient.GetFuturesTickerClients(TradingMode.PerpetualLinear);// All exchanges, all modesIEnumerable<IFuturesTickerRestClient> allClients = restClient.GetFuturesTickerClients();
Pass a TradingMode filter when calling GetXxxClients(TradingMode) to avoid calling exchanges or market types that don’t apply to your use case.
IFuturesTickerRestClient
Retrieve 24-hour price ticker data for futures symbols, including mark price, index price, and funding rate where available.Client access
// Single symbol on a specific exchangeTask<ExchangeWebResult<SharedFuturesTicker>> GetFuturesTickerAsync( string exchange, GetTickerRequest request, CancellationToken ct = default);// Single symbol across all (or filtered) exchanges — wait for allTask<ExchangeWebResult<SharedFuturesTicker>[]> GetFuturesTickerAsync( GetTickerRequest request, IEnumerable<string>? exchanges = null, CancellationToken ct = default);// Single symbol — stream results as they arriveIAsyncEnumerable<ExchangeWebResult<SharedFuturesTicker>> GetFuturesTickerAsyncEnumerable( GetTickerRequest request, IEnumerable<string>? exchanges = null, CancellationToken ct = default);// All symbols on a specific exchangeTask<ExchangeWebResult<SharedFuturesTicker[]>> GetFuturesTickersAsync( string exchange, GetTickersRequest request, CancellationToken ct = default);// All symbols across all (or filtered) exchanges — wait for allTask<ExchangeWebResult<SharedFuturesTicker[]>[]> GetFuturesTickersAsync( GetTickersRequest request, IEnumerable<string>? exchanges = null, CancellationToken ct = default);// All symbols — stream results as they arriveIAsyncEnumerable<ExchangeWebResult<SharedFuturesTicker[]>> GetFuturesTickersAsyncEnumerable( GetTickersRequest request, IEnumerable<string>? exchanges = null, CancellationToken ct = default);
Example
var symbol = new SharedSymbol(TradingMode.PerpetualLinear, "BTC", "USDT");// Fetch from Binancevar ticker = await restClient.GetFuturesTickerAsync("Binance", new GetTickerRequest(symbol));// Fetch from all exchanges simultaneously, streaming resultsawait foreach (var result in restClient.GetFuturesTickerAsyncEnumerable( new GetTickerRequest(symbol))){ Console.WriteLine($"{result.Exchange}: {result.Data?.LastPrice}");}
IFuturesSymbolRestClient
List all available futures trading pairs on an exchange, optionally filtered by trading mode.Client access
// Place a futures orderTask<ExchangeWebResult<SharedId>> PlaceFuturesOrderAsync( string exchange, PlaceFuturesOrderRequest request, CancellationToken ct = default);// Retrieve a specific orderTask<ExchangeWebResult<SharedFuturesOrder>> GetFuturesOrderAsync( string exchange, GetOrderRequest request, CancellationToken ct = default);// Retrieve fills for a specific orderTask<ExchangeWebResult<SharedUserTrade[]>> GetFuturesOrderTradesAsync( string exchange, GetOrderTradesRequest request, CancellationToken ct = default);// Cancel an open orderTask<ExchangeWebResult<SharedId>> CancelFuturesOrderAsync( string exchange, CancelOrderRequest request, CancellationToken ct = default);// Close an open position at marketTask<ExchangeWebResult<SharedId>> ClosePositionAsync( string exchange, ClosePositionRequest request, CancellationToken ct = default);// Get open orders (optionally scoped to a symbol)Task<ExchangeWebResult<SharedFuturesOrder[]>> GetFuturesOpenOrdersAsync( string exchange, GetOpenOrdersRequest request, CancellationToken ct = default);// Get closed/historical ordersTask<ExchangeWebResult<SharedFuturesOrder[]>> GetFuturesClosedOrdersAsync( string exchange, GetClosedOrdersRequest request, PageRequest? pageRequest = null, CancellationToken ct = default);// Get user trade historyTask<ExchangeWebResult<SharedUserTrade[]>> GetFuturesUserTradesAsync( string exchange, GetUserTradesRequest request, PageRequest? pageRequest = null, CancellationToken ct = default);// Get open positionsTask<ExchangeWebResult<SharedPosition[]>> GetPositionsAsync( string exchange, GetPositionsRequest request, CancellationToken ct = default);
Example
var symbol = new SharedSymbol(TradingMode.PerpetualLinear, "ETH", "USDT");// Open a long position with 10x leveragevar order = await restClient.PlaceFuturesOrderAsync("Bybit", new PlaceFuturesOrderRequest( symbol, SharedOrderSide.Buy, SharedOrderType.Market, quantity: 1m));// Close the positionawait restClient.ClosePositionAsync("Bybit", new ClosePositionRequest(symbol, SharedPositionSide.Long));
IFuturesOrderClientIdRestClient
Retrieve or cancel futures orders using a client-assigned order ID.Client access
// Set 10x leverage for BTC-USDT perp on Bybitawait restClient.SetLeverageAsync("Bybit", new SetLeverageRequest( new SharedSymbol(TradingMode.PerpetualLinear, "BTC", "USDT"), leverage: 10));