About Task

In this Task, I evaluate the pricing of a European-style up-and-out put option using a Monte Carlo simulation approach implemented in C++ and interfaced with R via the OptionPrice package. This method allows us to estimate the option’s theoretical price by simulating the potential future paths of the underlying asset’s price.

# Set Environment
setwd("C://Users//User//Desktop//OptionPrice")
# Installing Source Package
install.packages("OptionPrice_0.1.0.tar.gz", repos = NULL, type = "source")
## Installing package into 'C:/Users/User/AppData/Local/R/win-library/4.3'
## (as 'lib' is unspecified)
## Warning in install.packages("OptionPrice_0.1.0.tar.gz", repos = NULL, type =
## "source"): installation of package 'OptionPrice_0.1.0.tar.gz' had non-zero exit
## status
# Import Tidyverse and new created OptionPrcie packages
library(OptionPrice)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.1     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
## [1] 12.92869

The simulation returns an estimated option price of approximately $12.91. It is important to note that due to the stochastic nature of the Monte Carlo simulation, this value varies slightly with each run of the simulation. This variability underscores the probabilistic basis of the simulation approach, reflecting the range of potential outcomes based on the random paths generated during the process.

To understand how the time to maturity affects the pricing of a European-style up-and-out put option, we conducted a series of Monte Carlo simulations. These simulations aimed to observe the variability and trend of the option price as the maturity period changes, from near-immediate expiry to one year.

The time to maturity (expiry) was varied systematically from 0.01 years (approximately 3.65 days) to 1 year in increments of 0.01 years.

Data Generation and Visualization The function getPutPriceWithExpiry was called iteratively for each time to maturity, generating a data set of option prices corresponding to each expiry period. The results were then plotted using ggplot2 to visualize the relationship between the option price and the time to maturity.

# Define a wrapper function for the up-and-out put option
getPutPriceWithExpiry <- function(expiry) {
  OptionPrice::getUpAndOutPutPriceCpp(
    nPaths = 10000, 
    strike = 150, 
    spot = 140, 
    vol = 0.24, 
    r = 0.07, 
    expiry = expiry, 
    barrier = 160
  )
}

# Generate data
expiry <- seq(0.01, 1, by = 0.01)
prices <- sapply(expiry, getPutPriceWithExpiry)

# Plot
library(ggplot2)
library(tibble)

tibble(expiry, prices) %>%
  ggplot(aes(expiry, prices)) +
  geom_point(col = "blue") +
  labs(
    x = "Time to Maturity",
    y = "Option Price",
    title = "Up-and-Out Put Option Price vs. Time to Maturity"
)

The analysis confirms that time to maturity is a critical factor influencing the pricing of up-and-out put options. Investors and traders can use this insight to better assess the risk and potential return associated with varying expiry periods of such options. This understanding is crucial for strategic decision-making in options trading, especially for those dealing with barrier options where the price path dependency is significant.

This section examines how the spot price and volatility of the underlying asset influence the pricing of a European-style up-and-out put option. The analysis utilizes a range of spot prices and three distinct volatility levels to illustrate their impact on the option’s theoretical price.

Methodology and Results Using the getUpAndOutPutPriceCpp function from the OptionPrice package, we conducted a series of Monte Carlo simulations across a grid of spot prices ranging from 90 to 150 and volatility levels of 10%, 20%, and 30%. The graph visualizes the resulting option prices, highlighting how each combination of spot price and volatility affects the option’s value.

As shown in the plot, the option price decreases as the spot price increases, which is typical for put options since their value generally rises as the underlying asset’s price falls. Additionally, for any given spot price, higher volatility leads to a higher option price. This pattern underscores the increased probability of the asset price hitting the barrier as volatility increases, which in turn enhances the value risk associated with the option.

# Define a wrapper function for the up-and-out put option
getPutPriceWithSpotAndVol <- function(spot, vol) {
  OptionPrice::getUpAndOutPutPriceCpp(
    nPaths = 10000, 
    strike = 150, 
    spot = spot, 
    vol = vol, 
    r = 0.07, 
    expiry = 0.75, 
    barrier = 160
  )
}

# Generate data
spot <- seq(90, 150, by = 1)
vol <- c(0.1, 0.2, 0.3)
grid <- expand.grid(spot = spot, vol = vol)
prices <- mapply(getPutPriceWithSpotAndVol, grid$spot, grid$vol)

# Plot
grid %>%
  as_tibble() %>%
  bind_cols(price = prices) %>%
  ggplot(aes(x = spot, y = price, group = vol, colour = vol)) +
  geom_line() +
  labs(
    x = "Spot Price",
    y = "Option Price",
    title = "Up-and-Out Put Option Price vs. Spot and Volatility"
)

The plotted data clearly demonstrates that both lower spot prices and higher volatility increase the value of the up-and-out put option, reflecting higher levels of inherent risk and potential return. This analysis is vital for traders and investors, as it provides insight into the sensitivity of barrier options to changes in market conditions, aiding in more informed decision-making regarding risk management and investment strategies.

General Conclusion for the Analysis of the European-Style Up-and-Out Put Option Pricing

Throughout this project, I have successfully developed and utilized a custom Rcpp package to address the Complex task of pricing a European-style up-and-out put option using Monte Carlo simulations. This endeavor not only reinforced our understanding of financial derivatives, particularly barrier options, but also showcased the power of combining advanced programming techniques with financial theory.

Technical Achievements

Rcpp Package Development: I created an Rcpp package, integrating C++ code to leverage its computational efficiency, which is crucial for the intensive calculations involved in Monte Carlo methods.

Function Implementation: Within this package, we developed specific functions tailored to calculate the theoretical prices of up-and-out put options under varying market conditions. This functionality allowed us to dynamically adjust input parameters such as volatility, spot price, and time to maturity.

Analytical Insights

Impact of Market Variables: Through our analyses, illustrated in detailed plots, we observed how sensitive the option pricing is to changes in spot prices and volatility. The option price exhibited a decrease with an increase in the spot price, while higher volatility generally led to higher option prices due to the greater risk of the asset hitting the barrier.

Time to Maturity: Our investigation also highlighted the relationship between the option price and time to maturity, indicating a gradual increase in price as the expiry date extends. This reflects the increased uncertainty and potential for price movement as the time horizon expands.

Conclusion

This project has demonstrated the practical application of theoretical financial models in a simulated environment, providing deep insights into the nuanced behavior of barrier options. These findings are essential for anyone involved in financial markets, enhancing understanding for investment strategies and risk management practices.

Furthermore, the integration of computational tools with financial theory exemplifies the evolving landscape of financial analysis, where technical skills and market knowledge converge to form a robust approach to understanding and predicting market behaviors. This comprehensive analysis not only fulfills academic purposes but also equips us with the methodologies necessary for sophisticated financial modeling and decision-making in real-world scenarios.

This conclusion not only sums up your project by emphasizing the technical achievements and key analytical insights but also places your work in the broader context of financial analysis and market application, stressing its practical relevance and educational value.