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/

    How to deal with multiple stocks data with multiple timeframes?

    General Discussion
    3
    3
    745
    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.
    • Suraj Thorat
      Suraj Thorat last edited by

      There is an example of using backtrader for multiple stocks and one for using multiple timeframes. Is there an example available to use both together? I want to get a signal on weekly data and buy if another signal on end of day data is satisfied.

      Mark Weaver 1 Reply Last reply Reply Quote 1
      • Mark Weaver
        Mark Weaver @Suraj Thorat last edited by

        @Suraj-Thorat I've had similar challenge.. I've settled on doing something like this in init and next. I check the _compression of the data to determine which datafeeds i want to setup indicators for, run calculations against, etc

                 def next(self):
                        if data._compression==self.p.largerCompression:
                            # do the larger timeframe stuff here
                        if data._compression==self.p.smallerCompression:
                            # do the smaller timeframe stuff here
        

        I've been able to add pairs of data feeds, one for each timeframe, for a couple dozen stocks and run them against months of data.. (takes a while obviously)

        1 Reply Last reply Reply Quote 0
        • A
          ab_trader last edited by

          What is your particular concern? It seems an approach is straight forward - in for loop add daily data feed, then resample it to weekly data feed. Now all odd data feeds are daily, all even data feeds are weekly. In the for loop apply signal indicators to even data feeds, apply confirmation indicators to odd data feeds. Check the signals and then issue the orders against odd data feeds.

          • If my answer helped, hit reputation up arrow at lower right corner of the post.
          • Python Debugging With Pdb
          • New to python and bt - check this out
          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors