Hi all,
I've just gotten around to implementing the relatively new continuous futures feature. I copied the moving average crossover strategy from Martin Molinero with few lines adjusted.
The issue I'm having is that on the first day of the algo it makes 40 orders with a stream of constant buy and sell orders. Which doesn't make much sense to me since the order execution is:
if self.fast_sma > self.slow_sma:
self.SetHoldings(self._continuousContract.Symbol, 1)
else:
if self.fast_sma < self.slow_sma:
self.SetHoldings(self._continuousContract.Symbol, -1)
Considering that the first period is a downtrend with fast ma being < slow ma, one would expect a single short sale order to ride the downtrend. I'm sure I'm missing something here as only 1 order should be made per signal.
Cheers,
Mike
Fred Painchaud
Hi Mike,
Sorry I did not look at your code extensively because of time I got right now here but right off the bat, it looks like your fast and slow SMAs are inverted. Doesn't this:
should be this:
instead?
Well, rhetorical question. It should 😊. I don't know if that single change will make everything else work however, but it will help for sure.
Cheers,
Fred
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.
Mike A
Hi Fred,
it appears this slipped me by, good eye. I have made the change, but the issue of a flood of buy and sell orders persists.
Thanks
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!