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

following the docs



  • I'm trying to follow the docs but I can't get the output that docs shows .
    what's the problem?

    My DataFrame
    0_1535072851982_그림1.png

     class PandasData(bt.feed.DataBase):
    
     parmas = (
    ('datetime', None),
    ('open', -1),
    ('high', -1),
    ('low', -1),
    ('close', -1),
    ('volume', -1),
    ('openinterest', None),)
    
    
    
    
    
    
    
    
    class TestStrategy(bt.Strategy):
    def log(self, txt, dt=None):
        
        df = dt or self.datas[0].datetime.date(0)
        print('%s, %s' %(dt.isoformat(), txt))
        
    def __init__(self):
        
        self.dataclose = self.datas[0].close
        
    def next(self):
        
        self.log('Close, %.2f' % self.dataclose[0])
        
        if self.dataclose[0] < self.dataclose[-1]:
            
            if self.dataclose[-1] < self.dataclose[-2]:
                
                self.log('BUY CREATE, %.2f' % self.dataclose[0])
                self.buy()
    
    
    
    
    
    def runstrat():
    cerebro = bt.Cerebro()
    
    cerebro.addstrategy(TestStrategy)
    
    dataframe = df_price
    
    data = PandasData(dataname=dataframe, timeframe=bt.TimeFrame.Days)
    
    cerebro.adddata(data)
    
    cerebro.broker.setcash(1000000.0)
    
    print('Starting Portfolio Value: %.2f' % cerebro.broker.getvalue())
    
    cerebro.run()
    
    print('Final Portfolio Value: %.2f' % cerebro.broker.getvalue())
    
    runstrat()
    
     Starting Portfolio Value: 1000000.00
     Final Portfolio Value: 1000000.00


  • Maybe the reason is that it should be params and you have parmas?



  • fixed it but the output didn't changed


  • administrators

    It's obvious then: you didn't fix it. Or else your code would raise an exception.

    You are not following the docs. There is no single example like that one in the docs.

    Your custom PandasData class is doing absolutely nothing. Use the PandasData which is part of the framework and at least your data will be read.