alpacahq / alpaca-backtrader-api

Alpaca Trading API integrated with backtrader
https://pypi.org/project/alpaca-backtrader-api/
Apache License 2.0
614 stars 144 forks source link

sleep 3 seconds and retrying https://paper-api.alpaca.markets/v2/account 3 more time(s) #45

Closed x777 closed 3 years ago

x777 commented 4 years ago

I try paper trading with my own live feed using alpaca-backtrader-api. When I do resample for this data feed, I received message:

sleep 3 seconds and retrying https://paper-api.alpaca.markets/v2/account 3 more time(s)…

Sometimes it starts normally, but often no at all.

When disable alpaca broker, data feed working well.

alias-noa commented 4 years ago

Nevermind, it didn't work. The market was just closed :/

alias-noa commented 4 years ago

Yes that's how I found this, the issues page. I saw this guy had the same issue but it doesn't seem like it was ever resolved.

alias-noa commented 4 years ago

I changed usePolygon to False and didn't get the error anymore. Idk what it uses if not polygon though. Maybe this is a polygon related error? I don't have money in my real $$ account yet, it's pending, so maybe I can't use polygon yet. I sent $5 to it to see if that's why i'm having this issue.

shlomiku commented 4 years ago

we have 2 data sources - polygon and alpaca. you can only use the polygon data source if you have a funded account the alpaca data source is free

alias-noa commented 4 years ago

You know what, it's not Polygon. It's something wrong with my strategy. I tried one of the sample strategies and it works fine with polygon and paper trading. I didn't find the problem specifically but it was an error on my part in the strategy. Thanks for the quick responses though!

alias-noa commented 4 years ago

I'm trying to use 5 minute candles but this code seems to be giving me that sleep 3 seconds and retrying error:

TRADE_LIVE = True TICKER_SYMBOL = 'AAPL' CHART_RESOLUTION = 5
BACKTEST_START_MONTH = 1 BACKTEST_START_DAY = 1 BACKTEST_START_YEAR = 2019

https://i.imgur.com/Df5yDVL.png image

alias-noa commented 4 years ago

When I change bt.TimeFrame.Minutes to Days the error goes away...so seems to be something to do with bt.TimeFrame.Minutes

alias-noa commented 4 years ago

I think this is where it's supposed to go: image

shlomiku commented 4 years ago

you are trying to get minute data for a year and a half, that could be a problem. check the docs, to see if you can find the limitations (polygon docs if you're using polygon and alpaca's docs otherwise)

alias-noa commented 4 years ago

OH that makes sense. I have had problems doing that with other frameworks too. Thanks I have been really frustrated trying to figure this out.

alias-noa commented 4 years ago

Actually i'm not sure if that was even the problem. I deleted all alpaca and backtrader folders, everything related to either of them, then just unzipped this back into the same folder and now it no longer gives me that error. Very odd. I had an alpaca api folder as well (without backtrader) and I think that was somehow conflicting with this.

shlomiku commented 4 years ago

maybe you installed things under the same virtual environment. try using a clean virtual env

shlomiku commented 3 years ago

closing due to lack of activity