[R-SIG-Finance] Option pricing, basic question

Joshua Ulrich josh.m.ulrich at gmail.com
Thu Jun 16 18:10:36 CEST 2016


On Thu, Jun 16, 2016 at 9:45 AM, thp <thp at 2pimail.com> wrote:
> 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.
>
This has been fixed for almost a year.  You need to upgrade.
https://github.com/joshuaulrich/quantmod/issues/56

> ~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
>> ...
>
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions
> should go.



-- 
Joshua Ulrich  |  about.me/joshuaulrich
FOSS Trading  |  www.fosstrading.com
R/Finance 2016 | www.rinfinance.com



More information about the R-SIG-Finance mailing list