diff --git a/README.md b/README.md index f1b3c7b2..42117166 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 a638ec6e..161288e8 100644 --- a/docs/index.html +++ b/docs/index.html @@ -163,6 +163,7 @@
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 @@dotnet add package WhiteBit.Net
dotnet add package XT.Net
+ builder.Services.AddWhiteBit();
builder.Services.AddXT();
+ Interface | Description |
---|---|
IXTRestClient |
+ The client for accessing the XT REST API | +
IXTSocketClient |
+ The client for accessing the XT Websocket API | +
IXTOrderBookFactory |
+ A factory for creating SymbolOrderBook instances for the XT API | +
IXTTrackerFactory |
+ A factory for creating kline and trade Tracker instances for the XT API | +
ICryptoRestClient |
+ An aggregating client from which multiple different library REST clients can be accessed | +
ICryptoSocketClient |
+ An aggregating client from which multiple different library Websocket clients can be accessed | +
ISharedClient |
+ Various interfaces deriving from ISharedClient which can be used for common functionality | +
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 @@ 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 @@ Subscribing
}
// 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
+ ILeverageRestClient
IPositionHistoryRestClient
IPositionModeRestClient
IFeeRestClient
Available Socket shared interfaces
@@ -2391,6 +2487,9 @@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"));
+ var client = new WhiteBitRestClient(opts =>
+{
+ opts.RequestTimeout = TimeSpan.FromSeconds(30);
+});
+ var client = new XTRestClient(opts =>
{
opts.RequestTimeout = TimeSpan.FromSeconds(30);
});
@@ -2834,6 +2954,9 @@ XTRestClient.SetDefaultOptions(options =>
+{
+ options.RequestTimeout = TimeSpan.FromSeconds(30);
+});
+var client = new XTRestClient();
+ 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 @@ // 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 @@ 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);
+
await whitebitClient.V4Api.ExchangeData.GetSymbolsAsync();
await xtClient.SpotApi.ExchangeData.GetSymbolsAsync();
+ await xtClient.SpotApi.ExchangeData.GetTickersAsync("btc-usdt");
await whitebitClient.V4Api.Account.GetSpotBalancesAsync();
await xtClient.SpotApi.Account.GetBalancesAsync();
+ 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);
+ await whitebitSocketClient.V4Api.SubscribeToTickerUpdatesAsync("ETH_USDT", data => {
// Handle update
});
+
+ await xtSocketClient.SpotApi.SubscribeToTickerUpdatesAsync("eth_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();
+ }
+});