2018-04-23 开胃学习数学系列 - 最大熵

Maximum Entropy Applications

Volatility skew

In the option market, OTM calls command higher implied volatility than the ATM/ITM calls. 在期权市场中,OTM看涨比ATM / ITM看涨有着 更高的隐含波动率

Suppose we only have the following three liquid 5M S&P500 index option:
现在假设我们只有以下三种流动5M S&P500指数期权:

from inst import BlackScholes
from scipy.stats import norm
import fmt

def optionCons(strikes, s) :
    a = [np.maximum(s-k, 0) for k in strikes]
    return np.array(a)


iv = np.array([.1594, .1481, .1383])

s = 1652.32
r = 0.
t = 5./12

ks = np.array([1611, s, 1694])

cs = np.array([BlackScholes.callPrice(0, s, k, t, v) for k, v in zip(ks, iv)])
d = np.array([BlackScholes.callDelta(0, s, k, t, v) for k, v in zip(ks, iv)])

df_opt = pd.DataFrame(np.array([cs, iv*100, d]).T, columns = ["Call Price", "Implied Vol(%)", "Delta"], index=ks)
fmt.displayDF(df_opt, "4g")

x = s*np.exp(np.arange(-1.5, 3, .001))
q = np.ones(len(x))
qn = norm.pdf((np.log(x/s)+.5*iv[1]*iv[1]*t)/(iv[1]*np.sqrt(t)))
qn = qn/sum(qn)

a = optionCons(ks, x)
e = np.ones(len(ks))*.0

mks = np.array([1322,  1487,  1570,  1611,  1652,  1694,  1735, 1818, 1982])
mvs = np.array([.2319, .1895, .1687, .1594, .1481, .1383, .1289, .1176, .1125])

7086733-ef58d5270d2bbbe6.png

我们对未来股票价格的分布进行离散抽样:
pi = P [s(t = 5M)= si],

  • 其中si是股票价格的离散
  • k 是执行价格
  • b(t) 是折现
  • pi 是执行改了??
  • 每个obesvered 期权价格v(k)成为pi中的线性约束:
7086733-8d0eebc39742eb98.png
  • 有了这个公式,然后应用 dual maximum entropy setup来找出, p *的隐含分布 implied distribution,
  • 所有strike的期权价格 之后看作 p∗
  • 由于时间跨度很短,discounting b(t) 忽略






Without prior belief

没有prior的 ME optimization结果,即使它完全准确地重新计算了observed prices,也没有多大意义。

# cs 是3个 call price
# q 是什么我确实不知道, size (4500,)
# a 又是什么,a是一堆0 和执行的数字
# e 又是什么? array([0., 0., 0.])
# res 是个对偶算出来的最小值
# po 是个分布 size (4500,) 在 call 附近取到再打值约0.008
# s是初始价格,为什么要在80 - 130 之间取值呢?为什么最后又返回了 1300 - 2200 这个范围?!公式是什么
cd = np.array([po.dot(np.maximum(x-k, 0)) for k in kd])
# 这一步很关键,但是我并没有理解



dual = me.MaxEntDual(q, a, cs, e)
res = minimize(dual.dual, np.zeros(len(cs)), jac=dual.grad, method="BFGS")
po = dual.dist(res.x)

kd = arange(80., 130., 1.)/100*s
cd = np.array([po.dot(np.maximum(x-k, 0)) for k in kd])
vd = [BlackScholes.compImpliedVolFromCall(0., s, k, t, c) for k, c in zip(kd, cd)]
# dd = [BlackScholes.callDelta(0, s, k, 1, v) for k, v in zip(kd, vd)]
# 这个是 impliedVol 我理解
# kd 是 strike price
figure(figsize=[12, 4])
subplot(1, 2, 1)
plot(x, dual.dist(res.x))
xlabel('Strike')
title('ME Distribution of Prices')
xlim(1200,2400)

subplot(1, 2, 2)
plot(kd, vd, 'g-')
plot(mks, mvs, 'k>')
plot(ks, iv, 'ro')
xlim(1200, 2200)
xlabel('Strike')
title('Implied Vol');
legend(['Max Entropy', 'Market']);

7086733-5bb56719f00f94fa.png

就是这个图可以说明:没有prior的 ME optimization结果,即使它完全准确地重新计算了observed prices,也没有多大意义呵呵。






Use the prior belief

我们可以利用stock return 是normal distribution 的prior belief ,并使用之前观察到的ATM
volatility:

  • The resulting distribution and volatility skew are reasonble
    由此产生的分布和波动skew是合理的
  • The whole vol skew curve is inferred from three option prices
    整个vol skew 曲线是从三个期权价格推断出来的
  • The resulting option prices are very close to the actual market
    由此产生的期权价格非常接近实际市场
dual = me.MaxEntDual(qn, a, cs, e)
res = minimize(dual.dual, np.zeros(len(cs)), jac=dual.grad, method="BFGS")
po = dual.dist(res.x)

cd = np.array([po.dot(np.maximum(x-k, 0)) for k in kd])
vd = [BlackScholes.compImpliedVolFromCall(0, s, k, t, c) for k, c in zip(kd, cd)]
#dd = [BlackScholes.callDelta(0, s, k, 1, v) for k, v in zip(kd, vd)]


## qn和 po的关系是什么?

figure(figsize=[12, 4])
subplot(1, 2, 1)
plot(x, qn)
plot(x, dual.dist(res.x))
# 在某个点会有最大的entropy

xlabel('Strike')
title('Max Entropy Distribution')
legend(['Prior', 'Max Entropy'])
xlim(1200,2600)

subplot(1, 2, 2)
axhline(iv[1])
plot(kd, vd, 'g-')
plot(mks, mvs, 'k>')
plot(ks, iv, 'ro')
xlim(1200, 2200)
xlabel('Strike')
legend(['Prior', 'Max Entropy', 'Market Quotes'])
title('Implied Vol');
7086733-a88fa4b680a1904f.png

猜你喜欢

转载自blog.csdn.net/weixin_34246551/article/details/87803500