Hello,
Is there any way to get position information in the trading algorithm running on the Blueshift?
context.portfolio.positions is empty even when there are open positions in there brokerage account.
It looks like position information is not queried from the broker.
Thank you,
Ed
Hi Ed, using context.portfolio.positions
should give you the updated positions information.
Note, wherever possible (including for Alpaca) we support virtual account. For such cases, algorithms maintain their own accounts independently, and only the positions resulting from the running strategy are returned by the above method. If you have placed a trade manually (or through some other platform or even other algos on blueshift) and not through this algo, the position will reflect in your Alpaca account, but the algo will not count it as its own. This allows you to run multiple strategies independently sharing a single broker account.
If you have a strategy positions (as you can see on the live dashboard), but not from context, please let us know.
Yes, I have a strategy positions made in the previous algo runs. However, when I restart algo it doesn't consider them. Unfortunately I have to restart it every week as Blueshift can only run for one week.
Got it. At present, blueshift actually does not support re-start. When you launch the same algo again, it is treated as a new execution, and starts with a clean past. As discussed in a separate mail chain, you will roll out a feature to restart (starting with existing context). That will solve your issue.