I Know First Research

Stock Market Forecast : How Can We Predict the Financial Markets by Using Algorithms?



Common fallacies about markets claim markets are unpredictable. However, chaos theory together with powerful algorithms proves such statements are wrong. Markets are chaotic systems with complex dynamics, yet to a certain extent we can make valid stock market forecasts. Using these forecasts generated by cutting-edge predictive algorithms together with a careful risk management strategy may give a trader a significant competitive advantage.

Markets Are Complex Systems

Looking at the common fallacies about stock markets, we can see two major groups. The first group is connected to the classical economic theory, which claims that markets are 100% efficient, and as such unpredictable. However, trying to make stock market forecast is useless anyway, as no stock can be possibly be a better deal than another. Both of them are efficient and everybody in the market has perfect information available to them. From our daily lives it is obvious that this does not truly reflect reality. There are people who actually profit trading stocks, which should not be possible in this idealistic market of economy theories.

On the other hand it is also not true that stock markets are completely chaotic, which claims the other big group of fallacies. Otherwise big trading houses such as Goldman Sachs are able to profit consistently, while in the chaotic market the profits and losses would always sum up to zero over a longer period of time. Where is the truth then? The complexity theory gives us an answer – markets are complex and chaotic systems and their behavior contains both a systemic and a random component. Therefore we can make a realistic stock market forecast, although it is precise only to a certain extent.

Complex chaotic systems are vulnerable to minor changes (butterfly effect applies) causing a big perturbation in the system pushing it far away from its equilibrium. Therefore we are usually able to predict behavior of such systems (such as the state of atmosphere and the weather) with a small error over a short period of time, until the minor errors accumulate and the system of feedback loops moves the system in a different direction than the prediction models. Even in this limited way, creating realistic stock market forecasts is surely possible and gives us the prospect to understand how market works and why big bubbles and big crashes happen.

Complexity – Combining Chaos and Patterns

As already mentioned, complexity of a system is a result of either the complex structure of the system (i.e. involvement of lots of actors with different goals and strategies) and/or of its complex dynamics (i.e. with lot of interdependencies and feedback loops between the system elements). Such complexity inevitably leads to chaos, when times with well-defined and predictable paths are interrupted with instability regimes where a minor perturbation can switch the future path between two opposite directions. It is important to note that the switch is not purely random, as the chaotic systems have memory and patterns tend to repeat.

Concerning the stock market, chaos is the result of the psychology of trading, which is never purely rational. People react with different emotional intensities to gains and losses tend to become biased by the latest news and subsequently are not able to quantify risks accurately. However there are underlying principles, basic economic assumptions, telling us that people try to reach the highest returns with the lowest amount of risk. Looking at price trends of a stock, we can generally say that the prices jump from one level to another, creating a pattern as we can see in picture 1. However, this cannot be seen at every time horizon. When we look too closely, on 1 day or even 1 month diagram, no patterns are apparent. Granularity matters and it is impossible to predict short-term movements of prices. With a longer time horizon, we can be far more successful, when we understand the underlying dynamics.

Picture 1: Stock price showing patterns in 5 years horizon



Feedback and Randomness – Forming and Crushing the Bubbles

What are the dynamics of a system? Generally, we can decompose it into a number of various feedbacks and causal loops influencing various aspects of the stock market. There are two basic types of feedback loops. A positive feedback loop is self-reinforcing – a positive effect in one variable increases the other variable, which in turn increases the first variable too. This leads to exponential growth in the system, moving it out of its equilibrium and eventually leading to a collapse of the system. On the other hand a negative feedback loop has a stabilizing effect, the system responds to a perturbation in the opposite direction. The examples of positive and negative feedback loop are depicted in picture 2.

Picture 2: Example of positive and negative feedback loop.

Interaction in the system with positive and negative feedback loops results in so called dynamic equilibrium, which in the stock market context means the stock price is oscillating around a certain price level. That’s why we say that market behaves as a drunken driver, the price is constantly overshooting the real stock value in both directions. For one example of influence of positive and negative feedback on a stock price see picture 3. However, under the influence of various delays there appear moments of randomness in the system. In these periods the volatility increases significantly and the system is basically unpredictable. As we can see from the dynamic nature of stock market, the market bubbles are essential part of it, so it is up to us to take the advantage of it.

Picture 3: Influence of positive and negative feedback on a price of a stock

Element of Randomness

Periods with high uncertainty may be caused not only by the system dynamics, but also by some specific events, such as natural disasters, earthquakes or floods. Even computers may cause a large chaotic periods, as we could have seen during the Flash Crash on May 6th 2010 causing shareholders’ losses over $1 trillion. These sudden falls can affect only one stock, as we experienced during Apple’s mini flash crash on February 10th 2011 (see the stock price of Apple in the picture 4). This crash was caused by high-frequency trading programs (HFT), enabling extremely quick transaction quoting. Being faster than competition is everything in this model, which leads among others to aggressive strategies, such as making enormous amounts of cancelled quotes just to slow down the competitors. HFT going wrong can cause huge volatility of the stock prices spreading across many markets.

Picture 4: Apple stock’s price fluctuation during the Flash Crash on February 10th 2011

The Key to the Market

The simple rule “Buy low, sell high” does not provide enough context to enable us to make good decision. The market can alternate between three different regimes – positive feedback, negative feedback and randomness. What is more, these regimes may be present simultaneously at different time scales. When analyzing the market before making a buy or sell decision, we therefore need to estimate the regime the market is at now and at what time scale. The knowledge of current the regimes gives us a true key to the market.

I Know First Algorithm – Seeking the Key & Generating Stock Market Forecast

The I Know First predictive algorithm is a successful attempt to discover the rules of the market that enable us to make accurate stock market forecasts. Taking advantage of artificial intelligence and machine learning and using insights of chaos theory and self-similarity (the fractals), the algorithmic system is able to predict behavior of over 10,000 markets. The key principle of the algorithm lays in the fact that a stock’s price is a function of many factors interacting non-linearly. Therefore, it is advantageous to use elements of artificial neural networks and genetic algorithms. How does it work? At first an analysis of inputs is performed, ranking them according to their significance in predicting the target stock price. Then multiple models are created and tested on utilizing 15 years of historical data. Only the best performing models are kept while the rest are rejected. Models are refined every day, as new data becomes available. For the visualization of the algorithm’s basic principle, see picture 5. As the algorithm is purely empirical and self-learning, there is no human bias in the models and the market forecast system adapts to the new reality every day while still following general historical rules.

Picture 5: Basic principle of the “I Know First” predictive algorithm

The stock market forecast algorithm is succesful even in predicting market bubbles, as you can see on picture 6. The algorithm successfully predicted the burst of the Apple stock’s price few days in advance. This is marked by the red down arrow on the chart.

Picture 6: Successful “I Know First” algorithmic prediction of Apple stock’s price bubble on August 2012

Interpreting the Results

The result of the “I Know First” algorithm is a daily stock market forecast for 1, 3, 7, 14, 30, 90 and 365 days showing trend prediction (the signal) together with its confidence (the predictability indicator), which helps the trader to decide which direction to trade, at what point to enter the trade, and when to exit. The indicators are influenced by two variables. One is related to the specific stock action, while the other follows the general behavior of the market. All together the stock market forecast makes a table as in picture 7, showing a color-coded heat map table with green cells indicating an up signal, and red cells indicating a down signal. Using this pattern the forecasts are customizable for specific needs of an industry or taking into account specific risk levels.

It is important to note, that the predictability rises and falls in waves, as the stock market behaves more or less systematically. By monitoring the predictability, we can be warned of changing behavioral patterns of the market in advance. There are also some stocks that are not predictable, mainly startups with little to none financial history providing not enough data for reliable predictions.

Picture 7: Example of stock market forecast generated by the “I Know First” predictive algorithm

Get today’s stock picks

Risk Management

From the empirical evidence of algorithmic performance analysis we can now tell that the trading system relying on the algorithm described above can usually profit consistently with a proper risk management strategy implemented as well. However, there still remains the random “luck” factor. We must be aware of the fact, that the market has a large number of hidden variables we don’t know about.

A stocks price generally cannot be described using normal statistical distribution, but rather utilizing a fat tailed distribution, having a significant percentage of events distributed on the extreme ends of the scale. This phenomenon is commonly known as Power Law. Events placed far from the mean value cause most of the market bubbles and raise the uncertainty significantly, making it difficult for traders to act rationally. This fact again emphasizes the importance of availing a proper risk management strategy. For a strategy to be successful, there are several rules to follow:

Watch the signals daily, but act only on strong ones.

To minimize risk stay out of the market until you see a great opportunity: a strong signal, extreme price.

When predictability is high, invest on strong signals.

When predictability goes down, expect a storm.

When the signal disappears or weakens, reduce your exposure.

For a stable portfolio invest in non-correlated securities.

Winning despite the Uncertainty

Market are complex systems, with random events occurring unpredictably. Commonly, the frequency and impact of unpredictable events is underestimated, which results to extremely high losses, as demonstrated above in the Flash Crash case. Despite all the randomness, the self-learning algorithms created with a deep understanding of the stock market accompanied with a risk management strategy are advantageous for traders.

This article is based on lecture given by Dr. Lipa Roitman the founder of I Know First, at Tel Aviv University. You can view the slides here.

[slideshare id=23453485&doc=i-20know-20first-20presentaion-20june-202013-20slideshare-130625045705-phpapp01]I Know First Presentation (February 2013) from I Know First

I Know First Research is the analytic branch of I Know First, a financial startup company that specializes in quantitatively predicting the stock market. This article was written by Alice Peková one of our interns. We did not receive compensation for this article, and we have no business relationship with any company whose stock is mentioned in this article.

Read More by I Know First Research

Stock Market Prediction Algorithm: I Know First Forecasts Market Volatility At Historic Heights

Read More Algorithmic Articles

Netflix Stock Prediction: Netflix Might Also Be An Acquisition Target

Artificial Intelligence: The Future of Trading