Custom fill for SPX options are not being applied in this backtest using ComboMarket or ComboLimit orders. I've tried with and without the SetFillModel line and it returns the same results. Is there an error in the code or an issue having it applied to SPX options?
Mia Alissi
Based on the provided code and the information from the knowledge sources, it seems like the
MidPriceFillModel
is correctly implemented and set for the SPX options. However, there are a few things to note:The
FillModel
is used by the algorithm to simulate order fills during backtesting. It does not affect live trading. In live trading, order fills are determined by the exchange or broker (source).The
ComboMarketOrder
andComboLimitOrder
are not listed as methods that can be overridden in theFillModel
class. The methods listed for overriding are specific to different types of orders such asMarketFill
,LimitFill
,StopMarketFill
, etc. (source).The
ComboLimitOrder
andComboMarketOrder
are not standard order types in QuantConnect. If these are custom order types you've created, you need to ensure they are correctly implemented and handled in your fill model.If you're still getting the same results with and without the
SetFillModel
line, it might be worth checking if theMidPriceFillModel
is being correctly applied to the SPX options. You can do this by adding some logging statements in theMarketFill
andLimitFill
methods of yourMidPriceFillModel
to see if they are being called.If the
MidPriceFillModel
is not being used, it could be due to an issue with the order types or the way the fill model is set for the SPX options. You might need to debug your code to find out what's going wrong.Remember, this is a simplified analysis and may not cover all possible edge cases. You may need to add additional error checking and handling code to make this robust for a live trading environment.
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.
Chris Hernandez
https://www.quantconnect.com/docs/v2/writing-algorithms/reality-modeling/trade-fills/key-concepts
This shows the order types are accepted in the Custom Fill Model.
Louis Szeto
Hi Chris
A few issues:
1. You are trading on the option contracts not the canonical option symbol, so you'll need to set the fill model on a custom security initializer:
2. You need to override the combo_market_fill, combo_limit_fill method instead of market_fill and limit_fill.
3. Just letting you know the correct zero-fee model should be set as
Best
Louis
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.
Chris Hernandez
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!