@@ -2381,6 +2536,15 @@ options.ApiCredentials = new ApiCredentials("YOUR PUBLIC KEY", "YOUR PRIVATE KEY
+
builder.Services.AddWhiteBit(
restOptions => {
restOptions.RequestTimeout = TimeSpan.FromSeconds(30);
},
@@ -2446,6 +2610,9 @@ options.ApiCredentials = new ApiCredentials("YOUR PUBLIC KEY", "YOUR PRIVATE KEY
OKX
+
+ WhiteBit
+
@@ -2546,6 +2713,12 @@ options.ApiCredentials = new ApiCredentials("YOUR PUBLIC KEY", "YOUR PRIVATE KEY
var client = new OKXRestClient(opts =>
+{
+ opts.RequestTimeout = TimeSpan.FromSeconds(30);
+});
+
+
+
var client = new WhiteBitRestClient(opts =>
{
opts.RequestTimeout = TimeSpan.FromSeconds(30);
});
@@ -2605,6 +2778,9 @@ options.ApiCredentials = new ApiCredentials("YOUR PUBLIC KEY", "YOUR PRIVATE KEY
OKX
+
+ WhiteBit
+
@@ -2719,6 +2895,13 @@ var client = new MexcRestClient();
});
var client = new OKXRestClient();
+
+
WhiteBitRestClient.SetDefaultOptions(options =>
+{
+ options.RequestTimeout = TimeSpan.FromSeconds(30);
+});
+var client = new WhiteBitRestClient();
+
@@ -2950,6 +3133,9 @@ var client = new OKXRestClient();
OKX
+
+ WhiteBit
+
@@ -3157,6 +3343,19 @@ if (!startResult.Success)
}
// Book has successfully started and synchronized
+// Once no longer needed you can stop the live sync functionality by calling StopAsync()
+await book.StopAsync();
+
+
+
+
var book = new WhiteBitSymbolOrderBook("ETH_USDT");
+var startResult = await book.StartAsync();
+if (!startResult.Success)
+{
+ // Handle error, error info available in startResult.Error
+}
+// Book has successfully started and synchronized
+
// Once no longer needed you can stop the live sync functionality by calling StopAsync()
await book.StopAsync();
@@ -3327,6 +3526,9 @@ foreach (var book in books.Where(b => b.Status == OrderBookStatus.Synced))
OKX
+
+ WhiteBit
+
@@ -3646,6 +3848,26 @@ if (!startResult.Success)
// Tracker has successfully started
// Note that it might not be fully synced yet, check tracker.Status for this.
+// Once no longer needed you can stop the live sync functionality by calling StopAsync()
+await tracker.StopAsync();
+
+
+
+
// Either create a new factory or inject the IWhiteBitTrackerFactory interface
+var factory = new WhiteBitTrackerFactory();
+
+var symbol = new SharedSymbol(TradingMode.Spot, "ETH", "USDT");
+
+// Create a tracker for ETH/USDT keeping track of trades in the last 5 minutes
+var tracker = factory.CreateTradeTracker(symbol, period: TimeSpan.FromMinutes(5));
+var startResult = await tracker.StartAsync();
+if (!startResult.Success)
+{
+ // Handle error, error info available in startResult.Error
+}
+// Tracker has successfully started
+// Note that it might not be fully synced yet, check tracker.Status for this.
+
// Once no longer needed you can stop the live sync functionality by calling StopAsync()
await tracker.StopAsync();
@@ -3996,6 +4218,9 @@ var binanceClient = new BinanceRestClient(new HttpClient(), logFactory, options
OKX
+
+ WhiteBit
+
@@ -4182,6 +4407,20 @@ var binanceClient = new BinanceRestClient(new HttpClient(), logFactory, options
To be notified of when a rate limit is hit the static OKXExchange.RateLimiter
exposes an event which triggers when a rate limit is reached
OKXExchange.RateLimiter.RateLimitTriggered += (rateLimitEvent) => Console.WriteLine("Limit triggered: " + rateLimitEvent);
+
+
+
+
services.AddWhiteBit(x =>
+ x.RatelimiterEnabled = true;
+ x.RateLimitingBehaviour = RateLimitingBehaviour.Wait;
+}, x =>
+{
+ x.RatelimiterEnabled = true;
+ x.RateLimitingBehaviour = RateLimitingBehaviour.Wait;
+});
+
To be notified of when a rate limit is hit the static WhiteBitExchange.RateLimiter
exposes an event which triggers when a rate limit is reached
+
WhiteBitExchange.RateLimiter.RateLimitTriggered += (rateLimitEvent) => Console.WriteLine("Limit triggered: " + rateLimitEvent);
+
@@ -4281,11 +4520,21 @@ var responseSource = result.DataSource;
OKX
+
+ WhiteBit
+
-
// This example uses Binance, but can be any exchange support. For example Bybit, Kraken, Kucoin etc
-await exchangeRestClient.Binance.SpotApi.ExchangeData.GetExchangeInfoAsync();
+
// This example uses Binance, but can be any supported exchange. For example Bybit, Kraken, Kucoin etc
+
+// Directly reference the Exchange API:
+await exchangeRestClient.Binance.SpotApi.ExchangeData.GetExchangeInfoAsync();
+
+// Or make it fully dynamic, either request on a single exchange:
+await exchangeRestClient.GetSpotSymbolClient("Binance")!.GetSpotSymbolsAsync(new GetSymbolsRequest());
+// Or request multiple exchanges at the same time:
+await exchangeRestClient.GetSpotSymbolsAsync(new GetSymbolsRequest(), ["Binance", "Kraken", "OKX"]);
await binanceClient.SpotApi.ExchangeData.GetExchangeInfoAsync();
@@ -4297,7 +4546,7 @@ await exchangeRestClient.Binance.SpotApi.ExchangeData.GetExchangeInfoAsync();
await bitfinexClient.SpotApi.ExchangeData.GetSymbolsAsync();
-
await bitgetClient.SpotApi.ExchangeData.GetSymbolsAsync();
+
await bitgetClient.SpotApiV2.ExchangeData.GetSymbolsAsync();
await bitMartClient.SpotApi.ExchangeData.GetSymbolsAsync();
@@ -4332,6 +4581,9 @@ await exchangeRestClient.Binance.SpotApi.ExchangeData.GetExchangeInfoAsync();
await okxClient.UnifiedApi.ExchangeData.GetSymbolsAsync(OKXInstrumentType.Spot);
+
+
await whitebitClient.V4Api.ExchangeData.GetSymbolsAsync();
+
@@ -4398,11 +4650,22 @@ await exchangeRestClient.Binance.SpotApi.ExchangeData.GetExchangeInfoAsync();
OKX
+
+ WhiteBit
+
-
// This example uses Binance, but can be any exchange support. For example Bybit, Kraken, Kucoin etc
-await exchangeRestClient.Binance.SpotApi.ExchangeData.GetTickerAsync(spotClient.GetSymbolName("BTC", "USDT"));
+
// This example uses Binance, but can be any supported exchange. For example Bybit, Kraken, Kucoin etc
+
+// Directly reference the Exchange API:
+await exchangeRestClient.Binance.SpotApi.ExchangeData.GetTickerAsync("ETHUSDT");
+
+// Or make it fully dynamic, either request on a single exchange:
+var symbol = new SharedSymbol(TradingMode.Spot, "ETH", "USDT");
+await exchangeRestClient.GetSpotTickerClient("Binance")!.GetSpotTickerAsync(new GetTickerRequest(symbol));
+// Or request multiple exchanges at the same time:
+await exchangeRestClient.GetSpotTickerAsync(new GetTickerRequest(symbol), ["Binance", "Kraken", "OKX"]);
await binanceClient.SpotApi.ExchangeData.GetTickerAsync("BTCUSDT");
@@ -4414,7 +4677,7 @@ await exchangeRestClient.Binance.SpotApi.ExchangeData.GetTickerAsync(spotClient.
await bitfinexClient.SpotApi.ExchangeData.GetTickerAsync("tBTCUST");
-
await bitgetClient.SpotApi.ExchangeData.GetTickerAsync("BTCUSDT_SPBL");
+
await bitgetClient.SpotApiV2.ExchangeData.GetTickersAsync("BTCUSDT");
await bitMartClient.SpotApi.ExchangeData.GetTickerAsync("BTC_USDT");
@@ -4450,6 +4713,11 @@ await coinbaseClient.AdvancedTradeApi.ExchangeData.GetSymbolAsync("BTC-USDT");
await okxClient.UnifiedApi.ExchangeData.GetTickerAsync("BTC-USDT");
+
+
// WhiteBit API doesn't offer a symbol filter, so we have to filter client side
+var tickersResult = await whitebitClient.V4Api.ExchangeData.GetTickersAsync();
+var ticker = tickersResult.Data.Single(x => x.Symbol == "BTC_USDT");
+
@@ -4516,11 +4784,21 @@ await coinbaseClient.AdvancedTradeApi.ExchangeData.GetSymbolAsync("BTC-USDT");
OKX
+
+ WhiteBit
+
-
// This example uses Binance, but can be any exchange support. For example Bybit, Kraken, Kucoin etc
-await exchangeRestClient.Binance.SpotApi.Account.GetBalancesAsync();
+
// This example uses Binance, but can be any supported exchange. For example Bybit, Kraken, Kucoin etc
+
+// Directly reference the Exchange API:
+await exchangeRestClient.Binance.SpotApi.Account.GetBalancesAsync();
+
+// Or make it fully dynamic, either request on a single exchange:
+await exchangeRestClient.GetBalancesClient(TradingMode.Spot, "Binance")!.GetBalancesAsync(new GetBalancesRequest());
+// Or request multiple exchanges at the same time:
+await exchangeRestClient.GetBalancesAsync(new GetBalancesRequest(TradingMode.Spot), ["Binance", "Kraken", "OKX"]);
await binanceClient.SpotApi.Account.GetBalancesAsync();
@@ -4532,7 +4810,7 @@ await exchangeRestClient.Binance.SpotApi.Account.GetBalancesAsync();
await bitfinexClient.SpotApi.Account.GetBalancesAsync();
-
await bitgetClient.SpotApi.Account.GetBalancesAsync();
+
await bitgetClient.SpotApiV2.Account.GetSpotBalancesAsync();
await bitMartClient.SpotApi.Account.GetSpotBalancesAsync();
@@ -4571,6 +4849,9 @@ var result = await htxClient.SpotApi.Account.GetBalancesAsync();
await okxClient.UnifiedApi.Account.GetAccountBalanceAsync();
+
+
await whitebitClient.V4Api.Account.GetSpotBalancesAsync();
+
@@ -4637,11 +4918,19 @@ var result = await htxClient.SpotApi.Account.GetBalancesAsync();
OKX
+
+ WhiteBit
+
-
// This example uses Binance, but can be any exchange support. For example Bybit, Kraken, Kucoin etc
-await exchangeRestClient.Binance.SpotApi.Trading.PlaceOrderAsync("BTCUSDT", OrderSide.Buy, SpotOrderType.Limit, 0.1m, price: 50000, timeInForce: TimeInForce.GoodTillCanceled);
+
// This example uses Binance, but can be any supported exchange. For example Bybit, Kraken, Kucoin etc
+
+// Directly reference the Exchange API:
+await exchangeRestClient.Binance.SpotApi.Trading.PlaceOrderAsync("BTCUSDT", Binance.Net.Enums.OrderSide.Buy, Binance.Net.Enums.SpotOrderType.Limit, 0.1m, price: 50000, timeInForce: Binance.Net.Enums.TimeInForce.GoodTillCanceled);
+
+// Or make it fully dynamic:
+await exchangeRestClient.GetSpotOrderClient("Binance")!.PlaceSpotOrderAsync(new PlaceSpotOrderRequest(new SharedSymbol(TradingMode.Spot, "ETH", "USDT"), SharedOrderSide.Buy, SharedOrderType.Limit, 0.1m, price: 50000));
await binanceClient.SpotApi.Trading.PlaceOrderAsync("BTCUSDT", OrderSide.Buy, SpotOrderType.Limit, 0.1m, price: 50000, timeInForce: TimeInForce.GoodTillCanceled);
@@ -4653,7 +4942,7 @@ await exchangeRestClient.Binance.SpotApi.Trading.PlaceOrderAsync("BTCUSDT", Orde
await bitfinexClient.SpotApi.Trading.PlaceOrderAsync("tBTCUST", OrderSide.Buy, OrderType.Limit, 0.1m, 50000);
-
await bitgetClient.SpotApi.Trading.PlaceOrderAsync("BTCUSDT_SPBL", BitgetOrderSide.Buy, BitgetOrderType.Limit, 0.1m, timeInForce: BitgetTimeInForce.GoodTillCanceled, 50000);
+
await bitgetRestClient.SpotApiV2.Trading.PlaceOrderAsync("BTCUSDT_SPBL", OrderSide.Buy, OrderType.Limit, 0.1m, timeInForce: TimeInForce.GoodTillCanceled, price: 50000);
await bitMartClient.SpotApi.Trading.PlaceOrderAsync("BTC_USDT", OrderSide.Buy, OrderType.Limit, 0.1m, price: 50000);
@@ -4692,6 +4981,9 @@ var result = await htxClient.SpotApi.Trading.PlaceOrderAsync(account.Id, "BTCUSD
await okxClient.UnifiedApi.Trading.PlaceOrderAsync("BTC-USDT", OKXOrderSide.Buy, OKXOrderType.LimitOrder, 0.1m, 50000);
+
+
await whitebitClient.V4Api.Trading.PlaceSpotOrderAsync("BTC_USDT", OrderSide.Buy, NewOrderType.Limit, 0.1m, price: 50000);
+
@@ -4758,13 +5050,28 @@ var result = await htxClient.SpotApi.Trading.PlaceOrderAsync(account.Id, "BTCUSD
OKX
+
+ WhiteBit
+
-
// This example uses Binance, but can be any exchange support. For example Bybit, Kraken, Kucoin etc
+ // This example uses Binance, but can be any supported exchange. For example Bybit, Kraken, Kucoin etc
+
+// Directly reference the Exchange API:
await exchangeSocketClient.Binance.SpotApi.ExchangeData.SubscribeToTickerUpdatesAsync("ETHUSDT", data => {
// Handle update
-});
+});
+
+// Or make it fully dynamic, either subscribe on a single exchange:
+var symbol = new SharedSymbol(TradingMode.Spot, "ETH", "USDT");
+await exchangeSocketClient.GetTickerClient(TradingMode.Spot, "Binance")!.SubscribeToTickerUpdatesAsync(new SubscribeTickerRequest(symbol), data => {
+ // Handle update
+});
+// Or subscribe on multiple exchanges at the same time:
+await exchangeSocketClient.SubscribeToTickerUpdatesAsync(new SubscribeTickerRequest(symbol), data => {
+ // Handle update
+}, ["Binance", "Kraken", "OKX"]);
await binanceSocketClient.SpotApi.ExchangeData.SubscribeToTickerUpdatesAsync("ETHUSDT", data => {
@@ -4782,7 +5089,7 @@ await exchangeSocketClient.Binance.SpotApi.ExchangeData.SubscribeToTickerUpdates
});
-
await bitgetSocketClient.SpotApi.SubscribeToTickerUpdatesAsync("ETHUSDT", data => {
+ await bitgetSocketClient.SpotApiV2.SubscribeToTickerUpdatesAsync("ETHUSDT", data => {
// Handle update
});
@@ -4840,6 +5147,12 @@ await exchangeSocketClient.Binance.SpotApi.ExchangeData.SubscribeToTickerUpdates
await okxSocketClient.UnifiedApi.ExchangeData.SubscribeToTickerUpdatesAsync("ETHUSDT", data => {
// Handle update
});
+
+
+
+
await whitebitSocketClient.V4Api.SubscribeToTickerUpdatesAsync("ETH_USDT", data => {
+ // Handle update
+});
@@ -4908,27 +5221,35 @@ await exchangeSocketClient.Binance.SpotApi.ExchangeData.SubscribeToTickerUpdates
// This example uses Binance, but can be any exchange support. For example Bybit, Kraken, Kucoin etc
+// Binance requires a listenkey to start the user stream
-// Retrieve the listen key
+//Directly reference the Exchange API:
var listenKey = await exchangeRestClient.Binance.SpotApi.Account.StartUserStreamAsync();
-
-// Subscribe using the key
-await exchangeSocketClient.Binance.SpotApi.Account.SubscribeToUserDataUpdatesAsync(listenKey.Data, data => {
+await exchangeSocketClient.Binance.SpotApi.Account.SubscribeToUserDataUpdatesAsync(listenKey.Data, data =>
+{
// Handle update
}, null, null, null);
-// The listen key will stay valid for 60 minutes, after this no updates will be send anymore
-// To extend the life time of the listen key it is recommended to call the KeepAliveUserStreamAsync method every 30 minutes
-_ = Task.Run(async () => {
- while (true)
- {
- await Task.Delay(Timespan.FromMinutes(30));
- await exchangeRestClient.Binance.SpotApi.Account.KeepAliveUserStreamAsync(listenKey.Data);
- }
+
+// Or make it fully dynamic:
+string? listenKey = null;
+var listenkeyClient = exchangeRestClient.GetListenKeyClient(TradingMode.Spot, "Binance");
+if (listenkeyClient != null)
+{
+ // Exchange needs a listenkey; so request that
+ var listenKeyResult = await listenkeyClient.StartListenKeyAsync(new StartListenKeyRequest());
+ listenKey = listenKeyResult.Data;
+}
+await exchangeSocketClient.GetSpotOrderClient("Binance")!.SubscribeToSpotOrderUpdatesAsync(new SubscribeSpotOrderRequest(listenKey: listenKey), data =>
+{
+ // Handle update
});
@@ -4975,7 +5296,7 @@ _ = Task.Run(async () => {
});
-
await bitgetSocketClient.SpotApi.SubscribeToOrderUpdatesAsync(data => {
+ await bitgetSocketClient.SpotApiV2.SubscribeToOrderUpdatesAsync(data => {
// Handle update
});
@@ -5051,6 +5372,13 @@ _ = Task.Run(async () => {
await okxSocketClient.UnifiedApi.Trading.SubscribeToOrderUpdatesAsync(OKXInstrumentType.Spot, null, null, data => {
// Handle update
});
+
+