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

Stuck at delayed status



  • When I run this

    from __future__ import (absolute_import, division, print_function,
                            unicode_literals)
    import backtrader as bt
    import datetime
    
    class St(bt.Strategy):
        def logdata(self):
            txt = []
            txt.append('{}'.format(len(self)))
    
            txt.append('{}'.format(
                self.data.datetime.datetime(0).isoformat())
            )
            txt.append('{:.2f}'.format(self.data.open[0]))
            txt.append('{:.2f}'.format(self.data.open[0]))
            txt.append('{:.2f}'.format(self.data.high[0]))
            txt.append('{:.2f}'.format(self.data.low[0]))
            txt.append('{:.2f}'.format(self.data.close[0]))
            txt.append('{:.2f}'.format(self.data.volume[0]))
            print(','.join(txt))
    
        def next(self):
            self.logdata()
    
        data_live = False
    
        def notify_data(self, data, status, *args, **kwargs):
            print('*' * 5, 'DATA NOTIF:', data._getstatusname(status),
                  *args)
            if status == data.LIVE:
                self.data_live = True
    
    def run(args=None):
        cerebro = bt.Cerebro(stdstats=False)
        store = bt.stores.IBStore(port=7497)
        data = store.getdata(dataname='TSLA-STK-SMART-USD',
                             timeframe=bt.TimeFrame.Ticks)
        cerebro.resampledata(data, timeframe=bt.TimeFrame.Minutes,
                             compression=1)
        cerebro.addstrategy(St)
        cerebro.run()
    
    
    if __name__ == '__main__':
        run()
    

    I get

    G:\Git\Personal\Trading_Algo\venv2\Scripts\python.exe G:/Git/Personal/Trading_Algo/bt_test.py
    Server Version: 76
    TWS Time at connection:20200515 13:00:55 EST
    ***** DATA NOTIF: DELAYED
    

    This stays that way with no changes until I terminate the program. However, if I replace 'TSLA-STK-SMART-USD' with 'EUR.USD-CASH-IDEALPRO', it will work, showing everything from the strategy. Can anyone help me out?


Log in to reply
 

});