Back

Futures Portfolio - Managing Multiple Underlyings

Hi folks,

I am new to Futures trading and am looking to implement a very simple strategy that trades multiple futures contracts.  The intent was to eventually add indicators to adjust overall leverage and allocation between the asset classes.

For those interested in the strategy, it will end up looking like the Dalio All Weather portfolio for those of us who dont have access to Bridgewater portfolios: https://inside.bwater.com/publications/engineering_targeted_returns_plus_risks

I've encountered two issues:

1) The conditional statements on lines 105 and 113 are completly ignored.  I have tried a few different things here with no success.  Most of the documentation and threads are related to options and I couldn't quite figure out how to match up the underlying contracts to trade only one specific contract.

2) On line 69 I was hoping to Rebalance rather than Liquidate() but I need to get the current slice and am unsure how to complete this as well - this is probably a very simple fix.

Thank you in advance!

-Brian

Update Backtest








0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Hi Brian,

Please see the attached backtest that addresses the two issues.

1)    For lines 105 and 113, the contract.Symbol.Underlying is actually null because futures do not have an underlying. You can use IsCanonical() to check if symbol is a derivative canonical symbol. Instead, you should use chain.Key to get the symbol and check with the symbols you created (i.e. ES, ZB). As you can see from the backtest, only ES orders are placed because they come first.

2)    You do not need to call the Rebalance method. When you set up a scheduled event, on the scheduled dates, the OnData() will be triggered automatically. Since you have called Rebalance(slice) in OnData(), the algorithm will call the Rebalance() method on each scheduled date. Therefore, I simply added a logging statement to demonstrate that.

Hope this helps!

1

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed