【量化】【量化】4天学会天学会python机器学习与量化交易机器学习与量化交易-笔记笔记4(p21~p25)
文章目录文章目录p21 因子数据的标准化处理p22 市值中心化处理介绍p23 案例:市值中性化实现以及回测选股结果p24 市值中心化结果总
结分析p25 总结
平台:https://www.ricequant.com/quant
api1:https://www.ricequant.com/doc/rqdata-institutional#research-API-get_fundamentals
api2:https://www.ricequant.com/doc/api/python/chn#wizard-stock
rice quant ipynb
p21 因子数据的标准化处理因子数据的标准化处理
视频:https://www.bilibili.com/video/av55456917?p=21
# 2,标准化处理
from sklearn.preprocessing import StandardScaler
std = StandardScaler()
std.fit_transform(fund['pe_ratio_3md'])
# (我的为什么报错。。)
def stand(factor):
'''自实现标准化'''
mean = factor.mean()
std = factor.std()
return (factor - mean)/std
fund['pe_ratio_stand'] = stand(fund['pe_ratio_3md'])
fund
结果:
p22 市值中心化处理介绍市值中心化处理介绍
视频:https://www.bilibili.com/video/av55456917?p=22
1,市值中心化处理
防止得到的股票比较集中。(原因:默认大部分因子都包含了市值的影响。)
去除其他的因子存在的市值的影响。
2,回归法进行去除
建立某因子跟市值之间的一个回归方程,得出系数
最终预测的结果与因子之间的差值就是不受影响的那部分
p23 案例:市值中性化实现以及回测选股结果案例:市值中性化实现以及回测选股结果
视频:https://www.bilibili.com/video/av55456917?p=23
# 1,获取数据
q = query(fundamentals.eod_derivative_indicator.pb_ratio,
评论0