Option pricing, basic question

classic Classic list List threaded Threaded
9 messages Options
thp
Reply | Threaded
Open this post in threaded view
|

Option pricing, basic question

thp
Hello,

I have a question regarding option pricing. In advance:
thank you for the patience.

I am trying to replay the calculation of plain
vanilla option prices using the Black-Scholes model
(the one leading to the analytic solution seen for
example on the wikipedia page [1]).

Using numerical values as simply obtained from
an arbitrary broker, I am surprised to see that
the formula values and quoted prices mismatch
a lot. (seems cannot all be explained by spread
or dividend details)

My question: What values for r (drift) and \sigma^2
are usually to be used, in which units?

If numerical values are chosen to be given "per year",
then I would expect r to be chosen as \ln(1+i),
where i is the yearly interest rate of the risk-free
portfolio and \ln is the natural logarithm. Would the
risk-free rate currently be chosen as zero?

The \sigma^2 one would accordingly have to choose
as the variance of the underlying security over
a one year period. Should this come out equal in
numerical value to the implied volatility, which is
0.2 to 0.4 for the majority of options?

Tom

[1] https://de.wikipedia.org/wiki/Black-Scholes-Modell

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Option pricing, basic question

Hong Yu

I remember John Hull’s book on option pricing should be helpful in finding some examples for your programming and modelling.  

Some assumptions of the Black-Scholes model are known to be impractical.  “Implied volatility” is one way to handle that.  Again you can find books for theoretical discussions to improve Black-Scholes.

My suggestions do not stick to your particular questions.  But hope the above may help.

Hong Yu




From: thp
Sent: Thursday, June 09, 2016 2:03 PM
To: [hidden email]
Subject: [R-SIG-Finance] Option pricing, basic question

Hello,

I have a question regarding option pricing. In advance:
thank you for the patience.

I am trying to replay the calculation of plain
vanilla option prices using the Black-Scholes model
(the one leading to the analytic solution seen for
example on the wikipedia page [1]).

Using numerical values as simply obtained from
an arbitrary broker, I am surprised to see that
the formula values and quoted prices mismatch
a lot. (seems cannot all be explained by spread
or dividend details)

My question: What values for r (drift) and \sigma^2
are usually to be used, in which units?

If numerical values are chosen to be given "per year",
then I would expect r to be chosen as \ln(1+i),
where i is the yearly interest rate of the risk-free
portfolio and \ln is the natural logarithm. Would the
risk-free rate currently be chosen as zero?

The \sigma^2 one would accordingly have to choose
as the variance of the underlying security over
a one year period. Should this come out equal in
numerical value to the implied volatility, which is
0.2 to 0.4 for the majority of options?

Tom

[1] https://de.wikipedia.org/wiki/Black-Scholes-Modell

_______________________________________________
[hidden email] 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.

        [[alternative HTML version deleted]]

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Option pricing, basic question

Frank-2
In reply to this post by thp
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

You say "r (drift)". Interest rates do move around despite the constant
interest rate assumption of the Black-Scholes model. This could be
characterized as drift. I'm not sure why else drift is in this post.
Correcting for interest rate drift has not mattered in calculations I've
made.

Volatility is also assumed constant in Black-Scholes. Volatility does drift
and this is the core problem with fitting market data to the standard
Black-Scholes model. Correctly correcting for drift might give you a better
fit to market data.

Best,

Frank
Chicago, IL

-----Original Message-----
From: R-SIG-Finance [mailto:[hidden email]] On Behalf
Of thp
Sent: Thursday, June 09, 2016 1:03 AM
To: [hidden email]
Subject: [R-SIG-Finance] Option pricing, basic question

Hello,

I have a question regarding option pricing. In advance:
thank you for the patience.

I am trying to replay the calculation of plain
vanilla option prices using the Black-Scholes model
(the one leading to the analytic solution seen for
example on the wikipedia page [1]).

Using numerical values as simply obtained from
an arbitrary broker, I am surprised to see that
the formula values and quoted prices mismatch
a lot. (seems cannot all be explained by spread
or dividend details)

