【FinE】隐含波动率
导航
- 隐含波动率
- 二分法
- 案例
- 解析
- 牛顿迭代法
- 案例
- 解析
- 参考资料
隐含波动率
隐含波动率是市场上无法观察到的波动率,通过Black-Scholes定价公式计算出的波动率,由于无法给出解析式,因此需要借助数值计算给出近似解,主要有二分法和牛顿法.
二分法
二分法求解隐含波动率步骤如下:
1.设置隐含波动率上下限v_lo
和v_hi
2.计算隐含波动率均值(v_lo+v_hi)/2
代入BS期权定价公式
3.计算差值,对比精度
案例
看涨期权价格为1.8751.8751.875,标的资产价格为212121,期权行权价格为202020,无风险利率为10%10\%10%,权利期还有333个月,求隐含波动率
解析
c++
二分法求解
#include<iostream>
#include<vector>
#include<cmath>
#include<cstring>
#include<cassert>
#include<iomanip>
#include<random>
#include<map>
using namespace std;const double pi=3.1415926;double N(const double &x){if(x>6.0) return 1.0;if(x<-6.0) return 0.0;double b1=0.31938153;double b2=-0.356563782;double b3=1.781477937;double b4=-1.821255978;double b5=1.330274429;double p=0.2316419;double c=1.0/sqrt(2*pi);double a=fabs(x);double k=1.0/(1+a*p);double b=c*exp(-pow(x, 2)/2.0);double n=((((b5*k+b4)*k+b3)*k+b2)*k+b1)*k;n=1.0-b*n;if(x<0.0) n=1.0-n;return n;
}double BSprice(const double& S, const double& K, const double& r, const double& sigma, const double& tm){double d1=(log(S/K)+(r+pow(sigma, 2)/2))/(sigma*sqrt(tm));double d2=d1-sigma*sqrt(tm);double c=S*N(d1)-K*exp(-r*tm)*N(d2);return c;
}double binary_search(const double& S, const double& K, const double& r, const double& tm, const double price){const double EPS=1e-5;double lo=1e-5;double hi=0.5;while(lo+EPS<hi){double sigma=(lo+hi)/2;double c=BSprice(S, K, r, sigma, tm);if(c-price<0.00) lo=sigma;else hi=sigma;}return lo;
}int main(){double S=21, K=20, r=0.10, tm=0.25, price=1.875;double sigma=binary_search(S, K, r, tm, price);cout<<"二分法求隐含波动率为: "<<sigma<<endl;return 0;
}
python
二分法求解
from scipy.stats import norm as N
from scipy.stats import multivariate_normal as mvn
from math import log, exp, pi
import numpy as npdef bsprice(S, K, r, sigma, tm):d1=(log(S/K)+(r+sigma**2/2))/(sigma*sqrt(tm))d2=d1-sigma*sqrt(tm)c=S*N.cdf(d1)-K*exp(-r*tm)*N.cdf(d2)return cdef binary_search(S, K, r, tm, price):EPS=1e-6hi, lo=0.5, 1e-5while lo+EPS<hi:sigma=(lo+hi)/2c=bsprice(S, K, r, sigma, tm)if c-price<0: lo=sigmaelse: hi=sigmareturn losigma=binary_search(21, 20, 0.1, 0.25, 1.875)
print('二分法求隐含波动率为: {}'.format(sigma))
牛顿迭代法
牛顿-拉夫逊(Newton-Raphson)法可以求解方程近似解.
1.将函数f(x)f(x)f(x)在x0x_0x0附近Taylor展开
f(x)=f(x0)+(x−x0)f′(x0)+(x−x0)f′′(x0)/2!+…f(x)=f(x_0)+(x-x_0)f'(x_0)+(x-x_0)f''(x_0)/2!+\dots f(x)=f(x0)+(x−x0)f′(x0)+(x−x0)f′′(x0)/2!+…
2.取一阶展开近似
f(x)=f(x0)+(x−x0)f′(x0)f(x)=f(x_0)+(x-x_0)f'(x_0) f(x)=f(x0)+(x−x0)f′(x0)
求解方程f(x)=0f(x)=0f(x)=0
f(x0)+(x−x0)f′(x0)=0⇒x=x0−f(x0)/f′(x0)f(x_0)+(x-x_0)f'(x_0)=0\Rightarrow x=x_0-f(x_0)/f'(x_0) f(x0)+(x−x0)f′(x0)=0⇒x=x0−f(x0)/f′(x0)
得到迭代公式
xn+1=xn−f(xn)f′(xn)x_{n+1}=x_n-\frac{f(x_n)}{f'(x_n)} xn+1=xn−f′(xn)f(xn)
使用牛顿法计算隐含波动率步骤如下:
1.令f(σ)=c−cBS(σ)f(\sigma)=c-c_{BS}(\sigma)f(σ)=c−cBS(σ)是关于σ\sigmaσ的一元函数
2.迭代计算隐含波动率
σi+1=σi−c−cBS(σi)∂cBS(σ)∂σ∣σi\sigma_{i+1}=\sigma_i-\frac{c-c_{BS}(\sigma_i)}{\frac{\partial c_{BS}(\sigma)}{\partial \sigma}|_{\sigma_i}} σi+1=σi−∂σ∂cBS(σ)∣σic−cBS(σi)
收敛条件为∣f(σi+1)−f(σi)∣<ε|f(\sigma_{i+1})-f(\sigma_i)|<\varepsilon∣f(σi+1)−f(σi)∣<ε.
案例
看涨期权价格为1.8751.8751.875,标的资产价格为212121,期权行权价格为202020,无风险利率为10%10\%10%,权利期还有333个月,求隐含波动率
解析
使用牛顿迭代法计算
c++
计算代码
#include<iostream>
#include<vector>
#include<cmath>
#include<cstring>
#include<cassert>
#include<iomanip>
#include<random>
#include<map>
using namespace std;const double pi=3.1415926;double N(const double &x){if(x>6.0) return 1.0;if(x<-6.0) return 0.0;double b1=0.31938153;double b2=-0.356563782;double b3=1.781477937;double b4=-1.821255978;double b5=1.330274429;double p=0.2316419;double c=1.0/sqrt(2*pi);double a=fabs(x);double k=1.0/(1+a*p);double b=c*exp(-pow(x, 2)/2.0);double n=((((b5*k+b4)*k+b3)*k+b2)*k+b1)*k;n=1.0-b*n;if(x<0.0) n=1.0-n;return n;
}double BSprice(const double& S, const double& K, const double& r, const double& sigma, const double& tm){double d1=(log(S/K)+(r+pow(sigma, 2)/2))/(sigma*sqrt(tm));double d2=d1-sigma*sqrt(tm);double c=S*N(d1)-K*exp(-r*tm)*N(d2);return c;
}double n(double x){return exp(-pow(x, 2)/2.00)/sqrt(2.00*pi);
}double newton(const double& S, const double& K, const double& r, const double& tm, const double price){const double EPS=1e-5;double sigma=(price/S)/(0.398*sqrt(tm));const int max_iter=1000;for(int i=0; i<max_iter; ++i){double c=BSprice(S, K, r, sigma, tm);double d=price-c;if(fabs(d)<EPS) return sigma;double d1=(log(S/K)+(r+pow(sigma, 2)/2))/(sigma*sqrt(tm));double vega=S*sqrt(tm)*n(d1);sigma=sigma+d/vega;}return sigma;
}int main(){double S=21, K=20, r=0.10, tm=0.25, price=1.875;double sigma=newton(S, K, r, tm, price);cout<<"牛顿法求隐含波动率为: "<<sigma<<endl;return 0;
}
参考资料
金融资产的定价理论与数值计算 北京大学出版社 田文昭
【FinE】隐含波动率相关推荐
- NUMECA FINE Turbo 14中文版
教程: 1.下载文件包,然后解压,得到软件安装程序和文件 2.运行Setup.exe主程序开始安装软件 3.依安装向导提示完成软件安装,软件安装成功后,选择第二项,先不要运行启动软件 4.将NUMEC ...
- [代码示例]用Fine Uploader+ASP.NET MVC实现ajax文件上传
[代码示例]用Fine Uploader+ASP.NET MVC实现ajax文件上传 原文 [代码示例]用Fine Uploader+ASP.NET MVC实现ajax文件上传 Fine Upload ...
- Unity Fine Prued Tiled Light (FPTL)
Fine Prued Tiled Light Lists 视频讲解:https://www.bilibili.com/video/av90517615 FPT是在Tile裁剪的基础上在进行一次剔除 可 ...
- 真格量化-隐含波动率购买
# coding:utf-8 #!/usr/bin/env python from PoboAPI import * import datetime import numpy as np #50ETF ...
- python 隐含波动率_【BSM模型】用实际市场数据计算隐含波动率并验证波动率微笑...
在Black-Scholes期权定价模型中,不能直接观察到的参数只有股票价格的波动率.波动率可以由历史数据进行估计,这是历史波动率.隐含波动率也是交易员非常关心的,隐含波动率是期权的市场价格中所包含的 ...
- pytorch深度学习-微调(fine tuning)
微调(fine tuning) 首先举一个例子,假设我们想从图像中识别出不同种类的椅子,然后将购买链接推荐给用户.一种可能的方法是先找出100种常见的椅子,为每种椅子拍摄1,000张不同角度的图像,然 ...
- 什么是微调(Fine Tune)?什么时候使用什么样的微调?【数据量和数据相似度决定】
目录 微调的基本思想 什么是模型微调? 为什么要微调? 什么情况下使用微调? 不同数据集下使用微调? 微调的基本思想 我们的网络架构一般可以分为两部分,分别是:特征抽取和softmax回归, 特征抽取 ...
- 《中国人工智能学会通讯》——2.35 敏捷和灵巧精细动作技能(Agile and Dexterous Fine Motor Skills)...
2.35 敏捷和灵巧精细动作技能(Agile and Dexterous Fine Motor Skills) 今年 AI 进展并不局限于电脑屏幕. 今年的早些时候,一支德国的灵长类学团队记录下了灵长 ...
- 的garch预测_精品细读|基于隐含波动率、已实现波动率和GARCH模型波动率的预测...
这是"高频数据"第130篇推送 编辑:张莉(西南交通大学数学学院) 审稿:唐瑜穗(西南交通大学经济管理学院) 仅用于学术交流,原本版权归原作者和原发刊所有 导读 contents ...
- ORA-39181: Only partial table data may be exported due to fine grain access control on OE.PURCHAS
操作环境:Oracle Linux 6.5+Oracle11g 今天在用数据泵导出表空间的实验中出现一个错误:ORA-39181: Only partial table data may be exp ...
最新文章
- hibernate4中取得connection的方法
- UI:UITableView 编辑、cell重用机制
- win2008无法用计算机名共享,Windows Server 2008 R2中文件共享
- Spring @PostConstruce 和 @PreDestroy 实例化\销毁 bean 时
- BZOJ 2588: Spoj 10628. Count on a tree( LCA + 主席树 )
- 智能安全实验室-杀马(Defendio) 2.5.0.430 :自定义上报威胁
- 层次聚类 簇数_聚类(一):K-means、层次、DBSCAN、均值漂移、K-Means 与 KNN
- 分布式文件存储FastDFS之配置Nginx模块
- java使用fast报表控件_FastReport报表控件的使用
- 32位Linux系统时间截止,linux – 如果系统设置为2038年以后的日期,则ntpdate失败
- Mac 安装Gradle教程
- matlab subs eval,MATLAB里计算表达式的值:subs函数与eval、vpa、double等配合使用
- 如何简单又好看地美化你的Ubuntu界面
- 直播预告 | openGauss自治运维能力的技术演进分享
- python: 贝叶斯实现实例
- 项目实训第五周团队及个人进展汇报
- Linux——Linux必备的基础知识总结
- C++结构体 结构体定义和使用、结构体数组、结构体指针、结构体嵌套结构体、结构体做函数参数
- pspad 格式化php代码,PSPad editor编辑
- 关于Kindle,我所知道的
热门文章
- [渝粤题库]西北工业大学自动控制理论
- 黑鲨重装计算机安装无法继续,示例黑鲨装机大师装机失败无法开机怎么办?
- 2022年全球程序员薪资排行出炉:中国倒数第九,GO最赚钱
- 大规模定制(Mass Customization,MC)
- 『原创』老范的XML文档编辑程序——不是一般的山寨!(原创附程序)
- 计算机单位换换算,时间单位换算表与计算机单位换算
- Windows 技术篇 - win10系统更新后切换应用一直自动切换为微软输入法解决方法,win10微软输入法卸载方法
- 反爬虫破解——裁判文书网
- 记java的那些编辑器的故事之凌嘉文+李晓彤-结对编程
- win10关闭某个端口