For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
how to inspect the data in the datafeed
-
Hi All
I am new to backtrader. I used to build strategy with pandas and it was easy to check the data that you are back testing and verify the strategy is working correctly.
I am not sure what's the best way to inspect OHLC data in the data feeds, it is bit confusing for me.
Can someone shed some light on it?
-
I dont exactly understand your question. But backtrader had a plotting function which you can use to verify.
-
@petehe You can use this to get logging of your ohlc.
def log(self, txt, dt=None): """ Logging function for this strategy""" if self.p.printon: dt = dt or self.datas[1].datetime.datetime(0) print("%s, %s" % (dt, txt)) else: pass def print_signal(self): """Print to termianl ohlcv.""" print( "{} o {} \th {} \tl {} \tc {}\tv {}".format( self.datas[0].datetime.datetime(), self.datas[0].open[0], self.datas[0].high[0], self.datas[0].low[0], self.datas[0].close[0], self.datas[0].volume[0], ) ) def next(self): self.print_signal()
-
@run-out I just realized looking at the code I posted that the
print_signal
doesn't use the log but uses its owndatetime
. -
@run-out thank you very much