mafipy.function module

function (mafipy.function)

Black Model

Basics

black_payers_swaption_value(init_swap_rate, ...) calculates value of payer’s swaptions under black model.
black_receivers_swaption_value(...) calculates value of receiver’s swaptions under black model.
black_payers_swaption_value_fprime_by_strike(...) First derivative of value of payer’s swaption with respect to strike under black model.
black_payers_swaption_value_fhess_by_strike(...) Second derivative of value of payer’s swaption with respect to strike under black model.
black_payers_swaption_value_third_by_strike(...) Third derivative of value of payer’s swaption with respect to strike under black model.

Greeks

black_payers_swaption_delta(init_swap_rate, ...) calculates delta of payer’s swaptions under black model.
black_payers_swaption_vega(init_swap_rate, ...) calculates vega of payer’s swaption under black model.
black_payers_swaption_volga(init_swap_rate, ...) calculates volga of payer’s swaption under black model.
black_payers_swaption_vega_fprime_by_strike(...) calculates derivative of vega with respect to strike under black model.

Distribution

black_swaption_cdf(init_swap_rate, ...) calculates value of c.d.f. of black swaption.
black_swaption_pdf(init_swap_rate, ...) calculates value of p.d.f. of black swaption.

Black Scholes Model

Miscs

func_d1(underlying, strike, rate, maturity, vol) calculate \(d_{1}\) in black scholes formula.
func_d2(underlying, strike, rate, maturity, vol) calculate \(d_{2}\) in black scholes formula.
d_fprime_by_strike(underlying, strike, rate, ...) derivative of \(d_{1}\) with respect to \(K\)
d_fhess_by_strike(underlying, strike, rate, ...) second derivative of \(d_{i}\ (i = 1, 2)\) with respect to \(K\),

Basics

black_scholes_call_value(underlying, strike, ...) calculate call value in the case of today is not zero.
black_scholes_put_value(underlying, strike, ...) evaluates value of put option using put-call parity so that
black_scholes_call_value_fprime_by_strike(...) First derivative of value of call option with respect to strike under black scholes model.
black_scholes_call_value_fhess_by_strike(...) Second derivative of value of call option with respect to strike under black scholes model.
black_scholes_call_value_third_by_strike(...) Third derivative of value of call option with respect to strike under black scholes model.

Greeks

black_scholes_call_delta(underlying, strike, ...) calculates black scholes delta.
black_scholes_call_gamma(underlying, strike, ...) calculates black scholes gamma.
black_scholes_call_vega(underlying, strike, ...) calculates black scholes vega.
black_scholes_call_volga(underlying, strike, ...) black_scholes_call_volg
black_scholes_call_theta(underlying, strike, ...) calculates black scholes theta.
black_scholes_call_rho(underlying, strike, ...) calculates black scholes rho.
black_scholes_call_vega_fprime_by_strike(...) calculates derivative of black scholes vega with respect to strike.

Distribution

black_scholes_cdf(underlying, strike, rate, ...) calculates value of c.d.f. of black scholes model.
black_scholes_pdf(underlying, strike, rate, ...) calculates value of p.d.f. of black scholes model.

Local Volatility model

To be displayed.

Payoff functions

payoff_call(underlying, strike[, gearing]) Payoff of call option.
payoff_call_fprime(underlying, strike[, gearing]) derivative of payoff of call option with respect to underlying.
payoff_put(underlying, strike[, gearing]) Payoff of put option.
payoff_put_fprime(underlying, strike[, gearing]) derivative of payoff of call option with respect to underlying.
payoff_bull_spread(underlying, lower_strike, ...) Buy call option with lower_strike \(K_{\mathrm{lower}}\) and sell put option with upper_strike \(K_{\mathrm{upper}}\).
payoff_bull_spread_fprime(underlying, ...[, ...]) calculate value of derivative of payoff of bull spread option
payoff_straddle(underlying, strike[, gearing]) Buy call option and put option at same time with same strike.
payoff_strangle(underlying, lower_strike, ...) Buy call option and put option at same time with different strike.
payoff_butterfly_spread(underlying, ...[, ...]) Butterfly option consists of following options:
payoff_risk_reversal(underlying, ...[, gearing])
  • Sell 1 out of the money put option.

SABR model

Basics

sabr_payers_swaption_value(init_swap_rate, ...) calculate european payer’s swaption value.
sabr_receivers_swaption_value(...) calculate european reciever’s swaption value.
sabr_implied_vol_hagan(underlying, strike, ...) calculate implied volatility under SABR model.
sabr_atm_implied_vol_hagan(underlying, ...) calculate implied volatility under SABR model at the money.

Greeks

sabr_implied_vol_hagan_fprime_by_strike(...) first derivative of Hagan’s SABR implied volatility formula
sabr_implied_vol_hagan_fhess_by_strike(...) second derivative of Hagan’s SABR implied volatility formula
sabr_implied_vol_hagan_fprime_by_underlying(...) first derivative of Hagan’s SABR implied volatility formula
sabr_implied_vol_hagan_fhess_by_underlying(...) second derivative of Hagan’s SABR implied volatility formula
sabr_payers_swaption_delta(init_swap_rate, ...) calculate payer’s swaption delta under SABR model.

Distribution

sabr_cdf(underlying, strike, maturity, ...) calculates value of c.d.f. when underlying follows SABR model.
sabr_pdf(underlying, strike, maturity, ...) calculates value of p.d.f. when underlying follows SABR model.