The financial functions are defined in the header pnl/pnl_finance.h.
int pnl_cf_call_bs (double s, double k, double T, double r, double divid, double
sigma, double *ptprice, double *ptdelta)
Description Compute the price and delta of a call option (s-k)+ in the Black-Scholes
model with volatility sigma, instantaneous interest rate r, maturity T and dividend rate
divid. The parameters ptprice and ptdelta are respectively set to the price and delta on
output.
int pnl_cf_put_bs (double s, double k, double T, double r, double divid, double
sigma, double *ptprice, double *ptdelta)
Description Compute the price and delta of a put option (k-s)+ in the Black-Scholes
model with volatility sigma, instantaneous interest rate r, maturity T and dividend rate
divid. The parameters ptprice and ptdelta are respectively set to the price and delta on
output.
double pnl_bs_call (double s, double k, double T, double r, double divid, double
sigma)
Description Compute the price of a call option with spot s and strike k in the
Black-Scholes model with volatility sigma, instantaneous interest rate r, maturity T and
dividend rate divid.
double pnl_bs_put (double s, double k, double T, double r, double divid, double
sigma)
Description Compute the price a put option with spot s and strike k in the
Black-Scholes model with volatility sigma, instantaneous interest rate r, maturity T and
dividend rate divid.
double pnl_bs_call_put (int iscall, double s, double k, double T, double r, double
divid, double sigma)
Description Compute the price of a put option if iscall=0 or a call option if iscall=1
with spot s and strike k in the Black-Scholes model with volatility sigma, instantaneous
interest rate r, maturity T and dividend rate divid.
double pnl_bs_vega (double s, double k, double T, double r, double divid, double
sigma)
Description Compute the vega of a put or call option with spot s and strike k in the
Black-Scholes model with volatility sigma, instantaneous interest rate r, maturity T and
dividend rate divid.
double pnl_bs_gamma (double s, double k, double T, double r, double divid, double
sigma)
Description Compute the gamma of a put or call option with spot s and strike k in
the Black-Scholes model with volatility sigma, instantaneous interest rate r, maturity
T and dividend rate divid.
Practitioners do not speak in terms of option prices, but rather compare prices in terms of their implied Black & Scholes volatilities. So this parameter is very useful in practice. Here, we propose two functions to compute σimpl : the first one is for one up-let, maturity, strike, option price. the second function is for a list of strikes and maturities, a matrix of prices (with strikes varying row-wise).
double pnl_bs_implicit_vol (int is_call, double Price, double s, double K, double
T, double r, double divid, int *error)
Description Compute the implied volatility of a put option if iscall=0 or a call option
if iscall=1 with spot s and strike K in the Black-Scholes model with instantaneous
interest rate r, maturity T and dividend rate divid. On output error is OK if the
computation of the implied volatility succeeded or FAIL if it failed.
int pnl_bs_matrix_implicit_vol (const PnlMatInt *iscall, const PnlMat *Price,
double s, double r, double divid, const PnlVect *K, const PnlVect *T, PnlMat *Vol)
Description Compute the matrix of implied volatilities Vol(i,j) of a put option
if iscall(i,j)=0 or a call option if iscall(i,j)=1 with spot s and strike K(j) in the
Black-Scholes model with instantaneous interest rate r, maturity T(j) and dividend rate
divid. This function returns the number of failures, when everything succeeded it returns
0.