Did this ever get addressed? It seems like a great tool, but the ability to simulate a strategy on a portfolio of stocks is essential for it to be truly useful. For example, how would we build a portfolio of relative value strategies that are buying and shorting multiple single-name stocks and hedging against that via sector ETFs and SPY? How do we address position sizing too?
Originally posted by **vchopra9** February 1, 2023
Is it possible to run and evaluate cross-sectional backtests using backtesting.py (or another resource)? For example, I want to calculate a simple moving average crossover strategy signal (20 days vs 200 days), apply it to every stocks in the Dow Jones index, and restrict my Buy universe to only those stocks that meet the buy condition (sma(20)>=sma(200)). From within this Universe, I want the rank every stock using a measure of momentum (3 month price change) and pick the top 10 stocks to create a portfolio. Each stock is equal-weighted.
Then I want to evaluate the performance of this portfolio over time and compare it with the performance of the Dow Jones index itself. What is the best Python resource for doing this?
Did this ever get addressed? It seems like a great tool, but the ability to simulate a strategy on a portfolio of stocks is essential for it to be truly useful. For example, how would we build a portfolio of relative value strategies that are buying and shorting multiple single-name stocks and hedging against that via sector ETFs and SPY? How do we address position sizing too?
Discussed in https://github.com/kernc/backtesting.py/discussions/895