第一部分 新手入门
- 一 量化投资视频学习课程
- 二 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
第三部分 基金、利率互换、固定收益类
- 一 分级基金
- 二 基金分析
- 三 债券
- 四 利率互换
第四部分 衍生品相关
- 一 期权数据
- 二 期权系列
- 三 期权分析
- 四 期货分析
文章来源于网络收集而来,版权归原创者所有,如有侵权请及时联系!
ROIC&cashROIC
from CAL.PyCAL import *
import numpy as np
from pandas import DataFrame , Series
start = '2015-01-01' # 回测起始时间
end = '2015-11-01' # 回测结束时间
benchmark = 'HS300' # 策略参考标准
universe = set_universe('HS300') # 证券池,支持股票和基金
capital_base = 100000 # 起始资金
freq = 'd' # 策略类型,'d'表示日间策略使用日线回测,'m'表示日内策略使用分钟线回测
refresh_rate = 30 # 调仓频率,表示执行handle_data的时间间隔,若freq = 'd'时间间隔的单位为交易日,若freq = 'm'时间间隔为分钟
cal = Calendar('China.SSE')
def initialize(account): # 初始化虚拟账户状态
pass
def handle_data(account): # 每个交易日的买入卖出指令
today = account.current_date.strftime('%Y%m%d')
yesterday = cal.advanceDate(account.current_date, '-1B', BizDayConvention.Following).strftime('%Y%m%d')
ROIC = {}
cashROIC = {}
# EBITToTOR
EBITToTOR = DataAPI.MktStockFactorsOneDayGet(tradeDate=yesterday,secID=account.universe,field=u"secID,EBITToTOR",pandas="1")
EBITToTOR.drop_duplicates('secID' , inplace= True)
EBITToTOR.set_index('secID' , inplace = True)
# tRevenue : 营业收入
tRevenue = DataAPI.FdmtISAllLatestGet(secID=account.universe,endDate=u"20151101",beginDate=u"20150101",field=u"secID,tRevenue",pandas="1")
tRevenue.drop_duplicates('secID' , inplace= True)
tRevenue.set_index('secID' , inplace = True)
# 自由现金流
freeCF = DataAPI.FdmtCFAllLatestGet(secID=account.universe,endDate=u"20151101",beginDate=u"20150101",field=u"secID,NCFOperateA,purFixAssetsOth,dispFixAssetsOth",pandas="1")
freeCF.drop_duplicates('secID' , inplace= True)
freeCF.set_index('secID' , inplace= True)
# IC : 投入资本
IC = DataAPI.FdmtBSAllLatestGet(secID=account.universe,endDate=u"20151101",beginDate=u"20150101",field=u"secID,TShEquity,LTBorr",pandas="1")
IC.drop_duplicates('secID' , inplace= True)
IC.set_index('secID' , inplace = True)
for s in account.universe:
ROIC[s] = (EBITToTOR['EBITToTOR'][s] * tRevenue['tRevenue'][s] * (1-0.25)) / (IC['TShEquity'][s] + IC['LTBorr'][s])
cashROIC[s] = (freeCF['NCFOperateA'][s] - (freeCF['purFixAssetsOth'][s] - freeCF['dispFixAssetsOth'][s])) / (IC['TShEquity'][s] + IC['LTBorr'][s])
# ROIC
ROIC = Series(ROIC)
ROIC.sort(ascending = False)
ROIC.dropna(inplace = True)
ROIC = ROIC[0:60]
buylist1 = list(ROIC.index)
# cashROIC
cashROIC = Series(cashROIC)
cashROIC.sort(ascending = False)
cashROIC.dropna(inplace = True)
cashROIC = cashROIC[0:60]
buylist2 = list(cashROIC.index)
# buylist为buylist1与buylist2的交集
buylist = list(set(buylist1)&set(buylist2))
print 'buylist', len(buylist)
print buylist
sell_list = [x for x in account.valid_secpos if x not in buylist]
for s in sell_list :
order_to(s,0)
total_money = account.referencePortfolioValue
for s in buylist:
if s in account.valid_secpos:
pass
else:
order(s,total_money/(len(buylist)-len(set(buylist)&set(account.valid_secpos)))/account.referencePrice[s])
buylist 24
['601601.XSHG', '601899.XSHG', '000895.XSHE', '000539.XSHE', '600276.XSHG', '600011.XSHG', '600887.XSHG', '000712.XSHE', '600863.XSHG', '600018.XSHG', '000538.XSHE', '600900.XSHG', '002470.XSHE', '600600.XSHG', '600153.XSHG', '002304.XSHE', '600104.XSHG', '000333.XSHE', '600873.XSHG', '600578.XSHG', '000999.XSHE', '002294.XSHE', '601006.XSHG', '600177.XSHG']
buylist 24
['600027.XSHG', '000559.XSHE', '601899.XSHG', '000895.XSHE', '000876.XSHE', '000539.XSHE', '600276.XSHG', '600011.XSHG', '601006.XSHG', '000538.XSHE', '600900.XSHG', '002470.XSHE', '600600.XSHG', '600153.XSHG', '600332.XSHG', '002304.XSHE', '600104.XSHG', '000333.XSHE', '600873.XSHG', '600578.XSHG', '000999.XSHE', '002294.XSHE', '000712.XSHE', '600177.XSHG']
buylist 21
['600276.XSHG', '600900.XSHG', '600104.XSHG', '600011.XSHG', '600887.XSHG', '600873.XSHG', '600027.XSHG', '601006.XSHG', '600663.XSHG', '600018.XSHG', '000538.XSHE', '601899.XSHG', '600863.XSHG', '002470.XSHE', '002304.XSHE', '000999.XSHE', '000895.XSHE', '000876.XSHE', '600153.XSHG', '600177.XSHG', '000712.XSHE']
buylist 22
['601601.XSHG', '600027.XSHG', '000876.XSHE', '600276.XSHG', '600011.XSHG', '600887.XSHG', '600863.XSHG', '000538.XSHE', '002470.XSHE', '600332.XSHG', '002304.XSHE', '601377.XSHG', '600104.XSHG', '000333.XSHE', '600873.XSHG', '601628.XSHG', '002294.XSHE', '600663.XSHG', '000712.XSHE', '600886.XSHG', '601318.XSHG', '600177.XSHG']
buylist 22
['601216.XSHG', '600027.XSHG', '000895.XSHE', '000876.XSHE', '600011.XSHG', '600887.XSHG', '000538.XSHE', '002470.XSHE', '600649.XSHG', '600332.XSHG', '002304.XSHE', '601377.XSHG', '600104.XSHG', '000333.XSHE', '600873.XSHG', '600578.XSHG', '600741.XSHG', '601628.XSHG', '000999.XSHE', '600795.XSHG', '600663.XSHG', '601318.XSHG']
buylist 26
['601216.XSHG', '600340.XSHG', '000876.XSHE', '600276.XSHG', '600011.XSHG', '600887.XSHG', '601006.XSHG', '600018.XSHG', '000538.XSHE', '002470.XSHE', '000069.XSHE', '600332.XSHG', '002304.XSHE', '601377.XSHG', '600104.XSHG', '000333.XSHE', '600578.XSHG', '601628.XSHG', '000999.XSHE', '002294.XSHE', '600795.XSHG', '600663.XSHG', '600863.XSHG', '600060.XSHG', '601318.XSHG', '600177.XSHG']
buylist 28
['002304.XSHE', '601216.XSHG', '600027.XSHG', '601111.XSHG', '601899.XSHG', '000878.XSHE', '600018.XSHG', '000895.XSHE', '600276.XSHG', '600887.XSHG', '601006.XSHG', '601601.XSHG', '601088.XSHG', '002470.XSHE', '000069.XSHE', '600332.XSHG', '600597.XSHG', '601377.XSHG', '600873.XSHG', '600578.XSHG', '600649.XSHG', '601628.XSHG', '002294.XSHE', '600795.XSHG', '600663.XSHG', '600863.XSHG', '601318.XSHG', '600177.XSHG']
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论