finmarketpy icon indicating copy to clipboard operation
finmarketpy copied to clipboard

Pipelining / stacking strategies

Open flipdazed opened this issue 3 years ago • 2 comments

Hey Saeed - been looking your finmarketpy library - looks nice!

What wasn't clear to me from looking at it was if you can stack strategies upon each other?

For example:

  • I have 4 building-block strats which solely roll commodity futures contracts.
  • I have 2 strategies, say Seasonality and Momentum taking roll strats as an underlying "asset".
  • Combine as a portfolio with some smart switching taking all 8 as inputs

Is that achievable ?

I couldn't see how it would be set up and return risk metrics at each constituent level.

flipdazed avatar Oct 04 '20 19:10 flipdazed

Thanks @flipdazed - one way to do this, would be to construct TradingModel classes for each of your building blocks. You'd then create a another portfolio based TradingModel strategy, and you'd fill the load_asset method to construct all the building blocks. The construct_signal method could be filled with all your weightings. You can then access all the return risk metrics for the whole portfolio, do all the sensitivity analysis (using TradeAnalysis) too.

At the moment there are automatic processes for doing things like vol targeting, but can imagine that people might want more complicated portfolio construction too.

However, I can add additional functionality to make this stacking of strategies a bit nicer/easier with TradingModel? One way I thought of doing this, would be simply to add your substrategies as parameters to the BacktestRequest and all the load_assets stuff would get filled automatically. You'd just need to write the scheme for construct_signals (and could default that to equal weighting). How does that sound?

saeedamen avatar Oct 05 '20 12:10 saeedamen

Ok I'll check how that works and get back to you

flipdazed avatar Oct 20 '20 07:10 flipdazed