实施高频金融计量工具。
hffe的Python项目详细描述
目录
- HFFE: High-Frequency Financial Econometrics
- Introduction
- Stocks
- Options
- Under development
- Redo introduction
- Add examples on how to use stock.py
- Add examples on how to use options.py
- Change file stock.py to stocks.py
- Add citations
- Sample data
- [stock.py] Change internals to pandas dataframe
- [stock.py]
- [stock.py] Truncated variance estimator
- [stock.py] Local volatility estimator
- [stock.py] Confidence intervals
高频金融计量经济学
简介
这个包实现了高频金融计量经济学文献的一些工具。
hffe包提供了一个类Stock
。这个类有两种用法:
- 实例化类并提供库存数据。实例
__init__
方法将自动计算几何收益、已实现方差和双幂方差,并使用提供的库存数据将扩散收益和跳跃收益分开。 - 根据需要单独使用类方法。
Stock
中的所有方法都是静态方法,可以在不实例化类的情况下使用。
通过提供包含价格(浮动)的iterable和包含日期戳的iterable(年、月和日的格式为yyymmdd),可以通过默认构造函数实例化该类。默认构造函数还接受包含时间戳的可选iterable(格式为hhmm表示小时和分钟,hhmms表示小时、分钟和秒)。 假设数据是矩形的,这意味着每天包含相同数量的价格观察值。
假设价格每天观察(n)次,时间间隔相同。例如,如果从上午9:30开始每5分钟采样一次价格,到下午4:00结束,那么我们将每天进行(n=79)价格观察。 假设价格在(t)天内有效。在这些(t)天中,我们每一天都有(n)个价格观察。 几何回报(对数回报)是计算每一天和每一个离散采样间隔。然而,隔夜收益不被考虑,打包后的收益只专注于日内收益的分析。 如果每天都有(n=79)个价格观察,那么我们每天都会有(n=78)个回报。
示例:
from hffe import Stock
from random import normalvariate as randn
# generate some fake data
prices = np.array([10.0 + randn(0, 1) for _ in range(10)])
dates = ['20181112']*len(prices)
times = [f'093{i}' for i in range(10)]
# instantiate class
stock = Stock(prices, dates, times)
# at this point we can access the returns, variance measures and
# obtain the diffusive returns separated from the jump returns
print(f'Number of prices per day: {stock.total["prices"]}\n'
f'Number of days: {stock.total["days"]}')
print(stock.returns)
# print measures of variance
print(f'Realized Variance: {stock.RV}\n'
f'Annualized Realized Variance: {(252*stock.RV)**0.5}\n'
f'Bipower Variance: {stock.BV}\n'
f'Annualized Bipower Variance: {(252*stock.BV)**0.5}')
库存
选项
开发中
待办事项重做简介
todo添加如何使用stock.py
的示例todo添加如何使用options.py
的示例todo将stock.py文件更改为stocks.py
要添加引文
波动性估计器的待办事项
TOdo跳转阈值和分隔
待办事项到每日时间因素
TOdo样本数据
待办事项库存数据样本
TOdo示例SPX选项数据