paper: https://arxiv.org/abs/1706.03762
The naive transformer implemented here for financial time series prediction follows the paper "Attention is all you need":
Given the input (N, T, F),
# 本代码由可视化策略环境自动生成 2021年10月26日 16:27
# 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
# Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端
def m33_run_bigquant_run(input_1, input_2, input_3):
# 示例代码如下。在这里编写您的代码
from sklearn.model_selection import train_test_split
# train data
train_data = input_1.read()
x_train, x_val, y_train, y_val = train_test_split(train_data["x"], train_data['y'], shuffle=True, random_state=2021)
# val data
test_data = input_2.read()
x_test = test_data["x"]
from bigmodels.models.transformer import Transformer
model = Transformer(input_dim=98, embed_dim=256, nhead=8, num_layers=6, dropout=0.1)
model.compile(device="cuda:0")
model.fit(x_train, y_train, val_data=(x_val, y_val), batch_size=2048, epochs=10, verbose=1, num_workers=2)
# model.fit(train_data["x"], train_data['y'], batch_size=1024, epochs=2, verbose=1, num_workers=2)
output = model.predict(x_test)
data_1 = DataSource.write_pickle(output)
return Outputs(data_1=data_1, data_2=None, data_3=None)
# 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。
def m33_post_run_bigquant_run(outputs):
return outputs
# Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端
def m41_run_bigquant_run(input_1, input_2, input_3):
# 示例代码如下。在这里编写您的代码
pred_label = input_1.read_pickle()
df = input_2.read_df()
df = pd.DataFrame({'pred_label':pred_label[:], 'instrument':df.instrument, 'date':df.date})
df.sort_values(['date','pred_label'],inplace=True, ascending=[True,False])
return Outputs(data_1=DataSource.write_df(df), data_2=None, data_3=None)
# 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。
def m41_post_run_bigquant_run(outputs):
return outputs
# 回测引擎:初始化函数,只执行一次
def m42_initialize_bigquant_run(context):
# 加载预测数据
context.ranker_prediction = context.options['data'].read_df()
# 系统已经设置了默认的交易手续费和滑点,要修改手续费可使用如下函数
context.set_commission(PerOrder(buy_cost=0.001, sell_cost=0.001, min_cost=5))
# 预测数据,通过options传入进来,使用 read_df 函数,加载到内存 (DataFrame)
# 设置买入的股票数量,这里买入预测股票列表排名靠前的5只
stock_count = 20
# 每只的股票的权重,如下的权重分配会使得靠前的股票分配多一点的资金,[0.339160, 0.213986, 0.169580, ..]
context.stock_weights = T.norm([1 / math.log(i + 2) for i in range(0, stock_count)])
# 设置每只股票占用的最大资金比例
context.max_cash_per_instrument = 0.2
context.options['hold_days'] = 5
# 回测引擎:每日数据处理函数,每天执行一次
def m42_handle_data_bigquant_run(context, data):
# 按日期过滤得到今日的预测数据
ranker_prediction = context.ranker_prediction[
context.ranker_prediction.date == data.current_dt.strftime('%Y-%m-%d')]
# 1. 资金分配
# 平均持仓时间是hold_days,每日都将买入股票,每日预期使用 1/hold_days 的资金
# 实际操作中,会存在一定的买入误差,所以在前hold_days天,等量使用资金;之后,尽量使用剩余资金(这里设置最多用等量的1.5倍)
is_staging = context.trading_day_index < context.options['hold_days'] # 是否在建仓期间(前 hold_days 天)
cash_avg = context.portfolio.portfolio_value / context.options['hold_days']
cash_for_buy = min(context.portfolio.cash, (1 if is_staging else 1.5) * cash_avg)
cash_for_sell = cash_avg - (context.portfolio.cash - cash_for_buy)
positions = {e.symbol: p.amount * p.last_sale_price
for e, p in context.perf_tracker.position_tracker.positions.items()}
# 2. 生成卖出订单:hold_days天之后才开始卖出;对持仓的股票,按机器学习算法预测的排序末位淘汰
if not is_staging and cash_for_sell > 0:
equities = {e.symbol: e for e, p in context.perf_tracker.position_tracker.positions.items()}
instruments = list(reversed(list(ranker_prediction.instrument[ranker_prediction.instrument.apply(
lambda x: x in equities and not context.has_unfinished_sell_order(equities[x]))])))
# print('rank order for sell %s' % instruments)
for instrument in instruments:
context.order_target(context.symbol(instrument), 0)
cash_for_sell -= positions[instrument]
if cash_for_sell <= 0:
break
# 3. 生成买入订单:按机器学习算法预测的排序,买入前面的stock_count只股票
buy_cash_weights = context.stock_weights
buy_instruments = list(ranker_prediction.instrument[:len(buy_cash_weights)])
max_cash_per_instrument = context.portfolio.portfolio_value * context.max_cash_per_instrument
for i, instrument in enumerate(buy_instruments):
cash = cash_for_buy * buy_cash_weights[i]
if cash > max_cash_per_instrument - positions.get(instrument, 0):
# 确保股票持仓量不会超过每次股票最大的占用资金量
cash = max_cash_per_instrument - positions.get(instrument, 0)
if cash > 0:
context.order_value(context.symbol(instrument), cash)
# 回测引擎:准备数据,只执行一次
def m42_prepare_bigquant_run(context):
pass
m22 = M.instruments.v2(
start_date='2010-01-01',
end_date='2017-12-31',
market='CN_STOCK_A',
instrument_list='',
max_count=0
)
m23 = M.advanced_auto_labeler.v2(
instruments=m22.data,
label_expr="""# #号开始的表示注释
# 0. 每行一个,顺序执行,从第二个开始,可以使用label字段
# 1. 可用数据字段见 https://bigquant.com/docs/data_history_data.html
# 添加benchmark_前缀,可使用对应的benchmark数据
# 2. 可用操作符和函数见 `表达式引擎 <https://bigquant.com/docs/big_expr.html>`_
# 计算收益:5日收盘价(作为卖出价格)除以明日开盘价(作为买入价格)
shift(close, -5) / shift(open, -1)-1
# 极值处理:用1%和99%分位的值做clip
clip(label, all_quantile(label, 0.01), all_quantile(label, 0.99))
# 过滤掉一字涨停的情况 (设置label为NaN,在后续处理和训练中会忽略NaN的label)
where(shift(high, -1) == shift(low, -1), NaN, label)
""",
start_date='',
end_date='',
benchmark='000300.SHA',
drop_na_label=True,
cast_label_int=False
)
m1 = M.standardlize.v8(
input_1=m23.data,
columns_input='label'
)
m24 = M.input_features.v1(
features="""close_0
open_0
high_0
low_0
amount_0
turn_0
return_0
close_1
open_1
high_1
low_1
return_1
amount_1
turn_1
close_2
open_2
high_2
low_2
amount_2
turn_2
return_2
close_3
open_3
high_3
low_3
amount_3
turn_3
return_3
close_4
open_4
high_4
low_4
amount_4
turn_4
return_4
mean(close_0, 5)
mean(low_0, 5)
mean(open_0, 5)
mean(high_0, 5)
mean(turn_0, 5)
mean(amount_0, 5)
mean(return_0, 5)
ts_max(close_0, 5)
ts_max(low_0, 5)
ts_max(open_0, 5)
ts_max(high_0, 5)
ts_max(turn_0, 5)
ts_max(amount_0, 5)
ts_max(return_0, 5)
ts_min(close_0, 5)
ts_min(low_0, 5)
ts_min(open_0, 5)
ts_min(high_0, 5)
ts_min(turn_0, 5)
ts_min(amount_0, 5)
ts_min(return_0, 5)
std(close_0, 5)
std(low_0, 5)
std(open_0, 5)
std(high_0, 5)
std(turn_0, 5)
std(amount_0, 5)
std(return_0, 5)
ts_rank(close_0, 5)
ts_rank(low_0, 5)
ts_rank(open_0, 5)
ts_rank(high_0, 5)
ts_rank(turn_0, 5)
ts_rank(amount_0, 5)
ts_rank(return_0, 5)
decay_linear(close_0, 5)
decay_linear(low_0, 5)
decay_linear(open_0, 5)
decay_linear(high_0, 5)
decay_linear(turn_0, 5)
decay_linear(amount_0, 5)
decay_linear(return_0, 5)
correlation(volume_0, return_0, 5)
correlation(volume_0, high_0, 5)
correlation(volume_0, low_0, 5)
correlation(volume_0, close_0, 5)
correlation(volume_0, open_0, 5)
correlation(volume_0, turn_0, 5)
correlation(return_0, high_0, 5)
correlation(return_0, low_0, 5)
correlation(return_0, close_0, 5)
correlation(return_0, open_0, 5)
correlation(return_0, turn_0, 5)
correlation(high_0, low_0, 5)
correlation(high_0, close_0, 5)
correlation(high_0, open_0, 5)
correlation(high_0, turn_0, 5)
correlation(low_0, close_0, 5)
correlation(low_0, open_0, 5)
correlation(low_0, turn_0, 5)
correlation(close_0, open_0, 5)
correlation(close_0, turn_0, 5)
correlation(open_0, turn_0, 5)"""
)
m27 = M.general_feature_extractor.v7(
instruments=m22.data,
features=m24.data,
start_date='',
end_date='',
before_start_days=10
)
m28 = M.derived_feature_extractor.v3(
input_data=m27.data,
features=m24.data,
date_col='date',
instrument_col='instrument',
drop_na=True,
remove_extra_columns=False
)
m34 = M.standardlize.v8(
input_1=m28.data,
input_2=m24.data,
columns_input='[]'
)
m35 = M.fillnan.v1(
input_data=m34.data,
features=m24.data,
fill_value='0.0'
)
m25 = M.join.v3(
data1=m1.data,
data2=m35.data,
on='date,instrument',
how='inner',
sort=False
)
m2 = M.dl_convert_to_bin.v2(
input_data=m25.data,
features=m24.data,
window_size=5,
feature_clip=3,
flatten=False,
window_along_col='instrument'
)
m26 = M.instruments.v2(
start_date='2018-01-01',
end_date='2021-07-01',
market='CN_STOCK_A',
instrument_list='',
max_count=0
)
m29 = M.general_feature_extractor.v7(
instruments=m26.data,
features=m24.data,
start_date='',
end_date='',
before_start_days=10
)
m30 = M.derived_feature_extractor.v3(
input_data=m29.data,
features=m24.data,
date_col='date',
instrument_col='instrument',
drop_na=True,
remove_extra_columns=False
)
m37 = M.standardlize.v8(
input_1=m30.data,
input_2=m24.data,
columns_input='[]'
)
m36 = M.fillnan.v1(
input_data=m37.data,
features=m24.data,
fill_value='0.0'
)
m32 = M.dl_convert_to_bin.v2(
input_data=m36.data,
features=m24.data,
window_size=5,
feature_clip=3,
flatten=False,
window_along_col='instrument'
)
m33 = M.cached.v3(
input_1=m2.data,
input_2=m32.data,
run=m33_run_bigquant_run,
post_run=m33_post_run_bigquant_run,
input_ports='',
params='{}',
output_ports='',
m_cached=False
)
m41 = M.cached.v3(
input_1=m33.data_1,
input_2=m30.data,
run=m41_run_bigquant_run,
post_run=m41_post_run_bigquant_run,
input_ports='',
params='{}',
output_ports='',
m_cached=False
)
m42 = M.trade.v4(
instruments=m26.data,
options_data=m41.data_1,
start_date='',
end_date='',
initialize=m42_initialize_bigquant_run,
handle_data=m42_handle_data_bigquant_run,
prepare=m42_prepare_bigquant_run,
volume_limit=0.025,
order_price_field_buy='open',
order_price_field_sell='close',
capital_base=1000000,
auto_cancel_non_tradable_orders=True,
data_frequency='daily',
price_type='后复权',
product_type='股票',
plot_charts=True,
backtest_only=False,
benchmark='000300.SHA'
)
[2021-10-26 11:53:50.153481] INFO: moduleinvoker: instruments.v2 开始运行..
[2021-10-26 11:53:50.171521] INFO: moduleinvoker: 命中缓存
[2021-10-26 11:53:50.173299] INFO: moduleinvoker: instruments.v2 运行完成[0.019842s].
[2021-10-26 11:53:50.186849] INFO: moduleinvoker: advanced_auto_labeler.v2 开始运行..
[2021-10-26 11:53:54.220897] INFO: 自动标注(股票): 加载历史数据: 4597290 行
[2021-10-26 11:53:54.222802] INFO: 自动标注(股票): 开始标注 ..
[2021-10-26 11:54:00.037485] INFO: moduleinvoker: advanced_auto_labeler.v2 运行完成[9.850633s].
[2021-10-26 11:54:00.047115] INFO: moduleinvoker: standardlize.v8 开始运行..
[2021-10-26 11:54:35.140195] INFO: moduleinvoker: standardlize.v8 运行完成[35.093074s].
[2021-10-26 11:54:35.149912] INFO: moduleinvoker: input_features.v1 开始运行..
[2021-10-26 11:54:35.157407] INFO: moduleinvoker: 命中缓存
[2021-10-26 11:54:35.158889] INFO: moduleinvoker: input_features.v1 运行完成[0.008981s].
[2021-10-26 11:54:35.180277] INFO: moduleinvoker: general_feature_extractor.v7 开始运行..
[2021-10-26 11:54:35.852280] INFO: 基础特征抽取: 年份 2009, 特征行数=12795
[2021-10-26 11:54:37.641108] INFO: 基础特征抽取: 年份 2010, 特征行数=431567
[2021-10-26 11:54:40.014269] INFO: 基础特征抽取: 年份 2011, 特征行数=511455
[2021-10-26 11:54:42.560162] INFO: 基础特征抽取: 年份 2012, 特征行数=565675
[2021-10-26 11:54:45.498635] INFO: 基础特征抽取: 年份 2013, 特征行数=564168
[2021-10-26 11:54:48.333216] INFO: 基础特征抽取: 年份 2014, 特征行数=569948
[2021-10-26 11:54:51.292088] INFO: 基础特征抽取: 年份 2015, 特征行数=569698
[2021-10-26 11:54:54.306600] INFO: 基础特征抽取: 年份 2016, 特征行数=641546
[2021-10-26 11:54:57.600060] INFO: 基础特征抽取: 年份 2017, 特征行数=743233
[2021-10-26 11:54:57.785779] INFO: 基础特征抽取: 总行数: 4610085
[2021-10-26 11:54:57.798430] INFO: moduleinvoker: general_feature_extractor.v7 运行完成[22.618144s].
[2021-10-26 11:54:57.813805] INFO: moduleinvoker: derived_feature_extractor.v3 开始运行..
[2021-10-26 11:55:12.355656] INFO: derived_feature_extractor: 提取完成 mean(close_0, 5), 3.105s
[2021-10-26 11:55:15.505062] INFO: derived_feature_extractor: 提取完成 mean(low_0, 5), 3.148s
[2021-10-26 11:55:18.670265] INFO: derived_feature_extractor: 提取完成 mean(open_0, 5), 3.163s
[2021-10-26 11:55:22.073671] INFO: derived_feature_extractor: 提取完成 mean(high_0, 5), 3.402s
[2021-10-26 11:55:25.606597] INFO: derived_feature_extractor: 提取完成 mean(turn_0, 5), 3.531s
[2021-10-26 11:55:29.168257] INFO: derived_feature_extractor: 提取完成 mean(amount_0, 5), 3.559s
[2021-10-26 11:55:32.639465] INFO: derived_feature_extractor: 提取完成 mean(return_0, 5), 3.470s
[2021-10-26 11:55:36.130133] INFO: derived_feature_extractor: 提取完成 ts_max(close_0, 5), 3.489s
[2021-10-26 11:55:39.607039] INFO: derived_feature_extractor: 提取完成 ts_max(low_0, 5), 3.475s
[2021-10-26 11:55:43.033029] INFO: derived_feature_extractor: 提取完成 ts_max(open_0, 5), 3.424s
[2021-10-26 11:55:46.471137] INFO: derived_feature_extractor: 提取完成 ts_max(high_0, 5), 3.436s
[2021-10-26 11:55:50.220594] INFO: derived_feature_extractor: 提取完成 ts_max(turn_0, 5), 3.748s
[2021-10-26 11:55:53.811971] INFO: derived_feature_extractor: 提取完成 ts_max(amount_0, 5), 3.590s
[2021-10-26 11:55:57.420308] INFO: derived_feature_extractor: 提取完成 ts_max(return_0, 5), 3.606s
[2021-10-26 11:56:00.844461] INFO: derived_feature_extractor: 提取完成 ts_min(close_0, 5), 3.422s
[2021-10-26 11:56:04.302785] INFO: derived_feature_extractor: 提取完成 ts_min(low_0, 5), 3.456s
[2021-10-26 11:56:07.776412] INFO: derived_feature_extractor: 提取完成 ts_min(open_0, 5), 3.471s
[2021-10-26 11:56:11.216635] INFO: derived_feature_extractor: 提取完成 ts_min(high_0, 5), 3.439s
[2021-10-26 11:56:14.652846] INFO: derived_feature_extractor: 提取完成 ts_min(turn_0, 5), 3.435s
[2021-10-26 11:56:20.422620] INFO: derived_feature_extractor: 提取完成 ts_min(amount_0, 5), 5.768s
[2021-10-26 11:56:23.895356] INFO: derived_feature_extractor: 提取完成 ts_min(return_0, 5), 3.471s
[2021-10-26 11:56:27.562111] INFO: derived_feature_extractor: 提取完成 std(close_0, 5), 3.665s
[2021-10-26 11:56:31.071210] INFO: derived_feature_extractor: 提取完成 std(low_0, 5), 3.507s
[2021-10-26 11:56:34.599965] INFO: derived_feature_extractor: 提取完成 std(open_0, 5), 3.527s
[2021-10-26 11:56:38.156569] INFO: derived_feature_extractor: 提取完成 std(high_0, 5), 3.554s
[2021-10-26 11:56:41.780756] INFO: derived_feature_extractor: 提取完成 std(turn_0, 5), 3.623s
[2021-10-26 11:56:45.286708] INFO: derived_feature_extractor: 提取完成 std(amount_0, 5), 3.504s
[2021-10-26 11:56:48.737082] INFO: derived_feature_extractor: 提取完成 std(return_0, 5), 3.449s
[2021-10-26 11:57:03.732952] INFO: derived_feature_extractor: 提取完成 ts_rank(close_0, 5), 14.994s
[2021-10-26 11:57:18.459438] INFO: derived_feature_extractor: 提取完成 ts_rank(low_0, 5), 14.725s
[2021-10-26 11:57:33.122956] INFO: derived_feature_extractor: 提取完成 ts_rank(open_0, 5), 14.662s
[2021-10-26 11:57:47.786432] INFO: derived_feature_extractor: 提取完成 ts_rank(high_0, 5), 14.662s
[2021-10-26 11:58:02.666538] INFO: derived_feature_extractor: 提取完成 ts_rank(turn_0, 5), 14.878s
[2021-10-26 11:58:18.017712] INFO: derived_feature_extractor: 提取完成 ts_rank(amount_0, 5), 15.350s
[2021-10-26 11:58:31.295005] INFO: derived_feature_extractor: 提取完成 ts_rank(return_0, 5), 13.276s
[2021-10-26 11:58:40.218690] INFO: derived_feature_extractor: 提取完成 decay_linear(close_0, 5), 8.922s
[2021-10-26 11:58:49.214164] INFO: derived_feature_extractor: 提取完成 decay_linear(low_0, 5), 8.993s
[2021-10-26 11:58:59.132243] INFO: derived_feature_extractor: 提取完成 decay_linear(open_0, 5), 9.917s
[2021-10-26 11:59:08.514253] INFO: derived_feature_extractor: 提取完成 decay_linear(high_0, 5), 9.380s
[2021-10-26 11:59:18.789320] INFO: derived_feature_extractor: 提取完成 decay_linear(turn_0, 5), 10.273s
[2021-10-26 11:59:28.503915] INFO: derived_feature_extractor: 提取完成 decay_linear(amount_0, 5), 9.713s
[2021-10-26 11:59:37.544933] INFO: derived_feature_extractor: 提取完成 decay_linear(return_0, 5), 9.039s
[2021-10-26 12:00:02.975498] INFO: derived_feature_extractor: 提取完成 correlation(volume_0, return_0, 5), 25.429s
[2021-10-26 12:00:27.372198] INFO: derived_feature_extractor: 提取完成 correlation(volume_0, high_0, 5), 24.395s
[2021-10-26 12:00:52.934548] INFO: derived_feature_extractor: 提取完成 correlation(volume_0, low_0, 5), 25.561s
[2021-10-26 12:01:20.010069] INFO: derived_feature_extractor: 提取完成 correlation(volume_0, close_0, 5), 27.074s
[2021-10-26 12:01:44.298519] INFO: derived_feature_extractor: 提取完成 correlation(volume_0, open_0, 5), 24.287s
[2021-10-26 12:02:08.581897] INFO: derived_feature_extractor: 提取完成 correlation(volume_0, turn_0, 5), 24.281s
[2021-10-26 12:02:34.001895] INFO: derived_feature_extractor: 提取完成 correlation(return_0, high_0, 5), 25.418s
[2021-10-26 12:02:59.017000] INFO: derived_feature_extractor: 提取完成 correlation(return_0, low_0, 5), 25.012s
[2021-10-26 12:03:22.921364] INFO: derived_feature_extractor: 提取完成 correlation(return_0, close_0, 5), 23.902s
[2021-10-26 12:03:48.729838] INFO: derived_feature_extractor: 提取完成 correlation(return_0, open_0, 5), 25.807s
[2021-10-26 12:04:15.353114] INFO: derived_feature_extractor: 提取完成 correlation(return_0, turn_0, 5), 26.622s
[2021-10-26 12:04:41.273675] INFO: derived_feature_extractor: 提取完成 correlation(high_0, low_0, 5), 25.919s
[2021-10-26 12:05:06.007658] INFO: derived_feature_extractor: 提取完成 correlation(high_0, close_0, 5), 24.732s
[2021-10-26 12:05:33.035505] INFO: derived_feature_extractor: 提取完成 correlation(high_0, open_0, 5), 27.026s
[2021-10-26 12:05:58.033689] INFO: derived_feature_extractor: 提取完成 correlation(high_0, turn_0, 5), 24.996s
[2021-10-26 12:06:24.976763] INFO: derived_feature_extractor: 提取完成 correlation(low_0, close_0, 5), 26.941s
[2021-10-26 12:06:48.961616] INFO: derived_feature_extractor: 提取完成 correlation(low_0, open_0, 5), 23.983s
[2021-10-26 12:07:13.420652] INFO: derived_feature_extractor: 提取完成 correlation(low_0, turn_0, 5), 24.457s
[2021-10-26 12:07:37.684751] INFO: derived_feature_extractor: 提取完成 correlation(close_0, open_0, 5), 24.262s
[2021-10-26 12:08:01.753210] INFO: derived_feature_extractor: 提取完成 correlation(close_0, turn_0, 5), 24.067s
[2021-10-26 12:08:25.407178] INFO: derived_feature_extractor: 提取完成 correlation(open_0, turn_0, 5), 23.652s
[2021-10-26 12:08:36.650192] INFO: derived_feature_extractor: /y_2009, 12795
[2021-10-26 12:08:37.734691] INFO: derived_feature_extractor: /y_2010, 431567
[2021-10-26 12:08:41.034377] INFO: derived_feature_extractor: /y_2011, 511455
[2021-10-26 12:08:44.912275] INFO: derived_feature_extractor: /y_2012, 565675
[2021-10-26 12:08:55.839108] INFO: derived_feature_extractor: /y_2013, 564168
[2021-10-26 12:09:01.819675] INFO: derived_feature_extractor: /y_2014, 569948
[2021-10-26 12:09:06.178728] INFO: derived_feature_extractor: /y_2015, 569698
[2021-10-26 12:09:10.828357] INFO: derived_feature_extractor: /y_2016, 641546
[2021-10-26 12:09:15.870005] INFO: derived_feature_extractor: /y_2017, 743233
[2021-10-26 12:09:19.815031] INFO: moduleinvoker: derived_feature_extractor.v3 运行完成[862.001215s].
[2021-10-26 12:09:19.821489] INFO: moduleinvoker: standardlize.v8 开始运行..
[2021-10-26 12:18:12.229323] INFO: moduleinvoker: standardlize.v8 运行完成[532.407828s].
[2021-10-26 12:18:12.244742] INFO: moduleinvoker: fillnan.v1 开始运行..
[2021-10-26 12:18:48.164191] INFO: moduleinvoker: fillnan.v1 运行完成[35.919437s].
[2021-10-26 12:18:48.180423] INFO: moduleinvoker: join.v3 开始运行..
[2021-10-26 12:20:17.262404] INFO: join: /data, 行数=4551595/4593884, 耗时=82.428297s
[2021-10-26 12:20:17.585025] INFO: join: 最终行数: 4551595
[2021-10-26 12:20:17.611010] INFO: moduleinvoker: join.v3 运行完成[89.430583s].
[2021-10-26 12:20:17.635495] INFO: moduleinvoker: dl_convert_to_bin.v2 开始运行..
[2021-10-26 12:27:25.442033] INFO: moduleinvoker: dl_convert_to_bin.v2 运行完成[427.806539s].
[2021-10-26 12:27:25.449393] INFO: moduleinvoker: instruments.v2 开始运行..
[2021-10-26 12:27:25.582275] INFO: moduleinvoker: instruments.v2 运行完成[0.132887s].
[2021-10-26 12:27:25.594975] INFO: moduleinvoker: general_feature_extractor.v7 开始运行..
[2021-10-26 12:27:26.711155] INFO: 基础特征抽取: 年份 2017, 特征行数=19477
[2021-10-26 12:27:30.429043] INFO: 基础特征抽取: 年份 2018, 特征行数=816987
[2021-10-26 12:27:34.965009] INFO: 基础特征抽取: 年份 2019, 特征行数=884867
[2021-10-26 12:27:39.441845] INFO: 基础特征抽取: 年份 2020, 特征行数=945961
[2021-10-26 12:27:42.652818] INFO: 基础特征抽取: 年份 2021, 特征行数=503096
[2021-10-26 12:27:42.719656] INFO: 基础特征抽取: 总行数: 3170388
[2021-10-26 12:27:42.726163] INFO: moduleinvoker: general_feature_extractor.v7 运行完成[17.131184s].
[2021-10-26 12:27:42.733879] INFO: moduleinvoker: derived_feature_extractor.v3 开始运行..
[2021-10-26 12:27:52.363850] INFO: derived_feature_extractor: 提取完成 mean(close_0, 5), 1.940s
[2021-10-26 12:27:54.283908] INFO: derived_feature_extractor: 提取完成 mean(low_0, 5), 1.918s
[2021-10-26 12:27:56.255265] INFO: derived_feature_extractor: 提取完成 mean(open_0, 5), 1.970s
[2021-10-26 12:27:58.139536] INFO: derived_feature_extractor: 提取完成 mean(high_0, 5), 1.882s
[2021-10-26 12:28:00.141823] INFO: derived_feature_extractor: 提取完成 mean(turn_0, 5), 2.001s
[2021-10-26 12:28:02.199664] INFO: derived_feature_extractor: 提取完成 mean(amount_0, 5), 2.056s
[2021-10-26 12:28:04.246438] INFO: derived_feature_extractor: 提取完成 mean(return_0, 5), 2.045s
[2021-10-26 12:28:06.392845] INFO: derived_feature_extractor: 提取完成 ts_max(close_0, 5), 2.145s
[2021-10-26 12:28:08.543476] INFO: derived_feature_extractor: 提取完成 ts_max(low_0, 5), 2.149s
[2021-10-26 12:28:10.632842] INFO: derived_feature_extractor: 提取完成 ts_max(open_0, 5), 2.088s
[2021-10-26 12:28:12.668501] INFO: derived_feature_extractor: 提取完成 ts_max(high_0, 5), 2.034s
[2021-10-26 12:28:14.639460] INFO: derived_feature_extractor: 提取完成 ts_max(turn_0, 5), 1.969s
[2021-10-26 12:28:16.574115] INFO: derived_feature_extractor: 提取完成 ts_max(amount_0, 5), 1.933s
[2021-10-26 12:28:18.513672] INFO: derived_feature_extractor: 提取完成 ts_max(return_0, 5), 1.938s
[2021-10-26 12:28:20.452093] INFO: derived_feature_extractor: 提取完成 ts_min(close_0, 5), 1.937s
[2021-10-26 12:28:22.441648] INFO: derived_feature_extractor: 提取完成 ts_min(low_0, 5), 1.988s
[2021-10-26 12:28:24.446836] INFO: derived_feature_extractor: 提取完成 ts_min(open_0, 5), 2.003s
[2021-10-26 12:28:26.413216] INFO: derived_feature_extractor: 提取完成 ts_min(high_0, 5), 1.965s
[2021-10-26 12:28:28.444456] INFO: derived_feature_extractor: 提取完成 ts_min(turn_0, 5), 2.030s
[2021-10-26 12:28:30.448992] INFO: derived_feature_extractor: 提取完成 ts_min(amount_0, 5), 2.003s
[2021-10-26 12:28:32.464012] INFO: derived_feature_extractor: 提取完成 ts_min(return_0, 5), 2.013s
[2021-10-26 12:28:34.498931] INFO: derived_feature_extractor: 提取完成 std(close_0, 5), 2.033s
[2021-10-26 12:28:36.604983] INFO: derived_feature_extractor: 提取完成 std(low_0, 5), 2.104s
[2021-10-26 12:28:38.689591] INFO: derived_feature_extractor: 提取完成 std(open_0, 5), 2.083s
[2021-10-26 12:28:40.769011] INFO: derived_feature_extractor: 提取完成 std(high_0, 5), 2.078s
[2021-10-26 12:28:42.794530] INFO: derived_feature_extractor: 提取完成 std(turn_0, 5), 2.024s
[2021-10-26 12:28:44.875730] INFO: derived_feature_extractor: 提取完成 std(amount_0, 5), 2.080s
[2021-10-26 12:28:46.898182] INFO: derived_feature_extractor: 提取完成 std(return_0, 5), 2.021s
[2021-10-26 12:28:56.208391] INFO: derived_feature_extractor: 提取完成 ts_rank(close_0, 5), 9.309s
[2021-10-26 12:29:06.116166] INFO: derived_feature_extractor: 提取完成 ts_rank(low_0, 5), 9.906s
[2021-10-26 12:29:14.331373] INFO: derived_feature_extractor: 提取完成 ts_rank(open_0, 5), 8.214s
[2021-10-26 12:29:22.487410] INFO: derived_feature_extractor: 提取完成 ts_rank(high_0, 5), 8.155s
[2021-10-26 12:29:31.381519] INFO: derived_feature_extractor: 提取完成 ts_rank(turn_0, 5), 8.893s
[2021-10-26 12:29:40.152395] INFO: derived_feature_extractor: 提取完成 ts_rank(amount_0, 5), 8.769s
[2021-10-26 12:29:49.191599] INFO: derived_feature_extractor: 提取完成 ts_rank(return_0, 5), 9.037s
[2021-10-26 12:29:54.872129] INFO: derived_feature_extractor: 提取完成 decay_linear(close_0, 5), 5.679s
[2021-10-26 12:30:00.766686] INFO: derived_feature_extractor: 提取完成 decay_linear(low_0, 5), 5.893s
[2021-10-26 12:30:06.451341] INFO: derived_feature_extractor: 提取完成 decay_linear(open_0, 5), 5.683s
[2021-10-26 12:30:12.246862] INFO: derived_feature_extractor: 提取完成 decay_linear(high_0, 5), 5.794s
[2021-10-26 12:30:17.725530] INFO: derived_feature_extractor: 提取完成 decay_linear(turn_0, 5), 5.477s
[2021-10-26 12:30:23.244134] INFO: derived_feature_extractor: 提取完成 decay_linear(amount_0, 5), 5.517s
[2021-10-26 12:30:28.655429] INFO: derived_feature_extractor: 提取完成 decay_linear(return_0, 5), 5.410s
[2021-10-26 12:30:56.206949] INFO: derived_feature_extractor: 提取完成 correlation(volume_0, return_0, 5), 27.550s
[2021-10-26 12:31:23.410111] INFO: derived_feature_extractor: 提取完成 correlation(volume_0, high_0, 5), 27.202s
[2021-10-26 12:31:50.606612] INFO: derived_feature_extractor: 提取完成 correlation(volume_0, low_0, 5), 27.195s
[2021-10-26 12:32:17.829087] INFO: derived_feature_extractor: 提取完成 correlation(volume_0, close_0, 5), 27.221s
[2021-10-26 12:32:46.023033] INFO: derived_feature_extractor: 提取完成 correlation(volume_0, open_0, 5), 28.192s
[2021-10-26 12:33:13.672546] INFO: derived_feature_extractor: 提取完成 correlation(volume_0, turn_0, 5), 27.648s
[2021-10-26 12:33:42.205336] INFO: derived_feature_extractor: 提取完成 correlation(return_0, high_0, 5), 28.531s
[2021-10-26 12:34:11.623303] INFO: derived_feature_extractor: 提取完成 correlation(return_0, low_0, 5), 29.416s
[2021-10-26 12:34:39.994834] INFO: derived_feature_extractor: 提取完成 correlation(return_0, close_0, 5), 28.370s
[2021-10-26 12:35:08.699852] INFO: derived_feature_extractor: 提取完成 correlation(return_0, open_0, 5), 28.703s
[2021-10-26 12:35:37.518479] INFO: derived_feature_extractor: 提取完成 correlation(return_0, turn_0, 5), 28.817s
[2021-10-26 12:36:05.670344] INFO: derived_feature_extractor: 提取完成 correlation(high_0, low_0, 5), 28.150s
[2021-10-26 12:36:33.215872] INFO: derived_feature_extractor: 提取完成 correlation(high_0, close_0, 5), 27.544s
[2021-10-26 12:37:01.105531] INFO: derived_feature_extractor: 提取完成 correlation(high_0, open_0, 5), 27.888s
[2021-10-26 12:37:29.016628] INFO: derived_feature_extractor: 提取完成 correlation(high_0, turn_0, 5), 27.909s
[2021-10-26 12:37:56.723779] INFO: derived_feature_extractor: 提取完成 correlation(low_0, close_0, 5), 27.705s
[2021-10-26 12:38:25.542625] INFO: derived_feature_extractor: 提取完成 correlation(low_0, open_0, 5), 28.817s
[2021-10-26 12:38:55.289339] INFO: derived_feature_extractor: 提取完成 correlation(low_0, turn_0, 5), 29.745s
[2021-10-26 12:39:24.894432] INFO: derived_feature_extractor: 提取完成 correlation(close_0, open_0, 5), 29.603s
[2021-10-26 12:39:52.029630] INFO: derived_feature_extractor: 提取完成 correlation(close_0, turn_0, 5), 27.133s
[2021-10-26 12:40:19.871997] INFO: derived_feature_extractor: 提取完成 correlation(open_0, turn_0, 5), 27.841s
[2021-10-26 12:40:22.726691] INFO: derived_feature_extractor: /y_2017, 19477
[2021-10-26 12:40:24.561747] INFO: derived_feature_extractor: /y_2018, 816987
[2021-10-26 12:40:29.724688] INFO: derived_feature_extractor: /y_2019, 884867
[2021-10-26 12:40:35.368188] INFO: derived_feature_extractor: /y_2020, 945961
[2021-10-26 12:40:40.349933] INFO: derived_feature_extractor: /y_2021, 503096
[2021-10-26 12:40:42.644037] INFO: moduleinvoker: derived_feature_extractor.v3 运行完成[779.910146s].
[2021-10-26 12:40:42.651622] INFO: moduleinvoker: standardlize.v8 开始运行..
[2021-10-26 12:45:48.480882] INFO: moduleinvoker: standardlize.v8 运行完成[305.829258s].
[2021-10-26 12:45:48.489918] INFO: moduleinvoker: fillnan.v1 开始运行..
[2021-10-26 12:46:13.162504] INFO: moduleinvoker: fillnan.v1 运行完成[24.672576s].
[2021-10-26 12:46:13.177489] INFO: moduleinvoker: dl_convert_to_bin.v2 开始运行..
[2021-10-26 12:49:18.286543] INFO: moduleinvoker: dl_convert_to_bin.v2 运行完成[185.109061s].
[2021-10-26 12:49:18.306753] INFO: moduleinvoker: cached.v3 开始运行..
[2021-10-26 13:24:59.964824] INFO: moduleinvoker: cached.v3 运行完成[2141.658078s].
[2021-10-26 13:24:59.976056] INFO: moduleinvoker: cached.v3 开始运行..
[2021-10-26 13:25:23.372819] INFO: moduleinvoker: cached.v3 运行完成[23.396768s].
[2021-10-26 13:25:25.177196] INFO: moduleinvoker: backtest.v8 开始运行..
[2021-10-26 13:25:25.182304] INFO: backtest: biglearning backtest:V8.5.0
[2021-10-26 13:25:25.183746] INFO: backtest: product_type:stock by specified
[2021-10-26 13:25:25.306291] INFO: moduleinvoker: cached.v2 开始运行..
[2021-10-26 13:25:34.766921] INFO: backtest: 读取股票行情完成:4336032
[2021-10-26 13:25:40.770124] INFO: moduleinvoker: cached.v2 运行完成[15.463849s].
[2021-10-26 13:25:44.622145] INFO: algo: TradingAlgorithm V1.8.5
[2021-10-26 13:25:46.347660] INFO: algo: trading transform...
[2021-10-26 13:26:48.391142] INFO: Performance: Simulated 849 trading days out of 849.
[2021-10-26 13:26:48.392757] INFO: Performance: first open: 2018-01-02 09:30:00+00:00
[2021-10-26 13:26:48.394270] INFO: Performance: last close: 2021-07-01 15:00:00+00:00
[2021-10-26 13:27:03.494861] INFO: moduleinvoker: backtest.v8 运行完成[98.317669s].
[2021-10-26 13:27:03.496681] INFO: moduleinvoker: trade.v4 运行完成[100.082863s].