Dear all,
It's my first post here. Trying to find a simple sample code/algorithm which can be used to show me how to code a algorithm for live trading. What I found in both documenation or community is all back test sample/code. Can someone show me a very basic strucuture and sample code such as moving average 20 bars which can be used for live trading.
have been struggle a little while.
thanks,
Ding
Alexandre Catarino
We can use the exact same algorithms for backtesting and live trading.
Please check out the attached project, it is a clone of QuantConnect University "Moving Average Cross" algorithm. After you clone it, you just need to deploy it in live mode (click on the switch labelled Mode in the top banner and follow the wizard).
Ding Ma
Alexandra,
thanks for the help. One more question: why do we still need to have "// set up our analysis span SetStartDate(2009, 01, 01); SetEndDate(2015, 01, 01); " in the initialize method, if I want to just to trade live for this algorithm.
that is the part confused me for live trading.
thanks,
Ding
Achagani
Ding,
I'll let Alexandre cofirm this, but from what I understand, those will just be ignored in a live enviornment and that way you can just take your code algorithm live after sufficient backtesting with a click of a button.
Alexandre Catarino
Achagani got it right.
There are setup methods like SetStartDate and SetEndDate that are not applicable, therefore they are ignored. In live mode, the amount of capital we set with the SetCash method is overriden by the capital we have in our brokerage account.
On the other hand, there are two features that are exclusive of live trading (and does not affect backtesting): Notifications and Runtime Statistics.
Ding Ma
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!