My question: What values for r (drift) and \sigma^2
are usually to be used, in which units?

If numerical values are chosen to be given "per year",
then I would expect r to be chosen as \ln(1+i),
where i is the yearly interest rate of the risk-free
portfolio and \ln is the natural logarithm. Would the
risk-free rate currently be chosen as zero?

The \sigma^2 one would accordingly have to choose
as the variance of the underlying security over
a one year period. Should this come out equal in
numerical value to the implied volatility, which is
0.2 to 0.4 for the majority of options?

Tom

[1] https://de.wikipedia.org/wiki/Black-Scholes-Modell

_______________________________________________
[hidden email] 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.

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Option pricing, basic question

Adam Ginensky
In reply to this post by thp
The comments below address the issue of drift and \sigma .  As for the
interest rate used, I think you will find that the difference in the
values obtained by using different interest rates is on the order of
magnitude of rounding error.

There is a famous quote of Box - " All models are wrong, some are
useful ".  This applies to Black-Scholes in spades.  The B-S model is
almost universally  used to price options, but there are a number of
important caveats about using B-S to price options. I would summarize
my comment by  saying that the  volatility of the underlying is merely
a guideline as to what volatility to use in pricing options.  For at
the money options, the implied volatility ( the \sigma that will give
the value of the option) is a market consensus of what volatility will
be going forward.  In times of high volatility, the implied volatility
will always be lower (and I say always in an informed, not theoretical
way) than the realized volatility and similarly in times of low
volatility the implied volatility will typically be higher than
realized volatility - both situations reflecting 'regression to the
mean' nature of market movement. When I was an active floor trader,
this was called 'tilt' by many people. I would sum this up by saying
that the implied volatility is the market consensus as to what
realized volatility will be going forward.
As another exercise, get the prices of relatively short term options
mid-day on the Friday before a 3 day weekend.  The implied volatility
will typically seem absurdly low but will seem reasonable if the
volatility is computed with the date being 3 days forward. That is the
implied volatility will 'price in' the three day weekend .  This is
also true for most ordinary weekends.  Further, this is just a piece
of the issue.  The Black-Scholes model  significantly underprices out
of the money options.  This is because the real world distribution of
log returns has 'fat tails'.
Finally, there is no such thing as 'the volatility'.  For a given
option class, implied volatility is usually different at every strike.
This is in fundamental contradiction to the assumptions of B-S, but
reflects the reality of what happens in the real world.  For stocks,
volatility of out of the money puts is almost always higher than the
volatility for out of the money calls.  This reflects the fact that
markets usually go down faster than they go up as well as the reality
that people usually want insurance against stock prices going down,
not insurance against stock prices going up.  This volatility curve is
dynamic.  As the market goes higher, the difference between the
volatility of out of the money puts and the volatility of out of the
money calls will usually increase.  When the market goes back down,
the volatility difference usually decreases.
The point is that modeling implied volatility is a complicated and not
well understood item.  hth.








On Thu, Jun 9, 2016 at 1:02 AM, thp <[hidden email]> wrote:

> Hello,
>
> I have a question regarding option pricing. In advance:
> thank you for the patience.
>
> I am trying to replay the calculation of plain
> vanilla option prices using the Black-Scholes model
> (the one leading to the analytic solution seen for
> example on the wikipedia page [1]).
>
> Using numerical values as simply obtained from
> an arbitrary broker, I am surprised to see that
> the formula values and quoted prices mismatch
> a lot. (seems cannot all be explained by spread
> or dividend details)
>
> My question: What values for r (drift) and \sigma^2
> are usually to be used, in which units?
>
> If numerical values are chosen to be given "per year",
> then I would expect r to be chosen as \ln(1+i),
> where i is the yearly interest rate of the risk-free
> portfolio and \ln is the natural logarithm. Would the
> risk-free rate currently be chosen as zero?
>
> The \sigma^2 one would accordingly have to choose
> as the variance of the underlying security over
> a one year period. Should this come out equal in
> numerical value to the implied volatility, which is
> 0.2 to 0.4 for the majority of options?
>
> Tom
>
> [1] https://de.wikipedia.org/wiki/Black-Scholes-Modell
>
> _______________________________________________
> [hidden email] 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.

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Option pricing, basic question

