Rate-Limiting
Last updated
Last updated
Some traders have issues with certain 3rd-party services sending duplicate alerts in rapid succession, which can have catastrophic consequences. In response to this, we've create self-rate limiting, where the trader can dictate how often CrossTrade is allowed to evaluate similar commands.
To use rate limiting, you simply have to provide a rate_limit
and id
identifier field to any alert message to track the message type. In this example, we set a rate_limit=1
and id=mystrategy
.
By default, if the rate limit is a single number, it defines the number of requests allowed through CrossTrade every one minute (60 seconds) for that id
. So if 2 alerts show up within a few milliseconds of each other, the first one with that id
will be accepted, and the second one will be blocked.
If you have more advanced rate limiting requirements, it is also possible to dictate both the request count and the finite interval to allow that many requests.
rate_limit=1;
(default, 1 request every 60 seconds)
rate_limit=1/120;
(1 request every 120 seconds, or 2 minutes)
rate_limit=3/900;
(3 requests every 900 seconds, or 15 minutes)
And so on. The maximum request rate limit is 1,000 requests over 86,400 seconds, or 24 hours.
The following alert will only be processed if no other alerts with ID "mystrategy" have shown up in the last 1 minute.
key=your-secret-key; command=PLACE; account=sim101; instrument=NQ 12-24; action=BUY; qty=1; order_type=MARKET; TIF=DAY; rate_limit=1; id=mystrategy;