Professional Documents
Culture Documents
Quant Book 2022
Quant Book 2022
QUANT BOOK
2021-2022
COMPILATION OF INQUISITIVE QUANT IDEAS AND
INSIGHTS
Aayush Ananya
Pradipto Shreekrishna Archit Abhishek
Pratik Nilesh
A. Intro to Algorithmic Trading
B. Modern Portfolio Theory
C. Fama and French model
D. Black Litterman Model
E. Pairs Trading
F. Blockchain, bitcoin and NFT
G. Martingale theory
H. Hidden Markov model
I. Kalman filter
J. Reinforcement Learning in Finance
K. Double Irish Dutch Sandwich
L. Dragon king theory
Making the right choices while trading and taking emotion away from all the decisions you make in a high-
stakes live market is not the easiest thing to do, right? Even with ample knowledge of the stock market and
the resources to make active trades, it’s not humanly possible to be on the lookout for and capitalise on all
possible profit opportunities. You do have a computer though, which is exponentially faster than you at doing
preprogrammed things. If only you could teach it to take trade decisions for you, you would essentially have
a money-making machine on your hands! This is where algorithmic trading comes in.
Algorithmic trading was introduced in the 1970s, this was when highly computerized trading systems
emerged in the American financial markets. The New York Stock Exchange also introduced a system in 1976
which enhanced the acceptance of electronic trades by traders. Algorithmic trading was popularized by
Michael Lewis, an author who drew the attention of market traders and the public to high-frequency
algorithmic trading. In the status quo, around 70 percent of the trading in the US equities market is
automated through algorithms. Why did algorithmic trading become so popular, and what are the risks that
come along with it? That is what we seek to explore in this article.
Situational Algorithms
These algorithms are designed to work in the live market and make trading decisions based on the current
situation of the market. They are designed to replace humans as more intelligent decision-makers and are
aimed at making profits. They can spot patterns that they are designed to look for even across market noise
depending on how good the algorithm is and can make consistent profits for the entity deploying them. These
algorithms are usually proprietary and coming up with a good performing situational algorithm is going to
make you lots of money.
Most algorithmic trading consists of execution algorithms due to the huge impact they have on costs to large
corporations. That is to say, the bulk of the trades carried out by algorithms is in the category of execution
rather than situational.
Capitalize on Arbitrage
● Due to certain market conditions, arbitrage opportunities exist which fast and precise algorithms can
capitalise on.
● This can be as simple as buying and selling a stock that is listed on two exchanges at slightly different
prices, or as complex as taking advantage of price differentials between pairs or stocks and their
respective futures.
● These algorithms need to be blazing fast as these arbitrage opportunities exist for only a small period
of time.
● Execution of such algorithms needs data streams at extremely low latencies.
Sentiment Analysis
● As we know there are a lot of current securities (aka crypto) that don’t have any fundamentals to go
off of.
● Other than the expandability of the currency and other such factors, in the short term the dependency
of such securities is correlated higher to market sentiment than traditional stocks.
● In such scenarios, sentiment analysis which is a well known NLP problem can be used to aid decision
making.
● There exist live data feeds of bitcoin sentiment from the likes of Thomson Reuters which analyses
market sentiment from a variety of social media platforms and news sites which can be used as part
of your algorithm to trade these securities.
Conclusion
while being an increasingly robust approach to trading, algorithmic trading due to the competitive nature of
the market is still very hard to get started and profit in if you are a small investor. But for big players in the
market who have a lot of capital to invest and can afford top of the line hardware, this can be an excellent
way to increase their profits and cut losses.
What is Modern Portfolio Theory (MPT)?
Harry Markowitz developed a basic but fantastic portfolio selection theory which was published in the
Journal of Finance in 1952. Modern Portfolio Theory, also popularly known as MPT proposes a solution to
build a balanced portfolio that provides the highest return on a particularly given risk of the investor. Beauty
of this theory is its simplicity. It aims for the simple use of statistical methods for predicting the optimal
balance for a portfolio. It is a very popular theory all over the world. It initiated a wave of investment and
financial research.
The weight vector x is chosen randomly and for each weight Expected Return vs Risk is plotted. This plot
is known as Efficient Frontier.
Sharpe Ratio =
Where:
R = return of portfolio
P
R = risk-free rate
f
Advantages of MPT
•MPT became incredibly famous after its release in 1952. After the introduction of MPT people started
optimizing their portfolios in some rational way. Almost all the fund managers at that time used MPT to
balance and rebalance the weights of their portfolio.
•People started using MPT for creating a portfolio of ETFs (which is a collection of stocks which is traded
in the market as stocks. Like, you can sell and buy ETFs same as stock, you need not to hold it for years
like Mutual Funds). This helped people to truly diversify their portfolio and increase their expected return.
•Each stock is related to unsystematic risk (Risks which are not under control of investors like
Management Change, Faulting of Company, etc.). MPT aims to dampen this unsystematic risk by
diversifying the portfolio. It proposes that one can’t control the unsystematic risk but can reduce it by
diversifying the portfolio.
Disadvantages of MPT
•The biggest fault of this theory was that it used variance or volatility for risk calculation. Upside Volatility
is preferable to the investors, so it is not rational to account it in the risk calculation. To solve this, we
should only account downside-volatility or downside-risk which means the variance of that results only
when there was a loss. This was proposed by Brian M. Rom and Kathleen Ferguson in 1991 as Post-
Modern Portfolio Theory (PMPT).
•Each stock is related to unsystematic risk (Risks which are not under control of investors like
Management Change, Faulting of Company, etc.). MPT aims to dampen this unsystematic risk by
diversifying the portfolio. It proposes that one can’t control the unsystematic risk but can
reduce it by diversifying the portfolio.
•People started using MPT for creating a portfolio of ETFs (which is a collection of stocks which is traded
in the market as stocks. Like, you can sell and buy ETFs same as stock, you need not to hold it for years
like Mutual Funds). This helped people to truly diversify their portfolio and increase their expected
return.
•MPT became very famous after its release in 1952. After the introduction of MPT people started
optimizing their portfolios in some rational way. Almost all the fund managers at that time used MPT to
balance and rebalance the weights of their portfolio.
• It was also assumed in MPT that the market is ideal. All the investors in the market are rational; it is not
affected by any factor, or the effect is gradual. Which is also a major downside of this theory because we
all know that markets are never ideal. It functions majorly on sentiments. For e.g., Covid brought up a
negative sentiment and the market crashed.
• Third major downside of this theory is it works on historical data only. So, it is very difficult to believe
that the portfolio made on historical data will sustain the unpredictable future
Challenges on how to use it in today’s scenario…
MPT can give you only weights of the stocks in the portfolio hence leaving us with a great challenge of selecting
stocks.
There are certain guidelines to do this:
• The most logical hack is to select assets with negative correlation. Like you can mix govt. issued bonds
with small-cap and large-cap. Bonds are pretty stable and almost considered risk-free.
• The higher your selection correlation is near to -1 the better your portfolio will be.
• Another popular hack is to apply MPT to already created 2 efficient portfolios. This is known as TWO-
FUND THEOREM.
TWO-FUND THEOREM
This theorem states that you can hold a weighted portfolio of 2 already available efficient mutual funds. (Mutual
funds means an already created pool of assets). This can create another efficient portfolio to invest in.
Advantages of this is that it is easier to have such a portfolio because the mutual funds will be low in cost than
holding each individual asset. And the portfolio will be easily maintainable by the investor because he
needs to see only the two fund performances.
It can be shown that if you want your expected return between the 2 efficient funds then you can hold them
both in certain weights (determined by MPT) to expect the return in comparatively less risk. It is similar to holding
two of your favourite stocks in a portfolio.
The red point in the efficient frontier is the point of highest Sharpe Ratio. The weights for this point is
We invested $10,000 on 2021-10-01 and ran the algorithm to find the returns and percentage
returns.
Returns: $456.9
Percentage Return: 4.56% in
almost 4 months.
Introduction:
The Capital Asset pricing model (CAPM) was developed by Shape (1964), linter (1965), and Mossin
(1966). This model aims to answer the question of how we can price one security taking into consideration
the risk and return that this security poses. A vast amount of research has been conducted to test the validity
of the CAPM in explaining the variation in the return. However, these studies provide no evidence to support
this model. Motivated by the weakness and limitations of the CAPM, Eugene Fama & Kenneth French (1992),
used a sample of nonfinancial firms drawn from 3 major US financial markets over the period of 1963 to
1990, Fama and french tested the ability of the market beta coefficient, size, leverage book to market equity
ratio, to predict the cross-section rate of return, they found no relationship between the market beta factor
and stock return. Inspired by the results Fama and French(1993) developed what become Fama and french
3-factor model.
Volatility is a proxy for risk: It is one of the widely accepted measures of risk. Volatility means fluctuations
because the asset whose value fluctuates dramatically is perceived to have more risk because asset value at
the time of selling is less predictable.
Diversification: One of the ways to reduce the risk is through diversification.it means holding multiple assets
to reduce the volatility, without lowering the expected return, by spreading the same amount of money
across multiple assets. The idea behind this technique is that a portfolio is constructed of different kinds of
assets, on average, yield higher long-term returns and lower the risk of any individual holdings or security.
As we can now tell there can be two types of risk i.e risk that can get Diversified and risk which cannot. Now
an investor cannot expect a return on a diversified risk. So one can only expect a return on undiversified risks.
Systematic Risk: Systematic risk refers to the risk inherent to the entire market or market segment. It is also
known as undiversifiable risk, volatility, or market risk that affects the entire market, not just one particular
stock. And the measure of systematic risk is called Beta. Beta is measured by a measure with which return
varies relative to the overall market
The beta of the investment measures the amount of risk the investment adds to the portfolio which
resembles the market
if the beta is greater than 1 then the risk is greater than market
If beta is less than 1 then the stock is less risker than market
CAPM: As the name suggests it is a model used for pricing assets.it attempts to provide a relationship
between market return and a beta of an asset and its corresponding return/expected return.
CAPM made a number of simplifying assumptions about this the most important to note is the behavior of
investors and the presence of a single risk factor.
The plot we get after adding other factors in the CAPM model is shown below as we can see it's almost
horizontal which results in an incorrect calculation of the expected return as we calculated from the CAPM
model.
So to represent these two new risks new factors were constructed that are
● SMB (small minus big) to address size
● HML (high minus low) to address value
So after adding this two new factors we get our new expected return model is:
E(ra) = rf + βa*(E(rm)-rf) + sa*SMB + ha*HML
Coefficients for SMB and HML are sa and ha respectively and two new factors are SML and HML and the rest
is the same as in the CAPM model. Now let's understand what is SMB and HML.
SMB (small minus big): The SMB is the excess return that smaller market capitalization returns versus larger
companies. If a portfolio has more small-cap companies in it then it should outperform the market over the
longer run.
HML(high minus low): The HML is provided to the investors for investing in companies with high book-to-
market value(means value placed on the company by accountants as a ratio relative to the value of public
markets placed on the company, commonly expressed as B/M). Specifically, value stocks(high B/M)
outperform growth stocks (low B/M).
To tell the truth, there is no proper explanation for the effect of HML and SMB. and there is lots of argument
over the correct explanation for it but one of the easiest explanations for the SMB and HML is:
Reason for the size risk: for SMB which is a measure of size risk, small companies logically should be
more sensitive to many risk factors as a result of their undiversified nature and reduced ability to absorb
negative financial events. So when investors invest in these small companies taking the risk they expect an
excess return
Reason for value risk: On the other hand, the HML factor suggests higher risk exposure for typical “value”
stocks (high B/M) versus “growth” stocks (low B/M). This makes sense intuitively because companies need
to reach a minimum size in order to execute an Initial Public Offering. If we later observe them in the bucket
of high B/M, this is usually an indication that their public market value has plummeted because of hard times
or doubt regarding future earnings. Since these companies have experienced some sort of difficulty, it seems
plausible that they would be exposed to greater risk of bankruptcy or other financial troubles than their more
highly valued counterparts.
Now the question comes of how to calculate SMB and HML so in order to calculate?.
So SMB and HML are made up of 6 portfolios formed by size and book to market ratio. So as per the method
used by Fama and French in 1993.
In June of each year all stocks on the study samples are ranked based on the firm size(we take an average
daily closing price till June of each year of each stock in the sample) and are assigned into two portfolios of
size(small (S) and big(B)) based on split point which is 50% that means highest 50% are big and rest are small.
Then stocks are divided into 3 more portfolios of value, neutral, and growth book to market ratio on the basis
of the percentile system which you can see in the figure below.
Let's take an example to suppose we have to split the above-given form and we have data of stocks from
each June of 2000 to 2010 then the spit will look something like this.
So now to calculate SMB and HML we use the formula
SMB = 1/3 (Small Value + Small Neutral + Small Growth) - 1/3 (Big Value + Big Neutral + Big Growth)
HML = 1/2 (Small Value + Big Value) - 1/2 (Small Growth + Big Growth).
Implementation:
● Other than just asset pricing 3-factor model also used in categorizing funds is that investors can
effectively choose the amount to which they are exposed to the risk factor when investing in a
particular fund.
We can say from the above distribution that there is most risk in fund A and least in fund D.
● In practice, the above characterization is executed through multivariate regression. The historical
returns of a particular portfolio are regressed against the historical values of the three factors,
generating estimates of the coefficients which we will see in the code part for some of the funds.
After Fama and French, there was further research done and two new models that were the extension of
Fama and french were introduced. Let's look what were those models
4 Factor model:
Mark Carhart added the Fourth factor, Momentum(UMD)(Which is a tendency for an asset to continue on a
given path, rising or falling) into the 3-factor model. The model is also known as Carhart 4 factor model. The
addition of this factor boosted the explanatory power of the model to 95% vs the 90% of the 3-factor model
on the same data used for the 3-factor model.
The Momentum Factor(UMD) can be calculated by subtracting the equal-weighted average of the lowest-
performing firms from the equal-weighted average of the highest performing firms, that lagged one month.
A stock would be considered to show momentum if its prior 12-month average of returns is positive, or
greater.
So after adding the momentum factor to the 3-factor model our overall model becomes:
Everything is the same as that of the 3-factor model except for the addition of the Momentum factor. ma is
the coefficient of momentum factor.
Five-Factor model:
The Fama-French five-factor model which added two factors, profitability and investment, came about after
evidence showed that the three-factor model was an inadequate model for expected returns because its
three factors overlook a lot of the variation in average returns related to Profitability(RMW) and
Investment(CMA).
The theoretical starting point for the Fama-French five-factor model is the dividend discount model as the
model states that the value of a stock today is dependent upon future dividends. Fama and French use the
dividend discount model to get two new factors from it, investment and profitability. the Five-Factor Model
also explains roughly 95% of portfolio returns.
Profitability(RMW) factor can be calculated by The return of stocks with high operating profitability minus
the return of stocks with low or negative operating profitability. And for Investment factor(CMA) can be
calculated by The return of the stocks of companies that require little on-going capital investment to maintain
and grow their businesses minus the return of the stocks of companies that require large on-going capital
investment.
So after adding these two factor to out 3 factor model our overall model becomes:
E(ra) = rf + βa*(E(rm)-rf) + sa*SMB + ha*HML+ra*RMW+ca*CMA
Besides addition of new two factors profitability and investment rest of the model is same as of 3 factor
model. ra and ca are coefficients of porfitibiliy and investments respectively.
Conclusion:
In conclusion we can say that 3 factor is nothing but extension of CAPM which has better explanatory power
of portfolio as it cover additional factors by explaining how small cap and value stocks outperforms market.
3 factor model can be used for pricing assets and also mainly used for portfolio management.
Why black Litterman:
One of the major drawbacks of a very famous market in a Portfolio initialisation model CAPM is that
it does not incorporate the views of an investor i.e if he or she has a hunch about a particular asset and wants
to to invest in that asset. Black Litterman model It was made to overcome this weakness by incorporating
the views of an investor in the portfolio.
The Formula:
is a scalar
Let's not get scared by looking at the formula and let's look at each term one by one :
The first half of the formula is just a normalisation term so that the new combined
return vector has weights with sum up to 1. Also note that is a very mysterious parameter and there are
several research papers based on this parameter itself. Roughly speaking it gives a user defined vote of
confidence in our views rather than the variance based vote of confidence as we will see later. We will be
using a value of 0.05 which is a commonly used value.
In this article I will be taking an example of 7 countries to illustrate the model as given in the official paper[2].
As we all are familiar with the CAPM equation which gives us the expected rate of return of the market
portfolio.
The CAPM model gives us weights according to the market capitalization of each asset.
These are the equilibrium portfolio weights according to the market capitalization of the seven countries.
# Correlation Matrix
# AUL, CAN, FRA, GER, JAP, UKG, USA
correlation = np.array([
[1, 0.488, 0.478, 0.515, 0.439, 0.512, 0.491],
[0.488, 1, 0.664, 0.655, 0.310, 0.608, 0.779],
[0.478, 0.664, 1, 0.861, 0.355, 0.783, 0.668],
[0.515, 0.655, 0.861, 1, 0.354, 0.777, 0.653],
[0.439, 0.310, 0.355, 0.354, 1, 0.405, 0.306],
[0.512, 0.608, 0.783, 0.777, 0.405, 1, 0.652],
[0.491, 0.779, 0.668, 0.653, 0.306, 0.652, 1]])
# Variance Covariance Matrix (which can be calculated with the correlation and volatility above)
Sigma = correlation * np.dot(std.T, std)
Reverse Optimization:
Another term that is usually coined with black litterman model is Reverse Optimisation.
In Reverse Optimisation we focus on optimising the returns and then calculating the weights of each asset in
the portfolio by applying some other model rather than the classical procedure in which we optimise our
model so as to give the most efficient weights for each asset.
The First Half:
Now we are in a position to understand the the first part of the second term in the formula
Point to be noted here is that is a covariance matrix so is a vote of confidence. Now is just a
scalar so the complete terms represent how much confident I am in my portfolio returns if I allot the weights
to each asset according to its market capitalisation.
Now the views are represented in a view vector which just stores the values of excess returns that are
expected by the investor
Q = np.array([[0.05],[0.03]])
Now since we have defined our view vector we need a way to say which views are related to which assets,
so here comes another matrix known as Pick Matrix .
Here each row is for a view therefore k is the number of views and the number of rows in the pick matrix.
# AUL, CAN, FRA, GER, JAP, UKG, USA
P = np.array([
[0,0,-0.295,1,0,-0.705,0],
[0,1,0,0,0,0,-1]])
In the second row we see that CAN (index 1) overtakes USA (index 6) so +1 at P[1][1] and -1 at P[1][6].
In the first row we see that GER (index 3) overtakes FRA (index 2) and UKG (index 5) combined so +1 at P[0][3]
and the -1 is distributed according to the market caps of FRA and UKG thus -0.295 at P[0][2] and -0.705 at
P[0][5].
Now we have our views and a way to interlink them with our assets, but our views are not absolute so we
need a vote of confidence for them and thus here comes another term which represents the covariance
matrix in our views.
Here all the non diagonal elements are zero and the diagonal elements represent the variance in the errors
in each view as each view can be seen as Q + E where E is the error which is sampled from a Normal
Distribution with 0 mean and variance.
Calculating is one of the most difficult tasks of the Black Litterman model so we will skip it and directly
go to the result.
# AUL, CAN, FRA, GER, JAP, UKG, USA
Q = np.array([[0.05],[0.03]])
P = np.array([
[0,0,-0.295,1,0,-0.705,0],
[0,1,0,0,0,0,-1]])
Omega = np.array([
[0.001065383332,0],
[0,0.0008517381]])
Now we are in a position to understand the second part of the second term in the formula.
Point to be noted here is that is a covariance matrix so is a vote of confidence. The complete
terms represent how much confident I am in my portfolio returns if I allot the weights to each asset according
to the views.
Ready to launch:
The following two flow charts are self explanatory and very crucial for the understanding of the Black
Litterman Model.
Source : [1]
Source : [3]
Now we have all the terms we need to calculate the returns of our model and let us plug them in and plot
the graph.
df = pd.DataFrame([w.reshape(7),w_posterior.reshape(7)],
columns=['AUL','CAN','FRA','GER','JAP','UKG','USA'],
index=['Equilibrium Weights','Constrained Optimal Weights'])
df.T.plot(kind='bar', color='br')
Results:
The blue weights are the ones which were assigned before our views and thus after saying that GER will have
an excess return over FRA and UKG we can see the weights of FRA and UKG decreasing and weight of GER
increasing. The same goes for CAN and USA.
‘
Introduction to Pairs Trading
At its very core Pairs Trading is a statistical arbitrage strategy which is based on statistical concepts like
mean reversion principle and stationary stochastic process.
● Statistical Arbitrage Strategies: These are investment strategies that seek to profit from the narrowing
of price gap between two or more securities ● Mean Reversion Principle: It is a financial theory that
states that an asset’s price tends to converge to converge to it’s long term mean over a period of time
● Stochastic Process: Stochastic Process is basically a random process which is a collection of random
variables that are indexed by some mathematical set ● Stationary Stochastic Process: These are
stochastic processes whose statistical properties do not change with time
What exactly is Pairs Trading and what does it involve?
Pairs Trading is basically a trading strategy that involves matching a long position with a short position in
two securities which have very high correlation
So now that we understand what the overview of the process in Pairs Trading is we now try to dive deeper
into what are the broad processes that would be involved in it. So broadly there are two major processes
that we follow, one of which is very intuitive to understand from the above passage explaining what Pairs
Trading is exactly and one process which is not so intuitive but would be explained comprehensively in the
further parts of this article.
Processes Involved:
● Identifying Securities which have very high positive correlation
● Using Statistical and Technical analysis to seek out potential market neutral profits
● Mitigates potential losses and risks: In the best case scenario when the trade occurs as per expectation
and both the securities converge to their original correlation after a short period of divergence, the
trader is able to generate profits and potential losses are mitigated. But even in scenarios when the
trade is not going ideally and one of the securities is underperforming then there is a very high
likelihood that the other security will absorb the losses from the underperformance of the other
security. Thus we see that Pairs Trading also provides a very robust mechanism for mitigating risks
● Market Neutral Strategy: Since Pairs Trading as a strategy only requires a divergence to open up
between two highly correlated stocks therefore it is a market neutral strategy, that is, it is
independent of the behavior of the market as a divergence could open up even when the market is
in a bull run, bear run or going sideways. Simply put a pairs trader can make a profit regardless of
the condition of the market
● Inherent Hedging Mechanism: As in a Pairs Trade the trader is selling an overvalued security and
buying an undervalued security therefore he is limiting his chances of losses considerably.
Therefore Pairs Trade provides an inherent hedging mechanism which is not an advantage that is
found normally in most trades
Important factors Affecting Pairs Trading
There are three important factors which impact the mechanism of Pairs Trading:
● Parameter Estimation: This involves estimating the parameters such as threshold value and band gaps
up to which we allow for divergence among the highly correlated securities and when these securities
diverges beyond this gap we execute the trade
● Statistical Modeling: As Pairs Trading is a statistical arbitrage strategy then it is very intuitive to
understand that for implementing this strategy and to execute any trade with this strategy we would
need to create a statistical model which would evaluate things like the stationarity of the spread and
once that is evaluated would help model a threshold line for the statistical correlation
● Market Events: This factor, although an extremely important factor affecting Pairs Trading, is a very
rare occurrence as a result of which it is mostly discounted in most pairs trades that are executed on
a day to day basis. But as this is an extremely factor it deserves a complete discussion in itself and
hence would be taken up at the end of the article
But before we go into tackling the problem here are some pointers for stock selection for Pairs
Trading:
So now that we know the parameters to be kept in mind while selecting stock for Pairs Trading, let
us get back to tackling the issue of stationarity. To identify pairs of securities we have to create a
portfolio of two price series such that the linear combination of these is stationary. If the linear
combination is stationary then the individual price is said to be cointegrated with each other.
If there be two stocks A and B then we first create a spread where, Spread=log(a)-
m*log(b)
Where
a=Price of stock A
b=Price of stock B
m=The number of stocks of B we have to buy per share of A (regression coefficient)
The initial step is to run a regression model to identify the value of m which would give a stationary
value for spread.
For us to have a better understanding of the concept of Pairs Trading we will be doing a case study
of HDFC and HDFC bank pair (The two stocks selected cover all the parameters that have been listed
for stock selection as a pair)
Cointegration is verified by determining the stationarity of the spread, in the scenario that the spread
is stationary, both the securities are said to be cointegrated and vice versa.
The mechanism that we employ for checking stationarity of the spread equation is as follows:
● We first plot a two way line graph which is a time series plot to have a preliminary visual
test for stationarity
● In the scenario that the line plot is satisfactory we move on to mathematical tests for
checking the stationarity of the spread
● We can either make use of the Augmented Dickey Fuller (ADF) test or the Johanssen test
to check for stationarity (In this article we will be using the ADF test for checking for
stationarity)
The above stats are the result of the ADF test on the adjusted closing price of HDFC Limited over a
period of around 4 years. closing price of HDFC limited over a period of 5 years. The highly negative
stats at different critical values and a p value which is much greater than 0.05 signifies that a unit
root exists and the time series data is non-stationary.
----------Interpolated Dickey-Fuller—------------
Test 1% Critical 5% Critical 10% Critical
Statistic Value Value Value
------------------------------------------------------------------------------
Z(t)1.495 3.430 2.860 2.570
------------------------------------------------------------------------------
MacKinnon approximate p
value for Z(t) = 0.5361
These are the ADF tests stats for HDFC Bank limited over a period of around 4 years. The p value
of more than 0.5 signifies that a unit root does exist and the time series data is non stationary.
These final stats are the results of the ADF test on the spread that was calculated after
running the regression model. From the result we can clearly see that the p value is 0 and
therefore we can easily reject the null hypothesis and say that a unit root does not exist
and the time series data of the spread is stationary.
We calculate the z-score of the spread and we set up threshold parameters ● For a 66% confidence
level we set up the threshold parameter at sigma ● For a 95% confidence level we set up the threshold
parameter at 2*sigma ● For a 99% confidence level we set up the threshold parameter at 3*sigma
If the z-score crosses the upper threshold we short asset A and long asset B and if the z-score crosses
the lower threshold we go long on asset A and we short asset B
● Challenging to identify securities with such high statistical correlation: One of the ways to overcome this
issue is by identifying multiple pairs of stocks in different sectors which would help in providing trade
opportunities in all kinds of situations
Long Term Capital Management was an extremely successful hedge fund in the 1990’s which attracted a
large number of investors. They traded mostly on the basis of statistical arbitrage strategies which primarily
included Pairs Trading strategy. During 1997-1998 when the Asian debt crisis the Russian debt crisis which
led to a divergence in a lot of historically correlated stocks which LTCM took to be a trade signal and took
highly leveraged positions in these stocks but the issue was that what LTCM had failed to identify was that
these events were Black Swan events and the divergence that had opened up was a permanent departure
from the historical equilibrium. Due to their failure in identifying these events as Black Swan events LTCM
had to face huge losses and as a result finally went bankrupt.
This real life example clearly demonstrates that market events are extremely important factors to
be considered while analysing any divergence in correlated stocks.
What if a technical breakthrough made it possible for everybody anywhere in the globe to be their bank? To
develop money that is tax- and fee-free.
What is Bitcoin?
Bitcoin is one of the most original and elegant solutions that has emerged recently. It was the first to
introduce the notion of decentralized bookkeeping, which is now known as blockchain technology, and it is
a tremendously powerful concept. So, Bitcoin is a lot of different things. It is an open-source computer
program that is free to use. Anyone can look at the code for this software and start using it. A network is
formed by the machines that run the Bitcoin application. The network follows a
set of regulations, and its main purpose is to allow users to make electronic
payments. Bitcoin
is the currency used to make these transactions.
Why Bitcoin?
Bitcoin was established to allow consumers to send and receive online payments
without having to rely on a trusted banking institution or any other type of central
intermediary. We need some kind of utility that is equally accessible to all people.
So, it believes in the democracy of Money!
If there is no central intermediary:
● No question of a corrupt central authority
● The cost needed to sustain and trust that intermediary is removed.
● More security.
Decentralized System
Conditions for a Decentralised system:
● People can make and receive payments.
● There should be no central third party at all.
● The system should be viable enough to avoid any errors and fraud.
Cryptography
Bitcoin moves the burden of trust from institutions to numbers. So, the
Bitcoin protocol makes heavy use of cryptography. Cryptography is the
study of secure communications techniques that allow only the sender and
recipients of a message to read its contents. If we are to understand Bitcoin,
we need to understand two concepts from cryptography, Hashing, and
Digital Signatures.
Hashing
A hash is a mathematical function that turns an arbitrary-length input into a fixed-length encrypted
output. In simpler words, a hash function takes some data and produces a unique shorter summary or
fingerprint of it. It takes input, divides it into equal bite-sized packets, and then repeatedly jumbles each of
those packets. Some of the Hashing algorithms are MD5, SHA-1, and SHA-256.
Some properties of any good hash algorithm are:
● One-way: You cannot restore the document from its given hash. That is, you cannot decrypt the hash
in any way.
● Deterministic: Hash value for a given document always remains the same no matter how many times
we run the algorithm.
● Fast Computation: Now this is a tricky one. The algorithm should be fast enough to churn through a
lot of data but not too fast then it will be easy to break.
● Avalanche Effect: Any slight change in data will result in a complete change of the calculated hash
which is not at all predictable.
● Withstand collisions: Even after a lot of variations in the hash, it is limited. But the amount of data
available is infinite. We can understand it using Pigeonhole Principle. It states that, If n pigeons are
placed in m containers, with n>m, then at least one container must contain more than one pigeon.
So with very little probability, two different documents may have the same hash value, which is fine!
But, a hacker can forge documents by artificially creating a collision and our algorithm should be
designed in a way that it doesn’t allow such artificial collisions.
SHA-256
SHA stands for Secure Hashing Algorithm and 256 is the number of bits it takes up in memory. And, it is 64
characters long hexadecimal hash. This hashing algorithm works for any type of digital input. Complete data
is represented in ones and zeroes using their corresponding ASCII Table and these operations are combined
to generate the compound movements of bits.
Basic operations that happen in SHA-256 are:
● Bit right-shift operation
● Rotational bitwise operation
● XOR
● Binary addition
●
A basic SHA-256 hash will look like this-
Digital Signatures
● Signing messages: Signing a message in cryptography is analogous to putting a stamp on an
envelope.
Inputs: Message, Private Key -----> Signing Function -------> Output: Signature
● Verifying messages: Verifying a signature allows you to check whether a given signature was
created by the right person.
Inputs: Message, Signature, Public Key ----> Signature Verification Function ---> Output:
True/False
Uses of Digital Signature
It is useful for ensuring secure and reliable communications - and this is exactly why digital signatures are
used extensively throughout the Internet. In fact, digital signatures are working in your browser at this very
moment. If you look at the URL bar of your browser, you will probably see a lock icon next to it. Each website
effectively has its legal public key. When your browser shows you the lock icon, it is telling you that you are
communicating with a party can that prove they own the corresponding private key.
A B
Everyone is familiar with the first one so let’s discuss the second one. Any computer running the Bitcoin
program is called a node. So instead of having one central bank server, we now have four individual Bitcoin
nodes run by Ishan, Shalini, Rahul, and Anmol.
Consensus
One of the problems with such a decentralized architecture is consensus i.e. how can we ensure that each
ledger in this system is consistent with the others? There is no point if everybody has ledgers with different
values - nobody will trust the system and it will be useless for payments.
Bitcoin Transaction
Simplified structure of a transaction in Bitcoin:
● Sender: Public key of the sender
● Recipient: Public key of the recipient
● Amount: Amount of bitcoin to be sent
● Mining Fee (Later)
● Signature: This is the result of putting the first four fields in a
signing function along with the sender’s private key.
These transactions get added to the ledgers once every ten minutes
on average. But these transactions don’t get directly added to the
ledger - they are first batched into groups of transactions called
‘blocks’.
Before putting transactions in the memory pool of each bucket, we need to verify a
few things:
➔ Is all the necessary information included here?
● This can be verified very easily by all the nodes.
If this transaction meets all of these criteria, then it is considered valid, and the nodes receiving it will put it
into a bucket called a memory pool.
In reality, not every transaction is received by every node due to maybe bad internet So, in reality, each
node’s mempool could be different from their peers.
Bitcoin Mining
Bitcoin groups transactions into ‘blocks’. Each block contains ~2000 transactions, and ledger entries are
always made one block at a time. But how do nodes decide which transactions to put in the block? We can
see that there is a mining fee associated with each transaction.
Mining Fee: The sender of a transaction has set aside some fee that he is willing to pay to the miner for his
transaction to get through onto the ledger.
But still, some questions need to be answered.
1. Who is a miner?
● Any Bitcoin node that is working to try and add transactions to the ledger is a miner.
Too many new terms! But, don’t worry we’ll cover them all :)
Candidate Block
Block Header
● The Block Height
○ Each block in Bitcoin has a different vertical 'height' based on when it was added to the ledger.
The genesis block, mined by Satoshi, has a Block Height of 0. The next block has a Block Height
of 1. The Block Height for the next one is 2, and so on. The most recent Bitcoin Block Height is
713378 at the time of writing.
● The Previous Block Hash(Later)
● Transactions Hash
○ The transaction hash is the sum of all transactions in a bitcoin block. So, when Ishan composes
his candidate block, he will take the transactions he wants to include from his mempool,
organize them in a specific order, and hash them all together so that they may be represented
in a single short hash in the block header. This has the advantage of allowing you to compare
two sets of transactions rapidly by computing their transaction hashes.
● Timestamp
○ This is the date and time at which the miner claims to have created the block.
● Difficulty(Later)
● Nonce(Have patience;)
Difficulty
Phrase(Input): Harsh is afraid the length of this topic is way too long and it will take him forever to complete
it!
Output(Hash): 31794a589c4d90224d953ee382abbc5c629ee8f4a0bb2e2217bfd8775a736225
Now,
P(First bit as 0) = 0.5
P(First 2 bits as 0) = 0.25 …..
P(First 10 bits as 0) = 0.098%
In Bitcoin, the difficulty number tells us how many leading 0s we need in the hash of the block header for
that block to successfully solve the mining puzzle. So, if difficulty is set to 10 then the chances to get a hash
with the initial 10 bits as 0 in the first attempt is as low as 0.098%.
Nonce
“Number only used once”
➔ On average, a miner would need to make about 1020 different block header hashes before stumbling
upon one which begins with 10 zeros. In Ishan’s candidate block, the nonce is 26. So that means that
if you include the number 26 with all the other fields in the block header and hash them, the output
hash has ten leading 0s.
➔ The miners change the nonce when attempting a new solution to the mining puzzle because the other
fields in the block header are either fixed (such as the block height) or time-consuming to compute
(the transaction hash).
➔ The nonce exists solely for the purpose of helping miners come up with different solutions to the
mining puzzle.
There will always be some nonce value that makes a miner’s individual candidate block achieve the right
number of 0s to solve the difficulty. This magic nonce number is what all miners are searching for!
Final Verification!
Let’s say Ishan has won the mining puzzle and Ishan’s candidate block is sent to every miner to make sure it
is valid.
● Does the block have a valid previous block hash?
● When we hash all of the transactions in the given block, does the resulting transaction hash tally up
with the transaction hash given in the block header?
● Are all the other fields in the block header correct?
● When we hash the block header, do you get a hash that satisfies the difficulty criteria?
When each miner verifies, they append Ishan’s candidate block to their local copy of the ledger and Ishan
finally wins all the rewards :)
Performing a hash is easy to do - so checking that the hash value is correct or not is extremely quick, even
though generating the right hash value for Ishan and the other miners was very unpredictable and
hard!
Problems faced
★ Why would even Shalini, Rahul, and Anmol even add Ishan’s block in their local copy of the
ledger if it doesn’t benefit them?
○ Rule: If some other miner sends you a valid candidate block, then add it to your local copy of
the ledger immediately for consistency.
★ What if Ishan and Shalini both come up with a valid block at the same time?
○ Rule: Always believe the version of the ledger which has the highest Block Height.
Remember, miners don’t know each other and they are not friends!
Proof-of-work
If we have a problem of having two different versions of the ledger called a fork in the ledger then Which
version of the ledger is correct?
● If a version of the ledger has more blocks, that means more work has gone into generating that
version of the ledger. That implies that the version of the ledger has the most public support since it
took the most effort to create. This is known as the consensus mechanism in Bitcoin also called proof-
of-work.
Non-Fungible Token
Bored Ape
NFT
Introduction
Non-fungible tokens, or NFTs, are blockchain-based cryptographic assets having unique identification codes and
information that separate them from one another. NFTs can be linked to digital assets that can be reproduced,
such as images, movies, and audio. NFTs employ a digital ledger to offer a public certificate of authenticity or
evidence of ownership, but the underlying digital data may be shared or copied freely. NFTs are distinguished
from blockchain cryptocurrencies such as Bitcoin by their lack of interchangeability (fungibility). This is in contrast
to fungible tokens, such as cryptocurrencies, which are identical to one another and may thus be used as a
medium for economic transactions.
History:
Quantum, the first known "NFT," was constructed in May 2014 by Kevin McCoy and Anil Dash, and consisted of
a video clip prepared by McCoy's wife Jennifer. During a live presentation for the Seven on Seven conferences at
the New Museum in New York City, McCoy registered the video on the Namecoin network and sold it to Dash for
$4. The technology was dubbed "monetized graphics" by McCoy and Dash. Following the development of many
NFT initiatives that year, the word "NFT" only acquired currency with the ERC-721 standard, which was initially
Metarift NFT
suggested in 2017 via the Ethereum GitHub. Curio Cards, CryptoPunks (a project to trade unique cartoon figures
created by the American company Larva Labs on the Ethereum blockchain), and the Decentraland platform are
examples of these.
The popularity of CryptoKitties, an online game in which participants adopt and exchange virtual kittens, raised
public awareness of NFTs. The initiative quickly went viral, garnering a $12.5 million investment, with some
kittens selling for more than $100,000 apiece. Decentraland, a blockchain-based virtual world that originally sold
tokens in August 2017, raised $26 million in an initial coin offering in 2018, and as of September 2018, had a $20
million internal economy. The NFT market tripled in value to $250 million in 2020, owing to strong expansion.
More than $200 million was spent on NFTs in the first three months of 2021.
Understanding NFT’s
● NFTs alter the crypto paradigm by making each token distinct and
irreplaceable, making it impossible for one non-fungible token to be identical
to another.
● They are digital representations of assets that have been compared to digital
passports since each token carries a unique, non-transferable identity that
allows it to be distinguished from other tokens.
● Owners can also add metadata(for eg. Signature) or attributes pertaining to the
asset in NFTs. NFTs are having a very unique property of extensibility which
means that two NFTs can be combined to get or breed a third(new) NFT.
First NFT to be sold by a historic
Why NFTs:
auction house
NFTs can be used to represent real-world items like artwork and real
estate. "Tokenizing" these real-world tangible assets allow them to
be bought, sold, and traded more efficiently while reducing the
probability of fraud. Non-fungible tokens are also excellent for
identity management. They can be used to represent people's
identities, property rights, and more. NFTs also provide the
opportunity for multiple sharing of physical assets like real estate or
digital art. The emergence of new markets and kinds of investing is
the most intriguing opportunity for NFTs.
Introduction
Have you ever considered it possible having a gambling technique that you can establish is always a winner,
a fair game, and yet might bankrupt you at the same time? The martingale theory and betting strategy
essentially demonstrates this.
The martingale probability theory is a mathematical representation of a fair game, in which there is equal
chance of winning or losing. It's a process in which today's events serve as the best predictor of what will
happen tomorrow. Originally, a martingale was a class of betting strategies. Despite the fact that they are
commonly recognized to lead to bankruptcy, they are still widely used.
When the Martingale Strategy is used, the transaction size is doubled every time a loss occurs. A common
situation for the technique is to try to trade a result that has a 50% chance of occurring. We also call this
strategy a zero-expectation scenario. Here we are doubling our stake each time we lose, so we say our
multiplier is 2. You can use 3 or other numbers as well as your multiplier.
Given, (1) You are doubling the stake every time you lose.
(2) You will stop playing the game if you win.
(3) You are starting the game with 1$.
Calculate the profit (or loss) that the gambler will face after n th bet.
Solution:
Case (1): You lose all first n bets, then the loss you will be gone through will be-
W = -(1+2+22+23 …... + 2n-1)
= -(2 -1) + 2
n-1 n-1
=1
So, you can see in this case, either we are going bankrupt (probability of which is very less) or we are winning
1$. You must have got an intuition that we don't intend to play the game with Martingale strategy from the
start but we use Martingale to cover our losses after loss.
Filtration
Now that you have gotten a basic idea of a martingale, the next step is to define it mathematically. To do
that, it is crucial to understand the concept of filtration.
A filtration is an increasing sequence of σ - algebras on a measurable probability space. Filtrations represent
the information about an experiment that has been revealed up to a certain time t. a σ-algebra (also σ-field)
on a set X is a collection Σ of subsets of X, is closed under complement,and is closed under countable unions
and countable interactions.
Looking at an example for a better understanding:
Consider an experiment where a coin is tossed 3 times in 3 seconds.The sample space for our experiment
will be a set of all the possible outcomes -
Ω = {HHH, HHT, HTH, HTT, THH, THT, TTH, TTT}
As the sample space is finite, we will take the σ - algebra, F (set of all the events possible), as the power set
of Ω - F = 2Ω
Martingales
You may have picked up a bit on Martingales in the introduction part. However, once we've covered filtration,
we can move on to the important aspect of Martingales, which includes the basic mathematics underlying it
and its applications.
Martingales is a stochastic process (sequence of random variables) in which the conditional expectation of
the next value in the sequence, regardless of all previous values, is equal to the current value of the sequence.
To offer a simple illustration, imagine tossing a coin in a sequence: if it comes up head, you get one dollar; if
it comes up tail, you lose one dollar. Let's say you have $5 after 100 such tosses. As a result, your expected
value after the 101st coin is $5. Isn't it straightforward? This is the core concept of Martingales; we should
grasp the basic mathematics underlying it to have delve more into it.
(1) Say, {Fn}n≥0 is an increasing sequence of σ−algebras (filtration) in a probability space (Ω, F, P). Let X0, X1, X2
…. Xn is an adapted sequence (Xn ∈ Fn) of integrable real valued random variable such that E(Xn+1) < ∞, the
sequence X0, X1, X2 …. Xn is said to be a Martingale relative to the filtration {Fn}n≥0 if
E (Xn+1 |Fn) = Xn (Martingale condition)
(2) We have, E(Xn+1|Fn) = Xn.
E(Xn+k|Fn) = E((Xn+k|Fn+k-1)|Fn) (Using Tower’s property)
= E(Xn+k-1|Fn) (Using Martingale)
.
.
.
= E(Xn+1|Fn)
= Xn
(3) The expectation of next value in sequence to be equal to current value, there are several types of
martingales sequences, the most basic one is sums of independent, mean zero random variables. Let Y1, Y2...
be such a series; then with following conditions,
E(Yi) = 0
Fn = σ (Y1, Y2, Y3…. Yn)
the partial sums sequence:
X n = Y 1 + Y 2 + Y 3… Y n
is a martingale in comparison to the natural filtering caused by the variables Y n. The linearity and stability
features, as well as the independence law for conditional expectation, make this easy to verify:
E (Xn+1 |Fn) = E (Xn +Yn+1 |Fn)
= E (Xn |Fn) + E (Yn+1 |Fn) (Linearity)
= Xn +E(Yn+1)
= Xn.
Example:
We went through a 3-coin toss example in the filtration part, now let's do the same thing in Martingales. If
we apply the random variables and probability terms to the three coin-toss examples, we get Xn, which is the
total amount won/lost in n bets. The profit/loss on the nth bet is represented by Yn. Fn is a collection of values
that may be obtained via the use of n bets. So, if we have been given a F n that has led us to an Xn value, we
may claim that our value X will not change after one more bet since the Yn+1 expectation will be zero owing
to fair toss.
Now, once we have done the basic mathematics of the martingales we can move towards the applications
of Martingales in stock market.
Implementation of Martingles
Let us see what we have,
Initially the investor will buy one stock. The primary premise behind using Martingales to generate an idea
for this stock is that if the current day's stock price is less than 1.5% lower than the previous day's, the investor
should double his investment at the end of the day. Investment will rise, and investors might be able to profit
from the market even if there are fewer victories.
Dataset:
Apple data containing for date and price (closing) for the time interval 6/3/2019 to 31/12/2019
Simple Martingale strategy:
Signal is a indication of action to the investor if he has buy, hold. If current day’s price is 1.5% greater than
previous day’s close then +1, if current day’s price is 1.5% less than previous day’s close then -1, Otherwise
0.
Returns are returns on the given date and returns_in_per are returns on the given date in percentage
cumulative returns is net returns from the starting date to till date, cumulative returns in percentage is total
returns from starting date to till date in percentage.
As you can see, the cumulative returns in percentage for the period of 6 months is 9.57 for total invested
money 312360.7804$.
Code and dataset:
Dataset: File
Code: Code
Final results: Final file
A Hidden Markov Model (HMM) is a statistical model which is also used in machine learning. It can be used
to describe the evolution of observable events that depend on internal factors, which are not directly
observable.
A simple example of an HMM is predicting the weather (hidden variable) based on the type of clothes that
someone wears (observed).
By forecasting weather precisely we can prevent and overcome many hazards that could lead to a great
loss to a nation. HMM is used to predict weather using the Markov Chain property. The training of the
model and probability of occurrence of an event is calculated by observing weather data for the last 21
years. The data is firstly categorized based on standard values set apart. The result obtained shows that
our model is reliable and works very well in predicting the weather for the next 5 days based on today's
weather pattern.
The Markov process assumption is simply that the “future is independent of the past given the present”. In
other words, assuming we know our present state, we do not need any other historical information to predict
the future state.
1. Transition data — the probability of transitioning to a new state conditioned on a present state.
2. Emission data — the probability of transitioning to an observed state conditioned on a hidden state.
3. Initial state information — the initial probability of transitioning to a hidden state. This can also be
looked at as the prior probability.
● Unsupervised: When we want to discover a pattern or model a distribution but don’t have any labeled
data.
● Supervised: When we do have labels and want to be able to accurately predict the labels.
● HMMs are used for modelling sequences:
○ x(1), x(2), x(3), x(4).……x(t),....,x(T).
○ No labels are available.
Hidden Markov models are known for their applications to thermodynamics, statistical mechanics, physics,
chemistry, economics, finance, signal processing, information theory, pattern recognition - such as speech,
handwriting, gesture recognition, part-of-speech tagging, musical score following, partial discharges
Applications, where the HMM can be used, have sequential data like time series data, audio, and video data,
and text data or NLP data.
● It is used for Classification using Bayes’ rule and creating a separating model for each class, and
choosing the class that gives us the maximum posterior probability.
Markov Property:
● In general: ‘states’
● State at time t: s(t)
● p(s(t) | s(t-1), s(t-2),...........,s(0)) = p(s(t) | s(t-1))
We want to model the joint probability i.e. probability of a sequence of states, which becomes (using chain
rule of probability):
p(s4, s3, s2, s1) = p(s4 | s3, s2, s1) * p(s3, s2, s1)
= p(s4 | s3, s2, s1) * p(s3 | s2, s1) * p(s2, s1)
= p(s4 | s3, s2, s1) * p(s3 | s2, s1) * p(s2 | s1) * p(s1)
= p(s4 | s3) * p(s3 | s2) * p(s2 | s1) * p(s1)
(assuming Markov property)
Markov Models are often used to model the probabilities of different states and the rates of transition among
them.
Weather Example:
3 states: SUN, RAIN, CLOUD
● Here, each node is a state and each edge is the probability of going from one state to the next state.
● This is 1st order Markov Model because weights depend only on the current state and it only affects
the next state.
How many weights do we need to calculate?
EXAMPLE:
p(sun, sun, rain, cloud) = p(cloud | rain) * p(rain | sun) * p(sun | sun) * p(sun)
= 0.2 * 0.05 * 0.8 * p(sun)
In general:
p(s(0),.......,s(T)) = ℿ(s(0))
How is a Markov Model trained?
1) I like dogs
2) I like cats
3) I love kangaroos
If we use maximum likelihood, then our initial state distribution is just one hundred percent probability.
ℿ = [1, 0, 0, 0, 0, 0]
p(like | I) = ⅔
p(love | I) = ⅓
p(dogs | like ) = p(cats | like ) = ½
p(kangaroos | love ) = 1
Markov Chain:
A Markov chain is a mathematical system that experiences transitions from one state to another according
to certain probabilistic rules. The defining characteristic of a Markov chain is that no matter how the process
arrived at its present state, the possible future states are fixed.
Markov Chain: Example
= P(sun(1)|sun(0)) ℿ (sun)
+
P(sun(1)|rain(0)) ℿ (rain)
+
P(sun(1)|cloud(0)) ℿ (cloud)
In General:
P(s(1)) = ℿ A
P(s(2)) = ℿ A A = ℿ A2
P(s(t)) = ℿ At
Stationary Distribution
● Eigenvalues are not unique -> make it sum to 1 so it’s a proper distribution.
Limiting Distribution:
It is the state distribution that you settle into after a very long time.
But A∞ A = A∞
So, ℿ∞ = ℿ∞ A
● If I take an Equilibrium distribution multiplied by A and get the same distribution, then it’s a stationary
distribution
● So, All the Equilibrium distributions are stationary distributions, but vice-versa is not true.
Suppose you are at a carnival, magician has 2 coins hidden behind his back.
He will choose one coin to flip at random, you can only see the result of the coin flip ( H/T)
H/T - space of observed values
Hidden State - Which coin it is.
(This is a stochastic/random process)
HMMs are probabilistic models. They allow us to compute the joint probability of a set of hidden states given
a set of observed states. The hidden states are also referred to as latent states. Once we know the joint
probability of a sequence of hidden states, we determine the best possible sequence i.e. the sequence with
the highest probability, and choose that sequence as the best sequence of hidden states.
HMM:
It has 3 parts: 𝚷, A, B
ℿi : the probability of starting at state i
A(i, j) = probability of going to state j from state i.
B(j, k) = probability of observing symbol k in state j.
The hidden Markov model has been widely used in the financial mathematics area to predict economic
regimes or predict stock prices.
Choosing a number of hidden states for the HMM is a critical task. We use four
common criteria: the AIC, the BIC, the HQC, and the CAIC to evaluate the performances of HMM with
different numbers of states. These criteria are suitable for HMM because, in the model training algorithm,
the Baum–Welch Algorithm, the EM method was used to maximize the log-likelihood of the model. We limit
the number of states from two to six to keep the model simple and feasible for stock prediction.
AIC = -2 ln(L) + 2k
BIC = -2 ln(L) + k ln(M)
HQC = -2 ln(L) + k ln(ln(M))
CAIC = -2 ln(L) + k(ln(M) + 1)
where L is the likelihood function for the model, M is the number of observation points, and k is the number
of estimated parameters in the model.We assume that the distribution corresponding with each hidden state
is a Gaussian distribution, therefore, the number of parameters, k, is formulated as k = N2 + 2N - 1, where N
is numbers of states used in the HMM.
Independence Assumptions:
“Kalman Filter is an iterative mathematical process that uses a set of equations and consecutive data inputs
to quickly estimate the true value of the measurement.”
There are several important keywords in this definition. Let’s talk about them.
● Iterative: It is important to remember that Kalman filter is an iterative process in its core. The output
that we get in a certain iteration is used as input in the next. You may encounter vectorized
implementation of Kalman Filter out there in the wild which, in a way, bypasses iteration but the core
concepts remain the same.
● True value and measurement: When talking about Kalman Filters, we consider the measured and
true value of an event as two very different quantities. We shall understand this in greater detail in
the following example.
●
I did not see that coming
Let’s say we are interested in the movement of a certain stock. We analyze its past prices and its trends.
From the graph, it is pretty evident that the stock is on a bullish trend. Suppose we are optimistic about
the market and predict that the stock will continue its upward ascent. This seems to be a reasonable
assumption to make. However, something happens which we did not anticipate.
Some external factor influences the market and the trend immediately reverses.
Under these circumstances, we find that a person with optimistic views on the market will have to suffer
heavy losses. Moreover, the model which the person employs for predicting the future of the series may not
give correct predictions until the downward trend is firmly established. During this period, the trader will
suffer great losses. Our target is to minimize such losses due to unforeseeable circumstances.
Note that we are dealing with several quantities related to the price series. Firstly there is the predicted
value. This is the value that we expected to attain before actually measuring the quantity. This is based on
some prediction model that we have employed. This model can never be 100% accurate and therefore there
is bound to be some error in our predicted value. Then there is the measured value which is the actual value
that the series takes. In some other contexts where our measurement is based on experimental observations,
there may be some errors in the measurement as well. In our current example, we can see that the measured
value at any instance can be a possible outlier or may represent a short-term trend. Thus it may give wrong
inferences about the long-term behaviour of the series. We can therefore say that there can be possible
errors in measured value as well. Lastly we have our estimated value. Since we have errors in our predicted
as well as measured value, we want to estimate the true underlying behaviour based on these values and
their errors. This is our estimated value.
Self-correcting models
We essentially want a model that self-corrects itself when unforeseeable events occur. There are various
models which accomplish this. The simplest among them is the Simple Moving Average (SMA). We simply
take the average over a certain time period and expect the price to lie close to this average. This way, when
the stock price falls down, the average also falls down and our predicted value also goes down. A similar thing
happens when there is a sudden jump in stock prices. In this way SMA self-corrects the predicted value based
on the stock prices.
So why can’t we use SMA everywhere? Well, there are certain shortcomings of using SMA. The most
prominent among them being slow reaction time. If there is a sudden reversal in trend, it takes a while for
SMA to react to this change (until the trend reversal has been established). This is because SMA gives equal
weightage to all data. As a result, older data dominates the newer data (which suggest a trend reversal) for
a while.
So how do we overcome this? Well, one solution is to use Exponential Moving Average (EMA). In EMA, we
give greater weight to the latest data and lesser weight to older data. This allows it to react quickly to sharp
changes. However, there are still problems with using an EMA (or any moving average in general). Note that
moving averages work over a certain time period. This time period is often arbitrary and is chosen by the
trader as a hyperparameter. Thus by using a moving average, we are essentially introducing another
hyperparameter to our strategy. This hyperparameter involves additional effort on the trader’s end for tuning
and has associated risks of overfitting.
What if we had a self-correcting model which reacts quickly to sharp changes and does not involve an
additional hyperparameter?
As mentioned earlier, Kalman filter is an iterative process. In each iteration there are three major steps.
The Kalman Gain is the heart of the Kalman Filter. It decides how much weight must be given to the
estimated and measured values in our current estimate. Mathematically, it can be computed using
the following relation
where,
KG = Kalman Gain
EEst = Error in Estimation
EMea = Error in Measurement
2. Calculating current estimate
Once we have our Kalman Gain, we can calculate the current estimate. This can be calculated using
the following formula:
where,
From these two equations we can get an intuitive idea about how the Kalman Filter works. Let’s say
in a certain reading, the error in prediction is very high. Compared to this, the error in measurement
is very low. Under these circumstances, we can clearly see that the Kalman Gain approaches 1. When
this happens, the current estimation gets very close to the Measured value. In other words, when the
error in prediction is very high, the Kalman Filter gives very little weight to the predicted value and
very large weight to the measured value. Similarly, when the error is Prediction is very less as
compared to the error in measurement, the Kalman Gain approaches 0. Consequently, the estimation
gets very close to the predicted value.
Finally we can calculate the error in our current estimate using the following formula:
All these operations have been summed up graphically in this flowchart.
Assumptions
1. Gaussian distributions
2. Linear Functions
Applications in finance
We can now say that the Kalman filter helps us find dynamic (self-correcting) parameters and can be used as
a replacement for moving averages. We can use it in various stock market indicators which use moving
averages (eg. Bollinger Bands). We can also use it to calculate quantities which may not remain static over
time for example hedge ratio in Pairs Trading.
Code Sample
import numpy as np
import matplotlib.pyplot as plt
np.random.seed(10)
# Kalman Gain.
K = E_est / (E_est + E_mea)
# Estimation.
x_est = x_est + K * (z_meas - x_est)
# Error.
E_est = E_est - K * E_est
# Input parameters.
time_end = 10
dt = 0.2
t = 4
R = 4
# Initialization for estimation.
x_0 = -10
E_0 = 6
time = np.arange(0, time_end, dt)
n_samples = len(time)
meas_save = np.zeros(n_samples)
esti_save = np.zeros(n_samples)
err = []
for i in range(10):
err.append(n_samples)
x_esti, E = None, None
for i in range(n_samples):
z_meas = np.random.normal(0, 2)
err.append(z_meas)
E_mea = np.std(err)
if i == 0:
x_esti, E = x_0, E_0
else:
meas_save[i] = z_meas
x_esti, E = kalman_filter(z_meas, x_esti, E, E_mea)
esti_save[i] = x_esti
plt.rcParams["figure.figsize"] = (20,10)
plt.plot(time, meas_save, 'g*--', label='Measurements')
plt.plot(time, esti_save, 'bo-', label='Kalman Filter')
plt.legend(loc='lower left')
plt.title('Measurements v.s. Estimation (Kalman Filter)')
plt.xlabel('Time [sec]')
plt.ylabel('Value [V]')
What is Reinforcement Learning?
Reinforcement learning is an area of machine learning concerned with how intelligent agents
The above definition brings a handful of terms to the table at once. Let us understand them and how they form
the bigger picture in detail.
The two main entities involved are the environment and agent. The agent performs an action ‘a’ on the
environment which results in a change in its state. The environment returns this state to the agent in addition to
another entity called the reward. This reward acts like a feedback loop that tells the agent whether the action it
took is simply put, a good one.
Chessbots as an example
To understand the underlying principle of reinforcement learning let us go through one of the applications of
reinforcement learning in the real world: a chess bot.
You must have heard about different powerful Chessbots out there like Leela, Stockfish, and AlphaGo. They have
famously even defeated the best human players in the world. So how do they do it? Let’s understand it roughly.
These bots are fueled via reinforcement learning. The environment here is
the Chessboard, this is where all the action takes place. The agent i.e., the
chess bot can perform an action on the environment through a chess
move. This action then returns its new state, the new board position to
the agent. Along with the new state, it returns a reward that gives the
agent an idea of how good its action was or how favourable the current
state of the board is for the chess bot. This reward can be just a real
number that scores the position, or a flag for checkmate or queen capture.
After the opponent plays its move, the agent observes the new state and
plans its next action.
POLICY: Policy 𝜋 is a function that yields an action ‘a’ given the current state ‘s’ as input:
𝜋(𝑠) = 𝑎
A policy can also be thought of as a stochastic function, which emits the probability of taking
an action ‘a’ given an action ‘s’.
𝜋(𝑠, 𝑎) = ℙ(𝑎𝑐𝑡𝑖𝑜𝑛 = 𝑎 |𝑠𝑡𝑎𝑡𝑒 = 𝑠)
VALUE FUNCTION: This function helps to calculate the ‘value’ of a state ‘s’. This is synonymous with
quantifying how much the current state is favourable to the user. It is calculated as follows:
In the above expression, 𝛾 is called the discount rate, a number between 0 and 1 whereas 𝑟𝑡 is the
reward at a time instant ‘t’. Thus, this expression is the expected value of the cumulative value of future
rewards given the current state is 𝑠0. Due to the discount rate being raised to the power of ‘t’, the value
function tends to favour immediate rewards, and this behaviour can be controlled externally by varying
the discount reward.
Q – LEARNING
The value function simply gives the expected reward for a current state. Now, we introduce an entity
called the Q-value which takes into account a state and an action and gives us the value of the maximum
reward that can be achieved if the action ‘a’ is performed at a state ‘s’.
The last equation we reached, is the famous Bellman’s equation which is used extensively in reinforcement
learning systems
Now, if this information is fed into a trading bot, on Day 1, it sees that it earns more on selling the stock
than on holding the stock, so without further ado, the stock is sold on the first day. Hence, it is deprived
of the maximum profit on Day 5 i.e., Rs. 50. In some way, holding the stock on the first day should have
more value than selling it. Let’s see if Q-learning can solve this issue.
Through Bellman’s equation, we will attempt to update the ‘value’ of holding the stock on the days so
that the trading bot can complete the transaction in the most profitable manner.
Assume discount rate 𝛾 = 0.9. Beginning from Day 4, the Q value for holding the stock on that day can
be calculated as follows:
Original reward + 0.9 × Maximum reward of the successor state = 0 + 0.9×50 = 45 Going backward with
a similar calculation we can evaluate the value for holding the stock for all the other days.
Now, we can clearly see holding the stock on Day 1 is more valuable than selling it, and likewise for the
following days so that it can enjoy
We use a deep neural network to estimate the Q-values for a given state-action pair. The input to this
layer is a state that is not restricted only to the stock price, it can have other components too which
might include indicators such as RSI, moving averages, market sentiment scores, portfolio value,
remaining funds, etc.
Now we will discuss in detail how does experience replay work towards optimizing this model. We have
at our disposal historical data of the prices of a particular stock.
● First, the weights of the deep neural network are initialized randomly.
● The first state 𝑠 is passed into the network, and the Q values for the three actions
(buy, sell & hold) are calculated. The action 𝑎 with the highest Q-value is chosen, and
a new state 𝑠′ is achieved. The reward (~profit) is also calculated corresponding to this
action.
● This whole transaction can be identified through four entities (𝑠, 𝑎, 𝑠′, 𝑟). This tuple is
known as an ‘experience’ and is stored in a memory called the replay memory.
The replay memory has a memory limit beyond which it begins deleting old experiences.
● A random experience is picked up from the replay memory say 𝑒 = (𝑠, 𝑎, 𝑠′, 𝑟).
● The state 𝑠 is then again passed through the neural network, and now the Q value is
obtained corresponding to the action a.
● The expected Q value for this state-action pair (s, a) is however different. The
expected Q-value is calculated by using Bellman’s equation.
●
To calculate the second part of RHS, max [𝑄(𝑠′, 𝑎) needs to be calculated. This is found
by passing the state 𝑠′ again through the network and retrieving the maximum Q value
for all possible actions a.
● Finally, the loss for the neural network is calculated as LOSS = (Q* - Q)
● This loss is then used to update the weights of the neural network.
maximum profit on Day 5. With a sufficient number of iterations and data points, we
eventually can create a model which can almost accurately estimate Q values for any state-
action pair.
The above work by Suhail et. al. implements Deep Q-learning and experience replay to create a trading
bot that performs really well on real-world data. The input state vector in this implementation contains
5 quantities: Open, 5-day SMA, Stocks held, Cash held, and sentiment score. The market sentiment
score is calculated by processing relevant market news through a robust NLTK library called VADER
(Valence Aware Dictionary and Sentiment Reasoner).
ACTOR-CRITIC NETWORKS
This is a slightly different kind of reinforcement learning model, which estimated the Value function for
the successor state. It implements two networks: the actor and the critic network. The actor-network
decides which action to take, whereas the critic network on the other hand estimates the value function
for the successor state thereby ‘criticizing’ or keeping the actor-network in check.
The ’advantage’ value is calculated as follows:
The above expression can be expressed in terms of Q-value as 𝑄(𝑠𝑡, 𝑎𝑡) − 𝑉(𝑠𝑡+1)
The losses for the above two networks are calculated as follows:
Such actor-critic networks can be easily implemented through a dataset using the famous open-source
library Gym. This implements many other useful models based on reinforcement learning.
IMPLEMENTATION OF A2C NETWORK ON MARKET DATA
Using the gym open-source library, the A2C network can be implemented on real-world stock data, in
this case, the $AAPL stock is used for the period of 1 year: 2019-2020.
Final results:
As we can see, this trained bot earned a net profit of about 13.97% over the period of one year. This
performance can be further improved through Deep Q-Learning, using better indicators and integrating
market sentiment scores with the model.
Link to notebook:
https://colab.research.google.com/drive/1j1h3q_oxNax_f-2OLdH8H9JAn0hyEjD-?usp=sharing
CONCLUSION
Reinforcement Learning is just an artificial way of imitating how living organisms learn to do various
tasks: by rewarding good actions and penalizing bad ones. This helps a system learn and exploit patterns
that otherwise would not be comprehendible by the human eye. It turns out to be very efficient in
situations where training data is unavailable, where it learns through experience. It has been
extensively used in robots for performing physical tasks with unprecedented accuracy, and in video
games where RL has even defeated the best players in the world.
However, reinforcement learning has its own shortcomings. It assumes the world to be purely
Markovian which is incorrect. It is data-hungry, meaning it needs a lot of time and experience to
construct a usable model. But taking into consideration these disadvantages and pursuing appropriate
measures to combat them, RL can open a plethora of opportunities in the domain of artificial
intelligence.
The field of finance has made great use of this emerging concept in portfolio optimization, optimized
trade execution, market-making, etc. These new RL solutions have proved to be better than many pre-
existing solutions to the above-mentioned problem areas. We can expect reinforcement learning to
take the world of artificial intelligence by storm and perform tasks like or even better than the most
skilled human beings.
Introduction
Before understanding the importance of this concept, let us have a look at some supporting figures-
1. By 2017, tech companies that were users of the Double Irish Dutch Sandwich (DIDS) scheme, had
saved up to 1 Trillion dollars of tax-free European profits in offshore islands such as the Bermuda
Islands, the Caribbean islands, etc.
2. In the period 2004-2014, Apple had collected over 111 Billion dollars of European profits.
3. In 2003, Apple had paid a 1% tax on all European profits. By 2014, Apple paid only 0.005% tax on
its European profits.
American corporate firms need to pay a high tax rate of 35% but tax evasion schemes like the DIDS help
them achieve a <1% effective tax rate (ETR). DIDS in essence is a Base Erosion and Profit Shifting (BEPS)
scheme.
BEPS schemes refer to a set of tax-saving tool based on profit reallocation developed by tech firms exploiting
incoherence in international tax rules. Now a natural question arises, why BEPS? This is because of the
worldwide tax system in the US.
The US Tax System
There are two types of tax systems, the territorial tax system, and the worldwide tax system. In the
territorial tax system, a firm should pay taxes on whatever income it earns in the territory of the nation.
However, in the worldwide tax system, a firm will be taxed on its income earned globally. The first system,
promotes the free flow of cash allowing companies to expand their reach and perform free trade. However,
the
worldwide tax system makes free trade difficult by doubly taxing the country’s foreign profits. All the
present-day G7 nations use the territorial tax system. The US used the worldwide taxation system till 2017
and hence it forced MNCs based in the US to use BEPS tools such as the DIDS.
To understand the concept of DIDS, let us take the example of Apple US. Suppose Apple sells an iPhone for
1100$ in the US and achieves a 1000$ profit. Now as per corporate tax rule, it would be supposed to pay
350$ on the profit earned. Now, suppose Apple wants to do business in the European countries. For this, it
sets up a European subsidiary. The European subsidiary may be Irish as Ireland has a lot of friendly tax
policies that help companies use BEPS tools. Let’s suppose that it sells the same iPhone for 1100$ in Europe
as well. Now, as per the old worldwide tax system followed in the US, Apple will have to pay 350$ of tax to
the US government. In addition to this, it will also have to pay taxes in the nation where its European
subsidiary is located. This will decrease their profits as they are getting doubly taxed.
So, to avoid paying so much tax, we can open a Caribbean islands subsidiary that will control the European
subsidiary. This can be done by transferring assets such as IP from the European subsidiary to the Caribbean
island subsidiary. Since the major asset of tech firms are intangible in nature such as IP, it is easier for them
to transfer assets digitally.
As the Irish subsidiary uses the IP of the Caribbean islands’ subsidiary, we can redirect all the profits made
by the Irish subsidiary to the Caribbean islands subsidiary citing royalty payments. In this way, the Irish
subsidiary has 0$ of effective profit and hence it won’t be subject to any taxes. Meanwhile, as the Caribbean
islands have a ~0% corporate tax rate, all of the European profits will now lie untaxed there.
To improvise the Effective Tax Rate (ETR) in the above scheme, some companies have introduced a Dutch
twist. Since Ireland imposes withholding tax for monetary transfers between two Irish firms, company A will
have to pay tax to the Irish government while transferring money to company B. But as Ireland has tax
agreements with few countries such as the Netherlands, it does not impose any withholding tax for
monetary transfers between the firms of both nations. In the above example, we can introduce a Dutch
company (C) to achieve an even lower ETR. This arrangement is known as the Double Irish Dutch Sandwich.
Discovery & Shutdown
The DIDS scheme was officially discovered by the US in 2014 and it gave a 5-year time period to all tech
firms to discontinue the use of this policy. The European Union also pressurized the Irish government to
reform its tax policies so that MNCs cannot avoid paying taxes on their profits by means of profit shifting.
The US government also decided to switch to the territorial tax system in 2017 and brought down corporate
tax rates from 35% to 15.5% in 2018 under the Trump tax reforms in order to promote free trade and
decrease the use of BEPS tools such as the DIDS. Following these tax reforms, Apple had announced the
repatriation of 252$ Billion of money in offshore havens. However, the new tax reforms and international
tax policy changes did not achieve the expected success and the use of BEPS tools continued to increase
over time.
Newer Alternatives
After the shutdown of the Double Irish Dutch Sandwich scheme, two BEPS strategies became prominent,
namely the CAIA and the Single Malt scheme.
● Apple’s Irish subsidiary bought $300 Billion of IP from Apple’s Jersey subsidiary
● The Irish subsidiary made use of the CAIA rule to write off this amount against future Irish profits,
i.e. the next $300 Billion of profits that Apple’s Irish subsidiary makes would be subject to $0 tax.
● Further, Apple made use of the Irish interest relief laws to double its tax shield to $600 Billion with
an ETR of exactly 0%.
Conclusion
In this article, we primarily focused on the development of the DIDS scheme, its need, workarounds, etc.
We also shed light on modifications and recent alternatives to the Standard Double Irish scheme such as
the Single Malt and CAIA.
A rescue to financial crisis……….
Dragon King……….
Seems quite interesting right and so it is Come let’s explore the powers of this dragon. Dragon King (DK) is
a double metaphor for an event that is both extremely large in size or impact (a "king") and born of unique
origins (a "dragon") relative to its peers (other events from the same system).
These events are generated by mechanisms such as phase transitions, bifurcations, positive feedback, etc
which usually take place in complex non-linear systems. In simple words, these are the extreme special
events. They are the outliers. However, being generated by specific mechanisms makes them predictable
and at best, controllable.
So basically this concept came up after the global financial crisis of 2008. When the economy was shattered
and the economist pondered upon the event and analyzed that this could have been controlled and the
economy could have been in a much better
condition., It’s believed that with the help of Dragon King Theory economists will be able to spot similar
financial bubbles before they burst in the future.
Some might ask then what is the difference between a black swan and a dragon King??
For the ones unaware of the tern black swan, I would like to ask, how frequently, have you seen a black
swan? The answer would be rare and very hard to find. Just as a black swan which is hard to find
unpredictable and shattered your belief that all swans should be white so is the black swan theory. A
black swan is an unpredictable event that is beyond what is normally expected of a situation and has
potentially severe consequences. Black swan events are characterized by their extreme rarity, severe
impact, and the widespread insistence they were obvious in hindsight. This is unlike the Dragon King
theory which s exactly the opposite, that most extreme events are knowable and predictable. So we can
be empowered and take responsibility and make predictions about them.
The two main hypotheses behind the dragon king theory are :
Hypothesis I: Financial bubbles can be identified in real-time
Hypothesis II: The end of the financial bubble can be assessed using probabilistic forecasts.
Few steps are needed to be taken to identify when will a dragon king appear.
● fueled by positive feedbacks. Most crises are “endogenous”(can be predicted through a model).
● Whenever there is a super-exponential growth coupled with positive feedbacks then there comes a
warning signal.
The power law is the exponential relationship between two quantities where one quality varies as a power
of the other quantity. A relative change in one quantity results in a proportional relative change in the other
quantity. For instance, considering the area of a square in terms of the length of its side, if the length is
doubled, the area is multiplied by a factor of four.
It is well known that many phenomena in both the natural and social sciences have power-law statistics.
However, In a variety of studies, it has been found that even though a power-law models the tail of the
empirical distribution well, the largest events are significantly outlying (i.e., much larger than what would
be expected under the model). Such events are interpreted as dragon kings as they indicate a departure
from the generic process underlying the power law. Examples of this include the largest radiation release
events occurring in nuclear power plant accidents, the largest city (agglomeration) within the sample of
cities in a country, the largest crashes in financial markets, and intraday wholesale electricity prices.
How does the dragon king event impact the scaling law parameter??
Considering Poisson and Negative Binomial distribution we shall try to predict scaling parameters (alpha
and beta).
Y = αXβ
When Y follows a Poisson distribution, the Poisson regression must be applied to estimate the scaling
parameters. Similarly, when Y has an NB distribution, the negative binomial regression must be applied.
However, it can be difficult to ascertain the distribution of Y when real data is considered and this can lead
to the wrong choice of a regression model. Hence, to show how this can affect the estimated values for the
scaling parameters, we also apply the Poisson regression to samples where Y is NB-distributed and the
negative binomial regression to samples where Y is Poisson-distributed.
We could observe that the same results are obtained with and without dragon king(DKs)
We conclude that as long as X and Y satisfy the same scaling law for all the points in each sample, the
presence of dragon-kings does not have an impact on the estimated scaling exponent, regardless of the
type of regression used for the estimation.
The main concepts that are needed to understand stock markets are imitation, herding, self-organized
cooperativity, and positive feedbacks, leading to the development of endogenous instabilities. According to
this theory, local effects such as interest raises, new tax laws, new regulations, and so on, invoked as the
cause of the burst of a given bubble leading to a crash, are only one of the triggering factors but not the
fundamental cause of the bubble collapse. We propose that the true origin of a bubble and its collapse lies
in the unsustainable pace of stock market price growth based on self-reinforcing over-optimistic
anticipation. As a speculative bubble develops, it becomes more and more unstable and very susceptible to
any disturbance. In a given financial bubble, it is the expectation of future earnings rather than the present
economic reality that motivates the average investor. History provides many examples of bubbles driven by
unrealistic expectations of future earnings followed by crashes. The development of a given financial bubble
releases precursory “fingerprints” observable in the stock market prices.
These fingerprints have been modeled by “log-periodic power laws” (LPPL), which are mathematical
patterns associated with the mathematical generalization of the notion of fractals to complex imaginary
dimensions. We refer to the book of Sornette for a detailed description and the review of many empirical
tests and of several forward predictions. Analysis with the LPPL model of the Hang Seng China Enterprises
Index (HSCEI) led to (i) a diagnostic of an on-going bubble and (ii) the prediction of the end of the bubble in
early 2008
As an investor, you should look out for warning signs of instability such as exponential growth and positive
feedback. While these factors can make a stock seem highly lucrative, Dragon King Theory can be used to
predict that over time growth will become unsustainable and a crash will likely occur. Beware of the bubble
burst.
QUANT CLUB IIT KHARAGPUR
THANK YOU