Oleg Mubarakshin
In reply to this post by thp
Hi Tom!

I hope you do not try to get option prices with using vol calculated from
underlying (so called realized or historical vol).
BSM model is a model based on GBM, that we do not see in the real markets of
course.
Real markets express skew and fat tails in log-return distributions, that
leads to vol skew and higher implied vol of deep OTM options.

For modeling of option prices often use:
1. Stochastic vol models
2. Local vol models
3. Stochastic local vol models

these models is constructed for catch the effects described by me above.

I hope it will help you!

Kind regards,
Oleg Mubarakshin

-----Исходное сообщение-----
From: thp
Sent: Thursday, June 09, 2016 9:02 AM
To: [hidden email]
Subject: [R-SIG-Finance] Option pricing, basic question

Hello,

I have a question regarding option pricing. In advance:
thank you for the patience.

I am trying to replay the calculation of plain
vanilla option prices using the Black-Scholes model
(the one leading to the analytic solution seen for
example on the wikipedia page [1]).

Using numerical values as simply obtained from
an arbitrary broker, I am surprised to see that
the formula values and quoted prices mismatch
a lot. (seems cannot all be explained by spread
or dividend details)

My question: What values for r (drift) and \sigma^2
are usually to be used, in which units?

If numerical values are chosen to be given "per year",
then I would expect r to be chosen as \ln(1+i),
where i is the yearly interest rate of the risk-free
portfolio and \ln is the natural logarithm. Would the
risk-free rate currently be chosen as zero?

The \sigma^2 one would accordingly have to choose
as the variance of the underlying security over
a one year period. Should this come out equal in
numerical value to the implied volatility, which is
0.2 to 0.4 for the majority of options?

Tom

[1] https://de.wikipedia.org/wiki/Black-Scholes-Modell

_______________________________________________
[hidden email] 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.

_______________________________________________
[hidden email] 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.
thp
Reply | Threaded
Open this post in threaded view
|

Re: Option pricing, basic question

thp
In reply to this post by Frank-2
Hello to all,

I noticed that indeed my questions are not truly specific to R.
Nevertheless the code in Frank's post
was guiding to FRED which contributes to answers.

With "drift" I mistakenly meant "risk-free rate"; properly one refers to
"drift" when meaning the overall movement of the _underlying_.

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
>
> You say "r (drift)". Interest rates do move around despite the constant
> interest rate assumption of the Black-Scholes model. This could be
> characterized as drift. I'm not sure why else drift is in this post.
> Correcting for interest rate drift has not mattered in calculations
> I've
> made.
>
> Volatility is also assumed constant in Black-Scholes. Volatility does
> drift
> and this is the core problem with fitting market data to the standard
> Black-Scholes model. Correctly correcting for drift might give you a
> better
> fit to market data.
>
> Best,
>
> Frank
> Chicago, IL
>
> -----Original Message-----
> From: R-SIG-Finance [mailto:[hidden email]] On
> Behalf
> Of thp
> Sent: Thursday, June 09, 2016 1:03 AM
> To: [hidden email]
> Subject: [R-SIG-Finance] Option pricing, basic question
>
> Hello,
>
> I have a question regarding option pricing. In advance:
> thank you for the patience.
>
> I am trying to replay the calculation of plain
> vanilla option prices using the Black-Scholes model
> (the one leading to the analytic solution seen for
> example on the wikipedia page [1]).
>
> Using numerical values as simply obtained from
> an arbitrary broker, I am surprised to see that
> the formula values and quoted prices mismatch
> a lot. (seems cannot all be explained by spread
> or dividend details)
>
> My question: What values for r (drift) and \sigma^2
> are usually to be used, in which units?
>
> If numerical values are chosen to be given "per year",
> then I would expect r to be chosen as \ln(1+i),
> where i is the yearly interest rate of the risk-free
> portfolio and \ln is the natural logarithm. Would the
> risk-free rate currently be chosen as zero?
>
> The \sigma^2 one would accordingly have to choose
> as the variance of the underlying security over
> a one year period. Should this come out equal in
> numerical value to the implied volatility, which is
> 0.2 to 0.4 for the majority of options?
>
> Tom
>
> [1] https://de.wikipedia.org/wiki/Black-Scholes-Modell
>
> _______________________________________________
> [hidden email] 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.

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Option pricing, basic question

