0% found this document useful (0 votes)
20 views12 pages

Assignment 4

This paper presents a comprehensive approach to Stock Data Analysis & Prediction, integrating financial analysis with technology to enhance investment strategies. It emphasizes the importance of multi-source data collection and advanced analytical tools, enabling investors to make informed decisions based on real-time insights and curated datasets. The document details various analytical techniques, including Bollinger Bands and candlestick analysis, to help investors navigate market complexities and optimize their investment outcomes.

Uploaded by

Ravi Bhuva
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views12 pages

Assignment 4

This paper presents a comprehensive approach to Stock Data Analysis & Prediction, integrating financial analysis with technology to enhance investment strategies. It emphasizes the importance of multi-source data collection and advanced analytical tools, enabling investors to make informed decisions based on real-time insights and curated datasets. The document details various analytical techniques, including Bollinger Bands and candlestick analysis, to help investors navigate market complexities and optimize their investment outcomes.

Uploaded by

Ravi Bhuva
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

“Stock Data Analysis & Prediction:

Multi-Source Data Collection, Mining,


Pre-processing, and Its Comprehensive
Analysis”
1

Abstract – This paper discusses Stock Data Analysis B. Importance of Multi-Source Data
& Prediction, a Idea that merges financial analysis Collection and Analysis in Stock Market
with technology to aid stock market investors. It
provides a toolkit for data collection, analysis, and Reliance on a single data source or a limited
interpretation, using multiple data sources and range of analytical tools may restrict an
advanced tools. The Idea empowers investors with
investor's ability to recognize opportunities and
curated datasets, algorithms, and real-time insights.
It emphasizes multi-source data analysis, Python, efficiently manage risks in today's dynamic and
web scraping, and their impact on investment fast-paced financial markets. This is where
strategies. Overall, Stock Data Analysis & gathering and analysing data from multiple
Prediction offers a powerful resource for investors sources is crucial.
to optimize decisions and achieve success.

Keywords - Stock Data Analysis & Prediction, Investors can obtain a more
Informed decision-making, Stock market comprehensive understanding of market
investment, Financial analysis, Cuttingedge dynamics, trends, and sentiment by
technology, Comprehensive toolkit, Data collection, utilizing data from various sources,
Data analysis, Interpretation, Multi-source data including stock exchanges, financial
collection, Advanced analytical tools, Investor
news websites, regulatory filings, and
empowerment, Market complexities, Curated
datasets, Sophisticated algorithms, Real-time social media Ideas. As a result, they can
market insights, Trend identification, Risk find previously undiscovered
assessment, Opportunity capitalization, Python, information, recognize new
Web scraping technologies, Informed investment opportunities, and make wise
strategies, Paradigm shift, Investment optimization, investment choices.
Financial success.
In addition, a wide range of factors
I. INTRODUCTION impact the stock market, from company
fundamentals and industry specific
A. Brief Overview of Stock Data Analysis & trends to economic indicators and
Prediction geopolitical events. By using multiple
sources for data collection, investors can
Stock Data Analysis & Prediction is a cutting-
evaluate the influence of market drivers
edge Idea designed to revolutionize the way
on both specific stocks and overall
investors approach stock market analysis. It
market trends.
serves as a centralized hub for accessing a vast
array of financial data, analytical tools, and
Essentially, Stock Data Analysis &
market insights. Developed by a team of
Prediction acknowledges the inherent
seasoned financial experts and data scientists,
worth of gathering and analysing data
Stock Data Analysis & Prediction aims to
from multiple sources when navigating
empower investors of all levels with the
the intricacies of the stock market. The
information and tools needed to make informed
Idea enables investors to stay ahead of
investment decisions.
the curve, adjust to shifting market

1 Student, Department of Computer Engineering, L.D. College Of Eng., Ahmedabad, Gujarat, India
conditions, and ultimately meet their Upper band = x̅ + 2σ ... Equation (iii)

Moving Average = x̅
investment goals by giving them access … Equation (iv)

Lower band = x̅ − 2σ
to a wide variety of data sources and
… Equation (v)
sophisticated analytical tools.

II. DETAILED FINANCIAL


ANALYSIS

A. Overview of curated dataset from the


National Stock Exchange (NSE)

The National Stock Exchange (NSE) is


the source of the carefully selected
dataset that forms the basis of Stock
Data Analysis & Prediction's analytical
capabilities. A sizable collection of Fig.1 Visual Representation of Bollinger Bands along with
historical and current data on stocks, Upper
Band, Lower Band, and Moving Average
indices, and other financial instruments
traded on the NSE is included in this
(ii) Candlestick Analysis
dataset. Stock Data Analysis & Candlestick analysis is a method of
Prediction gives investors a thorough analysing price movements and market
understanding of the stock market sentiment based on the shapes and patterns
environment by compiling information formed by candlestick charts. Each
from a variety of sources, such as stock candlestick represents a specific period (e.g.,
prices, trading volumes, company one day) and contains information about the
financials,and market indicators. opening, closing, and high, and low prices
during that period. By studying patterns such
To guarantee accuracy and relevance, the as doji, hammer, and engulfing, investors
carefully org and dataset is updated regularly. It can gain insights into market psychology and
provides the framework for some analytical anticipate future price movements.
models and tools that Stock Data Analysis &
Prediction offers, allowing investors to perform
comprehensive research and get useful insights.

B. Explanation of Techniques Used (i)


Bollinger Bands
Bollinger Bands are a technical analysis tool
used in stock trading to identify short-term
price movements and potential entry and exit
points. They are a type of price envelope that
define upper and lower price range levels,
plotted at a standard deviation level above Fig. 2 Visual Representation of Candlestick
and below a simple moving average of the
price. The bands widen when there is a price
increase, and narrow when there is a price
decrease.

Standard Deviation .
..Equation (i)

Mean …. Equation (ii)


Fig. 3 Image of various patterns of desired data points such as stock prices, trading
Candlestick
volumes, and other market indicators associated
with TCS's stock.
(iii) Percentage Delivery Analysis The data after cleaning process has shown below.
Percentage Delivery analysis is a As per shown into the image, we are available
fundamental analysis technique with 21 features (columns), which are pre-
used to assess investor interest and calculated.
market liquidity in a particular
stock. It involves calculating the
percentage of shares that are
physically delivered (transferred
from sellers to buyers) relative to
the total volume of shares traded.
High percentage delivery indicates
strong investor confidence and
interest in a stock, while low
percentage delivery may signal
weakness or manipulation.

(iv) Golden Cross Over Signals

Fig. 5 Sample of prepared data for the TCS stock

Now, that data has been prepared, we can easily


and accurately visualize the data using various
charts.

A. Simple Visualization

Fig.4 Visual Representation of Golden Crossover

Golden cross-over signals are a technical analysis


indicator that occurs when a short-term moving
average crosses above a long-term moving
average. This signal is often interpreted as a
bullish sign, indicating a potential upward trend Fig.6 Line graph representation of TCS stock
in the price of a stock or index. Investors use data
Golden Cross Over signals to identify entry The graph in Fig. 5 has been plotted
points for long positions and confirm bullish using the "plot" method if the "pdf"
market sentiment. library. It helps users visualize how
values change over different periods
III. DATA COLLECTION AND in 2020 by clearly and simply
VISUALIZATION displaying the trends or patterns of
the data over time.
We are scraping the data of TCS's stock with the
symbol 'TCS'. Selenium has been employed for
web scraping, allowing us to efficiently retrieve B. Candlestick Representation
real-time or historical data from the web pages
containing the relevant information. Selenium's
capabilities facilitate the automated navigation of
web pages, enabling us to access and extract the
Fig. 6 Code snippet for plotting candlestick offering a more complete picture of
graph of TCS stock
market dynamics during the
data
specified time frame.
This code shown in Fig. 6 selects a
specific portion of the data, Fig. 8 Code snippet of plotting candlestick plot with
focusing on the time period from volume of
May 1, 2023, to July 1, 2023, and TCS stock data
stores it in a new variable called
"data_2023". Then, it uses the
"mpf" library to create a candlestick
chart from this selected data. The
chart displays the open, high, low,
and close prices of a stock for each
day within the specified time frame.
The title of the chart is set to "Stock
Open Price in May - July". The
chart is styled in the 'yahoo' theme,
and its size is adjusted to be 12
inches wide and 6 inches tall.

Fig. 7 Candle Stick representation of TCS stock


data

C. Candlestick Representation but adding


one Volume

The code shown in Fig. 8 snippet


builds upon the code snippet in the
Fig. 6, by adding volume data to the
candlestick chart, giving users
insights into trading activity
alongside stock price movements.
The chart's title reflects this
inclusion, clarifying that it
visualizes both stock open prices
and trading volumes. Additionally,
the layout is optimized for
readability with elements neatly
arranged and an adjusted aspect
ratio providing a broader view of
the data. Overall, the second code
snippet enhances the visualization's
comprehensiveness and clarity,
Fig. 9 Candlestick representation along with volume of TCS
stock data

