Ijraset Journal For Research in Applied Science and Engineering Technology
Authors: Sushmitha Popuri
DOI Link: https://doi.org/10.22214/ijraset.2023.56196
Certificate: View Certificate
Data is a significant driver for several business decisions in this current era due to advent of big data and Stock markets are a great playground for deep learning and AI due to their high uncertainty. Although there are several tools in the market that aim to predict the future stock values with a prediction accuracy of almost 85%, none of them is fool proof and pave way and create scope for better accuracy. The current suite of tools predicts intraday buy /sell prices but are not capable of generating the pattern of day trade and stock swing, which when predicted, can generate 12X revenues for a full-time trader. The work focuses on the intraday trend and aims to predict the flow of Intraday trade, to gain larger profits and minimize losses in time in case of adverse conditions.
I. INTRODUCTION
Stock markets are the place where various parties including (but not limited to) governments, private entities trade stocks of listed entities, currencies, derivatives with the sole motive of making profits. However, there are several factors driving the price of a stock. The stock market is primarily driven by sentiment of their investors and general public. Since its inception, there is humungous amount of data piled up, making it a viable use case for using machine learning to drive more profits. The motive of this research is to create a solution which can assist traders earn better profits.
After observing the dataset of the stock, it was understood that the stock of any entity, at any given point in time has a significant influence of its past performance. There are several factors that can be considered for determining the current position of the stock, and each attribute has its own significance. The attributes of Open price of the day, Close price of the day, High Price of the current day, High price of the current week, Low price of the current day, Low price of the current week and Volume of trade, clearly signify the sentiment of the general public as they are the derivatives of the market activity of that stock. Volume signifies the interest of the stock in general public either in a positive sense or in a negative sense. These handcrafted features have been selected to be a part of the algorithm adopted.
While there are many ways of analysing the stocks and leveraging the analysis for maximizing profits, the scope of this research is limited to using the past performance of the stock to efficiently predict its current behaviour. Technical Analysis is purely based on analysing the stock based on its past performance. Market history is a key characteristic that can help investors decide the future performance of a stock. Technical analysis depends on plotting the stock’s price characteristics like Open price, close price, week’s highest traded price and volume and identifying a sequence or a pattern from them. Often there is a pattern which can be identified and in cases where it is not identified, they become a helpful tool for further analysis in conjunction with fundamental analysis.
Technical analysis relies on a fact that several indicators determine the price of a particular stock. Several indicators aid an analyst to predict a stock’s price.
II. ANALYSIS TOOLS AND STRATEGIES IN EXISTANCE
There are several indicators to determine the entry and exit price for intraday trade. However, none of them are close to predicting the entry and exit time for the same.
A. 200 Day Moving Average Indicator
The average of the closing price of the stock for the last 200 days is taken into consideration to determine the performance of the stock the future scope on benchmark for return of Investment and margins. To have enhanced accuracy, exponential average (EMA) might be considered instead of Simple average. There are other flavours of moving averages apart from Simple moving average and exponential Moving average like WMA (Weighted Moving Average), TEMA (Triple exponential moving average)
This moving average indicator is not applicable to analyse on Intraday trends as its sensitivity increases with a decrease in the time span, and a reduced sensitivity is more likely to reduce accuracy of prediction due to generation of false positives.
B. Relative Strength Index
This determines the strength and performance of a stock by analysing its closing price for a specific duration of time and computing its momentum of profits and losses. Relative Strength is the extend of average Profit over average Loss. 14-day RSI is mostly used, which estimates the strength of the stock basing on the past 14 days of data.
The indicator is extremely useful to identify the saturation level of stock trade in the market, i.e., identify if a stock I overbought or oversold, but it isn’t enough to make a trade decision on whether to buy or sell the stock is left to the discretion of the trader.
C. Moving Average Convergence Divergence (MACD)
MACD, moving Average Convergence Divergence indicator (MACD) is a comparison between Moving average indicators of different lengths. In general, the relation between 12 – day Moving average indicator and 26-Day moving average indicator with reference to 9- day moving average indicator. The last line crossing the Slow line reflects a shift in momentum. The MACD line above and below the signal Line indicates a bearish and bullish trend respectively. The amount of divergence of MACD from signal line is relative to the deviation of price from current trend. Also, a sudden deviation between the slow and fast MAs mean that the stock is either over bought / oversold, and the market would regain its stand soon.
The limitation with this indicator is that it fails in case of unusual price surges or drops and is thus highly unreliable and inaccurate to make trade decisions for volatile stocks.
III. ML AND AI IN STOCK PREDICTION
With the advent of technology Era, Machine learning and Artificial Intelligence have become the ultimate solution to attain perfection in any field. Conventional Techniques are quite promising but not accurate.
S No |
Prediction |
RMS Value of Deviation |
1 |
Prediction with Moving Averages |
7.87 |
2 |
Prediction with Regression |
6.91 |
3 |
Prediction with rNN |
3.08 |
A. Shortcomings of Existing Analysis
While fundamental analysis considers traders sentiments, emotions and true value of the company it alone cannot be used to determine the stock prices. Technical analysis’s beauty is its versatility. Despite of having several tools to predict stock prices, there is still a significant gap between the actual price and prediction of stock prices due to reasons like not having the capability to analyse humungous amount of historic data in real-time as every second, the price of the stock might change.
Several applications have employed rNN (Recurrent Neural Networks) in stock prediction from micro to macro level. However, the current tools employ it in a default way without any customizations. The research proposes to employ model rectification based on error coefficient. While the current systems consider daily trade data to predict and analyse meaning it fails to capture intraday trends thereby failing the use-case of fundamental analysis. This also impacts the negative market days pushing investor into huge losses.
IV. STOCK PRICE PREDICTION USING LSTM
LSTM is a form of recurrent neural network used for time series data analysis and sequential data processing. he input activation is done by input gate where it accepts inputs and feeds the memory cells. Memory cells contain connections which stores the temporal state of the network along with the gates to control the flow of information. The output gate controls the outward cell activation into the rest of the network and a forget date is present which scales the internal state of the cell before adding it back to the previous cell as input through self-recurrent connection, therefore adaptively forgetting or resetting the cells memory. The working memory or hidden state function reforms itself basing on a sequential pattern that was fed in the latest input, thereby adjusting and accommodating the latest trend changes to improve the prediction accuracy.
In a simple RNN with a sigmoid or tanh neuron units, the output nodes of the network are less sensitive to the input at time t=1. This is because of the vanishing gradient problem. An LSTM allows the preservation of gradients. The memory cell remembers the first input if the forget gate is open and the input gate is closed. The output gate provides finer control to switch the output layer on or off without altering the cell contents.
When compared with other RNN’s and hidden Markov models, LSTM has an advantage over them due to the relative insensitivity to gap length. LSTM can remove or add information to the cell state which is carefully regulated by gates. The output of the forget gate tells the cell which information to forget by multiplying 0 to a position in the matrix. If the forget gate’s output is 1, the information is kept in the cell state. The weighted observation and the previous hidden state are composed out of a sigmoid neural net layer and pointwise multiplication operation.
V. IMPLEMENTATION
A. Data Procurement
1-minute ticker data for some stocks is collected from Alpha vantage in JSON format and is stored in Excel sheets for one week period, to accumulate ~400 data points per day. The stocks under consideration are CANBK (Canara Bank), AXISBANK (Axis Bank), SBIN(State Bank of India), BANKBARODA(Bank of Baroda), ICICIBANK(ICICI Bank), HDFCBANK(HDFC Bank), INDUSINDBK(Indus Ind Bank), PNB( Punjab National Bank), YESBANK (YES Bank), FEDERALBNK (Federal bank) from NSE(National Stock Exchange).
B. Data Storage
The procured data is loaded to a PostgreSQL database using a python script, to map JSON object to table schema. Open Price, Close Price, High, Low, Volume are some of the extracted attributes.
C. Data Cleaning
By leveraging the DBScan technique, the data is cleaned in the initial stage. By using K-means, outliers are smoothed to adjust to normal range and obtain a smooth data curve. The timestamps are converted from EST to IST. Finally, the junk data is deleted, and sudden peaks and valleys are replaced by their exponentially moving average for last 60 minutes.
D. Analysis of Factor Significance
It was learnt that despite having several features that determine the trade state of a stock, three factors namely Open Price, close price and volume are the most significant among them. Open price and close price will help in determining the average unit price of the stock and in this case it’s one minute. Analysing the volume trends provides gainful insights and with the intraday patterns would help determine when the trader can enter a particular stock and when the trader can exit to maximum profit with the same investment.
E. Computation of Utility Indicators using Data Mining Techniques
Upon analysing the patterns for Intraday trading using clustering of weighted averages, it was observed that accurate signal of SELL or BUY can be decided by analysing the first 20 minutes of trade data. The performance of the stock for the entire day can be determined with the first 20 minutes performance. It was also observed that if a stock trades above the exponential weighted moving average of that stock, then it is likely to trade in positive trend indicating a BUY signal prediction. Similarly, if a stock opens below the exponential weighted moving average of that stock, it is likely that a negative trend is present, and a SELL signal is generated.
The range of stock fluctuation for the day, entry and exits are not clearly specified by the 20-minute ticker data. Few algorithms have been used to determine the same. Determining the intraday trading patterns can be done by analyzing previous day trade patterns.
F. Effective Indicator Utilization for Prediction
There are several indicators in the current day trade for extracting inferences and generating stock predictions. Some of the indicators leveraged are Moving Average, Exponential Moving average, Fibonacci zone, pitch form indicator, trend line generator and so on and so forth. But not all of them are useful and accurate in predicting the intraday trend or analysing and adjusting based on sudden fluctuations during the trade. Hence proposing a new indicator that would memorize the stock trading pattern, fit accordingly and adjust accordingly to predict the ups and downs of a particular stock.
G. Assessment of Indicator Strength using Machine Learning
The indicator for the trade is the volume weighted average of the stock traded for the first 20 minutes of the trade day. That indicator is extrapolated based on trend pattern of that stock. The Root Mean Square Error is computed, and the LSTM process is reiterated along with the current predicted data post adjusting to minimize RMS to enhance model accuracy. Leveraging NLP to understand market movement and trade emotions. Market sentiments and trader emotions are one of the key indicators in determining the price of the stock. But the key aspect which technical analysts fail to understand and analyse is that market and thereby trade is driven by emotions and sentiments. Understanding market sentiments is a cup of tea for fundamental analysts, however, they fail to predict actual values. Hence, popular finance websites like moneycontrol and platforms like facebook page of CNBC, moneycontrol which impact trades and stock are crawled using web crawlers like scapy, mechanize and the traders’ comments and reactions are captured. They are pre-processed and classified whether they are positive or negative. Accordingly, the signal can be predicted if the market is positive towards a particular stock.
H. Prediction of calls (buy/sell)
Initially, data is collected and stored in the database. It is cleaned, by removing outliers that are insignificant enough to not run into losses. Once that is complete, the data is processed to ensure compliance with the first 20-minute trade logic. The next step is to predict and give a signal: BUY or SELL. Based on the call for that day, extrapolating the data to generate current day’s trend is done. In Parallel, websites such as moneyControl.com are continuously checked for any news related to that stock. Any news found is subjected to classification, to check if it impacts trading, if yes, in what way. If there is no significant impact, the traders are confidently advised to proceed with trading. In case of adverse situations, there is a warning indicator that alerts the traders well before the transaction is done, by providing the risk indicator. Basing on the above process, the intraday trades are predicted for a particular stock.
I. Results
The above process is implemented, in different standalone modules starting from collecting Data, cleaning it, processing and storing in the database. Intraday stock trends are predicted for Canara bank (CANBK) stock. The graphs beneath showcase training data with blue plot, Prediction Data with Orange Plot and Actual Data with Green Plot.
VI. ACKNOWLEDGMENT
This research work is carried out under the supervision of Department of Computer Science Engineering, BITS WILP.
Stock market is gambling if a proper analysis is not followed. Certain precautions and little insight into the stocks past performance helps achieve significant results in trading. One can earn maximum profits with minimum to low risk, by leveraging the above analysis technique.
[1] Sudheer, V. \\\"Trading Through Technical Analysis: An Empirical Study from Indian Stock Market” International Journal of Development Research Vol. 5, Issue, 08(2003): 5410-5416 [2] C. Boobalan. “Technical Analysis in Select Analysis of Indian Stocks of Indian Companies” IJBARR vol2-issue4(2014):26-36 [3] Hemal Pandya. “Technical Analysis for Selected Companies of Indian IT Sector” International Journal of Advanced Research, Volume 1, Issue 4(2013): 430-446 [4] Kunwar Singh Vaisla.” An Analysis of the Performance of Artificial Neural Network Technique for Stock Market Forecasting” International Journal on Computer Science and Engineering Vol. 02, No. 06(2010): 2104-2109 [5] Kalyani Dacha “Causal Modeling of Stock Market Prices using Neural Networks and Multiple Regression: A Comparison Report” Finance India, Vol. xxi No.3(2007):923-930. [6] https://www.investopedia.com/articles/active-trading/062315/using-bullish-candlestick-patterns-buy-stocks.asp [7] https://stockcharts.com/school/doku.php?id=chart_school:overview:technical_analysis [8] https://www.thebalancemoney.com/best-technical-indicators-for-day-trading-1031208 [9] https://school.stockcharts.com/doku.php?id=overview:technical_analysis [10] https://www.daytrading.com/technical-analysis [11] https://www.investorsunderground.com/technical-analysi
Copyright © 2023 Sushmitha Popuri. This is an open access article distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.
Paper Id : IJRASET56196
Publish Date : 2023-10-17
ISSN : 2321-9653
Publisher Name : IJRASET
DOI Link : Click Here