sonvister / Binance

A .NET Standard Binance API library.
MIT License
229 stars 77 forks source link

Alter default rate limits on BinanceApi #24

Closed mehtadone closed 6 years ago

mehtadone commented 6 years ago

What is the correct way to alter the rate limiter on the BinanceApi. This does not seem to work:

        var client = new BinanceApi();
        var httpClient = client.HttpClient;
        httpClient.RateLimiter.IsEnabled = true;
        httpClient.Options.RequestRateLimit.Count = 50;
        httpClient.Options.RequestRateLimit.DurationMinutes = 1;
        httpClient.Options.RequestRateLimit.BurstCount = 1;
        httpClient.Options.RequestRateLimit.BurstDurationSeconds = 5;

Thanks,

sonvister commented 6 years ago

@mehtadone I see how that might be misleading. The options (BinanceApiOptions) are applied to the IApiRateLimiter when BinanceHttpClient is created and provide a means of passing appsettings.json configuration to the rate limiters (as in the BinanceConsoleApp sample). If you want to modify the rate limiter, use IApiRateLimiter.Configure(<duration>, <count>). To remove an existing duration/count combination set the count to 0 for that duration.

var client = new BinanceApi();
client.HttpClient.RateLimiter.Configure(TimeSpan.FromMinutes(1), 50);
client.HttpClient.RateLimiter.Configure(TimeSpan.FromSeconds(1), 5);