用python完成选股策略_传统市值选股策略 VS AI市值策略(Python源码)

# 基础参数配置

class conf:

start_date = '2010-01-01'

end_date='2017-01-20'

# split_date 之前的数据用于训练,之后的数据用作效果评估

split_date = '2015-01-01'

# D.instruments: https://bigquant.com/docs/data_instruments.html

instruments = D.instruments(start_date, end_date)

# 机器学习目标标注函数

# 如下标注函数等价于 max(min((持有期间的收益 * 100), -20), 20) + 20 (后面的M.fast_auto_labeler会做取整操作)

# 说明:max/min这里将标注分数限定在区间[-20, 20],+20将分数变为非负数 (StockRanker要求标注分数非负整数)

label_expr = ['return * 100', 'where(label > {0}, {0}, where(label < -{0}, -{0}, label)) + {0}'.format(20)]

# 持有天数,用于计算label_expr中的return值(收益)

hold_days = 30

# 特征 https://bigquant.com/docs/data_features.html,你可以通过表达式构造任何特征

features = [

'market_cap_0',  # 总市值

]

#

你可能感兴趣的:(用python完成选股策略)