Options Tradingusing Artificial Neural Network
Options Tradingusing Artificial Neural Network
net/publication/365827094
CITATIONS READS
0 713
5 authors, including:
Rashmi Welekar
Shri Ramdeobaba college of engineering & management, Nagpur
34 PUBLICATIONS 103 CITATIONS
SEE PROFILE
All content following this page was uploaded by Rashmi Welekar on 01 April 2023.
Predicting stock market movements is a well-known problem of interest. Financial markets employ a staggering
amount of sophisticated and complex technologies for getting efficient results while trading. Algorithmic trading
(AT) is one of the major steps in this direction as it is gaining wide acceptance in the global market. There are
various Computational intelligence models that have produced a significant number of results over a period of
time. Some of them are neuro fuzzy models, systems based on genetic algorithm and support vector machines
(SVM). Every day a huge volume of data is produced from Dotex International Limited which is also known as
NSE Data Analytics Ltd. This data contains all the factors which more or less directly affect the movement of the
market. A stock market is a complicated system which attract a lot of people everyday but there have been many
instances where people have lost their entire life savings within a day specially while trading in options. Hence,
it requires a lot of knowledge and one should be able to control his emotions while trading. Usually, newbies
consider stock market as a money vending machine and jump into it directly without even knowing the basics of
it. Every one knows that one who can predict the momentum of market is the real king of this game and thus we
have made an attempt for predicting the trend of the stock market. Two models are built, one for daily forecast
and one for monthly forecast.
Keywords: Artificial neural network, Stock market, multi layer perceptron, algorithmic trading,
technical analysis
1. INTRODUCTION
Accurate prediction of stocks is one of the most important factors the investor must consider
before investing their hard-earned money in the stock market. There are Multiple factors that
affect the price of any stock like market conditions, demand and supply, interest rates. As a
result of which there is a larger amount of data in which we have to find the patterns. Various
market experts and researchers are always involved in finding various techniques to maximize
the profits. Thus, algorithmic trading has evolved over the years which uses automated trading
strategiesThe remainder of this paper is organized as follows. Section 2 describes an overview
of Model Features,followed by an overview of Evaluation which includes data collection and pre-
processing in Section 3. Section 4 discusses Model training and section 5 about the modelling
and prediction.
2. MODEL FEATURES
a) Relative Strength Index (RSI)
The Relative Strength Index (RSI) is a momentum predictor technical indicator. On the y-
axis of the RSI indicator, values range from 0 to 100.Usually, this range of values helps the
trader to predict whether the stock is in the overbought or oversell stateWhen the value of
RSI has value above 70, it indicates that the stock is now in overbought state and those people
who are buying it are paying more than what it actually deserves. When the value of RSI has
value below 30, it indicates that the stock is now in oversold state. It also indicates a state of
panic where people are selling the stock blindly based on some news. All this are the rough
estimates and can’t be said as a sure shot strategy to predict the buying or selling(Araujo and
Ferreira, 2013) (Kim., 2003).
b) Moving Average Convergence and Divergence (MACD): The MACD indicator which
is moving average convergence and divergence is one of the technical indicator used to detect
International Journal of Next-Generation Computing - Special Issue, Vol. 13, No. 5, November 2022.
Options Trading using Artificial Neural Network and Algorithmic Trading · 1287
the trend along with the momentum.While trading when we use MACD, when the value is
above 0 then we consider it as a bullish momentum whereas when the value is below 0 then
we consider it as a bearish momentum. Usually, MACD is considered to be a better option
when we trade on time frame of a week or month as compared to intraday trading.
c) Bollinger Bands: The Bollinger bands plotted over the candles consists of 3 bands viz.
upper, middle and the lower band.
✓ Middle band is plotted based on the moving average. Moving average is calculated by
adding all the previous data points and then dividing it by n
✓ The upper and lower band is calculated by adding and subtracting the standard deviations
to the Moving Average respectively.(Jireh Yi-Le Chan, 2022)(S Z Mahfooz, 2022)
The Bollinger bands are plotted based on the market volatility so it is generally considered that
if the two bands are squeezing then the market seems low volatile. Bollinger bands are generally
used as a combination with any other indicator like RSI or MACD as per the trader’s choice and
preference.(J. Wang and Guo, 2011)(F. Zarandi and Neshat, 2009)
3. EVALUATION
3.1 Data Collection
The live data for trial testing was obtained from the NSE website and money control API.For
obtaining the data in real time, Trigger time of a minute was set and every minute a particular
code was triggered that used to fetch data from the money control site.
We have to call the Ticker module to access ticker data. Fig.2. shows how the sixty days of
NSEI data of interval 15 minutes can be retrieved and saved as .csv file, while fig.3. shows the
sample of fetched data. There are more params we can set for the history () method as seen in
fig.
International Journal of Next-Generation Computing - Special Issue, Vol. 13, No. 5, November 2022.
1288 · Rashmi Welekar et al.
The data used for training the model was fetched from yahoo finance site which consists of 4
attributes viz. open, high, low, close. The data was the data was trained from 01-01-2015 till the
date with one day interval. For prediction based on live data, the interval was of 1 day having 1
minute time frame.
3.1.1 Data Pre-Processing. For modeling purposes, we fetched data from Nifty site using
Pandas library. Column mismatch was faced where the forecasting and predicting data columns
were not matching. To resolve this, we separated the forecasting and prediction data. We chose
International Journal of Next-Generation Computing - Special Issue, Vol. 13, No. 5, November 2022.
Options Trading using Artificial Neural Network and Algorithmic Trading · 1289
the minimum number of columns (Open, high, close, low and volume for forecasting) as possible
for training our model. To manipulate data, we used Pandas library.
4. MODEL TRAINING
The data has been fetched using Yfinance library Contains 6 attributes – Open, Close, Adj Close,
High, Low, Volume. Unwanted “Adj Close” column was dropped. Preprocessing was done using
sklearn (MinMax scaler). Seq. LSTM model. Batch size – 64, epochs - 1000 First, based on
‘Close’ attribute. Second, based on all 5 attributes, i.e., features (Finalized model). The finalized
model was tested on the 20 percent dataset entries (80:20) that gives accuracy of 70.77 percent.
Using this model, forecasting was done for the next 5 days market closing price, by analyzing
previous 28 days data. By comparing with the original data, the accuracy lied between 40-
70 percent, as it also considers the rapid fall or rise of the market during weekly opening day
(Monday). This trained model was saved in .h5 and .json format, and loaded at the time of
forecasting.
Finally, the data has been fetched using Yfinance library. This data contains 6 attributes –
Open, Close, Adj Close, High, Low, Volume. The time period is 1 day and interval 1 min. The
graph was plotted using plotly and matplotlib libraries. Applied indicator for algorithm trading
– Bollinger bands (70 percent accuracy) and MACD. PUT/CALL signals are generated based
on the indicators individually. The plots will be plotted individually. Based on the method,
PUT/CALL signals will be generated.
The graph was plotted using plotly and matplotlib libraries. Applied indicator for algorithm
trading – Bollinger bands (70 percent accuracy) and MACD. PUT/CALL signals are generated
based on the indicators individually. The plots will be plotted individually. Based on the method,
PUT/CALL signals will be generated. It is recommended for the user to gain some insight about
intraday option trading, so that they can analyze the plot and go for the CALL/PUT option All
the phases of methodology applied in the backend part. Model was trained based upon the five
parameters. (Close, Open, High, Low, Volume).
(1) Single entity based on “Close” attribute which showed high accuracy while training and
testing on test data. As you can see,loss and valloss of the trained model is extremely, which
means high accuracy.
The output of the trained model on the “Close” parameter gives high accuracy on the test
dataset (refer Figure 4.), but in real life it fails, as a single entity cannot determine the
“Close” parameter.
(2) The output of the trained model on the all 5 parameters gives high accuracy on the test
dataset, also in real life, there is need of all 5 parameters for the prediction, and hence it
shows good results in real life scenario too. Epoch cycle was 1000, and the applied model
is sequential-LSTM. So, what we tried is to forecast the upcoming trends based on all 5 pa-
rameters (Open, High, Low, Close, Volume)(Liao and Wang, 2010)Park and Shin [2013].Our
OTP model shows the accuracy of 40-70 percentage, on real time evaluation. While on the
test dataset it shows70.75 percent (Figure 5). This variation in accuracy is due to following
reasons.
✓ Sudden disruption in the market due to the current Ukraine war crisis.
✓ The data that we fetch from the NSE site is not continuous. It is obtained for every five
days due to which it is difficult for the model to differentiate the data of one week from
the other one.
International Journal of Next-Generation Computing - Special Issue, Vol. 13, No. 5, November 2022.
Options Trading using Artificial Neural Network and Algorithmic Trading · 1291
In Figure 6-., as the plot interprets, if 2-3 candlesticks touch Upper band or Lower band, go for
PUT or CALL. We can show indicators on MACD and Bollinger Bands (Figure 7 and Figure 8),
but it is preferred to go through this live plot, as the indicators may result you net profit zero as
only a few predictions were correct (use of pandas trading library), while your own observation
from the live graph will give you accurate results.
International Journal of Next-Generation Computing - Special Issue, Vol. 13, No. 5, November 2022.
1292 · Rashmi Welekar et al.
6. CONCLUSION
Option trading or any other market trading is mainly focused on three vital points.
(1) Presence of historical data, to analyze the market behaviour.
(2) Availability of accurate live data, which on which you will do the trade, with the help of
trading algorithms and indicators.
(3) Market sentiments, to see how the market is reacting. These all points are analysed and dif-
ferent approaches are applied which resulted in an open-source tool (named as Open Trading
Prediction model), provides us an accuracy range of overall 40-70 percentage for option trad-
ing. This open-source tool can be further developed as a product platform with availability
of custom dataset creation which can merge all the vital points in a single model.
References
Araujo, R. and Ferreira, T. 2013. A morphological-rank-linear evolutionary method for
stock market predictions. Information Sciences, 3–17.
F. Zarandi, B. Rezaee, I. T. and Neshat, E. 2009. Forecasting model of global stock
index by stochastic time effective neural network. Expert Systems with Applications 36,
pp.139–154.
J. Wang, J. Wang, Z. Z. and Guo, S. 2011. Forecasting stock indices with back propagation
neural network. Expert Systems with Apps. 38(11), pp.14346–14355.
Jireh Yi-Le Chan, Seuk Wai Phoong, W. K. C. Y.-L. C. 2022. Support resistance levels
towards profitability in intelligent algorithmic trading models.
Kim., K. 2003. Financial time series forecasting using support vector machines. Neurocomput-
ing 55(1–2), pp.307–319.
Liao, Z. and Wang, J. 2010. Forecasting model of global stock index by stochastic time effective
neural network. Expert Systems with Applications, 37(1)), pp.834–841.
Park, K. and Shin, H. 2013. Stock price prediction based on a complex interrelation network
of economic factor. Engineering Applications of Artificial Intelligence 26, pp.1550–1561.
S Z Mahfooz, Iftikhar Ali, M. N. K. 2022. Improving stock trend prediction using lstm
neural network trained on a complex trading strategy. Expert Systems with Applications.
International Journal of Next-Generation Computing - Special Issue, Vol. 13, No. 5, November 2022.
Options Trading using Artificial Neural Network and Algorithmic Trading · 1293
International Journal of Next-Generation Computing - Special Issue, Vol. 13, No. 5, November 2022.