In this blog we will learn how to extract & analyze the Stock Market data using R!

Using quantmod package first we will extract the Stock data after that we will create some charts for analysis.

Quantmod – “Quantitative Financial Modeling and Trading Framework for R”!

R Package designed to assist the quantitative trader in the development, testing, and deployment of statistically based trading models. It has many features so check out its link.

Check out this app for Quantmod getSymol R Shiny App – Link

R Packages Required:-


Extracting Stock Market Data–

Functions getSymbols: It load and manage data from Multiple Sources.

getSymbols(“SYMBOL”, src=”SOURCE” , from =”YYYY-MM-DD”, to = “YYYY-MM-DD”)

Some src methods are: yahoo, google, oanda etc.

In this blog we will first extract Bombay Stock Exchange Data using yahoo finance source. Bombay Stock Exchange Index/Symbol – BSESN 

1) Analyze One Month Data of Bombay Stock Exchange- 


getSymbols("^BSESN",src="yahoo" , from ="2016-10-23", to = Sys.Date())


Here is the BSESN (xts Object) Output Data. Here you can see different columns having data for Open, High, Low, Close, Volume & Adjusted Stock Price.

High refers to the highest price of the stock touched the same day, Low refer to the lowest price the stock was traded on the same day, Close refers to the closing price of that particular stock and the Volume refer to the number of share traded that day.


Output Charts:- 


As you can see in below chart there was huge dip after 8 Nov 2016, may be this is due to demonetization in India.


2) Analyze One Year Data of Bombay Stock Exchange- 

getSymbols("^BSESN",src="yahoo" , from ="2015-10-23", to = Sys.Date())

chart_Series(BSESN,type = "candlesticks")

Output Chart:-


2) Complete Data of Bombay Stock Exchange– 

It will provide you all data after 2007.


Quantmod has some other features. For more details, please visit this Link.


Happy Learning! Your feedback would be appreciated!

3 thoughts on “Stock Market Analysis Using R

  1. I enjoyed reading this post. I read your articles really often and you
    always find a way to entertain! Shares this to my Facebook and my fans loved it!

    Keep up the good work :)!|
    This is a great post, I read your blog regularly and have
    to say, you have some great content, keep it up!!|
    Amazing article! Very impressed with the quality of this, gotta share
    this to my social medias now! :D!|


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s