The HTML document presents a simplified representation of a derivative trading model utilizing two different mathematical models: the Black-Scholes model and the Cox Ross Rubinstein (CRR) binomial tree model. The goal is to calculate and analyze the prices of financial derivatives, (options), which are financial instruments whose value is derived from an underlying asset, most commonly a stock.
The two stocks we’re looking at: Interactive Brokers & Nvidia
The goal of each mathematical model:
Black-Scholes: Provides option prices based on current stock price, strike price, expiration time, risk-free interest rate, volatility, and cost of carry (total expense while carrying the asset…used for cost-benefit analysis of holding underlying asset while having deriv. position)
Cox Ross Rubinstein model: Uses a discrete-time approach(sequence of distinct points or intervals) to produce option prices for call options based on upward/downward movements of the underlying asset
# Specifying the stock symbols and time period
symbols <- c("ibkr", "nvda")
start_date <- "2023-01-01"
end_date <- Sys.Date() # Uses today's date as the end date
# Fetching historical stock prices
getSymbols(symbols, src = "yahoo", from = "2023-01-01", to = "2024-02-21")
## [1] "ibkr" "nvda"
# Fetching historical stock prices
getSymbols("IBKR", src = "yahoo", from = "2023-01-01", to = "2024-02-21")
## [1] "IBKR"
getSymbols("NVDA", src = "yahoo", from = "2023-01-01", to = "2024-02-21")
## [1] "NVDA"
# Viewing most recent few rows from the downloaded data
tail(IBKR)
## IBKR.Open IBKR.High IBKR.Low IBKR.Close IBKR.Volume IBKR.Adjusted
## 2024-02-12 98.44 98.49 97.76 98.16 639100 98.06961
## 2024-02-13 98.07 101.94 98.07 100.97 1570500 100.87702
## 2024-02-14 101.60 102.31 100.79 101.05 1182300 100.95695
## 2024-02-15 101.76 105.17 101.37 104.59 2099400 104.49368
## 2024-02-16 105.04 106.43 104.18 104.53 1005400 104.43374
## 2024-02-20 104.54 104.90 102.27 103.34 1031500 103.24483
tail(NVDA)
## NVDA.Open NVDA.High NVDA.Low NVDA.Close NVDA.Volume NVDA.Adjusted
## 2024-02-12 726.00 746.11 712.50 722.48 61371000 722.4461
## 2024-02-13 704.00 734.50 696.20 721.28 60258000 721.2462
## 2024-02-14 732.02 742.36 719.38 739.00 50491700 738.9653
## 2024-02-15 738.69 739.75 724.00 726.58 42012200 726.5460
## 2024-02-16 741.00 744.02 725.01 726.13 49391800 726.0959
## 2024-02-20 719.47 719.56 677.34 694.52 70483300 694.4874
Black-Scholes Call Option Price for IBKR
# Black-Scholes option pricing formula
bs_option_price_quantmod <- function(type, underlying, strike, expire, rate, volatility, div = 0) {
T <- expire
S <- underlying
K <- strike
r <- rate
sigma <- volatility
D <- div
d1 <- (log(S / K) + (r - D + 0.5 * sigma^2) * T) / (sigma * sqrt(T))
d2 <- d1 - sigma * sqrt(T)
if (type == "call") {
option_price <- S * exp(-D * T) * pnorm(d1) - K * exp(-r * T) * pnorm(d2)
} else if (type == "put") {
option_price <- K * exp(-r * T) * pnorm(-d2) - S * exp(-D * T) * pnorm(-d1)
} else {
stop("Invalid option type. Use 'call' or 'put'.")
}
return(option_price)
}
# Using short-term option strategy of three months (0.25 = ~90 days)
underlying_price <- 104 # Current stock price
strike_price <- 112 # Strike price
time_to_expiry <- 0.25 # Time to maturity or expiry (in years, so 90-day period)
risk_free_rate <- 0.0544 # Risk-free rate (current 3-month bond rate)
dividend_yield <- 0.38 # Dividend yield
volatility <- 0.2665 # Volatility (Blended)
# Calculate the Black-Scholes call option price for IBKR
ibkr_bs_call_price <- bs_option_price_quantmod(type = "call",
underlying = underlying_price,
strike = strike_price,
expire = time_to_expiry,
rate = risk_free_rate,
volatility = volatility,
div = dividend_yield)
# Print the result
print(paste("IBKR Call Option Price (with quantmod):", ibkr_bs_call_price))
## [1] "IBKR Call Option Price (with quantmod): 0.816081915851534"
Analyzing the hypothetical effect of price evolution given interest rate changes for the given security: IBKR
# Function to calculate Black-Scholes option price with variable interest rate
black_scholes_with_rate_change <- function(S, K, T, r, r_new, sigma, type = "call") {
d1 <- (log(S / K) + ((r_new + (sigma^2) / 2) * T)) / (sigma * sqrt(T))
d2 <- d1 - sigma * sqrt(T)
if (type == "call") {
option_price <- S * pnorm(d1) - K * exp(-r_new * T) * pnorm(d2)
} else {
option_price <- K * exp(-r_new * T) * pnorm(-d2) - S * pnorm(-d1)
}
return(option_price)
}
# Set parameters
S <- 104 # Current stock price
K <- 112 # Strike price
r <- 0.0544 # Initial risk-free rate
sigma <- 0.2655 # Volatility (Blended)
# Define a range of time points (e.g., from 0 to 1 with 0.1 increments)
T <- seq(0, 1, 0.1)
# Calculate option prices at different time points with the initial interest rate
option_prices_initial_rate <- sapply(T, function(t) black_scholes_with_rate_change(S, K, t, r, r, sigma))
# New interest rate (drop by 25 basis points)
r_new <- r - 0.0025 # Adjusting for 25 basis points drop
# Calculating option prices at different time points with the new interest rate
option_prices_new_rate <- sapply(T, function(t) black_scholes_with_rate_change(S, K, t, r, r_new, sigma))
# Create data frames for plotting
df_initial_rate <- data.frame(Time = T, OptionPrice = option_prices_initial_rate, RateType = "Initial Rate")
df_new_rate <- data.frame(Time = T, OptionPrice = option_prices_new_rate, RateType = "New Rate")
# Combine data frames
df_combined <- rbind(df_initial_rate, df_new_rate)
# Plot option price evolution over time with both initial and new interest rates
library(ggplot2)
ggplot(df_combined, aes(x = Time, y = OptionPrice, color = RateType)) +
geom_line() +
labs(title = "Option Price Evolution Over Time with Interest Rate Change",
x = "Time to Maturity (Years)",
y = "Option Price") +
theme_minimal() +
scale_color_manual(values = c("blue", "red"))
Explanation of Option Price Chart: - I am comparing the option price over time with the initial risk-free rate and new rate (-25 basis points) - X-axis represents the option’s time to expiration (0.25 equates to 90 days) - Y-axis represents price of the option according to the Black-Scholes model - Being that the option is out-of-the-money, the factors playing into the price decrease may be time value impact
**Keep in mind for volatility, Black-Scholes uses historic
volatility, so I am using blended volatility to smooth out extremes -
IBKR: (1/2 of historical (0.2630) x 1/2 of implied (0.2700)) ->
0.1350 + 0.1315 = 0.2665
- NVDA: (1/2 of historical (0.3249) x 1/2 of implied (0.4880)) ->
0.1625 + 0.2440 = 0.4065
Obtain call option price for NVDA
# Load the quantmod package
library(quantmod)
# Function to calculate Black-Scholes option price
black_scholes <- function(S, K, T, r, sigma, type = "call") {
d1 <- (log(S / K) + (r + sigma^2 / 2) * T) / (sigma * sqrt(T))
d2 <- d1 - sigma * sqrt(T)
if (type == "call") {
option_price <- S * pnorm(d1) - K * exp(-r * T) * pnorm(d2)
} else {
option_price <- K * exp(-r * T) * pnorm(-d2) - S * pnorm(-d1)
}
return(option_price)
}
# Set parameters for NVDA
S_nvda <- 670 # Current stock price for NVDA
K_nvda <- 690 # Strike price for NVDA
T_nvda <- 0.25 # Time to maturity or expiry (in years) for NVDA
r_nvda <- 0.0544 # Risk-free rate (current 3-month bond rate) for NVDA
D_nvda <- 0.024 # Dividend yield for NVDA
sigma_nvda <- 0.4065 # Volatility (Blended) for NVDA
# Calculate NVDA Call Option Price using Black-Scholes formula
nvda_bs_price <- black_scholes(S_nvda, K_nvda, T_nvda, r_nvda, sigma_nvda, type = "call")
# Print the result
print(paste("NVDA Call Option Price:", nvda_bs_price))
## [1] "NVDA Call Option Price: 49.4908717600953"
Price evolution chart given interest rate changes for the given security: NVDA
# Function to calculate Black-Scholes option price with variable interest rate
black_scholes_with_rate_change <- function(S, K, T, r, r_new, sigma, type = "call") {
d1 <- (log(S / K) + ((r_new + (sigma^2) / 2) * T)) / (sigma * sqrt(T))
d2 <- d1 - sigma * sqrt(T)
if (type == "call") {
option_price <- S * pnorm(d1) - K * exp(-r_new * T) * pnorm(d2)
} else {
option_price <- K * exp(-r_new * T) * pnorm(-d2) - S * pnorm(-d1)
}
return(option_price)
}
# Set parameters for NVDA
S_nvda <- 670 # Current stock price for NVDA
K_nvda <- 690 # Strike price for NVDA
T_nvda <- seq(0.01, 0.25, by = 0.01) # Time to maturity or expiry (in years) for NVDA
r_nvda <- 0.0544 # Risk-free rate (current 3-month bond rate) for NVDA
sigma_nvda <- 0.4162 # Volatility (Blended) for NVDA
# Calculate option prices at different time points with the initial interest rate for NVDA
option_prices_initial_rate_nvda <- sapply(T_nvda, function(t) black_scholes_with_rate_change(S_nvda, K_nvda, t, r_nvda, r_nvda, sigma_nvda))
# New interest rate (drop by 25 basis points) for NVDA
r_new_nvda <- r_nvda - 0.0025 # Adjusting for 25 basis points drop
# Calculating option prices at different time points with the new interest rate for NVDA
option_prices_new_rate_nvda <- sapply(T_nvda, function(t) black_scholes_with_rate_change(S_nvda, K_nvda, t, r_nvda, r_new_nvda, sigma_nvda))
# Create data frames for plotting for NVDA
df_initial_rate_nvda <- data.frame(Time = T_nvda, OptionPrice = option_prices_initial_rate_nvda, RateType = "Initial Rate")
df_new_rate_nvda <- data.frame(Time = T_nvda, OptionPrice = option_prices_new_rate_nvda, RateType = "New Rate")
# Combine data frames for NVDA
df_combined_nvda <- rbind(df_initial_rate_nvda, df_new_rate_nvda)
# Plot option price evolution over time with both initial and new interest rates for NVDA
library(ggplot2)
ggplot(df_combined_nvda, aes(x = Time, y = OptionPrice, color = RateType)) +
geom_line() +
labs(title = "NVDA Option Price Evolution Over Time with Interest Rate Change",
x = "Time to Maturity (Years)",
y = "Option Price") +
theme_minimal() +
scale_color_manual(values = c("red", "blue"))
- Decrease in risk-free rate decreases present cash flow values, making
call options perhaps less attractive in this case. - If the new rate is
lower than the initial rate, call options may experience a decline in
value due to the present value of the future stock price being lower
when discounted at a lower interest rate. - Keep in mind market
sentiment and volatility changes. - You’re theoretically holding the
option until maturity with the Black-Scholes model
CRR Model Call Option price for IBKR
# Cox Ross Rubinstein Model for IBKR
# Function to calculate option price using CRR-like logic
crr_option_price <- function(S0, X, T, r, sigma, n, type = "call") {
delta_t <- T / n
u <- exp(sigma * sqrt(delta_t))
d <- 1 / u
p <- (exp(r * delta_t) - d) / (u - d)
# Generate stock prices at expiration
ST <- S0 * u^(n:0) * d^(0:n)
# Calculate option payoffs at expiration
payoff <- pmax(ST - X, 0) # For a call option
# Backward induction to calculate option price at t=0
for (i in (n - 1):0) {
payoff <- exp(-r * delta_t) * (p * payoff[2:(i + 2)] + (1 - p) * payoff[1:(i + 1)])
}
return(payoff[1])
}
# Parameters
underlying_price <- 104
strike_price <- 112
time_to_expiry <- 0.25
risk_free_rate <- 0.0544
volatility <- 0.2665
n <- 5 # Number of periods
# Calculating IBKR call option price using CRR-like model
ibkr_crr_price <- crr_option_price(underlying_price, strike_price, time_to_expiry, risk_free_rate, volatility, n)
# Print the result
cat("IBKR Call Option Price (CRR-like):", ibkr_crr_price, "\n")
## IBKR Call Option Price (CRR-like): 2.614556
CRR Model Call Option Price for NVDA
# Cox Ross Rubinstein Model for NVDA
# Function to calculate option price using CRR-like logic
crr_option_price <- function(S0, X, T, r, sigma, n, type = "call") {
delta_t <- T / n
u <- exp(sigma * sqrt(delta_t))
d <- 1 / u
p <- (exp(r * delta_t) - d) / (u - d)
# Generate stock prices at expiration
ST <- S0 * u^(n:0) * d^(0:n)
# Calculate option payoffs at expiration
payoff <- pmax(ST - X, 0) # For a call option
# Backward induction to calculate option price at t=0
for (i in (n - 1):0) {
payoff <- exp(-r * delta_t) * (p * payoff[2:(i + 2)] + (1 - p) * payoff[1:(i + 1)])
}
return(payoff[1])
}
# Define parameters for NVDA
underlying_price_nvda <- 670
strike_price_nvda <- 690
time_to_expiry_nvda <- 0.25
risk_free_rate_nvda <- 0.0544
dividend_yield_nvda <- 0.024
volatility_nvda <- 0.4162
n_nvda <- 5 # Number of periods
# Calculate NVDA call option price using CRR-like model
nvda_crr_price <- crr_option_price(underlying_price_nvda, strike_price_nvda, time_to_expiry_nvda, risk_free_rate_nvda, volatility_nvda, n_nvda)
# Print the result
print(nvda_crr_price)
## [1] 58.6334
cat("NVDA Call Option Price (CRR-like):", nvda_crr_price, "\n")
## NVDA Call Option Price (CRR-like): 58.6334
Again, intrinsic value utilizing the CRR model for Nvidia
Creating CRR Binomial Tree Model for IBKR (Altering variable names to match package output)
s <- 104 # Current stock price
k <- 112 # Strike price
tt <- 0.25 # Time to maturity or expiry (in years)
r <- .0544 # Risk-free rate (current 3-month bond rate)
d <- .38 # Dividend yield
v <- 0.2665 # Volatility (Blended)
nstep <- 5 # Number of steps or periods in binomial tree
# Calculate option price and associated information
result <- binomopt(s, k, v, r, tt, d, nstep, american = TRUE, putopt = FALSE, returntrees = TRUE, returnparams = TRUE)
# Calculate American Call Option Price
american_call_option_price <- binomopt(s, k, v, r, tt, d, nstep, american = TRUE, putopt = FALSE, returntrees = TRUE, returnparams = TRUE)[[1]]
# Calculate American Put Option Price
#american_put_option_price <- binomopt(s, k, v, r, tt, d, nstep, american = TRUE, putopt = TRUE, returntrees = TRUE, returnparams = TRUE)[[1]]
# Calculate European Call Option Price
#european_call_option_price <- binomopt(s, k, v, r, tt, d, nstep, american = FALSE, putopt = FALSE, returntrees = TRUE, returnparams = TRUE)[[1]]
# Calculate European Put Option Price
#european_put_option_price <- binomopt(s, k, v, r, tt, d, nstep, american = FALSE, putopt = TRUE, returntrees = TRUE, returnparams = TRUE)[[1]]
# Access the parameters returned
oppricretree <- result$oppricretree
delta <- result$delta
bond <- result$bond
# Print or use these parameters as needed
print(oppricretree)
## NULL
print(delta)
## [,1] [,2] [,3] [,4] [,5]
## [1,] 0.1340593 0.24095963 0.42866332 0.7341624 0.9811794
## [2,] 0.0000000 0.02589582 0.05125827 0.1014608 0.2008318
## [3,] 0.0000000 0.00000000 0.00000000 0.0000000 0.0000000
## [4,] 0.0000000 0.00000000 0.00000000 0.0000000 0.0000000
## [5,] 0.0000000 0.00000000 0.00000000 0.0000000 0.0000000
print(bond)
## [,1] [,2] [,3] [,4] [,5]
## [1,] -12.99158 -24.357429 -45.187143 -80.64520 -111.69577
## [2,] 0.00000 -2.351973 -4.861569 -10.04895 -20.77135
## [3,] 0.00000 0.000000 0.000000 0.00000 0.00000
## [4,] 0.00000 0.000000 0.000000 0.00000 0.00000
## [5,] 0.00000 0.000000 0.000000 0.00000 0.00000
# Print option prices
cat("American Call Option Price:", american_call_option_price, "\n")
## American Call Option Price: 0.9505848
#cat("European Call Option Price:", european_call_option_price, "\n")
# Plot Binomial Tree for American Call Option
binomplot(s, k, v, r, tt, d, nstep, putopt = FALSE, american = TRUE,
plotvalues= TRUE, plotarrows= TRUE, drawstrike= TRUE, pointsize= 6, ylimval=c(0,0),
saveplot= FALSE, saveplotfn='IBKR CRR Plots.png',
crr= TRUE, jarrowrudd= FALSE, titles = TRUE, specifyupdn = FALSE,
returnprice = TRUE, logy = FALSE)
## [1] 0.9503154
#binomplot(s, k, v, r, tt, d, nstep, putopt = FALSE, american = FALSE, titles = TRUE,
#plotvalues= TRUE, plotarrows= TRUE, drawstrike= TRUE, pointsize= 3, ylimval=c(0,0),
#saveplot= FALSE, saveplotfn='IBKR CRR Plots.png',
#crr= TRUE, jarrowrudd= FALSE, specifyupdn = FALSE,
#returnprice = TRUE, logy = FALSE)
American option call price represents estimated price considering the option’s ability to be exercised
Each point denotes to the different possible future stock price at time of expiry
The number of terminal nodes is determined by the number of steps in the tree
Red dots represent nodes where early exercise occurs. For American options, these would be points where it’s optimal to exercise the option before expiration.
Green dots indicate terminal nodes where the option is exercised or where the payoff is received.
Other Significance:
Creating CRR Binomial Tree Model for NVDA
s <- 670 # Current stock price
k <- 690 # Strike price
tt <- 0.25 # Time to maturity or expiry (in years)
r <- .0544 # Risk-free rate (current 3-month bond rate)
d <- .024 # Dividend yield
v <- 0.4162 # Volatility (Blended)
nstep <- 5 # Number of steps in binomial tree
# Calculate option price and associated information
result <- binomopt(s, k, v, r, tt, d, nstep, american = TRUE, putopt = FALSE, returntrees = TRUE, returnparams = TRUE)
# Calculate American Call Option Price
american_call_option_price <- binomopt(s, k, v, r, tt, d, nstep, american = TRUE, putopt = FALSE, returntrees = TRUE, returnparams = TRUE)[[1]]
# Calculate European Call Option Price
#european_call_option_price <- binomopt(s, k, v, r, tt, d, nstep, american = FALSE, putopt = FALSE, returntrees = TRUE, returnparams = TRUE)[[1]]
# Access the parameters returned
oppricretree <- result$oppricretree
delta <- result$delta
bond <- result$bond
# Print or use these parameters as needed (Return time 0 delta, gamma, and theta in the vector greeks)
print(oppricretree)
## NULL
print(delta)
## [,1] [,2] [,3] [,4] [,5]
## [1,] 0.4963669 0.6760732 0.8616398 0.9976029 0.9988007
## [2,] 0.0000000 0.3003835 0.4741104 0.7145858 0.9988007
## [3,] 0.0000000 0.0000000 0.1104690 0.2113746 0.4044503
## [4,] 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
## [5,] 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
print(bond)
## [,1] [,2] [,3] [,4] [,5]
## [1,] -281.2889 -413.9636 -564.65487 -686.2566 -688.1258
## [2,] 0.0000 -161.8687 -278.81856 -456.7986 -688.1258
## [3,] 0.0000 0.0000 -56.15423 -118.1062 -248.4064
## [4,] 0.0000 0.0000 0.00000 0.0000 0.0000
## [5,] 0.0000 0.0000 0.00000 0.0000 0.0000
# Print option prices
cat("American Call Option Price:", american_call_option_price, "\n")
## American Call Option Price: 51.27692
#cat("European Call Option Price:", european_call_option_price, "\n")
# Plot Binomial Tree for American Call Option
binomplot(s, k, v, r, tt, d, nstep, putopt = FALSE, american = TRUE,
plotvalues= TRUE, plotarrows= TRUE, drawstrike= TRUE, pointsize= 3, ylimval=c(0,0),
saveplot= FALSE, saveplotfn='NVDA CRR Plots.png',
crr= TRUE, jarrowrudd= FALSE, titles = TRUE, specifyupdn = FALSE,
returnprice = TRUE, logy = FALSE)
## [1] 51.00663
Intrinsic Value: The green dots likely correspond to nodes where the American call option has intrinsic value, meaning the stock price is sufficiently higher than the strike price. Exercising the option at these nodes allows the option holder to capture the intrinsic value.
Optimal Early Exercise: According to CRR, it has determined that early exercise is optimal at these specific nodes based on the calculated option values and potential future stock prices.
Factors Influencing Early Exercise: Factors such as dividends, interest rates, and volatility may contribute to the decision to exercise early. The model takes into account these factors to determine the optimal exercise strategy.
For the sake of this document, referencing Puts as well (CRR Put Option for IBKR) (Same principles apply)
s <- 104 # Current stock price
k <- 99 # Strike price
tt <- 0.25 # Time to maturity or expiry (in years)
r <- .0544 # Risk-free rate (current 3-month bond rate)
d <- .38 # Dividend yield
v <- 0.2665 # Volatility (Blended)
nstep <- 5 # Number of steps or periods in binomial tree
# Calculating option price and associated information
result <- binomopt(s, k, v, r, tt, d, nstep, american = TRUE, putopt = FALSE, returntrees = TRUE, returnparams = TRUE)
# Calculating American Put Option Price
american_put_option_price <- binomopt(s, k, v, r, tt, d, nstep, american = TRUE, putopt = TRUE, returntrees = TRUE, returnparams = TRUE)[[1]]
# Calculating European Put Option Price
#european_put_option_price <- binomopt(s, k, v, r, tt, d, nstep, american = FALSE, putopt = TRUE, returntrees = TRUE, returnparams = TRUE)[[1]]
# Access the parameters returned
oppricretree <- result$oppricretree
delta <- result$delta
bond <- result$bond
# Print or use these parameters as needed
print(oppricretree)
## NULL
print(delta)
## [,1] [,2] [,3] [,4] [,5]
## [1,] 0.6311811 0.8559893 0.98117936 0.9811794 0.9811794
## [2,] 0.0000000 0.2586837 0.45515445 0.7512594 0.9811794
## [3,] 0.0000000 0.0000000 0.06037781 0.1195120 0.2365625
## [4,] 0.0000000 0.0000000 0.00000000 0.0000000 0.0000000
## [5,] 0.0000000 0.0000000 0.00000000 0.0000000 0.0000000
print(bond)
## [,1] [,2] [,3] [,4] [,5]
## [1,] -60.09622 -84.30020 -98.731086 -98.73109 -98.73109
## [2,] 0.00000 -23.18354 -42.525541 -73.07683 -98.73109
## [3,] 0.00000 0.00000 -5.083112 -10.50688 -21.71790
## [4,] 0.00000 0.00000 0.000000 0.00000 0.00000
## [5,] 0.00000 0.00000 0.000000 0.00000 0.00000
# Print option prices
cat("American Put Option Price:", american_put_option_price, "\n")
## American Put Option Price: 6.909045
#cat("European Put Option Price:", european_put_option_price, "\n")
# Plot Binomial Tree for American & European Put Option
binomplot(s, k, v, r, tt, d, nstep, putopt = TRUE, american = TRUE,
plotvalues= TRUE, plotarrows= TRUE, drawstrike= TRUE, pointsize= 3, ylimval=c(0,0),
saveplot= FALSE, saveplotfn='IBKR US CRR Plots.png',
crr= TRUE, jarrowrudd= FALSE, titles = TRUE, specifyupdn = FALSE,
returnprice = TRUE, logy = FALSE)
## [1] 6.547534
#binomplot(s, k, v, r, tt, d, nstep, putopt = TRUE, american = FALSE,
#plotvalues= TRUE, plotarrows= TRUE, drawstrike= TRUE, pointsize= 3, ylimval=c(0,0),
#saveplot= FALSE, saveplotfn='IBKR Euro CRR Plots.png',
#crr= TRUE, jarrowrudd= FALSE, titles = TRUE, specifyupdn = FALSE,
# returnprice = TRUE, logy = FALSE)
CRR Put Option for NVDA
s <- 670 # Current stock price
k <- 655 # Strike price
tt <- 0.25 # Time to maturity or expiry (in years)
r <- .0544 # Risk-free rate (current 3-month bond rate)
d <- .024 # Dividend yield
v <- 0.4162 # Volatility (Blended)
nstep <- 5 # Number of steps in binomial tree
# Calculating option price and associated information
result <- binomopt(s, k, v, r, tt, d, nstep, american = TRUE, putopt = FALSE, returntrees = TRUE, returnparams = TRUE)
# Calculating American Put Option Price
american_put_option_price <- binomopt(s, k, v, r, tt, d, nstep, american = TRUE, putopt = TRUE, returntrees = TRUE, returnparams = TRUE)[[1]]
# Calculating European Put Option Price
#european_put_option_price <- binomopt(s, k, v, r, tt, d, nstep, american = FALSE, putopt = TRUE, returntrees = TRUE, returnparams = TRUE)[[1]]
# Accessing the parameters returned
oppricretree <- result$oppricretree
delta <- result$delta
bond <- result$bond
# Parameters as needed
print(oppricretree)
## NULL
print(delta)
## [,1] [,2] [,3] [,4] [,5]
## [1,] 0.5995942 0.7748321 0.9246292 0.9976029 0.9988007
## [2,] 0.0000000 0.4087748 0.6123763 0.8468669 0.9988007
## [3,] 0.0000000 0.0000000 0.1863448 0.3565575 0.6822473
## [4,] 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
## [5,] 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
print(bond)
## [,1] [,2] [,3] [,4] [,5]
## [1,] -334.6905 -464.1287 -585.90421 -651.4465 -653.2208
## [2,] 0.0000 -218.4972 -355.59083 -529.2363 -653.2208
## [3,] 0.0000 0.0000 -94.72382 -199.2275 -419.0246
## [4,] 0.0000 0.0000 0.00000 0.0000 0.0000
## [5,] 0.0000 0.0000 0.00000 0.0000 0.0000
# Print option prices
cat("American Put Option Price:", american_put_option_price, "\n")
## American Put Option Price: 47.75394
#cat("European Put Option Price:", european_put_option_price, "\n")
# Plot Binomial Tree for American/Euro Put Option
binomplot(s, k, v, r, tt, d, nstep, putopt = TRUE, american = TRUE,
plotvalues= TRUE, plotarrows= TRUE, drawstrike= TRUE, pointsize= 3, ylimval=c(0,0),
saveplot= FALSE, saveplotfn='NVDA CRR Plots.png',
crr= TRUE, jarrowrudd= FALSE, titles = TRUE, specifyupdn = FALSE,
returnprice = TRUE, logy = FALSE)
## [1] 47.98999
#binomplot(s, k, v, r, tt, d, nstep, putopt = TRUE, american = FALSE,
#plotvalues= TRUE, plotarrows= TRUE, drawstrike= TRUE, pointsize= 3, ylimval=c(0,0),
#saveplot= FALSE, saveplotfn='NVDA CRR Plots.png',
#crr= TRUE, jarrowrudd= FALSE, titles = TRUE, specifyupdn = FALSE,
#returnprice = TRUE, logy = FALSE)