Programmer's Path to quantitative trading (--quantconnect) Case 1

Source: Internet
Author: User
Tags quantconnect

Reprint needs to indicate: Http://blog.csdn.net/minimicall, http://cloudtrade.top/

Analysis Cointrader has a certain level, found that it is not a product after all, has not been verified. In terms of architecture, coding and so on are very non-standard.

Want to write a cloud trading platform, the way and heavy. We need to refer to some mature architectures.

Quantopian zipline not, because I just see it can't, so just to analyze Cointrader.

Now these two, one is not the cloud platform at all, one is immature, so I can only analyze the remaining one quantconnect. Its engine is lean.

Learning lean starts with learning, then learns its architecture and source code. Then we design our architecture and platform.

Let's first look at an example. The most basic case of the official.

The code is as follows:

namespace quantconnect {/* * Quantconnect university:full Basic Template:    * * The underlying QCALGORITHM class is full of helper methods which enable your to use Quantconnect. * We have explained some of these here, but the full algorithm can is found at: * Https://github.com/QuantConnect/Q    Calgorithm/blob/master/quantconnect.algorithm/qcalgorithm.cs */public class Basictemplatealgorithm:qcalgorithm {//initialize The data and resolution require for your strategy 
        public override void Initialize () {//start and End Date range for the Backtest:sets                     Tartdate (2013, 1, 1);                         Setenddate (DateTime.Now.Date.AddDays (-1));                        Cash allocation Setcash (25000); Add as many securities as.         All the data would be passed into the event handler:addsecurity (securitytype.equity, "SPY", Resolution.minute); }//data Event Handler:new Data arrives here.        "Tradebars" type is a dictionary of strings so you can access it by symbol. public void OnData (Tradebars data) {//' Tradebars ' object holds many "Tradebar" Objects:it is a di  Ctionary indexed by the symbol:////e.g. data["MSFT"] data["GOOG"] if (! Portfolio.holdstock) {int quantity = (int) math.floor (portfolio.cash/data["SPY"].                                Close); ORder function places trades:enter the string symbol and the quantity you Want:order ("SPY", quantity);                 Debug sends messages to the user console: ' Time ' is the algorithm time keeper object                                Debug ("Purchased SPY on" + time.toshortdatestring ()); You can also use log to send longer messages to a file.            You were capped to 10kb//log ("This is a longer message, send to Log."); }        }    }}


Programmer's Path to quantitative trading (--quantconnect) Case 1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.