@volare.finance/volare.js
Version:
The SDK for Volare Protocol
48 lines (47 loc) • 2.29 kB
TypeScript
/**
* @file black-scholes.ts
* @description Black-Scholes option pricing formula and supporting statistical functions.
* @author astra <astra@volare.finance>
* @date 2022
*/
/**
* Standard normal density function.
* @description See {@link http://en.wikipedia.org/wiki/Normal_distribution#Cumulative_distribution_function|Wikipedia page}.
* @param {Number} x The value to calculate the standard normal density of
* @returns {Number} The value of the standard normal density function at x
*/
export declare function stdNormDensity(x: number): number;
/**
* Standard normal cumulative distribution function. The probability is estimated
* by expanding the CDF into a series using the first 100 terms.
* See {@link http://en.wikipedia.org/wiki/Normal_distribution#Cumulative_distribution_function|Wikipedia page}.
*
* @param {Number} x The upper bound to integrate over. This is P{Z <= x} where Z is a standard normal random variable.
* @returns {Number} The probability that a standard normal random variable will be less than or equal to x
*/
export declare function stdNormCDF(x: number): number;
/**
* Black-Scholes option pricing formula.
* See {@link http://en.wikipedia.org/wiki/Black%E2%80%93Scholes_model#Black-Scholes_formula|Wikipedia page}
* for pricing puts in addition to calls.
*
* @param {Number} s Current price of the underlying
* @param {Number} k Strike price
* @param {Number} t Time to expatriation in years
* @param {Number} v Volatility as a decimal
* @param {Number} r Annual risk-free interest rate as a decimal
* @param {Boolean} isPut The type of option to be priced
* @returns {Number} Price of the option
*/
export declare function blackScholes(s: number, k: number, t: number, v: number, r: number, isPut: boolean): number;
/**
* Calculate omega as defined in the Black-Scholes formula.
*
* @param {Number} s Current price of the underlying
* @param {Number} k Strike price
* @param {Number} t Time to expatriation in years
* @param {Number} v Volatility as a decimal
* @param {Number} r Annual risk-free interest rate as a decimal
* @returns {Number} The value of omega
*/
export declare function getW(s: number, k: number, t: number, v: number, r: number): number;