版本 v1.0
可视化策略实现如下:
# 本代码由可视化策略环境自动生成 2022年1月14日 15:48
# 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
# Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端
def m2_run_bigquant_run(input_1, input_2, input_3):
# 示例代码如下。在这里编写您的代码
# 计算行业行业收益
industry_df = DataSource("basic_info_index_CN_STOCK_A").read()
SW_industry_list = industry_df[industry_df.instrument.str.startswith('SW')].instrument.tolist()
SW_industry_df = DataSource("bar1d_index_CN_STOCK_A").read(SW_industry_list)
SW_industry_ret = SW_industry_df.groupby('instrument').apply(calcu_ret)
SW_industry_ret.reset_index(inplace=True, drop=True)
SW_industry_ret['date'] = SW_industry_ret['date'].apply(lambda x:x.strftime('%Y-%m-%d'))
daily_buy_industry_dict = {dt:seek_head_industry(SW_industry_ret.set_index('date').loc[dt]) for dt in list(set(SW_industry_ret.date))}
daily_stock = input_1.read()
daily_stock['industry_sw_level1_0'] = daily_stock['industry_sw_level1_0'].apply(lambda x:'SW'+str(x)+'.HIX')
daily_stock = daily_stock.groupby(['date', 'industry_sw_level1_0']).apply(seek_head_stock).reset_index()
buy_df = pd.DataFrame()
for k,v in daily_buy_industry_dict.items():
buy_df = buy_df.append(daily_stock[(daily_stock.date==k)&(daily_stock.industry_sw_level1_0.apply(lambda x: x in v))])
buy_df = buy_df.groupby('date').apply(lambda x:x[0].values.tolist()).reset_index()
buy_df[0] = buy_df[0].apply(lambda x:x[0]+x[1]+x[2])
data_1 = DataSource.write_df(buy_df)
return Outputs(data_1=data_1, data_2=None, data_3=None)
# 计算不同周期的动量
def calcu_ret(df):
df = df.sort_values('date')
for i in [42, 84, 126]: # 分别代表2月、4月、半年的动量
df['ret_%s'%i] = df['close']/df['close'].shift(i)-1
return df
# 计算出得分
def seek_head_industry(df):
for j in ['ret_42','ret_84','ret_126']:
df['%s'%j] = df['%s'%j].rank(ascending=True)
df['score'] = 0.4*df['ret_42']+0.3*df['ret_84']+0.3*df['ret_126'] # 得分的权重分别为0.4、0.3、0.3
result = df.sort_values('score', ascending=False)
return list(result.instrument)[:3] # 前3个行业
# 选出特定行业优质股票
def seek_head_stock(df):
result = df.sort_values(['myrank'], ascending=False)
return list(result.instrument[:10]) # 每个行业选10只股票
# 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。
def m2_post_run_bigquant_run(outputs):
return outputs
# 回测引擎:初始化函数,只执行一次
def m4_initialize_bigquant_run(context):
# 手续费设置
context.set_commission(PerOrder(buy_cost=0.0003, sell_cost=0.0013, min_cost=5))
context.mydata = context.options["data"].read()
# 回测引擎:每日数据处理函数,每天执行一次
def m4_handle_data_bigquant_run(context, data):
# 按月调仓
if context.trading_day_index % 20 != 0:
return
date = data.current_dt.strftime('%Y-%m-%d') # 日期
# 整理出当天要买入的股票
stock_to_buy = context.mydata[context.mydata.date==date][0].tolist()[0]
# 通过positions对象,使用列表生成式的方法获取目前持仓的股票列表
stock_hold_now = [equity.symbol for equity in context.portfolio.positions]
# 继续持有的股票:调仓时,如果买入的股票已经存在于目前的持仓里,那么应继续持有
no_need_to_sell = [i for i in stock_hold_now if i in stock_to_buy]
# 需要卖出的股票
stock_to_sell = [i for i in stock_hold_now if i not in no_need_to_sell]
# 卖出
for stock in stock_to_sell:
# 如果该股票停牌,则没法成交。因此需要用can_trade方法检查下该股票的状态
# 如果返回真值,则可以正常下单,否则会出错
# 因为stock是字符串格式,我们用symbol方法将其转化成平台可以接受的形式:Equity格式
if data.can_trade(context.symbol(stock)):
# order_target_percent是平台的一个下单接口,表明下单使得该股票的权重为0,
# 即卖出全部股票,可参考回测文档
context.order_target_percent(context.symbol(stock), 0)
# 如果当天没有买入的股票,就返回
if len(stock_to_buy) == 0:
return
# 等权重买入
weight = 1 / len(stock_to_buy)
# 买入
for stock in stock_to_buy:
if data.can_trade(context.symbol(stock)):
# 下单使得某只股票的持仓权重达到weight,因为weight大于0,因此是等权重买入
context.order_target_percent(context.symbol(stock), weight)
# 回测引擎:准备数据,只执行一次
def m4_prepare_bigquant_run(context):
pass
# 回测引擎:每个单位时间开始前调用一次,即每日开盘前调用一次。
def m4_before_trading_start_bigquant_run(context, data):
pass
m7 = M.input_features.v1(
features="""industry_sw_level1_0
myrank=rank_fs_roe_ttm_0+rank_fs_net_profit_qoq_0-rank_pb_lf_0"""
)
m5 = M.instruments.v2(
start_date='2021-01-01',
end_date='2022-01-10',
market='CN_STOCK_A',
instrument_list='',
max_count=0
)
m6 = M.general_feature_extractor.v7(
instruments=m5.data,
features=m7.data,
start_date='',
end_date='',
before_start_days=90
)
m8 = M.derived_feature_extractor.v3(
input_data=m6.data,
features=m7.data,
date_col='date',
instrument_col='instrument',
drop_na=False,
remove_extra_columns=False,
user_functions={}
)
m9 = M.dropnan.v2(
input_data=m8.data
)
m2 = M.cached.v3(
input_1=m9.data,
run=m2_run_bigquant_run,
post_run=m2_post_run_bigquant_run,
input_ports='',
params='{}',
output_ports='data_1'
)
m4 = M.trade.v4(
instruments=m5.data,
options_data=m2.data_1,
start_date='',
end_date='',
initialize=m4_initialize_bigquant_run,
handle_data=m4_handle_data_bigquant_run,
prepare=m4_prepare_bigquant_run,
before_trading_start=m4_before_trading_start_bigquant_run,
volume_limit=0.025,
order_price_field_buy='open',
order_price_field_sell='close',
capital_base=10000000,
auto_cancel_non_tradable_orders=True,
data_frequency='daily',
price_type='真实价格',
product_type='股票',
plot_charts=True,
backtest_only=False,
benchmark=''
)
[2022-01-14 15:21:06.128423] INFO: moduleinvoker: input_features.v1 开始运行..
[2022-01-14 15:21:06.140055] INFO: moduleinvoker: 命中缓存
[2022-01-14 15:21:06.141593] INFO: moduleinvoker: input_features.v1 运行完成[0.013179s].
[2022-01-14 15:21:06.146236] INFO: moduleinvoker: instruments.v2 开始运行..
[2022-01-14 15:21:06.220231] INFO: moduleinvoker: instruments.v2 运行完成[0.073978s].
[2022-01-14 15:21:06.234019] INFO: moduleinvoker: general_feature_extractor.v7 开始运行..
[2022-01-14 15:21:09.679094] INFO: 基础特征抽取: 年份 2020, 特征行数=243745
[2022-01-14 15:21:15.373274] INFO: 基础特征抽取: 年份 2021, 特征行数=1061527
[2022-01-14 15:21:15.658919] INFO: 基础特征抽取: 年份 2022, 特征行数=23368
[2022-01-14 15:21:15.724166] INFO: 基础特征抽取: 总行数: 1328640
[2022-01-14 15:21:15.729169] INFO: moduleinvoker: general_feature_extractor.v7 运行完成[9.49515s].
[2022-01-14 15:21:15.737204] INFO: moduleinvoker: derived_feature_extractor.v3 开始运行..
[2022-01-14 15:21:17.898569] INFO: derived_feature_extractor: 提取完成 myrank=rank_fs_roe_ttm_0+rank_fs_net_profit_qoq_0-rank_pb_lf_0, 0.003s
[2022-01-14 15:21:18.323013] INFO: derived_feature_extractor: /y_2020, 243745
[2022-01-14 15:21:19.950871] INFO: derived_feature_extractor: /y_2021, 1061527
[2022-01-14 15:21:20.214360] INFO: derived_feature_extractor: /y_2022, 23368
[2022-01-14 15:21:20.339393] INFO: moduleinvoker: derived_feature_extractor.v3 运行完成[4.602175s].
[2022-01-14 15:21:20.347192] INFO: moduleinvoker: dropnan.v2 开始运行..
[2022-01-14 15:21:20.562471] INFO: dropnan: /y_2020, 216017/243745
[2022-01-14 15:21:21.063027] INFO: dropnan: /y_2021, 891641/1061527
[2022-01-14 15:21:21.137937] INFO: dropnan: /y_2022, 16787/23368
[2022-01-14 15:21:21.239446] INFO: dropnan: 行数: 1124445/1328640
[2022-01-14 15:21:21.244238] INFO: moduleinvoker: dropnan.v2 运行完成[0.897036s].
[2022-01-14 15:21:21.260102] INFO: moduleinvoker: cached.v3 开始运行..
[2022-01-14 15:23:42.064725] INFO: moduleinvoker: cached.v3 运行完成[140.804637s].
[2022-01-14 15:23:42.146073] INFO: moduleinvoker: backtest.v8 开始运行..
[2022-01-14 15:23:42.151605] INFO: backtest: biglearning backtest:V8.6.1
[2022-01-14 15:23:42.152619] INFO: backtest: product_type:stock by specified
[2022-01-14 15:23:42.239882] INFO: moduleinvoker: cached.v2 开始运行..
[2022-01-14 15:23:46.949885] INFO: backtest: 读取股票行情完成:2185220
[2022-01-14 15:23:50.043348] INFO: moduleinvoker: cached.v2 运行完成[7.803463s].
[2022-01-14 15:23:51.818526] INFO: algo: TradingAlgorithm V1.8.6
[2022-01-14 15:23:52.394703] INFO: algo: trading transform...
[2022-01-14 15:23:53.545809] INFO: algo: handle_splits get splits [dt:2021-05-10 00:00:00+00:00] [asset:Equity(2952 [000932.SZA]), ratio:0.9750295877456665]
[2022-01-14 15:23:53.547328] INFO: Position: position stock handle split[sid:2952, orig_amount:43200, new_amount:44306.0, orig_cost:7.880000143367766, new_cost:7.6832, ratio:0.9750295877456665, last_sale_price:8.19999885559082]
[2022-01-14 15:23:53.548452] INFO: Position: after split: PositionStock(asset:Equity(2952 [000932.SZA]), amount:44306.0, cost_basis:7.6832, last_sale_price:8.40999984741211)
[2022-01-14 15:23:53.549435] INFO: Position: returning cash: 2.8517
[2022-01-14 15:23:53.621849] INFO: algo: handle_splits get splits [dt:2021-05-13 00:00:00+00:00] [asset:Equity(67 [600282.SHA]), ratio:0.9446902871131897]
[2022-01-14 15:23:53.623086] INFO: Position: position stock handle split[sid:67, orig_amount:77600, new_amount:82143.0, orig_cost:3.4800001418347604, new_cost:3.2875, ratio:0.9446902871131897, last_sale_price:4.269999980926514]
[2022-01-14 15:23:53.624147] INFO: Position: after split: PositionStock(asset:Equity(67 [600282.SHA]), amount:82143.0, cost_basis:3.2875, last_sale_price:4.519999980926514)
[2022-01-14 15:23:53.625117] INFO: Position: returning cash: 1.382
[2022-01-14 15:23:53.633189] INFO: algo: handle_splits get splits [dt:2021-05-14 00:00:00+00:00] [asset:Equity(5618 [601677.SHA]), ratio:0.9888015389442444]
[2022-01-14 15:23:53.634242] INFO: Position: position stock handle split[sid:5618, orig_amount:17600, new_amount:17799.0, orig_cost:19.820001835264847, new_cost:19.598, ratio:0.9888015389442444, last_sale_price:17.65999412536621]
[2022-01-14 15:23:53.635381] INFO: Position: after split: PositionStock(asset:Equity(5618 [601677.SHA]), amount:17799.0, cost_basis:19.598, last_sale_price:17.85999870300293)
[2022-01-14 15:23:53.636346] INFO: Position: returning cash: 5.7404
[2022-01-14 15:23:53.666186] INFO: algo: handle_splits get splits [dt:2021-05-21 00:00:00+00:00] [asset:Equity(4477 [600985.SHA]), ratio:0.944444477558136]
[2022-01-14 15:23:53.667306] INFO: Position: position stock handle split[sid:4477, orig_amount:26900, new_amount:28482.0, orig_cost:13.050000348065378, new_cost:12.325, ratio:0.944444477558136, last_sale_price:11.050000190734863]
[2022-01-14 15:23:53.668335] INFO: Position: after split: PositionStock(asset:Equity(4477 [600985.SHA]), amount:28482.0, cost_basis:12.325, last_sale_price:11.699999809265137)
[2022-01-14 15:23:53.669293] INFO: Position: returning cash: 3.889
[2022-01-14 15:23:53.699134] INFO: algo: handle_splits get splits [dt:2021-05-28 00:00:00+00:00] [asset:Equity(2681 [600740.SHA]), ratio:0.7466666102409363]
[2022-01-14 15:23:53.700190] INFO: Position: position stock handle split[sid:2681, orig_amount:49100, new_amount:65758.0, orig_cost:7.35000048128496, new_cost:5.488, ratio:0.7466666102409363, last_sale_price:5.039999485015869]
[2022-01-14 15:23:53.701200] INFO: Position: after split: PositionStock(asset:Equity(2681 [600740.SHA]), amount:65758.0, cost_basis:5.488, last_sale_price:6.75)
[2022-01-14 15:23:53.702165] INFO: Position: returning cash: 4.705
[2022-01-14 15:23:53.710221] INFO: algo: handle_splits get splits [dt:2021-05-31 00:00:00+00:00] [asset:Equity(30 [000630.SZA]), ratio:0.9863481521606445]
[2022-01-14 15:23:53.711309] INFO: Position: position stock handle split[sid:30, orig_amount:115300, new_amount:116895.0, orig_cost:3.150000103645066, new_cost:3.107, ratio:0.9863481521606445, last_sale_price:2.8899998664855957]
[2022-01-14 15:23:53.712310] INFO: Position: after split: PositionStock(asset:Equity(30 [000630.SZA]), amount:116895.0, cost_basis:3.107, last_sale_price:2.929999828338623)
[2022-01-14 15:23:53.713279] INFO: Position: returning cash: 2.44
[2022-01-14 15:23:53.726877] INFO: algo: handle_splits get splits [dt:2021-06-02 00:00:00+00:00] [asset:Equity(5429 [000825.SZA]), ratio:0.97826087474823]
[2022-01-14 15:23:53.727937] INFO: Position: position stock handle split[sid:5429, orig_amount:45200, new_amount:46204.0, orig_cost:8.100000402258555, new_cost:7.9239, ratio:0.97826087474823, last_sale_price:6.75]
[2022-01-14 15:23:53.728946] INFO: Position: after split: PositionStock(asset:Equity(5429 [000825.SZA]), amount:46204.0, cost_basis:7.9239, last_sale_price:6.900000095367432)
[2022-01-14 15:23:53.729909] INFO: Position: returning cash: 2.9983
[2022-01-14 15:23:53.838409] INFO: algo: handle_splits get splits [dt:2021-06-11 00:00:00+00:00] [asset:Equity(512 [002732.SZA]), ratio:0.9935564398765564]
[2022-01-14 15:23:53.839726] INFO: algo: handle_splits get splits [dt:2021-06-11 00:00:00+00:00] [asset:Equity(5223 [600997.SHA]), ratio:0.96517413854599]
[2022-01-14 15:23:53.840782] INFO: algo: handle_splits get splits [dt:2021-06-11 00:00:00+00:00] [asset:Equity(3051 [600887.SHA]), ratio:0.9791930317878723]
[2022-01-14 15:23:53.841795] INFO: Position: position stock handle split[sid:512, orig_amount:14200, new_amount:14292.0, orig_cost:23.330123490590477, new_cost:23.1798, ratio:0.9935564398765564, last_sale_price:23.129993438720703]
[2022-01-14 15:23:53.842813] INFO: Position: after split: PositionStock(asset:Equity(512 [002732.SZA]), amount:14292.0, cost_basis:23.1798, last_sale_price:23.279998779296875)
[2022-01-14 15:23:53.843776] INFO: Position: returning cash: 2.1269
[2022-01-14 15:23:53.844772] INFO: Position: position stock handle split[sid:5223, orig_amount:43500, new_amount:45069.0, orig_cost:8.170000346305054, new_cost:7.8855, ratio:0.96517413854599, last_sale_price:7.7599992752075195]
[2022-01-14 15:23:53.845755] INFO: Position: after split: PositionStock(asset:Equity(5223 [600997.SHA]), amount:45069.0, cost_basis:7.8855, last_sale_price:8.039999008178711)
[2022-01-14 15:23:53.846722] INFO: Position: returning cash: 4.5567
[2022-01-14 15:23:53.847706] INFO: Position: position stock handle split[sid:3051, orig_amount:7700, new_amount:7863.0, orig_cost:38.13000107484398, new_cost:37.3366, ratio:0.9791930317878723, last_sale_price:38.589996337890625]
[2022-01-14 15:23:53.848698] INFO: Position: after split: PositionStock(asset:Equity(3051 [600887.SHA]), amount:7863.0, cost_basis:37.3366, last_sale_price:39.40999984741211)
[2022-01-14 15:23:53.849648] INFO: Position: returning cash: 23.8506
[2022-01-14 15:23:53.880998] INFO: algo: handle_splits get splits [dt:2021-06-21 00:00:00+00:00] [asset:Equity(804 [300783.SZA]), ratio:0.9947943687438965]
[2022-01-14 15:23:53.882118] INFO: algo: handle_splits get splits [dt:2021-06-21 00:00:00+00:00] [asset:Equity(5437 [000933.SZA]), ratio:0.9905749559402466]
[2022-01-14 15:23:53.883135] INFO: Position: position stock handle split[sid:804, orig_amount:6600, new_amount:6634.0, orig_cost:49.99002685166021, new_cost:49.7298, ratio:0.9947943687438965, last_sale_price:47.770023345947266]
[2022-01-14 15:23:53.884134] INFO: Position: after split: PositionStock(asset:Equity(804 [300783.SZA]), amount:6634.0, cost_basis:49.7298, last_sale_price:48.019996643066406)
[2022-01-14 15:23:53.885095] INFO: Position: returning cash: 25.6503
[2022-01-14 15:23:53.886089] INFO: Position: position stock handle split[sid:5437, orig_amount:30300, new_amount:30588.0, orig_cost:12.856039104935975, new_cost:12.7349, ratio:0.9905749559402466, last_sale_price:10.510000228881836]
[2022-01-14 15:23:53.887065] INFO: Position: after split: PositionStock(asset:Equity(5437 [000933.SZA]), amount:30588.0, cost_basis:12.7349, last_sale_price:10.609999656677246)
[2022-01-14 15:23:53.888014] INFO: Position: returning cash: 3.1114
[2022-01-14 15:23:53.913834] INFO: algo: handle_splits get splits [dt:2021-06-25 00:00:00+00:00] [asset:Equity(367 [600508.SHA]), ratio:0.9723047018051147]
[2022-01-14 15:23:53.915326] INFO: Position: position stock handle split[sid:367, orig_amount:35000, new_amount:35996.0, orig_cost:10.008488835345963, new_cost:9.7313, ratio:0.9723047018051147, last_sale_price:9.829999923706055]
[2022-01-14 15:23:53.916406] INFO: Position: after split: PositionStock(asset:Equity(367 [600508.SHA]), amount:35996.0, cost_basis:9.7313, last_sale_price:10.109999656677246)
[2022-01-14 15:23:53.917377] INFO: Position: returning cash: 9.3007
[2022-01-14 15:23:53.932720] INFO: algo: handle_splits get splits [dt:2021-06-29 00:00:00+00:00] [asset:Equity(2777 [601699.SHA]), ratio:0.9847512245178223]
[2022-01-14 15:23:53.933880] INFO: algo: handle_splits get splits [dt:2021-06-29 00:00:00+00:00] [asset:Equity(2168 [601168.SHA]), ratio:0.9901957511901855]
[2022-01-14 15:23:53.934915] INFO: Position: position stock handle split[sid:2777, orig_amount:27400, new_amount:27824.0, orig_cost:10.769999699083742, new_cost:10.6058, ratio:0.9847512245178223, last_sale_price:12.269999504089355]
[2022-01-14 15:23:53.935920] INFO: Position: after split: PositionStock(asset:Equity(2777 [601699.SHA]), amount:27824.0, cost_basis:10.6058, last_sale_price:12.459999084472656)
[2022-01-14 15:23:53.936880] INFO: Position: returning cash: 3.5128
[2022-01-14 15:23:53.937876] INFO: Position: position stock handle split[sid:2168, orig_amount:24400, new_amount:24641.0, orig_cost:15.671149089315998, new_cost:15.5175, ratio:0.9901957511901855, last_sale_price:12.119997024536133]
[2022-01-14 15:23:53.938865] INFO: Position: after split: PositionStock(asset:Equity(2168 [601168.SHA]), amount:24641.0, cost_basis:15.5175, last_sale_price:12.24000072479248)
[2022-01-14 15:23:53.939808] INFO: Position: returning cash: 7.1787
[2022-01-14 15:23:53.947836] INFO: algo: handle_splits get splits [dt:2021-06-30 00:00:00+00:00] [asset:Equity(813 [600497.SHA]), ratio:0.988452672958374]
[2022-01-14 15:23:53.948922] INFO: Position: position stock handle split[sid:813, orig_amount:71100, new_amount:71930.0, orig_cost:4.67000165586029, new_cost:4.6161, ratio:0.988452672958374, last_sale_price:4.28000020980835]
[2022-01-14 15:23:53.949924] INFO: Position: after split: PositionStock(asset:Equity(813 [600497.SHA]), amount:71930.0, cost_basis:4.6161, last_sale_price:4.329999923706055)
[2022-01-14 15:23:53.950889] INFO: Position: returning cash: 2.5947
[2022-01-14 15:23:53.958986] INFO: algo: handle_splits get splits [dt:2021-07-01 00:00:00+00:00] [asset:Equity(102 [600073.SHA]), ratio:0.9841269254684448]
[2022-01-14 15:23:53.960064] INFO: Position: position stock handle split[sid:102, orig_amount:37700, new_amount:38308.0, orig_cost:8.770015360710675, new_cost:8.6308, ratio:0.9841269254684448, last_sale_price:8.0600004196167]
[2022-01-14 15:23:53.961085] INFO: Position: after split: PositionStock(asset:Equity(102 [600073.SHA]), amount:38308.0, cost_basis:8.6308, last_sale_price:8.190000534057617)
[2022-01-14 15:23:53.962054] INFO: Position: returning cash: 0.5384
[2022-01-14 15:23:54.074451] INFO: algo: handle_splits get splits [dt:2021-07-07 00:00:00+00:00] [asset:Equity(1696 [600070.SHA]), ratio:0.994356632232666]
[2022-01-14 15:23:54.075886] INFO: Position: position stock handle split[sid:1696, orig_amount:35900, new_amount:36103.0, orig_cost:8.810003196629912, new_cost:8.7603, ratio:0.994356632232666, last_sale_price:8.809999465942383]
[2022-01-14 15:23:54.076998] INFO: Position: after split: PositionStock(asset:Equity(1696 [600070.SHA]), amount:36103.0, cost_basis:8.7603, last_sale_price:8.859999656677246)
[2022-01-14 15:23:54.077972] INFO: Position: returning cash: 6.5786
[2022-01-14 15:23:54.093037] INFO: algo: handle_splits get splits [dt:2021-07-09 00:00:00+00:00] [asset:Equity(1294 [002441.SZA]), ratio:0.9691357612609863]
[2022-01-14 15:23:54.094178] INFO: algo: handle_splits get splits [dt:2021-07-09 00:00:00+00:00] [asset:Equity(2296 [601222.SHA]), ratio:0.9878934025764465]
[2022-01-14 15:23:54.095205] INFO: Position: position stock handle split[sid:1294, orig_amount:39300, new_amount:40551.0, orig_cost:8.130035237634294, new_cost:7.8791, ratio:0.9691357612609863, last_sale_price:7.849998950958252]
[2022-01-14 15:23:54.096207] INFO: Position: after split: PositionStock(asset:Equity(1294 [002441.SZA]), amount:40551.0, cost_basis:7.8791, last_sale_price:8.09999942779541)
[2022-01-14 15:23:54.097177] INFO: Position: returning cash: 4.6635
[2022-01-14 15:23:54.098158] INFO: Position: position stock handle split[sid:2296, orig_amount:40500, new_amount:40996.0, orig_cost:7.900001661113412, new_cost:7.8044, ratio:0.9878934025764465, last_sale_price:8.159998893737793]
[2022-01-14 15:23:54.099144] INFO: Position: after split: PositionStock(asset:Equity(2296 [601222.SHA]), amount:40996.0, cost_basis:7.8044, last_sale_price:8.25999927520752)
[2022-01-14 15:23:54.100099] INFO: Position: returning cash: 2.6603
[2022-01-14 15:23:54.108350] INFO: algo: handle_splits get splits [dt:2021-07-12 00:00:00+00:00] [asset:Equity(3899 [601088.SHA]), ratio:0.90940922498703]
[2022-01-14 15:23:54.109467] INFO: Position: position stock handle split[sid:3899, orig_amount:16000, new_amount:17593.0, orig_cost:20.300001248510235, new_cost:18.461, ratio:0.90940922498703, last_sale_price:18.16999626159668]
[2022-01-14 15:23:54.110477] INFO: Position: after split: PositionStock(asset:Equity(3899 [601088.SHA]), amount:17593.0, cost_basis:18.461, last_sale_price:19.979999542236328)
[2022-01-14 15:23:54.111438] INFO: Position: returning cash: 15.2548
[2022-01-14 15:23:54.119786] INFO: algo: handle_splits get splits [dt:2021-07-13 00:00:00+00:00] [asset:Equity(3196 [002128.SZA]), ratio:0.9605911374092102]
[2022-01-14 15:23:54.120928] INFO: Position: position stock handle split[sid:3196, orig_amount:30900, new_amount:32167.0, orig_cost:11.897781513691788, new_cost:11.4289, ratio:0.9605911374092102, last_sale_price:9.75]
[2022-01-14 15:23:54.121943] INFO: Position: after split: PositionStock(asset:Equity(3196 [002128.SZA]), amount:32167.0, cost_basis:11.4289, last_sale_price:10.149999618530273)
[2022-01-14 15:23:54.122916] INFO: Position: returning cash: 6.7486
[2022-01-14 15:23:54.142330] INFO: algo: handle_splits get splits [dt:2021-07-16 00:00:00+00:00] [asset:Equity(3277 [000983.SZA]), ratio:0.9876237511634827]
[2022-01-14 15:23:54.143601] INFO: Position: position stock handle split[sid:3277, orig_amount:39300, new_amount:39792.0, orig_cost:7.000000116005202, new_cost:6.9134, ratio:0.9876237511634827, last_sale_price:7.980000019073486]
[2022-01-14 15:23:54.144629] INFO: Position: after split: PositionStock(asset:Equity(3277 [000983.SZA]), amount:39792.0, cost_basis:6.9134, last_sale_price:8.079999923706055)
[2022-01-14 15:23:54.145600] INFO: Position: returning cash: 3.8436
[2022-01-14 15:23:54.159320] INFO: algo: handle_splits get splits [dt:2021-07-20 00:00:00+00:00] [asset:Equity(3183 [600382.SHA]), ratio:0.9773243069648743]
[2022-01-14 15:23:54.160389] INFO: Position: position stock handle split[sid:3183, orig_amount:69100, new_amount:70703.0, orig_cost:4.620010961719229, new_cost:4.5152, ratio:0.9773243069648743, last_sale_price:4.309999942779541]
[2022-01-14 15:23:54.161396] INFO: Position: after split: PositionStock(asset:Equity(3183 [600382.SHA]), amount:70703.0, cost_basis:4.5152, last_sale_price:4.409999847412109)
[2022-01-14 15:23:54.162350] INFO: Position: returning cash: 1.0563
[2022-01-14 15:23:54.181447] INFO: algo: handle_splits get splits [dt:2021-07-23 00:00:00+00:00] [asset:Equity(1396 [600188.SHA]), ratio:0.944444477558136]
[2022-01-14 15:23:54.182472] INFO: Position: position stock handle split[sid:1396, orig_amount:21300, new_amount:22552.0, orig_cost:14.889999662424778, new_cost:14.0628, ratio:0.944444477558136, last_sale_price:17.0]
[2022-01-14 15:23:54.183474] INFO: Position: after split: PositionStock(asset:Equity(1396 [600188.SHA]), amount:22552.0, cost_basis:14.0628, last_sale_price:18.0)
[2022-01-14 15:23:54.184431] INFO: Position: returning cash: 15.9866
[2022-01-14 15:23:55.346912] INFO: Performance: Simulated 248 trading days out of 248.
[2022-01-14 15:23:55.348405] INFO: Performance: first open: 2021-01-04 09:30:00+00:00
[2022-01-14 15:23:55.349516] INFO: Performance: last close: 2022-01-10 15:00:00+00:00
[2022-01-14 15:24:00.440533] INFO: moduleinvoker: backtest.v8 运行完成[18.294443s].
[2022-01-14 15:24:00.442081] INFO: moduleinvoker: trade.v4 运行完成[18.358552s].