Back

Futures Algorithm with Indicator and Consolidator for Python

First off all, credit goes to AlphAngel for the development of this implementation, which he or she did in C#. See the link to the original thread here. Managing futures indicators can be a complex task and I didn't find much on the forums so I did my best to replicate AlphAngel's implementation using Python. This implementation doesn't have any trading logic embedded but can be added relatively simply. Feel free to propose changes and update the code for anyone working with futures in Python.

Update Backtest








0

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.


Hey Brian. Thank you for the code example. I have a few questions/comments:

How are you handling the rollover to the next contract? Does self._contract always get updated to the most recent contract to trade? For a day trading algorithm I think calling OnEndOfDay to Liquidate all positions is ideal. But I'm not not sure about the rollover since I'm printing to log when a contract should be expired, but self._contract and self._nextContract are still the same.

Also for entering trades and checking indicator logic, would you use specify this in the OnHour method?

Thanks for any help you can provide!

0


I was able to get the futures contract to rollover successfully with this algorithm.

0


Here is the code.

3


Brian Weber thanks, if you get it to work with different futures contracts please post it.

0

Update Backtest





0

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.


Loading...

This discussion is closed