This package provides ways to estimate the value of European stock options given stock price data. It includes functions for calculating option values based on Auto-Regressive–Moving-Average (ARMA) models and also returns information about these models. This package is make to be easy to understand and is built for financial analysis capabilities, however it can be used in many other situations. This package is dependent on the 'forecast' and 'stats' packages.
The current version of the armaOptions
package can be installed with:
devtools::install_github("BrianMacCarvill/armaOptions")
Calculating put option values for simulated data.
library(armaOptions)
library(forecast)
library(stats)
# Create simulated data
n = 100
set.seed(42)
arma_values = arima.sim(n = n, model = list(ar = c(0.6), ma = c(0.5, -0.5)))
linear_model = 5 + 1:n
stock_data = arma_values + linear_model
# Define a sell value and future times
sell_value = 110
future_times = c(1, 3, 5)
# Calculate put option values over a list of future times
results = PutOptionsOverTime(stock_data = stock_data, future_times = future_times, sell_value = sell_value)
# Print results
print(results)
# Define a list of sell values
sell_values = seq(90, 110, length.out = 5)
future_time = 2
# Calculate put option values over a list of sell values
results = PutOptionsOverStrikePrices(stock_data = stock_data, future_time = future_time, sell_values = sell_values)
# Print results
print(results)
These functions are based on the assumption that price data follow the following equation
where
An ARMA(p,q) model is defined as
where
So lets say our friend Bob wants to sell us a European put option at a price S, h days into the future. How do we find a fair price? This put option is only valuable if, in h-days,
The expected value can therefore be written as
where
We have defined the stock price at point
where
For an ARMA(p,q) model, assuming knowledge of the model parameters, at a forecasted value
The logic for Call options is the exact same just, in the other direction.