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

Nothing happens when running cerebro

  • Hi, I have written my code just like strategy example but it won't run anything. Please help me.
    Strategy code:

    class TestStrategy2(bt.Strategy):
        def log(self, txt, dt=None):
            ''' Logging function for this strategy'''
            dt = dt or self.datas[0]
            print('%s, %s' % (dt.isoformat(), txt))
        def __init__(self):
            # Keep a reference to the "close" line in the data[0] dataseries
            self.dataclose = self.datas[0].close
        def next(self):
            # Simply log the closing price of the series from the reference
            self.log('Close, %.2f' % self.dataclose[0])


    class PandasData(bt.feed.DataBase):
        #linesoverride = True  # discard usual OHLC structure
        # datetime must be present and last
        #lines = ('Signal',)
        params = (
            #('dtformat', '%Y-%m-%d'),
            #('datetime', -1),
            #('time', None),
            ('open', 1),
            ('high', 2),
            ('low', 3),
            ('close', 4),
            ('volume', 5),
            #('Signal', 6),
            ('timeframe', bt.TimeFrame.Days),
            ('compression', 1),
            ('openinterest', None)
        # datafields = bt.feeds.PandasData.datafields + ([
        #     ('Signal')]
        # )


    ready_data = PandasData(dataname=strategy_data2)
    cerebro = bt.Cerebro()

    in the jupyter it gives this:

    [<__main__.TestStrategy at 0x150489c3ba8>]

    but running in normal file gives nothing. At least I want it to log the close, so, I can make that cerebro is working on my data.
    Please help me. Thanks

  • Your data feed has not datetime parameter.

Log in to reply