第一部分 新手入门
- 一 量化投资视频学习课程
- 二 Python 手把手教学
- 量化分析师的Python日记【第1天:谁来给我讲讲Python?】
- 量化分析师的Python日记【第2天:再接着介绍一下Python呗】
- 量化分析师的Python日记【第3天:一大波金融Library来袭之numpy篇】
- 量化分析师的Python日记【第4天:一大波金融Library来袭之scipy篇】
- 量化分析师的Python日记【第5天:数据处理的瑞士军刀pandas】
- 量化分析师的Python日记【第6天:数据处理的瑞士军刀pandas下篇
- 量化分析师的Python日记【第7天:Q Quant 之初出江湖】
- 量化分析师的Python日记【第8天 Q Quant兵器谱之函数插值】
- 量化分析师的Python日记【第9天 Q Quant兵器谱之二叉树】
- 量化分析师的Python日记【第10天 Q Quant兵器谱 -之偏微分方程1】
- 量化分析师的Python日记【第11天 Q Quant兵器谱之偏微分方程2】
- 量化分析师的Python日记【第12天:量化入门进阶之葵花宝典:因子如何产生和回测】
- 量化分析师的Python日记【第13天 Q Quant兵器谱之偏微分方程3】
- 量化分析师的Python日记【第14天:如何在优矿上做Alpha对冲模型】
- 量化分析师的Python日记【第15天:如何在优矿上搞一个wealthfront出来】
第二部分 股票量化相关
- 一 基本面分析
- 1.1 alpha 多因子模型
- 1.2 基本面因子选股
- 1.3 财报阅读 • [米缸量化读财报] 资产负债表-投资相关资产
- 1.4 股东分析
- 1.5 宏观研究
- 二 套利
- 三 事件驱动
- 四 技术分析
- 4.1 布林带
- 4.2 均线系统
- 4.3 MACD
- 4.4 阿隆指标 • 技术指标阿隆( Aroon )全解析
- 4.5 CCI • CCI 顺势指标探索
- 4.6 RSI
- 4.7 DMI • DMI 指标体系的构建及简单应用
- 4.8 EMV • EMV 技术指标的构建及应用
- 4.9 KDJ • KDJ 策略
- 4.10 CMO
- 4.11 FPC • FPC 指标选股
- 4.12 Chaikin Volatility
- 4.13 委比 • 实时计算委比
- 4.14 封单量
- 4.15 成交量 • 决战之地, IF1507 !
- 4.16 K 线分析 • 寻找夜空中最亮的星
- 五 量化模型
- 5.1 动量模型
- 5.2 Joseph Piotroski 9 F-Score Value Investing Model
- 5.3 SVR
- 5.4 决策树、随机树
- 5.5 钟摆理论
- 5.6 海龟模型
- 5.7 5217 策略
- 5.8 SMIA
- 5.9 神经网络
- 5.10 PAMR
- 5.11 Fisher Transform
- 5.12 分型假说, Hurst 指数
- 5.13 变点理论
- 5.14 Z-score Model
- 5.15 机器学习
- 5.16 DualTrust 策略和布林强盗策略
- 5.17 卡尔曼滤波
- 5.18 LPPL anti-bubble model
- 六 大数据模型
- 6.1 市场情绪分析
- 6.2 新闻热点
- 七 排名选股系统
- 八 轮动模型
- 九 组合投资
- 十 波动率
- 十一 算法交易
- 十二 中高频交易
- 十三 Alternative Strategy
第三部分 基金、利率互换、固定收益类
- 一 分级基金
- 二 基金分析
- 三 债券
- 四 利率互换
第四部分 衍生品相关
- 一 期权数据
- 二 期权系列
- 三 期权分析
- 四 期货分析
文章来源于网络收集而来,版权归原创者所有,如有侵权请及时联系!
期权市场一周纵览
本文档依赖的数据 option_data.csv
可以通过运行 期权高频数据准备 notebook而获取。
from matplotlib import pylab
import pandas as pd
import seaborn as sns
sns.set(style="white", context="talk")
import pandas as pd
pd.options.display.float_format = '{:,>.4f}'.format
res = pd.read_csv('option_data.csv', parse_dates=['pdDateTime'])
res['timeStamp'] = res['dataDate'] + ' ' + res['dataTime']
res['timeStamp'] = pd.to_datetime(res['timeStamp'])
res.optionId = res.optionId.astype('str')
res = res.drop('Unnamed: 0', axis=1)
res.pdDateTime = res.pdDateTime.apply(lambda x:Date(x.year,x.month,x.day))
print('开始日期: ' + res['dataDate'].iloc[0])
print('结束日期: ' + res['dataDate'].iloc[-1])
print('Market Sample: ')
res[['dataDate', 'dataTime', 'optionId', 'lastPrice', 'bidPrice1', 'askPrice1', 'lastPrice(vol)']].head()
开始日期: 2015-03-05
结束日期: 2015-03-09
Market Sample:
dataDate | dataTime | optionId | lastPrice | bidPrice1 | askPrice1 | lastPrice(vol) | |
---|---|---|---|---|---|---|---|
0 | 2015-03-05 | 09:30:00 | 10000001 | 0.1677 | 0.1717 | 0.1765 | 0.3468 |
1 | 2015-03-05 | 09:30:14 | 10000001 | 0.1717 | 0.1717 | 0.1765 | 0.3768 |
2 | 2015-03-05 | 09:30:15 | 10000001 | 0.1717 | 0.1610 | 0.1798 | 0.3768 |
3 | 2015-03-05 | 09:30:16 | 10000001 | 0.1678 | 0.1610 | 0.1798 | 0.3525 |
4 | 2015-03-05 | 09:30:18 | 10000001 | 0.1798 | 0.1641 | 0.1798 | 0.4205 |
1. 买卖价差分析
1.1 买卖价差(到期时间)
bidAskSample = res[[u'optionId', 'pdDateTime', 'dataDate', 'contractType', 'strikePrice', 'bidAskSpread(bps)']]
bidAskSample.columns = ['optionId', 'maturity', 'tradingDate', 'contractType', 'strikePrice', 'bidAskSpread(bps)']
tmp = bidAskSample.groupby(['maturity'])[['bidAskSpread(bps)']]
ax = tmp.mean().plot(kind = 'bar', figsize = (12,6), rot = 45)
ax.set_title(u'买卖价差(按照期权到期时间)', fontproperties = font, fontsize = 25)
ax.set_xlabel(u'到期时间', fontproperties = font, fontsize = 15)
<matplotlib.text.Text at 0x7798290>
1.2 买卖价差(行权价)
tmp = bidAskSample.groupby(['maturity', 'strikePrice'])[['bidAskSpread(bps)']].mean().unstack()
ax = tmp.plot(kind = 'bar', figsize = (12,6), legend = True, rot = 45)
patches, labels = ax.get_legend_handles_labels()
labels = ['Strike/' + l.strip('()').split()[1] for l in labels]
ax.legend(patches, labels, loc='best', prop = font)
ax.set_title(u'买卖价差(按照期权行权价)', fontproperties = font, fontsize = 25)
ax.set_xlabel(u'到期时间', fontproperties = font, fontsize = 15)
<matplotlib.text.Text at 0x5bc08d0>
1.3 买卖价差(期权类型)
tmp = bidAskSample.groupby(['maturity', 'contractType'])[['bidAskSpread(bps)']].mean().unstack()
ax = tmp.plot(kind = 'bar', figsize = (12,6), rot = 45)
patches, labels = ax.get_legend_handles_labels()
labels = [l.strip('()').split()[1] for l in labels]
ax.legend(patches, labels, loc='best')
ax.set_title(u'买卖价差(按照期权类型)', fontproperties = font, fontsize = 25)
ax.set_xlabel(u'到期时间', fontproperties = font, fontsize = 15)
<matplotlib.text.Text at 0x7a8d7d0>
2. 日交易量分析
volumeSample = res[[u'optionId', 'pdDateTime', 'dataDate', 'contractType', 'strikePrice', 'volume']]
volumeSample.columns = ['optionId', 'maturity', 'tradingDate', 'contractType', 'strikePrice', 'volume']
tmp = volumeSample.groupby(['tradingDate'])[['volume']].sum()
ax = tmp.plot(kind = 'bar', figsize = (12,6), rot = 45)
ax.set_title(u'日交易量(按交易日期)', fontproperties = font, fontsize = 25)
ax.set_xlabel(u'交易日期', fontproperties = font, fontsize = 15)
<matplotlib.text.Text at 0x7a72d90>
2.1 日交易量(到期时间)
tmp = volumeSample.groupby(['maturity', 'tradingDate'])[['volume']].sum().unstack()
ax = tmp.plot(kind = 'bar', figsize = (12,6), rot = 45)
patches, labels = ax.get_legend_handles_labels()
labels = [l.strip('()').split()[1] for l in labels]
ax.legend(patches, labels, loc='best')
ax.set_title(u'日交易量(按照期权到期时间)', fontproperties = font, fontsize = 25)
ax.set_xlabel(u'到期时间', fontproperties = font, fontsize = 15)
每个交易日不同到期期限期权的交易量:
tmp
volume | |||||
---|---|---|---|---|---|
tradingDate | 2015-03-05 | 2015-03-06 | 2015-03-09 | 2015-03-10 | 2015-03-11 |
maturity | |||||
March 25th, 2015 | 18767.0000 | 16704.0000 | 31115.0000 | 11888.0000 | 11562.0000 |
April 22nd, 2015 | 7791.0000 | 4468.0000 | 13355.0000 | 6909.0000 | 5632.0000 |
June 24th, 2015 | 965.0000 | 326.0000 | 3091.0000 | 619.0000 | 604.0000 |
September 23rd, 2015 | 635.0000 | 101.0000 | 2426.0000 | 240.0000 | 178.0000 |
2.2 日交易量(行权价)
tmp = volumeSample.groupby(['tradingDate','strikePrice'])[['volume']].sum().unstack()
ax = tmp.plot(kind = 'bar', figsize = (16,8), rot = 45)
patches, labels = ax.get_legend_handles_labels()
labels = ['Strike/' + l.strip('()').split()[1] for l in labels]
ax.legend(patches, labels, loc='best')
ax.set_title(u'日交易量(按照期权行权价)', fontproperties = font, fontsize = 25)
ax.set_xlabel(u'交易日期', fontproperties = font, fontsize = 15)
<matplotlib.text.Text at 0x7fa5610>
每个交易日不同行权价期权的交易量:
tmp
volume | ||||||||
---|---|---|---|---|---|---|---|---|
strikePrice | 2.2000 | 2.2500 | 2.3000 | 2.3500 | 2.4000 | 2.4500 | 2.5000 | 2.5500 |
tradingDate | ||||||||
2015-03-05 | 2597.0000 | 1725.0000 | 3077.0000 | 5351.0000 | 5430.0000 | 4231.0000 | 3148.0000 | 2599.0000 |
2015-03-06 | 1352.0000 | 750.0000 | 1435.0000 | 5219.0000 | 4395.0000 | 3301.0000 | 3143.0000 | 2004.0000 |
2015-03-09 | 4576.0000 | 3407.0000 | 3599.0000 | 8954.0000 | 9564.0000 | 9015.0000 | 5969.0000 | 4903.0000 |
2015-03-10 | 2225.0000 | 1649.0000 | 1532.0000 | 3237.0000 | 3588.0000 | 2832.0000 | 2343.0000 | 2250.0000 |
2015-03-11 | 2021.0000 | 1286.0000 | 1299.0000 | 2959.0000 | 3121.0000 | 2648.0000 | 2565.0000 | 2077.0000 |
2.3 日交易量(期权类型)
tmp = volumeSample.groupby(['tradingDate','contractType'])[['volume']].sum().unstack()
ax = tmp.plot(kind = 'bar', y = ['volume'], figsize = (12,6), rot = 45)
patches, labels = ax.get_legend_handles_labels()
labels = [l.strip('()').split()[1] for l in labels]
ax.legend(patches, labels, loc='best')
ax.set_title(u'日交易量(按照期权类型)', fontproperties = font, fontsize = 25)
ax.set_xlabel(u'交易日期', fontproperties = font, fontsize = 15)
<matplotlib.text.Text at 0x8813e10>
3. 波动率价差分析
bidAskVolSample = res[[u'optionId', 'pdDateTime', 'dataDate', 'contractType', 'strikePrice', 'bidAskSpread(vol bps)']]
bidAskVolSample.columns = ['optionId', 'maturity', 'tradingDate', 'contractType', 'strikePrice', 'bidAskSpread(vol bps)']
3.1 波动率价差(到期时间)
tmp = bidAskVolSample.groupby(['maturity'])[['bidAskSpread(vol bps)']]
ax = tmp.mean().plot(kind = 'bar', figsize = (12,6), rot = 45)
ax.set_title(u'波动率价差(按照期权到期时间)', fontproperties = font, fontsize = 25)
ax.set_xlabel(u'到期时间', fontproperties = font, fontsize = 15)
<matplotlib.text.Text at 0x8c0b7d0>
3.2 波动率价差(行权价)
tmp = bidAskVolSample.groupby(['maturity', 'strikePrice'])[['bidAskSpread(vol bps)']].mean().unstack()
ax = tmp.plot(kind = 'bar', figsize = (14,6), legend = True, rot = 45)
patches, labels = ax.get_legend_handles_labels()
labels = ['strike/' + l.strip('()').split()[-1] for l in labels]
ax.legend(patches, labels, loc='best')
ax.set_title(u'波动率价差(按照期权行权价)', fontproperties = font, fontsize = 25)
ax.set_xlabel(u'到期时间', fontproperties = font, fontsize = 15)
3.3 波动率价差(期权类型)
tmp = bidAskVolSample.groupby(['maturity', 'contractType'])[['bidAskSpread(vol bps)']].mean().unstack()
ax = tmp.plot(kind = 'bar', figsize = (12,6), rot = 45)
patches, labels = ax.get_legend_handles_labels()
labels = [l.split()[-1].strip('()') for l in labels]
ax.legend(patches, labels, loc='best')
ax.set_title(u'波动率价差(按照期权类型)', fontproperties = font, fontsize = 25)
ax.set_xlabel(u'到期时间', fontproperties = font, fontsize = 15)
3.4 波动率价差(交易时间)
tmp = bidAskVolSample.groupby(['tradingDate', 'maturity'])[['bidAskSpread(vol bps)']].mean().unstack()
ax = tmp.plot(kind = 'bar', figsize = (12,6), rot = 45)
patches, labels = ax.get_legend_handles_labels()
labels = [l.split(',')[1].strip('()') for l in labels]
ax.legend(patches, labels, loc='best')
ax.set_title(u'波动率价差(按照交易时间)', fontproperties = font, fontsize = 25)
ax.set_xlabel(u'交易日期', fontproperties = font, fontsize = 15)
<matplotlib.text.Text at 0x8d1fc50>
4. 个券分析
4.1 交易量
tmp = volumeSample.groupby(['tradingDate','optionId'])[['volume']].sum().unstack()
fig, axs = pylab.subplots(len(tmp)/2 + len(tmp)%2, 2, figsize = (16,8 * len(tmp)/2))
for i in range(len(tmp)):
sample = pd.DataFrame(tmp.iloc[i]['volume'])
sample.columns = ['volume']
sample = sample.sort('volume', ascending = False)
sample = sample[:10]
row = i / 2
col = i % 2
sample.plot(kind = 'PIE',y = 'volume', sharex= False, ax = axs[row][col], legend = False, rot = 45)
axs[row][col].set_title(u'交易日: ' + str(tmp.index[i]), fontproperties = font, fontsize = 18)
4.2 买卖价差
tmp = bidAskSample.groupby(['tradingDate','optionId'])[['bidAskSpread(bps)']].mean().unstack()
fig, axs = pylab.subplots(len(tmp)/2 + len(tmp)%2, 2, figsize = (16,8*len(tmp)/2))
for i in range(len(tmp)):
sample = pd.DataFrame(tmp.iloc[i]['bidAskSpread(bps)'])
sample.columns = ['bidAskSpread(bps)']
sample = sample.sort('bidAskSpread(bps)')
sample = sample[:10]
row = i / 2
col = i % 2
sample.plot(kind = 'bar',y = 'bidAskSpread(bps)', sharex= False, ax = axs[row][col], legend = False, rot = 20)
axs[row][col].set_title(u'交易日: ' + str(tmp.index[i]), fontproperties = font, fontsize = 18)
4.3 波动率价差
tmp = bidAskVolSample.groupby(['tradingDate','optionId'])[['bidAskSpread(vol bps)']].mean().unstack()
fig, axs = pylab.subplots(len(tmp)/2 + len(tmp)%2, 2, figsize = (16,8*len(tmp)/2))
for i in range(len(tmp)):
sample = pd.DataFrame(tmp.iloc[i]['bidAskSpread(vol bps)'])
sample.columns = ['bidAskSpread(vol bps)']
sample = sample.sort('bidAskSpread(vol bps)')
sample = sample[:10]
row = i / 2
col = i % 2
sample.plot(kind = 'bar',y = 'bidAskSpread(vol bps)', sharex= False, ax = axs[row][col], legend = False, rot = 20)
axs[row][col].set_title(u'交易日: ' + str(tmp.index[i]), fontproperties = font, fontsize = 18)
4.4 时间序列分析
tmp = volumeSample.groupby(['tradingDate','optionId'])[['volume']].sum().unstack()
for i, d in enumerate(tmp.index):
fig, axs = pylab.subplots(2, 1, figsize = (16,5))
sample = tmp.loc(d)
sample = sample[d]
sample.sort('volume', ascending = False)
base = res[res['dataDate'] == d]
base = base[base.optionId == sample.index[0][1]]
base.index = range(len(base))
base['calTimeStamp'] = base.timeStamp.apply(lambda s: DateTime(s.year, s.month, s.day, s.hour, s.minute, s.second))
ax = base.plot(x = 'calTimeStamp', y = ['volume'], kind = 'bar', sharex=True, xticks = [], color = 'r', ax = axs[0])
ax.set_title(u'交易日: ' + unicode(d) + u' 最活跃期权:'+ unicode(sample.index[0][1]), fontproperties = font, fontsize = 18)
ax = base.plot(x= 'calTimeStamp', y = ['lastPrice(vol)'], sharex=True, legend = True,ax = axs[1], rot = 45)
ax.set_xlabel(u'交易时间', fontproperties = font, fontsize = 15)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论