[MATLAB] BS期权隐含资产(implied asset)和隐含波动率(implied volatility)计算 迭代法 源码程序

本文介绍了如何使用迭代法在MATLAB中计算Black-Scholes(BS)期权的隐含资产价值和隐含波动率。讨论了在实际问题中遇到的挑战,特别是数值范围的问题,并提出了一种将两个变量限制在[0,1]范围内的技巧。文章提供了两种解决方案:一种是自定义迭代法,另一种是利用MATLAB的fsolve函数。还分享了相关源码的下载链接。" 123717688,5594651,Vite2与Vue3中PrismJS的配置与使用,"['前端开发', 'Vue', 'JavaScript', 'HTML', '代码预览']
摘要由CSDN通过智能技术生成

实际问题

已知B,r,sigma_e,E_t,T

实际上公式中的V_t就是implied asset,\sigma_a 就是implied volatility,公式与BS期权公式和equity方程

在实际全网调查中大多数都是对隐含波动率的计算,但是缺少对隐含资产(implied asset)和隐含波动率(implied volatility)的计算,且本人是电子计算机专业,在这方面也不免做了不少调查,以下便是对隐含资产(implied asset)和隐含波动率(implied volatility)的计算

csdn首发第一份资料!

解决方案

题目要求是用迭代法,一开始用牛顿迭代法,可以把问题简化成一个二元函数用牛顿迭代法去求解最低点,当时太年轻,两个变量直接用V_t\sigma_a,为什么说年轻呢,因为前

计算期权隐含波动的代码: ```matlab function [iv, K] = implied_volatility(S, K, r, T, C, type) % S: underlying asset price % K: strike price % r: risk-free interest rate % T: time to maturity (in years) % C: call option price % type: 'call' or 'put' tol = 1e-6; max_iter = 100; % Define the objective function if strcmp(type, 'call') obj_fun = @(sigma) (bsprice(S, K, r, T, sigma, type) - C)^2; elseif strcmp(type, 'put') obj_fun = @(sigma) (bsprice(S, K, r, T, sigma, type) - C)^2; end % Use fminbnd to find the implied volatility [iv, ~, exitflag] = fminbnd(obj_fun, tol, 1, optimset('MaxIter', max_iter)); if exitflag ~= 1 warning('Implied volatility not found'); end end function [price, delta, gamma, vega, theta] = bsprice(S, K, r, T, sigma, type) % S: underlying asset price % K: strike price % r: risk-free interest rate % T: time to maturity (in years) % sigma: volatility % type: 'call' or 'put' d1 = (log(S/K) + (r + 0.5*sigma^2)*T) / (sigma*sqrt(T)); d2 = d1 - sigma*sqrt(T); if strcmp(type, 'call') price = normcdf(d1)*S - normcdf(d2)*K*exp(-r*T); delta = normcdf(d1); gamma = normpdf(d1) / (S*sigma*sqrt(T)); vega = S*normpdf(d1)*sqrt(T); theta = (-S*normpdf(d1)*sigma/(2*sqrt(T)) - r*K*exp(-r*T)*normcdf(d2)) / 365; elseif strcmp(type, 'put') price = normcdf(-d2)*K*exp(-r*T) - normcdf(-d1)*S; delta = normcdf(d1) - 1; gamma = normpdf(d1) / (S*sigma*sqrt(T)); vega = S*normpdf(d1)*sqrt(T); theta = (-S*normpdf(d1)*sigma/(2*sqrt(T)) + r*K*exp(-r*T)*normcdf(-d2)) / 365; end end ``` 其中,bsprice函数计算了Black-Scholes期权定价公式中的期权价格、希腊字母(delta、gamma、vega和theta),implied_volatility函数使用fminbnd函数寻找隐含波动。 绘制波动微笑图的代码: ```matlab S = 100; % underlying asset price K = [80:5:120]; % strike prices r = 0.05; % risk-free interest rate T = 1; % time to maturity (in years) C = [20.54 16.06 12.36 9.36 7.05 5.30 4.03 3.11 2.46 1.99 1.68]; % call option prices P = [1.39 3.10 5.15 7.13 9.08 10.98 12.76 14.34 15.68 16.78 17.63]; % put option prices % Calculate implied volatilities for call options iv_call = zeros(size(K)); for i = 1:length(K) iv_call(i) = implied_volatility(S, K(i), r, T, C(i), 'call'); end % Calculate implied volatilities for put options iv_put = zeros(size(K)); for i = 1:length(K) iv_put(i) = implied_volatility(S, K(i), r, T, P(i), 'put'); end % Plot implied volatilities as a function of strike price plot(K, iv_call, 'b-', K, iv_put, 'r-'); xlabel('Strike price'); ylabel('Implied volatility'); title('Volatility smile'); legend('Call options', 'Put options'); ``` 其中,我们假设有11个不同的行权价,对应的看涨期权和看跌期权的价格分别为C和P。我们使用implied_volatility函数计算每个行权价对应的隐含波动,并绘制出波动微笑图。
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值