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/

    Different number of instruments available over time

    General Code/Help
    2
    2
    33
    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.
    • Federico Bassetto
      Federico Bassetto last edited by

      I have the following problems, I have 5 different objects in self.datas that start at a different point in times. For example the first three assets start being available on 2001-01-01 and the remaining two start on 2005-01-01. How can I backtest from 2001 to 2010 by allocating the portfolio between three assets first and between five assets later? Until now the backtester either raises an error if I try to backtest let's say between 2001 and 2004, or starts trading on 2005 if the dates I set are 2001 to 2010.

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

        In order to run strategy from the very beginning of the oldest data feed call strategy logic in both prenext() and next() functions. But you need to put some checks if data feed exists in the prenext().

        Check out Docs - Strategy

        • 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