Stock Price Prediction with Big Data and Machine Learning
eugenezhulenev.com
eugenezhulenev.com
Meta note: I especially like how the code was intertwined with descriptive text like an R Knitr file. It makes it easy to follow allow and verify that what the author says he's doing, is actually what he's doing:)
A few issues about using this in production, none of which are intended to slight article's author or his work.
1) The biggest issue for me has always been speed. In this instance he's using one symbol, imagine trying to do this against 1000 symbols with the real depth of market and not just the precanned market data he's using. its alot more data to parse and classify. You can start to see why many HFT systems are more of an IT and programming endeavor than a quantitative one, not that the quantitative portion isn't important:)
2) Just being able to detect which way the stock will tick doesn't really help as much as you'd think.
Assume that you can correctly identify the direction of the next tick 100% of the time. To make money off of this information you need to:
- be able to do this classification and send the order to market faster than it takes to receive the next tick(n+1), a difficult task for most stocks that trade in major US markets.
- Get to the top of the order book, again a difficult task as the bid/ask spread is already tight, and sometimes at its penny limit.
- Get someone to fill your order, again a factor of being at the top of the order book,
- Identify if the tick n+2 is going in the same or opposite direction. if you guess wrong, then you lose. If you guess right you still need to be able to exit your position.
As always, if you are capable of doing this kind of work and able to work in Canada. I'd love to chat with you!! Heck even if you are interested in machine learning and the markets, I'll make time to chat.
Put very bluntly, in high frequency domains you compete with fast people (and they have resources) but in mid- or low frequency you compete with smart people. The problem is much harder but therefore it's also much easier :)
This is not to say that I'm a profitable quant (because I'm not) but I think my chances are much higher in the are I chose.
The question that seems interesting: is it possible to guess the price movement for some t+delta moment, where the delta could be for instance 0.1 sec? Or it would be completely unpredictable...
How about doing this not with 1000 equities but with say SPY options, or any other high volume options on cboe ? As long as your derivatives are ATM or say max 2 hops from ATM on either side & open interest is high, it would work ok.
I've only had a glance, but it looks very well done.
I did a little bit of BTC trading, and I thought I had an interesting idea. I traded on one of the smaller exchanges, but uses Mt. Gox as the oracle to predict which way the price would move. The basic idea worked pretty well: there was correlation. The problem ended up being my order placing algorithm which would actually do the wrong thing on very large/fast swings.
I think that idea may be interesting to apply, in terms of correlated stocks. If you detect a price drop in stock for a lithium mining company, you might predict a stock drop for Apple, since Apple uses lithium batteries for their devices.
Suppose you have a miraculous trading algorithm that you believe makes somewhat above-market returns with somewhat below-market risks, but you have only a small amount of capital you're happy to gamble with.
Then what you can do by keeping your algorithm to yourself is: have investments that perform slightly better than most other people's. That's nice, for sure, but getting rich that way takes a long time unless you start out quite rich (or gamble a lot and get lucky, but that's also a way to get poor).
On the other hand, what you get by publishing it might be a lucrative job offer at a hedge fund or investment bank, who hope you can use the skills you've just demonstrated to get them an extra 0.1% of return on their $10B pot. Now you have the opportunity to apply the same techniques to thousands of times more money than before, along with much more data and a server room full of hardware for backtesting and other smart people who will look at your clever ideas and maybe notice if there's a big mistake or omission. Of course most of the gains from your miraculous algorithm now go to the investors, and most of the rest probably go to other people with more seniority, but you are still likely to get rich faster and more reliably that way.
I make no claim about the particular algorithm here or the person who published it. But the above seems to me like a pretty plausible reason why someone might prefer to publish, even if they have good reason to think their algorithm works.
On the other hand, there is very little barrier to entry if you have a winning stock trading algorithm. All you really need is money, which is easy to acquire (for this purpose at least).
imagine you have algos A and B, where A is better than B
your top competitor has algo B, and everyone else has C
if you release B to the public, now every C becomes a B and competes directly with your strongest competitor.
(pure speculation)
Plus, the data used is only for a couple of days.
And finally: if someone had an ML model to reliably make money on the stock market, they wouldn't be writing about it; they'd be laughing all the way to the bank.
in hindsight, we can easily identify what is and is not relevant/influential, whereas in real-time anything could prove to be relevant/influential.
Years of thinking and ruminating and learning (and investing) on the subject has left me solidly in the "random walk" camp. At any given point, a stock is equally as likely to go up or down. There's a small upward bias in the market (greater than inflation), and I reason that it's the premium offered over debt to take the higher risk of equity.
If you plot number of consecutive up-days and down-days, it's a normal distribution, skewed to the right, and with fat tails.
That said, my own belief and experience suggests that I can consistently press a small edge, which is why I gravitate towards options and futures (highly leveraged, high notional value). I don't think that would be possible without a "Portfolio Margin" account.
In fact the authors of the original paper seem completely clueless about this point: "For example, since the prediction time of AAPL, 0.0311ms, is less than 0.0612ms, which is the time difference between the upward spread crossing events from the Row k −1 to Row k + 4 in Table 1, the model could in principle perform fast enough to influence corresponding trading decisions"
As if their order could reach the matching engine in 30 us...
Stock price is an stochastic process. It's unpredictable for the most part (of course if there are news with a big impact on a company the stock price usually reflects that, still)
It's certainly a nice experiment, but don't expect to get rich with it (the opposite is most likely)
edit: It's two days of data? For one stock? If you are interested in this stuff, this is not an article worth reading.