Hello!
Since last night May 1st I’m getting 429 for market data on free account (development stage). And it was unexpected since I have internal limiter “new Semaphore(2, true)” means 2 calls per second which is less then 3 per second(200/min).
Any updates or server issue?
@Sergey_Kuznetsov A 429 error is ‘rate limit exceeded’ (as you guessed). There are/weren’t any server issues last night (which would typically return a 500 error in any case). If you provide your account number and the approximate times you received that error I can check the logs. Those will show the times and requests which are being received by Alpaca which may help you debug the issue.
Yes that’s would be good for debugging. Thanks, @Dan_Whitnable_Alpaca
Sorry for confusion first 429 I got yesterday afternoon EST.
Paper:PA3NIEAZYDQ5
This is the first message:
HTTP response body: {“code”:42910000,“message”:“rate limit exceeded”}
HTTP response headers: {access-control-allow-credentials=[true], access-control-allow-headers=[Apca-Api-Key-Id, Apca-Api-Secret-Key, Authorization, Content-Type], access-control-allow-methods=[GET, OPTIONS, PUT, DELETE, POST, PATCH], access-control-allow-origin=[*], access-control-max-age=[1728000], connection=[keep-alive], content-length=[49], content-type=[application/json; charset=UTF-8], date=[Wed, 01 May 2024 16:36:02 GMT], strict-transport-security=[max-age=31536000; includeSubDomains], vary=[Origin], x-ratelimit-limit=[200], x-ratelimit-remaining=[0], x-ratelimit-reset=[1714581422], x-request-id=[721b75a6ef9f5995ca2668d4f30d40e3]} - 2024-05-01 12:36:02
2024-05-01 12:36:05
@Sergey_Kuznetsov You are simply placing too many calls. Your rate limiting logic must not be working.
Below are the calls leading up to the 429 rate limit error. Notice the timestamps are only milliseconds apart.
timestamp |
method |
path |
ratelimit |
remaining |
status_code |
May 1, 2024 @ 11:36:00.144 |
GET |
/papertrader/api/v2/orders |
200 |
3 |
200 |
May 1, 2024 @ 11:36:02.019 |
GET |
/papertrader/api/v2/positions |
200 |
2 |
200 |
May 1, 2024 @ 11:36:02.389 |
GET |
/papertrader/api/v2/clock |
200 |
3 |
200 |
May 1, 2024 @ 11:36:02.582 |
GET |
/papertrader/api/v2/orders |
200 |
2 |
200 |
May 1, 2024 @ 11:36:02.659 |
GET |
/papertrader/api/v2/orders |
200 |
1 |
200 |
May 1, 2024 @ 11:36:02.814 |
GET |
/papertrader/api/v2/orders |
200 |
0 |
200 |
May 1, 2024 @ 11:36:02.889 |
GET |
/papertrader/api/v2/orders |
200 |
0 |
429 |
@Dan_Whitnable_Alpaca thank you for the helpful feedback, i’m gonna debug and find leaks on my side.
have a good day!
@Sergey_Kuznetsov I can provide more log detail if you wish. Good luck.
1 Like
Hi @Dan_Whitnable_Alpaca Again Looks like I’m getting 429 even if I’m on subscription with 10000 limit.
Please, check where I’m wrong
2024-06-04 10:10:24 - ERROR - 10 - shsmith - TradeApp- 0.0.5.4b - AlpacaAPI getAlpacaAllOrders ->API Exception Message: Too Many Requests
HTTP response code: 429
HTTP response body: {“code”:42910000,“message”:“rate limit exceeded”}
HTTP response headers: {access-control-allow-credentials=[true], access-control-allow-headers=[Apca-Api-Key-Id, Apca-Api-Secret-Key, Authorization, Content-Type], access-control-allow-methods=[GET, OPTIONS, PUT, DELETE, POST, PATCH], access-control-allow-origin=[*], access-control-max-age=[1728000], connection=[keep-alive], content-length=[49], content-type=[application/json; charset=UTF-8], date=[Tue, 04 Jun 2024 14:10:25 GMT], strict-transport-security=[max-age=31536000; includeSubDomains], vary=[Origin], x-ratelimit-limit=[200], x-ratelimit-remaining=[0], x-ratelimit-reset=[1717510285], x-request-id=[5426ebc01d5dc8237733cf2e96c4df75]}
Found the answer:
The Trading APIs (eg submit_order, get_account, etc) all have a rate limit of 200 calls/min. This is independent, and completely separate from, the Market Data APIs (eg get_bars, get_quotes, etc) which have a default rate limit of 200 calls/min but is increased to 10,000 calls/min if subscribed to a paid market data subscription. A paid market data subscription does not increase the rate limit for the Trading APIs, only the market data calls.
The 200 call/min rate should be adequate for most applications. Alpaca has many accounts trading tens of thousands of orders a day with this same restriction. About 150 orders can very realistically be placed every minute.
1 Like
@Sergey_Kuznetsov Yes, that’s the issue. The Trade APIs (eg getAlpacaAllOrders as in the example) are limited to 200 calls/min independent of the market data subscription.