How to update access token of oanda while paper trading
Monil Shah last edited by
I have a problem while doing paper-trading for 15 days. As Oanda token expires and I can not refresh the program as I will lose initial positioning and open orders. Is there any method in which I can update the token in backtrader while the program is running. I have tried to change the token in next() method.
def next(self): self.logdata(self.original) if not self.data_live: return if self.data_live and not eq_sod < datetime.datetime.now().time() < eq_eod: print(datetime.datetime.now()) new_access_token=input("Please enter access token:") self.cerebro.stores.p.access_token = new_access_token self.cerebro.stores.oapi.access_token = new_access_token print(datetime.datetime.now())
After updating the token, there is no response from the broker.
13375,2019-12-23T13:24:00,Original,333.15000,333.50000,333.10000,333.35000,84248.00000 ***** Original DATA NOTIF: LIVE 13376,2019-12-23T13:26:00,Original,333.60000,333.65000,333.55000,333.55000,232467653.00000 2019-12-23 13:26:01.577574 Please enter access token:a340646bf6d99a52054098961a53abb72d17b007 2019-12-23 13:27:16.912265 2019-12-23 13:27:16.912329
backtrader administrators last edited by
You are for sure using:
Without looking at the code I would dare to say that the store doesn't re-open the connection simply because you update a couple of attribute members whilst trading.
You will have to ask the author(s) to add a method to do such a thing, something like this from within the strategy
and have this method creating a new connection to Oanda which will replace the existing one.