Navigation

    Backtrader Community

    • Register
    • 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/

    Is this a valid way of analyzing multiple timeframes?

    General Discussion
    2
    4
    1589
    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.
    • T
      Taewoo Kim last edited by

      I am adding data, then resampling data to get multiple time frame trend analysis.. but it's the same data feed. Source code:

      '''

      df = csv_to_pandas(args.data, timeframe="1Min")
      
      cerebro_data = bt.feeds.PandasData(dataname=df)
      
      logging.info("Adding pandas dataframe to cerebro")
      
      cerebro.adddata(cerebro_data)
      
      logging.info("Adding resampled pandas dataframe for higher timeframe to cerebro")
      cerebro.resampledata(cerebro_data, timeframe=bt.TimeFrame.Minutes, compression=60) # 1 hour
      

      '''
      Is this correct? For some reason the resulting graph doesn't look right

      B 1 Reply Last reply Reply Quote 0
      • B
        backtrader administrators @Taewoo Kim last edited by

        @Taewoo-Kim said in Is this a valid way of analyzing multiple timeframes?:

        cerebro_data = bt.feeds.PandasData(dataname=df)

        Missing timeframe/compression? The default is timeframe=bt.TimeFrame.Days

        T 1 Reply Last reply Reply Quote 0
        • T
          Taewoo Kim @backtrader last edited by

          @backtrader I already resampled in pandas... is this "un-kosher"? Should I be letting backtrader doing this?

          1 Reply Last reply Reply Quote 0
          • B
            backtrader administrators last edited by

            You can resample 1000 times in pandas if you wish, there is nothing against it. It will actually probably save you time (more if you save it to disk/database/something-else) and read it from there each time.

            But you are simply not telling the platform to what you actually resampled to and therefore the default settings bt.TimeFrame.Days/1 are applied.

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            Copyright © 2016, 2017, 2018 NodeBB Forums | Contributors
            $(document).ready(function () { app.coldLoad(); }); }