Friday, April 1, 2022

Exploring Nifty with Altair

Exploring Nifty with Altair









 




Nifty or Nifty50 is the benchmark index for Indian stock market, which trades at the national stock exchange (NSE) in Mumbai. Nifty50 holds the top 50 public companies (by market capitalization) in India , and so in a sense it serves as a reflection of the Indian stock markets

What is Altair: Altair is a visualization and analysis library for the programming language Python which i just got introduced to. Till now i used Matplotlib for most of my work , but Altair , it seems is a worthy opponent. 

With those out of the way , lets start with the heart of the matter. 

I start with a simple time series of prices. The blue line reflects the price level of Nifty , starting from 2000 to 2022 Feb . You will see that Nifty has appreciated from a sub 1500 level to above 17000 in ~20 years . While this seems like a 10x increase in 2 decades , really the CAGR ( compound annualised growth) is close to 12% 
















Now lets make it a bit more complicated in the chart below , the blue line is still the Nifty price levels , but i have added the India 10 year bold yields (red line) , and the Nifty trading volume (grey bars
) . Some interesting observations 
  • Bond yields have been falling over time . From double digit yields in the early 2000s, its now around 6-7% range. 
  • Its then quite natural than the stock market participation has increased over time , as investors shifted capital to stock markers from fixed income , searching for incremental yield. 
  • You will see that there is a major dip in both stock prices and bond yields during the crisis periods (e.g. Lehman around 2007/8 , Covid-19 around 2020). While the stock market crash is intuitive , the crash in bond yields is perhaps a reflection of central bank monetary easing by lowering interest rates and increasing the money supply 
  • It also then makes some sense that the increased money supply also found its way to the capital markets , further increasing stock market participation.  

Finally i end this section by examining the volatility of monthly returns of Nifty50. 

Below is a binned histogram of the monthly returns for a sample size of 266 (i.e. we have 266 monthly returns arranged in a histogram) 
Some observations we can make from these 
  • Mean monthly return for this period is close to 1% (the red line)
  • The central 5 bins have about 194 observations in them. So for this period, Nifty monthly returns has been between -5% and +5% almost 73% of the time (194/266). Option sellers find this kind of odds interesting to build short strategies 













Scatter plots 

A scatter plot is a great way to describe relationships between two variables and understand the strength of the statistical correlation between them . I have used this to track Nifty50 monthly returns with some other factors , which economically seems relevant. 

S&P 500

The first one is a scatter plot with S&P 500 returns in the horizontal axis , against Nifty50 returns in the vertical.
Its evident that there is a reasonably strong positive correlation , identified by the positive sloped regression line. 
Economically this is intuitive as well , S&P 500 is the benchmark for the top 500 firms in the US , which largely dominates the global stock markets. 
The emerging markets are heavily linked with the performance of the US stock markets and thats what is validated here





Crude Oil

India is a large importer of Crude oil and therefore it has a significant impact to the stock markets. In the last two decades this correlation has been positive , and this in a way seems puzzling. The general intuition is that the increase in oil price should depress stocks and vice -versa , but the data tells you a different story. Perhaps this is why numbers often help you make better judgement. 

 Generally an increase in oil price driven by increased demand signals a booming economy, leading to an inflationary environment , and that's when stocks are preferred as an asset class. So a demand driven move in oil prices have correlated positively to Nifty50. This relation do not hold when oil prices spike due to supply shocks, and then infact the relation may turn negative (this is for another day)


Gold

Gold has no correlation of statistical significance with Nifty50 under normal market situations. 
This is contrary to popular belief at the outset , but noticed i placed normal in bold . 
Under a stressed market situation (e.g. war , covid , Lehman crisis) Gold tend to be negatively correlated with Nifty. This makes sense as people prefer gold as a safe asset and resort to it in a flight to safety. 






US Dollar Index ( DXY)

This one is the favorite among many traders. The DXY as you can see is negatively related to Nifty50
In short DXY is a measure of the strength of the USD (but its not exactly a cross currency quote) , which reflects the prevailing risk appetite in the markets 
Why this relation is negative is quite complex . Firstly USD being a reserve currency is preferred at time of stress, when assets are moved from riskier emerging markets to safer havens . 
On the other hand a weakening of USD means flows into emerging markets by FIIs as their investment returns are augmented with a foreign currency return as well. 


India 10 year Bond Yields

Getting back to where i started , its natural that government bonds are negatively related to Nifty50. 
In the strong phase of the business cycle , investors prefer stocks as it helps beat inflation and preserve real growth. 
As central banks become more concerned with inflation and increase interest rates , bond become a preferable investment for two reasons. Firstly the yield is higher and secondly a higher borrowing cost impacts corporate balance sheets suppressing earnings. 

Disclaimer : I am not a registered investment advisor and neither is this blog intended for any investment advice. This should be treated for learning purposes only. 


Banking Balance Sheet : Part 1 : Regulatory Management

  Banks are regulated by various agencies but the overarching principles are directed by Basel regulations .  As per Basel's pillar 1 re...