For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:

How to handle multi-products with different date range?

  • Let's say we have a macro indicator to buy or sell treasury notes, or any product that expires for that matter. For a given date, there would be a certain set of notes from which to buy or sell. How can Backtrader handle that in data feeds, I can pass all the products data feeds from the note inception to expiry. But then, all data feeds will won't have same start and end date.

  • bt can handle as many data feeds as you pass, also it doesn't matter for bt what are the data feed lengths. Script written should check if data feed prices are available at the moment, specify what to buy and what to sell etc.

  • @ab_trader Not sure if this is an issue since I did this a long time ago.... But when i was putting in stocks for an asx200 analysis going back a long time, some of the stocks didn't have data either at the beginning or the end. I had to at the time use pandas to fill in the beginning and ends with zeros before passing this into backtrader. Again, I was pretty green with backtrader then so not sure if this practice is necessary or not.

Log in to reply