第一部分 新手入门
- 一 量化投资视频学习课程
- 二 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
第三部分 基金、利率互换、固定收益类
- 一 分级基金
- 二 基金分析
- 三 债券
- 四 利率互换
第四部分 衍生品相关
- 一 期权数据
- 二 期权系列
- 三 期权分析
- 四 期货分析
文章来源于网络收集而来,版权归原创者所有,如有侵权请及时联系!
5.11 Fisher Transform
策略思路:
在技术分析中,很多时候,人们都把股价数据当作正态分布的数据来分析。但是,其实股价数据分布并不符合正态分布。Fisher Transformation是一个可以把股价数据变为类似于正态分布的方法。
Fisher Transformation将市场数据的走势平滑化,去掉了一些尖锐的短期振荡;利用今日和前一日该指标的交错可以给出交易信号;
例如,对于沪深300指数使用Fisher变换的结果见本文后面的具体讨论。
Fisher Transformation
定义今日中间价:
mid=(low+high)/2
确定计算周期,例如可使用10日为周期。计算周期内最高价和最低价:
lowestLow=周期内最低价, highestHigh=周期内最高价
定义价变参数(其中的
ratio
为0-1之间常数,例如可取0.5或0.33):对价变参数
x
使用Fisher变换,得到Fisher指标:
import quartz
import quartz.backtest as qb
import quartz.performance as qp
from quartz.api import *
import pandas as pd
import numpy as np
from datetime import datetime
from matplotlib import pylab
start = datetime(2014, 1, 1) # 回测起始时间
end = datetime(2014, 12, 10) # 回测结束时间
benchmark = 'HS300' # 使用沪深 300 作为参考标准
universe = set_universe('SH50') # 股票池
capital_base = 100000 # 起始资金
refresh_rate = 1
window = 10
# 本策略对于window非常非常敏感!!!
histFish = pd.DataFrame(0.0, index = universe, columns = ['preDiff', 'preFish', 'preState'])
def initialize(account): # 初始化虚拟账户状态
account.amount = 10000
account.universe = universe
add_history('hist', window)
def handle_data(account): # 每个交易日的买入卖出指令
for stk in account.universe:
prices = account.hist[stk]
if prices is None:
return
preDiff = histFish.at[stk, 'preDiff']
preFish = histFish.at[stk, 'preFish']
preState = histFish.at[stk, 'preState']
diff, fish = FisherTransIndicator(prices, preDiff, preFish)
if fish > preFish:
state = 1
elif fish < preFish:
state = -1
else:
state = 0
if state == 1 and preState == -1:
#stkAmount = int(account.amount / prices.iloc[-1]['openPrice'])
order(stk, account.amount)
elif state == -1 and preState == 1:
order_to(stk, 0)
histFish.at[stk, 'preDiff'] = diff
histFish.at[stk, 'preFish'] = fish
histFish.at[stk, 'preState'] = state
def FisherTransIndicator(windowData, preDiff, preFish):
# This function calculate the Fisher Transform indicator based on the data
# in the windowData.
minLowPrice = min(windowData['lowPrice'])
maxHghPrice = max(windowData['highPrice'])
tdyMidPrice = (windowData.iloc[-1]['lowPrice'] + windowData.iloc[-1]['highPrice'])/2.0
diffRatio = 0.33
# 本策略对于diffRatio同样非常敏感!!!
diff = (tdyMidPrice - minLowPrice)/(maxHghPrice - minLowPrice) - 0.5
diff = 2 * diff
diff = diffRatio * diff + (1.0 - diffRatio) * preDiff
if diff > 0.99:
diff = 0.999
elif diff < -0.99:
diff = -0.999
fish = np.log((1.0 + diff)/(1.0 - diff))
fish = 0.5 * fish + 0.5 * fish
return diff, fish
沪深300指数上使用Fisher Transformation
- 对最近半年的沪深300进行Fisher变换,得到的指标能够比较温和准确反映出指数的变化
from CAL.PyCAL import *
# DataAPI.MktIdxdGet返回pandas.DataFrame格式
index = DataAPI.MktIdxdGet(indexID = "000001.ZICN", beginDate = "20140501", endDate = "20140901")
index.head()
indexID | tradeDate | ticker | secShortName | exchangeCD | preCloseIndex | openIndex | lowestIndex | highestIndex | closeIndex | turnoverVol | turnoverValue | CHG | CHGPct | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 000001.ZICN | 2014-05-05 | 1 | 上证综指 | XSHG | 2026.358 | 2022.178 | 2007.351 | 2028.957 | 2027.353 | 7993339500 | 60093487736 | 0.995 | 0.00049 |
1 | 000001.ZICN | 2014-05-06 | 1 | 上证综指 | XSHG | 2027.353 | 2024.256 | 2021.485 | 2038.705 | 2028.038 | 7460941100 | 57548110850 | 0.685 | 0.00034 |
2 | 000001.ZICN | 2014-05-07 | 1 | 上证综指 | XSHG | 2028.038 | 2023.152 | 2008.451 | 2024.631 | 2010.083 | 7436019200 | 57558051925 | -17.955 | -0.00885 |
3 | 000001.ZICN | 2014-05-08 | 1 | 上证综指 | XSHG | 2010.083 | 2006.853 | 2005.685 | 2036.941 | 2015.274 | 7786539300 | 59529365546 | 5.191 | 0.00258 |
4 | 000001.ZICN | 2014-05-09 | 1 | 上证综指 | XSHG | 2015.274 | 2016.501 | 2001.300 | 2020.454 | 2011.135 | 7622424400 | 57505383717 | -4.139 | -0.00205 |
def FisherTransIndicator(windowData, preDiff, preFish, state):
# This function calculate the Fisher Transform indicator based on the data
# in the windowData.
minLowPrice = min(windowData['lowestIndex'])
maxHghPrice = max(windowData['highestIndex'])
tdyMidPrice = (windowData.iloc[-1]['lowestIndex'] + windowData.iloc[-1]['highestIndex'])/2.0
diffRatio = 0.5
diff = (tdyMidPrice - minLowPrice)/(maxHghPrice - minLowPrice) - 0.5
diff = 2 * diff
if state == 1:
diff = diffRatio * diff + (1 - diffRatio) * preDiff
if diff > 0.995:
diff = 0.999
elif diff < -0.995:
diff = -0.999
fish = np.log((1 + diff)/(1 - diff))
if state == 1:
fish = 0.5 * fish + 0.5 * fish
return diff, fish
window = 10
index['diff'] = 0.0
index['fish'] = 0.0
index['preFish'] = 0.0
for i in range(window, index.shape[0]):
windowData = index.iloc[i-window : i]
if i == window:
diff, fish = FisherTransIndicator(windowData, 0, 0, 1)
index.at[i,'preFish'] = 0
index.at[i,'diff'] = diff
index.at[i,'fish'] = fish
else:
preDiff = index.iloc[i-1]['diff']
preFish = index.iloc[i-1]['fish']
diff, fish = FisherTransIndicator(windowData, preDiff, preFish, 1)
index.at[i,'preFish'] = preFish
index.at[i,'diff'] = diff
index.at[i,'fish'] = fish
Plot(index, settings = {'x':'tradeDate','y':'closeIndex', 'title':u'沪深300指数历史收盘价'})
Plot(index, settings = {'x':'tradeDate','y':['fish', 'preFish'], 'title':u'沪深300指数Fisher Transform Indicator'})
- 上图中的蓝色曲线表示Fisher指标,绿色曲线表示前一日的Fisher指标,两个指标的交错可以给出沪深300指数涨跌情况的信号
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论