diff --git a/Binance.Net.UnitTests/BinanceSocketClientTests.cs b/Binance.Net.UnitTests/BinanceSocketClientTests.cs index f65492bf1..249f3deb7 100644 --- a/Binance.Net.UnitTests/BinanceSocketClientTests.cs +++ b/Binance.Net.UnitTests/BinanceSocketClientTests.cs @@ -79,7 +79,7 @@ public async Task SubscribingToContinuousKlineStream_Should_TriggerWhenContinuou var client = TestHelpers.CreateSocketClient(socket); IBinanceStreamKlineData result = null; - var subTask = client.UsdFuturesApi.SubscribeToContinuousContractKlineUpdatesAsync("ETHBTC", ContractType.Perpetual, KlineInterval.OneMinute, (test) => result = test.Data); + var subTask = client.UsdFuturesApi.ExchangeData.SubscribeToContinuousContractKlineUpdatesAsync("ETHBTC", ContractType.Perpetual, KlineInterval.OneMinute, (test) => result = test.Data); socket.InvokeMessage(new BinanceSocketQueryResponse { Id = ExchangeHelpers.LastId() - 1 }); await subTask; diff --git a/Binance.Net.UnitTests/SocketSubscriptionTests.cs b/Binance.Net.UnitTests/SocketSubscriptionTests.cs index 614496e37..4b76fa37a 100644 --- a/Binance.Net.UnitTests/SocketSubscriptionTests.cs +++ b/Binance.Net.UnitTests/SocketSubscriptionTests.cs @@ -52,27 +52,27 @@ public async Task ValidateUsdFuturesSubscriptions() opts.ApiCredentials = new CryptoExchange.Net.Authentication.ApiCredentials("123", "456"); }); var tester = new SocketSubscriptionValidator<BinanceSocketClient>(client, "Subscriptions/UsdFutures", "https://fapi.binance.com", "data", stjCompare: true); - await tester.ValidateAsync<BinanceFuturesUsdtStreamMarkPrice>((client, handler) => client.UsdFuturesApi.SubscribeToMarkPriceUpdatesAsync("BTCUSDT", 1000, handler), "MarkPrice"); - await tester.ValidateAsync<IBinanceStreamKlineData>((client, handler) => client.UsdFuturesApi.SubscribeToKlineUpdatesAsync("BTCUSDT", Enums.KlineInterval.OneMonth, handler), "Klines", ignoreProperties: new List<string> { "B" }); - await tester.ValidateAsync<BinanceStreamContinuousKlineData>((client, handler) => client.UsdFuturesApi.SubscribeToContinuousContractKlineUpdatesAsync("BTCUSDT", Enums.ContractType.Perpetual, Enums.KlineInterval.OneMonth, handler), "ContKlines", ignoreProperties: new List<string> { "B" }); - await tester.ValidateAsync<IBinanceMiniTick>((client, handler) => client.UsdFuturesApi.SubscribeToMiniTickerUpdatesAsync("BTCUSDT", handler), "MiniTicker"); - await tester.ValidateAsync<IBinance24HPrice>((client, handler) => client.UsdFuturesApi.SubscribeToTickerUpdatesAsync("BTCUSDT", handler), "Ticker"); - await tester.ValidateAsync<BinanceFuturesStreamCompositeIndex>((client, handler) => client.UsdFuturesApi.SubscribeToCompositeIndexUpdatesAsync("BTCUSDT", handler), "CompositIndex"); - await tester.ValidateAsync<BinanceStreamAggregatedTrade>((client, handler) => client.UsdFuturesApi.SubscribeToAggregatedTradeUpdatesAsync("BTCUSDT", handler), "AggTrades"); - await tester.ValidateAsync<BinanceFuturesStreamBookPrice>((client, handler) => client.UsdFuturesApi.SubscribeToBookTickerUpdatesAsync("BTCUSDT", handler), "BookTicker"); - await tester.ValidateAsync<BinanceFuturesStreamLiquidation>((client, handler) => client.UsdFuturesApi.SubscribeToLiquidationUpdatesAsync("BTCUSDT", handler), "Liquidations", "data.o", ignoreProperties: new List<string> { "e", "E" }); - await tester.ValidateAsync<IBinanceFuturesEventOrderBook>((client, handler) => client.UsdFuturesApi.SubscribeToPartialOrderBookUpdatesAsync("BTCUSDT", 5, 100, handler), "PartialBook"); - await tester.ValidateAsync<IBinanceFuturesEventOrderBook>((client, handler) => client.UsdFuturesApi.SubscribeToOrderBookUpdatesAsync("BTCUSDT", 100, handler), "Book"); - await tester.ValidateAsync<BinanceFuturesStreamSymbolUpdate>((client, handler) => client.UsdFuturesApi.SubscribeToSymbolUpdatesAsync(handler), "SymbolUpdates"); - await tester.ValidateAsync<IEnumerable<BinanceFuturesStreamAssetIndexUpdate>>((client, handler) => client.UsdFuturesApi.SubscribeToAssetIndexUpdatesAsync(handler), "AssetIndex"); - await tester.ValidateAsync<BinanceFuturesStreamConfigUpdate>((client, handler) => client.UsdFuturesApi.SubscribeToUserDataUpdatesAsync("123", onLeverageUpdate: handler), "Leverage"); - await tester.ValidateAsync<BinanceFuturesStreamConfigUpdate>((client, handler) => client.UsdFuturesApi.SubscribeToUserDataUpdatesAsync("123", onLeverageUpdate: handler), "MultiAssetMode"); - await tester.ValidateAsync<BinanceFuturesStreamMarginUpdate>((client, handler) => client.UsdFuturesApi.SubscribeToUserDataUpdatesAsync("123", onMarginUpdate: handler), "MarginUpdate"); - await tester.ValidateAsync<BinanceFuturesStreamAccountUpdate>((client, handler) => client.UsdFuturesApi.SubscribeToUserDataUpdatesAsync("123", onAccountUpdate: handler), "AccountUpdate"); - await tester.ValidateAsync<BinanceFuturesStreamOrderUpdate>((client, handler) => client.UsdFuturesApi.SubscribeToUserDataUpdatesAsync("123", onOrderUpdate : handler), "OrderUpdate", ignoreProperties: new List<string> { "si", "ss" }); - await tester.ValidateAsync<BinanceFuturesStreamTradeUpdate>((client, handler) => client.UsdFuturesApi.SubscribeToUserDataUpdatesAsync("123", onTradeUpdate: handler), "TradeUpdate"); - await tester.ValidateAsync<BinanceStrategyUpdate>((client, handler) => client.UsdFuturesApi.SubscribeToUserDataUpdatesAsync("123", onStrategyUpdate : handler), "StrategyUpdate"); - await tester.ValidateAsync<BinanceConditionOrderTriggerRejectUpdate>((client, handler) => client.UsdFuturesApi.SubscribeToUserDataUpdatesAsync("123", onConditionalOrderTriggerRejectUpdate: handler), "ConditionalTrigger"); + await tester.ValidateAsync<BinanceFuturesUsdtStreamMarkPrice>((client, handler) => client.UsdFuturesApi.ExchangeData.SubscribeToMarkPriceUpdatesAsync("BTCUSDT", 1000, handler), "MarkPrice"); + await tester.ValidateAsync<IBinanceStreamKlineData>((client, handler) => client.UsdFuturesApi.ExchangeData.SubscribeToKlineUpdatesAsync("BTCUSDT", Enums.KlineInterval.OneMonth, handler), "Klines", ignoreProperties: new List<string> { "B" }); + await tester.ValidateAsync<BinanceStreamContinuousKlineData>((client, handler) => client.UsdFuturesApi.ExchangeData.SubscribeToContinuousContractKlineUpdatesAsync("BTCUSDT", Enums.ContractType.Perpetual, Enums.KlineInterval.OneMonth, handler), "ContKlines", ignoreProperties: new List<string> { "B" }); + await tester.ValidateAsync<IBinanceMiniTick>((client, handler) => client.UsdFuturesApi.ExchangeData.SubscribeToMiniTickerUpdatesAsync("BTCUSDT", handler), "MiniTicker"); + await tester.ValidateAsync<IBinance24HPrice>((client, handler) => client.UsdFuturesApi.ExchangeData.SubscribeToTickerUpdatesAsync("BTCUSDT", handler), "Ticker"); + await tester.ValidateAsync<BinanceFuturesStreamCompositeIndex>((client, handler) => client.UsdFuturesApi.ExchangeData.SubscribeToCompositeIndexUpdatesAsync("BTCUSDT", handler), "CompositIndex"); + await tester.ValidateAsync<BinanceStreamAggregatedTrade>((client, handler) => client.UsdFuturesApi.ExchangeData.SubscribeToAggregatedTradeUpdatesAsync("BTCUSDT", handler), "AggTrades"); + await tester.ValidateAsync<BinanceFuturesStreamBookPrice>((client, handler) => client.UsdFuturesApi.ExchangeData.SubscribeToBookTickerUpdatesAsync("BTCUSDT", handler), "BookTicker"); + await tester.ValidateAsync<BinanceFuturesStreamLiquidation>((client, handler) => client.UsdFuturesApi.ExchangeData.SubscribeToLiquidationUpdatesAsync("BTCUSDT", handler), "Liquidations", "data.o", ignoreProperties: new List<string> { "e", "E" }); + await tester.ValidateAsync<IBinanceFuturesEventOrderBook>((client, handler) => client.UsdFuturesApi.ExchangeData.SubscribeToPartialOrderBookUpdatesAsync("BTCUSDT", 5, 100, handler), "PartialBook"); + await tester.ValidateAsync<IBinanceFuturesEventOrderBook>((client, handler) => client.UsdFuturesApi.ExchangeData.SubscribeToOrderBookUpdatesAsync("BTCUSDT", 100, handler), "Book"); + await tester.ValidateAsync<BinanceFuturesStreamSymbolUpdate>((client, handler) => client.UsdFuturesApi.ExchangeData.SubscribeToSymbolUpdatesAsync(handler), "SymbolUpdates"); + await tester.ValidateAsync<IEnumerable<BinanceFuturesStreamAssetIndexUpdate>>((client, handler) => client.UsdFuturesApi.ExchangeData.SubscribeToAssetIndexUpdatesAsync(handler), "AssetIndex"); + await tester.ValidateAsync<BinanceFuturesStreamConfigUpdate>((client, handler) => client.UsdFuturesApi.Account.SubscribeToUserDataUpdatesAsync("123", onLeverageUpdate: handler), "Leverage"); + await tester.ValidateAsync<BinanceFuturesStreamConfigUpdate>((client, handler) => client.UsdFuturesApi.Account.SubscribeToUserDataUpdatesAsync("123", onLeverageUpdate: handler), "MultiAssetMode"); + await tester.ValidateAsync<BinanceFuturesStreamMarginUpdate>((client, handler) => client.UsdFuturesApi.Account.SubscribeToUserDataUpdatesAsync("123", onMarginUpdate: handler), "MarginUpdate"); + await tester.ValidateAsync<BinanceFuturesStreamAccountUpdate>((client, handler) => client.UsdFuturesApi.Account.SubscribeToUserDataUpdatesAsync("123", onAccountUpdate: handler), "AccountUpdate"); + await tester.ValidateAsync<BinanceFuturesStreamOrderUpdate>((client, handler) => client.UsdFuturesApi.Account.SubscribeToUserDataUpdatesAsync("123", onOrderUpdate : handler), "OrderUpdate", ignoreProperties: new List<string> { "si", "ss" }); + await tester.ValidateAsync<BinanceFuturesStreamTradeUpdate>((client, handler) => client.UsdFuturesApi.Account.SubscribeToUserDataUpdatesAsync("123", onTradeUpdate: handler), "TradeUpdate"); + await tester.ValidateAsync<BinanceStrategyUpdate>((client, handler) => client.UsdFuturesApi.Account.SubscribeToUserDataUpdatesAsync("123", onStrategyUpdate : handler), "StrategyUpdate"); + await tester.ValidateAsync<BinanceConditionOrderTriggerRejectUpdate>((client, handler) => client.UsdFuturesApi.Account.SubscribeToUserDataUpdatesAsync("123", onConditionalOrderTriggerRejectUpdate: handler), "ConditionalTrigger"); } } } diff --git a/Binance.Net/Binance.Net.xml b/Binance.Net/Binance.Net.xml index 9ca9d8b05..a75f9b7dd 100644 --- a/Binance.Net/Binance.Net.xml +++ b/Binance.Net/Binance.Net.xml @@ -39,6 +39,11 @@ Usd futures Socket address </summary> </member> + <member name="P:Binance.Net.BinanceEnvironment.UsdFuturesSocketApiAddress"> + <summary> + Usd futures Socket address for the request API + </summary> + </member> <member name="P:Binance.Net.BinanceEnvironment.CoinFuturesRestAddress"> <summary> Coin futures Rest address @@ -64,20 +69,10 @@ Binance.us environment </summary> </member> - <member name="M:Binance.Net.BinanceEnvironment.CreateCustom(System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.String)"> + <member name="M:Binance.Net.BinanceEnvironment.CreateCustom(System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.String)"> <summary> Create a custom environment </summary> - <param name="name"></param> - <param name="spotRestAddress"></param> - <param name="spotSocketStreamsAddress"></param> - <param name="spotSocketApiAddress"></param> - <param name="blvtSocketAddress"></param> - <param name="usdFuturesRestAddress"></param> - <param name="usdFuturesSocketAddress"></param> - <param name="coinFuturesRestAddress"></param> - <param name="coinFuturesSocketAddress"></param> - <returns></returns> </member> <member name="T:Binance.Net.BinanceExchange"> <summary> @@ -2216,6 +2211,21 @@ Client providing access to the Binance Usd futures websocket Api </summary> </member> + <member name="P:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.ClientOptions"> + <inheritdoc /> + </member> + <member name="P:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.ApiOptions"> + <inheritdoc /> + </member> + <member name="P:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.Account"> + <inheritdoc /> + </member> + <member name="P:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.ExchangeData"> + <inheritdoc /> + </member> + <member name="P:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.Trading"> + <inheritdoc /> + </member> <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.#ctor(Microsoft.Extensions.Logging.ILogger,Binance.Net.Objects.Options.BinanceSocketOptions)"> <summary> Create a new instance of BinanceSocketClientUsdFuturesStreams @@ -2227,112 +2237,148 @@ <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.FormatSymbol(System.String,System.String,CryptoExchange.Net.SharedApis.TradingMode,System.Nullable{System.DateTime})"> <inheritdoc /> </member> - <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.SubscribeToMarkPriceUpdatesAsync(System.String,System.Nullable{System.Int32},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesUsdtStreamMarkPrice}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.GetListenerIdentifier(CryptoExchange.Net.Interfaces.IMessageAccessor)"> <inheritdoc /> </member> - <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.SubscribeToMarkPriceUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Nullable{System.Int32},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesUsdtStreamMarkPrice}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.GetAuthenticationRequest(CryptoExchange.Net.Sockets.SocketConnection)"> <inheritdoc /> </member> - <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.SubscribeToAllMarkPriceUpdatesAsync(System.Nullable{System.Int32},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{System.Collections.Generic.IEnumerable{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesUsdtStreamMarkPrice}}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiAccount.GetBalancesAsync(System.Nullable{System.Int64},System.Threading.CancellationToken)"> <inheritdoc /> </member> - <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.SubscribeToKlineUpdatesAsync(System.String,Binance.Net.Enums.KlineInterval,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceStreamKlineData}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiAccount.GetAccountInfoAsync(System.Nullable{System.Int64},System.Threading.CancellationToken)"> <inheritdoc /> </member> - <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.SubscribeToKlineUpdatesAsync(System.String,System.Collections.Generic.IEnumerable{Binance.Net.Enums.KlineInterval},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceStreamKlineData}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiAccount.SubscribeToUserDataUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamConfigUpdate}},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamMarginUpdate}},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamAccountUpdate}},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamOrderUpdate}},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamTradeUpdate}},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.BinanceStreamEvent}},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceStrategyUpdate}},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceGridUpdate}},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceConditionOrderTriggerRejectUpdate}},System.Threading.CancellationToken)"> <inheritdoc /> </member> - <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.SubscribeToKlineUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},Binance.Net.Enums.KlineInterval,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceStreamKlineData}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.GetOrderBookAsync(System.String,System.Nullable{System.Int32},System.Threading.CancellationToken)"> <inheritdoc /> </member> - <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.SubscribeToKlineUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Collections.Generic.IEnumerable{Binance.Net.Enums.KlineInterval},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceStreamKlineData}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.GetPriceAsync(System.String,System.Threading.CancellationToken)"> <inheritdoc /> </member> - <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.SubscribeToContinuousContractKlineUpdatesAsync(System.String,Binance.Net.Enums.ContractType,Binance.Net.Enums.KlineInterval,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceStreamContinuousKlineData}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.GetPricesAsync(System.Threading.CancellationToken)"> <inheritdoc /> </member> - <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.SubscribeToContinuousContractKlineUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},Binance.Net.Enums.ContractType,Binance.Net.Enums.KlineInterval,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceStreamContinuousKlineData}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.GetBookPriceAsync(System.String,System.Threading.CancellationToken)"> <inheritdoc /> </member> - <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.SubscribeToMiniTickerUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceMiniTick}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.GetBookPricesAsync(System.Threading.CancellationToken)"> <inheritdoc /> </member> - <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.SubscribeToMiniTickerUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceMiniTick}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.SubscribeToMarkPriceUpdatesAsync(System.String,System.Nullable{System.Int32},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesUsdtStreamMarkPrice}},System.Threading.CancellationToken)"> <inheritdoc /> </member> - <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.SubscribeToAllMiniTickerUpdatesAsync(System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{System.Collections.Generic.IEnumerable{Binance.Net.Interfaces.IBinanceMiniTick}}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.SubscribeToMarkPriceUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Nullable{System.Int32},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesUsdtStreamMarkPrice}},System.Threading.CancellationToken)"> <inheritdoc /> </member> - <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.SubscribeToTickerUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinance24HPrice}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.SubscribeToAllMarkPriceUpdatesAsync(System.Nullable{System.Int32},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{System.Collections.Generic.IEnumerable{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesUsdtStreamMarkPrice}}},System.Threading.CancellationToken)"> <inheritdoc /> </member> - <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.SubscribeToTickerUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinance24HPrice}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.SubscribeToKlineUpdatesAsync(System.String,Binance.Net.Enums.KlineInterval,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceStreamKlineData}},System.Threading.CancellationToken)"> <inheritdoc /> </member> - <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.SubscribeToCompositeIndexUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamCompositeIndex}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.SubscribeToKlineUpdatesAsync(System.String,System.Collections.Generic.IEnumerable{Binance.Net.Enums.KlineInterval},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceStreamKlineData}},System.Threading.CancellationToken)"> <inheritdoc /> </member> - <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.SubscribeToAllTickerUpdatesAsync(System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{System.Collections.Generic.IEnumerable{Binance.Net.Interfaces.IBinance24HPrice}}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.SubscribeToKlineUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},Binance.Net.Enums.KlineInterval,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceStreamKlineData}},System.Threading.CancellationToken)"> <inheritdoc /> </member> - <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.SubscribeToAggregatedTradeUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Spot.Socket.BinanceStreamAggregatedTrade}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.SubscribeToKlineUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Collections.Generic.IEnumerable{Binance.Net.Enums.KlineInterval},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceStreamKlineData}},System.Threading.CancellationToken)"> <inheritdoc /> </member> - <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.SubscribeToAggregatedTradeUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Spot.Socket.BinanceStreamAggregatedTrade}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.SubscribeToContinuousContractKlineUpdatesAsync(System.String,Binance.Net.Enums.ContractType,Binance.Net.Enums.KlineInterval,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceStreamContinuousKlineData}},System.Threading.CancellationToken)"> <inheritdoc /> </member> - <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.SubscribeToTradeUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Spot.Socket.BinanceStreamTrade}},System.Boolean,System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.SubscribeToContinuousContractKlineUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},Binance.Net.Enums.ContractType,Binance.Net.Enums.KlineInterval,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceStreamContinuousKlineData}},System.Threading.CancellationToken)"> <inheritdoc /> </member> - <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.SubscribeToTradeUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Spot.Socket.BinanceStreamTrade}},System.Boolean,System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.SubscribeToMiniTickerUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceMiniTick}},System.Threading.CancellationToken)"> <inheritdoc /> </member> - <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.SubscribeToBookTickerUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamBookPrice}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.SubscribeToMiniTickerUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceMiniTick}},System.Threading.CancellationToken)"> <inheritdoc /> </member> - <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.SubscribeToBookTickerUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamBookPrice}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.SubscribeToAllMiniTickerUpdatesAsync(System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{System.Collections.Generic.IEnumerable{Binance.Net.Interfaces.IBinanceMiniTick}}},System.Threading.CancellationToken)"> <inheritdoc /> </member> - <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.SubscribeToAllBookTickerUpdatesAsync(System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamBookPrice}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.SubscribeToTickerUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinance24HPrice}},System.Threading.CancellationToken)"> <inheritdoc /> </member> - <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.SubscribeToLiquidationUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamLiquidation}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.SubscribeToTickerUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinance24HPrice}},System.Threading.CancellationToken)"> <inheritdoc /> </member> - <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.SubscribeToLiquidationUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamLiquidation}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.SubscribeToCompositeIndexUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamCompositeIndex}},System.Threading.CancellationToken)"> <inheritdoc /> </member> - <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.SubscribeToAllLiquidationUpdatesAsync(System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamLiquidation}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.SubscribeToAllTickerUpdatesAsync(System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{System.Collections.Generic.IEnumerable{Binance.Net.Interfaces.IBinance24HPrice}}},System.Threading.CancellationToken)"> <inheritdoc /> </member> - <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.SubscribeToPartialOrderBookUpdatesAsync(System.String,System.Int32,System.Nullable{System.Int32},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceFuturesEventOrderBook}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.SubscribeToAggregatedTradeUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Spot.Socket.BinanceStreamAggregatedTrade}},System.Threading.CancellationToken)"> <inheritdoc /> </member> - <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.SubscribeToPartialOrderBookUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Int32,System.Nullable{System.Int32},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceFuturesEventOrderBook}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.SubscribeToAggregatedTradeUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Spot.Socket.BinanceStreamAggregatedTrade}},System.Threading.CancellationToken)"> <inheritdoc /> </member> - <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.SubscribeToOrderBookUpdatesAsync(System.String,System.Nullable{System.Int32},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceFuturesEventOrderBook}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.SubscribeToTradeUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Spot.Socket.BinanceStreamTrade}},System.Boolean,System.Threading.CancellationToken)"> <inheritdoc /> </member> - <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.SubscribeToOrderBookUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Nullable{System.Int32},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceFuturesEventOrderBook}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.SubscribeToTradeUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Spot.Socket.BinanceStreamTrade}},System.Boolean,System.Threading.CancellationToken)"> <inheritdoc /> </member> - <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.SubscribeToSymbolUpdatesAsync(System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamSymbolUpdate}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.SubscribeToBookTickerUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamBookPrice}},System.Threading.CancellationToken)"> <inheritdoc /> </member> - <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.SubscribeToAssetIndexUpdatesAsync(System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{System.Collections.Generic.IEnumerable{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamAssetIndexUpdate}}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.SubscribeToBookTickerUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamBookPrice}},System.Threading.CancellationToken)"> <inheritdoc /> </member> - <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.SubscribeToAssetIndexUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamAssetIndexUpdate}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.SubscribeToAllBookTickerUpdatesAsync(System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamBookPrice}},System.Threading.CancellationToken)"> <inheritdoc /> </member> - <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.SubscribeToUserDataUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamConfigUpdate}},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamMarginUpdate}},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamAccountUpdate}},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamOrderUpdate}},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamTradeUpdate}},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.BinanceStreamEvent}},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceStrategyUpdate}},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceGridUpdate}},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceConditionOrderTriggerRejectUpdate}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.SubscribeToLiquidationUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamLiquidation}},System.Threading.CancellationToken)"> <inheritdoc /> </member> - <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.GetListenerIdentifier(CryptoExchange.Net.Interfaces.IMessageAccessor)"> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.SubscribeToLiquidationUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamLiquidation}},System.Threading.CancellationToken)"> <inheritdoc /> </member> - <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.GetAuthenticationRequest(CryptoExchange.Net.Sockets.SocketConnection)"> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.SubscribeToAllLiquidationUpdatesAsync(System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamLiquidation}},System.Threading.CancellationToken)"> + <inheritdoc /> + </member> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.SubscribeToPartialOrderBookUpdatesAsync(System.String,System.Int32,System.Nullable{System.Int32},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceFuturesEventOrderBook}},System.Threading.CancellationToken)"> + <inheritdoc /> + </member> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.SubscribeToPartialOrderBookUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Int32,System.Nullable{System.Int32},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceFuturesEventOrderBook}},System.Threading.CancellationToken)"> + <inheritdoc /> + </member> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.SubscribeToOrderBookUpdatesAsync(System.String,System.Nullable{System.Int32},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceFuturesEventOrderBook}},System.Threading.CancellationToken)"> + <inheritdoc /> + </member> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.SubscribeToOrderBookUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Nullable{System.Int32},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceFuturesEventOrderBook}},System.Threading.CancellationToken)"> + <inheritdoc /> + </member> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.SubscribeToSymbolUpdatesAsync(System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamSymbolUpdate}},System.Threading.CancellationToken)"> + <inheritdoc /> + </member> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.SubscribeToAssetIndexUpdatesAsync(System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{System.Collections.Generic.IEnumerable{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamAssetIndexUpdate}}},System.Threading.CancellationToken)"> + <inheritdoc /> + </member> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiExchangeData.SubscribeToAssetIndexUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamAssetIndexUpdate}},System.Threading.CancellationToken)"> + <inheritdoc /> + </member> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiTrading.PlaceOrderAsync(System.String,Binance.Net.Enums.OrderSide,Binance.Net.Enums.FuturesOrderType,System.Nullable{System.Decimal},System.Nullable{System.Decimal},System.Nullable{Binance.Net.Enums.PositionSide},System.Nullable{Binance.Net.Enums.TimeInForce},System.Nullable{System.Boolean},System.String,System.Nullable{System.Decimal},System.Nullable{System.Decimal},System.Nullable{System.Decimal},System.Nullable{Binance.Net.Enums.WorkingType},System.Nullable{System.Boolean},System.Nullable{Binance.Net.Enums.OrderResponseType},System.Nullable{System.Boolean},System.Nullable{Binance.Net.Enums.PriceMatch},System.Nullable{Binance.Net.Enums.SelfTradePreventionMode},System.Nullable{System.DateTime},System.Nullable{System.Int32},System.Threading.CancellationToken)"> + <inheritdoc /> + </member> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiTrading.EditOrderAsync(System.String,Binance.Net.Enums.OrderSide,System.Decimal,System.Decimal,System.Nullable{System.Int64},System.String,System.Nullable{System.Int64},System.Threading.CancellationToken)"> + <inheritdoc /> + </member> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiTrading.CancelOrderAsync(System.String,System.Nullable{System.Int64},System.String,System.Nullable{System.Int64},System.Threading.CancellationToken)"> + <inheritdoc /> + </member> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiTrading.GetOrderAsync(System.String,System.Nullable{System.Int64},System.String,System.Nullable{System.Int64},System.Threading.CancellationToken)"> + <inheritdoc /> + </member> + <member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApiTrading.GetPositionsAsync(System.String,System.Nullable{System.Int64},System.Threading.CancellationToken)"> <inheritdoc /> </member> <member name="M:Binance.Net.Converters.SymbolFilterConverter.CreateConverter(System.Type,System.Text.Json.JsonSerializerOptions)"> @@ -11408,7 +11454,7 @@ <param name="ct">Cancellation token</param> </member> <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceRestClientUsdFuturesApiAccount.GetBalancesAsync(System.Nullable{System.Int64},System.Threading.CancellationToken)"> - <summary>. + <summary> Gets account balances <para><a href="https://binance-docs.github.io/apidocs/futures/en/#futures-account-balance-v2-user_data" /></para> </summary> @@ -11417,7 +11463,7 @@ <returns>The account information</returns> </member> <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceRestClientUsdFuturesApiAccount.GetMultiAssetsModeAsync(System.Nullable{System.Int64},System.Threading.CancellationToken)"> - <summary>. + <summary> Get user's Multi-Assets mode (Multi-Assets Mode or Single-Asset Mode) on Every symbol <para><a href="https://binance-docs.github.io/apidocs/futures/en/#get-current-multi-assets-mode-user_data" /></para> </summary> @@ -11426,7 +11472,7 @@ <returns>Multi asset mode</returns> </member> <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceRestClientUsdFuturesApiAccount.SetMultiAssetsModeAsync(System.Boolean,System.Nullable{System.Int64},System.Threading.CancellationToken)"> - <summary>. + <summary> Set user's Multi-Assets mode (Multi-Assets Mode or Single-Asset Mode) on Every symbol <para><a href="https://binance-docs.github.io/apidocs/futures/en/#change-multi-assets-mode-trade" /></para> </summary> @@ -12277,7 +12323,110 @@ Get the shared socket subscription client. This interface is shared with other exhanges to allow for a common implementation for different exchanges. </summary> </member> - <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.SubscribeToAggregatedTradeUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Spot.Socket.BinanceStreamAggregatedTrade}},System.Threading.CancellationToken)"> + <member name="P:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.Account"> + <summary> + Account streams and queries + </summary> + </member> + <member name="P:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.ExchangeData"> + <summary> + Exchange data streams and queries + </summary> + </member> + <member name="P:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.Trading"> + <summary> + Trading data and queries + </summary> + </member> + <member name="T:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiAccount"> + <summary> + Binance USD futures account websocket API + </summary> + </member> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiAccount.GetBalancesAsync(System.Nullable{System.Int64},System.Threading.CancellationToken)"> + <summary> + Gets account balances + <para><a href="https://binance-docs.github.io/apidocs/futures/en/#futures-account-balance-v2-user_data" /></para> + </summary> + <param name="receiveWindow">The receive window for which this request is active. When the request takes longer than this to complete the server will reject the request</param> + <param name="ct">Cancellation token</param> + <returns>The account information</returns> + </member> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiAccount.GetAccountInfoAsync(System.Nullable{System.Int64},System.Threading.CancellationToken)"> + <summary> + Get account information, including position and balances + <para><a href="https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Information-V3" /></para> + </summary> + <param name="receiveWindow">The receive window for which this request is active. When the request takes longer than this to complete the server will reject the request</param> + <param name="ct">Cancellation token</param> + </member> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiAccount.SubscribeToUserDataUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamConfigUpdate}},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamMarginUpdate}},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamAccountUpdate}},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamOrderUpdate}},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamTradeUpdate}},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.BinanceStreamEvent}},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceStrategyUpdate}},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceGridUpdate}},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceConditionOrderTriggerRejectUpdate}},System.Threading.CancellationToken)"> + <summary> + Subscribes to the account update stream. Prior to using this, the <see cref="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceRestClientUsdFuturesApiAccount.StartUserStreamAsync(System.Threading.CancellationToken)">restClient.UsdFuturesApi.Account.StartUserStreamAsync</see> method should be called to start the stream and obtaining a listen key. + <para><a href="https://binance-docs.github.io/apidocs/futures/en/#user-data-streams" /></para> + </summary> + <param name="listenKey">Listen key retrieved by the <see cref="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceRestClientUsdFuturesApiAccount.StartUserStreamAsync(System.Threading.CancellationToken)">restClient.UsdFuturesApi.Account.StartUserStreamAsync</see> method</param> + <param name="onLeverageUpdate">The event handler for leverage changed update</param> + <param name="onMarginUpdate">The event handler for whenever a margin has changed</param> + <param name="onAccountUpdate">The event handler for whenever an account update is received</param> + <param name="onOrderUpdate">The event handler for whenever an order status update is received</param> + <param name="onTradeUpdate">The event handler for whenever an trade status update is received</param> + <param name="onListenKeyExpired">Responds when the listen key for the stream has expired. Initiate a new instance of the stream here</param> + <param name="onStrategyUpdate">The event handler for whenever a strategy update is received</param> + <param name="onGridUpdate">The event handler for whenever a grid update is received</param> + <param name="onConditionalOrderTriggerRejectUpdate">The event handler for whenever a trigger order failed to place an order</param> + <param name="ct">Cancellation token for closing this subscription</param> + <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> + </member> + <member name="T:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData"> + <summary> + Binance USD futures exchange data websocket API + </summary> + </member> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.GetOrderBookAsync(System.String,System.Nullable{System.Int32},System.Threading.CancellationToken)"> + <summary> + Gets the order book for the provided symbol + <para><a href="https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/websocket-api" /></para> + </summary> + <param name="symbol">The symbol to get the order book for, for example `ETHUSDT`</param> + <param name="limit">Max number of results</param> + <param name="ct">Cancellation token</param> + </member> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.GetPriceAsync(System.String,System.Threading.CancellationToken)"> + <summary> + Gets the price of a symbol + <para><a href="https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/websocket-api/Symbol-Price-Ticker" /></para> + </summary> + <param name="symbol">The symbol to get the price for, for example `ETHUSDT`</param> + <param name="ct">Cancellation token</param> + <returns>Price of symbol</returns> + </member> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.GetPricesAsync(System.Threading.CancellationToken)"> + <summary> + Gets the price of all symbols + <para><a href="https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/websocket-api/Symbol-Price-Ticker" /></para> + </summary> + <param name="ct">Cancellation token</param> + <returns>Price of symbol</returns> + </member> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.GetBookPriceAsync(System.String,System.Threading.CancellationToken)"> + <summary> + Gets the best price/quantity on the order book for a symbol. + <para><a href="https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/websocket-api/Symbol-Order-Book-Ticker" /></para> + </summary> + <param name="symbol">Symbol to get book price for, for example `ETHUSDT`</param> + <param name="ct">Cancellation token</param> + <returns>List of book prices</returns> + </member> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.GetBookPricesAsync(System.Threading.CancellationToken)"> + <summary> + Gets the best price/quantity on the order book for all symbols. + <para><a href="https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/websocket-api/Symbol-Order-Book-Ticker" /></para> + </summary> + <param name="ct">Cancellation token</param> + <returns>List of book prices</returns> + </member> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.SubscribeToAggregatedTradeUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Spot.Socket.BinanceStreamAggregatedTrade}},System.Threading.CancellationToken)"> <summary> Subscribes to the aggregated trades update stream for the provided symbol <para><a href="https://binance-docs.github.io/apidocs/futures/en/#aggregate-trade-streams" /></para> @@ -12287,7 +12436,7 @@ <param name="ct">Cancellation token for closing this subscription</param> <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> </member> - <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.SubscribeToTradeUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Spot.Socket.BinanceStreamTrade}},System.Boolean,System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.SubscribeToTradeUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Spot.Socket.BinanceStreamTrade}},System.Boolean,System.Threading.CancellationToken)"> <summary> Subscribe to individual trade update. NOTE: This endpoint stream isn't document and therefor might be changed or removed without prior notice </summary> @@ -12297,7 +12446,7 @@ <param name="ct">Cancellation token for closing this subscription</param> <returns></returns> </member> - <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.SubscribeToTradeUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Spot.Socket.BinanceStreamTrade}},System.Boolean,System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.SubscribeToTradeUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Spot.Socket.BinanceStreamTrade}},System.Boolean,System.Threading.CancellationToken)"> <summary> Subscribe to individual trade update. NOTE: This endpoint stream isn't document and therefor might be changed or removed without prior notice </summary> @@ -12307,7 +12456,7 @@ <param name="ct">Cancellation token for closing this subscription</param> <returns></returns> </member> - <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.SubscribeToAggregatedTradeUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Spot.Socket.BinanceStreamAggregatedTrade}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.SubscribeToAggregatedTradeUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Spot.Socket.BinanceStreamAggregatedTrade}},System.Threading.CancellationToken)"> <summary> Subscribes to the aggregated trades update stream for the provided symbols <para><a href="https://binance-docs.github.io/apidocs/futures/en/#aggregate-trade-streams" /></para> @@ -12317,7 +12466,7 @@ <param name="ct">Cancellation token for closing this subscription</param> <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> </member> - <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.SubscribeToMarkPriceUpdatesAsync(System.String,System.Nullable{System.Int32},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesUsdtStreamMarkPrice}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.SubscribeToMarkPriceUpdatesAsync(System.String,System.Nullable{System.Int32},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesUsdtStreamMarkPrice}},System.Threading.CancellationToken)"> <summary> Subscribes to the Mark price update stream for a single symbol <para><a href="https://binance-docs.github.io/apidocs/futures/en/#mark-price-stream" /></para> @@ -12328,7 +12477,7 @@ <param name="ct">Cancellation token for closing this subscription</param> <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> </member> - <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.SubscribeToMarkPriceUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Nullable{System.Int32},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesUsdtStreamMarkPrice}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.SubscribeToMarkPriceUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Nullable{System.Int32},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesUsdtStreamMarkPrice}},System.Threading.CancellationToken)"> <summary> Subscribes to the Mark price update stream for a list of symbols <para><a href="https://binance-docs.github.io/apidocs/futures/en/#mark-price-stream" /></para> @@ -12339,7 +12488,7 @@ <param name="ct">Cancellation token for closing this subscription</param> <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> </member> - <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.SubscribeToKlineUpdatesAsync(System.String,Binance.Net.Enums.KlineInterval,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceStreamKlineData}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.SubscribeToKlineUpdatesAsync(System.String,Binance.Net.Enums.KlineInterval,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceStreamKlineData}},System.Threading.CancellationToken)"> <summary> Subscribes to the candlestick update stream for the provided symbol <para><a href="https://binance-docs.github.io/apidocs/futures/en/#kline-candlestick-streams" /></para> @@ -12350,7 +12499,7 @@ <param name="ct">Cancellation token for closing this subscription</param> <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> </member> - <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.SubscribeToKlineUpdatesAsync(System.String,System.Collections.Generic.IEnumerable{Binance.Net.Enums.KlineInterval},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceStreamKlineData}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.SubscribeToKlineUpdatesAsync(System.String,System.Collections.Generic.IEnumerable{Binance.Net.Enums.KlineInterval},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceStreamKlineData}},System.Threading.CancellationToken)"> <summary> Subscribes to the candlestick update stream for the provided symbol and intervals <para><a href="https://binance-docs.github.io/apidocs/futures/en/#kline-candlestick-streams" /></para> @@ -12361,7 +12510,7 @@ <param name="ct">Cancellation token for closing this subscription</param> <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> </member> - <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.SubscribeToKlineUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},Binance.Net.Enums.KlineInterval,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceStreamKlineData}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.SubscribeToKlineUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},Binance.Net.Enums.KlineInterval,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceStreamKlineData}},System.Threading.CancellationToken)"> <summary> Subscribes to the candlestick update stream for the provided symbols <para><a href="https://binance-docs.github.io/apidocs/futures/en/#kline-candlestick-streams" /></para> @@ -12372,7 +12521,7 @@ <param name="ct">Cancellation token for closing this subscription</param> <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> </member> - <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.SubscribeToKlineUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Collections.Generic.IEnumerable{Binance.Net.Enums.KlineInterval},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceStreamKlineData}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.SubscribeToKlineUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Collections.Generic.IEnumerable{Binance.Net.Enums.KlineInterval},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceStreamKlineData}},System.Threading.CancellationToken)"> <summary> Subscribes to the candlestick update stream for the provided symbols and intervals <para><a href="https://binance-docs.github.io/apidocs/futures/en/#kline-candlestick-streams" /></para> @@ -12383,7 +12532,7 @@ <param name="ct">Cancellation token for closing this subscription</param> <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> </member> - <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.SubscribeToContinuousContractKlineUpdatesAsync(System.String,Binance.Net.Enums.ContractType,Binance.Net.Enums.KlineInterval,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceStreamContinuousKlineData}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.SubscribeToContinuousContractKlineUpdatesAsync(System.String,Binance.Net.Enums.ContractType,Binance.Net.Enums.KlineInterval,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceStreamContinuousKlineData}},System.Threading.CancellationToken)"> <summary> Subscribes to the continuous contract candlestick update stream for the provided pair <para><a href="https://binance-docs.github.io/apidocs/futures/en/#continuous-contract-kline-candlestick-streams" /></para> @@ -12395,7 +12544,7 @@ <param name="ct">Cancellation token for closing this subscription</param> <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> </member> - <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.SubscribeToContinuousContractKlineUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},Binance.Net.Enums.ContractType,Binance.Net.Enums.KlineInterval,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceStreamContinuousKlineData}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.SubscribeToContinuousContractKlineUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},Binance.Net.Enums.ContractType,Binance.Net.Enums.KlineInterval,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceStreamContinuousKlineData}},System.Threading.CancellationToken)"> <summary> Subscribes to the continuous contract candlestick update stream for the provided pairs <para><a href="https://binance-docs.github.io/apidocs/futures/en/#continuous-contract-kline-candlestick-streams" /></para> @@ -12407,7 +12556,7 @@ <param name="ct">Cancellation token for closing this subscription</param> <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> </member> - <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.SubscribeToMiniTickerUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceMiniTick}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.SubscribeToMiniTickerUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceMiniTick}},System.Threading.CancellationToken)"> <summary> Subscribes to mini ticker updates stream for a specific symbol <para><a href="https://binance-docs.github.io/apidocs/futures/en/#individual-symbol-mini-ticker-stream" /></para> @@ -12417,7 +12566,7 @@ <param name="ct">Cancellation token for closing this subscription</param> <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> </member> - <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.SubscribeToMiniTickerUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceMiniTick}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.SubscribeToMiniTickerUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceMiniTick}},System.Threading.CancellationToken)"> <summary> Subscribes to mini ticker updates stream for a list of symbol <para><a href="https://binance-docs.github.io/apidocs/futures/en/#individual-symbol-mini-ticker-stream" /></para> @@ -12427,7 +12576,7 @@ <param name="ct">Cancellation token for closing this subscription</param> <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> </member> - <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.SubscribeToAllMiniTickerUpdatesAsync(System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{System.Collections.Generic.IEnumerable{Binance.Net.Interfaces.IBinanceMiniTick}}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.SubscribeToAllMiniTickerUpdatesAsync(System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{System.Collections.Generic.IEnumerable{Binance.Net.Interfaces.IBinanceMiniTick}}},System.Threading.CancellationToken)"> <summary> Subscribes to mini ticker updates stream for all symbols <para><a href="https://binance-docs.github.io/apidocs/futures/en/#all-market-mini-tickers-stream" /></para> @@ -12436,7 +12585,7 @@ <param name="ct">Cancellation token for closing this subscription</param> <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> </member> - <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.SubscribeToTickerUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinance24HPrice}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.SubscribeToTickerUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinance24HPrice}},System.Threading.CancellationToken)"> <summary> Subscribes to ticker updates stream for a specific symbol <para><a href="https://binance-docs.github.io/apidocs/futures/en/#individual-symbol-ticker-streams" /></para> @@ -12446,7 +12595,7 @@ <param name="ct">Cancellation token for closing this subscription</param> <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> </member> - <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.SubscribeToTickerUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinance24HPrice}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.SubscribeToTickerUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinance24HPrice}},System.Threading.CancellationToken)"> <summary> Subscribes to ticker updates stream for a specific symbol <para><a href="https://binance-docs.github.io/apidocs/futures/en/#individual-symbol-ticker-streams" /></para> @@ -12456,7 +12605,7 @@ <param name="ct">Cancellation token for closing this subscription</param> <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> </member> - <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.SubscribeToAllTickerUpdatesAsync(System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{System.Collections.Generic.IEnumerable{Binance.Net.Interfaces.IBinance24HPrice}}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.SubscribeToAllTickerUpdatesAsync(System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{System.Collections.Generic.IEnumerable{Binance.Net.Interfaces.IBinance24HPrice}}},System.Threading.CancellationToken)"> <summary> Subscribes to ticker updates stream for all symbols <para><a href="https://binance-docs.github.io/apidocs/futures/en/#all-market-tickers-streams" /></para> @@ -12465,7 +12614,7 @@ <param name="ct">Cancellation token for closing this subscription</param> <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> </member> - <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.SubscribeToAllBookTickerUpdatesAsync(System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamBookPrice}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.SubscribeToAllBookTickerUpdatesAsync(System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamBookPrice}},System.Threading.CancellationToken)"> <summary> Subscribes to all book ticker update streams <para><a href="https://binance-docs.github.io/apidocs/futures/en/#all-book-tickers-stream" /></para> @@ -12474,7 +12623,7 @@ <param name="ct">Cancellation token for closing this subscription</param> <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> </member> - <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.SubscribeToBookTickerUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamBookPrice}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.SubscribeToBookTickerUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamBookPrice}},System.Threading.CancellationToken)"> <summary> Subscribes to the book ticker update stream for the provided symbol <para><a href="https://binance-docs.github.io/apidocs/futures/en/#individual-symbol-book-ticker-streams" /></para> @@ -12484,7 +12633,7 @@ <param name="ct">Cancellation token for closing this subscription</param> <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> </member> - <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.SubscribeToBookTickerUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamBookPrice}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.SubscribeToBookTickerUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamBookPrice}},System.Threading.CancellationToken)"> <summary> Subscribes to the book ticker update stream for the provided symbols <para><a href="https://binance-docs.github.io/apidocs/futures/en/#individual-symbol-book-ticker-streams" /></para> @@ -12494,7 +12643,7 @@ <param name="ct">Cancellation token for closing this subscription</param> <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> </member> - <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.SubscribeToLiquidationUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamLiquidation}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.SubscribeToLiquidationUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamLiquidation}},System.Threading.CancellationToken)"> <summary> Subscribes to specific symbol forced liquidations stream <para><a href="https://binance-docs.github.io/apidocs/futures/en/#liquidation-order-streams" /></para> @@ -12504,7 +12653,7 @@ <param name="onMessage">The event handler for the received data</param> <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> </member> - <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.SubscribeToLiquidationUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamLiquidation}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.SubscribeToLiquidationUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamLiquidation}},System.Threading.CancellationToken)"> <summary> Subscribes to list of symbol forced liquidations stream <para><a href="https://binance-docs.github.io/apidocs/futures/en/#liquidation-order-streams" /></para> @@ -12514,7 +12663,7 @@ <param name="ct">Cancellation token for closing this subscription</param> <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> </member> - <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.SubscribeToAllLiquidationUpdatesAsync(System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamLiquidation}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.SubscribeToAllLiquidationUpdatesAsync(System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamLiquidation}},System.Threading.CancellationToken)"> <summary> Subscribes to all forced liquidations stream <para><a href="https://binance-docs.github.io/apidocs/futures/en/#all-market-liquidation-order-streams" /></para> @@ -12523,7 +12672,7 @@ <param name="ct">Cancellation token for closing this subscription</param> <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> </member> - <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.SubscribeToPartialOrderBookUpdatesAsync(System.String,System.Int32,System.Nullable{System.Int32},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceFuturesEventOrderBook}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.SubscribeToPartialOrderBookUpdatesAsync(System.String,System.Int32,System.Nullable{System.Int32},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceFuturesEventOrderBook}},System.Threading.CancellationToken)"> <summary> Subscribes to the depth updates for the provided symbol <para><a href="https://binance-docs.github.io/apidocs/futures/en/#partial-book-depth-streams" /></para> @@ -12535,7 +12684,7 @@ <param name="ct">Cancellation token for closing this subscription</param> <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> </member> - <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.SubscribeToPartialOrderBookUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Int32,System.Nullable{System.Int32},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceFuturesEventOrderBook}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.SubscribeToPartialOrderBookUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Int32,System.Nullable{System.Int32},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceFuturesEventOrderBook}},System.Threading.CancellationToken)"> <summary> Subscribes to the depth updates for the provided symbols <para><a href="https://binance-docs.github.io/apidocs/futures/en/#partial-book-depth-streams" /></para> @@ -12547,7 +12696,7 @@ <param name="ct">Cancellation token for closing this subscription</param> <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> </member> - <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.SubscribeToOrderBookUpdatesAsync(System.String,System.Nullable{System.Int32},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceFuturesEventOrderBook}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.SubscribeToOrderBookUpdatesAsync(System.String,System.Nullable{System.Int32},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceFuturesEventOrderBook}},System.Threading.CancellationToken)"> <summary> Subscribes to the order book updates for the provided symbol <para><a href="https://binance-docs.github.io/apidocs/futures/en/#diff-book-depth-streams" /></para> @@ -12558,7 +12707,7 @@ <param name="ct">Cancellation token for closing this subscription</param> <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> </member> - <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.SubscribeToOrderBookUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Nullable{System.Int32},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceFuturesEventOrderBook}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.SubscribeToOrderBookUpdatesAsync(System.Collections.Generic.IEnumerable{System.String},System.Nullable{System.Int32},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Interfaces.IBinanceFuturesEventOrderBook}},System.Threading.CancellationToken)"> <summary> Subscribes to the depth update stream for the provided symbols <para><a href="https://binance-docs.github.io/apidocs/futures/en/#diff-book-depth-streams" /></para> @@ -12569,7 +12718,7 @@ <param name="ct">Cancellation token for closing this subscription</param> <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> </member> - <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.SubscribeToSymbolUpdatesAsync(System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamSymbolUpdate}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.SubscribeToSymbolUpdatesAsync(System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamSymbolUpdate}},System.Threading.CancellationToken)"> <summary> Subscribe to contract/symbol updates </summary> @@ -12577,25 +12726,7 @@ <param name="ct">Cancellation token for closing this subscription</param> <returns></returns> </member> - <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.SubscribeToUserDataUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamConfigUpdate}},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamMarginUpdate}},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamAccountUpdate}},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamOrderUpdate}},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamTradeUpdate}},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.BinanceStreamEvent}},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceStrategyUpdate}},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceGridUpdate}},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceConditionOrderTriggerRejectUpdate}},System.Threading.CancellationToken)"> - <summary> - Subscribes to the account update stream. Prior to using this, the <see cref="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceRestClientUsdFuturesApiAccount.StartUserStreamAsync(System.Threading.CancellationToken)">restClient.UsdFuturesApi.Account.StartUserStreamAsync</see> method should be called to start the stream and obtaining a listen key. - <para><a href="https://binance-docs.github.io/apidocs/futures/en/#user-data-streams" /></para> - </summary> - <param name="listenKey">Listen key retrieved by the <see cref="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceRestClientUsdFuturesApiAccount.StartUserStreamAsync(System.Threading.CancellationToken)">restClient.UsdFuturesApi.Account.StartUserStreamAsync</see> method</param> - <param name="onLeverageUpdate">The event handler for leverage changed update</param> - <param name="onMarginUpdate">The event handler for whenever a margin has changed</param> - <param name="onAccountUpdate">The event handler for whenever an account update is received</param> - <param name="onOrderUpdate">The event handler for whenever an order status update is received</param> - <param name="onTradeUpdate">The event handler for whenever an trade status update is received</param> - <param name="onListenKeyExpired">Responds when the listen key for the stream has expired. Initiate a new instance of the stream here</param> - <param name="onStrategyUpdate">The event handler for whenever a strategy update is received</param> - <param name="onGridUpdate">The event handler for whenever a grid update is received</param> - <param name="onConditionalOrderTriggerRejectUpdate">The event handler for whenever a trigger order failed to place an order</param> - <param name="ct">Cancellation token for closing this subscription</param> - <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> - </member> - <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.SubscribeToAllMarkPriceUpdatesAsync(System.Nullable{System.Int32},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{System.Collections.Generic.IEnumerable{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesUsdtStreamMarkPrice}}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.SubscribeToAllMarkPriceUpdatesAsync(System.Nullable{System.Int32},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{System.Collections.Generic.IEnumerable{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesUsdtStreamMarkPrice}}},System.Threading.CancellationToken)"> <summary> Subscribes to the Mark price update stream for a all symbols <para><a href="https://binance-docs.github.io/apidocs/futures/en/#mark-price-stream-for-all-market" /></para> @@ -12605,7 +12736,7 @@ <param name="ct">Cancellation token for closing this subscription</param> <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> </member> - <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.SubscribeToCompositeIndexUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamCompositeIndex}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.SubscribeToCompositeIndexUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamCompositeIndex}},System.Threading.CancellationToken)"> <summary> Subscribes to composite index updates stream for a symbol <para><a href="https://binance-docs.github.io/apidocs/futures/en/#composite-index-symbol-information-streams" /></para> @@ -12615,7 +12746,7 @@ <param name="ct">Cancellation token for closing this subscription</param> <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> </member> - <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.SubscribeToAssetIndexUpdatesAsync(System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{System.Collections.Generic.IEnumerable{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamAssetIndexUpdate}}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.SubscribeToAssetIndexUpdatesAsync(System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{System.Collections.Generic.IEnumerable{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamAssetIndexUpdate}}},System.Threading.CancellationToken)"> <summary> Subscribe to asset index updates stream <para><a href="https://binance-docs.github.io/apidocs/futures/en/#multi-assets-mode-asset-index-2" /></para> @@ -12624,7 +12755,7 @@ <param name="ct">Cancellation token for closing this subscription</param> <returns></returns> </member> - <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.SubscribeToAssetIndexUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamAssetIndexUpdate}},System.Threading.CancellationToken)"> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiExchangeData.SubscribeToAssetIndexUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamAssetIndexUpdate}},System.Threading.CancellationToken)"> <summary> Subscribe to asset index updates for a single <para><a href="https://binance-docs.github.io/apidocs/futures/en/#multi-assets-mode-asset-index-2" /></para> @@ -12639,6 +12770,86 @@ Shared interface for USD-M Futures socket API usage </summary> </member> + <member name="T:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiTrading"> + <summary> + Binance USD futures trading websocket API + </summary> + </member> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiTrading.PlaceOrderAsync(System.String,Binance.Net.Enums.OrderSide,Binance.Net.Enums.FuturesOrderType,System.Nullable{System.Decimal},System.Nullable{System.Decimal},System.Nullable{Binance.Net.Enums.PositionSide},System.Nullable{Binance.Net.Enums.TimeInForce},System.Nullable{System.Boolean},System.String,System.Nullable{System.Decimal},System.Nullable{System.Decimal},System.Nullable{System.Decimal},System.Nullable{Binance.Net.Enums.WorkingType},System.Nullable{System.Boolean},System.Nullable{Binance.Net.Enums.OrderResponseType},System.Nullable{System.Boolean},System.Nullable{Binance.Net.Enums.PriceMatch},System.Nullable{Binance.Net.Enums.SelfTradePreventionMode},System.Nullable{System.DateTime},System.Nullable{System.Int32},System.Threading.CancellationToken)"> + <summary> + Place a new order + <para><a href="https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/websocket-api" /></para> + </summary> + <param name="symbol">The symbol the order is for, for example `ETHUSDT`</param> + <param name="side">The order side (buy/sell)</param> + <param name="type">The order type</param> + <param name="timeInForce">Lifetime of the order (GoodTillCancel/ImmediateOrCancel/FillOrKill)</param> + <param name="quantity">The quantity of the base symbol</param> + <param name="positionSide">The position side</param> + <param name="reduceOnly">Specify as true if the order is intended to only reduce the position</param> + <param name="price">The price to use</param> + <param name="newClientOrderId">Unique id for order</param> + <param name="stopPrice">Used for stop orders</param> + <param name="activationPrice">Used with TRAILING_STOP_MARKET orders, default as the latest price(supporting different workingType)</param> + <param name="callbackRate">Used with TRAILING_STOP_MARKET orders</param> + <param name="workingType">stopPrice triggered by: "MARK_PRICE", "CONTRACT_PRICE"</param> + <param name="closePosition">Close-All,used with STOP_MARKET or TAKE_PROFIT_MARKET.</param> + <param name="orderResponseType">The response type. Default Acknowledge</param> + <param name="priceProtect">If true when price reaches stopPrice, difference between "MARK_PRICE" and "CONTRACT_PRICE" cannot be larger than "triggerProtect" of the symbol.</param> + <param name="priceMatch">Only avaliable for Limit/Stop/TakeProfit order</param> + <param name="selfTradePreventionMode">Self trade prevention mode</param> + <param name="goodTillDate">Order cancel time for timeInForce GoodTillDate</param> + <param name="receiveWindow">The receive window for which this request is active. When the request takes longer than this to complete the server will reject the request</param> + <param name="ct">Cancellation token</param> + </member> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiTrading.EditOrderAsync(System.String,Binance.Net.Enums.OrderSide,System.Decimal,System.Decimal,System.Nullable{System.Int64},System.String,System.Nullable{System.Int64},System.Threading.CancellationToken)"> + <summary> + Edit an existing order + <para><a href="https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/websocket-api/Modify-Order" /></para> + </summary> + <param name="symbol">The symbol, for example `ETHUSDT`</param> + <param name="side">Order side</param> + <param name="quantity">New quantity</param> + <param name="price">New price</param> + <param name="orderId">Order id of the order to edit</param> + <param name="origClientOrderId">Client order id of the order to edit</param> + <param name="receiveWindow">The receive window for which this request is active. When the request takes longer than this to complete the server will reject the request</param> + <param name="ct">Cancellation token</param> + <returns></returns> + </member> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiTrading.CancelOrderAsync(System.String,System.Nullable{System.Int64},System.String,System.Nullable{System.Int64},System.Threading.CancellationToken)"> + <summary> + Cancels a pending order + <para><a href="https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/websocket-api/Cancel-Order" /></para> + </summary> + <param name="symbol">The symbol the order is for, for example `ETHUSDT`</param> + <param name="orderId">The order id of the order</param> + <param name="origClientOrderId">The client order id of the order</param> + <param name="receiveWindow">The receive window for which this request is active. When the request takes longer than this to complete the server will reject the request</param> + <param name="ct">Cancellation token</param> + <returns>Id's for canceled order</returns> + </member> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiTrading.GetOrderAsync(System.String,System.Nullable{System.Int64},System.String,System.Nullable{System.Int64},System.Threading.CancellationToken)"> + <summary> + Retrieves data for a specific order. Either orderId or origClientOrderId should be provided. + <para><a href="https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/websocket-api/Query-Order" /></para> + </summary> + <param name="symbol">The symbol the order is for, for example `ETHUSDT`</param> + <param name="orderId">The order id of the order</param> + <param name="origClientOrderId">The client order id of the order</param> + <param name="receiveWindow">The receive window for which this request is active. When the request takes longer than this to complete the server will reject the request</param> + <param name="ct">Cancellation token</param> + <returns>The specific order</returns> + </member> + <member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiTrading.GetPositionsAsync(System.String,System.Nullable{System.Int64},System.Threading.CancellationToken)"> + <summary> + Get position information + <para><a href="https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/websocket-api/Position-Info-V2" /></para> + </summary> + <param name="symbol">Filter by symbol, for example `ETHUSDT`</param> + <param name="receiveWindow">The receive window for which this request is active. When the request takes longer than this to complete the server will reject the request</param> + <param name="ct">Cancellation token</param> + </member> <member name="T:Binance.Net.Interfaces.IBinance24HPrice"> <summary> 24 hour price stats @@ -13239,6 +13450,11 @@ </summary> </member> <member name="P:Binance.Net.Objects.BinanceApiAddresses.UsdFuturesSocketClientAddress"> + <summary> + The address used by the BinanceSocketClient for the USD futures streams + </summary> + </member> + <member name="P:Binance.Net.Objects.BinanceApiAddresses.UsdFuturesSocketApiClientAddress"> <summary> The address used by the BinanceSocketClient for the USD futures API </summary> diff --git a/Binance.Net/BinanceEnvironment.cs b/Binance.Net/BinanceEnvironment.cs index 632853396..465c6b217 100644 --- a/Binance.Net/BinanceEnvironment.cs +++ b/Binance.Net/BinanceEnvironment.cs @@ -37,6 +37,11 @@ public class BinanceEnvironment : TradeEnvironment /// </summary> public string? UsdFuturesSocketAddress { get; } + /// <summary> + /// Usd futures Socket address for the request API + /// </summary> + public string? UsdFuturesSocketApiAddress { get; } + /// <summary> /// Coin futures Rest address /// </summary> @@ -55,6 +60,7 @@ internal BinanceEnvironment( string? blvtSocketAddress, string? usdFuturesRestAddress, string? usdFuturesSocketAddress, + string? usdFuturesSocketApiAddress, string? coinFuturesRestAddress, string? coinFuturesSocketAddress) : base(name) @@ -65,6 +71,7 @@ internal BinanceEnvironment( BlvtSocketAddress = blvtSocketAddress; UsdFuturesRestAddress = usdFuturesRestAddress; UsdFuturesSocketAddress = usdFuturesSocketAddress; + UsdFuturesSocketApiAddress = usdFuturesSocketApiAddress; CoinFuturesRestAddress = coinFuturesRestAddress; CoinFuturesSocketAddress = coinFuturesSocketAddress; } @@ -80,6 +87,7 @@ internal BinanceEnvironment( BinanceApiAddresses.Default.BlvtSocketClientAddress, BinanceApiAddresses.Default.UsdFuturesRestClientAddress, BinanceApiAddresses.Default.UsdFuturesSocketClientAddress, + BinanceApiAddresses.Default.UsdFuturesSocketApiClientAddress, BinanceApiAddresses.Default.CoinFuturesRestClientAddress, BinanceApiAddresses.Default.CoinFuturesSocketClientAddress); @@ -94,6 +102,7 @@ internal BinanceEnvironment( BinanceApiAddresses.TestNet.BlvtSocketClientAddress, BinanceApiAddresses.TestNet.UsdFuturesRestClientAddress, BinanceApiAddresses.TestNet.UsdFuturesSocketClientAddress, + BinanceApiAddresses.TestNet.UsdFuturesSocketApiClientAddress, BinanceApiAddresses.TestNet.CoinFuturesRestClientAddress, BinanceApiAddresses.TestNet.CoinFuturesSocketClientAddress); @@ -109,21 +118,12 @@ internal BinanceEnvironment( null, null, null, + null, null); /// <summary> /// Create a custom environment /// </summary> - /// <param name="name"></param> - /// <param name="spotRestAddress"></param> - /// <param name="spotSocketStreamsAddress"></param> - /// <param name="spotSocketApiAddress"></param> - /// <param name="blvtSocketAddress"></param> - /// <param name="usdFuturesRestAddress"></param> - /// <param name="usdFuturesSocketAddress"></param> - /// <param name="coinFuturesRestAddress"></param> - /// <param name="coinFuturesSocketAddress"></param> - /// <returns></returns> public static BinanceEnvironment CreateCustom( string name, string spotRestAddress, @@ -132,8 +132,9 @@ public static BinanceEnvironment CreateCustom( string? blvtSocketAddress, string? usdFuturesRestAddress, string? usdFuturesSocketAddress, + string? usdFuturesSocketApiAddress, string? coinFuturesRestAddress, string? coinFuturesSocketAddress) - => new BinanceEnvironment(name, spotRestAddress, spotSocketStreamsAddress, spotSocketApiAddress, blvtSocketAddress, usdFuturesRestAddress, usdFuturesSocketAddress, coinFuturesRestAddress, coinFuturesSocketAddress); + => new BinanceEnvironment(name, spotRestAddress, spotSocketStreamsAddress, spotSocketApiAddress, blvtSocketAddress, usdFuturesRestAddress, usdFuturesSocketAddress, usdFuturesSocketApiAddress, coinFuturesRestAddress, coinFuturesSocketAddress); } } diff --git a/Binance.Net/BinanceExchange.cs b/Binance.Net/BinanceExchange.cs index b732df0a5..60358f298 100644 --- a/Binance.Net/BinanceExchange.cs +++ b/Binance.Net/BinanceExchange.cs @@ -67,7 +67,9 @@ private void Initialize() .AddGuard(new RateLimitGuard(RateLimitGuard.PerHost, new IGuardFilter[] { new HostFilter("https://fapi.binance.com") }, 2400, TimeSpan.FromMinutes(1), RateLimitWindowType.Fixed)) // IP limit of 2400 request weight per minute to fapi.binance.com host .AddGuard(new RateLimitGuard(RateLimitGuard.PerHost, new IGuardFilter[] { new HostFilter("https://dapi.binance.com") }, 2400, TimeSpan.FromMinutes(1), RateLimitWindowType.Fixed)); // IP limit of 2400 request weight per minute to dapi.binance.com host FuturesSocket = new RateLimitGate("Futures Socket") - .AddGuard(new RateLimitGuard(RateLimitGuard.PerEndpoint, new IGuardFilter[] { new LimitItemTypeFilter(RateLimitItemType.Request) }, 10, TimeSpan.FromSeconds(1), RateLimitWindowType.Fixed)); // 10 requests per second per path (connection) + .AddGuard(new RateLimitGuard(RateLimitGuard.PerEndpoint, new IGuardFilter[] { new LimitItemTypeFilter(RateLimitItemType.Request), new HostFilter("wss://dstream.binance.com") }, 10, TimeSpan.FromSeconds(1), RateLimitWindowType.Fixed)) // 10 requests per second per path (connection) + .AddGuard(new RateLimitGuard(RateLimitGuard.PerEndpoint, new IGuardFilter[] { new LimitItemTypeFilter(RateLimitItemType.Request), new HostFilter("wss://fstream.binance.com") }, 10, TimeSpan.FromSeconds(1), RateLimitWindowType.Fixed)) // 10 requests per second per path (connection) + .AddGuard(new RateLimitGuard(RateLimitGuard.PerEndpoint, new IGuardFilter[] { new HostFilter("wss://ws-fapi.binance.com") }, 2400, TimeSpan.FromMinutes(1), RateLimitWindowType.Fixed, connectionWeight: 5)); EndpointLimit.RateLimitTriggered += (x) => RateLimitTriggered?.Invoke(x); SpotRestIp.RateLimitTriggered += (x) => RateLimitTriggered?.Invoke(x); diff --git a/Binance.Net/Clients/UsdFuturesApi/BinanceSocketClientUsdFuturesApi.cs b/Binance.Net/Clients/UsdFuturesApi/BinanceSocketClientUsdFuturesApi.cs index 58134f350..716ba7888 100644 --- a/Binance.Net/Clients/UsdFuturesApi/BinanceSocketClientUsdFuturesApi.cs +++ b/Binance.Net/Clients/UsdFuturesApi/BinanceSocketClientUsdFuturesApi.cs @@ -1,8 +1,12 @@ -using Binance.Net.Converters; +using Binance.Net.Clients.SpotApi; +using Binance.Net.Converters; using Binance.Net.Enums; using Binance.Net.Interfaces; using Binance.Net.Interfaces.Clients.UsdFuturesApi; +using Binance.Net.Objects; +using Binance.Net.Objects.Internal; using Binance.Net.Objects.Models; +using Binance.Net.Objects.Models.Futures; using Binance.Net.Objects.Models.Futures.Socket; using Binance.Net.Objects.Models.Spot.Socket; using Binance.Net.Objects.Options; @@ -21,30 +25,27 @@ namespace Binance.Net.Clients.UsdFuturesApi /// </summary> internal partial class BinanceSocketClientUsdFuturesApi : SocketApiClient, IBinanceSocketClientUsdFuturesApi { - #region fields - private const string _klineStreamEndpoint = "@kline"; - private const string _continuousContractKlineStreamEndpoint = "@continuousKline"; - private const string _markPriceStreamEndpoint = "@markPrice"; - private const string _allMarkPriceStreamEndpoint = "!markPrice@arr"; - private const string _symbolMiniTickerStreamEndpoint = "@miniTicker"; - private const string _allMiniTickerStreamEndpoint = "!miniTicker@arr"; - private const string _symbolTickerStreamEndpoint = "@ticker"; - private const string _allTickerStreamEndpoint = "!ticker@arr"; - private const string _compositeIndexEndpoint = "@compositeIndex"; - - private const string _aggregatedTradesStreamEndpoint = "@aggTrade"; - private const string _tradesStreamEndpoint = "@trade"; - private const string _bookTickerStreamEndpoint = "@bookTicker"; - private const string _allBookTickerStreamEndpoint = "!bookTicker"; - private const string _liquidationStreamEndpoint = "@forceOrder"; - private const string _allLiquidationStreamEndpoint = "!forceOrder@arr"; - private const string _partialBookDepthStreamEndpoint = "@depth"; - private const string _depthStreamEndpoint = "@depth"; + /// <inheritdoc /> + public new BinanceSocketOptions ClientOptions => (BinanceSocketOptions)base.ClientOptions; + /// <inheritdoc /> + public new BinanceSocketApiOptions ApiOptions => (BinanceSocketApiOptions)base.ApiOptions; + #region fields private static readonly MessagePath _idPath = MessagePath.Get().Property("id"); private static readonly MessagePath _streamPath = MessagePath.Get().Property("stream"); + + internal BinanceFuturesUsdtExchangeInfo? _exchangeInfo; + internal DateTime? _lastExchangeInfoUpdate; + internal readonly string _brokerId; #endregion + /// <inheritdoc /> + public IBinanceSocketClientUsdFuturesApiAccount Account { get; } + /// <inheritdoc /> + public IBinanceSocketClientUsdFuturesApiExchangeData ExchangeData { get; } + /// <inheritdoc /> + public IBinanceSocketClientUsdFuturesApiTrading Trading { get; } + #region constructor/destructor /// <summary> @@ -53,6 +54,12 @@ internal partial class BinanceSocketClientUsdFuturesApi : SocketApiClient, IBina internal BinanceSocketClientUsdFuturesApi(ILogger logger, BinanceSocketOptions options) : base(logger, options.Environment.UsdFuturesSocketAddress!, options, options.UsdFuturesOptions) { + Account = new BinanceSocketClientUsdFuturesApiAccount(logger, this); + ExchangeData = new BinanceSocketClientUsdFuturesApiExchangeData(logger, this); + Trading = new BinanceSocketClientUsdFuturesApiTrading(logger, this); + + _brokerId = !string.IsNullOrEmpty(options.UsdFuturesOptions.BrokerId) ? options.UsdFuturesOptions.BrokerId! : "x-d63tKbx3"; + // When sending more than 4000 bytes the server responds very delayed (somehow connected to the websocket keep alive interval on framework level) // See https://dev.binance.vision/t/socket-live-subscribing-server-delay/9645/2 // To prevent issues we keep below this @@ -76,356 +83,65 @@ public override string FormatSymbol(string baseAsset, string quoteAsset, Trading protected override IByteMessageAccessor CreateAccessor() => new SystemTextJsonByteMessageAccessor(); public IBinanceSocketClientUsdFuturesApiShared SharedClient => this; - #region Mark Price Stream - - /// <inheritdoc /> - public async Task<CallResult<UpdateSubscription>> SubscribeToMarkPriceUpdatesAsync(string symbol, int? updateInterval, Action<DataEvent<BinanceFuturesUsdtStreamMarkPrice>> onMessage, CancellationToken ct = default) => await SubscribeToMarkPriceUpdatesAsync(new[] { symbol }, updateInterval, onMessage, ct).ConfigureAwait(false); - - /// <inheritdoc /> - public async Task<CallResult<UpdateSubscription>> SubscribeToMarkPriceUpdatesAsync(IEnumerable<string> symbols, int? updateInterval, Action<DataEvent<BinanceFuturesUsdtStreamMarkPrice>> onMessage, CancellationToken ct = default) - { - symbols.ValidateNotNull(nameof(symbols)); - updateInterval?.ValidateIntValues(nameof(updateInterval), 1000, 3000); - - var handler = new Action<DataEvent<BinanceCombinedStream<BinanceFuturesUsdtStreamMarkPrice>>>(data => onMessage(data.As(data.Data.Data).WithStreamId(data.Data.Stream).WithSymbol(data.Data.Data.Symbol))); - symbols = symbols.Select(a => a.ToLower(CultureInfo.InvariantCulture) + _markPriceStreamEndpoint + (updateInterval == 1000 ? "@1s" : "")).ToArray(); - return await SubscribeAsync(BaseAddress, symbols, handler, ct).ConfigureAwait(false); - } - - #endregion - - #region Mark Price Stream for All market - - /// <inheritdoc /> - public async Task<CallResult<UpdateSubscription>> SubscribeToAllMarkPriceUpdatesAsync(int? updateInterval, Action<DataEvent<IEnumerable<BinanceFuturesUsdtStreamMarkPrice>>> onMessage, CancellationToken ct = default) - { - updateInterval?.ValidateIntValues(nameof(updateInterval), 1000, 3000); - - var handler = new Action<DataEvent<BinanceCombinedStream<IEnumerable<BinanceFuturesUsdtStreamMarkPrice>>>>(data => onMessage(data.As(data.Data.Data).WithStreamId(data.Data.Stream))); - return await SubscribeAsync(BaseAddress, new[] { _allMarkPriceStreamEndpoint + (updateInterval == 1000 ? "@1s" : "") }, handler, ct).ConfigureAwait(false); - } - - #endregion - - #region Kline/Candlestick Streams - - /// <inheritdoc /> - public async Task<CallResult<UpdateSubscription>> SubscribeToKlineUpdatesAsync(string symbol, KlineInterval interval, Action<DataEvent<IBinanceStreamKlineData>> onMessage, CancellationToken ct = default) => await SubscribeToKlineUpdatesAsync(new[] { symbol }, interval, onMessage, ct).ConfigureAwait(false); - - /// <inheritdoc /> - public async Task<CallResult<UpdateSubscription>> SubscribeToKlineUpdatesAsync(string symbol, IEnumerable<KlineInterval> intervals, Action<DataEvent<IBinanceStreamKlineData>> onMessage, CancellationToken ct = default) => await SubscribeToKlineUpdatesAsync(new[] { symbol }, intervals, onMessage, ct).ConfigureAwait(false); - - /// <inheritdoc /> - public async Task<CallResult<UpdateSubscription>> SubscribeToKlineUpdatesAsync(IEnumerable<string> symbols, KlineInterval interval, Action<DataEvent<IBinanceStreamKlineData>> onMessage, CancellationToken ct = default) => - await SubscribeToKlineUpdatesAsync(symbols, new[] { interval }, onMessage, ct).ConfigureAwait(false); - - /// <inheritdoc /> - public async Task<CallResult<UpdateSubscription>> SubscribeToKlineUpdatesAsync(IEnumerable<string> symbols, IEnumerable<KlineInterval> intervals, Action<DataEvent<IBinanceStreamKlineData>> onMessage, CancellationToken ct = default) - { - symbols.ValidateNotNull(nameof(symbols)); - var handler = new Action<DataEvent<BinanceCombinedStream<BinanceStreamKlineData>>>(data => onMessage(data.As<IBinanceStreamKlineData>(data.Data.Data).WithStreamId(data.Data.Stream).WithSymbol(data.Data.Data.Symbol))); - symbols = symbols.SelectMany(a => intervals.Select(i => a.ToLower(CultureInfo.InvariantCulture) + _klineStreamEndpoint + "_" + EnumConverter.GetString(i))).ToArray(); - return await SubscribeAsync(BaseAddress, symbols, handler, ct).ConfigureAwait(false); - } - - #endregion - - #region Continuous contract kline/Candlestick Streams - - /// <inheritdoc /> - public async Task<CallResult<UpdateSubscription>> SubscribeToContinuousContractKlineUpdatesAsync(string pair, ContractType contractType, KlineInterval interval, Action<DataEvent<BinanceStreamContinuousKlineData>> onMessage, CancellationToken ct = default) => await SubscribeToContinuousContractKlineUpdatesAsync(new[] { pair }, contractType, interval, onMessage, ct).ConfigureAwait(false); - - /// <inheritdoc /> - public async Task<CallResult<UpdateSubscription>> SubscribeToContinuousContractKlineUpdatesAsync(IEnumerable<string> pairs, ContractType contractType, KlineInterval interval, Action<DataEvent<BinanceStreamContinuousKlineData>> onMessage, CancellationToken ct = default) - { - pairs.ValidateNotNull(nameof(pairs)); - var handler = new Action<DataEvent<BinanceCombinedStream<BinanceStreamContinuousKlineData>>>(data => onMessage(data.As(data.Data.Data).WithStreamId(data.Data.Stream).WithSymbol(data.Data.Data.Symbol))); - pairs = pairs.Select(a => a.ToLower(CultureInfo.InvariantCulture) + - "_" + - EnumConverter.GetString(contractType).ToLower() + - _continuousContractKlineStreamEndpoint + - "_" + - EnumConverter.GetString(interval)).ToArray(); - return await SubscribeAsync(BaseAddress, pairs, handler, ct).ConfigureAwait(false); - } - - #endregion - #region Individual Symbol Mini Ticker Stream - - /// <inheritdoc /> - public async Task<CallResult<UpdateSubscription>> SubscribeToMiniTickerUpdatesAsync(string symbol, Action<DataEvent<IBinanceMiniTick>> onMessage, CancellationToken ct = default) => await SubscribeToMiniTickerUpdatesAsync(new[] { symbol }, onMessage, ct).ConfigureAwait(false); - - /// <inheritdoc /> - public async Task<CallResult<UpdateSubscription>> SubscribeToMiniTickerUpdatesAsync(IEnumerable<string> symbols, Action<DataEvent<IBinanceMiniTick>> onMessage, CancellationToken ct = default) + internal Task<CallResult<UpdateSubscription>> SubscribeAsync<T>(string url, IEnumerable<string> topics, Action<DataEvent<T>> onData, CancellationToken ct) { - symbols.ValidateNotNull(nameof(symbols)); - - var handler = new Action<DataEvent<BinanceCombinedStream<BinanceStreamMiniTick>>>(data => onMessage(data.As<IBinanceMiniTick>(data.Data.Data).WithStreamId(data.Data.Stream).WithSymbol(data.Data.Data.Symbol))); - symbols = symbols.Select(a => a.ToLower(CultureInfo.InvariantCulture) + _symbolMiniTickerStreamEndpoint).ToArray(); - return await SubscribeAsync(BaseAddress, symbols, handler, ct).ConfigureAwait(false); + var subscription = new BinanceSubscription<T>(_logger, topics.ToList(), onData, false); + return SubscribeAsync(url.AppendPath("stream"), subscription, ct); } - #endregion - - #region All Market Mini Tickers Stream - /// <inheritdoc /> - public async Task<CallResult<UpdateSubscription>> SubscribeToAllMiniTickerUpdatesAsync(Action<DataEvent<IEnumerable<IBinanceMiniTick>>> onMessage, CancellationToken ct = default) + internal Task<CallResult<UpdateSubscription>> SubscribeInternalAsync(string url, Subscription subscription, CancellationToken ct) { - var handler = new Action<DataEvent<BinanceCombinedStream<IEnumerable<BinanceStreamMiniTick>>>>(data => onMessage(data.As<IEnumerable<IBinanceMiniTick>>(data.Data.Data).WithStreamId(data.Data.Stream))); - return await SubscribeAsync(BaseAddress, new[] { _allMiniTickerStreamEndpoint }, handler, ct).ConfigureAwait(false); + return base.SubscribeAsync(url.AppendPath("stream"), subscription, ct); } - #endregion - - #region Individual Symbol Ticker Streams /// <inheritdoc /> - public async Task<CallResult<UpdateSubscription>> SubscribeToTickerUpdatesAsync(string symbol, Action<DataEvent<IBinance24HPrice>> onMessage, CancellationToken ct = default) => await SubscribeToTickerUpdatesAsync(new[] { symbol }, onMessage, ct).ConfigureAwait(false); - - /// <inheritdoc /> - public async Task<CallResult<UpdateSubscription>> SubscribeToTickerUpdatesAsync(IEnumerable<string> symbols, Action<DataEvent<IBinance24HPrice>> onMessage, CancellationToken ct = default) + public override string? GetListenerIdentifier(IMessageAccessor message) { - symbols.ValidateNotNull(nameof(symbols)); + var id = message.GetValue<int?>(_idPath); + if (id != null) + return id.ToString(); - var handler = new Action<DataEvent<BinanceCombinedStream<BinanceStreamTick>>>(data => onMessage(data.As<IBinance24HPrice>(data.Data.Data).WithStreamId(data.Data.Stream).WithSymbol(data.Data.Data.Symbol))); - symbols = symbols.Select(a => a.ToLower(CultureInfo.InvariantCulture) + _symbolTickerStreamEndpoint).ToArray(); - return await SubscribeAsync(BaseAddress, symbols, handler, ct).ConfigureAwait(false); + return message.GetValue<string>(_streamPath); } - #endregion - - #region Composite index Streams - - /// <inheritdoc /> - public async Task<CallResult<UpdateSubscription>> SubscribeToCompositeIndexUpdatesAsync(string symbol, Action<DataEvent<BinanceFuturesStreamCompositeIndex>> onMessage, CancellationToken ct = default) + internal async Task<CallResult<BinanceResponse<T>>> QueryAsync<T>(string url, string method, Dictionary<string, object> parameters, bool authenticated = false, bool sign = false, int weight = 1, CancellationToken ct = default) { - var action = new Action<DataEvent<BinanceCombinedStream<BinanceFuturesStreamCompositeIndex>>>(data => + if (authenticated) { - onMessage(data.As(data.Data.Data).WithStreamId(data.Data.Stream).WithSymbol(data.Data.Data.Symbol)); - }); - return await SubscribeAsync(BaseAddress, new[] { symbol.ToLower(CultureInfo.InvariantCulture) + _compositeIndexEndpoint }, action, ct).ConfigureAwait(false); - } - - #endregion - - #region All Market Tickers Streams - - /// <inheritdoc /> - public async Task<CallResult<UpdateSubscription>> SubscribeToAllTickerUpdatesAsync(Action<DataEvent<IEnumerable<IBinance24HPrice>>> onMessage, CancellationToken ct = default) - { - var handler = new Action<DataEvent<BinanceCombinedStream<IEnumerable<BinanceStreamTick>>>>(data => onMessage(data.As<IEnumerable<IBinance24HPrice>>(data.Data.Data).WithStreamId(data.Data.Stream))); - return await SubscribeAsync(BaseAddress, new[] { _allTickerStreamEndpoint }, handler, ct).ConfigureAwait(false); - } - - #endregion - - #region Aggregate Trade Streams - - /// <inheritdoc /> - public async Task<CallResult<UpdateSubscription>> SubscribeToAggregatedTradeUpdatesAsync(string symbol, Action<DataEvent<BinanceStreamAggregatedTrade>> onMessage, CancellationToken ct = default) => await SubscribeToAggregatedTradeUpdatesAsync(new[] { symbol }, onMessage, ct).ConfigureAwait(false); - - /// <inheritdoc /> - public async Task<CallResult<UpdateSubscription>> SubscribeToAggregatedTradeUpdatesAsync(IEnumerable<string> symbols, Action<DataEvent<BinanceStreamAggregatedTrade>> onMessage, CancellationToken ct = default) - { - symbols.ValidateNotNull(nameof(symbols)); - - var handler = new Action<DataEvent<BinanceCombinedStream<BinanceStreamAggregatedTrade>>>(data => onMessage(data.As(data.Data.Data).WithStreamId(data.Data.Stream).WithSymbol(data.Data.Data.Symbol))); - symbols = symbols.Select(a => a.ToLower(CultureInfo.InvariantCulture) + _aggregatedTradesStreamEndpoint).ToArray(); - return await SubscribeAsync(BaseAddress, symbols, handler, ct).ConfigureAwait(false); - } - #endregion - - #region Trade Streams - - /// <inheritdoc /> - public async Task<CallResult<UpdateSubscription>> SubscribeToTradeUpdatesAsync(string symbol, - Action<DataEvent<BinanceStreamTrade>> onMessage, bool filterOutNonTradeUpdates = true, CancellationToken ct = default) => - await SubscribeToTradeUpdatesAsync(new[] { symbol }, onMessage, filterOutNonTradeUpdates, ct).ConfigureAwait(false); - - /// <inheritdoc /> - public async Task<CallResult<UpdateSubscription>> SubscribeToTradeUpdatesAsync(IEnumerable<string> symbols, - Action<DataEvent<BinanceStreamTrade>> onMessage, bool filterOutNonTradeUpdates = true, CancellationToken ct = default) - { - symbols.ValidateNotNull(nameof(symbols)); - - var handler = new Action<DataEvent<BinanceCombinedStream<BinanceStreamTrade>>>(data => + if (AuthenticationProvider == null) + throw new InvalidOperationException("No credentials provided for authenticated endpoint"); + + var authProvider = (BinanceAuthenticationProvider)AuthenticationProvider; + if (sign) + { + parameters = authProvider.AuthenticateSocketParameters(parameters); + } + else + { + parameters.Add("apiKey", authProvider.ApiKey); + } + } + + var request = new BinanceSocketQuery { - if (filterOutNonTradeUpdates && data.Data.Data.Type != "MARKET") - return; - - onMessage(data.As(data.Data.Data).WithStreamId(data.Data.Stream).WithSymbol(data.Data.Data.Symbol)); - }); - symbols = symbols.Select(a => a.ToLower(CultureInfo.InvariantCulture) + _tradesStreamEndpoint).ToArray(); - return await SubscribeAsync(BaseAddress, symbols, handler, ct).ConfigureAwait(false); - } - - #endregion - - #region Individual Symbol Book Ticker Streams - - /// <inheritdoc /> - public async Task<CallResult<UpdateSubscription>> SubscribeToBookTickerUpdatesAsync(string symbol, Action<DataEvent<BinanceFuturesStreamBookPrice>> onMessage, CancellationToken ct = default) => await SubscribeToBookTickerUpdatesAsync(new[] { symbol }, onMessage, ct).ConfigureAwait(false); - - /// <inheritdoc /> - public async Task<CallResult<UpdateSubscription>> SubscribeToBookTickerUpdatesAsync(IEnumerable<string> symbols, Action<DataEvent<BinanceFuturesStreamBookPrice>> onMessage, CancellationToken ct = default) - { - symbols.ValidateNotNull(nameof(symbols)); - - var handler = new Action<DataEvent<BinanceCombinedStream<BinanceFuturesStreamBookPrice>>>(data => onMessage(data.As(data.Data.Data).WithStreamId(data.Data.Stream).WithSymbol(data.Data.Data.Symbol))); - symbols = symbols.Select(a => a.ToLower(CultureInfo.InvariantCulture) + _bookTickerStreamEndpoint).ToArray(); - return await SubscribeAsync(BaseAddress, symbols, handler, ct).ConfigureAwait(false); - } - - #endregion - - #region All Book Tickers Stream - - /// <inheritdoc /> - public async Task<CallResult<UpdateSubscription>> SubscribeToAllBookTickerUpdatesAsync(Action<DataEvent<BinanceFuturesStreamBookPrice>> onMessage, CancellationToken ct = default) - { - var handler = new Action<DataEvent<BinanceCombinedStream<BinanceFuturesStreamBookPrice>>>(data => onMessage(data.As(data.Data.Data).WithStreamId(data.Data.Stream).WithSymbol(data.Data.Data.Symbol))); - return await SubscribeAsync(BaseAddress, new[] { _allBookTickerStreamEndpoint }, handler, ct).ConfigureAwait(false); - } - - #endregion - - #region Liquidation Order Streams - - /// <inheritdoc /> - public async Task<CallResult<UpdateSubscription>> SubscribeToLiquidationUpdatesAsync(string symbol, Action<DataEvent<BinanceFuturesStreamLiquidation>> onMessage, CancellationToken ct = default) => await SubscribeToLiquidationUpdatesAsync(new[] { symbol }, onMessage, ct).ConfigureAwait(false); - - /// <inheritdoc /> - public async Task<CallResult<UpdateSubscription>> SubscribeToLiquidationUpdatesAsync(IEnumerable<string> symbols, Action<DataEvent<BinanceFuturesStreamLiquidation>> onMessage, CancellationToken ct = default) - { - symbols.ValidateNotNull(nameof(symbols)); - - var handler = new Action<DataEvent<BinanceCombinedStream<BinanceFuturesStreamLiquidationData>>>(data => onMessage(data.As(data.Data.Data.Data).WithStreamId(data.Data.Stream).WithSymbol(data.Data.Data.Data.Symbol))); - symbols = symbols.Select(a => a.ToLower(CultureInfo.InvariantCulture) + _liquidationStreamEndpoint).ToArray(); - return await SubscribeAsync(BaseAddress, symbols, handler, ct).ConfigureAwait(false); - } - - #endregion - - #region All Market Liquidation Order Streams - - /// <inheritdoc /> - public async Task<CallResult<UpdateSubscription>> SubscribeToAllLiquidationUpdatesAsync(Action<DataEvent<BinanceFuturesStreamLiquidation>> onMessage, CancellationToken ct = default) - { - var handler = new Action<DataEvent<BinanceCombinedStream<BinanceFuturesStreamLiquidationData>>>(data => onMessage(data.As(data.Data.Data.Data).WithStreamId(data.Data.Stream).WithSymbol(data.Data.Data.Data.Symbol))); - return await SubscribeAsync(BaseAddress, new[] { _allLiquidationStreamEndpoint }, handler, ct).ConfigureAwait(false); - } - - #endregion - - #region Partial Book Depth Streams - - /// <inheritdoc /> - public async Task<CallResult<UpdateSubscription>> SubscribeToPartialOrderBookUpdatesAsync(string symbol, int levels, int? updateInterval, Action<DataEvent<IBinanceFuturesEventOrderBook>> onMessage, CancellationToken ct = default) => await SubscribeToPartialOrderBookUpdatesAsync(new[] { symbol }, levels, updateInterval, onMessage, ct).ConfigureAwait(false); - - /// <inheritdoc /> - public async Task<CallResult<UpdateSubscription>> SubscribeToPartialOrderBookUpdatesAsync(IEnumerable<string> symbols, int levels, int? updateInterval, Action<DataEvent<IBinanceFuturesEventOrderBook>> onMessage, CancellationToken ct = default) - { - symbols.ValidateNotNull(nameof(symbols)); - levels.ValidateIntValues(nameof(levels), 5, 10, 20); - updateInterval?.ValidateIntValues(nameof(updateInterval), 100, 250, 500); - - var handler = new Action<DataEvent<BinanceCombinedStream<BinanceFuturesStreamOrderBookDepth>>>(data => + Method = method, + Params = parameters, + Id = ExchangeHelpers.NextId() + }; + + var query = new BinanceSpotQuery<BinanceResponse<T>>(request, false, weight); + var result = await QueryAsync(url, query, ct).ConfigureAwait(false); + if (!result.Success && result.Error is BinanceRateLimitError rle) { - data.Data.Data.Symbol = data.Data.Stream.Split('@')[0]; - onMessage(data.As<IBinanceFuturesEventOrderBook>(data.Data.Data).WithStreamId(data.Data.Stream).WithSymbol(data.Data.Data.Symbol)); - }); - - symbols = symbols.Select(a => a.ToLower(CultureInfo.InvariantCulture) + _partialBookDepthStreamEndpoint + levels + (updateInterval.HasValue ? $"@{updateInterval.Value}ms" : "")).ToArray(); - return await SubscribeAsync(BaseAddress, symbols, handler, ct).ConfigureAwait(false); - } - - #endregion - - #region Diff. Book Depth Streams - - /// <inheritdoc /> - public async Task<CallResult<UpdateSubscription>> SubscribeToOrderBookUpdatesAsync(string symbol, int? updateInterval, Action<DataEvent<IBinanceFuturesEventOrderBook>> onMessage, CancellationToken ct = default) => await SubscribeToOrderBookUpdatesAsync(new[] { symbol }, updateInterval, onMessage, ct).ConfigureAwait(false); - - /// <inheritdoc /> - public async Task<CallResult<UpdateSubscription>> SubscribeToOrderBookUpdatesAsync(IEnumerable<string> symbols, int? updateInterval, Action<DataEvent<IBinanceFuturesEventOrderBook>> onMessage, CancellationToken ct = default) - { - symbols.ValidateNotNull(nameof(symbols)); - - updateInterval?.ValidateIntValues(nameof(updateInterval), 100, 250, 500); - var handler = new Action<DataEvent<BinanceCombinedStream<BinanceFuturesStreamOrderBookDepth>>>(data => onMessage(data.As<IBinanceFuturesEventOrderBook>(data.Data.Data).WithStreamId(data.Data.Stream).WithSymbol(data.Data.Data.Symbol))); - symbols = symbols.Select(a => a.ToLower(CultureInfo.InvariantCulture) + _depthStreamEndpoint + (updateInterval.HasValue ? $"@{updateInterval.Value}ms" : "")).ToArray(); - return await SubscribeAsync(BaseAddress, symbols, handler, ct).ConfigureAwait(false); - } - - #endregion - - #region Contract Info Streams - - /// <inheritdoc /> - public async Task<CallResult<UpdateSubscription>> SubscribeToSymbolUpdatesAsync(Action<DataEvent<BinanceFuturesStreamSymbolUpdate>> onMessage, CancellationToken ct = default) - { - var handler = new Action<DataEvent<BinanceCombinedStream<BinanceFuturesStreamSymbolUpdate>>>(data => onMessage(data.As(data.Data.Data).WithStreamId(data.Data.Stream).WithSymbol(data.Data.Data.Symbol))); - return await SubscribeAsync(BaseAddress, new[] { "!contractInfo" }, handler, ct).ConfigureAwait(false); - } - - #endregion - - #region Asset Index Streams - - /// <inheritdoc /> - public async Task<CallResult<UpdateSubscription>> SubscribeToAssetIndexUpdatesAsync(Action<DataEvent<IEnumerable<BinanceFuturesStreamAssetIndexUpdate>>> onMessage, CancellationToken ct = default) - { - var handler = new Action<DataEvent<BinanceCombinedStream<IEnumerable<BinanceFuturesStreamAssetIndexUpdate>>>>(data => onMessage(data.As(data.Data.Data).WithStreamId(data.Data.Stream))); - return await SubscribeAsync(BaseAddress, new[] { "!assetIndex@arr" }, handler, ct).ConfigureAwait(false); - } - - /// <inheritdoc /> - public async Task<CallResult<UpdateSubscription>> SubscribeToAssetIndexUpdatesAsync(string symbol, Action<DataEvent<BinanceFuturesStreamAssetIndexUpdate>> onMessage, CancellationToken ct = default) - { - var handler = new Action<DataEvent<BinanceCombinedStream<BinanceFuturesStreamAssetIndexUpdate>>>(data => onMessage(data.As(data.Data.Data).WithStreamId(data.Data.Stream).WithSymbol(data.Data.Data.Symbol))); - return await SubscribeAsync(BaseAddress, new[] { symbol.ToLowerInvariant() + "@assetIndex" }, handler, ct).ConfigureAwait(false); - } - - #endregion - - #region User Data Streams - - /// <inheritdoc /> - public async Task<CallResult<UpdateSubscription>> SubscribeToUserDataUpdatesAsync( - string listenKey, - Action<DataEvent<BinanceFuturesStreamConfigUpdate>>? onConfigUpdate = null, - Action<DataEvent<BinanceFuturesStreamMarginUpdate>>? onMarginUpdate = null, - Action<DataEvent<BinanceFuturesStreamAccountUpdate>>? onAccountUpdate = null, - Action<DataEvent<BinanceFuturesStreamOrderUpdate>>? onOrderUpdate = null, - Action<DataEvent<BinanceFuturesStreamTradeUpdate>>? onTradeUpdate = null, - Action<DataEvent<BinanceStreamEvent>>? onListenKeyExpired = null, - Action<DataEvent<BinanceStrategyUpdate>>? onStrategyUpdate = null, - Action<DataEvent<BinanceGridUpdate>>? onGridUpdate = null, - Action<DataEvent<BinanceConditionOrderTriggerRejectUpdate>>? onConditionalOrderTriggerRejectUpdate = null, - CancellationToken ct = default) - { - listenKey.ValidateNotNull(nameof(listenKey)); - - var subscription = new BinanceUsdFuturesUserDataSubscription(_logger, new List<string> { listenKey }, onOrderUpdate, onTradeUpdate, onConfigUpdate, onMarginUpdate, onAccountUpdate, onListenKeyExpired, onStrategyUpdate, onGridUpdate, onConditionalOrderTriggerRejectUpdate); - return await SubscribeAsync(BaseAddress.AppendPath("stream"), subscription, ct).ConfigureAwait(false); - } - - #endregion - - internal Task<CallResult<UpdateSubscription>> SubscribeAsync<T>(string url, IEnumerable<string> topics, Action<DataEvent<T>> onData, CancellationToken ct) - { - var subscription = new BinanceSubscription<T>(_logger, topics.ToList(), onData, false); - return SubscribeAsync(url.AppendPath("stream"), subscription, ct); - } - - /// <inheritdoc /> - public override string? GetListenerIdentifier(IMessageAccessor message) - { - var id = message.GetValue<int?>(_idPath); - if (id != null) - return id.ToString(); - - return message.GetValue<string>(_streamPath); + if (rle.RetryAfter != null && RateLimiter != null && ClientOptions.RateLimiterEnabled) + { + _logger.LogWarning("Ratelimit error from server, pausing requests until {Until}", rle.RetryAfter.Value); + await RateLimiter.SetRetryAfterGuardAsync(rle.RetryAfter.Value).ConfigureAwait(false); + } + } + + return result; } /// <inheritdoc /> diff --git a/Binance.Net/Clients/UsdFuturesApi/BinanceSocketClientUsdFuturesApiAccount.cs b/Binance.Net/Clients/UsdFuturesApi/BinanceSocketClientUsdFuturesApiAccount.cs new file mode 100644 index 000000000..d9e74c1cf --- /dev/null +++ b/Binance.Net/Clients/UsdFuturesApi/BinanceSocketClientUsdFuturesApiAccount.cs @@ -0,0 +1,84 @@ +using Binance.Net.Clients.SpotApi; +using Binance.Net.Interfaces.Clients.UsdFuturesApi; +using Binance.Net.Objects; +using Binance.Net.Objects.Models; +using Binance.Net.Objects.Models.Futures; +using Binance.Net.Objects.Models.Futures.Socket; +using Binance.Net.Objects.Sockets; +using CryptoExchange.Net.Objects.Sockets; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Binance.Net.Clients.UsdFuturesApi +{ + internal class BinanceSocketClientUsdFuturesApiAccount : IBinanceSocketClientUsdFuturesApiAccount + { + private readonly BinanceSocketClientUsdFuturesApi _client; + private readonly ILogger _logger; + + internal BinanceSocketClientUsdFuturesApiAccount(ILogger logger, BinanceSocketClientUsdFuturesApi client) + { + _client = client; + _logger = logger; + } + + #region Queries + + + #region Future Account Balance + + /// <inheritdoc /> + public async Task<CallResult<BinanceResponse<IEnumerable<BinanceUsdFuturesAccountBalance>>>> GetBalancesAsync(long? receiveWindow = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("recvWindow", receiveWindow?.ToString(CultureInfo.InvariantCulture)); + + return await _client.QueryAsync<IEnumerable<BinanceUsdFuturesAccountBalance>>(_client.ClientOptions.Environment.UsdFuturesSocketApiAddress!.AppendPath("ws-fapi/v1"), $"v2/account.balance", parameters, true, true, weight: 5, ct: ct).ConfigureAwait(false); + } + + #endregion + + #region Get Account Info + + /// <inheritdoc /> + public async Task<CallResult<BinanceResponse<BinanceFuturesAccountInfoV3>>> GetAccountInfoAsync(long? receiveWindow = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("recvWindow", receiveWindow?.ToString(CultureInfo.InvariantCulture)); + return await _client.QueryAsync<BinanceFuturesAccountInfoV3>(_client.ClientOptions.Environment.UsdFuturesSocketApiAddress!.AppendPath("ws-fapi/v1"), $"v2/account.status", parameters, true, true, weight: 5, ct: ct).ConfigureAwait(false); + } + + #endregion + + #endregion + + #region Streams + + #region User Data Streams + + /// <inheritdoc /> + public async Task<CallResult<UpdateSubscription>> SubscribeToUserDataUpdatesAsync( + string listenKey, + Action<DataEvent<BinanceFuturesStreamConfigUpdate>>? onConfigUpdate = null, + Action<DataEvent<BinanceFuturesStreamMarginUpdate>>? onMarginUpdate = null, + Action<DataEvent<BinanceFuturesStreamAccountUpdate>>? onAccountUpdate = null, + Action<DataEvent<BinanceFuturesStreamOrderUpdate>>? onOrderUpdate = null, + Action<DataEvent<BinanceFuturesStreamTradeUpdate>>? onTradeUpdate = null, + Action<DataEvent<BinanceStreamEvent>>? onListenKeyExpired = null, + Action<DataEvent<BinanceStrategyUpdate>>? onStrategyUpdate = null, + Action<DataEvent<BinanceGridUpdate>>? onGridUpdate = null, + Action<DataEvent<BinanceConditionOrderTriggerRejectUpdate>>? onConditionalOrderTriggerRejectUpdate = null, + CancellationToken ct = default) + { + listenKey.ValidateNotNull(nameof(listenKey)); + + var subscription = new BinanceUsdFuturesUserDataSubscription(_logger, new List<string> { listenKey }, onOrderUpdate, onTradeUpdate, onConfigUpdate, onMarginUpdate, onAccountUpdate, onListenKeyExpired, onStrategyUpdate, onGridUpdate, onConditionalOrderTriggerRejectUpdate); + return await _client.SubscribeInternalAsync(_client.BaseAddress, subscription, ct).ConfigureAwait(false); + } + + #endregion + + #endregion + } +} diff --git a/Binance.Net/Clients/UsdFuturesApi/BinanceSocketClientUsdFuturesApiExchangeData.cs b/Binance.Net/Clients/UsdFuturesApi/BinanceSocketClientUsdFuturesApiExchangeData.cs new file mode 100644 index 000000000..f95d8ebaa --- /dev/null +++ b/Binance.Net/Clients/UsdFuturesApi/BinanceSocketClientUsdFuturesApiExchangeData.cs @@ -0,0 +1,428 @@ +using Binance.Net.Enums; +using Binance.Net.Interfaces; +using Binance.Net.Interfaces.Clients.UsdFuturesApi; +using Binance.Net.Objects; +using Binance.Net.Objects.Models; +using Binance.Net.Objects.Models.Futures; +using Binance.Net.Objects.Models.Futures.Socket; +using Binance.Net.Objects.Models.Spot; +using Binance.Net.Objects.Models.Spot.Socket; +using CryptoExchange.Net.Objects.Sockets; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Binance.Net.Clients.UsdFuturesApi +{ + internal class BinanceSocketClientUsdFuturesApiExchangeData : IBinanceSocketClientUsdFuturesApiExchangeData + { + private readonly BinanceSocketClientUsdFuturesApi _client; + private readonly ILogger _logger; + + private const string _klineStreamEndpoint = "@kline"; + private const string _continuousContractKlineStreamEndpoint = "@continuousKline"; + private const string _markPriceStreamEndpoint = "@markPrice"; + private const string _allMarkPriceStreamEndpoint = "!markPrice@arr"; + private const string _symbolMiniTickerStreamEndpoint = "@miniTicker"; + private const string _allMiniTickerStreamEndpoint = "!miniTicker@arr"; + private const string _symbolTickerStreamEndpoint = "@ticker"; + private const string _allTickerStreamEndpoint = "!ticker@arr"; + private const string _compositeIndexEndpoint = "@compositeIndex"; + + private const string _aggregatedTradesStreamEndpoint = "@aggTrade"; + private const string _tradesStreamEndpoint = "@trade"; + private const string _bookTickerStreamEndpoint = "@bookTicker"; + private const string _allBookTickerStreamEndpoint = "!bookTicker"; + private const string _liquidationStreamEndpoint = "@forceOrder"; + private const string _allLiquidationStreamEndpoint = "!forceOrder@arr"; + private const string _partialBookDepthStreamEndpoint = "@depth"; + private const string _depthStreamEndpoint = "@depth"; + + internal BinanceSocketClientUsdFuturesApiExchangeData(ILogger logger, BinanceSocketClientUsdFuturesApi client) + { + _client = client; + _logger = logger; + } + + #region Queries + + #region Get Orderbook + + /// <inheritdoc /> + public async Task<CallResult<BinanceResponse<BinanceFuturesOrderBook>>> GetOrderBookAsync(string symbol, int? limit = null, CancellationToken ct = default) + { + var parameters = new Dictionary<string, object>(); + parameters.AddParameter("symbol", symbol); + parameters.AddOptionalParameter("limit", limit); + int weight = limit <= 50 ? 2 : limit <= 100 ? 5 : limit <= 500 ? 10 : 20; + return await _client.QueryAsync<BinanceFuturesOrderBook>(_client.ClientOptions.Environment.UsdFuturesSocketApiAddress!.AppendPath("ws-fapi/v1"), $"depth", parameters, weight: weight, ct: ct).ConfigureAwait(false); + } + + #endregion + + #region Get Price + + /// <inheritdoc /> + public async Task<CallResult<BinanceResponse<BinancePrice>>> GetPriceAsync(string symbol, CancellationToken ct = default) + { + var parameters = new Dictionary<string, object>(); + parameters.AddParameter("symbol", symbol); + return await _client.QueryAsync<BinancePrice>(_client.ClientOptions.Environment.UsdFuturesSocketApiAddress!.AppendPath("ws-fapi/v1"), $"ticker.price", parameters, weight: 1, ct: ct).ConfigureAwait(false); + } + + #endregion + + #region Get Price + + /// <inheritdoc /> + public async Task<CallResult<BinanceResponse<IEnumerable<BinancePrice>>>> GetPricesAsync(CancellationToken ct = default) + { + var parameters = new Dictionary<string, object>(); + return await _client.QueryAsync<IEnumerable<BinancePrice>>(_client.ClientOptions.Environment.UsdFuturesSocketApiAddress!.AppendPath("ws-fapi/v1"), $"ticker.price", parameters, weight: 2, ct: ct).ConfigureAwait(false); + } + + #endregion + + #region Get Book Price + + /// <inheritdoc /> + public async Task<CallResult<BinanceResponse<BinanceBookPrice>>> GetBookPriceAsync(string symbol, CancellationToken ct = default) + { + var parameters = new Dictionary<string, object>(); + parameters.AddParameter("symbol", symbol); + return await _client.QueryAsync<BinanceBookPrice>(_client.ClientOptions.Environment.UsdFuturesSocketApiAddress!.AppendPath("ws-fapi/v1"), $"ticker.book", parameters, weight: 2, ct: ct).ConfigureAwait(false); + } + + #endregion + + #region Get Book Price + + /// <inheritdoc /> + public async Task<CallResult<BinanceResponse<IEnumerable<BinanceBookPrice>>>> GetBookPricesAsync(CancellationToken ct = default) + { + var parameters = new Dictionary<string, object>(); + return await _client.QueryAsync<IEnumerable<BinanceBookPrice>>(_client.ClientOptions.Environment.UsdFuturesSocketApiAddress!.AppendPath("ws-fapi/v1"), $"ticker.book", parameters, weight: 5, ct: ct).ConfigureAwait(false); + } + + #endregion + + #endregion + + #region Streams + + #region Mark Price Stream + + /// <inheritdoc /> + public async Task<CallResult<UpdateSubscription>> SubscribeToMarkPriceUpdatesAsync(string symbol, int? updateInterval, Action<DataEvent<BinanceFuturesUsdtStreamMarkPrice>> onMessage, CancellationToken ct = default) => await SubscribeToMarkPriceUpdatesAsync(new[] { symbol }, updateInterval, onMessage, ct).ConfigureAwait(false); + + /// <inheritdoc /> + public async Task<CallResult<UpdateSubscription>> SubscribeToMarkPriceUpdatesAsync(IEnumerable<string> symbols, int? updateInterval, Action<DataEvent<BinanceFuturesUsdtStreamMarkPrice>> onMessage, CancellationToken ct = default) + { + symbols.ValidateNotNull(nameof(symbols)); + updateInterval?.ValidateIntValues(nameof(updateInterval), 1000, 3000); + + var handler = new Action<DataEvent<BinanceCombinedStream<BinanceFuturesUsdtStreamMarkPrice>>>(data => onMessage(data.As(data.Data.Data).WithStreamId(data.Data.Stream).WithSymbol(data.Data.Data.Symbol))); + symbols = symbols.Select(a => a.ToLower(CultureInfo.InvariantCulture) + _markPriceStreamEndpoint + (updateInterval == 1000 ? "@1s" : "")).ToArray(); + return await _client.SubscribeAsync(_client.BaseAddress, symbols, handler, ct).ConfigureAwait(false); + } + + #endregion + + #region Mark Price Stream for All market + + /// <inheritdoc /> + public async Task<CallResult<UpdateSubscription>> SubscribeToAllMarkPriceUpdatesAsync(int? updateInterval, Action<DataEvent<IEnumerable<BinanceFuturesUsdtStreamMarkPrice>>> onMessage, CancellationToken ct = default) + { + updateInterval?.ValidateIntValues(nameof(updateInterval), 1000, 3000); + + var handler = new Action<DataEvent<BinanceCombinedStream<IEnumerable<BinanceFuturesUsdtStreamMarkPrice>>>>(data => onMessage(data.As(data.Data.Data).WithStreamId(data.Data.Stream))); + return await _client.SubscribeAsync(_client.BaseAddress, new[] { _allMarkPriceStreamEndpoint + (updateInterval == 1000 ? "@1s" : "") }, handler, ct).ConfigureAwait(false); + } + + #endregion + + #region Kline/Candlestick Streams + + /// <inheritdoc /> + public async Task<CallResult<UpdateSubscription>> SubscribeToKlineUpdatesAsync(string symbol, KlineInterval interval, Action<DataEvent<IBinanceStreamKlineData>> onMessage, CancellationToken ct = default) => await SubscribeToKlineUpdatesAsync(new[] { symbol }, interval, onMessage, ct).ConfigureAwait(false); + + /// <inheritdoc /> + public async Task<CallResult<UpdateSubscription>> SubscribeToKlineUpdatesAsync(string symbol, IEnumerable<KlineInterval> intervals, Action<DataEvent<IBinanceStreamKlineData>> onMessage, CancellationToken ct = default) => await SubscribeToKlineUpdatesAsync(new[] { symbol }, intervals, onMessage, ct).ConfigureAwait(false); + + /// <inheritdoc /> + public async Task<CallResult<UpdateSubscription>> SubscribeToKlineUpdatesAsync(IEnumerable<string> symbols, KlineInterval interval, Action<DataEvent<IBinanceStreamKlineData>> onMessage, CancellationToken ct = default) => + await SubscribeToKlineUpdatesAsync(symbols, new[] { interval }, onMessage, ct).ConfigureAwait(false); + + /// <inheritdoc /> + public async Task<CallResult<UpdateSubscription>> SubscribeToKlineUpdatesAsync(IEnumerable<string> symbols, IEnumerable<KlineInterval> intervals, Action<DataEvent<IBinanceStreamKlineData>> onMessage, CancellationToken ct = default) + { + symbols.ValidateNotNull(nameof(symbols)); + var handler = new Action<DataEvent<BinanceCombinedStream<BinanceStreamKlineData>>>(data => onMessage(data.As<IBinanceStreamKlineData>(data.Data.Data).WithStreamId(data.Data.Stream).WithSymbol(data.Data.Data.Symbol))); + symbols = symbols.SelectMany(a => intervals.Select(i => a.ToLower(CultureInfo.InvariantCulture) + _klineStreamEndpoint + "_" + EnumConverter.GetString(i))).ToArray(); + return await _client.SubscribeAsync(_client.BaseAddress, symbols, handler, ct).ConfigureAwait(false); + } + + #endregion + + #region Continuous contract kline/Candlestick Streams + + /// <inheritdoc /> + public async Task<CallResult<UpdateSubscription>> SubscribeToContinuousContractKlineUpdatesAsync(string pair, ContractType contractType, KlineInterval interval, Action<DataEvent<BinanceStreamContinuousKlineData>> onMessage, CancellationToken ct = default) => await SubscribeToContinuousContractKlineUpdatesAsync(new[] { pair }, contractType, interval, onMessage, ct).ConfigureAwait(false); + + /// <inheritdoc /> + public async Task<CallResult<UpdateSubscription>> SubscribeToContinuousContractKlineUpdatesAsync(IEnumerable<string> pairs, ContractType contractType, KlineInterval interval, Action<DataEvent<BinanceStreamContinuousKlineData>> onMessage, CancellationToken ct = default) + { + pairs.ValidateNotNull(nameof(pairs)); + var handler = new Action<DataEvent<BinanceCombinedStream<BinanceStreamContinuousKlineData>>>(data => onMessage(data.As(data.Data.Data).WithStreamId(data.Data.Stream).WithSymbol(data.Data.Data.Symbol))); + pairs = pairs.Select(a => a.ToLower(CultureInfo.InvariantCulture) + + "_" + + EnumConverter.GetString(contractType).ToLower() + + _continuousContractKlineStreamEndpoint + + "_" + + EnumConverter.GetString(interval)).ToArray(); + return await _client.SubscribeAsync(_client.BaseAddress, pairs, handler, ct).ConfigureAwait(false); + } + + #endregion + + #region Individual Symbol Mini Ticker Stream + + /// <inheritdoc /> + public async Task<CallResult<UpdateSubscription>> SubscribeToMiniTickerUpdatesAsync(string symbol, Action<DataEvent<IBinanceMiniTick>> onMessage, CancellationToken ct = default) => await SubscribeToMiniTickerUpdatesAsync(new[] { symbol }, onMessage, ct).ConfigureAwait(false); + + /// <inheritdoc /> + public async Task<CallResult<UpdateSubscription>> SubscribeToMiniTickerUpdatesAsync(IEnumerable<string> symbols, Action<DataEvent<IBinanceMiniTick>> onMessage, CancellationToken ct = default) + { + symbols.ValidateNotNull(nameof(symbols)); + + var handler = new Action<DataEvent<BinanceCombinedStream<BinanceStreamMiniTick>>>(data => onMessage(data.As<IBinanceMiniTick>(data.Data.Data).WithStreamId(data.Data.Stream).WithSymbol(data.Data.Data.Symbol))); + symbols = symbols.Select(a => a.ToLower(CultureInfo.InvariantCulture) + _symbolMiniTickerStreamEndpoint).ToArray(); + return await _client.SubscribeAsync(_client.BaseAddress, symbols, handler, ct).ConfigureAwait(false); + } + + #endregion + + #region All Market Mini Tickers Stream + /// <inheritdoc /> + public async Task<CallResult<UpdateSubscription>> SubscribeToAllMiniTickerUpdatesAsync(Action<DataEvent<IEnumerable<IBinanceMiniTick>>> onMessage, CancellationToken ct = default) + { + var handler = new Action<DataEvent<BinanceCombinedStream<IEnumerable<BinanceStreamMiniTick>>>>(data => onMessage(data.As<IEnumerable<IBinanceMiniTick>>(data.Data.Data).WithStreamId(data.Data.Stream))); + return await _client.SubscribeAsync(_client.BaseAddress, new[] { _allMiniTickerStreamEndpoint }, handler, ct).ConfigureAwait(false); + } + #endregion + + #region Individual Symbol Ticker Streams + + /// <inheritdoc /> + public async Task<CallResult<UpdateSubscription>> SubscribeToTickerUpdatesAsync(string symbol, Action<DataEvent<IBinance24HPrice>> onMessage, CancellationToken ct = default) => await SubscribeToTickerUpdatesAsync(new[] { symbol }, onMessage, ct).ConfigureAwait(false); + + /// <inheritdoc /> + public async Task<CallResult<UpdateSubscription>> SubscribeToTickerUpdatesAsync(IEnumerable<string> symbols, Action<DataEvent<IBinance24HPrice>> onMessage, CancellationToken ct = default) + { + symbols.ValidateNotNull(nameof(symbols)); + + var handler = new Action<DataEvent<BinanceCombinedStream<BinanceStreamTick>>>(data => onMessage(data.As<IBinance24HPrice>(data.Data.Data).WithStreamId(data.Data.Stream).WithSymbol(data.Data.Data.Symbol))); + symbols = symbols.Select(a => a.ToLower(CultureInfo.InvariantCulture) + _symbolTickerStreamEndpoint).ToArray(); + return await _client.SubscribeAsync(_client.BaseAddress, symbols, handler, ct).ConfigureAwait(false); + } + + #endregion + + #region Composite index Streams + + /// <inheritdoc /> + public async Task<CallResult<UpdateSubscription>> SubscribeToCompositeIndexUpdatesAsync(string symbol, Action<DataEvent<BinanceFuturesStreamCompositeIndex>> onMessage, CancellationToken ct = default) + { + var action = new Action<DataEvent<BinanceCombinedStream<BinanceFuturesStreamCompositeIndex>>>(data => + { + onMessage(data.As(data.Data.Data).WithStreamId(data.Data.Stream).WithSymbol(data.Data.Data.Symbol)); + }); + return await _client.SubscribeAsync(_client.BaseAddress, new[] { symbol.ToLower(CultureInfo.InvariantCulture) + _compositeIndexEndpoint }, action, ct).ConfigureAwait(false); + } + + #endregion + + #region All Market Tickers Streams + + /// <inheritdoc /> + public async Task<CallResult<UpdateSubscription>> SubscribeToAllTickerUpdatesAsync(Action<DataEvent<IEnumerable<IBinance24HPrice>>> onMessage, CancellationToken ct = default) + { + var handler = new Action<DataEvent<BinanceCombinedStream<IEnumerable<BinanceStreamTick>>>>(data => onMessage(data.As<IEnumerable<IBinance24HPrice>>(data.Data.Data).WithStreamId(data.Data.Stream))); + return await _client.SubscribeAsync(_client.BaseAddress, new[] { _allTickerStreamEndpoint }, handler, ct).ConfigureAwait(false); + } + + #endregion + + #region Aggregate Trade Streams + + /// <inheritdoc /> + public async Task<CallResult<UpdateSubscription>> SubscribeToAggregatedTradeUpdatesAsync(string symbol, Action<DataEvent<BinanceStreamAggregatedTrade>> onMessage, CancellationToken ct = default) => await SubscribeToAggregatedTradeUpdatesAsync(new[] { symbol }, onMessage, ct).ConfigureAwait(false); + + /// <inheritdoc /> + public async Task<CallResult<UpdateSubscription>> SubscribeToAggregatedTradeUpdatesAsync(IEnumerable<string> symbols, Action<DataEvent<BinanceStreamAggregatedTrade>> onMessage, CancellationToken ct = default) + { + symbols.ValidateNotNull(nameof(symbols)); + + var handler = new Action<DataEvent<BinanceCombinedStream<BinanceStreamAggregatedTrade>>>(data => onMessage(data.As(data.Data.Data).WithStreamId(data.Data.Stream).WithSymbol(data.Data.Data.Symbol))); + symbols = symbols.Select(a => a.ToLower(CultureInfo.InvariantCulture) + _aggregatedTradesStreamEndpoint).ToArray(); + return await _client.SubscribeAsync(_client.BaseAddress, symbols, handler, ct).ConfigureAwait(false); + } + #endregion + + #region Trade Streams + + /// <inheritdoc /> + public async Task<CallResult<UpdateSubscription>> SubscribeToTradeUpdatesAsync(string symbol, + Action<DataEvent<BinanceStreamTrade>> onMessage, bool filterOutNonTradeUpdates = true, CancellationToken ct = default) => + await SubscribeToTradeUpdatesAsync(new[] { symbol }, onMessage, filterOutNonTradeUpdates, ct).ConfigureAwait(false); + + /// <inheritdoc /> + public async Task<CallResult<UpdateSubscription>> SubscribeToTradeUpdatesAsync(IEnumerable<string> symbols, + Action<DataEvent<BinanceStreamTrade>> onMessage, bool filterOutNonTradeUpdates = true, CancellationToken ct = default) + { + symbols.ValidateNotNull(nameof(symbols)); + + var handler = new Action<DataEvent<BinanceCombinedStream<BinanceStreamTrade>>>(data => + { + if (filterOutNonTradeUpdates && data.Data.Data.Type != "MARKET") + return; + + onMessage(data.As(data.Data.Data).WithStreamId(data.Data.Stream).WithSymbol(data.Data.Data.Symbol)); + }); + symbols = symbols.Select(a => a.ToLower(CultureInfo.InvariantCulture) + _tradesStreamEndpoint).ToArray(); + return await _client.SubscribeAsync(_client.BaseAddress, symbols, handler, ct).ConfigureAwait(false); + } + + #endregion + + #region Individual Symbol Book Ticker Streams + + /// <inheritdoc /> + public async Task<CallResult<UpdateSubscription>> SubscribeToBookTickerUpdatesAsync(string symbol, Action<DataEvent<BinanceFuturesStreamBookPrice>> onMessage, CancellationToken ct = default) => await SubscribeToBookTickerUpdatesAsync(new[] { symbol }, onMessage, ct).ConfigureAwait(false); + + /// <inheritdoc /> + public async Task<CallResult<UpdateSubscription>> SubscribeToBookTickerUpdatesAsync(IEnumerable<string> symbols, Action<DataEvent<BinanceFuturesStreamBookPrice>> onMessage, CancellationToken ct = default) + { + symbols.ValidateNotNull(nameof(symbols)); + + var handler = new Action<DataEvent<BinanceCombinedStream<BinanceFuturesStreamBookPrice>>>(data => onMessage(data.As(data.Data.Data).WithStreamId(data.Data.Stream).WithSymbol(data.Data.Data.Symbol))); + symbols = symbols.Select(a => a.ToLower(CultureInfo.InvariantCulture) + _bookTickerStreamEndpoint).ToArray(); + return await _client.SubscribeAsync(_client.BaseAddress, symbols, handler, ct).ConfigureAwait(false); + } + + #endregion + + #region All Book Tickers Stream + + /// <inheritdoc /> + public async Task<CallResult<UpdateSubscription>> SubscribeToAllBookTickerUpdatesAsync(Action<DataEvent<BinanceFuturesStreamBookPrice>> onMessage, CancellationToken ct = default) + { + var handler = new Action<DataEvent<BinanceCombinedStream<BinanceFuturesStreamBookPrice>>>(data => onMessage(data.As(data.Data.Data).WithStreamId(data.Data.Stream).WithSymbol(data.Data.Data.Symbol))); + return await _client.SubscribeAsync(_client.BaseAddress, new[] { _allBookTickerStreamEndpoint }, handler, ct).ConfigureAwait(false); + } + + #endregion + + #region Liquidation Order Streams + + /// <inheritdoc /> + public async Task<CallResult<UpdateSubscription>> SubscribeToLiquidationUpdatesAsync(string symbol, Action<DataEvent<BinanceFuturesStreamLiquidation>> onMessage, CancellationToken ct = default) => await SubscribeToLiquidationUpdatesAsync(new[] { symbol }, onMessage, ct).ConfigureAwait(false); + + /// <inheritdoc /> + public async Task<CallResult<UpdateSubscription>> SubscribeToLiquidationUpdatesAsync(IEnumerable<string> symbols, Action<DataEvent<BinanceFuturesStreamLiquidation>> onMessage, CancellationToken ct = default) + { + symbols.ValidateNotNull(nameof(symbols)); + + var handler = new Action<DataEvent<BinanceCombinedStream<BinanceFuturesStreamLiquidationData>>>(data => onMessage(data.As(data.Data.Data.Data).WithStreamId(data.Data.Stream).WithSymbol(data.Data.Data.Data.Symbol))); + symbols = symbols.Select(a => a.ToLower(CultureInfo.InvariantCulture) + _liquidationStreamEndpoint).ToArray(); + return await _client.SubscribeAsync(_client.BaseAddress, symbols, handler, ct).ConfigureAwait(false); + } + + #endregion + + #region All Market Liquidation Order Streams + + /// <inheritdoc /> + public async Task<CallResult<UpdateSubscription>> SubscribeToAllLiquidationUpdatesAsync(Action<DataEvent<BinanceFuturesStreamLiquidation>> onMessage, CancellationToken ct = default) + { + var handler = new Action<DataEvent<BinanceCombinedStream<BinanceFuturesStreamLiquidationData>>>(data => onMessage(data.As(data.Data.Data.Data).WithStreamId(data.Data.Stream).WithSymbol(data.Data.Data.Data.Symbol))); + return await _client.SubscribeAsync(_client.BaseAddress, new[] { _allLiquidationStreamEndpoint }, handler, ct).ConfigureAwait(false); + } + + #endregion + + #region Partial Book Depth Streams + + /// <inheritdoc /> + public async Task<CallResult<UpdateSubscription>> SubscribeToPartialOrderBookUpdatesAsync(string symbol, int levels, int? updateInterval, Action<DataEvent<IBinanceFuturesEventOrderBook>> onMessage, CancellationToken ct = default) => await SubscribeToPartialOrderBookUpdatesAsync(new[] { symbol }, levels, updateInterval, onMessage, ct).ConfigureAwait(false); + + /// <inheritdoc /> + public async Task<CallResult<UpdateSubscription>> SubscribeToPartialOrderBookUpdatesAsync(IEnumerable<string> symbols, int levels, int? updateInterval, Action<DataEvent<IBinanceFuturesEventOrderBook>> onMessage, CancellationToken ct = default) + { + symbols.ValidateNotNull(nameof(symbols)); + levels.ValidateIntValues(nameof(levels), 5, 10, 20); + updateInterval?.ValidateIntValues(nameof(updateInterval), 100, 250, 500); + + var handler = new Action<DataEvent<BinanceCombinedStream<BinanceFuturesStreamOrderBookDepth>>>(data => + { + data.Data.Data.Symbol = data.Data.Stream.Split('@')[0]; + onMessage(data.As<IBinanceFuturesEventOrderBook>(data.Data.Data).WithStreamId(data.Data.Stream).WithSymbol(data.Data.Data.Symbol)); + }); + + symbols = symbols.Select(a => a.ToLower(CultureInfo.InvariantCulture) + _partialBookDepthStreamEndpoint + levels + (updateInterval.HasValue ? $"@{updateInterval.Value}ms" : "")).ToArray(); + return await _client.SubscribeAsync(_client.BaseAddress, symbols, handler, ct).ConfigureAwait(false); + } + + #endregion + + #region Diff. Book Depth Streams + + /// <inheritdoc /> + public async Task<CallResult<UpdateSubscription>> SubscribeToOrderBookUpdatesAsync(string symbol, int? updateInterval, Action<DataEvent<IBinanceFuturesEventOrderBook>> onMessage, CancellationToken ct = default) => await SubscribeToOrderBookUpdatesAsync(new[] { symbol }, updateInterval, onMessage, ct).ConfigureAwait(false); + + /// <inheritdoc /> + public async Task<CallResult<UpdateSubscription>> SubscribeToOrderBookUpdatesAsync(IEnumerable<string> symbols, int? updateInterval, Action<DataEvent<IBinanceFuturesEventOrderBook>> onMessage, CancellationToken ct = default) + { + symbols.ValidateNotNull(nameof(symbols)); + + updateInterval?.ValidateIntValues(nameof(updateInterval), 100, 250, 500); + var handler = new Action<DataEvent<BinanceCombinedStream<BinanceFuturesStreamOrderBookDepth>>>(data => onMessage(data.As<IBinanceFuturesEventOrderBook>(data.Data.Data).WithStreamId(data.Data.Stream).WithSymbol(data.Data.Data.Symbol))); + symbols = symbols.Select(a => a.ToLower(CultureInfo.InvariantCulture) + _depthStreamEndpoint + (updateInterval.HasValue ? $"@{updateInterval.Value}ms" : "")).ToArray(); + return await _client.SubscribeAsync(_client.BaseAddress, symbols, handler, ct).ConfigureAwait(false); + } + + #endregion + + #region Contract Info Streams + + /// <inheritdoc /> + public async Task<CallResult<UpdateSubscription>> SubscribeToSymbolUpdatesAsync(Action<DataEvent<BinanceFuturesStreamSymbolUpdate>> onMessage, CancellationToken ct = default) + { + var handler = new Action<DataEvent<BinanceCombinedStream<BinanceFuturesStreamSymbolUpdate>>>(data => onMessage(data.As(data.Data.Data).WithStreamId(data.Data.Stream).WithSymbol(data.Data.Data.Symbol))); + return await _client.SubscribeAsync(_client.BaseAddress, new[] { "!contractInfo" }, handler, ct).ConfigureAwait(false); + } + + #endregion + + #region Asset Index Streams + + /// <inheritdoc /> + public async Task<CallResult<UpdateSubscription>> SubscribeToAssetIndexUpdatesAsync(Action<DataEvent<IEnumerable<BinanceFuturesStreamAssetIndexUpdate>>> onMessage, CancellationToken ct = default) + { + var handler = new Action<DataEvent<BinanceCombinedStream<IEnumerable<BinanceFuturesStreamAssetIndexUpdate>>>>(data => onMessage(data.As(data.Data.Data).WithStreamId(data.Data.Stream))); + return await _client.SubscribeAsync(_client.BaseAddress, new[] { "!assetIndex@arr" }, handler, ct).ConfigureAwait(false); + } + + /// <inheritdoc /> + public async Task<CallResult<UpdateSubscription>> SubscribeToAssetIndexUpdatesAsync(string symbol, Action<DataEvent<BinanceFuturesStreamAssetIndexUpdate>> onMessage, CancellationToken ct = default) + { + var handler = new Action<DataEvent<BinanceCombinedStream<BinanceFuturesStreamAssetIndexUpdate>>>(data => onMessage(data.As(data.Data.Data).WithStreamId(data.Data.Stream).WithSymbol(data.Data.Data.Symbol))); + return await _client.SubscribeAsync(_client.BaseAddress, new[] { symbol.ToLowerInvariant() + "@assetIndex" }, handler, ct).ConfigureAwait(false); + } + + #endregion + + #endregion + + } +} diff --git a/Binance.Net/Clients/UsdFuturesApi/BinanceSocketClientUsdFuturesApiShared.cs b/Binance.Net/Clients/UsdFuturesApi/BinanceSocketClientUsdFuturesApiShared.cs index 87f9f3177..ec5b5ba7b 100644 --- a/Binance.Net/Clients/UsdFuturesApi/BinanceSocketClientUsdFuturesApiShared.cs +++ b/Binance.Net/Clients/UsdFuturesApi/BinanceSocketClientUsdFuturesApiShared.cs @@ -23,7 +23,7 @@ async Task<ExchangeResult<UpdateSubscription>> ITickerSocketClient.SubscribeToTi return new ExchangeResult<UpdateSubscription>(Exchange, validationError); var symbol = request.Symbol.GetSymbol(FormatSymbol); - var result = await SubscribeToTickerUpdatesAsync(symbol, update => handler(update.AsExchangeEvent(Exchange, new SharedSpotTicker(symbol, update.Data.LastPrice, update.Data.HighPrice, update.Data.LowPrice, update.Data.Volume, update.Data.PriceChangePercent))), ct: ct).ConfigureAwait(false); + var result = await ExchangeData.SubscribeToTickerUpdatesAsync(symbol, update => handler(update.AsExchangeEvent(Exchange, new SharedSpotTicker(symbol, update.Data.LastPrice, update.Data.HighPrice, update.Data.LowPrice, update.Data.Volume, update.Data.PriceChangePercent))), ct: ct).ConfigureAwait(false); return new ExchangeResult<UpdateSubscription>(Exchange, result); } @@ -39,7 +39,7 @@ async Task<ExchangeResult<UpdateSubscription>> ITickersSocketClient.SubscribeToA if (validationError != null) return new ExchangeResult<UpdateSubscription>(Exchange, validationError); - var result = await SubscribeToAllTickerUpdatesAsync(update => + var result = await ExchangeData.SubscribeToAllTickerUpdatesAsync(update => { var data = update.Data; if (request.TradingMode != null) @@ -66,7 +66,7 @@ async Task<ExchangeResult<UpdateSubscription>> ITradeSocketClient.SubscribeToTra return new ExchangeResult<UpdateSubscription>(Exchange, validationError); var symbol = request.Symbol.GetSymbol(FormatSymbol); - var result = await SubscribeToAggregatedTradeUpdatesAsync(symbol, update => handler(update.AsExchangeEvent<IEnumerable<SharedTrade>>(Exchange, new[] { new SharedTrade(update.Data.Quantity, update.Data.Price, update.Data.TradeTime) })), ct:ct).ConfigureAwait(false); + var result = await ExchangeData.SubscribeToAggregatedTradeUpdatesAsync(symbol, update => handler(update.AsExchangeEvent<IEnumerable<SharedTrade>>(Exchange, new[] { new SharedTrade(update.Data.Quantity, update.Data.Price, update.Data.TradeTime) })), ct:ct).ConfigureAwait(false); return new ExchangeResult<UpdateSubscription>(Exchange, result); } @@ -83,7 +83,7 @@ async Task<ExchangeResult<UpdateSubscription>> IBookTickerSocketClient.Subscribe return new ExchangeResult<UpdateSubscription>(Exchange, validationError); var symbol = request.Symbol.GetSymbol(FormatSymbol); - var result = await SubscribeToBookTickerUpdatesAsync(symbol, update => handler(update.AsExchangeEvent(Exchange, new SharedBookTicker(update.Data.BestAskPrice, update.Data.BestAskQuantity, update.Data.BestBidPrice, update.Data.BestBidQuantity))), ct).ConfigureAwait(false); + var result = await ExchangeData.SubscribeToBookTickerUpdatesAsync(symbol, update => handler(update.AsExchangeEvent(Exchange, new SharedBookTicker(update.Data.BestAskPrice, update.Data.BestAskQuantity, update.Data.BestBidPrice, update.Data.BestBidQuantity))), ct).ConfigureAwait(false); return new ExchangeResult<UpdateSubscription>(Exchange, result); } @@ -104,7 +104,7 @@ async Task<ExchangeResult<UpdateSubscription>> IBalanceSocketClient.SubscribeToB if (validationError != null) return new ExchangeResult<UpdateSubscription>(Exchange, validationError); - var result = await SubscribeToUserDataUpdatesAsync(request.ListenKey!, + var result = await Account.SubscribeToUserDataUpdatesAsync(request.ListenKey!, onAccountUpdate: update => handler(update.AsExchangeEvent<IEnumerable<SharedBalance>>(Exchange, update.Data.UpdateData.Balances.Select(x => new SharedBalance(x.Asset, x.WalletBalance, x.WalletBalance)).ToArray())), ct: ct).ConfigureAwait(false); @@ -128,7 +128,7 @@ async Task<ExchangeResult<UpdateSubscription>> IFuturesOrderSocketClient.Subscri if (validationError != null) return new ExchangeResult<UpdateSubscription>(Exchange, validationError); - var result = await SubscribeToUserDataUpdatesAsync(request.ListenKey!, + var result = await Account.SubscribeToUserDataUpdatesAsync(request.ListenKey!, onOrderUpdate: update => handler(update.AsExchangeEvent<IEnumerable<SharedFuturesOrder>>(Exchange, new[] { new SharedFuturesOrder( update.Data.UpdateData.Symbol, @@ -174,7 +174,7 @@ async Task<ExchangeResult<UpdateSubscription>> IKlineSocketClient.SubscribeToKli return new ExchangeResult<UpdateSubscription>(Exchange, validationError); var symbol = request.Symbol.GetSymbol(FormatSymbol); - var result = await SubscribeToKlineUpdatesAsync(symbol, interval, update => handler(update.AsExchangeEvent(Exchange, new SharedKline(update.Data.Data.OpenTime, update.Data.Data.ClosePrice, update.Data.Data.HighPrice, update.Data.Data.LowPrice, update.Data.Data.OpenPrice, update.Data.Data.Volume))), ct).ConfigureAwait(false); + var result = await ExchangeData.SubscribeToKlineUpdatesAsync(symbol, interval, update => handler(update.AsExchangeEvent(Exchange, new SharedKline(update.Data.Data.OpenTime, update.Data.Data.ClosePrice, update.Data.Data.HighPrice, update.Data.Data.LowPrice, update.Data.Data.OpenPrice, update.Data.Data.Volume))), ct).ConfigureAwait(false); return new ExchangeResult<UpdateSubscription>(Exchange, result); } @@ -189,7 +189,7 @@ async Task<ExchangeResult<UpdateSubscription>> IOrderBookSocketClient.SubscribeT return new ExchangeResult<UpdateSubscription>(Exchange, validationError); var symbol = request.Symbol.GetSymbol(FormatSymbol); - var result = await SubscribeToPartialOrderBookUpdatesAsync(symbol, request.Limit ?? 20, 100, update => handler(update.AsExchangeEvent(Exchange, new SharedOrderBook(update.Data.Asks, update.Data.Bids))), ct).ConfigureAwait(false); + var result = await ExchangeData.SubscribeToPartialOrderBookUpdatesAsync(symbol, request.Limit ?? 20, 100, update => handler(update.AsExchangeEvent(Exchange, new SharedOrderBook(update.Data.Asks, update.Data.Bids))), ct).ConfigureAwait(false); return new ExchangeResult<UpdateSubscription>(Exchange, result); } @@ -209,7 +209,7 @@ async Task<ExchangeResult<UpdateSubscription>> IPositionSocketClient.SubscribeTo if (validationError != null) return new ExchangeResult<UpdateSubscription>(Exchange, validationError); - var result = await SubscribeToUserDataUpdatesAsync(request.ListenKey!, + var result = await Account.SubscribeToUserDataUpdatesAsync(request.ListenKey!, onAccountUpdate: update => handler(update.AsExchangeEvent<IEnumerable<SharedPosition>>(Exchange, update.Data.UpdateData.Positions.Select(x => new SharedPosition(x.Symbol, x.Quantity, update.Data.EventTime) { AverageOpenPrice = x.EntryPrice, diff --git a/Binance.Net/Clients/UsdFuturesApi/BinanceSocketClientUsdFuturesApiTrading.cs b/Binance.Net/Clients/UsdFuturesApi/BinanceSocketClientUsdFuturesApiTrading.cs new file mode 100644 index 000000000..a71f507ea --- /dev/null +++ b/Binance.Net/Clients/UsdFuturesApi/BinanceSocketClientUsdFuturesApiTrading.cs @@ -0,0 +1,175 @@ +using Binance.Net.Enums; +using Binance.Net.Interfaces.Clients.UsdFuturesApi; +using Binance.Net.Objects; +using Binance.Net.Objects.Models.Futures; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Binance.Net.Clients.UsdFuturesApi +{ + internal class BinanceSocketClientUsdFuturesApiTrading : IBinanceSocketClientUsdFuturesApiTrading + { + private readonly BinanceSocketClientUsdFuturesApi _client; + private readonly ILogger _logger; + + internal BinanceSocketClientUsdFuturesApiTrading(ILogger logger, BinanceSocketClientUsdFuturesApi client) + { + _client = client; + _logger = logger; + } + + #region Queries + + #region Place Order + + /// <inheritdoc /> + public async Task<CallResult<BinanceResponse<BinanceUsdFuturesOrder>>> PlaceOrderAsync(string symbol, + Enums.OrderSide side, + FuturesOrderType type, + decimal? quantity, + decimal? price = null, + Enums.PositionSide? positionSide = null, + TimeInForce? timeInForce = null, + bool? reduceOnly = null, + string? newClientOrderId = null, + decimal? stopPrice = null, + decimal? activationPrice = null, + decimal? callbackRate = null, + WorkingType? workingType = null, + bool? closePosition = null, + OrderResponseType? orderResponseType = null, + bool? priceProtect = null, + PriceMatch? priceMatch = null, + SelfTradePreventionMode? selfTradePreventionMode = null, + DateTime? goodTillDate = null, + int? receiveWindow = null, + CancellationToken ct = default) + { + if (closePosition == true && positionSide != null) + { + if (positionSide == Enums.PositionSide.Short && side == Enums.OrderSide.Sell) + throw new ArgumentException("Can't close short position with order side sell"); + if (positionSide == Enums.PositionSide.Long && side == Enums.OrderSide.Buy) + throw new ArgumentException("Can't close long position with order side buy"); + } + + if (orderResponseType == OrderResponseType.Full) + throw new ArgumentException("OrderResponseType.Full is not supported in Futures"); + + string clientOrderId = newClientOrderId ?? ExchangeHelpers.AppendRandomString(_client._brokerId, 32); + + var parameters = new ParameterCollection(); + parameters.AddParameter("symbol", symbol); + parameters.AddEnum("side", side); + parameters.AddEnum("type", type); + parameters.AddOptionalParameter("quantity", quantity?.ToString(CultureInfo.InvariantCulture)); + parameters.AddOptionalParameter("newClientOrderId", clientOrderId); + parameters.AddOptionalParameter("price", price?.ToString(CultureInfo.InvariantCulture)); + parameters.AddOptionalEnum("timeInForce", timeInForce); + parameters.AddOptionalEnum("positionSide", positionSide); + parameters.AddOptionalParameter("stopPrice", stopPrice?.ToString(CultureInfo.InvariantCulture)); + parameters.AddOptionalParameter("activationPrice", activationPrice?.ToString(CultureInfo.InvariantCulture)); + parameters.AddOptionalParameter("callbackRate", callbackRate?.ToString(CultureInfo.InvariantCulture)); + parameters.AddOptionalEnum("workingType", workingType); + parameters.AddOptionalParameter("reduceOnly", reduceOnly?.ToString().ToLower()); + parameters.AddOptionalParameter("closePosition", closePosition?.ToString().ToLower()); + parameters.AddOptionalEnum("newOrderRespType", orderResponseType); + parameters.AddOptionalParameter("priceProtect", priceProtect?.ToString().ToUpper()); + parameters.AddOptionalEnum("priceMatch", priceMatch); + parameters.AddOptionalEnum("selfTradePreventionMode", selfTradePreventionMode); + parameters.AddOptionalMilliseconds("goodTillDate", goodTillDate); + parameters.AddOptionalParameter("recvWindow", receiveWindow?.ToString(CultureInfo.InvariantCulture)); + + return await _client.QueryAsync<BinanceUsdFuturesOrder>(_client.ClientOptions.Environment.UsdFuturesSocketApiAddress!.AppendPath("ws-fapi/v1"), $"order.place", parameters, true, true, weight: 0, ct: ct).ConfigureAwait(false); + } + + #endregion + + #region Edit Order + + /// <inheritdoc /> + public async Task<CallResult<BinanceResponse<BinanceUsdFuturesOrder>>> EditOrderAsync(string symbol, OrderSide side, decimal quantity, decimal price, long? orderId = null, string? origClientOrderId = null, long? receiveWindow = null, CancellationToken ct = default) + { + if (!orderId.HasValue && string.IsNullOrEmpty(origClientOrderId)) + throw new ArgumentException("Either orderId or origClientOrderId must be sent"); + + var parameters = new ParameterCollection + { + { "symbol", symbol }, + { "side", EnumConverter.GetString(side) }, + { "quantity", quantity.ToString(CultureInfo.InvariantCulture) }, + { "price", price.ToString(CultureInfo.InvariantCulture) }, + }; + parameters.AddOptionalParameter("orderId", orderId?.ToString(CultureInfo.InvariantCulture)); + parameters.AddOptionalParameter("origClientOrderId", origClientOrderId); + parameters.AddOptionalParameter("recvWindow", receiveWindow?.ToString(CultureInfo.InvariantCulture)); + + return await _client.QueryAsync<BinanceUsdFuturesOrder>(_client.ClientOptions.Environment.UsdFuturesSocketApiAddress!.AppendPath("ws-fapi/v1"), $"order.modify", parameters, true, true, weight: 1, ct: ct).ConfigureAwait(false); + + } + + #endregion + + #region Cancel Order + + /// <inheritdoc /> + public async Task<CallResult<BinanceResponse<BinanceUsdFuturesOrder>>> CancelOrderAsync(string symbol, long? orderId = null, string? origClientOrderId = null, long? receiveWindow = null, CancellationToken ct = default) + { + if (!orderId.HasValue && string.IsNullOrEmpty(origClientOrderId)) + throw new ArgumentException("Either orderId or origClientOrderId must be sent"); + + var parameters = new ParameterCollection + { + { "symbol", symbol } + }; + parameters.AddOptionalParameter("orderId", orderId?.ToString(CultureInfo.InvariantCulture)); + parameters.AddOptionalParameter("origClientOrderId", origClientOrderId); + parameters.AddOptionalParameter("recvWindow", receiveWindow?.ToString(CultureInfo.InvariantCulture)); + + return await _client.QueryAsync<BinanceUsdFuturesOrder>(_client.ClientOptions.Environment.UsdFuturesSocketApiAddress!.AppendPath("ws-fapi/v1"), $"order.cancel", parameters, true, true, weight: 1, ct: ct).ConfigureAwait(false); + } + + #endregion + + #region Get Order + + /// <inheritdoc /> + public async Task<CallResult<BinanceResponse<BinanceUsdFuturesOrder>>> GetOrderAsync(string symbol, long? orderId = null, string? origClientOrderId = null, long? receiveWindow = null, CancellationToken ct = default) + { + if (orderId == null && origClientOrderId == null) + throw new ArgumentException("Either orderId or origClientOrderId must be sent"); + + var parameters = new ParameterCollection + { + { "symbol", symbol } + }; + parameters.AddOptionalParameter("orderId", orderId?.ToString(CultureInfo.InvariantCulture)); + parameters.AddOptionalParameter("origClientOrderId", origClientOrderId); + parameters.AddOptionalParameter("recvWindow", receiveWindow?.ToString(CultureInfo.InvariantCulture)); + + return await _client.QueryAsync<BinanceUsdFuturesOrder>(_client.ClientOptions.Environment.UsdFuturesSocketApiAddress!.AppendPath("ws-fapi/v1"), $"order.status", parameters, true, true, weight: 1, ct: ct).ConfigureAwait(false); + } + + #endregion + + #region Get Positions + + /// <inheritdoc /> + public async Task<CallResult<BinanceResponse<IEnumerable<BinancePositionV3>>>> GetPositionsAsync(string? symbol = null, long? receiveWindow = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptional("symbol", symbol); + parameters.AddOptionalParameter("recvWindow", receiveWindow?.ToString(CultureInfo.InvariantCulture)); + + return await _client.QueryAsync<IEnumerable<BinancePositionV3>>(_client.ClientOptions.Environment.UsdFuturesSocketApiAddress!.AppendPath("ws-fapi/v1"), $"v2/account.position", parameters, true, true, weight: 5, ct: ct).ConfigureAwait(false); + } + + #endregion + + #endregion + + #region Streams + #endregion + } +} diff --git a/Binance.Net/Interfaces/Clients/UsdFuturesApi/IBinanceRestClientUsdFuturesApiAccount.cs b/Binance.Net/Interfaces/Clients/UsdFuturesApi/IBinanceRestClientUsdFuturesApiAccount.cs index a2ae3b6ea..5f74087f5 100644 --- a/Binance.Net/Interfaces/Clients/UsdFuturesApi/IBinanceRestClientUsdFuturesApiAccount.cs +++ b/Binance.Net/Interfaces/Clients/UsdFuturesApi/IBinanceRestClientUsdFuturesApiAccount.cs @@ -140,7 +140,7 @@ Task<WebCallResult<IEnumerable<BinanceFuturesQuantileEstimation>>> GetPositionAd /// <param name="ct">Cancellation token</param> Task<WebCallResult<BinanceFuturesAccountInfoV3>> GetAccountInfoV3Async(long? receiveWindow = null, CancellationToken ct = default); - /// <summary>. + /// <summary> /// Gets account balances /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#futures-account-balance-v2-user_data" /></para> /// </summary> @@ -149,7 +149,7 @@ Task<WebCallResult<IEnumerable<BinanceFuturesQuantileEstimation>>> GetPositionAd /// <returns>The account information</returns> Task<WebCallResult<IEnumerable<BinanceUsdFuturesAccountBalance>>> GetBalancesAsync(long? receiveWindow = null, CancellationToken ct = default); - /// <summary>. + /// <summary> /// Get user's Multi-Assets mode (Multi-Assets Mode or Single-Asset Mode) on Every symbol /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#get-current-multi-assets-mode-user_data" /></para> /// </summary> @@ -158,7 +158,7 @@ Task<WebCallResult<IEnumerable<BinanceFuturesQuantileEstimation>>> GetPositionAd /// <returns>Multi asset mode</returns> Task<WebCallResult<BinanceFuturesMultiAssetMode>> GetMultiAssetsModeAsync(long? receiveWindow = null, CancellationToken ct = default); - /// <summary>. + /// <summary> /// Set user's Multi-Assets mode (Multi-Assets Mode or Single-Asset Mode) on Every symbol /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#change-multi-assets-mode-trade" /></para> /// </summary> diff --git a/Binance.Net/Interfaces/Clients/UsdFuturesApi/IBinanceSocketClientUsdFuturesApi.cs b/Binance.Net/Interfaces/Clients/UsdFuturesApi/IBinanceSocketClientUsdFuturesApi.cs index deb74659d..ef368a77b 100644 --- a/Binance.Net/Interfaces/Clients/UsdFuturesApi/IBinanceSocketClientUsdFuturesApi.cs +++ b/Binance.Net/Interfaces/Clients/UsdFuturesApi/IBinanceSocketClientUsdFuturesApi.cs @@ -1,10 +1,4 @@ -using Binance.Net.Enums; -using Binance.Net.Objects.Models; -using Binance.Net.Objects.Models.Futures.Socket; -using Binance.Net.Objects.Models.Spot.Socket; -using CryptoExchange.Net.Objects.Sockets; - -namespace Binance.Net.Interfaces.Clients.UsdFuturesApi +namespace Binance.Net.Interfaces.Clients.UsdFuturesApi { /// <summary> /// Binance USD futures streams @@ -17,375 +11,16 @@ public interface IBinanceSocketClientUsdFuturesApi : ISocketApiClient, IDisposab IBinanceSocketClientUsdFuturesApiShared SharedClient { get; } /// <summary> - /// Subscribes to the aggregated trades update stream for the provided symbol - /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#aggregate-trade-streams" /></para> - /// </summary> - /// <param name="symbol">The symbol, for example `ETHUSDT`</param> - /// <param name="onMessage">The event handler for the received data</param> - /// <param name="ct">Cancellation token for closing this subscription</param> - /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> - Task<CallResult<UpdateSubscription>> SubscribeToAggregatedTradeUpdatesAsync(string symbol, Action<DataEvent<BinanceStreamAggregatedTrade>> onMessage, CancellationToken ct = default); - - /// <summary> - /// Subscribe to individual trade update. NOTE: This endpoint stream isn't document and therefor might be changed or removed without prior notice - /// </summary> - /// <param name="symbol">Symbol to subscribe, for example `ETHUSDT`</param> - /// <param name="onMessage">The event handler for the received data</param> - /// <param name="filterOutNonTradeUpdates">Filter out any update which isn't a trade. Occasionally different updates (like INSURANCE_FUND updates) will occur on this stream. By default these are ignored</param> - /// <param name="ct">Cancellation token for closing this subscription</param> - /// <returns></returns> - Task<CallResult<UpdateSubscription>> SubscribeToTradeUpdatesAsync(string symbol, - Action<DataEvent<BinanceStreamTrade>> onMessage, bool filterOutNonTradeUpdates = true, CancellationToken ct = default); - - /// <summary> - /// Subscribe to individual trade update. NOTE: This endpoint stream isn't document and therefor might be changed or removed without prior notice - /// </summary> - /// <param name="symbols">Symbols to subscribe, for example `ETHUSDT`</param> - /// <param name="onMessage">The event handler for the received data</param> - /// <param name="filterOutNonTradeUpdates">Filter out any update which isn't a trade. Occasionally different updates (like INSURANCE_FUND updates) will occur on this stream. By default these are ignored</param> - /// <param name="ct">Cancellation token for closing this subscription</param> - /// <returns></returns> - Task<CallResult<UpdateSubscription>> SubscribeToTradeUpdatesAsync(IEnumerable<string> symbols, - Action<DataEvent<BinanceStreamTrade>> onMessage, bool filterOutNonTradeUpdates = true, CancellationToken ct = default); - - /// <summary> - /// Subscribes to the aggregated trades update stream for the provided symbols - /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#aggregate-trade-streams" /></para> - /// </summary> - /// <param name="symbols">The symbols, for example `ETHUSDT`</param> - /// <param name="onMessage">The event handler for the received data</param> - /// <param name="ct">Cancellation token for closing this subscription</param> - /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> - Task<CallResult<UpdateSubscription>> SubscribeToAggregatedTradeUpdatesAsync(IEnumerable<string> symbols, Action<DataEvent<BinanceStreamAggregatedTrade>> onMessage, CancellationToken ct = default); - - /// <summary> - /// Subscribes to the Mark price update stream for a single symbol - /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#mark-price-stream" /></para> - /// </summary> - /// <param name="symbol">The symbol, for example `ETHUSDT`</param> - /// <param name="updateInterval">Update interval in milliseconds, either 1000 or 3000. Defaults to 3000</param> - /// <param name="onMessage">The event handler for the received data</param> - /// <param name="ct">Cancellation token for closing this subscription</param> - /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> - Task<CallResult<UpdateSubscription>> SubscribeToMarkPriceUpdatesAsync(string symbol, int? updateInterval, Action<DataEvent<BinanceFuturesUsdtStreamMarkPrice>> onMessage, CancellationToken ct = default); - - /// <summary> - /// Subscribes to the Mark price update stream for a list of symbols - /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#mark-price-stream" /></para> - /// </summary> - /// <param name="symbols">The symbols, for example `ETHUSDT`</param> - /// <param name="updateInterval">Update interval in milliseconds, either 1000 or 3000. Defaults to 3000</param> - /// <param name="onMessage">The event handler for the received data</param> - /// <param name="ct">Cancellation token for closing this subscription</param> - /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> - Task<CallResult<UpdateSubscription>> SubscribeToMarkPriceUpdatesAsync(IEnumerable<string> symbols, int? updateInterval, Action<DataEvent<BinanceFuturesUsdtStreamMarkPrice>> onMessage, CancellationToken ct = default); - - /// <summary> - /// Subscribes to the candlestick update stream for the provided symbol - /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#kline-candlestick-streams" /></para> - /// </summary> - /// <param name="symbol">The symbol, for example `ETHUSDT`</param> - /// <param name="interval">The interval of the candlesticks</param> - /// <param name="onMessage">The event handler for the received data</param> - /// <param name="ct">Cancellation token for closing this subscription</param> - /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> - Task<CallResult<UpdateSubscription>> SubscribeToKlineUpdatesAsync(string symbol, KlineInterval interval, Action<DataEvent<IBinanceStreamKlineData>> onMessage, CancellationToken ct = default); - - /// <summary> - /// Subscribes to the candlestick update stream for the provided symbol and intervals - /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#kline-candlestick-streams" /></para> - /// </summary> - /// <param name="symbol">The symbol, for example `ETHUSDT`</param> - /// <param name="intervals">The intervals of the candlesticks</param> - /// <param name="onMessage">The event handler for the received data</param> - /// <param name="ct">Cancellation token for closing this subscription</param> - /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> - Task<CallResult<UpdateSubscription>> SubscribeToKlineUpdatesAsync(string symbol, IEnumerable<KlineInterval> intervals, Action<DataEvent<IBinanceStreamKlineData>> onMessage, CancellationToken ct = default); - - /// <summary> - /// Subscribes to the candlestick update stream for the provided symbols - /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#kline-candlestick-streams" /></para> - /// </summary> - /// <param name="symbols">The symbols, for example `ETHUSDT`</param> - /// <param name="interval">The interval of the candlesticks</param> - /// <param name="onMessage">The event handler for the received data</param> - /// <param name="ct">Cancellation token for closing this subscription</param> - /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> - Task<CallResult<UpdateSubscription>> SubscribeToKlineUpdatesAsync(IEnumerable<string> symbols, KlineInterval interval, Action<DataEvent<IBinanceStreamKlineData>> onMessage, CancellationToken ct = default); - - /// <summary> - /// Subscribes to the candlestick update stream for the provided symbols and intervals - /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#kline-candlestick-streams" /></para> - /// </summary> - /// <param name="symbols">The symbols, for example `ETHUSDT`</param> - /// <param name="intervals">The intervals of the candlesticks</param> - /// <param name="onMessage">The event handler for the received data</param> - /// <param name="ct">Cancellation token for closing this subscription</param> - /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> - Task<CallResult<UpdateSubscription>> SubscribeToKlineUpdatesAsync(IEnumerable<string> symbols, IEnumerable<KlineInterval> intervals, Action<DataEvent<IBinanceStreamKlineData>> onMessage, CancellationToken ct = default); - - /// <summary> - /// Subscribes to the continuous contract candlestick update stream for the provided pair - /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#continuous-contract-kline-candlestick-streams" /></para> - /// </summary> - /// <param name="pair">The pair, for example `ETHUSDT`</param> - /// <param name="contractType">The contract type</param> - /// <param name="interval">The interval of the candlesticks</param> - /// <param name="onMessage">The event handler for the received data</param> - /// <param name="ct">Cancellation token for closing this subscription</param> - /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> - Task<CallResult<UpdateSubscription>> SubscribeToContinuousContractKlineUpdatesAsync(string pair, ContractType contractType, KlineInterval interval, Action<DataEvent<BinanceStreamContinuousKlineData>> onMessage, CancellationToken ct = default); - - /// <summary> - /// Subscribes to the continuous contract candlestick update stream for the provided pairs - /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#continuous-contract-kline-candlestick-streams" /></para> - /// </summary> - /// <param name="pairs">The pairs, for example `ETHUSDT`</param> - /// <param name="contractType">The contract type</param> - /// <param name="interval">The interval of the candlesticks</param> - /// <param name="onMessage">The event handler for the received data</param> - /// <param name="ct">Cancellation token for closing this subscription</param> - /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> - Task<CallResult<UpdateSubscription>> SubscribeToContinuousContractKlineUpdatesAsync(IEnumerable<string> pairs, ContractType contractType, KlineInterval interval, Action<DataEvent<BinanceStreamContinuousKlineData>> onMessage, CancellationToken ct = default); - - /// <summary> - /// Subscribes to mini ticker updates stream for a specific symbol - /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#individual-symbol-mini-ticker-stream" /></para> - /// </summary> - /// <param name="symbol">The symbol to subscribe to, for example `ETHUSDT`</param> - /// <param name="onMessage">The event handler for the received data</param> - /// <param name="ct">Cancellation token for closing this subscription</param> - /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> - Task<CallResult<UpdateSubscription>> SubscribeToMiniTickerUpdatesAsync(string symbol, Action<DataEvent<IBinanceMiniTick>> onMessage, CancellationToken ct = default); - - /// <summary> - /// Subscribes to mini ticker updates stream for a list of symbol - /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#individual-symbol-mini-ticker-stream" /></para> - /// </summary> - /// <param name="symbols">The symbols to subscribe to, for example `ETHUSDT`</param> - /// <param name="onMessage">The event handler for the received data</param> - /// <param name="ct">Cancellation token for closing this subscription</param> - /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> - Task<CallResult<UpdateSubscription>> SubscribeToMiniTickerUpdatesAsync(IEnumerable<string> symbols, Action<DataEvent<IBinanceMiniTick>> onMessage, CancellationToken ct = default); - - /// <summary> - /// Subscribes to mini ticker updates stream for all symbols - /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#all-market-mini-tickers-stream" /></para> - /// </summary> - /// <param name="onMessage">The event handler for the received data</param> - /// <param name="ct">Cancellation token for closing this subscription</param> - /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> - Task<CallResult<UpdateSubscription>> SubscribeToAllMiniTickerUpdatesAsync(Action<DataEvent<IEnumerable<IBinanceMiniTick>>> onMessage, CancellationToken ct = default); - - /// <summary> - /// Subscribes to ticker updates stream for a specific symbol - /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#individual-symbol-ticker-streams" /></para> - /// </summary> - /// <param name="symbol">The symbol to subscribe to, for example `ETHUSDT`</param> - /// <param name="onMessage">The event handler for the received data</param> - /// <param name="ct">Cancellation token for closing this subscription</param> - /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> - Task<CallResult<UpdateSubscription>> SubscribeToTickerUpdatesAsync(string symbol, Action<DataEvent<IBinance24HPrice>> onMessage, CancellationToken ct = default); - - /// <summary> - /// Subscribes to ticker updates stream for a specific symbol - /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#individual-symbol-ticker-streams" /></para> - /// </summary> - /// <param name="symbols">The symbols to subscribe to, for example `ETHUSDT`</param> - /// <param name="onMessage">The event handler for the received data</param> - /// <param name="ct">Cancellation token for closing this subscription</param> - /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> - Task<CallResult<UpdateSubscription>> SubscribeToTickerUpdatesAsync(IEnumerable<string> symbols, Action<DataEvent<IBinance24HPrice>> onMessage, CancellationToken ct = default); - - /// <summary> - /// Subscribes to ticker updates stream for all symbols - /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#all-market-tickers-streams" /></para> - /// </summary> - /// <param name="onMessage">The event handler for the received data</param> - /// <param name="ct">Cancellation token for closing this subscription</param> - /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> - Task<CallResult<UpdateSubscription>> SubscribeToAllTickerUpdatesAsync(Action<DataEvent<IEnumerable<IBinance24HPrice>>> onMessage, CancellationToken ct = default); - - /// <summary> - /// Subscribes to all book ticker update streams - /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#all-book-tickers-stream" /></para> - /// </summary> - /// <param name="onMessage">The event handler for the received data</param> - /// <param name="ct">Cancellation token for closing this subscription</param> - /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> - Task<CallResult<UpdateSubscription>> SubscribeToAllBookTickerUpdatesAsync(Action<DataEvent<BinanceFuturesStreamBookPrice>> onMessage, CancellationToken ct = default); - - /// <summary> - /// Subscribes to the book ticker update stream for the provided symbol - /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#individual-symbol-book-ticker-streams" /></para> - /// </summary> - /// <param name="symbol">The symbol, for example `ETHUSDT`</param> - /// <param name="onMessage">The event handler for the received data</param> - /// <param name="ct">Cancellation token for closing this subscription</param> - /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> - Task<CallResult<UpdateSubscription>> SubscribeToBookTickerUpdatesAsync(string symbol, Action<DataEvent<BinanceFuturesStreamBookPrice>> onMessage, CancellationToken ct = default); - - /// <summary> - /// Subscribes to the book ticker update stream for the provided symbols - /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#individual-symbol-book-ticker-streams" /></para> - /// </summary> - /// <param name="symbols">The symbols, for example `ETHUSDT`</param> - /// <param name="onMessage">The event handler for the received data</param> - /// <param name="ct">Cancellation token for closing this subscription</param> - /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> - Task<CallResult<UpdateSubscription>> SubscribeToBookTickerUpdatesAsync(IEnumerable<string> symbols, Action<DataEvent<BinanceFuturesStreamBookPrice>> onMessage, CancellationToken ct = default); - - /// <summary> - /// Subscribes to specific symbol forced liquidations stream - /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#liquidation-order-streams" /></para> - /// </summary> - /// <param name="symbol">The symbol, for example `ETHUSDT`</param> - /// <param name="ct">Cancellation token for closing this subscription</param> - /// <param name="onMessage">The event handler for the received data</param> - /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> - Task<CallResult<UpdateSubscription>> SubscribeToLiquidationUpdatesAsync(string symbol, Action<DataEvent<BinanceFuturesStreamLiquidation>> onMessage, CancellationToken ct = default); - - /// <summary> - /// Subscribes to list of symbol forced liquidations stream - /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#liquidation-order-streams" /></para> - /// </summary> - /// <param name="symbols">The symbols, for example `ETHUSDT`</param> - /// <param name="onMessage">The event handler for the received data</param> - /// <param name="ct">Cancellation token for closing this subscription</param> - /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> - Task<CallResult<UpdateSubscription>> SubscribeToLiquidationUpdatesAsync(IEnumerable<string> symbols, Action<DataEvent<BinanceFuturesStreamLiquidation>> onMessage, CancellationToken ct = default); - - /// <summary> - /// Subscribes to all forced liquidations stream - /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#all-market-liquidation-order-streams" /></para> - /// </summary> - /// <param name="onMessage">The event handler for the received data</param> - /// <param name="ct">Cancellation token for closing this subscription</param> - /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> - Task<CallResult<UpdateSubscription>> SubscribeToAllLiquidationUpdatesAsync(Action<DataEvent<BinanceFuturesStreamLiquidation>> onMessage, CancellationToken ct = default); - - /// <summary> - /// Subscribes to the depth updates for the provided symbol - /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#partial-book-depth-streams" /></para> - /// </summary> - /// <param name="symbol">The symbol to subscribe on, for example `ETHUSDT`</param> - /// <param name="levels">The amount of entries to be returned in the update, 5, 10 or 20</param> - /// <param name="updateInterval">Update interval in milliseconds, 100, 250 or 500</param> - /// <param name="onMessage">The event handler for the received data</param> - /// <param name="ct">Cancellation token for closing this subscription</param> - /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> - Task<CallResult<UpdateSubscription>> SubscribeToPartialOrderBookUpdatesAsync(string symbol, int levels, int? updateInterval, Action<DataEvent<IBinanceFuturesEventOrderBook>> onMessage, CancellationToken ct = default); - - /// <summary> - /// Subscribes to the depth updates for the provided symbols - /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#partial-book-depth-streams" /></para> - /// </summary> - /// <param name="symbols">The symbols to subscribe on, for example `ETHUSDT`</param> - /// <param name="levels">The amount of entries to be returned in the update of each symbol</param> - /// <param name="updateInterval">Update interval in milliseconds, either 100 or 500. Defaults to 250</param> - /// <param name="onMessage">The event handler for the received data</param> - /// <param name="ct">Cancellation token for closing this subscription</param> - /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> - Task<CallResult<UpdateSubscription>> SubscribeToPartialOrderBookUpdatesAsync(IEnumerable<string> symbols, int levels, int? updateInterval, Action<DataEvent<IBinanceFuturesEventOrderBook>> onMessage, CancellationToken ct = default); - - /// <summary> - /// Subscribes to the order book updates for the provided symbol - /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#diff-book-depth-streams" /></para> - /// </summary> - /// <param name="symbol">The symbol, for example `ETHUSDT`</param> - /// <param name="updateInterval">Update interval in milliseconds, either 0 or 100, 500 or 1000, depending on endpoint</param> - /// <param name="onMessage">The event handler for the received data</param> - /// <param name="ct">Cancellation token for closing this subscription</param> - /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> - Task<CallResult<UpdateSubscription>> SubscribeToOrderBookUpdatesAsync(string symbol, int? updateInterval, Action<DataEvent<IBinanceFuturesEventOrderBook>> onMessage, CancellationToken ct = default); - - /// <summary> - /// Subscribes to the depth update stream for the provided symbols - /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#diff-book-depth-streams" /></para> - /// </summary> - /// <param name="symbols">The symbols, for example `ETHUSDT`</param> - /// <param name="updateInterval">Update interval in milliseconds, either 0 or 100, 500 or 1000, depending on endpoint</param> - /// <param name="onMessage">The event handler for the received data</param> - /// <param name="ct">Cancellation token for closing this subscription</param> - /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> - Task<CallResult<UpdateSubscription>> SubscribeToOrderBookUpdatesAsync(IEnumerable<string> symbols, int? updateInterval, Action<DataEvent<IBinanceFuturesEventOrderBook>> onMessage, CancellationToken ct = default); - - /// <summary> - /// Subscribe to contract/symbol updates - /// </summary> - /// <param name="onMessage">The event handler for the received data</param> - /// <param name="ct">Cancellation token for closing this subscription</param> - /// <returns></returns> - Task<CallResult<UpdateSubscription>> SubscribeToSymbolUpdatesAsync(Action<DataEvent<BinanceFuturesStreamSymbolUpdate>> onMessage, CancellationToken ct = default); - - /// <summary> - /// Subscribes to the account update stream. Prior to using this, the <see cref="IBinanceRestClientUsdFuturesApiAccount.StartUserStreamAsync(CancellationToken)">restClient.UsdFuturesApi.Account.StartUserStreamAsync</see> method should be called to start the stream and obtaining a listen key. - /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#user-data-streams" /></para> - /// </summary> - /// <param name="listenKey">Listen key retrieved by the <see cref="IBinanceRestClientUsdFuturesApiAccount.StartUserStreamAsync(CancellationToken)">restClient.UsdFuturesApi.Account.StartUserStreamAsync</see> method</param> - /// <param name="onLeverageUpdate">The event handler for leverage changed update</param> - /// <param name="onMarginUpdate">The event handler for whenever a margin has changed</param> - /// <param name="onAccountUpdate">The event handler for whenever an account update is received</param> - /// <param name="onOrderUpdate">The event handler for whenever an order status update is received</param> - /// <param name="onTradeUpdate">The event handler for whenever an trade status update is received</param> - /// <param name="onListenKeyExpired">Responds when the listen key for the stream has expired. Initiate a new instance of the stream here</param> - /// <param name="onStrategyUpdate">The event handler for whenever a strategy update is received</param> - /// <param name="onGridUpdate">The event handler for whenever a grid update is received</param> - /// <param name="onConditionalOrderTriggerRejectUpdate">The event handler for whenever a trigger order failed to place an order</param> - /// <param name="ct">Cancellation token for closing this subscription</param> - /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> - Task<CallResult<UpdateSubscription>> SubscribeToUserDataUpdatesAsync( - string listenKey, - Action<DataEvent<BinanceFuturesStreamConfigUpdate>>? onLeverageUpdate = null, - Action<DataEvent<BinanceFuturesStreamMarginUpdate>>? onMarginUpdate = null, - Action<DataEvent<BinanceFuturesStreamAccountUpdate>>? onAccountUpdate = null, - Action<DataEvent<BinanceFuturesStreamOrderUpdate>>? onOrderUpdate = null, - Action<DataEvent<BinanceFuturesStreamTradeUpdate>>? onTradeUpdate = null, - Action<DataEvent<BinanceStreamEvent>>? onListenKeyExpired = null, - Action<DataEvent<BinanceStrategyUpdate>>? onStrategyUpdate = null, - Action<DataEvent<BinanceGridUpdate>>? onGridUpdate = null, - Action<DataEvent<BinanceConditionOrderTriggerRejectUpdate>>? onConditionalOrderTriggerRejectUpdate = null, - CancellationToken ct = default); - - - /// <summary> - /// Subscribes to the Mark price update stream for a all symbols - /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#mark-price-stream-for-all-market" /></para> - /// </summary> - /// <param name="updateInterval">Update interval in milliseconds, either 1000 or 3000. Defaults to 3000</param> - /// <param name="onMessage">The event handler for the received data</param> - /// <param name="ct">Cancellation token for closing this subscription</param> - /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> - Task<CallResult<UpdateSubscription>> SubscribeToAllMarkPriceUpdatesAsync(int? updateInterval, Action<DataEvent<IEnumerable<BinanceFuturesUsdtStreamMarkPrice>>> onMessage, CancellationToken ct = default); - - /// <summary> - /// Subscribes to composite index updates stream for a symbol - /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#composite-index-symbol-information-streams" /></para> + /// Account streams and queries /// </summary> - /// <param name="symbol">The symbol to subscribe, for example `ETHUSDT`</param> - /// <param name="onMessage">The event handler for the received data</param> - /// <param name="ct">Cancellation token for closing this subscription</param> - /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> - Task<CallResult<UpdateSubscription>> SubscribeToCompositeIndexUpdatesAsync(string symbol, - Action<DataEvent<BinanceFuturesStreamCompositeIndex>> onMessage, CancellationToken ct = default); - + IBinanceSocketClientUsdFuturesApiAccount Account { get; } /// <summary> - /// Subscribe to asset index updates stream - /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#multi-assets-mode-asset-index-2" /></para> + /// Exchange data streams and queries /// </summary> - /// <param name="onMessage">The event handler for the received data</param> - /// <param name="ct">Cancellation token for closing this subscription</param> - /// <returns></returns> - Task<CallResult<UpdateSubscription>> SubscribeToAssetIndexUpdatesAsync(Action<DataEvent<IEnumerable<BinanceFuturesStreamAssetIndexUpdate>>> onMessage, CancellationToken ct = default); - + IBinanceSocketClientUsdFuturesApiExchangeData ExchangeData { get; } /// <summary> - /// Subscribe to asset index updates for a single - /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#multi-assets-mode-asset-index-2" /></para> + /// Trading data and queries /// </summary> - /// <param name="symbol">The symbol, for example `ETHUSDT`</param> - /// <param name="onMessage">The event handler for the received data</param> - /// <param name="ct">Cancellation token for closing this subscription</param> - /// <returns></returns> - Task<CallResult<UpdateSubscription>> SubscribeToAssetIndexUpdatesAsync(string symbol, Action<DataEvent<BinanceFuturesStreamAssetIndexUpdate>> onMessage, CancellationToken ct = default); + IBinanceSocketClientUsdFuturesApiTrading Trading { get; } } } diff --git a/Binance.Net/Interfaces/Clients/UsdFuturesApi/IBinanceSocketClientUsdFuturesApiAccount.cs b/Binance.Net/Interfaces/Clients/UsdFuturesApi/IBinanceSocketClientUsdFuturesApiAccount.cs new file mode 100644 index 000000000..12f3edf5e --- /dev/null +++ b/Binance.Net/Interfaces/Clients/UsdFuturesApi/IBinanceSocketClientUsdFuturesApiAccount.cs @@ -0,0 +1,62 @@ +using Binance.Net.Enums; +using Binance.Net.Objects; +using Binance.Net.Objects.Models; +using Binance.Net.Objects.Models.Futures; +using Binance.Net.Objects.Models.Futures.Socket; +using Binance.Net.Objects.Models.Spot.Socket; +using CryptoExchange.Net.Objects.Sockets; + +namespace Binance.Net.Interfaces.Clients.UsdFuturesApi +{ + /// <summary> + /// Binance USD futures account websocket API + /// </summary> + public interface IBinanceSocketClientUsdFuturesApiAccount + { + /// <summary> + /// Gets account balances + /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#futures-account-balance-v2-user_data" /></para> + /// </summary> + /// <param name="receiveWindow">The receive window for which this request is active. When the request takes longer than this to complete the server will reject the request</param> + /// <param name="ct">Cancellation token</param> + /// <returns>The account information</returns> + Task<CallResult<BinanceResponse<IEnumerable<BinanceUsdFuturesAccountBalance>>>> GetBalancesAsync(long? receiveWindow = null, CancellationToken ct = default); + + /// <summary> + /// Get account information, including position and balances + /// <para><a href="https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Information-V3" /></para> + /// </summary> + /// <param name="receiveWindow">The receive window for which this request is active. When the request takes longer than this to complete the server will reject the request</param> + /// <param name="ct">Cancellation token</param> + Task<CallResult<BinanceResponse<BinanceFuturesAccountInfoV3>>> GetAccountInfoAsync(long? receiveWindow = null, CancellationToken ct = default); + + /// <summary> + /// Subscribes to the account update stream. Prior to using this, the <see cref="IBinanceRestClientUsdFuturesApiAccount.StartUserStreamAsync(CancellationToken)">restClient.UsdFuturesApi.Account.StartUserStreamAsync</see> method should be called to start the stream and obtaining a listen key. + /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#user-data-streams" /></para> + /// </summary> + /// <param name="listenKey">Listen key retrieved by the <see cref="IBinanceRestClientUsdFuturesApiAccount.StartUserStreamAsync(CancellationToken)">restClient.UsdFuturesApi.Account.StartUserStreamAsync</see> method</param> + /// <param name="onLeverageUpdate">The event handler for leverage changed update</param> + /// <param name="onMarginUpdate">The event handler for whenever a margin has changed</param> + /// <param name="onAccountUpdate">The event handler for whenever an account update is received</param> + /// <param name="onOrderUpdate">The event handler for whenever an order status update is received</param> + /// <param name="onTradeUpdate">The event handler for whenever an trade status update is received</param> + /// <param name="onListenKeyExpired">Responds when the listen key for the stream has expired. Initiate a new instance of the stream here</param> + /// <param name="onStrategyUpdate">The event handler for whenever a strategy update is received</param> + /// <param name="onGridUpdate">The event handler for whenever a grid update is received</param> + /// <param name="onConditionalOrderTriggerRejectUpdate">The event handler for whenever a trigger order failed to place an order</param> + /// <param name="ct">Cancellation token for closing this subscription</param> + /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> + Task<CallResult<UpdateSubscription>> SubscribeToUserDataUpdatesAsync( + string listenKey, + Action<DataEvent<BinanceFuturesStreamConfigUpdate>>? onLeverageUpdate = null, + Action<DataEvent<BinanceFuturesStreamMarginUpdate>>? onMarginUpdate = null, + Action<DataEvent<BinanceFuturesStreamAccountUpdate>>? onAccountUpdate = null, + Action<DataEvent<BinanceFuturesStreamOrderUpdate>>? onOrderUpdate = null, + Action<DataEvent<BinanceFuturesStreamTradeUpdate>>? onTradeUpdate = null, + Action<DataEvent<BinanceStreamEvent>>? onListenKeyExpired = null, + Action<DataEvent<BinanceStrategyUpdate>>? onStrategyUpdate = null, + Action<DataEvent<BinanceGridUpdate>>? onGridUpdate = null, + Action<DataEvent<BinanceConditionOrderTriggerRejectUpdate>>? onConditionalOrderTriggerRejectUpdate = null, + CancellationToken ct = default); + } +} diff --git a/Binance.Net/Interfaces/Clients/UsdFuturesApi/IBinanceSocketClientUsdFuturesApiExchangeData.cs b/Binance.Net/Interfaces/Clients/UsdFuturesApi/IBinanceSocketClientUsdFuturesApiExchangeData.cs new file mode 100644 index 000000000..3d8d4ff94 --- /dev/null +++ b/Binance.Net/Interfaces/Clients/UsdFuturesApi/IBinanceSocketClientUsdFuturesApiExchangeData.cs @@ -0,0 +1,402 @@ +using Binance.Net.Enums; +using Binance.Net.Objects; +using Binance.Net.Objects.Models; +using Binance.Net.Objects.Models.Futures; +using Binance.Net.Objects.Models.Futures.Socket; +using Binance.Net.Objects.Models.Spot; +using Binance.Net.Objects.Models.Spot.Socket; +using CryptoExchange.Net.Objects.Sockets; + +namespace Binance.Net.Interfaces.Clients.UsdFuturesApi +{ + /// <summary> + /// Binance USD futures exchange data websocket API + /// </summary> + public interface IBinanceSocketClientUsdFuturesApiExchangeData + { + /// <summary> + /// Gets the order book for the provided symbol + /// <para><a href="https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/websocket-api" /></para> + /// </summary> + /// <param name="symbol">The symbol to get the order book for, for example `ETHUSDT`</param> + /// <param name="limit">Max number of results</param> + /// <param name="ct">Cancellation token</param> + Task<CallResult<BinanceResponse<BinanceFuturesOrderBook>>> GetOrderBookAsync(string symbol, int? limit = null, CancellationToken ct = default); + + /// <summary> + /// Gets the price of a symbol + /// <para><a href="https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/websocket-api/Symbol-Price-Ticker" /></para> + /// </summary> + /// <param name="symbol">The symbol to get the price for, for example `ETHUSDT`</param> + /// <param name="ct">Cancellation token</param> + /// <returns>Price of symbol</returns> + Task<CallResult<BinanceResponse<BinancePrice>>> GetPriceAsync(string symbol, CancellationToken ct = default); + + /// <summary> + /// Gets the price of all symbols + /// <para><a href="https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/websocket-api/Symbol-Price-Ticker" /></para> + /// </summary> + /// <param name="ct">Cancellation token</param> + /// <returns>Price of symbol</returns> + Task<CallResult<BinanceResponse<IEnumerable<BinancePrice>>>> GetPricesAsync(CancellationToken ct = default); + + /// <summary> + /// Gets the best price/quantity on the order book for a symbol. + /// <para><a href="https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/websocket-api/Symbol-Order-Book-Ticker" /></para> + /// </summary> + /// <param name="symbol">Symbol to get book price for, for example `ETHUSDT`</param> + /// <param name="ct">Cancellation token</param> + /// <returns>List of book prices</returns> + Task<CallResult<BinanceResponse<BinanceBookPrice>>> GetBookPriceAsync(string symbol, CancellationToken ct = default); + + /// <summary> + /// Gets the best price/quantity on the order book for all symbols. + /// <para><a href="https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/websocket-api/Symbol-Order-Book-Ticker" /></para> + /// </summary> + /// <param name="ct">Cancellation token</param> + /// <returns>List of book prices</returns> + Task<CallResult<BinanceResponse<IEnumerable<BinanceBookPrice>>>> GetBookPricesAsync(CancellationToken ct = default); + + /// <summary> + /// Subscribes to the aggregated trades update stream for the provided symbol + /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#aggregate-trade-streams" /></para> + /// </summary> + /// <param name="symbol">The symbol, for example `ETHUSDT`</param> + /// <param name="onMessage">The event handler for the received data</param> + /// <param name="ct">Cancellation token for closing this subscription</param> + /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> + Task<CallResult<UpdateSubscription>> SubscribeToAggregatedTradeUpdatesAsync(string symbol, Action<DataEvent<BinanceStreamAggregatedTrade>> onMessage, CancellationToken ct = default); + + /// <summary> + /// Subscribe to individual trade update. NOTE: This endpoint stream isn't document and therefor might be changed or removed without prior notice + /// </summary> + /// <param name="symbol">Symbol to subscribe, for example `ETHUSDT`</param> + /// <param name="onMessage">The event handler for the received data</param> + /// <param name="filterOutNonTradeUpdates">Filter out any update which isn't a trade. Occasionally different updates (like INSURANCE_FUND updates) will occur on this stream. By default these are ignored</param> + /// <param name="ct">Cancellation token for closing this subscription</param> + /// <returns></returns> + Task<CallResult<UpdateSubscription>> SubscribeToTradeUpdatesAsync(string symbol, + Action<DataEvent<BinanceStreamTrade>> onMessage, bool filterOutNonTradeUpdates = true, CancellationToken ct = default); + + /// <summary> + /// Subscribe to individual trade update. NOTE: This endpoint stream isn't document and therefor might be changed or removed without prior notice + /// </summary> + /// <param name="symbols">Symbols to subscribe, for example `ETHUSDT`</param> + /// <param name="onMessage">The event handler for the received data</param> + /// <param name="filterOutNonTradeUpdates">Filter out any update which isn't a trade. Occasionally different updates (like INSURANCE_FUND updates) will occur on this stream. By default these are ignored</param> + /// <param name="ct">Cancellation token for closing this subscription</param> + /// <returns></returns> + Task<CallResult<UpdateSubscription>> SubscribeToTradeUpdatesAsync(IEnumerable<string> symbols, + Action<DataEvent<BinanceStreamTrade>> onMessage, bool filterOutNonTradeUpdates = true, CancellationToken ct = default); + + /// <summary> + /// Subscribes to the aggregated trades update stream for the provided symbols + /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#aggregate-trade-streams" /></para> + /// </summary> + /// <param name="symbols">The symbols, for example `ETHUSDT`</param> + /// <param name="onMessage">The event handler for the received data</param> + /// <param name="ct">Cancellation token for closing this subscription</param> + /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> + Task<CallResult<UpdateSubscription>> SubscribeToAggregatedTradeUpdatesAsync(IEnumerable<string> symbols, Action<DataEvent<BinanceStreamAggregatedTrade>> onMessage, CancellationToken ct = default); + + /// <summary> + /// Subscribes to the Mark price update stream for a single symbol + /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#mark-price-stream" /></para> + /// </summary> + /// <param name="symbol">The symbol, for example `ETHUSDT`</param> + /// <param name="updateInterval">Update interval in milliseconds, either 1000 or 3000. Defaults to 3000</param> + /// <param name="onMessage">The event handler for the received data</param> + /// <param name="ct">Cancellation token for closing this subscription</param> + /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> + Task<CallResult<UpdateSubscription>> SubscribeToMarkPriceUpdatesAsync(string symbol, int? updateInterval, Action<DataEvent<BinanceFuturesUsdtStreamMarkPrice>> onMessage, CancellationToken ct = default); + + /// <summary> + /// Subscribes to the Mark price update stream for a list of symbols + /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#mark-price-stream" /></para> + /// </summary> + /// <param name="symbols">The symbols, for example `ETHUSDT`</param> + /// <param name="updateInterval">Update interval in milliseconds, either 1000 or 3000. Defaults to 3000</param> + /// <param name="onMessage">The event handler for the received data</param> + /// <param name="ct">Cancellation token for closing this subscription</param> + /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> + Task<CallResult<UpdateSubscription>> SubscribeToMarkPriceUpdatesAsync(IEnumerable<string> symbols, int? updateInterval, Action<DataEvent<BinanceFuturesUsdtStreamMarkPrice>> onMessage, CancellationToken ct = default); + + /// <summary> + /// Subscribes to the candlestick update stream for the provided symbol + /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#kline-candlestick-streams" /></para> + /// </summary> + /// <param name="symbol">The symbol, for example `ETHUSDT`</param> + /// <param name="interval">The interval of the candlesticks</param> + /// <param name="onMessage">The event handler for the received data</param> + /// <param name="ct">Cancellation token for closing this subscription</param> + /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> + Task<CallResult<UpdateSubscription>> SubscribeToKlineUpdatesAsync(string symbol, KlineInterval interval, Action<DataEvent<IBinanceStreamKlineData>> onMessage, CancellationToken ct = default); + + /// <summary> + /// Subscribes to the candlestick update stream for the provided symbol and intervals + /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#kline-candlestick-streams" /></para> + /// </summary> + /// <param name="symbol">The symbol, for example `ETHUSDT`</param> + /// <param name="intervals">The intervals of the candlesticks</param> + /// <param name="onMessage">The event handler for the received data</param> + /// <param name="ct">Cancellation token for closing this subscription</param> + /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> + Task<CallResult<UpdateSubscription>> SubscribeToKlineUpdatesAsync(string symbol, IEnumerable<KlineInterval> intervals, Action<DataEvent<IBinanceStreamKlineData>> onMessage, CancellationToken ct = default); + + /// <summary> + /// Subscribes to the candlestick update stream for the provided symbols + /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#kline-candlestick-streams" /></para> + /// </summary> + /// <param name="symbols">The symbols, for example `ETHUSDT`</param> + /// <param name="interval">The interval of the candlesticks</param> + /// <param name="onMessage">The event handler for the received data</param> + /// <param name="ct">Cancellation token for closing this subscription</param> + /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> + Task<CallResult<UpdateSubscription>> SubscribeToKlineUpdatesAsync(IEnumerable<string> symbols, KlineInterval interval, Action<DataEvent<IBinanceStreamKlineData>> onMessage, CancellationToken ct = default); + + /// <summary> + /// Subscribes to the candlestick update stream for the provided symbols and intervals + /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#kline-candlestick-streams" /></para> + /// </summary> + /// <param name="symbols">The symbols, for example `ETHUSDT`</param> + /// <param name="intervals">The intervals of the candlesticks</param> + /// <param name="onMessage">The event handler for the received data</param> + /// <param name="ct">Cancellation token for closing this subscription</param> + /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> + Task<CallResult<UpdateSubscription>> SubscribeToKlineUpdatesAsync(IEnumerable<string> symbols, IEnumerable<KlineInterval> intervals, Action<DataEvent<IBinanceStreamKlineData>> onMessage, CancellationToken ct = default); + + /// <summary> + /// Subscribes to the continuous contract candlestick update stream for the provided pair + /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#continuous-contract-kline-candlestick-streams" /></para> + /// </summary> + /// <param name="pair">The pair, for example `ETHUSDT`</param> + /// <param name="contractType">The contract type</param> + /// <param name="interval">The interval of the candlesticks</param> + /// <param name="onMessage">The event handler for the received data</param> + /// <param name="ct">Cancellation token for closing this subscription</param> + /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> + Task<CallResult<UpdateSubscription>> SubscribeToContinuousContractKlineUpdatesAsync(string pair, ContractType contractType, KlineInterval interval, Action<DataEvent<BinanceStreamContinuousKlineData>> onMessage, CancellationToken ct = default); + + /// <summary> + /// Subscribes to the continuous contract candlestick update stream for the provided pairs + /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#continuous-contract-kline-candlestick-streams" /></para> + /// </summary> + /// <param name="pairs">The pairs, for example `ETHUSDT`</param> + /// <param name="contractType">The contract type</param> + /// <param name="interval">The interval of the candlesticks</param> + /// <param name="onMessage">The event handler for the received data</param> + /// <param name="ct">Cancellation token for closing this subscription</param> + /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> + Task<CallResult<UpdateSubscription>> SubscribeToContinuousContractKlineUpdatesAsync(IEnumerable<string> pairs, ContractType contractType, KlineInterval interval, Action<DataEvent<BinanceStreamContinuousKlineData>> onMessage, CancellationToken ct = default); + + /// <summary> + /// Subscribes to mini ticker updates stream for a specific symbol + /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#individual-symbol-mini-ticker-stream" /></para> + /// </summary> + /// <param name="symbol">The symbol to subscribe to, for example `ETHUSDT`</param> + /// <param name="onMessage">The event handler for the received data</param> + /// <param name="ct">Cancellation token for closing this subscription</param> + /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> + Task<CallResult<UpdateSubscription>> SubscribeToMiniTickerUpdatesAsync(string symbol, Action<DataEvent<IBinanceMiniTick>> onMessage, CancellationToken ct = default); + + /// <summary> + /// Subscribes to mini ticker updates stream for a list of symbol + /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#individual-symbol-mini-ticker-stream" /></para> + /// </summary> + /// <param name="symbols">The symbols to subscribe to, for example `ETHUSDT`</param> + /// <param name="onMessage">The event handler for the received data</param> + /// <param name="ct">Cancellation token for closing this subscription</param> + /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> + Task<CallResult<UpdateSubscription>> SubscribeToMiniTickerUpdatesAsync(IEnumerable<string> symbols, Action<DataEvent<IBinanceMiniTick>> onMessage, CancellationToken ct = default); + + /// <summary> + /// Subscribes to mini ticker updates stream for all symbols + /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#all-market-mini-tickers-stream" /></para> + /// </summary> + /// <param name="onMessage">The event handler for the received data</param> + /// <param name="ct">Cancellation token for closing this subscription</param> + /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> + Task<CallResult<UpdateSubscription>> SubscribeToAllMiniTickerUpdatesAsync(Action<DataEvent<IEnumerable<IBinanceMiniTick>>> onMessage, CancellationToken ct = default); + + /// <summary> + /// Subscribes to ticker updates stream for a specific symbol + /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#individual-symbol-ticker-streams" /></para> + /// </summary> + /// <param name="symbol">The symbol to subscribe to, for example `ETHUSDT`</param> + /// <param name="onMessage">The event handler for the received data</param> + /// <param name="ct">Cancellation token for closing this subscription</param> + /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> + Task<CallResult<UpdateSubscription>> SubscribeToTickerUpdatesAsync(string symbol, Action<DataEvent<IBinance24HPrice>> onMessage, CancellationToken ct = default); + + /// <summary> + /// Subscribes to ticker updates stream for a specific symbol + /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#individual-symbol-ticker-streams" /></para> + /// </summary> + /// <param name="symbols">The symbols to subscribe to, for example `ETHUSDT`</param> + /// <param name="onMessage">The event handler for the received data</param> + /// <param name="ct">Cancellation token for closing this subscription</param> + /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> + Task<CallResult<UpdateSubscription>> SubscribeToTickerUpdatesAsync(IEnumerable<string> symbols, Action<DataEvent<IBinance24HPrice>> onMessage, CancellationToken ct = default); + + /// <summary> + /// Subscribes to ticker updates stream for all symbols + /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#all-market-tickers-streams" /></para> + /// </summary> + /// <param name="onMessage">The event handler for the received data</param> + /// <param name="ct">Cancellation token for closing this subscription</param> + /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> + Task<CallResult<UpdateSubscription>> SubscribeToAllTickerUpdatesAsync(Action<DataEvent<IEnumerable<IBinance24HPrice>>> onMessage, CancellationToken ct = default); + + /// <summary> + /// Subscribes to all book ticker update streams + /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#all-book-tickers-stream" /></para> + /// </summary> + /// <param name="onMessage">The event handler for the received data</param> + /// <param name="ct">Cancellation token for closing this subscription</param> + /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> + Task<CallResult<UpdateSubscription>> SubscribeToAllBookTickerUpdatesAsync(Action<DataEvent<BinanceFuturesStreamBookPrice>> onMessage, CancellationToken ct = default); + + /// <summary> + /// Subscribes to the book ticker update stream for the provided symbol + /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#individual-symbol-book-ticker-streams" /></para> + /// </summary> + /// <param name="symbol">The symbol, for example `ETHUSDT`</param> + /// <param name="onMessage">The event handler for the received data</param> + /// <param name="ct">Cancellation token for closing this subscription</param> + /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> + Task<CallResult<UpdateSubscription>> SubscribeToBookTickerUpdatesAsync(string symbol, Action<DataEvent<BinanceFuturesStreamBookPrice>> onMessage, CancellationToken ct = default); + + /// <summary> + /// Subscribes to the book ticker update stream for the provided symbols + /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#individual-symbol-book-ticker-streams" /></para> + /// </summary> + /// <param name="symbols">The symbols, for example `ETHUSDT`</param> + /// <param name="onMessage">The event handler for the received data</param> + /// <param name="ct">Cancellation token for closing this subscription</param> + /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> + Task<CallResult<UpdateSubscription>> SubscribeToBookTickerUpdatesAsync(IEnumerable<string> symbols, Action<DataEvent<BinanceFuturesStreamBookPrice>> onMessage, CancellationToken ct = default); + + /// <summary> + /// Subscribes to specific symbol forced liquidations stream + /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#liquidation-order-streams" /></para> + /// </summary> + /// <param name="symbol">The symbol, for example `ETHUSDT`</param> + /// <param name="ct">Cancellation token for closing this subscription</param> + /// <param name="onMessage">The event handler for the received data</param> + /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> + Task<CallResult<UpdateSubscription>> SubscribeToLiquidationUpdatesAsync(string symbol, Action<DataEvent<BinanceFuturesStreamLiquidation>> onMessage, CancellationToken ct = default); + + /// <summary> + /// Subscribes to list of symbol forced liquidations stream + /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#liquidation-order-streams" /></para> + /// </summary> + /// <param name="symbols">The symbols, for example `ETHUSDT`</param> + /// <param name="onMessage">The event handler for the received data</param> + /// <param name="ct">Cancellation token for closing this subscription</param> + /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> + Task<CallResult<UpdateSubscription>> SubscribeToLiquidationUpdatesAsync(IEnumerable<string> symbols, Action<DataEvent<BinanceFuturesStreamLiquidation>> onMessage, CancellationToken ct = default); + + /// <summary> + /// Subscribes to all forced liquidations stream + /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#all-market-liquidation-order-streams" /></para> + /// </summary> + /// <param name="onMessage">The event handler for the received data</param> + /// <param name="ct">Cancellation token for closing this subscription</param> + /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> + Task<CallResult<UpdateSubscription>> SubscribeToAllLiquidationUpdatesAsync(Action<DataEvent<BinanceFuturesStreamLiquidation>> onMessage, CancellationToken ct = default); + + /// <summary> + /// Subscribes to the depth updates for the provided symbol + /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#partial-book-depth-streams" /></para> + /// </summary> + /// <param name="symbol">The symbol to subscribe on, for example `ETHUSDT`</param> + /// <param name="levels">The amount of entries to be returned in the update, 5, 10 or 20</param> + /// <param name="updateInterval">Update interval in milliseconds, 100, 250 or 500</param> + /// <param name="onMessage">The event handler for the received data</param> + /// <param name="ct">Cancellation token for closing this subscription</param> + /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> + Task<CallResult<UpdateSubscription>> SubscribeToPartialOrderBookUpdatesAsync(string symbol, int levels, int? updateInterval, Action<DataEvent<IBinanceFuturesEventOrderBook>> onMessage, CancellationToken ct = default); + + /// <summary> + /// Subscribes to the depth updates for the provided symbols + /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#partial-book-depth-streams" /></para> + /// </summary> + /// <param name="symbols">The symbols to subscribe on, for example `ETHUSDT`</param> + /// <param name="levels">The amount of entries to be returned in the update of each symbol</param> + /// <param name="updateInterval">Update interval in milliseconds, either 100 or 500. Defaults to 250</param> + /// <param name="onMessage">The event handler for the received data</param> + /// <param name="ct">Cancellation token for closing this subscription</param> + /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> + Task<CallResult<UpdateSubscription>> SubscribeToPartialOrderBookUpdatesAsync(IEnumerable<string> symbols, int levels, int? updateInterval, Action<DataEvent<IBinanceFuturesEventOrderBook>> onMessage, CancellationToken ct = default); + + /// <summary> + /// Subscribes to the order book updates for the provided symbol + /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#diff-book-depth-streams" /></para> + /// </summary> + /// <param name="symbol">The symbol, for example `ETHUSDT`</param> + /// <param name="updateInterval">Update interval in milliseconds, either 0 or 100, 500 or 1000, depending on endpoint</param> + /// <param name="onMessage">The event handler for the received data</param> + /// <param name="ct">Cancellation token for closing this subscription</param> + /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> + Task<CallResult<UpdateSubscription>> SubscribeToOrderBookUpdatesAsync(string symbol, int? updateInterval, Action<DataEvent<IBinanceFuturesEventOrderBook>> onMessage, CancellationToken ct = default); + + /// <summary> + /// Subscribes to the depth update stream for the provided symbols + /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#diff-book-depth-streams" /></para> + /// </summary> + /// <param name="symbols">The symbols, for example `ETHUSDT`</param> + /// <param name="updateInterval">Update interval in milliseconds, either 0 or 100, 500 or 1000, depending on endpoint</param> + /// <param name="onMessage">The event handler for the received data</param> + /// <param name="ct">Cancellation token for closing this subscription</param> + /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> + Task<CallResult<UpdateSubscription>> SubscribeToOrderBookUpdatesAsync(IEnumerable<string> symbols, int? updateInterval, Action<DataEvent<IBinanceFuturesEventOrderBook>> onMessage, CancellationToken ct = default); + + /// <summary> + /// Subscribe to contract/symbol updates + /// </summary> + /// <param name="onMessage">The event handler for the received data</param> + /// <param name="ct">Cancellation token for closing this subscription</param> + /// <returns></returns> + Task<CallResult<UpdateSubscription>> SubscribeToSymbolUpdatesAsync(Action<DataEvent<BinanceFuturesStreamSymbolUpdate>> onMessage, CancellationToken ct = default); + + /// <summary> + /// Subscribes to the Mark price update stream for a all symbols + /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#mark-price-stream-for-all-market" /></para> + /// </summary> + /// <param name="updateInterval">Update interval in milliseconds, either 1000 or 3000. Defaults to 3000</param> + /// <param name="onMessage">The event handler for the received data</param> + /// <param name="ct">Cancellation token for closing this subscription</param> + /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> + Task<CallResult<UpdateSubscription>> SubscribeToAllMarkPriceUpdatesAsync(int? updateInterval, Action<DataEvent<IEnumerable<BinanceFuturesUsdtStreamMarkPrice>>> onMessage, CancellationToken ct = default); + + /// <summary> + /// Subscribes to composite index updates stream for a symbol + /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#composite-index-symbol-information-streams" /></para> + /// </summary> + /// <param name="symbol">The symbol to subscribe, for example `ETHUSDT`</param> + /// <param name="onMessage">The event handler for the received data</param> + /// <param name="ct">Cancellation token for closing this subscription</param> + /// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns> + Task<CallResult<UpdateSubscription>> SubscribeToCompositeIndexUpdatesAsync(string symbol, + Action<DataEvent<BinanceFuturesStreamCompositeIndex>> onMessage, CancellationToken ct = default); + + /// <summary> + /// Subscribe to asset index updates stream + /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#multi-assets-mode-asset-index-2" /></para> + /// </summary> + /// <param name="onMessage">The event handler for the received data</param> + /// <param name="ct">Cancellation token for closing this subscription</param> + /// <returns></returns> + Task<CallResult<UpdateSubscription>> SubscribeToAssetIndexUpdatesAsync(Action<DataEvent<IEnumerable<BinanceFuturesStreamAssetIndexUpdate>>> onMessage, CancellationToken ct = default); + + /// <summary> + /// Subscribe to asset index updates for a single + /// <para><a href="https://binance-docs.github.io/apidocs/futures/en/#multi-assets-mode-asset-index-2" /></para> + /// </summary> + /// <param name="symbol">The symbol, for example `ETHUSDT`</param> + /// <param name="onMessage">The event handler for the received data</param> + /// <param name="ct">Cancellation token for closing this subscription</param> + /// <returns></returns> + Task<CallResult<UpdateSubscription>> SubscribeToAssetIndexUpdatesAsync(string symbol, Action<DataEvent<BinanceFuturesStreamAssetIndexUpdate>> onMessage, CancellationToken ct = default); + } +} diff --git a/Binance.Net/Interfaces/Clients/UsdFuturesApi/IBinanceSocketClientUsdFuturesApiTrading.cs b/Binance.Net/Interfaces/Clients/UsdFuturesApi/IBinanceSocketClientUsdFuturesApiTrading.cs new file mode 100644 index 000000000..dfd0f6c18 --- /dev/null +++ b/Binance.Net/Interfaces/Clients/UsdFuturesApi/IBinanceSocketClientUsdFuturesApiTrading.cs @@ -0,0 +1,108 @@ +using Binance.Net.Enums; +using Binance.Net.Objects; +using Binance.Net.Objects.Models.Futures; + +namespace Binance.Net.Interfaces.Clients.UsdFuturesApi +{ + /// <summary> + /// Binance USD futures trading websocket API + /// </summary> + public interface IBinanceSocketClientUsdFuturesApiTrading + { + /// <summary> + /// Place a new order + /// <para><a href="https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/websocket-api" /></para> + /// </summary> + /// <param name="symbol">The symbol the order is for, for example `ETHUSDT`</param> + /// <param name="side">The order side (buy/sell)</param> + /// <param name="type">The order type</param> + /// <param name="timeInForce">Lifetime of the order (GoodTillCancel/ImmediateOrCancel/FillOrKill)</param> + /// <param name="quantity">The quantity of the base symbol</param> + /// <param name="positionSide">The position side</param> + /// <param name="reduceOnly">Specify as true if the order is intended to only reduce the position</param> + /// <param name="price">The price to use</param> + /// <param name="newClientOrderId">Unique id for order</param> + /// <param name="stopPrice">Used for stop orders</param> + /// <param name="activationPrice">Used with TRAILING_STOP_MARKET orders, default as the latest price(supporting different workingType)</param> + /// <param name="callbackRate">Used with TRAILING_STOP_MARKET orders</param> + /// <param name="workingType">stopPrice triggered by: "MARK_PRICE", "CONTRACT_PRICE"</param> + /// <param name="closePosition">Close-All,used with STOP_MARKET or TAKE_PROFIT_MARKET.</param> + /// <param name="orderResponseType">The response type. Default Acknowledge</param> + /// <param name="priceProtect">If true when price reaches stopPrice, difference between "MARK_PRICE" and "CONTRACT_PRICE" cannot be larger than "triggerProtect" of the symbol.</param> + /// <param name="priceMatch">Only avaliable for Limit/Stop/TakeProfit order</param> + /// <param name="selfTradePreventionMode">Self trade prevention mode</param> + /// <param name="goodTillDate">Order cancel time for timeInForce GoodTillDate</param> + /// <param name="receiveWindow">The receive window for which this request is active. When the request takes longer than this to complete the server will reject the request</param> + /// <param name="ct">Cancellation token</param> + Task<CallResult<BinanceResponse<BinanceUsdFuturesOrder>>> PlaceOrderAsync(string symbol, + Enums.OrderSide side, + FuturesOrderType type, + decimal? quantity, + decimal? price = null, + Enums.PositionSide? positionSide = null, + TimeInForce? timeInForce = null, + bool? reduceOnly = null, + string? newClientOrderId = null, + decimal? stopPrice = null, + decimal? activationPrice = null, + decimal? callbackRate = null, + WorkingType? workingType = null, + bool? closePosition = null, + OrderResponseType? orderResponseType = null, + bool? priceProtect = null, + PriceMatch? priceMatch = null, + SelfTradePreventionMode? selfTradePreventionMode = null, + DateTime? goodTillDate = null, + int? receiveWindow = null, + CancellationToken ct = default); + + /// <summary> + /// Edit an existing order + /// <para><a href="https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/websocket-api/Modify-Order" /></para> + /// </summary> + /// <param name="symbol">The symbol, for example `ETHUSDT`</param> + /// <param name="side">Order side</param> + /// <param name="quantity">New quantity</param> + /// <param name="price">New price</param> + /// <param name="orderId">Order id of the order to edit</param> + /// <param name="origClientOrderId">Client order id of the order to edit</param> + /// <param name="receiveWindow">The receive window for which this request is active. When the request takes longer than this to complete the server will reject the request</param> + /// <param name="ct">Cancellation token</param> + /// <returns></returns> + Task<CallResult<BinanceResponse<BinanceUsdFuturesOrder>>> EditOrderAsync(string symbol, OrderSide side, decimal quantity, decimal price, long? orderId = null, string? origClientOrderId = null, long? receiveWindow = null, CancellationToken ct = default); + + /// <summary> + /// Cancels a pending order + /// <para><a href="https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/websocket-api/Cancel-Order" /></para> + /// </summary> + /// <param name="symbol">The symbol the order is for, for example `ETHUSDT`</param> + /// <param name="orderId">The order id of the order</param> + /// <param name="origClientOrderId">The client order id of the order</param> + /// <param name="receiveWindow">The receive window for which this request is active. When the request takes longer than this to complete the server will reject the request</param> + /// <param name="ct">Cancellation token</param> + /// <returns>Id's for canceled order</returns> + Task<CallResult<BinanceResponse<BinanceUsdFuturesOrder>>> CancelOrderAsync(string symbol, long? orderId = null, string? origClientOrderId = null, long? receiveWindow = null, CancellationToken ct = default); + + /// <summary> + /// Retrieves data for a specific order. Either orderId or origClientOrderId should be provided. + /// <para><a href="https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/websocket-api/Query-Order" /></para> + /// </summary> + /// <param name="symbol">The symbol the order is for, for example `ETHUSDT`</param> + /// <param name="orderId">The order id of the order</param> + /// <param name="origClientOrderId">The client order id of the order</param> + /// <param name="receiveWindow">The receive window for which this request is active. When the request takes longer than this to complete the server will reject the request</param> + /// <param name="ct">Cancellation token</param> + /// <returns>The specific order</returns> + Task<CallResult<BinanceResponse<BinanceUsdFuturesOrder>>> GetOrderAsync(string symbol, long? orderId = null, string? origClientOrderId = null, long? receiveWindow = null, CancellationToken ct = default); + + /// <summary> + /// Get position information + /// <para><a href="https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/websocket-api/Position-Info-V2" /></para> + /// </summary> + /// <param name="symbol">Filter by symbol, for example `ETHUSDT`</param> + /// <param name="receiveWindow">The receive window for which this request is active. When the request takes longer than this to complete the server will reject the request</param> + /// <param name="ct">Cancellation token</param> + Task<CallResult<BinanceResponse<IEnumerable<BinancePositionV3>>>> GetPositionsAsync(string? symbol = null, long? receiveWindow = null, CancellationToken ct = default); + + } +} diff --git a/Binance.Net/Objects/BinanceApiAddresses.cs b/Binance.Net/Objects/BinanceApiAddresses.cs index f7c556451..dfc82fc99 100644 --- a/Binance.Net/Objects/BinanceApiAddresses.cs +++ b/Binance.Net/Objects/BinanceApiAddresses.cs @@ -26,9 +26,13 @@ public class BinanceApiAddresses /// </summary> public string? UsdFuturesRestClientAddress { get; set; } /// <summary> - /// The address used by the BinanceSocketClient for the USD futures API + /// The address used by the BinanceSocketClient for the USD futures streams /// </summary> public string? UsdFuturesSocketClientAddress { get; set; } + /// <summary> + /// The address used by the BinanceSocketClient for the USD futures API + /// </summary> + public string? UsdFuturesSocketApiClientAddress { get; set; } /// <summary> /// The address used by the BinanceClient for the COIN futures API @@ -50,6 +54,7 @@ public class BinanceApiAddresses BlvtSocketClientAddress = "wss://nbstream.binance.com/", UsdFuturesRestClientAddress = "https://fapi.binance.com", UsdFuturesSocketClientAddress = "wss://fstream.binance.com/", + UsdFuturesSocketApiClientAddress = "wss://ws-fapi.binance.com/", CoinFuturesRestClientAddress = "https://dapi.binance.com", CoinFuturesSocketClientAddress = "wss://dstream.binance.com/", }; @@ -65,6 +70,7 @@ public class BinanceApiAddresses BlvtSocketClientAddress = "wss://fstream.binancefuture.com", UsdFuturesRestClientAddress = "https://testnet.binancefuture.com", UsdFuturesSocketClientAddress = "wss://fstream.binancefuture.com", + UsdFuturesSocketApiClientAddress = "wss://testnet.binancefuture.com", CoinFuturesRestClientAddress = "https://testnet.binancefuture.com", CoinFuturesSocketClientAddress = "wss://dstream.binancefuture.com", }; diff --git a/Binance.Net/SymbolOrderBooks/BinanceFuturesUsdtSymbolOrderBook.cs b/Binance.Net/SymbolOrderBooks/BinanceFuturesUsdtSymbolOrderBook.cs index ced854a87..af5f84053 100644 --- a/Binance.Net/SymbolOrderBooks/BinanceFuturesUsdtSymbolOrderBook.cs +++ b/Binance.Net/SymbolOrderBooks/BinanceFuturesUsdtSymbolOrderBook.cs @@ -70,9 +70,9 @@ protected override async Task<CallResult<UpdateSubscription>> DoStartAsync(Cance { CallResult<UpdateSubscription> subResult; if (_limit == null) - subResult = await _socketClient.UsdFuturesApi.SubscribeToOrderBookUpdatesAsync(Symbol, _updateInterval, HandleUpdate).ConfigureAwait(false); + subResult = await _socketClient.UsdFuturesApi.ExchangeData.SubscribeToOrderBookUpdatesAsync(Symbol, _updateInterval, HandleUpdate).ConfigureAwait(false); else - subResult = await _socketClient.UsdFuturesApi.SubscribeToPartialOrderBookUpdatesAsync(Symbol, _limit.Value, _updateInterval, HandleUpdate).ConfigureAwait(false); + subResult = await _socketClient.UsdFuturesApi.ExchangeData.SubscribeToPartialOrderBookUpdatesAsync(Symbol, _limit.Value, _updateInterval, HandleUpdate).ConfigureAwait(false); if (!subResult) return new CallResult<UpdateSubscription>(subResult.Error!); diff --git a/README.md b/README.md index a94711335..3db9821c6 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ A Discord server is available [here](https://discord.gg/MSpeEtSY8t). For discuss ## Supported functionality -### Spot/Margin/Savings/Mining +### Spot/Margin/Savings/Mining REST |API|Supported|Location| |--|--:|--| |Wallet endpoints|✓|`restClient.SpotApi.Account`| @@ -128,7 +128,7 @@ A Discord server is available [here](https://discord.gg/MSpeEtSY8t). For discuss |NFT Endpoints|X|| |Binance Gift Card Endpoints|X|| -### USD-M Futures +### USD-M Futures REST |API|Supported|Location| |--|--:|--| |Market Data|✓|`restClient.UsdFuturesApi.ExchangeData`| @@ -139,7 +139,7 @@ A Discord server is available [here](https://discord.gg/MSpeEtSY8t). For discuss |Convert|✓|`restClient.UsdFuturesApi.ExchangeData` / `restClient.UsdFuturesApi.Trading`| |Classic Portfolio Margin Endpoints|X|| -### COIN-M Futures +### COIN-M Futures REST |API|Supported|Location| |--|--:|--| |Market Data|✓|`restClient.CoinFuturesApi.ExchangeData`| @@ -149,18 +149,23 @@ A Discord server is available [here](https://discord.gg/MSpeEtSY8t). For discuss |Account|✓|`restClient.CoinFuturesApi.Account` / `restClient.CoinFuturesApi.Trading`| |Classic Portfolio Margin Endpoints|X|| -### European Options -|API|Supported|Location| -|--|--:|--| -|*|X|| - -### Websocket API +### Spot Websocket API |API|Supported|Location| |--|--:|--| |Market data requests|✓|`socketClient.SpotApi.ExchangeData`| |Trading requests|✓|`socketClient.SpotApi.Trading`| |Account requests|✓|`socketClient.SpotApi.Account`| +### USD-M Futures Websocket API +|API|Supported|Location| +|--|--:|--| +|*|✓|`socketClient.UsdFuturesApi.Account` / `socketClient.UsdFuturesApi.ExchangeData` / `socketClient.UsdFuturesApi.Trading`| + +### European Options +|API|Supported|Location| +|--|--:|--| +|*|X|| + ### Portfolio Margin |API|Supported|Location| |--|--:|--|