For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:

How to update access token of oanda while paper trading

  • Hi,
    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):
           if not self.data_live:
           if self.data_live and not eq_sod < < eq_eod:
               new_access_token=input("Please enter access token:")
               self.cerebro.stores[0].p.access_token = new_access_token
               self.cerebro.stores[0].oapi.access_token = new_access_token

    After updating the token, there is no response from the broker.

    ***** Original DATA NOTIF: LIVE
    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

  • administrators

    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.

Log in to reply