I want to long/short the VIX first front month- contract and second-front month contract at the same time. like this:
However in paper trading, it cannot be filled at the same time. Like this:
But if I just submit 1 order, it can be filled right away
Mia Alissi
To execute simultaneous long/short orders on VIX futures contracts, you can use the
combo_market_order
method in QuantConnect. Here's a step-by-step guide to help you achieve this:Add VIX Futures Data: Ensure you have added the VIX futures data to your algorithm using the appropriate QuantConnect data source.
Identify Contracts: Identify the first front-month and second front-month VIX futures contracts you want to trade.
Create Combo Order: Use the
combo_market_order
method to create a combo order that includes both the long and short positions on the identified contracts. Thecombo_market_order
method allows you to specify multiple legs for the order.Set Asynchronous Execution: Set the
asynchronous
parameter toTrue
in thecombo_market_order
to allow the orders to be processed simultaneously. This is crucial for ensuring that both legs of the order are filled at the same time.Monitor Order Status: Implement logic to monitor the status of the combo order to ensure both legs are filled as expected. You can use the order tickets returned by the
combo_market_order
method to track the status.Handle Partial Fills: Add error handling to manage scenarios where one leg of the combo order is filled while the other is not. This might involve retrying the order or adjusting the order parameters.
Here's a sample implementation:
This code sets up a combo market order for VIX futures contracts, ensuring that both legs are executed simultaneously. Make sure to adjust the contract selection logic to suit your specific requirements.
Sources: Combo Market Orders - QuantConnect.com, Combo Limit Orders - QuantConnect.com, Combo Leg Limit Orders - QuantConnect.com, Index Option Call Calendar Spread Algorithm, Combo Order Ticket Demo Algorithm
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.
Miranda Lu
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.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!