D. Moving Average SMA 5 & SMA 20

Fig. 10 Code snippet of plotting Moving Averages SMA 5 &


SMA 20

The code shown in Fig. 10 generates a candlestick


chart for TCS stock data from July to December
2020, showcasing the open, close, high, and A. Golden Crossover Signals
low prices for each day during this period.
Additionally, it includes volume bars
underneath the candlesticks, depicting the Fig. 12 Algorithm to analyse Golden Crossover
amount of trading activity. The chart is
further enhanced with moving average lines
Below Figure Fig. 13 shows the tabular
calculated over 20-day and 5-day periods,
form of the outcome, indicating the
providing insights into longer-term trends
optimal points to buy and sell the
and short-term fluctuations. Its title, "TCS -
particular stock within a given time
JAN - DEC(2020)", summarizes the time
frame. This tabular representation offers
frame of the data. With a wide aspect ratio
a clear and concise summary of the
and optimized layout, the visualization
trading strategy derived from the
ensures clarity and readability, offering a
analysis, presenting the recommended
comprehensive overview of TCS stock
actions for investors seeking to
performance throughout the specified
maximize their returns. Each entry in
months.
the table specifies the timing and
conditions under which buying or
selling actions are advisable, based on
the underlying data and methodology
employed in the analysis.

Fig. 11 Graph of Moving Averages SMA 5 & SMA


20 for TCS stock data

IV. ALGORITHMS AND THEIR


VISUALIZATION
Fig. 13 Tabular form of the outcome where to buy lower bands of the Bollinger Bands. This can
and where to sell the particular stock within
be achieved by applying Equation (iii) and
a given time
Equation (v). Equation (iii) helps us
Below shown in Figure Fig. 14 is the determine the upper band by adding two
visual representation corresponding to times the standard deviation to the SMA.
the table in Figure Fig. 13. This visual Conversely, Equation (iv) enables the
depiction offers a more intuitive calculation of the lower band by subtracting
understanding of the recommended buy two times the standard deviation from the
and sell points identified in the tabular SMA. These upper and lower bands serve as
form. Buy signals are indicated by dynamic thresholds, indicating potential
upward-pointing green arrows, while areas of resistance and support in the price
sell signals are represented by movements of the stock. By comparing the
downward-pointing red arrows. current price of the stock with these bands,
traders can gain valuable insights into the
likelihood of price reversals or
B. Bollinger Bands
continuations. The provided code snippet
To calculate the Bollinger Bands effectively, illustrates how to implement these
we begin by computing the mean, which is calculations effectively.
essentially a 20-day moving average of the
closing prices of TCS stock data. This
moving average provides a smoothed
representation of the stock's price trends
over the specified time frame. Equation (ii)
guides us in this calculation. Following this, After completing all the necessary
we determine the standard deviation of the calculations, the next step is to visualize the
closing prices using Equation (i). The Bollinger Bands using the computed
standard deviation quantifies the dispersion variables. This visualization provides a
of the closing prices around the mean, graphical representation of the stock's price
offering insights into the volatility of the movements relative to the upper and lower

Fig.14 Code snippet of calculation of SMA and Standard


Deviation of Closing price of TCS stock data

stock. Together, these metrics form the basis bands. By plotting the closing prices along
for establishing the upper and lower bands of with the upper and lower bands on a chart,
the Bollinger Bands, which assist traders in traders can easily identify potential buying
identifying potential overbought or oversold or selling opportunities based on the
conditions in the market. The code snippet deviation of the current price from these
presented below demonstrates how to bands.
execute these calculations programmatically.

After computing the Simple Moving Average


(SMA) and the Standard Deviation, the next
step involves calculating the upper and
conditions, providing corresponding
dates and closing prices where these
signals are triggered. These signals
serve as valuable indicators for traders,
helping them identify opportune
moments to enter or exit positions based
on the current market sentiment.

Fig.16 Code snippet of plotting Bollinger Bands

Fig.19 Tabular representation of ‘Overbought’ and


‘Oversold’
Signals

A graphical representation of the


Fig.17 Graphical representation of Bollinger Bands 'Overbought' and 'Oversold' signals is
depicted on the graph using upward arrows
of green colour for 'Overbought' conditions
After plotting the graph of the Bollinger and downward arrows of yellow colour for
Bands, the next step is to apply the 'Oversold' conditions. These arrows are
algorithm developed by us to identify strategically placed on the graph at the
the points of 'Overbought' and corresponding points where the signals
'Oversold' on the Bollinger Band graph. occur, indicating to traders the potential
This algorithm utilizes predefined opportunities to either sell (in the case of
criteria to determine when the stock overbought) or buy (in the case of
price deviates significantly from the oversold). This visual representation
Bollinger Bands, indicating potential enhances the readability of the graph and
overbought or oversold conditions in the assists traders in quickly identifying critical
market. By analysing the position of the market conditions.
closing price relative to the upper and
lower bands, the algorithm generates
signals for overbought and oversold
levels.

Fig.20 Graphical representation of


‘Overbought’ and
‘Oversold’ Signals

Fig.18 Algorithm for identifying ‘Overbought’ and


‘Oversold’ signals in Bollinger Band C. Percentage Delivery Analysis
Graph
We are using the data as per shown in Fig.21
which contains specific timestamp and
The table presented below illustrates the %delivery value.
signals for overbought and oversold
represented in the image below,
Fig.24, with highlighted colour.
From the above logic, it can be
determined that stocks of 2023-
05-03 and 2023-05-17 are good
to sell.

Fig. 21 Data of %delivery along with


timestamp
Fig.24 Image denoting %delivery values and timestamp which
Below is the graphical havecontinuously
higher value then 60
representation of data shown in
Fig. 21.

Fig.25 Graphical representation of points having


timestamp
‘2023-05-03’ and ‘2023-05-17’

Fig.22 Graphical Representation of %delivery


data

Now, for percentage delivery


analysis our algorithm checks
that for particular Days
represented in Column-C, if the
percentage delivery is
continuously high for value in
Column-B (i.e., here, we have
taken the base percentage
delivery value as 60) for the
particular stock TCS denoted in
Column-A.

Fig.23 Image showing fixed parameters


for our
%delivery analysis algorithm

From the algorithm in Fig. 26,


If any day has a percentage
delivery value consistently
higher than our fixed value of
60, then it indicates that it is
good to sell the stock. This is
Above shown graph in Fig.25 is graphical
representation of highlighted points in the Fig.24.

Fig.27 Algorithm to calculate Average increment in closing


value of stock and
Average %delivery changed

Below Fig.28 is the output of the algorithm in


Fig.27 by applying on the data present in
Fig.21.

Fig.26 Algorithm of %delivery Analysis

D. PERCENTAGE DELIVERY ANALYSIS WITH FIXING


PARAMETERS

In Topic-C, we have examined the increments that


coincide with the condition established as per Fig.
23. In above topic, we have assessed the amount
of
increase observed in the stock value while the
condition in Fig.23 is true. In this section, in our
final analysis, we calculate the average of the
percentage delivery value and the increment in
the stock value based on its closing value.
Subsequently, utilizing these average values, we
aim to identify a corresponding position to
initiate the sell signal. This process allows us to
refine our trading strategy by considering both
the delivery percentage and the stock value
increment, providing a more comprehensive
approach to decision-making regarding when to Fig.30 Output of Above algorithm
sell.

Here is the algorithm to find the average


increment in Closing value of stock (in %)
and average of %delivery changed by using
fixed window size as 10 and checking the
conditions in Fig. 23.

Fig.28 Output of Above Algorithm


Fig.31 Graphical representation of the
output of above
Now, we are fixing the values of algorithm
Average increment close % and Average
In the final phase, we apply the
%delivery changed parameters by the
Golden Crossover Signal
output generated using the above algorithm to the output obtained
algorithm of Fig.27. from the previous analysis. This
algorithm involves
identifying
instances where the short-
term moving average of the stock
price crosses above the long-term
moving average, signalling a
potential buying opportunity
(Golden Cross). Conversely, when
the short-term moving average
crosses below the long-term
moving average, it suggests a
potential selling opportunity
(Death Cross). By implementing
this algorithm on our output data,
we aim to generate precise buy and
sell signals based on the identified
Fig.29 Algorithm for calculating %delivery crossovers, thereby
based on set enhancing the
parameters effectiveness of our trading
strategy.
By using above algorithm, we
are available with some days
where above condition values,
that we have fixed based on the
output of algorithm Fig.27, are
satisfying.
V. CONCLUSION

In conclusion, the comprehensive stock


market analysis conducted in this report
offers valuable insights into the dynamics of
the market. By gathering data from multiple
sources and meticulously applying pre-
processing techniques, we ensured the
reliability and accuracy of our findings.

The utilization of various analytical methods,


including Bollinger bands analysis, golden
crossover assessment, and percentage
delivery analysis, allowed us to delve deep
into the market trends and identify potential
opportunities for investors.

Moreover, the combined analysis of golden


crossover signals and percentage delivery
provided a holistic view of market
conditions, enabling us to make informed
decisions and recommendations. By
integrating these diverse perspectives, we
enhanced the robustness of our insights and
Fig. 32 Tabular output after applying golden crossover highlighted actionable strategies for traders
analysis algorithm
and investors alike.

Overall, this report underscores the


importance of employing a multifaceted
approach to stock market analysis, leveraging
both quantitative techniques and qualitative
insights. By staying vigilant and adaptive to
market dynamics, investors can navigate
Fig.33 Graphical representation of above tabular output uncertainty more effectively and capitalize on
emerging opportunities.

Below image Fig.34 is the graphical


VI. FUTURE SCOPE
representation of both algorithm’s
outcomes: %Delivery analysis and The future scope based on the findings of this
Golden Crossover Signal Analysis, analysis holds significant potential for further
combined. exploration and application. Advanced
analytical techniques, such as machine
learning algorithms and sentiment analysis,
could enhance market predictions, while real-
time data integration and sector-specific
analysis may provide timely insights into
evolving market conditions and tailored
investment strategies. Developing
Fig.34 Combined graphical representation of the
output of both algorithms: %delivery analysis sophisticated risk assessment models and
and golden crossover signal analysis incorporating insights from behavioural
finance could offer comprehensive risk
management approaches and a deeper
understanding of investor behaviour.
Additionally, integrating alternative data [3] “IncredibleCharts,” [Online]. Available:
https://www.incrediblecharts.com/candlestick_patter
sources and expanding the scope of analysis ns/candlestickpatterns.php. [Accessed 23 04 2024].
to global markets could provide novel
insights and opportunities for portfolio [4] Pang-Ning Tan, Micheal Steinbach and Vipin
Kumar, Introduction to Data Mining, Pearson India
diversification. Embracing these avenues for Education Service Pvt. Ltd..
future development could enhance the
[5] T. W. Khairi, R. M. Zaki and W. A. Mahmood,
sophistication and effectiveness of stock
“Stock Price Prediction using Technical,
market analysis, empowering investors to Fundamental and News based Approach,” in
make more informed decisions and achieve Scientific Conference of Computer Sciences (SCCS),
2019.
their financial objectives.
[6] Y.-S. Tsai, C.-P. Chang and S.-W. Tzang, “The
Impact of Golden Cross and Death Cross Frequency
VII. ACKNOWLEDGEMENT on Stock Returns in Pre- and Post-financial Crisis,”
in International Conference on Innovative Mobile
and Internet Services in Ubiquitous Computing,
This work is ostensibly supported by 2018.
our professors. We also could not
have undertaken this journey without [7] J. Bollinger, “Using Bollinger Bands,” Stocks &
Commodities, vol. 10, no. 2, pp. 47-51.
our defence committee, who
generously provided knowledge and [8] Chaimaa Lotfi, Swetha Srinivasan, Myriam Ertz and
expertise and their continuous Imen Latrous, “Web Scraping Techniques and
Applications: A Literature Review,” in SCRS
feedback and scholarly input have CONFERENCE PROCEEDINGS ON
significantly contributed to this INTELLIGENT SYSTEMS, 2021, pp. 381-394.
journey of research. I am equally
grateful to my classmates and cohort
members, whose incredible support
has been a source of strength and
inspiration throughout this
unforgettable journey. Special thanks
are due to my dear mates, for their
invaluable editing assistance,
latenight feedback sessions, and
moral support.

Lastly, we would be remiss in not


mentioning, our family, especially
our parents, sisters, and almighty
god. Their belief in me has kept my
spirits and motivation high during
this entire process. Last but certainly
not least, we want to express our
deepest gratitude to each other.
Together, we have overcome
challenges, celebrated milestones,
and forged a bond that extends
beyond the confines of academia.

REFERENCES

[1] “Britannica Money,” [Online]. Available:


https://www.britannica.com/money/bollinger-bands-
indicator. [Accessed 27 04 2024].

[2] “DAILYFX,” IG, [Online]. Available:


https://www.dailyfx.com/education/moving-
averages/golden-cross.html. [Accessed 25 04 2024].

You might also like