Sleep 3 seconds and retrying https://paper-api.alpaca.markets/v2/orders 3 more time(s)

Hi All,

left my algo running to test it today, it is currently listening to 11 stocks, receiving minute updates. I came back to find this in the log:

sleep 3 seconds and retrying https://paper-api.alpaca.markets/v2/orders 3 more time(s)…
sleep 3 seconds and retrying https://paper-api.alpaca.markets/v2/orders 2 more time(s)…
sleep 3 seconds and retrying https//paper-api.alpaca.markets/v2/orders 1 more time(s)…
Closed Connection

I have never seen this error before, I would just like to understand what it is. Thanks to all who reply in advance.

E

Hi,
this indicates a server communication issue.
when did you experience that? during market open hours or outside of market hours?
did it happen again?
what repository are you using? (backtrader, pylivetrader, direct alpaca-trade-api)
what happened when you restarted?

thanks for your reply, it started again fine. must be an alpaca issue

1 Like

I get it all day long. Even if I stop and wait 10 seconds. It’s annoying and it makes me lose money. There is no way I can run my script on auto because this error requires me to manually set up sells. The buys may post but once this error comes, I am screwed. Let me ask you, is this due to the web socket? Like the OP I have more than two stocks that I am following and trading at one time. Will using AL for ordering and Poly (paid plan) for data and the web socket connect spare me of this error code?

I’m 82% sure that is caused because you are exceeding the 200 per minute query limit alpaca has in place.

Hi,
you have 2 choices for websocket connection as you mantioned (Alpaca data stream and Polygon data stream for paid accounts). of course - try both if you encounter an issue with the alpaca data steam.

no matter what you choose, your orders will be with Alpaca.

are you using python? if not what is your stack?
are you using the python SDK or doing it directly against the API servers?
are you using the backtrader integration or pylivetrader or did you write your own manager?

@GreenCauliflower and @TBD - I got this message too, and I can confirm it’s because I was making too many API calls per second. In Python, I now have a

time.sleep(0.5)

after every API call, so the script basically pauses for half a second (which is conservative since we’re allowed to make about 3 calls per second) before making another call. Hope that helps.