[Returnanalytics-commits] r3887 - pkg/Dowd/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Jul 31 11:23:53 CEST 2015
Author: dacharya
Date: 2015-07-31 11:23:53 +0200 (Fri, 31 Jul 2015)
New Revision: 3887
Added:
pkg/Dowd/R/LongBlackScholesCallVaR.R
Log:
Function LongBlackScholesCallVaR added.
Added: pkg/Dowd/R/LongBlackScholesCallVaR.R
===================================================================
--- pkg/Dowd/R/LongBlackScholesCallVaR.R (rev 0)
+++ pkg/Dowd/R/LongBlackScholesCallVaR.R 2015-07-31 09:23:53 UTC (rev 3887)
@@ -0,0 +1,42 @@
+#' Derives VaR of a long Black Scholes call option
+#'
+#' Function derives the VaR of a long Black Scholes call for specified
+#' confidence level and holding period, using analytical solution.
+#'
+#' @param stockPrice Stock price of underlying stock
+#' @param strike Strike price of the option
+#' @param r Risk-free rate and is annualised
+#' @param mu Mean return
+#' @param sigma Volatility of the underlying stock
+#' @param maturity Term to maturity and is expressed in days
+#' @param cl Confidence level and is scalar
+#' @param hp Holding period and is scalar and is expressed in days
+#' @return Price of European Call Option
+#' @references Dowd, Kevin. Measuring Market Risk, Wiley, 2007.
+#'
+#' Hull, John C.. Options, Futures, and Other Derivatives. 4th ed., Upper Saddle
+#' River, NJ: Prentice Hall, 200, ch. 11.
+#'
+#' Lyuu, Yuh-Dauh. Financial Engineering & Computation: Principles,
+#' Mathematics, Algorithms, Cambridge University Press, 2002.
+#'
+#' @author Dinesh Acharya
+#' @examples
+#'
+#' # Estimates the price of an American Put
+#' LongBlackScholesCallVaR(27.2, 25, .03, .12, .2, 60, .95, 40)
+#'
+#' @export
+LongBlackScholesCallVaR <- function(stockPrice, strike, r, mu, sigma,
+ maturity, cl, hp){
+ # Simplify notation
+ t <- maturity/360
+ hp <- hp/360
+ currentOptionPrice <- BlackScholesCallPrice(stockPrice, strike, r, sigma, t)
+ sStar <- exp(log(stockPrice) + (mu - (sigma ^ 2)/2) * hp -
+ qnorm(cl, 0, 1) * sigma * sqrt(hp))
+ # Critical future stock price, see Hull, p. 238
+ futureOptionPriceStar <- BlackScholesCallPrice(sStar, strike, r, sigma, t - hp)
+ y <- currentOptionPrice - futureOptionPriceStar
+ return(y)
+}
\ No newline at end of file
More information about the Returnanalytics-commits
mailing list