1
0
mirror of https://github.com/JKorf/CryptoExchange.Net synced 2025-06-07 07:56:12 +00:00
This commit is contained in:
JKorf 2023-06-25 21:43:30 +02:00
parent 84d0f0ec9e
commit 273cab9fdb
7 changed files with 56 additions and 56 deletions

View File

@ -11,15 +11,15 @@ Each implementation generally provides two different clients, which will be the
The rest client gives access to the Rest endpoint of the API. Rest endpoints are accessed by sending an HTTP request and receiving a response. The client is split in different sub-clients, which are named API Clients. These API clients are then again split in different topics. Typically a Rest client will look like this:
- [ExchangeName]RestClient
- SpotApi
- Account
- ExchangeData
- Trading
- FuturesApi
- Account
- ExchangeData
- Trading
- SpotApi
- Account
- ExchangeData
- Trading
- FuturesApi
- Account
- ExchangeData
- Trading
This rest client has 2 different API clients, the `SpotApi` and the `FuturesApi`, each offering their own set of endpoints.
*Requesting ticker info on the spot API*
@ -64,8 +64,8 @@ When processing the result of a call it should always be checked for success. No
var callResult = await kucoinClient.SpotApi.ExchangeData.GetTickersAsync();
if(!callResult.Success)
{
Console.WriteLine("Request failed: " + callResult.Error);
return;
Console.WriteLine("Request failed: " + callResult.Error);
return;
}
Console.WriteLine("Result: " + callResult.Data);
@ -78,8 +78,8 @@ Just like the Rest client is divided in Rest Api clients, the Socket client is d
```csharp
- KucoinSocketClient
- SpotStreams
- FuturesStreams
- SpotStreams
- FuturesStreams
```
*Subscribing to updates for all tickers on the Spot Api*
@ -95,7 +95,7 @@ await kucoinSocketClient.SpotStreams.SubscribeToAllTickerUpdatesAsync(DataHandle
private static void DataHandler(DataEvent<KucoinStreamTick> updateData)
{
// Process updateData
// Process updateData
}
```
@ -103,7 +103,7 @@ private static void DataHandler(DataEvent<KucoinStreamTick> updateData)
```csharp
await kucoinSocketClient.SpotStreams.SubscribeToAllTickerUpdatesAsync(updateData =>
{
// Process updateData
// Process updateData
});
```
@ -122,16 +122,16 @@ Subscribing to a stream will return a `CallResult<UpdateSubscription>` object. T
var subscriptionResult = await kucoinSocketClient.SpotStreams.SubscribeToAllTickerUpdatesAsync(DataHandler);
if(!subscriptionResult.Success)
{
Console.WriteLine("Failed to connect: " + subscriptionResult.Error);
return;
Console.WriteLine("Failed to connect: " + subscriptionResult.Error);
return;
}
subscriptionResult.Data.ConnectionLost += () =>
{
Console.WriteLine("Connection lost");
Console.WriteLine("Connection lost");
};
subscriptionResult.Data.ConnectionRestored += (time) =>
{
Console.WriteLine("Connection restored");
Console.WriteLine("Connection restored");
};
```

View File

@ -28,7 +28,7 @@ private void SomeMethod()
{
var socketClient = new BinanceSocketClient();
socketClient.Spot.SubscribeToOrderBookUpdates("BTCUSDT", data => {
// Handle data
// Handle data
});
}
```
@ -41,7 +41,7 @@ private BinanceSocketClient _socketClient = new BinanceSocketClient();
private void SomeMethod()
{
_socketClient.Spot.SubscribeToOrderBookUpdates("BTCUSDT", data => {
// Handle data
// Handle data
});
}
@ -52,7 +52,7 @@ Yes, generally these are all supported and can be configured by setting the Envi
```csharp
var client = new BinanceRestClient(options =>
{
options.Environment = BinanceEnvironment.Testnet;
options.Environment = BinanceEnvironment.Testnet;
});
```

View File

@ -10,7 +10,7 @@ The library offers extensive logging, which depends on the dotnet `Microsoft.Ext
```csharp
IServiceCollection services = new ServiceCollection();
services
.AddBinance()
.AddBinance()
.AddLogging(options =>
{
options.SetMinimumLevel(LogLevel.Trace);
@ -66,8 +66,8 @@ IServiceCollection serviceCollection = new ServiceCollection();
serviceCollection.AddBinance();
serviceCollection.AddLogging(options =>
{
options.SetMinimumLevel(LogLevel.Trace);
options.AddConsole();
options.SetMinimumLevel(LogLevel.Trace);
options.AddConsole();
}).BuildServiceProvider();
var client = serviceCollection.GetRequiredService<IBinanceRestClient>();
@ -91,7 +91,7 @@ By default the `OriginalData` property in the `WebCallResult`/`DataEvent` object
```csharp
var client = new BinanceClient(options =>
{
options.OutputOriginalData = true
options.OutputOriginalData = true
});
```
@ -103,7 +103,7 @@ var originallyReceivedData = tickerResult.OriginalData;
// Socket update
await client.SpotStreams.SubscribeToAllTickerUpdatesAsync(update => {
var originallyRecievedData = update.OriginalData;
var originallyRecievedData = update.OriginalData;
});
```

View File

@ -27,9 +27,9 @@ The HttpClient will now be received by the DI container instead of having to pas
```csharp
var client = new BinanceClient(new BinanceClientOptions(){
OutputOriginalData = true,
SpotApiOptions = new RestApiOptions {
BaseAddress = BinanceApiAddresses.TestNet.RestClientAddress
}
SpotApiOptions = new RestApiOptions {
BaseAddress = BinanceApiAddresses.TestNet.RestClientAddress
}
// Other options
});
```
@ -38,7 +38,7 @@ var client = new BinanceClient(new BinanceClientOptions(){
```csharp
var client = new BinanceClient(options => {
options.OutputOriginalData = true;
options.Environment = BinanceEnvironment.Testnet;
options.Environment = BinanceEnvironment.Testnet;
// Other options
});
```
@ -53,10 +53,10 @@ With the change in options providing the DI extension methods for the IServiceCo
```csharp
builder.Services.AddKucoin((restOpts, socketOpts) =>
{
restOpts.LogLevel = LogLevel.Debug;
restOpts.ApiCredentials = new KucoinApiCredentials("KEY", "SECRET", "PASS");
socketOpts.LogLevel = LogLevel.Debug;
socketOpts.ApiCredentials = new KucoinApiCredentials("KEY", "SECRET", "PASS");
restOpts.LogLevel = LogLevel.Debug;
restOpts.ApiCredentials = new KucoinApiCredentials("KEY", "SECRET", "PASS");
socketOpts.LogLevel = LogLevel.Debug;
socketOpts.ApiCredentials = new KucoinApiCredentials("KEY", "SECRET", "PASS");
}, ServiceLifetime.Singleton);
```

View File

@ -12,8 +12,8 @@ Each implementation can be configured using client options. There are 2 ways to
BinanceClient.SetDefaultOptions(options =>
{
options.OutputOriginalData = true;
options.ApiCredentials = new ApiCredentials("KEY", "SECRET");
options.OutputOriginalData = true;
options.ApiCredentials = new ApiCredentials("KEY", "SECRET");
});
```
@ -23,8 +23,8 @@ BinanceClient.SetDefaultOptions(options =>
var client = new BinanceClient(options =>
{
options.OutputOriginalData = true;
options.ApiCredentials = new ApiCredentials("KEY", "SECRET");
options.OutputOriginalData = true;
options.ApiCredentials = new ApiCredentials("KEY", "SECRET");
});
```
@ -34,12 +34,12 @@ When calling `SetDefaultOptions` each client created after that will use the opt
BinanceClient.SetDefaultOptions(options =>
{
options.OutputOriginalData = true;
options.OutputOriginalData = true;
});
var client = new BinanceClient(options =>
{
options.OutputOriginalData = false;
options.OutputOriginalData = false;
});
```
@ -54,8 +54,8 @@ The options are divided in two categories. The basic options, which will apply t
var client = new BinanceRestClient(options =>
{
options.ApiCredentials = new ApiCredentials("GENERAL-KEY", "GENERAL-SECRET"),
options.SpotOptions.ApiCredentials = new ApiCredentials("SPOT-KEY", "SPOT-SECRET");
options.ApiCredentials = new ApiCredentials("GENERAL-KEY", "GENERAL-SECRET"),
options.SpotOptions.ApiCredentials = new ApiCredentials("SPOT-KEY", "SPOT-SECRET");
});
```

View File

@ -18,15 +18,15 @@ book.OnStatusChange += (oldState, newState) => Console.WriteLine($"State changed
var startResult = await book.StartAsync();
if (!startResult.Success)
{
Console.WriteLine("Failed to start order book: " + startResult.Error);
return;
Console.WriteLine("Failed to start order book: " + startResult.Error);
return;
}
while(true)
{
Console.Clear();
Console.WriteLine(book.ToString(3);
await Task.Delay(500);
Console.Clear();
Console.WriteLine(book.ToString(3);
await Task.Delay(500);
}
```

View File

@ -13,12 +13,12 @@ A rate limiter can be configured in the options like so:
```csharp
new ClientOptions
{
RateLimitingBehaviour = RateLimitingBehaviour.Wait,
RateLimiters = new List<IRateLimiter>
{
new RateLimiter()
.AddTotalRateLimit(50, TimeSpan.FromSeconds(10))
}
RateLimitingBehaviour = RateLimitingBehaviour.Wait,
RateLimiters = new List<IRateLimiter>
{
new RateLimiter()
.AddTotalRateLimit(50, TimeSpan.FromSeconds(10))
}
}
```
@ -26,8 +26,8 @@ This will add a rate limiter for 50 requests per 10 seconds.
A rate limiter can have multiple limits:
```csharp
new RateLimiter()
.AddTotalRateLimit(50, TimeSpan.FromSeconds(10))
.AddEndpointLimit("/api/order", 10, TimeSpan.FromSeconds(2))
.AddTotalRateLimit(50, TimeSpan.FromSeconds(10))
.AddEndpointLimit("/api/order", 10, TimeSpan.FromSeconds(2))
```
This adds another limit of 10 requests per 2 seconds in addition to the 50 requests per 10 seconds limit.
These are the available rate limit configurations: