Hey guys first post here. Really like the platform and hope to be contributing member of the community.
I have zero experience coding but was able to make some minor adjustments to some sample algorithims and arrived at this.
So I had a few questions on how to implement certain improvements.
1) Why is not always trading the front contract? If you look at the trades the algo makes it skips trading for a month everytime the contract it is trading expires. I feel like I am missing something here.
2) I tried to come up with a line to close all current positions if you are x days within expiry of the current contract but could not get the syntax correct, any suggestions?
3) How do I track the future itself for the SMA as opposed to an equity equivalent? I tried changing
equity = self.AddEquity("USO", Resolution.Minute) to equity = self.AddFuture("CL", Resolution.Minute)
but it ended up not trading at all. I am assuming there has to be some specfication of the contract but I am unsure how to implement.
Any and all feedback is appreciated.
Jared Broad
Thomas Chang -- the "SMA" method is a helper which create a SimpleMovingAverage indicator and registers it to get data. You should only do the "SMA" method once then save the object. If you call SMA in the OnData/more than once - it'll re-register it n-times slowing down your 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.
Thomas Chang
Hi Jared,
This is a very important point. It seems it is somewhat different than that by QuantOpian. By QuantOpian I put the calculation of SMA in before_trading_start(), not in the initialize(). Do you mean I should use the SMA in initialize() and get its value in OnData() as Ravi did above, or in the scheduler_functions?
Ravi Bodepudi
Jared, I'm not sure I follow, what would the adjustment look like?
Jared Broad
Ravi Bodepudi - Your code is perfect; no adjustment needed. I was replying to Thomas' comment,
Thomas Chang - Correct; define the object once, then use it anywhere you like.
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.
Ravi Bodepudi
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!