[Returnanalytics-commits] r3893 - pkg/Dowd/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Jul 31 11:27:05 CEST 2015
Author: dacharya
Date: 2015-07-31 11:27:05 +0200 (Fri, 31 Jul 2015)
New Revision: 3893
Added:
pkg/Dowd/R/ShortBlackScholesCallVaR.R
Log:
Function ShortBlackScholesCallVaR added.
Added: pkg/Dowd/R/ShortBlackScholesCallVaR.R
===================================================================
--- pkg/Dowd/R/ShortBlackScholesCallVaR.R (rev 0)
+++ pkg/Dowd/R/ShortBlackScholesCallVaR.R 2015-07-31 09:27:05 UTC (rev 3893)
@@ -0,0 +1,42 @@
+#' Derives VaR of a short Black Scholes call option
+#'
+#' Function derives the VaR of a short 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
+#' ShortBlackScholesCallVaR(27.2, 25, .03, .12, .2, 60, .95, 40)
+#'
+#' @export
+ShortBlackScholesCallVaR <- 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