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

Backtest from pre-specified portfolios



  • Hi, I'm new to backtrader.

    If I have (from external analysis) monthly portfolios (i.e. tables with three columns - one with date, second with ticker, and the third with weights, adding up to 1 within each 'date') and I want to look at monthly returns -- is there a way to do this in backtrader?

    Thanks,



  • Sure you can do this in bt. Depending on how your external analysis data is structured you may need to write an indicator to read that data, or read that data during strategy __init()__ and then process it in next(). Having only monthly bars can probably simplify your strategy. Using Returns analyzer with the monthly period you will get your monthly returns. One caveat - prices for all stocks used in your portfolios need to be loaded into bt at the beginning of the backtest. Which is logical approach, but somehow missed.


Log in to reply
 

});