Option pricing, basic question
Hello Frank / all,
the getSymbols() code written down before in relation to my option
pricing question (see citation below)
somehow did not work with me. I got
library(quantmod)
Version 0.4-0 included new data defaults. See ?getSymbols.
Warning messages:
1: package .quantmod. was built under R version 2.14.2
2: package .Defaults. was built under R version 2.14.2
getSymbols('DGS3MO', verbose=TRUE,src='FRED')
As of 0.4-0, .getSymbols. uses env=parent.frame() and
auto.assign=TRUE by default.
...
trying URL
'http://research.stlouisfed.org/fred2/series/DGS3MO/downloaddata/DGS3MO.csv'
Error in download.file(paste(FRED.URL, "/", Symbols[[i]], "/",
"downloaddata/", :
cannot open URL
'http://research.stlouisfed.org/fred2/series/DGS3MO/downloaddata/DGS3MO.csv'
This is even though I could download the data at the specified url
manually.
~Tom
On 2016-06-09 15:42, Frank wrote:
I use the 3-month constant maturity Treasury bill rate from FRED
(Federal
Reserve Economic ??Database??) for the risk-free rate. For options with
substantially more than 3 months until expiration, I think it makes
sense to
use a maturity that best matches the option. The R code I use is:
library(quantmod)
library(chron)
##
## Get DGS3MO Treasury yield from FRED
##
getSymbols('DGS3MO',src='FRED')
DGS3MO<-na.locf(DGS3MO/100.0,na.rm = TRUE)
tail(DGS3MO)
file_name <- "DGS3MO.csv"
write.zoo(DGS3MO, file = file_name, append = FALSE, quote = TRUE, sep =
",")
quit()
I run this text from a batch file in Windows 7 Pro 64-bit. The text in
the
batch file is:
REM on Microsoft Windows (adjust the path to R.exe as needed)
DEL *DGS3MO.csv
"C:\Program Files\R\R-3.2.2\bin\x64\R.exe" CMD BATCH
"C:\Users\Frank\Documents\R\Projects\DGS3MO\DGS3MO.txt"
"C:\Users\Frank\Documents\R\Projects\DGS3MO\DGS3MO.out"
COPY DGS3MO.BAT DGS3MO.BAK
COPY DGS3MO.TXT DGS3MO.TXT.BAK
REM PAUSE
...