Backtrader Community

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    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

    Indicators/Strategies/Analyzers
    1
    1
    87
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      brettelliot last edited by

      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!

      1 Reply Last reply Reply Quote 0
      • 1 / 1
      • First post
        Last post
      Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors