Hi folks. I’m trying to implement dynamic rate limiter to not overload exchange API with place\cancel order requests and follow allowed count. To do so I added a code to parse each response and collect current value for remaining requests taken from response headers. But I faced an obstacle and want you to share possible solution. Pretend I use Binance Test Spot api, with 50 requests allowed in 10 seconds. I have a batch of orders (lets say 100 orders) which places in async way. So before response will be returned by exchange with remaining request count all place request already sent that leads to request overflow. Inisde my limiter I do calculation of request sent and sliding window logic which reset limits when 10 sec interval has passed. The question is how I can synchronize my internal sliding window behaviour with one that on exchange side? maybe the way I’m trying to implement this is completely wrong or API provides more flexible way to do it? please, share your thoughts since order limiting is pretty important part and I want to use throughput in most effective way and not get banned. thanks in advance.
There are many solutions worth to consider depending on your trading, some suggestions may not be suitable for you.
- reduce the order amount
- consider more trading clients
- has a centralized placed storing used weight.
Thank you for your response, Dino. According to my needs I want to increase order amount to its maximum possible value without getting banned. Thats why I’m looking for mechanism that will allow me predict current processed order count and current time frame on exchange side taking into account that there will be delays in response