diff --git a/README.md b/README.md index f1b3c7b..4211716 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ The following API's are directly supported. Note that there are 3rd party implem |Mexc|[JKorf/Mexc.Net](https://github.com/JKorf/Mexc.Net)|[![Nuget version](https://img.shields.io/nuget/v/JK.Mexc.net.svg?style=flat-square)](https://www.nuget.org/packages/JK.Mexc.Net)| |OKX|[JKorf/OKX.Net](https://github.com/JKorf/OKX.Net)|[![Nuget version](https://img.shields.io/nuget/v/JK.OKX.net.svg?style=flat-square)](https://www.nuget.org/packages/JK.OKX.Net)| |WhiteBit|[JKorf/WhiteBit.Net](https://github.com/JKorf/WhiteBit.Net)|[![Nuget version](https://img.shields.io/nuget/v/WhiteBit.net.svg?style=flat-square)](https://www.nuget.org/packages/WhiteBit.Net)| +|XT|[JKorf/XT.Net](https://github.com/JKorf/XT.Net)|[![Nuget version](https://img.shields.io/nuget/v/XT.net.svg?style=flat-square)](https://www.nuget.org/packages/XT.Net)| Any of these can be installed independently or install [CryptoClients.Net](https://github.com/jkorf/CryptoClients.Net) which includes all exchange API's. diff --git a/docs/index.html b/docs/index.html index a638ec6..161288e 100644 --- a/docs/index.html +++ b/docs/index.html @@ -163,6 +163,7 @@ MexcJKorf/Mexc.Net OKXJKorf/OKX.Net WhiteBitJKorf/WhiteBit.Net + XTJKorf/XT.Net

Note that there are 3rd party implementations going around, but only the listed ones here are created and supported by me.

When using multiple of these API's the CryptoClients.Net package can be used which combines these packages and allows easy access to all exchange API's.

@@ -279,7 +280,10 @@ OKX +
@@ -347,6 +351,9 @@
dotnet add package WhiteBit.Net
+
+
dotnet add package XT.Net
+
@@ -415,6 +422,9 @@ +
@@ -471,6 +481,9 @@
builder.Services.AddWhiteBit();
+
+
builder.Services.AddXT();
+
@@ -531,6 +544,9 @@ +
@@ -1111,6 +1127,39 @@
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
InterfaceDescription
IXTRestClientThe client for accessing the XT REST API
IXTSocketClientThe client for accessing the XT Websocket API
IXTOrderBookFactoryA factory for creating SymbolOrderBook instances for the XT API
IXTTrackerFactoryA factory for creating kline and trade Tracker instances for the XT API
ICryptoRestClientAn aggregating client from which multiple different library REST clients can be accessed
ICryptoSocketClientAn aggregating client from which multiple different library Websocket clients can be accessed
ISharedClientVarious interfaces deriving from ISharedClient which can be used for common functionality
+
@@ -1190,6 +1239,9 @@ +
@@ -1404,6 +1456,18 @@ if (!tickersResult.Success) // Handle error, tickersResult.Error contains more information } else +{ + // Handle data, tickersResult.Data will contain the actual data +} +
+
+
var client = new XTRestClient();
+var tickersResult = await client.SpotApi.ExchangeData.GetTickersAsync();
+if (!tickersResult.Success)
+{
+  // Handle error, tickersResult.Error contains more information
+}
+else
 {
   // Handle data, tickersResult.Data will contain the actual data
 }