Frank-2
Tom,

If you get some options data up for analysis, you might want to try 0
interest first and then DGS3MO second. Using DGS3MO should produce a lower
variance between the settlement and the B-S prices.

The CBOE sells market data for $3 per month per symbol. The data is
voluminous and is best loaded into a database where you can query a relevant
subset of data. For instance, all the DEC 2016 SPY Call options that have
greater than 0 volume and open interest and are out-of-the-money.

Best,

Frank
Chicago

-----Original Message-----
From: R-SIG-Finance [mailto:[hidden email]] On Behalf
Of thp
Sent: Thursday, June 09, 2016 11:27 AM
To: [hidden email]
Subject: Re: [R-SIG-Finance] Option pricing, basic question

Hello to all,

I noticed that indeed my questions are not truly specific to R.
Nevertheless the code in Frank's post
was guiding to FRED which contributes to answers.

With "drift" I mistakenly meant "risk-free rate"; properly one refers to
"drift" when meaning the overall movement of the _underlying_.

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
>
> You say "r (drift)". Interest rates do move around despite the constant
> interest rate assumption of the Black-Scholes model. This could be
> characterized as drift. I'm not sure why else drift is in this post.
> Correcting for interest rate drift has not mattered in calculations
> I've
> made.
>
> Volatility is also assumed constant in Black-Scholes. Volatility does
> drift
> and this is the core problem with fitting market data to the standard
> Black-Scholes model. Correctly correcting for drift might give you a
> better
> fit to market data.
>
> Best,
>
> Frank
> Chicago, IL
>
> -----Original Message-----
> From: R-SIG-Finance [mailto:[hidden email]] On
> Behalf
> Of thp
> Sent: Thursday, June 09, 2016 1:03 AM
> To: [hidden email]
> Subject: [R-SIG-Finance] Option pricing, basic question
>
> Hello,
>
> I have a question regarding option pricing. In advance:
> thank you for the patience.
>
> I am trying to replay the calculation of plain
> vanilla option prices using the Black-Scholes model
> (the one leading to the analytic solution seen for
> example on the wikipedia page [1]).
>
> Using numerical values as simply obtained from
> an arbitrary broker, I am surprised to see that
> the formula values and quoted prices mismatch
> a lot. (seems cannot all be explained by spread
> or dividend details)
>
> My question: What values for r (drift) and \sigma^2
> are usually to be used, in which units?
>
> If numerical values are chosen to be given "per year",
> then I would expect r to be chosen as \ln(1+i),
> where i is the yearly interest rate of the risk-free
> portfolio and \ln is the natural logarithm. Would the
> risk-free rate currently be chosen as zero?
>
> The \sigma^2 one would accordingly have to choose
> as the variance of the underlying security over
> a one year period. Should this come out equal in
> numerical value to the implied volatility, which is
> 0.2 to 0.4 for the majority of options?
>
> Tom
>
> [1] https://de.wikipedia.org/wiki/Black-Scholes-Modell
>
> _______________________________________________
> [hidden email] 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.

_______________________________________________
[hidden email] 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.

_______________________________________________
[hidden email] 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.
thp
Reply | Threaded
Open this post in threaded view
|

Re: Option pricing, basic question

thp
In reply to this post by Frank-2
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
> ...

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Option pricing, basic question

Joshua Ulrich
On Thu, Jun 16, 2016 at 9:45 AM, thp <[hidden email]> 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
>> ...
>
>
> _______________________________________________
> [hidden email] 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

_______________________________________________
[hidden email] 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.