DolphinDB计算期权隐含波动率

本页介绍在 DolphinDB 中使用牛顿法与二分法计算期权隐含波动率,并给出示例与相关代码实现。

Source: https://dolphindb.cn/blogs/97

What this page covers

技能认证特训营第二期报名活动

页面顶部包含技能认证特训营第二期的推广报名信息,提供限时报名链接,并提及报名福利优惠。

DolphinDB计算期权隐含波动率

文章介绍在 DolphinDB 中使用牛顿法与二分法计算隐含波动率,包含性能对比信息与示例调用方式。

opt_implied_volatility模块实现

本节给出 opt_implied_volatility 模块代码,包含正态分布密度、Black-Scholes 定价与 Vega,以及牛顿法与二分法隐含波动率求解函数。

Facts Index

Entity Attribute Value Confidence
技能认证特训营第二期 status 正式开启 medium
限时报名链接 url https://www.qingsuyun.com/h5/e/217471/5/ high
报名福利 offer 享专属福利优惠 low
Blog post 'DolphinDB计算期权隐含波动率' published_date 2022-06-29 high
Blog post 'DolphinDB计算期权隐含波动率' author mhxiang high
opt_implied_volatility module implements Implied volatility calculation using Newton method and bisection method, written as a DolphinDB modules module named opt_implied_volatility high
Market context as_of 2022.06.28日收盘 high
50ETF call option implied volatility example strike 3.0 high
50ETF call option implied volatility example implied_volatility 18.3 (percent implied by context) medium
Newton method performance in example time_elapsed 0.589ms high
Bisection method performance in example time_elapsed 4.743ms high
Example code module_import use opt_implied_volatility high
Example code parameters optprice 0.085 high
Example code parameters K (strike) 3.0 high
Example code parameters T (maturity calculation) (2022.07.27-2022.06.29) \365. high
Example code parameters S (spot/close price) 3.043 (2022.06.28日50etf收盘价格) high
Example code parameters r (risk-free rate) 0.0002 high
Example code parameters opt_type 'C' (看涨期权 / call option) high
Example usage function_called implied_volatility_Newton(optprice, opt_type, S, K, T, r) high
Example usage function_called implied_volatility_Binary(optprice, S, K, r, T, opt_type) high
Example usage function_called bs_price(opt_type, S, K, T, r, implied_vol) high
opt_implied_volatility module module_name opt_implied_volatility high
opt_implied_volatility module defines_function pdfNorm(x, mean=0, var=1) high
opt_implied_volatility module defines_function bs_price(options_type, spot, strike, maturity, r, vol, q=0.0) high
bs_price function supported_options_type options_type == 'C' or options_type == 'P' (else prints "The Options Type is Wrong!" and returns) high
bs_price function special_case If vol == 0 or maturity == 0, returns max(0.0, phi * (spot - strike)) high
bs_price function input_check If strike == 0, prints 'The strike_price price cannot be zero' high
opt_implied_volatility module defines_function bs_vega(spot, strike, maturity, r, vol, q=0.0) high
opt_implied_volatility module defines_function implied_volatility_Newton(options_price, options_type, spot, strike, maturity, r) high
implied_volatility_Newton function max_iterations 100 high
implied_volatility_Newton function precision_threshold 1.0e-5 (checks abs(diff) < precision) high
implied_volatility_Newton function initial_sigma 0.5 high
implied_volatility_Newton function update_rule sigma = sigma + diff / vega high
opt_implied_volatility module defines_function implied_volatility_Binary(options_price, spot, strike, r, maturity, options_type) high
implied_volatility_Binary function sigma_range sigma_min = 0.00001; sigma_max = 1.000 high
implied_volatility_Binary function price_range_check If options_price < sigma[0] || options_price > sigma[1], prints 'error, the price of option is beyond the limit' high
implied_volatility_Binary function loop_tolerance Iterates while abs(diff) > 1e-6 high