Stock Market (NIFTY) Forecasting Using Machine Learning Analysis On Option Chain

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

International Journal of Recent Technology and Engineering (IJRTE)

ISSN: 2277-3878, Volume-9 Issue-5, January 2021

Stock Market (NIFTY) Forecasting using Machine


Learning Analysis on Option Chain
Saurabh Gupta, Vaishali, Raghuvansh Tahlan, Navya Sanjna Joshi, Ritvik Agarwal

Abstract: Stock market prediction is a long-time intriguing


topic to researchers from different fields. Stock market data is II. OPTIONS AND OPTION CHAIN
extremely volatile and hence laborious to model. In particular,
innumerable studies have been conducted to predict the A strike price, also known as the exercise price, is a
movement of stock market using Machine Learning algorithms predefined price at which a contract can be bought or sold
such as Regression Techniques, Time Series Forecasting, Indices when exercised[1]. For the case of call options, the strike
Modelling, Natural Language Processing and more, but there is price is the price at which the holder can buy the security;
still room for improvement. Also, Option chain and Options have for put options, the strike price is the price at which the
been the subjects that not many have ventured into, leading us to security can be sold. Also, depending upon the difference
this subject. Mainly, NIFTY and BANKNIFTY Options account between the strike prices and underlying asset, the strike
for 70% of total derivatives traded and much more turnover than prices can be categorized into three categories. ‘At the
all stocks combined. This research paper attempts to figure out Money’(ATM) is a situation where the price of an option
the utility of Option Chain in predicting the direction of
contract is equal to the price of the underlying asset. ‘In the
movement in NIFTY. We have tried how different features from
Money’(ITM) is when an option contract’s price is less than
Option chain can be extracted, and the resulting problem can be
solved using Machine Learning techniques and Deep Learning
the asset in case of Call option and more than the asset in
techniques. case of Put option. ‘Out of the Money’ commonly referred
to as OTM, is when the option contract’s price is more than
Keywords: NIFTY Forecasting, Options, Option Chain, Stock the asset for the call option and less than the asset for the put
Market Forecasting. option. Open Interest (OI) refers to the total number of
option contracts that are active/traded but not yet
I. INTRODUCTION liquidated.On the other hand, Volume is the total number of
Prediction of stock trend has long been an intriguing topic contracts traded. Implied Volatility (IV) is the expected
and is extensively studied by researchers from different volatility of the underlying asset over the option’s life. The
fields. However, only a handful of studies on the expiry date for Options refers to the last date till which
relationship between the Stock Market and Option Options contracts are valid, and Option holders can exercise
Chain/Options for data and analysis exist today. In the their rights. For instance,in the case of NIFTY and
financial realm, Options are financial instruments that are BANKNIFTY weekly options, they expire every Thursday
derived from an underlying asset such as stocks or index[1]. at 3:30 pm.
An Options contract is an opportunity for the investor to buy Option Chain data is available on various online websites
or sell the underlying asset depending on the type of and portals. However, the one provided by the National
contract he holds. A call option gives the trader the right but Stock Exchange(NSE)[2] is the most accurate, reliable, and
not the obligation to buy a fixed quantity of the underlying acts as a reference for all. The data is volatile and keeps
asset at a given price.A put option, on the other hand, gives
changing every few minutes, so we collected the data every
the trader the right but not the compulsion to sell the given
5 minutes for six months, which became the basis of our
quantity of an asset at a given price.An option chain lists all
research.
available option contracts, both puts, and calls, for given
security. It shows all puts, calls, strike prices, and pricing The data collected consists of Strike Price, Last Traded
information for a single underlying asset within a given Price(LTP), Implied Volatility(IV), Open Interest(OI) and
maturity period[1]. Traded Volume. Data from Option Contracts corresponding
to these 7 Strike Prices are consolidated into a single row to
have one row of data per Timestamp.Some of the features
Revised Manuscript Received on December 30, 2020. are derived from Statistics like Sum of Open Interest(OI)
Dr Saurabh Gupta, Computer Science and Engineering Dr
AkhleshDas Gupta Institute of Technology and Management, New Delhi, and Sum of Volume of all Strike Price for both Put and Call
India, [email protected] Option contracts.However, Trading Tutorials have also
Vaishali, Computer Science and Engineering Dr AkhleshDas Gupta inspired us to extract some of the features, for example, Put
Institute of Technology and Management, New Delhi, India,
[email protected]
Call Ratio commonly called as PCR for Open Interest and
Raghuvansh Tahlan, Computer Science and Engineering Dr Volume[4].
AkhleshDas Gupta Institute of Technology and Management, New Delhi,
India,[email protected]
Navya Sanjna Joshi, Computer Science and Engineering Dr
AkhleshDas Gupta Institute of Technology and Management, New Delhi,
India, [email protected]
Ritvik Agarwal, Computer Science and Engineering Dr AkhleshDas
Gupta Institute of Technology and Management, New Delhi,
India,[email protected]

Published By:
Retrieval Number: 100.1/ijrte.E5155019521 Blue Eyes Intelligence Engineering
DOI:10.35940/ijrte.E5155.019521 80 and Sciences Publication
Stock Market (NIFTY) Forecasting using Machine Learning Analysis on Option Chain

Figure 1: Key Option Chain concepts[3]

PCR is a Contrarian indicator in the trading world and Table 2: Interpretation of Change in OI and LTP in Put
denotes the ratio of the total number of Put option contracts Contract.
and Call Option Contracts. Changes in the valueof Open
Interest(OI), Implied Volatility(IV), Last Traded Price(LTP) CHANGE
and Volume in respectof preceding Timestamp are also used CHANGE IN IN LAST
as features. The Strike Price where Open Interest is OPEN TRADED
Maxiumum for Call Option Contracts is considered as INTEREST(O PRICE(LT INTERPRETATIO PUT
‘Resistance’ for the underlying asset. At the same time, I) PUT P) PUT N SIGNAL
‘Support’ is the strike Price where Open Interest is BEARIS
RISE RISE LONG BUILDUP H
Maximum for Put Option Contracts. Depending upon the
BULLIS
signs of change in Open Interest and Last Traded Price we RISE FALL SHORT BUILDUP H
can also classify the Strike Price into one of the four SHORT BEARIS
Categories – Long BuildUp, Long Liquidation, Short FALL RISE COVERING H
BuildUp and Short Covering.[5]By observing the traded LONG BULLIS
Volume at different times of the day, we have found that FALL FALL LIQUIDATION H
significant trades.happen during the first and last two market A typical row in the dataset consists of Timestamp, Expiry
hours, so we have created a feature keeping that in mind. Date, PCR values, Interpretation of Change in Open Interest
and Change in Last Traded Price(LTP), the value of the
Table 1: Interpretation of Change in OI and LTP in Call underlying asset(NIFTY), time of the Trading day, Trading
Contract. Day(Monday, Tuesday, etc.) and data from ATM, Support
and Resistance Strike Prices.Since we are in the initial
stages of the research, we are not trying to predict the actual
CHANGE
values of the NIFTY, but we are attempting to at least
CHANGE IN LAST
IN OPEN TRADED
predict the trend of the NIFTY different time periods.The
INTEREST PRICE CALL research will help usfigure out if the data extracted from
CALL CALL INTERPRETATION SIGNAL Option Chain does have the power to predict and is worth
researching further.Over some time we have observed that
RISE RISE LONG BUILDUP BULLISH changes in the values of Option Chain are not readily
RISE FALL SHORT BUILDUP BEARISH reflected in the prices of NIFTY, so we conducted a series
SHORT of experimentsto see how the accuracy of the model changes
FALL RISE COVERING BULLISH with different time periods.
LONG
FALL FALL LIQUIDATION BEARISH

Published By:
Retrieval Number: 100.1/ijrte.E5155019521 Blue Eyes Intelligence Engineering
DOI:10.35940/ijrte.E5155.019521 81 and Sciences Publication
International Journal of Recent Technology and Engineering (IJRTE)
ISSN: 2277-3878, Volume-9 Issue-5, January 2021

Over some time we have observed that changes in the values Trading Tutorials and videos have always emphasized on
of Option Chain are not readily reflected in the pricesWe the use of Put Call Ratio(PCR) of Open Interest,and we do
formed a binary Target variable where it values 0 if the agree with this because PCR of Volume was our most
future value of NIFTY is less than the current value and 1 important feature.
otherwise. Since our target variable is binary and binary and However, surprisingly PCR of Open Interest does not
our data is numerical, we can use Classification Machine feature even in the top 15 ‘features’. Some other notable
Learning as well as Deep Learning Models. For this features include Open Interest values of the Put contract for
research, we have used CatBoost Classifier[6], which is fast, Resistance row and Call Contract’s for Support row. Implied
open-sourceand provides good results with relatively fewer Volatility(IV) does not feature anywhere in the top 15.
data. We have divided our data into two parts- 70% for
Training and 30% for Testing and a particular random state
IV. CONCLUSION
to get steady results. We have trained our model for 300
iterations with 100 early stopping rounds and used scikit- In the project, we researched the use of the Option chain
learn’s accuracy as well as ROC_AUC score as metrics for data to help predict the future trend of the underlying
our research. asset/NIFTY. Numerical results suggest high efficiency with
60% accuracy after 25 minutes and 70% accuracy after 30
III. RESULTS AND OBSERVATIONS minutes for the prediction of the NIFTY trend. PCR of
Volume was a prominent feature, but surprisingly PCR of
This research is based mostly on predicting trends (
Open Interest and Implied Volatility(IV) proved to be of
upward/downward) in NIFTY. We did not have pre hand little utility. Some noteworthy mentions include Open
knowledge about the time it takes for the changes in Option Interest values of the Put contract for Resistance and Call
chain to get reflected in the values of NIFTY. So we have Contract’s for Support. However, it is still far from what
tried multiple experiments in which we calculated the target could be used single-handedly in trading because knowing
variable using future values of NIFTY ranging from the the trend after 30 minutes might not give the confidence to
immediate row to next 6th row. As the timeframe or the time invest. Option Chain alone data may not be powerful
difference between each row is 5 minutes, this implies that enough. However, when coupled with the data of Equities,
we have tried predicting the trend of NIFTY using durations Futures and Sentiments and appropriate Deep Learning
ranging from 5 minutes to 30 minutes. Training scores were Technologies, it may become a game-changer.
always superior to testing scores, but both scores follow a
similar trend, where the scores dropped for the ‘Next 2nd REFERENCES
row’ (10 minutes in future) and then rising to their 1. https://www.investopedia.com/terms/o/option.asp
maximum in ‘Next 6th row’ (30 minutes in future) and 2. https://www.nseindia.com/option-chain
saturating at ‘Next 5th row.’ We also believed that by using 3. https://dotnettutorials.net/lesson/option-chain-analysis/
4. https://www.investopedia.com/trading/forecasting-market-direction-
preceding rows of data along with the current row might with-put-call-ratios/
produce some improvements in results. So we conducted 5. https://fyers.in/school-of-stocks/chapter/options/reading-option-chain-
experiments where up to 3 previous rows were used in using-volume-and-ol.html
6. https://catboost.ai/docs/concepts/python-
addition to the current row to predict the target variable. reference_catboostclassifier.html
However, this approach did not lead to any significant 7. Chia, C., 2020. Prediction Of Stock Price Movements Using Options
improvement in the result. Data., http://cs229.stanford.edu/proj2016spr/report/052.pdf
While understanding the ‘feature importance’ of the most
effective model, we encountered something interesting.
Table 3: Results of various Experiments

EXPERIMENT TRAINING TESTING TRAINING TESTING


