楼主: casey_c
1963 2

[程序分享] Python 金融数据分析:波动性期权 [推广有奖]

  • 0关注
  • 10粉丝

博士生

92%

还不是VIP/贵宾

-

威望
0
论坛币
96 个
通用积分
2.1003
学术水平
2 点
热心指数
15 点
信用等级
2 点
经验
11502 点
帖子
278
精华
0
在线时间
94 小时
注册时间
2016-11-22
最后登录
2022-5-2

楼主
casey_c 发表于 2017-11-14 10:47:21 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币


以下内容转自 数析学院,只节选了部分,有需要的同学可以直接查看原文


本文主要介绍使用 python 通过常用数据处理分析包对波动性股指构造期权模型并进行估值的方法。


一、波动性股指 VSTOXX 数据


  1. import sys
  2. sys.path.append('../python')
复制代码
  1. import numpy as np
  2. import pandas as pd
复制代码
1、VSTOXX 索引数据
  1. url = 'http://www.stoxx.com/download/historical_values/h_vstoxx.txt'
  2. vstoxx_index = pd.read_csv(url, index_col=0, header=2,
  3.                            parse_dates=True, dayfirst=True,
  4.                            sep=',')
复制代码
  1. vstoxx_index.info()
复制代码
<class 'pandas.core.frame.DataFrame'>DatetimeIndex: 4226 entries, 1999-01-04 to 2015-08-07Data columns (total 9 columns):V2TX    4226 non-null float64V6I1    3787 non-null float64V6I2    4226 non-null float64V6I3    4169 non-null float64V6I4    4226 non-null float64V6I5    4226 non-null float64V6I6    4210 non-null float64V6I7    4226 non-null float64V6I8    4213 non-null float64dtypes: float64(9)memory usage: 330.2 KB
  1. vstoxx_index = vstoxx_index[('2013/12/31' < vstoxx_index.index)
  2.                             & (vstoxx_index.index < '2014/4/1')]
复制代码
  1. np.round(vstoxx_index.tail(), 2)
复制代码
1.jpg
2、VSTOXX 期货数据
  1. vstoxx_futures = pd.read_excel('./source/vstoxx_march_2014.xlsx',
  2.                                'vstoxx_futures')
复制代码
  1. vstoxx_futures.info()
复制代码
<class 'pandas.core.frame.DataFrame'>Int64Index: 504 entries, 0 to 503Data columns (total 8 columns):A_DATE                       504 non-null datetime64[ns]A_EXP_YEAR                   504 non-null int64A_EXP_MONTH                  504 non-null int64A_CALL_PUT_FLAG              504 non-null objectA_EXERCISE_PRICE             504 non-null int64A_SETTLEMENT_PRICE_SCALED    504 non-null int64A_PRODUCT_ID                 504 non-null objectSETTLE                       504 non-null float64dtypes: datetime64[ns](1), float64(1), int64(4), object(2)memory usage: 35.4+ KB
  1. del vstoxx_futures['A_SETTLEMENT_PRICE_SCALED']
  2. del vstoxx_futures['A_CALL_PUT_FLAG']
  3. del vstoxx_futures['A_EXERCISE_PRICE']
  4. del vstoxx_futures['A_PRODUCT_ID']
复制代码
  1. columns = ['DATE', 'EXP_YEAR', 'EXP_MONTH', 'PRICE']
  2. vstoxx_futures.columns = columns
复制代码
  1. import datetime as dt
  2. import calendar

  3. def third_friday(date):
  4.     day = 21 - (calendar.weekday(date.year, date.month, 1) + 2) % 7
  5.     return dt.datetime(date.year, date.month, day)
复制代码
  1. set(vstoxx_futures['EXP_MONTH'])
复制代码
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
  1. third_fridays = {}
  2. for month in set(vstoxx_futures['EXP_MONTH']):
  3.     third_fridays[month] = third_friday(dt.datetime(2014, month, 1))
复制代码
  1. third_fridays
复制代码
{1: datetime.datetime(2014, 1, 17, 0, 0), 2: datetime.datetime(2014, 2, 21, 0, 0), 3: datetime.datetime(2014, 3, 21, 0, 0), 4: datetime.datetime(2014, 4, 18, 0, 0), 5: datetime.datetime(2014, 5, 16, 0, 0), 6: datetime.datetime(2014, 6, 20, 0, 0), 7: datetime.datetime(2014, 7, 18, 0, 0), 8: datetime.datetime(2014, 8, 15, 0, 0), 9: datetime.datetime(2014, 9, 19, 0, 0), 10: datetime.datetime(2014, 10, 17, 0, 0), 11: datetime.datetime(2014, 11, 21, 0, 0)}
  1. tf = lambda x: third_fridays[x]
  2. vstoxx_futures['MATURITY'] = vstoxx_futures['EXP_MONTH'].apply(tf)
复制代码
  1. vstoxx_futures.tail()
复制代码
2.jpg
以上内容转自 数析学院,如需完整内容可以直接查看原文
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:python 金融数据分析 数据分析 金融数据 波动性

沙发
飞天玄舞6 在职认证  发表于 2017-11-14 14:35:10

藤椅
casey_c 发表于 2017-11-15 11:06:21

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-22 04:53