# [R-SIG-Finance] [SPAM] - GBSVolatility using apply - Email found in subject

Thu Aug 12 15:50:31 CEST 2010

```You may not have gotten an answer because this is not really a finance question, but a regular R question,
unless you did not know of an implied vol function.

This should give you an idea:

> require(RQuantLib)
> mapply(function(K,OP) EuropeanOptionImpliedVolatility(type="call", value=OP, underlying=df\$SPOT[1], strike=K, dividendYield=0, riskFreeRate=0.01, maturity=2/52, volatility=0.6)\$impliedVol, df\$STRIKE_PR, df\$SETTLE_PR)
[1] 0.9196752 0.8249324 0.6735371 0.7005296 0.6028061 0.5740485

Or you could use Vectorize() to make a function to compute implied vols over vectors of strikes and option prices.
HTH,
-- David

-----Original Message-----
From: r-sig-finance-bounces at stat.math.ethz.ch [mailto:r-sig-finance-bounces at stat.math.ethz.ch] On Behalf Of Raghuraman Ramachandran
Sent: Wednesday, August 11, 2010 3:10 PM
To: r-sig-finance at stat.math.ethz.ch
Subject: [SPAM] - [R-SIG-Finance] GBSVolatility using apply - Email found in subject

Hi

I posted this query before but I guess it was missed out from the list. I am
trying to find the implied vols for the following structure using apply
function. As I am relatively new to R and learning to apply apply, could
someone please tell me how do I apply apply in this case? I want to try to
find out the IVs using vectorisation only and thus I want to understand how
apply works in this case.

structure(list(EXPIRY_DT = structure(c(1L, 1L, 1L, 1L, 1L, 1L
), .Label = "26-Aug-10", class = "factor"), STRIKE_PR = c(9600L,
9700L, 9800L, 9900L, 10000L, 10100L), OPTION_TYP = structure(c(1L,
1L, 1L, 1L, 1L, 1L), .Label = "CE", class = "factor"), OPEN = c(866.55,
783.1, 575, 0, 470, 355), HIGH = c(866.55, 783.1, 575, 0, 470,
360), LOW = c(866.55, 742.25, 575, 0, 420, 343), CLOSE = c(866.55,
742.25, 575, 493, 425, 360), SETTLE_PR = c(866.55, 742.25, 575,
547, 425, 360), SPOT = c(9900L, 9900L, 9900L, 9900L, 9900L, 9900L
)), .Names = c("EXPIRY_DT", "STRIKE_PR", "OPTION_TYP", "OPEN",
"HIGH", "LOW", "CLOSE", "SETTLE_PR", "SPOT"), class = "data.frame",
row.names = c(NA,
-6L))

Assume r=0.1 and cost-of-carry=0.1. All options are Calls (European),Exp =
26th Aug 2010.

Many thanks
Raghu

[[alternative HTML version deleted]]

_______________________________________________
R-SIG-Finance at stat.math.ethz.ch 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.

This e-mail and any materials attached hereto, including, without limitation, all content hereof and thereof (collectively, "XR Content") are confidential and proprietary to XR Trading, LLC ("XR") and/or its affiliates, and are protected by intellectual property laws.  Without the prior written consent of XR, the XR Content may not (i) be disclosed to any third party or (ii) be reproduced or otherwise used by anyone other than current employees of XR or its affiliates, on behalf of XR or its affiliates.

THE XR CONTENT IS PROVIDED AS IS, WITHOUT REPRESENTATIONS OR WARRANTIES OF ANY KIND.  TO THE MAXIMUM EXTENT PERMISSIBLE UNDER APPLICABLE LAW, XR HEREBY DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS AND IMPLIED, RELATING TO THE XR CONTENT, AND NEITHER XR NOR ANY OF ITS AFFILIATES SHALL IN ANY EVENT BE LIABLE FOR ANY DAMAGES OF ANY NATURE WHATSOEVER, INCLUDING, BUT NOT LIMITED TO, DIRECT, INDIRECT, CONSEQUENTIAL, SPECIAL AND PUNITIVE DAMAGES, LOSS OF PROFITS AND TRADING LOSSES, RESULTING FROM ANY PERSON'S USE OR RELIANCE UPON, OR INABILITY TO USE, ANY XR CONTENT, EVEN IF XR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGES OR IF SUCH DAMAGES WERE FORESEEABLE.

```