In this set of exercises we shall explore possibilities for fundamental and technical analysis of stocks offered by the
quantmod package. If you don’t have the package already installed, install it using the following code:
and load it into the session using the following code:
Answers to the exercises are available here.
If you have a different solution, feel free to post it.
Load FB (Facebook) market data from Yahoo and assign it to an xts object
Display monthly closing prices of Facebook in 2015.
Plot weekly returns of FB in 2016.
Plot a candlestick chart of FB in 2016.
Plot a line chart of FB in 2016., and add boilinger bands and a Relative Strength index to the chart.
Get yesterday’s EUR/USD rate.
Get financial data for FB and display it.
Calculate the current ratio for FB for years 2013, 2014 and 2015. (Tip: You can calculate the current ratio when you divide current assets with current liabilities from the balance sheet.)
Based on the last closing price and income statement for 12 months ending on December 31th 2015, Calculate the PE ratio for FB. (Tip: PE stands for Price/Earnings ratio. You calculate it as stock price divided by diluted normalized EPS read from income statement.)
write a function getROA(symbol, year) which will calculate return on asset for given stock symbol and year. What is the ROI for FB in 2014. (Tip: ROA stands for Return on asset. You calculate it as net income divided by total asset.)
- Become a Top R Programmer Fast with our Individual Coaching Program
- Explore all our (>4000) R exercises
- Find an R course using our R Course Finder directory
- Subscribe to receive weekly updates and bonus sets by email
- Share with your friends and colleagues using the buttons below