What is the name of Switzerland(SMI) stock market?
The SMI is symbol of the Switzerland(SMI) stock market.
How to get Switzerland(SMI) stock market data ?
you get data from yahoo finance,Quanda,google etc.
How to install data in python?
Here install python lib.
import yfinance as yf
import numpy as np
import pandas as pd
import seaborn as sns
import scipy.stats as scs
import statsmodels.api as sm
import statsmodels.tsa.api as smt
import matplotlib.pyplot as plt
Some python code data collected from yahoo finance
df = yf.download('^SSMI',
start='1985-01-01',
end='2021-07-07',
progress=False)
How to get indivisual column SMI adj price?
df = df.loc[:, ['Adj Close']]
df.rename(columns={'Adj Close':'adj_close'}, inplace=True)
Simple return and Log return SSMI
df['simple_rtn'] = df.adj_close.pct_change()
df['log_rtn'] = np.log(df.adj_close/df.adj_close.shift(1))
df[['simple_rtn','log_rtn']].tail(20)
How to get realised volatility SMI in python?
def realized_volatility(x):
return np.sqrt(np.sum(x**2))
df_rv = df.groupby(pd.Grouper(freq='M')).apply(realized_volatility)
df_rv.rename(columns={'log_rtn': 'rv'}, inplace=True)
df_rv.rv = df_rv.rv * np.sqrt(12)
fig, ax = plt.subplots(2, 1, sharex=True)
ax[0].plot(df)
ax[1].plot(df_rv)
Plot Realised volatility SMI
0 Comments