Friday, November 22, 2019

What Happened When I Tried Market Prediction With Machine Learning

This is I'm in the process of migrating my blog to Medium. The article you are looking for is here

This is mostly because I want to remove duplicate copies of articles, since it makes Google unhappy. I don't want to make Google unhappy. :-)

Thank you!


  1. Dear jason: Congrats on getting a jetson. I thought about it but wound up buying a freeze dryer. Plus I am not great at developing neural networks.

    When you speak of hidden patterns, I get excited. I think those patterns exist, and not just in markets.
    Let's say you generated 8192 letter blocks of random ascii text and, from them, retrieved a perceptual hash, a cryptographic hash, the length, and the first character, and implemented a network that receives this data and tries to reconstitute the text. Your loss rate starts at 100%, but because of getting even one character correct improves it, the graduation of gain might be much more realizable than a random walk. The neural network might discover mathematical correlations we can't even imagine.. or it might burn through electricity with no results. Go figure.

    I sometimes fantasize about what might be accomplished using neural networks, and I suspect the imagination of current researchers leaves a lot of room to expand. For example, the state of the art in neural network image compression consists of either networks that predict what method is best to use from a selection of contemporary compression techniques, or networks that extract features from the image and then reconstitute them using perceptual magic.

    I say to myself, but why? Consider the weight of the model in bytes as an analogue to the size of the lookup table in a contemporary compression library. If you could train a network to gradually achieve smaller intermediate products, while keeping the part of your network that reconstitutes it(something like a cyclegan i would guess), then the network could intuitively learn compression within the images you it processes.

    As far as stocks, a stock ticker by itself is a complex harmonic that reacts to the daily news, people's plans, the company's plans, all kinds of seemingly random data. But that data underlying it is not necessarily random, and in may cases, may be predictably organized. Such as periodic relationships between quarterly or yearly reports. I think, since the stock ticker can be considered a linear progression, it must be considered a sort of "harmonic" like in an audio file. If you converted all your stocks to audio format, and trained a neural network to reproduce them, it might be able to do a better job than literally trying to learn trends in a ticker absent the cues intrinsic to that ticker. Especially if you consider the complexity involved with trying to understand, at least for me, how the running network is actually "looking" at the data.

    Hoping you publish more interesting results, sincerely.

    1. Thank you! I wish you luck in your experiments!

  2. You made a few basic mistakes:
    1) 5% validation is far too low. I think that 20% are a minimum
    2) Selecting some good performing stocks during validation is just pure bias. You must look at all stocks (or look at a random subset).
    3) You have not shown that AI does not work on the stock market. Only that your approach does not work (this does of course not neccesarily mean that others do work)
    4) You can't predict a random walk. But most quants agree that an AI needs an underlying model (like pair trading)
    5) Most stock market transactions are currently AI based (HFT). They try to predict a few milliseconds (and not days) and are profitable (if you do thousands of trades a day even minimum gains sum up)

    1. Thanks very much for your feedback, I appreciate it! With only daily stock data to work with, I was concerned that only using 80% for training would be too small a training set. Perhaps that was a bad assumption - it would be very interesting to repeat the test with finer resolution data. I completely agree with you on point 2) - cherry picking results that fits the hypothesis is bad science. :-) Your point on 3) is also quite valid - it is entirely possible that someone has already figured it out and just isn't making it public. Again - thank you for your critique!

  3. I've been down that rabbit hole for quite some time and invested a lot of time looking for engineered models or using AI. I was trying to predict the small daily breaks in Bitcoin price, getting in only for a few minutes/hours to rake up 1% or 2%. My AI model did not perform better than my engineered model, this one managed to break even over 6 months during the great BTC price drop from january 2018, so not bad, but not enough to put real money behind it.

    What I've learned is that BTC-USD price is fafr from random, there are clear patterns that repeat, unlike random numbers, but it does not make it so easy to predict. I also think that using only price history as an input is not sufficient, especially for a short term trading strategy that i'm following. There are other trade inputs to consider and currently looking into it, but that's so much data, it's like drinking from a firehose.

    But one does not demonstrate anything unless that model has managed to beat the market for at least a year, and i'm not definitely not there.

  4. I never understood why ppl are always trying to predict the future with their models? Isn´t that the wrong approach? I mean trading is not really about predicting the future, is it. Its about playing the market how you see it based on statistical or fundamental indicators, then manage your positions with money management and cut losses while letting returns run. The question is of course when to enter and when to leave, but there are many indicators that show you when to to do that. They are just not always right. But with propper money management they shouldn´t cause big losses when they are wrong. And if you can trade with a 50% isch success rate, you should be in the green. Hell, you can even trade in the green with a 10-20% success rate. Thats how professional traders are doing it. They DON`T predict the future!

  5. Compared with discrete circuits, integrated circuit's reliability, mass production capability, and building-block approach to circuit design ensured its adoption. Microprocessors or cores are the most advanced part of an integrated circuit. semiconductor

  6. Great Article ! I was about to start the map hunt but this stopped me

  7. I agree, great article. I think verita$ has a well founded point. Most professional money managers would drool over having 50% accuracy as it is not really how well you win (although it matters) but how well you manage loss. I plus when it comes to market prediction I think a better approach is to use all of the macro economic factors in your model as well. Off I go to find out!

  8. Do you mind sharing the dataset to play around?