Hi,
I am trying to test my algo on paper trading. all is going well then for some reason the connection was closed. The computer was idle, I didn’t input anything. Can someone please explain this?
Thanks
E
Hi,
I am trying to test my algo on paper trading. all is going well then for some reason the connection was closed. The computer was idle, I didn’t input anything. Can someone please explain this?
Thanks
E
Hi,
server communication may sometimes break.
since v.049.0 (latest is 0.49.1) we do a ws reconnection when that happens.
make sure you are using the latest version.
Hi Shlomi,
Thanks for your reply. I am using the latest version. Is there a command you can call in the “on_close” function to automatically reconnect?
thanks in advance
it is automatically defined to reconnect.
do you have a stacktrace with the error you get?
there is no error, it just closes connection on its own. I haven’t written anything to reopen the connection because I can’t find anything online. I’m sure there is a simple solution but it has escaped me so far lol
add a logger to your script.
do it like this:
import logging
logging.basicConfig(format='%(asctime)s %(message)s', level=logging.INFO)
also, define the websocket connection in debug mode:
StreamConn(ALPACA_API_KEY,
ALPACA_SECRET_KEY,
base_url="https://paper-api.alpaca.markets",
debug=True) # <============== ADD THIS
this should give you more information
that doesn’t seem to work, I have it written like this:
api = tradeapi.REST(API_KEY, SECRET_KEY, BASE_URL, api_version=‘v2’)
unexpected key word arg.
are you sure you have the latest version of alpaca-trade-api?
No I’m confused sorry. I thought v2 would be newer than 0.49.1. I have changed my version to that and it still closes connection on its own.
wait for the market to open
Hi Shlomi, Sorry to be a pest but I am struggling to get to grips with this. I have changed the version to 0.49.1, though now I am unable to get account() and place orders. What am I missing?
there was nothing done in those areas (account / orders ) in the last 3 versions of the sdk
shouldn’t be related to that
It was the only thing I changed. once changed back to v2 all that stuff works fine again. Is there a change in notation I should be aware of?
v2 is the default api version. you don’t need to specify it.
make sure you read the readme file to learn how to use the sdk: https://github.com/alpacahq/alpaca-backtrader-api