I am new to this platform and am trying to implement a MACD strategy for the S&P Mini Futures Contract, and take a profit for a one point move. Essentially, if the Signal crosses the MACD, set a limit order to take a one point profit and set stop loss of 2 points. I am only trading 1 contract for now since I just want to start simple. In Ninja Trader, you don't actually buy the contract, you only need $500 of initial margin in your account to make the trade. How do you implement this in QuantConnect? It seems that you have to actually buy the contract at the actual price and you can't use initial margin. Also, looking at my trades, it doesn't seem my orders are executing at the various targets properly. Can anyone help me with that?
Lordy Mike
Attached backtest
Lordy Mike
Also is there an easier way to handle rollovers? It seems the way it is coded is pretty convoluted.
Critical.Error
Each futures contract security has a BuyingPowerModel, with an associated InitialOvernightMarginRequirement property that we can access to calculate the initial margin required to purchase the contract.
initialMargin = self.Securities[contract.Symbol].BuyingPowerModel.InitialOvernightMarginRequirement
Link to the bootcamp task that covers this:Â
Â
Â
Â
Â
Louis Szeto
Hi Lordy Mike, Critical.Error
Thank you for your reply Critical.Error. We can set a custom buying power model to lower the initial margin requirement. Please refer to this sample and this snippet on how to create a buying model that suits your need.
As per the rollover contract issue, sorry that we haven't support auto-rollover in LEAN yet. You will need to implement the logic in your algorithm to sell the expiring contract (or wait for expiration) and buy the new front-month contract.
If you are looking for continuous contracts, LEAN doesn't support it neither. Nonetheless, sources like Quandl has this type of data provided for free.
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.
Lordy Mike
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!