By Eric Hamer
Machine Learning and Artificial Intelligence are hot topics with respect to quantitative finance. The world’s largest fund company (Blackrock) recently announced that it was replacing some of their analysts with computers employing machine learn and artificial intelligence. The founder and CEO of Blackrock, Laurence Fink, says, “The democratization of information has made it much harder for active management. We have to change the ecosystem — that means relying more on big data, artificial intelligence, factors and models within quant and traditional investment strategies.”
The firm believes that the right machine learning algorithms could pick stocks as well traditional analysts. At Quantiacs, we share this belief, which is why we are on a mission to democratize hedge funds for good by empowering anyone in the world to earn a fortune creating trading algorithms in their spare time.
This post provides a brief introduction to machine learning and shows how to use the Quantiacs toolkit to create and test trading strategies.
The Machine Learning Process
There are many types ML algorithms, and some of the higher-level problems they are used to solve include: regression, classification, and prediction. The open source movement has provided many free ML tools, and I have found Python to be a great language to use with these ML libraries because of the number of the open source packages available and support of scientific computing.
- The basic workflow used in creating ML solutions requires the following steps.
- Identify the problem ML will solve (for instance are you classifying, predicting, or performing a regression analysis on something, etc.)
- Determine what data will be used as an input and what is the anticipated output.
- Generate the data that will be used by the algorithm. Make sure the data is valid and clean. If some of the data is missing is it properly accounted for?
- Split your data into a set of training data and a set of test data.
- Use the training data to “teach” the algorithm. In this case, the algorithm is given both the input and result data.
- Use the test data to see what the algorithm predicts and compare this to the actual data.
If the results are not satisfactory, the algorithm can be modified and the process repeated.
The Quantiacs Toolbox
As stated above, it is imperative that the data be accurate, or the results of the algorithm may not be valid. I serve as the CTO of the Silicon Valley startup, Quantiacs, and our platform provides both a Matlab and a Python toolkit, along with clean financial time series data (i.e. all data is validated daily and is error free) for futures. The toolkits we provide are open-source and the data and toolkits are provided free for anyone to use.
The toolkit allows the user to create a trading strategy and back test it with data all the way back to 1990. In addition to futures data, Quantiacs has recently added macro-economic data which can be used in conjunction with the price time series data to improve the trading algorithms.
An ML Example using the Mini SP-500 Futures
I will now use the data from the toolkit to create a neural network, based on the Keras Python package, to predict the performance of the Mini S&P 500 (ES) futures. The algorithm will do the following.
The algorithm will do the following.
- Load the ES futures data from Jan. 1, 2006 to Dec. 31, 2016
- Use the first seventy percent of the price data to train the network
- The network will be provided the daily price change for each business day in the range
- Use the most recent thirty percent of the data to see what the network predicts
- Compare the predicted values to the actual values
This algorithm will then be repeated with the daily returns of the ES futures as well.
The chart below shows the actual and the predicted values of the ES futures.
The next chart shows the actual and predicted returns for ES.
Discussing the Results
The prices data, as predicted by the neural network, appears to be quite good as they closely track the highs and lows made by the ES future. However, the predicted values do appear to be less than the actual values for the entire chart. For the returns, the predicted return data appears to track the actual data, but it does not show nearly the same volatility. A closer look at these results is recommended.
- Will this strategy be profitable if one were to use it for investment purposes?
- If not, is it possible to create neural network based algorithms that do beat the markets?
- What are some example strategies and tweaks to consider?
- How can we easily optimize strategies?
QuantInsti® hosted a webinar, “Introduction to Machine Learning for Quantitative Finance” which was held on 15th June 2017 and conducted by Eric Hamer, Chief Technology Officer – Quantiacs. You can click on the link provided above to access the recorded session of the webinar.
If you want to learn various aspects of Algorithmic trading then check out the Executive Programme in Algorithmic Trading (EPAT™). The course covers training modules like Statistics & Econometrics, Financial Computing & Technology, and Algorithmic & Quantitative Trading. EPAT™ equips you with the required skill sets to be a successful trader. Enroll now!
Also, you can check our FREE introductory course, ‘Introduction to Machine Learning for Trading‘, it covers basics of various techniques used in Machine Learning for Trading, teaches you how to interpret the predictions made and code a trading strategy in Python with the help of interactive exercises and downloadable content.