UNPKG

@bmancini55/finance

Version:

Finance utilities for JavaScript

120 lines (119 loc) 4.66 kB
/** * Using Black-Scholes, this will calculate the call price for a European options given * the current spot price, strike price, time in years til expiration, a risk free return, * the volatility of the asset. * * @remarks * https://en.wikipedia.org/wiki/Black%E2%80%93Scholes_model#Black%E2%80%93Scholes_formula * * @param call true for call, fasle for put * @param spot spot price * @param strike strike price * @param time time in years * @param rfr risk free rate * @param sigma volatility */ export declare function calcOptionPrice(call: boolean, spot: number, strike: number, time: number, rfr: number, sigma: number): number; /** * Using Black-Scholes and put-call parity, calculate the expected put price given * call price, current spot price, strike price, time and riskFreeRate * * @remarks * https://en.wikipedia.org/wiki/Black%E2%80%93Scholes_model#Black%E2%80%93Scholes_formula * * @param option price * @param spot price * @param strike price * @param time in years * @param rfr * @returns price of the put option */ export declare function calcPutFromCall(option: number, spot: number, strike: number, time: number, rfr: number): number; /** * Using Black-Scholes and put-call parity, calculate the expected call price given * put price, current spot price, strike price, time and riskFreeRate * * @param option price * @param spot price * @param strike price * @param time in years * @param rfr * @returns price of the call option */ export declare function calcCallFromPut(option: number, spot: number, strike: number, time: number, rfr: number): number; /** * Calculates delta * @param call true for call, false for put * @param spot spot price of the asset * @param strike strike price of the option * @param time days until expiration * @param rfr risk free rate * @param sigma volatility of the asset */ export declare function calcOptionDelta(call: boolean, spot: number, strike: number, time: number, rfr: number, sigma: number): number; /** * Calculates gamma * @param spot spot price of the asset * @param strike strike price of the option * @param time days until expiration * @param rfr risk free rate * @param sigma volatility of the asset */ export declare function calcOptionGamma(spot: number, strike: number, time: number, rfr: number, sigma: number): number; /** * Calculates theta * @param call true for call, false for put * @param spot spot price of the asset * @param strike strike price of the option * @param time days until expiration * @param rfr risk free rate * @param sigma volatility of the asset */ export declare function calcOptionTheta(call: boolean, spot: number, strike: number, time: number, rfr: number, sigma: number): number; /** * Calculates the vega for a European option. Vega is the first * derivative of an option’s price with respect to volatility. * * Note that this calculates based on the sigma as the unit, * so it represents a 100% change in volatility. You must divide * by 100 to get the 1% change (which is more useful) for calculating * price changes. * * @param spot spot price of the asset * @param strike strike price of the option * @param time days until expiration * @param rfr risk free rate * @param sigma volatility of the asset */ export declare function calcOptionVega(spot: number, strike: number, time: number, rfr: number, sigma: number): number; /** * Calculates rho for a European option. * @param call true for call, false for put * @param spot spot price of the asset * @param strike strike price of the option * @param time days until expiration * @param rfr risk free rate * @param sigma volatility of the asset */ export declare function calcOptionRho(call: boolean, spot: number, strike: number, time: number, rfr: number, sigma: number): number; /** * Estimate the implied volatility via the Brenner and Subrahmanyam method. * * @param option price of the option * @param spot spot price of the asset * @param time time in days */ export declare function estimateIV(option: number, spot: number, time: number): number; /** * Calculate the implied volatility by using Newton-Raphson where BS(v) * and Vega(v) are used as f(x) and g(x) respectively. * * @param call true for call, false for put * @param option price of the option * @param spot spot price of the asset * @param strike strike price of the option * @param time time in days * @param rfr risk free rate * @param estIV optional estimated IV, defaults to 1 */ export declare function calcIV(call: boolean, option: number, spot: number, strike: number, time: number, rfr: number, estIV?: number): number;