SUPERALGOS DATA MINING
Shannon’s Information Theory as a Basis to Confirm Market Movements
Hey Mr. Shannon! Is there something new in the market?
When entering a position, we look for special patterns in the market to catch the best possible opportunity and make substantial profits. Depending on the strategy, one could be interested in finding instability to confirm an intuition or on the contrary looks for a special event occurring while the market is quiet.
We propose to build an indicator based on Shannon’s information theory, to highlight the moments when the market is moving or steadying and that will simply tells if there is something new right now, compared to a certain amount of past periods.
Shannon’s Information Theory
Claude Shannon was an electrical engineer and mathematician who lived in the 20th century. Among all the discoveries and inventions he made, he is well known for the Information Theory, generally referred as the Shannon Theory of Information, but it is interesting to know he also invented the first ever artificial learning device, “Theseus”, a mechanical mouse driven by an electromechanical system, and able to find its own way in a configurable maze while memorizing new changes in the different configurations to find its way back.
Shannon’s theory is a mathematical probabilistic theory used to quantified the content of messages encoded in a way to fulfill a statistical distribution. Information theory is at the very basis of all our communication and information transmission systems.
According to Shannon, information is a random quantity described by its uncertainty and solely defined by its probability to occur:
Considering a time series of events normally distributed, the most probable an event, the closest to 0 the information, and lower probability events will then have their information quantity sinking below 0. There is a more than significant meaning in Information. Actually it is more about highlighting what is surprising, i.e. the low probability events in the information stream than trying to process the most probable events. Information is about what is new in the stream, and this is what we are going to use to build our indicator.
Building the “Surprise” Indicator on the Periodic Return
Information quantity of the periodic return
The Periodic Return is the ratio between the price of the current period and the price of the past period. It provides useful information when it comes to evaluate volatility and trends. On a very basic point of view, a higher than 1 periodic return tells the price is rising while a lower than 1 periodic return indicates the price is decreasing.
Considering the price follows a Geometric Brownian Motion process, the Periodic return, on a long period of time, will be distributed according to a normal distribution, making tricky if not irrelevant the use of periodic return to analyze trend on a short period of time.
Now, let us change our paradigm and consider the periodic return as a stream of information among a fixed window of time. Segmenting its distribution in a fixed number of bin we then have a number n of periodic return events different for each bin and a total of N periodic return events on the whole window. The probability the current event has to occur is then:
We can now build an Information quantity time series with:
Analysis of the periodic return information quantity
A surprising event is an event that will occur with a very low level of probability. In terms of information quantity we expect to observe a significant drop of I when this event occurs.
We propose to realize a two steps analysis. In a first time we will calculate the Z-score of I and set 2 Bollinger Bands like barriers above and below the Z-score. Z-score will indicate the position of I against its moving average in standard deviation unit and can be used as a probability indicator using reduced normal law. For more information, have a look at Highlight Market Singularities to differentiate Anomalies and Trend reversal.
With this first level of analysis, we expect to observe crossing of Z with the upper level when an event looks significantly surprising.
For the second step, since a trending behavior of the price should be materialized by a series of surprising periodic returns compared to the average dataset, we will calculate an accumulation indicator of Z above and below its moving average, using a trend intensity like indicator.
Implementation: ready for the surprise!
The Surprise indicator is built as follows:
- Build the Natural logarithm of periodic return in a 200 periods array
- Establish the probability distribution of the 200 last periodic return over a 10 bins histogram
- Find the probability of the actual periodic return and calculate Shannon’s information quantity
- Calculate the Z-Normalization of I with 20-periods moving average and upper/lower probability bands at twice I standard deviation
- Calculate the Z accumulation above and below its 20-periods moving average and on the last 5 periods
Using Superalgos, we set a Product definition in an indicator bot and the corresponding Plotter to plot the Z-Normalization with its 2 low probability bands and the accumulation as an alternating green/red line.
The accumulation curve turns green when a trend is establishing, related to Z spending more time above its moving average than below. It means actually something happens with the periodic return, information statistically new compared to the last 200 periods of periodic return.
Conclusion
We have shown an original use of Shannon’s information theory to highlight the establishment of trends. Analyzing how the periodic retunes compares to its historical value leads to a possibility to find when the market changes. This method could eventually be applied to other types of indicators.
The Surprise indicator can be found at Polus data mine in Superalgos.
All the material presented here can be reused and integrated freely on the condition linking to this article and the Superalgos website.
Disclaimer: The content of this article is for educational purpose only and does not constitute financial advice. Trading is not suitable for everybody; seek professional advice. Use this article at your own risk.
If you enjoyed this article and want to participate in the most promising open-source social trading platform… come and join us !
- Superalgos Community: https://t.me/superalgoscommunity
- Superalgos Support Group: https://t.me/superalgossupport
- Superalgos Develop Group: https://t.me/superalgosdevelop
- Superalgos Data Mining: https://t.me/superalgosdatamining
- Superalgos Machine Learning Group: https://t.me/superalgosmachinelearning
- On Discord Server: https://discord.gg/CGeKC6WQQb
- Superalgos en Français: https://t.me/superalgos_fr
- BTC/USDT Telegram Bot: https://t.me/superalgos_tradingBOT_BTC_USDT