Load existing orders from broker
-
Does backtrader have the ability to load existing orders from a live broker account?
For example, I place some orders with backtrader and the program shuts down. When the program starts up again, I'd like to be able to resume where I left off.
I've looked around the docs, forum, and web in general and could not find anything pertaining to this.
Thanks
-
@Thiago-P
To be more specific, load pending buy and sell orders and currently held positions from the broker? -
I think this question was already answered few times. Please take a look:
Is there way to track open orders with IB broker?
Is it possible to retrieve all the open/active orders from Interactive Broker?
Ways to repopulate IB trades/orders in strategy after shutdownYou may probably find other similar questions & answers by searching for 'open orders'.
-
From what I've gathered the answer is, "It depends on the broker you're using"
What I've discovered
It looks like the default back trader broker provides a get_orders_open method and it seems like the IB broker provides something of the sort as well, though I'm not sure if these will fetch orders already existing with the broker.
My intention was to use Alpaca as my broker through alpaca-backtrader-api. After experimentation using alpaca paper trading and looking through the alpaca-backtrader-api source code, it seems that the Alpaca broker does not provided any such method.
Conclusion
If I wanted to get existing Alpaca orders I'd have to make an API call directly to Alpaca or spend my time extending the Alpaca backtrader API.
Thanks for the links @vladisld
-
Indeed. Each broker implementation is responsible for such an action.