Your prayers were heard ;-) The following article gives you all you need, especially the function getOptionQuote() which lets you download option chains for any ticker symbol with one line of code!
You find the article here (with full R code):
Well, it wasn't easy because you didn't mentioned how your data is formatted. I create my own data.frame() basing on data you provided.
You can skip this part if your data.frame is ready. Here's code I used to create a dataframe:
> #given dates
> #formating ...
There is no such thing as "free" option data.
This is free -->http://www.nasdaq.com/symbol/aapl/option-chain
You could crawl that.
But to get the actual ticks or intraday data, you will unfortunately have to pay. I strongly suggest you find a college business program that has option data ticks and reach out to them.
Best of luck,
You cannot add a date column to an object returned by getSymbols or get.hist.quote. These function return matrices. Matrices can only store data of the same type, in this case the matrices contain double values (real numbers).
You can add a column of class Date to the objects if you transform them into a data frame:
p <- median(diff(.index(x)))
stop("can not calculate periodicity of 1 observation")
p can be NA if x has 1 observation, or if you have missing values in your index (because there's no na.rm=TRUE in the median call.
> xx <- xts(1:10, as.POSIXct(c(1:5,NA,7:10),origin='1970-01-01'))
Error in ...
Speaking about portfolio optimization in general, historical data is required to estimate the variance-covariance matrix that gives you the volatilities of the stock returns and the covariances thereof. The estimation depends on the periodicity of your returns, i.e. whether you are using intraday, daily, weekly, or monthly returns. (For intraday/daily ...
I don't have perfect solution for above problem, I but can help you out with the alternative. As far as my information you can't download the data country wise. I was also looking for the same. You should have all the symbols first in place. I have prepared a small code which loop through the all available symbols and get historical data from Yahoo.
When writing getSymbols(ticker) the function is creating an xts object in the global env named by the ticker. In the first iteration, when i = 1, ticker is a character, "AAMC".
Next, when you are trying to get the monthly returns for that newly created xts object, monthlyReturn(ticker, subset='2017-11-10') you are referencing the character, not the newly ...
It turns out the answer is quite simple!
I just needed to adjust the "lapply" function correctly such that:
QuarterlyReturns <- lapply(Prices, quarterlyReturn, USE.NAMES = TRUE)
Now the calculation works perfectly fine.
I'll be using tidyquant version 0.3.0 to answer this question, which changes from x_fun to ohlc_fun in tq_mutate and tq_transform and adds the new col_rename argument to solve situations like yours with non-intuitive column names.
Part 1: How do I transform the Closing stock prices to weekly?
You are using the periodReturns function from quantmod, and you ...
I agree with everything dnl said. This time period choice can get very involved. You are explicitly choosing an historical period that you think will be repeated in the future. Unfortunately, history does not repeat exactly. There is an old saying, all models are wrong, but some are useful. There is no right answer for the period. Should you include just a ...
Your premise that there should be no data is incorrect. The foreign exchange market is an over-the-counter market, so there is no official definition of a trading day and the market never officially closes. The fact that you see some data on weekends is because OANDA never stops collecting data. There is nothing to prevent any of the parties who report ...
The following answers the initial question:
To get a comprehensive list of all data series on FRED you can leverage the FRED API, and in particular the following calls:
You can start with the root category (id = 0) and traverse the category tree for the metadata including the series symbols.