Finding Correlation between strategies

3
(2)

We all know that Stock market is random and it has Three phase cycles:

  1. Uptrend
  2. Downtrend
  3. Sideways

Do you really think your strategy will perform really well in all market conditions?

Really Big No………………………………………

As we all know, It is hard to find a strategy which will work well in all market conditions.

So that means you have to go through Drawdown Phases of strategy.

What will it cause ?

It will affect your psychology. If it has higher Drawdowns periods, maybe you will stop your strategy thinking that it is not working before it hits Maximum Drawdowns.

What is the solution?

I will try to find multiple diversified Strategies.

What does that mean ?

In simple words I will try to find a Basket of strategies which will work well in different market conditions. i.e Some strategy will work good in sideways market conditions, some will work good at uptrend market condition and some will be good at downtrend market condition.

How will this help us?

Because you are running diversified strategies, your Drawdown will reduce tremendously and It will not affect your psychology,which will help you to trade all of the strategies for long the run.

Now, a question must be running in your mind, that If something is running good in one market condition and another is giving loss then will I end up playing a zero sum game?

For this we are going to analyze a no-correlation strategies with zero or near to zero correlation with each other that means their behavior is independent not same nor opposite.

We get an idea that this problem can be solved by finding the correlation between strategies.

What is correlation ?

It’s a statistical Term which is used to measure relations between two Data sets.

These two Data sets can be anything like D-mart and Nifty-50 Behavior or it maybe BankNifty and Nifty-50.

It’s hard to predict correlation because these are constantly changing value and mostly during panic and high volatility regime when most assets are moving downward directions.

So, Correlation ranges between -1 to 1.

  • Consider 2 Stocks If they are moving in the same direction, then they will have positive correlation between 0 to 1 and If they are moving exactly the same then it has a correlation value of +1.
  • If they are moving in opposite directions, then they will have Negative Correlation between 0 to -1 and If they are moving exactly opposite then it has a correlation value of -1.
  • If they are moving independent of each other, they will have a correlation value of 0.

Now, we will find correlation between strategies using their historic PNL data and how they are correlated.

As we are going find correlation between multiple strategies :

The matrix method will be use to find correlation between strategies. If we have N strategies then we are going to used the ( N x N ) matrix to find correlation between them.

I am going to use Python to find correlation and Data samples will be strategies PNL.

Step 1: Collect the data ( Let’s Take 3 strategies PNL )

You can take this as PNL as Weekly, Monthly or Yearly

Step 2 : Created Dataframe using Pandas library

Code:

Import pandas as pd

data = {‘strategy_1’: [-5781, 5055, 17098, -8164, 9585, -8897, 13404, 23181, 1877, 807, 3647],

        ‘strategy_2’: [7500, 6524, -371, 6806, -3337, -1588, 8659, -1308, -1029, -4917, 2141],

        ‘strategy_3’: [2298, -6859, -21059, -3043, -5568, 2661, 1879, 1192, -3177, 10598, -5266]

        }

df = pd.DataFrame(data,columns=[‘strategy_1′,’strategy_2′,’strategy_3’])

print(df)

Result :

Step 3 : Create correlation Matrix using Pandas Library

Use ” df.corr() “ to find correlation 

Code :

import pandas as pd

data = {‘strategy_1’: [-5781, 5055, 17098, -8164, 9585, -8897, 13404, 23181, 1877, 807, 3647],

        ‘strategy_2’: [7500, 6524, -371, 6806, -3337, -1588, 8659, -1308, -1029, -4917, 2141],

        ‘strategy_3’: [2298, -6859, 21059, -3043, -5568, 2661, 1879, 1192, -3177, 10598, -5266]

        }

df = pd.DataFrame(data,columns=[‘strategy_1′,’strategy_2′,’strategy_3’])

corrMatrix = df.corr()

print (corrMatrix)

Result :

How to analyze this matrix?

  1. As you can see diagonals will always be 1 as they are the same strategy, so they are fully correlated.
  2. We are taking the Ideal value between (+/-) 0.25 for correlation of strategy.
  3. Finally, Check If each cell except diagonal lies between (+/-)0.25 then are correlated with each other.
  4. Comment down and tell me what we have find is correlated or not.

This same thing you can do it on excel too. Hope you guys find this helpful and valuable.

Until then!

How useful was this post?

Click on a star to rate it!

Average rating 3 / 5. Vote count: 2

No votes so far! Be the first to rate this post.

Spread the love

About the author

Tushar Wasake

View all posts

Leave a Reply

Your email address will not be published. Required fields are marked *