QuantRocket

Multiple strategy rebalancing


#1

Hi Brian!
I hope you are doing well!

According to the usage guide, capital is currently distributed between multiple strategies using static quantrocket.moonshot.allocations.yml file. This seems pretty basic. What if, for instance, a strategy is only effective during some market conditions? Or intraday strategy that only enters into positions during certain times a day? Or a strategy that enters a position after certain rare events? Money allocated to such strategies need not lay in cash, while they are not used by the strategy. So how can we implement a more complex logic for multiple strategy rebalancing?

I currently see this as creating some meta-strategy, that will encapsulate all strategies (as a list), and define its own trade method with its own logic, sometimes simply calling target strategy trade method, sometimes going through the modified trade logic on itself and calling target strategy methods separately. However, before I start writing the code I wanted to confer with you - this seems to be a rather typical task for a trading system, so maybe there are already some recommendations on how to implement strategy rebalancing logic. Maybe there are some code samples for this too?

Additionally question about current rebalancing system: the strategy gets Net Liquidation Value for the account and calculates allocations from it, but it seems like it only rebalances assets it owns (using order-ref). So what if there is not enough cash and assets owned by the strategy to meet NLV * strategy_allocation?

Thank you!


#2

There is a de-centralized approach and a centralized approach.

The de-centralized approach is simply to run all those strategies in tandem. Each strategy creates or doesn’t create orders as it sees fit. If you have portfolio margin, a fair amount of leverage is available. You can set the allocations to something reasonable based on how much the strategies typically overlap. The total allocation can potentially be higher than portfolio margin would accommodate because you know all the strategies won’t trade at once. If occasionally they do trade all at once and exceed your available margin, IBKR will reject some orders, so you are essentially outsourcing the risk management to IBKR.

If you want a more centralized approach, you can make a satellite script that runs one or more Moonshot strategies using the Python API, collects the orders, and applies any meta-logic or risk management logic you like, possibly querying various account balance fields to determine buying power. Then use the Python API to submit the filtered orders to the blotter.