Skip to content

Commit

Permalink
Updated cc
Browse files Browse the repository at this point in the history
  • Loading branch information
JKorf committed Apr 17, 2024
1 parent 99e211c commit bc18f03
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Kucoin.Net.UnitTests/JsonTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class JsonTests
{
x.ApiCredentials = new KucoinApiCredentials("1234", "1234", "12");
x.SpotOptions.OutputOriginalData = false;
x.RatelimiterEnabled = false;
x.RateLimiterEnabled = false;
x.FuturesOptions.OutputOriginalData = false;
}));

Expand Down
2 changes: 1 addition & 1 deletion Kucoin.Net.UnitTests/TestImplementations/TestSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public class TestSocket: IWebsocket
#pragma warning disable 0067
public event Func<Task> OnReconnected;
public event Func<Task> OnReconnecting;
public event Func<int, Task> OnRequestRateLimited;
#pragma warning restore 0067
public event Func<int, Task> OnRequestSent;
public event Func<int, Task> OnRequestRateLimited;
public event Action<WebSocketMessageType, ReadOnlyMemory<byte>> OnStreamMessage;
public event Func<Exception, Task> OnError;
public event Func<Task> OnOpen;
Expand Down
4 changes: 1 addition & 3 deletions Kucoin.Net/Kucoin.Net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\CryptoExchange.Net\CryptoExchange.Net\CryptoExchange.Net.csproj" />
<PackageReference Include="CryptoExchange.Net" Version="7.3.0" />
</ItemGroup>
</Project>
22 changes: 22 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
<ul class="nav flex-column">
<li class="nav-item"><a class="nav-link" href="#idocs_installation">Installation</a></li>
<li class="nav-item"><a class="nav-link" href="#idocs_apiaccess">API Access</a></li>
<li class="nav-item"><a class="nav-link" href="#idocs_ratelimit">Rate limiting</a></li>
</ul>
</li>
<li class="nav-item"><a class="nav-link active" href="#idocs_examples">Examples</a>
Expand Down Expand Up @@ -181,6 +182,27 @@ <h2>API Access</h2>
});
var socketClient = new KucoinSocketClient();</code></pre>

</section>
<section id="idocs_ratelimit">
<h2>Rate limiting</h2>

<p>By default a rate limiter is enabled which makes sure the server rate limits aren't exceeded. For more info on what the rate limits for the Kucoin API are see the <a href="https://www.kucoin.com/docs/basic-info/request-rate-limit/rest-api" target="_blank">Spot API docs</a>. Currently client side rate limiting is only implemented for the Spot API. Note that rate limiting is only implemented to prevent going over the request rate limit, it does not apply for order limits.</p>
<p>Whether client ratelimiting is enabled in the library and what the behaviour should be when the limit is reached can be controlled with the <code>RatelimiterEnabled</code> and <code>RateLimitingBehaviour</code> client options</p>
<pre><code>services.AddKucoin(x =>
x.RatelimiterEnabled = true;
x.RateLimitingBehaviour = RateLimitingBehaviour.Wait;
}, x =>
{
x.RatelimiterEnabled = true;
x.RateLimitingBehaviour = RateLimitingBehaviour.Wait;
});</code></pre>
<p>To be notified of when a rate limit is hit the static <code>KucoinExchange.RateLimiter</code> exposes an event which triggers when a rate limit is reached</p>
<pre><code>KucoinExchange.RateLimiter.RateLimitTriggered += (rateLimitEvent) => Console.WriteLine("Limit triggered: " + rateLimitEvent);

// Output: Limit triggered: RateLimitEvent { ApiLimit = Public Rest, LimitDescription = Limit of 2000 per 00:00:30, RequestDefinition = GET api/v1/market/stats, Host = https://api.kucoin.com/, Current = 1995, RequestWeight = 15, Limit = 2000, TimePeriod = 00:00:30, DelayTime = 00:00:19.8111238, Behaviour = Wait }</code></pre>

<p>Kucoin applies different rate limits based on the account VIP level. By default the rate limit is set to the most conservative <code>VIP0</code> tier. To change the rate limit tier call the <code>Configure</code> method</p>
<pre><code>KucoinExchange.RateLimiter.Configure(Kucoin.Net.Enums.VipLevel.Vip5);</code></pre>
</section>

<hr class="divider">
Expand Down

0 comments on commit bc18f03

Please sign in to comment.