Professional Documents
Culture Documents
Financial Analytics Study To Build Robust Trading Strategies Capstone Project - 2022-23
Financial Analytics Study To Build Robust Trading Strategies Capstone Project - 2022-23
Financial Analytics Study To Build Robust Trading Strategies Capstone Project - 2022-23
Trading Strategies
Capstone Project -2022-23
Problem Definition
The main objective of this study is to find the best model to predict the
BUY \ SELL stocks in stock market.
In the finance world stock trading is one of the most important activities.
Stock market prediction is an act of trying to determine the future value
of a stock or any other financial instrument traded on a financial
exchange.
The successful prediction of the stock will be a great asset for the stock
market institutions and will provide real-life solutions to the problems
that stock investors face. It draws a detailed analysis of the techniques
employed in predicting BUY \ SELL stocks as well as explores the
challenges entailed along with the future scope of work in the domain.
Problem Definition
In, this project we are going to build trading strategies, present and review a
more feasible method to predict the BUY \ SELL stock with higher accuracy.
This paper explains the prediction of Buy \ Sell a stock using Machine
Learning & Artificial Neural Networks (ANN). The technical and fundamental
or the time series analysis is used by most of the stockbrokers while making
the stock predictions.
During the process we will be using techniques like 101 alphas along with
various Machine Learning Algorithms.
Proposed Solution ( including EDA)
Collected the historical Daily data (OHLC) of Nifty 50 stocks along with the
index from 1st Jan 2015 till 5th May 2022.
Leveraged a paid API of Zerodha to fetch the data using python coding.
Our approach towards the solution includes both conventional ML models
and using ANN. The conventional approach is based on the machine
learning algorithms namely XG Boost Classifier, Random Forest Classifier,
Gradient Boosting Classifier, Support Vector Machine classifier (SVC).
Created our target variable based on the Simple Moving Average (SMA)
200, to generate recommendation for BUY, SELL, BUY HOLD, SELL HOLD
with BUY_HOLD = 1 , SELL_HOLD = 3 , SELL = 2 , BUY = 0. The prediction
of the stock will be a great asset for the stock market institutions and will
provide real-life solutions to the problems that stock investors face.
Proposed Solution ( including EDA)
For our model building, we used historical data of Maruti and Nifty 50
index.
Created our target variable based on the SMA 200, to generate
recommendation for BUY, SELL, BUY HOLD, SELL HOLD.
Maruti dataset had columns namely: Open, High, Low, Close,
Recommendation and values for each of the 101 Alphas for a particular
date.
Initially Maruti dataset had 1815 rows and 117 columns.
Dropped the initial 200 rows as the recommendation column (our Target
variable) was blank, since SMA 200 build on the last 200 data points to
populate values thereon.
Proposed Solution ( including EDA)
We had to do data cleansing as we had lot of cells with infinite values as
well as null values.
Using Label Encoder, we converted our Target variable from categorical to
numerical.
Data analysis and data visualisation to find the outliers.
Plotted few graphs to have visual inference of
• time series data
• to view seasonality (monthly and yearly) of stock price
• to view co-variance between Maruti and Nifty 50 Index.
• to compare returns between Maruti and Nifty 50 Index.
• to view the price trend by leveraging Mann-Kendall Trend test
Algorithms, Solution and Conclusions
Before building our model, we addressed the class imbalance of our Target
variable (Recommendation) in our Maruti Dataset by using SMOTE.
Used used PCA for feature extraction by reducing the initial features set of
95 to 40 features.
Build ML models by using XGboost Classifier, RandomForest Classifier,
GradientBoosting Classifier, SVC classifier.
While comparing the performance metrics of the ML models used, the
accuracy and F1-score was highest for GradientBoosting Classifier.
In addition built a model using Artificial Neural Network (ANN) and the
performance was much better in comparison to our best performing ML
Model i.e GradientBoosting Classifier.
Algorithms, Solution and Conclusions
Model Creation
• XG Boost Classifier
• From XGBoost Library we have imported XG Boost Classifier. Model is created and trained with 70-30 train
• test split.