For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
Getting daily returns using hourly data
-
Hi all,
Thanks for keeping the backtrader community alive! I have a question about the timereturn analyzer.
Im using hourly data but I want to get daily returns at the end. Im not sure how to create the timereturn analyzer to do that?
By putting in TimeFrame.Days, i do get a series of returns indexed by days:
cerebro.addanalyzer(bt.analyzers.TimeReturn, _name='time_return_analyzer', timeframe=bt.TimeFrame.Days)
If i use a compression value, it doesn't seem to impact the results. Meaning, these two analyzers produce the same results:
cerebro.addanalyzer(bt.analyzers.TimeReturn, _name='time_return_analyzer1', timeframe=bt.TimeFrame.Days, compression=1) cerebro.addanalyzer(bt.analyzers.TimeReturn, _name='time_return_analyzer60', timeframe=bt.TimeFrame.Days, compression=60)
Should I leave out the compression? If not, what should i be using?
Thanks!