The goal of this project is to look at the NIFTY-50 data as well as the sectoral indices and visualise them in order to acquire useful information. Also, use the scikit learn python library's Kmean (unsupervised learning model) to find regimes.
- Visualization market performance 2019 onwards using plotly python library
- Major single day fall
- Major single day gain
- Box plot - Closing price of different indices
- To determine which trading model or trading strategy to execute at any particular time, we use regime detection.
-Importing KMeans from scikit learn python library
from sklearn.cluster import KMeans
- Creating Volatility and Momemtum feature
window = 20
data['mom'] = data[symbol].rolling(window).mean()
data['vol'] = data[symbol].rolling(window).std()
- Scale the dataset to improve the model's performance
data = (data - data.mean())/data.std()
f = ['mom', 'vol']
model = KMeans(n_clusters=4)
model.fit(data[f])
cluster = model.predict(data[f])
- Plotting cluster detected by KMeans model
- Positive Momentum and low Volatility
- Positive Momentum and high Volatility
- Negative Momentum and high volatility
- Negative Momentum and low volatility