Here is the Moving Average Cross example from QuantConnect University in Python. We will be posting other examples in Python soon.
QUANTCONNECT COMMUNITY
Here is the Moving Average Cross example from QuantConnect University in Python. We will be posting other examples in Python soon.
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.
Florent
... excited to see python is getting some love for those amongst us contemplating switching from Q/pian to QC.
Chinmaya Kumar
I am getting build error when I clone this project and build it in my project.
Alexandre Catarino
We are working on a new python platform that will shipped soon. We expect that this build error disappear with it.
Meanwhile, could you please retry? It is working for me.
Leigham Springer Sutton
"We are working on a new python platform that will shipped soon. "
Do you have an estimated time frame as to when this new python platform will be shipped ? I am really excited to give it a shot :).
Chinmaya Kumar
@alexandre its working for me now.
Could you explain what is the meaning of this code statement ?
# only once per day if self.previous is not None and self.previous.Date == self.Time.Date: returnAs I want to try it in hourly timeframe and not daily
Alexandre Catarino
Hopefully we will ship the new python framework before Christmas.
This line of code:
# only once per day if self.previous is not None and \ self.previous.Date == self.Time.Date: return
assures that we only check for a moving average cross once per day after the exchange opens.
In order to evaluate the moving average cross every hour, please modify the code for:
# only once per hour if self.previous is not None and \ self.previous.Hour == self.Time.Hour: return
If we do not want to work with C# System.DateTime, we can convert the IAlgorithm.Time object to a python datetime object:
from datetime import datetime def lang_time_convert(self, time): return datetime(time.Year, time.Month, time.Day, time.Hour, \ time.Minute, time.Second, time.Millisecond) # In OnData: # only once per hour py_time = lang_time_convert(self.Time) if self.previous is not None and \ self.previous.hour == py_time.hour: return
Nolan English
@Alexandre Catarino
Will there be an announcement for the new python framework?
Alexandre Catarino
Yes, there will be an announcement.
At this moment, the most used features works locally. We are working on documentation and making it work on the cloud (Algorithm Lab).
Jared Broad
This code has been deprecated as we've replaced it with PythonNet. It will no longer work in the QC Environment. You will need to use the new PythonNet example posted here:
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.
Alexandre Catarino
Here is a backtest of the Python version of MovingAverageCrossAlgorithm:
Alexandre Catarino
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!