Question
Find any stock you want to research. You can find ticker symbol from Google, Yahoo! Finance, MSN money, and so on (i.e. The ticker symbol
Find any stock you want to research.
You can find ticker symbol from Google, Yahoo! Finance, MSN money, and so on (i.e. The ticker symbol of Apple Inc. is "AAPL"). - Run the following steps.
1) Install package 'quantmod' and load it. install.packages("quantmod") library(quantmod)
2) From Yahoo! Finance, download daily prices of the stock (from Jan. 1, 2000 to Dec, 2018) you selected to research. Note that you have full length of daily prices. If not, consider other stock.
3) Obtain monthly log stock returns. For instance, if you decide to do research on Apple Inc. whose ticker is "AAPL", then you will need to run the following: AAPL.rtn <- monthlyReturn(AAPL$AAPL.Adjusted, subset=NULL, type='log', leading=TRUE)
4) Change the data type to ts. Again, for example, if you decide to do research on Apple Inc., rtn <- ts(AAPL.rtn, frequency = 12, start = c(2000,1))
I have downloaded AAPL stock prices from 01/01/2000 to 12/31/2018 and created my AAPL vector in r studio. I am trying to get monthly log stock returns using the code AAPL.rtn <- monthlyReturn(AAPL$AAPL.Adjusted, subset=NULL, type='log', leading=TRUE) and I receive and error message saying Error in try.xts(x) :
Error in UseMethod("as.xts") :no applicable method for 'as.xts' applied to an object of class "NULL".
What am I doing incorrectly?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
The error message youre encountering suggests that the object youre trying to pass to the monthlyRet...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started