Closed happysammy closed 1 year ago
Hi @happysammy apologies for the delayed response!
The short answer is no, the current adapters don't do a good job of handling any rate limits.
However, there is some indirect rate limiting available via the RiskEngines
order throttler, which is configurable (100/s by default). See the RiskEngineConfig
docs:
class RiskEngineConfig(pydantic.BaseModel):
"""
Configuration for ``RiskEngine`` instances.
Parameters
----------
bypass : bool
If True then all risk checks are bypassed (will still check for duplicate IDs).
max_order_rate : str, default=100/00:00:01
The maximum order rate per timedelta.
max_notional_per_order : Dict[str, str]
The maximum notional value of an order per instrument ID.
The value should be a valid decimal format.
"""
bypass: bool = False
max_order_rate: ConstrainedStr = ConstrainedStr("100/00:00:01")
max_notional_per_order: Dict[str, str] = {}
If rate limiting is extremely important, you could probably adapt the generic Throttler
into any adapter you may be writing.
Going forward my ideas on how to handle this are:
HttpClient
base class for flexible/configurable applications of rate limiting for certain endpoint paths.Do you have any thoughts or ideas?
For what it's worth, IB API allow automatic pacing. From their release notes :
API messages sent at a higher rate than 50/second can now be paced by TWS at the 50/second rate instead of potentially causing a disconnection. This is now done automatically by the RTD Server API and can be done with other API technologies by invoking SetConnectOptions("+PACEAPI") prior to eConnect.
Closing this issue for now, as we finally have basic rate limiting available for the base HttpClient
, with quotas currently being added for Binance.
Discussions and developments can be tracked here.
Exchanges usually impose what is called a rate limit. Exchanges will remember and track your user credentials and your IP address and will not allow you to query the API too frequently. So I was wondering how you process ratelimits for these Exchanges(such as Binance or Ftx)? As far as i know, token bucket algorithm often be used to solve the rate limit problem.