The purpose of this project is to price a European-style Down-and-Out Put Option using Monte Carlo simulation methods implemented via the Rcpp package.
Barrier options are unique financial derivatives that depend not only on the price of the underlying asset but also on whether the asset price breaches a certain barrier during the option’s life. This report explores:
The goal is to deliver an insightful analysis combining financial modeling with computational techniques to offer a robust understanding of barrier options, accompanied by detailed visualizations.
This study relies on the following assumptions:
Key parameters include:
These parameters reflect realistic market conditions and ensure that the analysis captures critical aspects of barrier options.
To price the Down-and-Out Put Option, we used Monte Carlo simulation implemented in C++ via the Rcpp package. The key steps include:
\[ \Phi_t = \max(K - S_T, 0), \text{ if } \min(S_t) \geq b \]
This approach captures the stochastic nature of financial markets while providing flexibility to analyze various parameter configurations.
The Rcpp package enables seamless integration of C++ code with R. The required libraries and source files are loaded as follows:
library(Rcpp)
sourceCpp("/Users/reyhanqurbanova/Desktop/src/main.cpp")
A wrapper function in R simplifies interaction with the underlying C++ code:
priceDownAndOutPut <- function(nInt, strike, spot, vol, r, expiry, nReps, barrier) {
priceOption(nInt, strike, spot, vol, r, expiry, nReps, "DownAndOutPut", barrier)
}
The theoretical price of the Down-and-Out Put Option is computed with the following parameters:
option_price <- priceDownAndOutPut(
nInt = 100,
strike = 110,
spot = 105,
vol = 0.21,
r = 0.05,
expiry = 0.75,
nReps = 10000,
barrier = 95
)
cat("Theoretical price of the Down-and-Out Put Option: ", round(option_price, 4))
## Theoretical price of the Down-and-Out Put Option: 0.7248
The impact of volatility and time to maturity on the option price is analyzed by simulating prices across a range of these parameters:
vol_range <- seq(0.1, 0.5, by = 0.05)
time_range <- seq(0.25, 2, by = 0.25)
sensitivity_results <- expand.grid(vol = vol_range, time = time_range)
sensitivity_results$price <- mapply(
function(vol, time) {
priceDownAndOutPut(100, 110, 105, vol, 0.05, time, 10000, 95)
},
sensitivity_results$vol, sensitivity_results$time
)
library(ggplot2)
ggplot(sensitivity_results, aes(x = vol, y = time, fill = price)) +
geom_tile() +
labs(
title = "Sensitivity of Option Price to Volatility and Time to Maturity",
x = "Volatility",
y = "Time to Maturity",
fill = "Option Price"
) +
theme_minimal()
This histogram visualizes the variability in simulated option prices:
simulation_prices <- replicate(100, priceDownAndOutPut(100, 110, 105, 0.21, 0.05, 0.75, 10000, 95))
ggplot(data.frame(price = simulation_prices), aes(x = price)) +
geom_histogram(bins = 30, fill = "blue", alpha = 0.7) +
labs(
title = "Distribution of Simulated Option Prices",
x = "Simulated Price",
y = "Frequency"
) +
theme_minimal()
The price evolution is explored by analyzing how the option price changes as the time to maturity varies:
time_steps <- seq(0.1, 1, by = 0.1)
price_over_time <- sapply(time_steps, function(t) priceDownAndOutPut(100, 110, 105, 0.21, 0.05, t, 10000, 95))
ggplot(data.frame(time = time_steps, price = price_over_time), aes(x = time, y = price)) +
geom_line(color = "red", size = 1) +
labs(
title = "Option Price Evolution Over Time",
x = "Time to Maturity",
y = "Option Price"
) +
theme_minimal()
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
The findings from this analysis reveal key insights into the behavior of Down-and-Out Put Options:
The combination of financial modeling and computational simulations showcased in this report highlights the dynamic interplay between market factors and option characteristics. This analysis serves as a foundation for further exploration into exotic options and their applications in complex financial markets.
In accordance with the Honor Code, I certify that my answers here are my own work, and I did not make my solutions available to anyone else.