JKorf / Binance.Net

A C# .netstandard client library for the Binance REST and Websocket Spot and Futures API focusing on clear usage and models
https://jkorf.github.io/Binance.Net/
MIT License
1.02k stars 420 forks source link

Binance - Spot Trading Via WebSockets - Order Request Rate Limits #1352

Closed BzCz closed 4 months ago

BzCz commented 4 months ago

Hi @JKorf

Hope you're keeping well.

Apologies but I was wondering if the automatic tracking of the Order Rate Limits when placing an Order via the WebSockets was implemented?

For instance I see that o.SpotOptions.RateLimitingBehaviour = CryptoExchange.Net.Objects.RateLimitingBehaviour.Fail is available when setting up the options for the Rest Client but not when setting up the WebSocket SpotOptions?

When I go and create a custom RateLimit via AddTotalRateLimit or AddEndpointLimit and add it to the WebSocket SpotOptions I don't see how I can set the endpoint to the order.place websocket method.

I had a look at the library code but perhaps I missed it but can you clarify if when placing spot orders via the websocket it automatically rate limits and stops any extra orders over 100 per 10 seconds and 200,000 per 24 hours without me needing to code it in?

On initialization of the rest client and or websocket does it check the exchange data on my current orders / request limits count for up to date tracking? I just want to know if I can use the websocket spot order trades as is or should I count the requests myself?

Thank you for your time and apologies for the stupid question.

https://binance-docs.github.io/apidocs/websocket_api/en/#place-new-order-trade

"rateLimits": [ { "rateLimitType": "ORDERS", "interval": "SECOND", "intervalNum": 10, "limit": 50, "count": 1 }, { "rateLimitType": "ORDERS", "interval": "DAY", "intervalNum": 1, "limit": 160000, "count": 1 }, { "rateLimitType": "REQUEST_WEIGHT", "interval": "MINUTE", "intervalNum": 1, "limit": 6000, "count": 1 } ] }

BzCz commented 4 months ago

I just coded the request limits in myself using the request header ratelimits you already provided for the websockets. Thank you for all your hard work :)