UNPKG

@volare.finance/volare.js

Version:
62 lines (61 loc) 2.88 kB
/** * @file greeks.ts * @description Calculation of option greeks. See {@link http://en.wikipedia.org/wiki/Black%E2%80%93Scholes_model#The_Greeks|Wikipedia} * @author astra <astra@volare.finance> * @date 2022 */ /** * @description Calculates the delta of an option. * @param {Number} s Current price of the underlying * @param {Number} k Strike price * @param {Number} t Time to expatriation in years * @param {Number} iv Volatility as a decimal * @param {Number} r Annual risk-free interest rate as a decimal * @param {Boolean} isPut The type of option * @returns {Number} The delta of the option */ export declare function getDelta(s: number, k: number, t: number, iv: number, r: number, isPut: boolean): number; /** * @description Calculates the rho of an option. * @param {Number} s Current price of the underlying * @param {Number} k Strike price * @param {Number} t Time to expatriation in years * @param {Number} iv Volatility as a decimal * @param {Number} r Annual risk-free interest rate as a decimal * @param {Boolean} isPut The type of option * @param {Number} [scale=100] The value to scale rho by (100=100BPS=1%, 10000=1BPS=.01%) * @returns {Number} The rho of the option */ export declare function getRho(s: number, k: number, t: number, iv: number, r: number, isPut: boolean, scale?: number): number; /** * @description Calculates the vega of a call and put option. * @param {Number} s Current price of the underlying * @param {Number} k Strike price * @param {Number} t Time to expatriation in years * @param {Number} iv Volatility as a decimal * @param {Number} r Annual risk-free interest rate as a decimal * @returns {Number} The vega of the option */ export declare function getVega(s: number, k: number, t: number, iv: number, r: number): number; /** * @description Calculates the theta of an option. * @param {Number} s Current price of the underlying * @param {Number} k Strike price * @param {Number} t Time to expatriation in years * @param {Number} iv Volatility as a decimal * @param {Number} r Annual risk-free interest rate as a decimal * @param {Boolean} isPut The type of option * @param {Number} [scale=365] The number of days to scale theta by - usually 365 or 252 * @returns {Number} The theta of the option */ export declare function getTheta(s: number, k: number, t: number, iv: number, r: number, isPut: boolean, scale?: number): number; /** * @description Calculates the gamma of a call and put option. * @param {Number} s Current price of the underlying * @param {Number} k Strike price * @param {Number} t Time to expatriation in years * @param {Number} iv Volatility as a decimal * @param {Number} r Annual risk-free interest rate as a decimal * @returns {Number} The gamma of the option */ export declare function getGamma(s: number, k: number, t: number, iv: number, r: number): number;