统计学在期权定价和交易中的应用

论坛 期权论坛 期权     
期权世界   2018-6-3 00:31   2281   0
期权定价与内在价值
[h1]常见的期权内在价值被定义为0与期权立刻执行所能获得回报的较大值,即max(S-K, 0)(看涨期权的情形)和max(K-S, 0)(看跌期权的情形)。[/h1]
  1. # Option Strike
  2. K = 8000
  3. # Graphical Output
  4. S = np.linspace(7000, 9000, 100) # index level values
  5. h = np.maximum(S - K, 0) # inner values of call option
  6. plt.figure()plt.plot(S, h, lw=2.5) # plot inner values at maturity
  7. plt.xlabel('index level $S_t$ at maturity')plt.ylabel('inner value of European call option')plt.grid(True)
复制代码


下面的代码是使用BSM模型来对期权进行定价:
  • 无收益资产欧式看涨期权的定价公式:




  • 无收益资产欧式看跌期权的定价公式:




下面画出了根据BSM模型计算出的期权的现值
  1. # Model and Option Parameters
  2. K = 8000 # strike price
  3. T = 1.0 # time-to-maturity
  4. r = 0.025 # constant, risk-less short rate
  5. vol = 0.2 # constant volatility
  6. # Sample Data Generation
  7. S = np.linspace(4000, 12000, 150) # vector of index level values
  8. h = np.maximum(S - K, 0) # inner value of option
  9. C = [BSM_call_value(S0, K, 0, T, r, vol) for S0 in S]  # calculate call option values# Graphical Output
  10. plt.figure()plt.plot(S, h, 'g-.', lw=2.5, label='inner value')  # plot inner value at maturity
  11. plt.plot(S, C, 'r', lw=2.5, label='present value')
  12. # plot option present valueplt.grid(True)plt.legend(loc=0)plt.xlabel('index level $S_0$')plt.ylabel('present value $C(t=0)$')
复制代码



历史波动率刻画
已经知道,B-S-M期权定价公式中的期权价格取决于下列五个参数:标的资产的市场价格,执行价格,到期期限,无风险利率和标的资产价格波动率。这五个参数中,前三个都是交易获得确定的值,在发达的经济市场,无风险利率也很容易估计,而估计标的资产的波动率要比估计无风险利率要困难的多。估计标的资长价格波动率有两种方法:历史波动率和隐含波动率。


所谓历史波动率,就是从标的资产价格的历史数据中计算出价格对数收益率的标准差,具体方法一般有以下两种:
  • 直接估计(矩估计)
  • GARCH模型

很遗憾,GARCH模型在中国市场无效。
模拟数据
  1. gbm = simulate_gbm()print_statistics(gbm)
复制代码
RETURN SAMPLE STATISTICS
---------------------------------------------
Mean of Daily Log Returns 0.000294
Std of Daily Log Returns 0.012479
Mean of Annua. Log Returns 0.074109
Std of Annua. Log Returns 0.198092
---------------------------------------------
Skew of Sample Log Returns 0.008369
Skew Normal Test p-value  0.861095
---------------------------------------------
Kurt of Sample Log Returns 0.059948
Kurt Normal Test p-value  0.495981
---------------------------------------------
Normal Test p-value 0.781084
---------------------------------------------
Realized Volatility 0.198147
Realized Variance 0.039262
  1. quotes_returns(gbm)
复制代码
上证50ETF的实际波动率
  1. etf50 = DataAPI.MktFunddGet(ticker=u"510050",beginDate=u"20150206",endDate=u"20160929",field=[u"closePrice", u"tradeDate"] ,pandas="1")etf50.set_index=("tradeDate")etf50['returns'] = np.log(etf50['closePrice'] /etf50['closePrice'].shift(1))
  2. # Realized Volatility (eg. as defined for variance swaps)
  3. etf50['rea_var'] = 252 * np.cumsum(etf50['returns'] ** 2) / np.arange(len(etf50))etf50['rea_vol'] = np.sqrt(etf50['rea_var'])print_statistics(etf50)