ACCURACY ACCURACY ROC_AUC ROC_AUC
TARGET PREVIOUS ROWS
NEXT
NA 0.67 0.57 0.67 0.57
ROW 1
NEXT
NA 0.71 0.55 0.7 0.54
ROW 2
NEXT
NA 0.91 0.61 0.91 0.6
ROW 3
NEXT
NA 0.91 0.65 0.91 0.65
ROW 4
NEXT
NA 0.93 0.69 0.93 0.68
ROW 5
NEXT
NA 0.93 0.7 0.93 0.69
ROW 6
NEXT
PREV1 0.71 0.57 0.71 0.57
ROW 1
NEXT
PREV1 0.69 0.56 0.68 0.55
ROW 2

Published By:
Retrieval Number: 100.1/ijrte.E5155019521 Blue Eyes Intelligence Engineering
DOI:10.35940/ijrte.E5155.019521 82 and Sciences Publication
Stock Market (NIFTY) Forecasting using Machine Learning Analysis on Option Chain

NEXT
PREV1 0.9 0.61 0.9 0.6
ROW 3
NEXT
PREV1 0.94 0.63 0.94 0.63
ROW 4
NEXT
PREV1 0.94 0.66 0.94 0.65
ROW 5
NEXT
PREV1 0.94 0.7 0.94 0.69
ROW 6
NEXT
PREV1 + PREV2 0.65 0.56 0.64 0.56
ROW 1
NEXT
PREV1 + PREV2 0.81 0.56 0.8 0.55
ROW 2
NEXT
PREV1 + PREV2 0.87 0.58 0.87 0.57
ROW 3
NEXT
PREV1 + PREV2 0.93 0.64 0.93 0.63
ROW 4
NEXT
PREV1 + PREV2 0.94 0.66 0.94 0.65
ROW 5
NEXT
PREV1 + PREV2 0.94 0.69 0.94 0.69
ROW 6
NEXT PREV1 + PREV2 +
0.64 0.56 0.64 0.56
ROW 1 PREV3
NEXT PREV1 + PREV2 +
0.85 0.56 0.85 0.55
ROW 2 PREV3
NEXT PREV1 + PREV2 +
0.95 0.6 0.95 0.59
ROW 3 PREV3
NEXT PREV1 + PREV2 +
0.96 0.61 0.96 0.61
ROW 4 PREV3
NEXT PREV1 + PREV2 +
0.96 0.65 0.95 0.64
ROW 5 PREV3
NEXT PREV1 + PREV2 +
0.95 0.69 0.95 0.68
ROW 6 PREV3

AUTHORS PROFILE
Ritvik is a final year student in Computer Science
Dr Saurabh Gupta works asProfessor in and Engineering Department in Dr. Akhilesh Das
Computer Science and Engineering Department in Institute of Technology & Management affiliated
Dr. Akhilesh Das Institute of Technology & to GGSIPU, New Delhi. He is interested in puzzles
Management affiliated to GGSIPU, Delhi. of all kinds and cracking difficult logical scenarios
and also am an enthusiast in the world of machine
learning.

Vaishali works as Assistant Professor in Computer


Science and Engineering Department in Dr.
Akhilesh Das Institute of Technology &
Management affiliated to GGSIPU, New Delhi.
She has contributed in publishing papers in the
area which includes web attacks, Internet of things,
vulnerability analysis, brief introduction to
machine learning and data mining.

Raghuvansh Tahlanis a final year student in


Computer Science and Engineering Department in
Dr. Akhilesh Das Institute of Technology &
Management affiliated to GGSIPU, New Delhi. He
is interested and enthusiastic in researching the
application of Data Science in the field of Sports
Analytics and Algorthmic Trading.

Navya Sanjna Joshiis a final year student in


Computer Science and Engineering Department in
Dr. Akhilesh Das Institute of Technology &
Management affiliated to GGSIPU, New Delhi.
She is interested and enthusiastic in researching
about design methodologies and formal
approaches in fields of computer science like,
social computing, data analysis and more.

Published By:
Retrieval Number: 100.1/ijrte.E5155019521 Blue Eyes Intelligence Engineering
DOI:10.35940/ijrte.E5155.019521 83 and Sciences Publication

You might also like