View source: R/calculate_payoffs.R
calculate_payoffs | R Documentation |
The calculate_payoffs function calculate payoffs from trajectories
calculate_payoffs(paths, FUN, ...)
paths |
numeric matrix, price of the asset from different trajectories. |
FUN |
the function to be applied, payoff option: see 'Details' and 'Examples'. |
... |
arguments to FUN. |
FUN have to had parameter asset_price which represent price of the asset over the life of the option, see call_payoff
Arguments in ... cannot have the same name as any of the other arguments, and care may be needed to avoid errors.
A numeric vector, option payoffs from different trajectories
X <- generate_scenarios(100, 0, 0.3) calculate_payoffs(X, call_payoff, strike = 100) calculate_payoffs(X, put_payoff, strike = 100) ## Example with asian call payoff asian_call <- function(asset_price, strike){ return(mean(asset_price) - min( mean(asset_price), strike )) } calculate_payoffs(paths = X, option_modificate_payoff, const = 110, drift = 0.05, rate = 0, vol = 0.3, p = 1, asian_call, strike = 105)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.