CustomDerivative {CustomDerivative} R Documentation

## Custom Derivative R6 Class

### Description

This class provides methods to create and price custom derivatives.

### Details

An R6 class to create and price custom derivatives.

The class uses the Monte Carlo method for pricing. The price method simulates the underlying asset price paths and applies the payoff function to determine the option price.

### Value

For price, delta, gamma, theta, vega, and rho: a numeric value.

### Methods

initialize(underlying_price, strike_price, time_to_maturity, volatility, risk_free_rate, payoff_function):

Constructor method. Initializes the parameters for the custom derivative.

price():

Calculate the option price using the Monte Carlo method.

delta():

Calculate the Delta of the option.

gamma():

Calculate the Gamma of the option.

theta():

Calculate the Theta of the option.

vega():

Calculate the Vega of the option.

rho():

Calculate the Rho of the option.

### Public fields

underlying_price

The underlying asset price.

strike_price

The strike price of the option.

time_to_maturity

Time to maturity of the option.

volatility

The volatility of the underlying asset.

risk_free_rate

The risk-free rate.

payoff_function

The function that determines the payoff of the option.

### Methods

#### Method new()

##### Returns

Numeric value representing the option price. Calculate the Delta of the option.

#### Method delta()

##### Returns

Numeric value representing the gamma Calculate the theta of the option.

#### Method theta()

##### Returns

Numeric value representing the vega Calculate the rho of the option.

#### Method rho()

##### Arguments
deep

Whether to make a deep clone.

### Examples

# Define the payoff function for a European call option
call_payoff <- function(price) {
return(max(price - 100, 0))
}

# Create an instance of the CustomDerivative class
option <- CustomDerivative$new(100, 100, 1, 0.2, 0.05, call_payoff) # Print Option Price and Greeks cat("Option Price:", option$price(), "\n")
cat("Delta:", option$delta(), "\n") cat("Gamma:", option$gamma(), "\n")
cat("Theta:", option$theta(), "\n") cat("Vega:", option$vega(), "\n")
cat("Rho:", option\$rho(), "\n")


[Package CustomDerivative version 0.1.1 Index]