@@ -1533,6 +1597,9 @@ else +
@@ -1711,7 +1778,7 @@ if (!subscribeResult.Success) } // Subscribing was successfull, the data will now be streamed into the data handler
-
+
var client = new WhiteBitSocketClient();
 var subscribeResult = await client.V4Api.ExchangeData.SubscribeToTickerUpdatesAsync("ETH_USDT", update => {
     // Handle the data update, update.Data will contain the actual data
@@ -1722,6 +1789,18 @@ if (!subscribeResult.Success)
 }
 // Subscribing was successfull, the data will now be streamed into the data handler
+
+
var client = new XTSocketClient();
+var subscribeResult = await client.SpotApi.ExchangeData.SubscribeToTickerUpdatesAsync("eth_usdt", update => {
+    // Handle the data update, update.Data will contain the actual data
+});
+if (!subscribeResult.Success)
+{
+  // Handle error, subscribeResult.Error contains more information on why the subscription failed
+}
+// Subscribing was successfull, the data will now be streamed into the data handler
+
+
@@ -1922,6 +2001,9 @@ var binanceTriggered = CheckForTrigger(lastBinanceTicker); +
@@ -2105,6 +2187,19 @@ var spotSharedRestClients = whitebitRestClient.V4Api.SharedClient; // Futures and Spot API common functionality socket client var spotSharedSocketClient = whitebitSocketClient.V4Api.SharedClient;
+
+
Spot API common functionality rest client
+var spotSharedRestClients = xtRestClient.SpotApi.SharedClient;
+
+Futures API common functionality rest client
+var futuresSharedRestClients = xtRestClient.UsdtFuturesApi.SharedClient;
+
+// Spot API common functionality socket client
+var spotSharedSocketClient = xtSocketClient.SpotApi.SharedClient;
+
+// Futures API common functionality socket client
+var futuresSharedSocketClient = xtSocketClient.FuturesApi.SharedClient;
+

TradingMode

@@ -2232,6 +2327,7 @@ var balances = await restClient.HTX.SpotApi.SharedClient.GetBalancesAsync(new Ge ILeverageRestClientFor managing leverage for a Futures symbol IPositionHistoryRestClientFor requesting the user position closing history IPositionModeRestClientFor managing the position mode for the user + IFeeRestClientFor requesting maker and taker trading fee percentages for the user

Available Socket shared interfaces

@@ -2391,6 +2487,9 @@ options.ApiCredentials = new ApiCredentials("YOUR PUBLIC KEY", "YOUR PRIVATE KEY +
@@ -2605,6 +2704,18 @@ builder.Services.AddOKX(builder.Configuration.GetSection("OKX")); // see https://github.com/JKorf/CryptoExchange.Net/tree/master/Examples/example-config.json for an example configuration builder.Services.AddWhiteBit(builder.Configuration.GetSection("WhiteBit"));
+
+
builder.Services.AddXT(
+  options => {
+    options.Rest.RequestTimeout = TimeSpan.FromSeconds(30);
+    options.Socket.RequestTimeout = TimeSpan.FromSeconds(5);
+  });
+  
+// OR
+  
+// see https://github.com/JKorf/CryptoExchange.Net/tree/master/Examples/example-config.json for an example configuration
+builder.Services.AddXT(builder.Configuration.GetSection("XT"));
+
@@ -2666,6 +2777,9 @@ builder.Services.AddWhiteBit(builder.Configuration.GetSection("WhiteBit")); WhiteBit +
@@ -2772,6 +2886,12 @@ builder.Services.AddWhiteBit(builder.Configuration.GetSection("WhiteBit"));
var client = new WhiteBitRestClient(opts =>
+{
+    opts.RequestTimeout = TimeSpan.FromSeconds(30);
+});
+
+
+
var client = new XTRestClient(opts =>
 {
     opts.RequestTimeout = TimeSpan.FromSeconds(30);
 });
@@ -2834,6 +2954,9 @@ builder.Services.AddWhiteBit(builder.Configuration.GetSection("WhiteBit")); WhiteBit +
@@ -2955,6 +3078,13 @@ var client = new OKXRestClient(); }); var client = new WhiteBitRestClient();
+
+
XTRestClient.SetDefaultOptions(options =>
+{
+    options.RequestTimeout = TimeSpan.FromSeconds(30);
+});
+var client = new XTRestClient();
+
@@ -3189,6 +3319,9 @@ var client = new WhiteBitRestClient(); +
@@ -3409,6 +3542,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 XTSymbolOrderBook("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();
 
@@ -3582,6 +3728,9 @@ foreach (var book in books.Where(b => b.Status == OrderBookStatus.Synced)) +
@@ -3921,6 +4070,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 IXTTrackerFactory interface
+var factory = new XTTrackerFactory();
+
+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();
 
@@ -4274,6 +4443,9 @@ var binanceClient = new BinanceRestClient(new HttpClient(), logFactory, options +
@@ -4474,6 +4646,20 @@ var binanceClient = new BinanceRestClient(new HttpClient(), logFactory, options

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);
 
+
+
+
+
services.AddXT(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 XTExchange.RateLimiter exposes an event which triggers when a rate limit is reached

+
XTExchange.RateLimiter.RateLimitTriggered += (rateLimitEvent) => Console.WriteLine("Limit triggered: " + rateLimitEvent);
+
 
@@ -4576,6 +4762,9 @@ var responseSource = result.DataSource; +
@@ -4637,6 +4826,9 @@ await exchangeRestClient.GetSpotSymbolsAsync(new GetSymbolsRequest(), ["Binance"
await whitebitClient.V4Api.ExchangeData.GetSymbolsAsync();
+
+
await xtClient.SpotApi.ExchangeData.GetSymbolsAsync();
+
@@ -4706,6 +4898,9 @@ await exchangeRestClient.GetSpotSymbolsAsync(new GetSymbolsRequest(), ["Binance" +
@@ -4770,6 +4965,9 @@ await coinbaseClient.AdvancedTradeApi.ExchangeData.GetSymbolAsync("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"); +
+
+
await xtClient.SpotApi.ExchangeData.GetTickersAsync("btc-usdt");
@@ -4840,6 +5038,9 @@ var ticker = tickersResult.Data.Single(x => x.Symbol == "BTC_USDT"); WhiteBit +
@@ -4905,6 +5106,9 @@ var result = await htxClient.SpotApi.Account.GetBalancesAsync();
await whitebitClient.V4Api.Account.GetSpotBalancesAsync();
+
+
await xtClient.SpotApi.Account.GetBalancesAsync();
+
@@ -4972,7 +5176,10 @@ var result = await htxClient.SpotApi.Account.GetBalancesAsync(); OKX +
@@ -5037,6 +5244,9 @@ var result = await htxClient.SpotApi.Trading.PlaceOrderAsync(account.Id, "BTCUSD
await whitebitClient.V4Api.Trading.PlaceSpotOrderAsync("BTC_USDT", OrderSide.Buy, NewOrderType.Limit, 0.1m, price: 50000);
+
+
await xtClient.SpotApi.Trading.PlaceOrderAsync("eth_usdt", OrderSide.Buy, OrderType.Limit, TimeInForce.GoodTillCanceled, BusinessType.Spot, 0.1m, price: 50000);
+
@@ -5106,6 +5316,9 @@ var result = await htxClient.SpotApi.Trading.PlaceOrderAsync(account.Id, "BTCUSD +
@@ -5206,6 +5419,12 @@ await exchangeSocketClient.SubscribeToTickerUpdatesAsync(new SubscribeTickerRequ
await whitebitSocketClient.V4Api.SubscribeToTickerUpdatesAsync("ETH_USDT", data => {
     // Handle update
 });
+
+
+
+
await xtSocketClient.SpotApi.SubscribeToTickerUpdatesAsync("eth_usdt", data => {
+    // Handle update
+});
 
@@ -5277,6 +5496,9 @@ await exchangeSocketClient.SubscribeToTickerUpdatesAsync(new SubscribeTickerRequ +
@@ -5432,6 +5654,26 @@ _ = Task.Run(async () => { await whitebitSocketClient.V4Api.SubscribeToOpenOrderUpdatesAsync(["ETH_USDT", "BTC_USDT"], data => { // Handle update }); + +
+
+
// Retrieve the token
+var listenKey = await xtRestClient.SpotApi.Account.GetWebsocketTokenAsync();
+
+// Subscribe using the key
+await xtSocketClient.SpotApi.SubscribeToBalanceUpdatesAsync(listenKey.Data, data => {
+    // Handle update
+});
+
+// The listen key will stay valid for 48 hours, 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 at a set interval
+_ = Task.Run(async () => {
+    while (true)
+    {
+        await Task.Delay(Timespan.FromHours(4));
+        await xtRestClient.SpotApi.Account.GetWebsocketTokenAsync();
+    }
+});