Skip to content

Commit

Permalink
Show file tree
Hide file tree
Showing 7 changed files with 180 additions and 4 deletions.
1 change: 1 addition & 0 deletions Binance.Net.UnitTests/SocketSubscriptionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public async Task ValidateUsdFuturesSubscriptions()
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");
}
Expand Down
22 changes: 22 additions & 0 deletions Binance.Net.UnitTests/Subscriptions/UsdFutures/TradeUpdate.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
> { "method": "SUBSCRIBE", "params": [ "123" ], "id": "|1|" }
< { "result": null, "id": |1| }
=
{
"stream": "123",
"data":
{
"e":"TRADE_LITE",
"E":1721895408092,
"T":1721895408214,
"s":"BTCUSDT",
"q":"0.001",
"p":"0",
"m":false,
"c":"z8hcUoOsqEdKMeKPSABslD",
"S":"BUY",
"L":"64089.20",
"l":"0.040",
"t":109100866,
"i":8886774
}
}
74 changes: 71 additions & 3 deletions Binance.Net/Binance.Net.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2320,7 +2320,7 @@
<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)">
<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.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.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)">
<inheritdoc />
</member>
<member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.GetListenerIdentifier(CryptoExchange.Net.Interfaces.IMessageAccessor)">
Expand Down Expand Up @@ -12493,7 +12493,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.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.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>
Expand All @@ -12503,6 +12503,7 @@
<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>
Expand Down Expand Up @@ -28685,6 +28686,72 @@
Auxiliary number for quick calculation
</summary>
</member>
<member name="T:Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamTradeUpdate">
<summary>
Update data about a trade
</summary>
</member>
<member name="P:Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamTradeUpdate.TransactionTime">
<summary>
Transaction time
</summary>
</member>
<member name="P:Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamTradeUpdate.Symbol">
<summary>
The symbol the order is for
</summary>
</member>
<member name="P:Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamTradeUpdate.Quantity">
<summary>
The quantity of the order
</summary>
</member>
<member name="P:Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamTradeUpdate.Price">
<summary>
The price of the order
</summary>
</member>
<member name="P:Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamTradeUpdate.BuyerIsMaker">
<summary>
Whether the buyer is the maker
</summary>
</member>
<member name="P:Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamTradeUpdate.ClientOrderId">
<summary>
The new client order id
</summary>
<remarks>
special client order id:
starts with "autoclose-": liquidation order
"adl_autoclose": ADL auto close order
"settlement_autoclose-": settlement order for delisting or delivery
</remarks>
</member>
<member name="P:Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamTradeUpdate.Side">
<summary>
The side of the order
</summary>
</member>
<member name="P:Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamTradeUpdate.PriceLastFilledTrade">
<summary>
The price of the last filled trade
</summary>
</member>
<member name="P:Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamTradeUpdate.QuantityOfLastFilledTrade">
<summary>
The quantity of the last filled trade of this order
</summary>
</member>
<member name="P:Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamTradeUpdate.TradeId">
<summary>
The trade id
</summary>
</member>
<member name="P:Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesStreamTradeUpdate.OrderId">
<summary>
The id of the order as assigned by Binance
</summary>
</member>
<member name="T:Binance.Net.Objects.Models.Futures.Socket.BinanceGridUpdate">
<summary>
Strategy update
Expand Down Expand Up @@ -29019,13 +29086,14 @@
<member name="M:Binance.Net.Objects.Sockets.BinanceUsdFuturesUserDataSubscription.GetMessageType(CryptoExchange.Net.Interfaces.IMessageAccessor)">
<inheritdoc />
</member>
<member name="M:Binance.Net.Objects.Sockets.BinanceUsdFuturesUserDataSubscription.#ctor(Microsoft.Extensions.Logging.ILogger,System.Collections.Generic.List{System.String},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.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.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}})">
<member name="M:Binance.Net.Objects.Sockets.BinanceUsdFuturesUserDataSubscription.#ctor(Microsoft.Extensions.Logging.ILogger,System.Collections.Generic.List{System.String},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.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.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}})">
<summary>
ctor
</summary>
<param name="logger"></param>
<param name="topics"></param>
<param name="orderHandler"></param>
<param name="tradeHandler"></param>
<param name="configHandler"></param>
<param name="marginHandler"></param>
<param name="accountHandler"></param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ public async Task<CallResult<UpdateSubscription>> SubscribeToUserDataUpdatesAsyn
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,
Expand All @@ -401,7 +402,7 @@ public async Task<CallResult<UpdateSubscription>> SubscribeToUserDataUpdatesAsyn
{
listenKey.ValidateNotNull(nameof(listenKey));

var subscription = new BinanceUsdFuturesUserDataSubscription(_logger, new List<string> { listenKey }, onOrderUpdate, onConfigUpdate, onMarginUpdate, onAccountUpdate, onListenKeyExpired, onStrategyUpdate, onGridUpdate, onConditionalOrderTriggerRejectUpdate);
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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ Task<CallResult<UpdateSubscription>> SubscribeToTradeUpdatesAsync(IEnumerable<st
/// <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>
Expand All @@ -334,6 +335,7 @@ Task<CallResult<UpdateSubscription>> SubscribeToUserDataUpdatesAsync(
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,
Expand Down
Loading

0 comments on commit d96e932

Please sign in to comment.