Usually I don’t write about services I use, but one came into my way that I like – Quantopian. For a while I am interested in financial side of computer science, quantitative analysis, machine learning applications to predicting a stock market, etc. However, I was not really able to get grasp of these fields. I certainly could get some data from either Yahoo Finance and I even had access to Bloomberg terminal to play a bit with at the University library. I made some models, published a paper or ArXiv , made a tool that make these models available and published it on GitHub and I am talking with people at MUTIS Finance society to make a Quant club as part of the Macro Fund. But while studying my PhD, I was not able to get a job in finance and continue with my research, so I can get my degree, so there was no real grasp of how these fields look for real.
Then I found Quantopian, a software as a service that allows you to write real trading algorithms in Python, backtest them over 5 years of past financial data and even enter a competitions with other quantitative analysts around the world for the best trading algorithm. I was playing with it for a couple of days, making some very simple algorithms that make some heuristics about the price movements. One of my first algorithms was looking at the price movement in the past 10 days. In case the price have positive change during the most of the day that would mean that the share should be bought, otherwise sold. This algorithms, however simple it is performed quite well, performing positive trading for most of the time during back-testing, as showed on the below picture:
Also when this algorithm was used in a competition on a real data (still imaginary money), it performed quite well, earning $300 000 in about 15 days of trading by using $10 000 000. It achieved Sharpie ratio of 3.12 at the moment of writing the post:
In paper trading session the algorithm scored 91st. Back-score was much lower, which can probably say that a lot of people are overfitting for the past data and their algorithms are not as good when it gets to real trade sessions with current data (not perfect, but good start):
Then I decided to try to add some machine learning to it. Quantopian allows the use of sklearn machine learning library. So I used pretty similar approach with Random Forests. It is quite interesting what can be achieved: Algorithm had positive and negative returns for about half of the period of time. I made some glitch to be honest that allowed algorithm to borrow some money from time to time. So it went to total returns of -5100% at one point – great loss – but if you are willing to risk that much, algorithm ended trading session with total returns of +4653%:
And it is interesting what you learn from machine learning in finance – it will act almost as human: sometimes it will be deterministic, some times it will not be so much. As professor Burkhard Rost said on one presentation I attended, machine learning algorithm create rules and models that we some times see as black boxes because we cannot understand the math and decision system behind it, however, it is not building more complex solutions and models then the problem is.
Quantopian also provides data sets with data about financial indicators, sentiments of the tweets and many more. Which can be very interesting to use and that will improve performance of the predictions. I still had no time to look into it, but most definitely will. I was really quite impressed with what Quantopian provides for free and they even give prizes to good algorithms or select some to trade with real money, while the author gets share of the profits, which I see as very good and smart business model.
I hope others will enjoy this tools as much as I did.