[Returnanalytics-commits] r3880 - pkg/Dowd/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Jul 30 01:09:50 CEST 2015
Author: dacharya
Date: 2015-07-30 01:09:50 +0200 (Thu, 30 Jul 2015)
New Revision: 3880
Added:
pkg/Dowd/R/BlackScholesPutPrice.R
Log:
Function BlackScholesPutPrice added.
Added: pkg/Dowd/R/BlackScholesPutPrice.R
===================================================================
--- pkg/Dowd/R/BlackScholesPutPrice.R (rev 0)
+++ pkg/Dowd/R/BlackScholesPutPrice.R 2015-07-29 23:09:50 UTC (rev 3880)
@@ -0,0 +1,34 @@
+#' Price of European Put Option
+#'
+#' Derives the price of European call option using the Black-Scholes approach
+#'
+#' @param stockPrice Stock price of underlying stock
+#' @param strike Strike price of the option
+#' @param rf Risk-free rate and is annualised
+#' @param sigma Volatility of the underlying stock
+#' @param t The term to maturity of the option in years
+#' @return Price of European Call Option
+#' @references Dowd, Kevin. Measuring Market Risk, Wiley, 2007.
+#'
+#' Hull, John C.. Options, Futures, and Other Derivatives. 5th ed., p. 246.
+#'
+#' Lyuu, Yuh-Dauh. Financial Engineering & Computation: Principles,
+#' Mathematics, Algorithms, Cambridge University Press, 2002.
+#'
+#' @author Dinesh Acharya
+#' @examples
+#'
+#' # Estimates the price of an American Put
+#' BlackScholesPutPrice(27.2, 25, .03, .2, 60)
+#'
+#' @export
+BlackScholesPutPrice <- function(stockPrice, strike, rf, sigma, t){
+ S <- stockPrice
+ X <- strike
+ # d terms
+ d1 <- (log(S/X) + (rf + (sigma ^ 2) / 2) * t) / (sigma * sqrt(t))
+ d2 <- d1 - sigma * sqrt(t)
+ # Option price
+ y <- exp(- rf * t) * strike * pnorm( - d2) - stockPrice * pnorm(- d1)
+ return(y)
+}
\ No newline at end of file
More information about the Returnanalytics-commits
mailing list