复制代码
RETURN SAMPLE STATISTICS
---------------------------------------------
Mean of Daily Log Returns -0.000067
Std of Daily Log Returns 0.021153
Mean of Annua. Log Returns -0.016917
Std of Annua. Log Returns 0.335787
---------------------------------------------
Skew of Sample Log Returns -0.734791
Skew Normal Test p-value  0.000000
---------------------------------------------
Kurt of Sample Log Returns 4.597651
Kurt Normal Test p-value  0.000000
---------------------------------------------
Normal Test p-value  0.000000
---------------------------------------------
Realized Volatility  0.335789
Realized Variance  0.112754
  1. # histogram of annualized daily log returns
  2. def return_histogram(data):  ''' Plots a histogram of the returns. '''  plt.figure(figsize=(9, 5))  x = np.linspace(min(data['returns'][1:]), max(data['returns'][1:]), 100)  plt.hist(np.array(data['returns'][1:]), bins=50, normed=True)  y = dN1(x, np.mean(data['returns'][1:]), np.std(data['returns'][1:]))  plt.plot(x, y, linewidth=2)  plt.xlabel('log returns')  plt.ylabel('frequency/probability')  plt.grid(True)return_histogram(etf50)
复制代码
  1. etf50.index = etf50['tradeDate']quotes_returns(etf50)
复制代码

期权的Greeks
期权的Greeks主要描述了期权价格对其标的的资产价格、到期时间、波动率和无风险利率四个参数值的敏感性指标。
  1. plot_greeks(BSM_delta, 'delta')
复制代码

  1. plot_greeks(BSM_gamma, 'gamma')
复制代码
  1. plot_greeks(BSM_theta, 'theta')
复制代码
  1. plot_greeks(BSM_rho, 'rho')
复制代码
  1. plot_greeks(BSM_vega, 'vega')
复制代码

二叉树模型和BSW模型
  1. BSM_benchmark = BSM_call_value(S0, K, 0, T, r, sigma)BSM_benchmark
复制代码
10.45058357218553
  1. CRR_option_value(S0, K, T, r, sigma, 'call', M=2000)
复制代码
10.449583775457942
  1. plot_convergence(10, 1011, 20)
复制代码

  1. plot_convergence(10, 1011, 25)
复制代码

动态对冲
  1. S, po, vt, errs, t = BSM_hedge_run(p=25)
复制代码
APPROXIMATION OF FIRST ORDER -----------------------------  step |   S_t |  Delta     1 |  97.10 |  -0.46    2 | 100.34 |  -0.40    3 | 101.03 |  -0.39    4 | 104.38 |  -0.30    5 | 103.81 |  -0.32    6 | 106.85 |  -0.27    7 | 109.36 |  -0.22    8 | 111.16 |  -0.21    9 | 111.09 |  -0.20     wrong   10 | 115.83 |  -0.15
(部分)
  1. plot_hedge_path(S, po, vt, errs, t)
复制代码

  1. pl_list = BSM_dynamic_hedge_mcs(M=200, I=150000)
复制代码
Value of American Put Option is  4.461
Delta t=0 is  -0.011
run 1000  p/l  0.044
run 2000  p/l  0.042
run 3000  p/l  0.305
run 4000  p/l  0.969
run 5000  p/l  -0.330
run 6000  p/l  0.093
run 7000  p/l  -0.438
run 8000  p/l  -0.156
run 9000  p/l  -0.126
run 10000  p/l  0.187
SUMMARY STATISTICS FOR P&L
---------------------------------
Dynamic Replications 10000
Time Steps 200
Paths for Valuation 150000
Maximum  2.358
Average 0.008
Median 0.006
Minimum -1.641
---------------------------------

来源:量化投资与机器学习

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:14304
帖子:3032
精华:1
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP