BookmarkSubscribeRSS Feed

Time-Series model using Stock Market Data

Started ‎04-11-2024 by
Modified ‎04-11-2024 by
Views 409

To remain ahead of market trends is critical in the fast-paced world of finance, where every action may have a significant impact. Investors, both experienced and inexperienced, are increasingly turning to data-driven solutions to help them negotiate the complexity of the stock market. In this blog, we will explore the tools and approaches that enable investors to make informed judgments in the stock market.

 

Stock market data research is more than just predicting future prices; it is a comprehensive methodology that includes studying past patterns, finding prospective growth possibilities, and reducing risks. The toolkit for studying stock market data has evolved, allowing a varied range of options to investigate.

 

 Load Data

 

We will start by loading in the CSV file, this data was provided by Kaggle. The dataset variable consist of Stock_Date, Open, High, Low, Close, Adj_Close( Adjusted Close), and Volume.

proc import datafile="/cisviya-export/cisviya/homes/Dee.McKoy@sas.com/Blgdata/data/Stock_Market_Dataset.csv"
out=work.marketdata
dbms=csv
replace;
run;

 

data market;
set work.marketdata;
format Stock_Date date9.;
if cmiss(of _all_) then delete;
run;


dm1_Stock-Obs.png

Select any image to see a larger version.
Mobile users: To view the images, select the "Full" version at the bottom of the page.

 

Descriptive Statistics

 

Now that we have an idea of what the data provides, let's take a look at the descriptive statistic.

proc means data=market;
var Open High Low Close Volume;
run;

dm_2_Descriptive_Stock.png

 

From the above Figure we are able to gain some insight into the dataset that we are using in this blog. The means for each variable Open, Low, High , and Close are all range between  35 and 36 for price of the stock. We also see from the descriptive statistic the minimum and maximum of each variable which could help us moving forward in the demo.

 

Visualization

proc sgplot data=market;
series x=Stock_Date y=High / lineattrs=(color=blue) legendlabel='High' datalabelpos=TOPRIGHT;
series x=Stock_Date y=Low / lineattrs=(color=red) legendlabel='Low';
xaxis label='Date';
yaxis label='Price';
keylegend / position=topright;
title 'High and Low Prices Over Time';
run;

 

dm_3_highlow-300x226.png

 

 

The scatter plot with a regression line depicting the High and Low stock market price from 2013 to 2023. The date is represented by the x-axis, while the closing price is shown by the y-axis.  The visualization allows for understanding of how a stock could fluctuate and  what to monitored when a drops in the stock price may occur.

 

data StockMarketData;
set market;
MA10=mean(Close, 10);
format Open d4.2;
run;
proc timeseries data=StockMarketData out=TimeSeriesOutput;
id Stock_Date interval=semiyear setmissing=prev accumulate=average; 
var Open;
run;
proc print data=TimeSeriesOutput;
run;

 

dm_4_Semiyeard-116x300.png

 

The next step of this process was to create a table using the proc timeseries function. This function forms a time series from the input time-stamped transactional data. It can provide results in output data sets or in other output formats by using the Output Delivery System (ODS).


proc sgplot data=TimeSeriesOutput;
series x=Stock_Date y=Open / markers datalabel;
xaxis label='Date';
yaxis label='Average Amount of Open Stock Prices';
title 'Time Series Plot Semi-Year for Open Stock Purchase';
run;

dm_5_Averagestock.png

 

From the Figure, we are able to see the Average cost of each stock on a semi-year. From 2013 through 2015 the stock  average price semi-year decreased until 2017, where the stock average price started to increase until 2020.

 

Conclusion

In conclusion, stock market data analysis is a journey rather than a destination. It's an ongoing process of learning, adapting, and refining strategies based on the ever-evolving nature of financial markets. Whether you are a seasoned trader or a newcomer to the investment landscape, the key lies in continuous education, a keen eye for market nuances, and an unwavering commitment to disciplined decision-making.

 

For more information:

 

Version history
Last update:
‎04-11-2024 01:16 PM
Updated by:
Contributors

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Tags