Guide to Automated Trading Using Quant Platforms and I Know First Algorithmic signals: 48% Annual Return

This guide will cover how to begin designing a strategy using an open source quant platform (QuantConnect), which you can then use to design your algorithm and eventually execute it in live paper trading or real money trading in just a click. I will also share a large data set of historical picks based on the I Know first “Top 10 Stock Picks + S&P500” which you can use free of charge for back testing.

Let us get right to it! Hopefully by the time you are done you will have a basic understanding of how you can take I Know First algorithmic forecast and use it to make a relatively powerful trading algorithms of your own. All your orders will execute timely on market opening, adjust prices according to your setting, and finally close according to your pre-defined parameters.

The first thing would be to sign up for an open source algorithmic development platform, two of the most powerfully available tools are QuantConnect and Quantopian. There are plenty of articles comparing the two so I won’t get into that here; however, in essence both are great. Perhaps the slight advantage is the ability to backtest and trade currency pairs on QuantConnect, which is why this guide will focus on it. It use (mainly) C#, unlike the alternative Python solution.

First of all start by opening up a free account and going through the “university” tab on the left. This will quickly teach you the basic ins and outs of C#, and the lean engine.

QuantConnect IDE

Make sure that you clone the algorithm so that you can follow along the video. The 4 videos will catch you up quickly, and really just take a couple hours to give you a huge head start. Now you want to code your first I Know First algorithm !!! So how do we do that? The most important thing is correctly uploading data from your excel files into your algorithm so that you use it to make decisions. Luckily we have this done for you, here is the code below.

Importing Data

This will look at an excel table (in csv format) located on a dropbox, and scan for new data which it saves on a string array (set of names). In this code we submit a daily excel data feed in this format

3

We are basically telling the algorithm to look into the excel table and make an array of 4 symbols, and 4 signals. In this case we simply tell it if we want to go short or long, as the picks have already been filtered according to the strongest four absolute signals in excel. These are the symbols we will be holding in the portfolio every day. The signals are the top 4 recommendations of the “Top 10 stock Picks + S&P500” after the new algorithmic strategy interface filters them according to momentum. Next we want to load this data into our algorithm. We create a copy of the data for use in that trading day with the following code.

AddData<Picks>(“SwingTrades”, Resolution.Minute,false, leverageset, false, false) (inside the initialize part)

public void OnData(Picks data){ todaysPicks = data;} (beginning of algo but after the initialization)

Great ! You now have updated algorithmic input and it is ready to be used for trading decisions. Because we are trading equities we generally want the algorithm to do nothing before the market opens, for that use the following:

if (Time.TimeOfDay <= new TimeSpan(9, 30, 00)) return;

So now you are ready to buy and sell stocks. This can be done in the most basic manner using SetHolding(ticker, percent of portfolio) which will place a market order to fill at that percentage of your portfolio, all the way to complex limit order and stop limit order based in variable pricing.

For now let us buy our first stock using our data copy (todayPicks) and our two arrays of information (symbol_E and signal_E). So let’s set our portfolio to today’s number one pick which will always load into the first position in the array (position 1).

if (todayPicks.symbol_E[1]!=cash_eq){ // check that it is not supposed to be cash.

if ((todayPicks.signal_E[1] > 0){ // check if we should go long

SetHoldings(todayPicks.symbol_E[1], 1);}// if yes set 100% to our pick

if ((todayPicks.signal_E[1]< 0){ //check if to go short

SetHoldings(SymbolInput, -1);} //if yes set -100% of your equity to this stock.

}

When you get more comfortable start setting up complex trading schedules, adjusting stop limits and much more! Here is an example of my algorithms methodology.

Step 1: At 9:31 Check which stocks need to be sold and create limit orders 1% away from the average price. Here you are closing yesterday’s positions.

Step 2: At 9:55 If orders didn’t fill than update them to the current average price !

Step 3: At 10:00 If orders didn’t fill than sell them at current market price L, what a bummer.

Step 4: At 10:01 Buy all of today’s recommendations which are not already in my portfolio with limit orders 1% away from average.

Step 5: At 10:25 If orders didn’t fill than set them to the current average price.

Step 6: At 10:30 Shame shame, fill all orders at the market price.

Step 7: Continuously check if a trade is at a 2% loss, if it is immediately sell it at market price to avoid further losses.

After simulating trading for a year from July 1st 2014 to June 30th 2015 here are my results.

Automated Trading

Because QuantConnect is already all set up for you with Interactive Broker’s API you can simply go from backtesting to live in one click!

5

Feel free to use the community to help you design your code and learn new ideas! I am sharing our historical daily picks with you HERE that I used in my back test. If you can beat our annual return of 48.47% and Sharpe ratio of 2.065 by more than 10%, with a lower draw-down, and you are never holding more than 25% of your portfolio in one stock then write us at [email protected], there is a big prize waiting for you!

Business relationship disclosure: I Know First Research is the analytic branch of I Know First, a financial start-up company that specializes in quantitatively predicting the stock market. This article was written by our head quant Daniel Hai. We did not receive compensation for this article, and we have no business relationship with any company whose stock is mentioned in this article.