I am building an environment where I do live trading and backtesting within the same python module. I want to store the values that I get from backtrader in my SQL database for both kinds of trading.
I am presently thinking how I can store the
positions that are created / deleted during trading and that I get informed about in the method
self.notify_order(self, order) .
I would like to take the
datetime that I possibly could get from backtrader for an order that is in state
order.getstatusname() = 'Completed' and use this as part of a compound key that I will store in my database.
I presently see the following candidates for this, but I am unsure which one to take.
These are my possible candidates:
datetime.datetime.utcnow() (at least during livetrading), as maybe the moment when
notify_order() gets triggered is independant from any candles I get).
At least during backtesting, 1.-3. contain the
datetime that I will receive with the upcoming
next(), but I am not sure whether to take 1.-3. is valid anyhow.
What would you take in my situation / what makes sense from the internal logics point of view of backtrader?
Thanks in advance!