复制链接
克隆策略

策略名称

可转债双低策略

策略思路

建仓条件:市场双低值均值低于170可进行建仓。

选择范围:在双低值排位(升序)前30位的可转债中进行筛选。

筛选条件:规模大于1.5亿元;剩余期限大于半年;上市超过1个月。

最终确定:如果数量大于10支,则选择转债价格最低的10支,等权重买入;如果不足10支,则双低排位范围扩大,直凑够10支。

轮动规则: 每月调仓 version 20230419

    {"description":"实验创建于2023/2/10","graph":{"edges":[{"to_node_id":"-161:input_data","from_node_id":"-505:data"},{"to_node_id":"-760:input","from_node_id":"-505:data"},{"to_node_id":"-645:input_1","from_node_id":"-512:data"},{"to_node_id":"-1953:input_1","from_node_id":"-519:data"},{"to_node_id":"-161:features","from_node_id":"-666:data"},{"to_node_id":"-549:input_1","from_node_id":"-161:data"},{"to_node_id":"-7412:instruments","from_node_id":"-760:instrument_list"},{"to_node_id":"-519:data2","from_node_id":"-645:data_1"},{"to_node_id":"-519:data1","from_node_id":"-549:data_1"},{"to_node_id":"-7412:options_data","from_node_id":"-1953:data_1"}],"nodes":[{"node_id":"-505","module_id":"BigQuantSpace.use_datasource.use_datasource-v1","parameters":[{"name":"datasource_id","value":"market_performance_CN_CONBOND","type":"Literal","bound_global_parameter":null},{"name":"start_date","value":"2018-01-01","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2020-12-31","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-505"},{"name":"features","node_id":"-505"}],"output_ports":[{"name":"data","node_id":"-505"}],"cacheable":true,"seq_num":1,"comment":"","comment_collapsed":true},{"node_id":"-512","module_id":"BigQuantSpace.use_datasource.use_datasource-v1","parameters":[{"name":"datasource_id","value":"basic_info_CN_CONBOND","type":"Literal","bound_global_parameter":null},{"name":"start_date","value":"2018-01-01","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2020-12-31","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-512"},{"name":"features","node_id":"-512"}],"output_ports":[{"name":"data","node_id":"-512"}],"cacheable":true,"seq_num":2,"comment":"","comment_collapsed":true},{"node_id":"-519","module_id":"BigQuantSpace.join.join-v3","parameters":[{"name":"on","value":"instrument","type":"Literal","bound_global_parameter":null},{"name":"how","value":"inner","type":"Literal","bound_global_parameter":null},{"name":"sort","value":"False","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"data1","node_id":"-519"},{"name":"data2","node_id":"-519"}],"output_ports":[{"name":"data","node_id":"-519"}],"cacheable":true,"seq_num":3,"comment":"","comment_collapsed":true},{"node_id":"-666","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"\n# #号开始的表示注释,注释需单独一行\n# 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征\ndouble_low = close + bond_prem_ratio\nremain_size > 1.5\n","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features_ds","node_id":"-666"}],"output_ports":[{"name":"data","node_id":"-666"}],"cacheable":true,"seq_num":4,"comment":"","comment_collapsed":true},{"node_id":"-161","module_id":"BigQuantSpace.derived_feature_extractor.derived_feature_extractor-v3","parameters":[{"name":"date_col","value":"date","type":"Literal","bound_global_parameter":null},{"name":"instrument_col","value":"instrument","type":"Literal","bound_global_parameter":null},{"name":"drop_na","value":"False","type":"Literal","bound_global_parameter":null},{"name":"remove_extra_columns","value":"False","type":"Literal","bound_global_parameter":null},{"name":"user_functions","value":"{}","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_data","node_id":"-161"},{"name":"features","node_id":"-161"}],"output_ports":[{"name":"data","node_id":"-161"}],"cacheable":true,"seq_num":5,"comment":"","comment_collapsed":true},{"node_id":"-760","module_id":"BigQuantSpace.trade_data_generation.trade_data_generation-v1","parameters":[{"name":"category","value":"CN_STOCK","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input","node_id":"-760"}],"output_ports":[{"name":"history_data","node_id":"-760"},{"name":"instrument_list","node_id":"-760"},{"name":"calendar","node_id":"-760"}],"cacheable":false,"seq_num":6,"comment":"","comment_collapsed":true},{"node_id":"-7412","module_id":"BigQuantSpace.hftrade.hftrade-v2","parameters":[{"name":"start_date","value":"","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"","type":"Literal","bound_global_parameter":null},{"name":"initialize","value":"# 交易引擎:初始化函数,只执行一次\ndef bigquant_run(context):\n print(\"initializing\")\n # 加载股票指标数据,数据继承自m6模块\n context.indicator_data = context.options['data'].read_df()\n\n # 系统已经设置了默认的交易手续费和滑点,要修改手续费可使用如下函数\n context.set_commission(PerOrder(buy_cost=0.0003, sell_cost=0.0013, min_cost=5))\n \n # 设置股票数量\n context.stock_num = 20\n \n # 调仓天数,22个交易日大概就是一个月。可以理解为一个月换仓一次\n context.rebalance_days = 22\n \n # 如果策略运行中,需要将数据进行保存,可以借用extension这个对象,类型为dict\n # 比如当前运行的k线的索引,比如个股持仓天数、买入均价\n try:\n print(f\"check idx: {context.extension.idx}\")\n except AttributeError as e:\n context.extension.idx = 0\n ","type":"Literal","bound_global_parameter":null},{"name":"before_trading_start","value":"# 交易引擎:每个单位时间开盘前调用一次。\ndef bigquant_run(context, data):\n context.subscribe(context.instruments)\n pass","type":"Literal","bound_global_parameter":null},{"name":"handle_tick","value":"# 交易引擎:tick数据处理函数,每个tick执行一次\ndef bigquant_run(context, data):\n pass\n","type":"Literal","bound_global_parameter":null},{"name":"handle_data","value":"# 回测引擎:每日数据处理函数,每天执行一次\ndef bigquant_run(context, data):\n \n context.extension.idx += 1\n # 不在换仓日就return,相当于后面的代码只会一个月运行一次,买入的股票会持有1个月\n if context.extension.idx % context.rebalance_days != 0:\n return\n \n # 当前的日期\n date = data.current_dt.strftime('%Y-%m-%d')\n cur_data = context.indicator_data[context.indicator_data['date'] == date]\n \n #建仓条件判断:市场双低均值达到170可进行建仓\n if cur_data['double_low'].mean() > 170:\n print(date,':该调仓日市场双低均值为',cur_data['double_low'].mean(),\",无需建仓\")\n return\n \n \n # 设定股票池\n # 条件1:上市超过1个月\n stock_can_buy = cur_data[cur_data['can_buy'] == 1]\n # 条件2:剩余期限小于180个自然日\n stock_to_clean = cur_data[cur_data['to_clean'] == 1]\n \n symbols = list(set(stock_can_buy['instrument'].values).difference(set(stock_to_clean['instrument'].values)))\n cur_data = cur_data.set_index('instrument').loc[symbols,:].reset_index().sort_values('double_low')\n stock_to_buy = list(cur_data.instrument[:context.stock_num])\n \n # 通过positions对象,使用列表生成式的方法获取目前持仓的股票列表\n stock_hold_now = [equity for equity in context.portfolio.positions]\n # 继续持有的股票:调仓时,如果买入的股票已经存在于目前的持仓里,那么应继续持有\n no_need_to_sell = [i for i in stock_hold_now if i in stock_to_buy]\n # 需要卖出的股票\n stock_to_sell = [i for i in stock_hold_now if i not in no_need_to_sell] \n \n # 卖出\n for stock in stock_to_sell:\n context.order_target_percent(stock, 0)\n \n # 如果当天没有买入的股票,就返回\n if len(stock_to_buy) == 0:\n print(date,'当天没有买入的股票')\n return\n\n # 等权重买入 \n weight = 1 / len(stock_to_buy)\n \n # 买入\n for stock in stock_to_buy:\n context.order_target_percent(stock, weight)\n ","type":"Literal","bound_global_parameter":null},{"name":"handle_trade","value":"# 交易引擎:成交回报处理函数,每个成交发生时执行一次\ndef bigquant_run(context, data):\n pass\n","type":"Literal","bound_global_parameter":null},{"name":"handle_order","value":"# 交易引擎:委托回报处理函数,每个委托变化时执行一次\ndef bigquant_run(context, data):\n pass\n","type":"Literal","bound_global_parameter":null},{"name":"after_trading","value":"# 交易引擎:盘后处理函数,每日盘后执行一次\ndef bigquant_run(context, data):\n pass\n","type":"Literal","bound_global_parameter":null},{"name":"capital_base","value":"1000001","type":"Literal","bound_global_parameter":null},{"name":"frequency","value":"daily","type":"Literal","bound_global_parameter":null},{"name":"price_type","value":"真实价格","type":"Literal","bound_global_parameter":null},{"name":"product_type","value":"可转债","type":"Literal","bound_global_parameter":null},{"name":"before_start_days","value":"0","type":"Literal","bound_global_parameter":null},{"name":"volume_limit","value":1,"type":"Literal","bound_global_parameter":null},{"name":"order_price_field_buy","value":"close","type":"Literal","bound_global_parameter":null},{"name":"order_price_field_sell","value":"close","type":"Literal","bound_global_parameter":null},{"name":"benchmark","value":"000300.HIX","type":"Literal","bound_global_parameter":null},{"name":"plot_charts","value":"True","type":"Literal","bound_global_parameter":null},{"name":"disable_cache","value":"False","type":"Literal","bound_global_parameter":null},{"name":"replay_bdb","value":"False","type":"Literal","bound_global_parameter":null},{"name":"show_debug_info","value":"False","type":"Literal","bound_global_parameter":null},{"name":"backtest_only","value":"False","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-7412"},{"name":"options_data","node_id":"-7412"},{"name":"history_ds","node_id":"-7412"},{"name":"benchmark_ds","node_id":"-7412"}],"output_ports":[{"name":"raw_perf","node_id":"-7412"}],"cacheable":false,"seq_num":7,"comment":"","comment_collapsed":true},{"node_id":"-645","module_id":"BigQuantSpace.cached.cached-v3","parameters":[{"name":"run","value":"# Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端\ndef bigquant_run(input_1, input_2, input_3):\n # 示例代码如下。在这里编写您的代码\n df = input_1.read()\n df['list_date'] = df['list_date'].astype(str)\n df['delist_date'] = df['delist_date'].astype(str)\n df = df.loc[:,['instrument','list_date','delist_date']]\n \n data_1 = DataSource.write_df(df)\n return Outputs(data_1=data_1, data_2=None, data_3=None)\n","type":"Literal","bound_global_parameter":null},{"name":"post_run","value":"# 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。\ndef bigquant_run(outputs):\n return outputs\n","type":"Literal","bound_global_parameter":null},{"name":"input_ports","value":"","type":"Literal","bound_global_parameter":null},{"name":"params","value":"{}","type":"Literal","bound_global_parameter":null},{"name":"output_ports","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_1","node_id":"-645"},{"name":"input_2","node_id":"-645"},{"name":"input_3","node_id":"-645"}],"output_ports":[{"name":"data_1","node_id":"-645"},{"name":"data_2","node_id":"-645"},{"name":"data_3","node_id":"-645"}],"cacheable":true,"seq_num":8,"comment":"","comment_collapsed":true},{"node_id":"-549","module_id":"BigQuantSpace.cached.cached-v3","parameters":[{"name":"run","value":"# Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端\ndef bigquant_run(input_1, input_2, input_3):\n # 示例代码如下。在这里编写您的代码\n df = input_1.read()\n \n df = df.loc[:,['date','instrument','close','bond_prem_ratio','double_low','remain_size']]\n \n data_1 = DataSource.write_df(df)\n return Outputs(data_1=data_1, data_2=None, data_3=None)\n","type":"Literal","bound_global_parameter":null},{"name":"post_run","value":"# 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。\ndef bigquant_run(outputs):\n return outputs\n","type":"Literal","bound_global_parameter":null},{"name":"input_ports","value":"","type":"Literal","bound_global_parameter":null},{"name":"params","value":"{}","type":"Literal","bound_global_parameter":null},{"name":"output_ports","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_1","node_id":"-549"},{"name":"input_2","node_id":"-549"},{"name":"input_3","node_id":"-549"}],"output_ports":[{"name":"data_1","node_id":"-549"},{"name":"data_2","node_id":"-549"},{"name":"data_3","node_id":"-549"}],"cacheable":true,"seq_num":9,"comment":"","comment_collapsed":true},{"node_id":"-1953","module_id":"BigQuantSpace.cached.cached-v3","parameters":[{"name":"run","value":"# Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端\ndef bigquant_run(input_1, input_2, input_3):\n # 示例代码如下。在这里编写您的代码\n df = input_1.read()\n \n df['date'] = pd.to_datetime(df['date'])\n df['list_date'] = pd.to_datetime(df['list_date'])\n df['delist_date'] = pd.to_datetime(df['delist_date'])\n \n #买入规则:上市满30天才能买入\n df['can_buy'] = df['date'] > (df['list_date'] + datetime.timedelta(days=30))\n\n #卖出规则:离退市日期差6个月时清仓\n df['to_clean'] = (df['date'] + datetime.timedelta(days=180)) > df['delist_date']\n \n data_1 = DataSource.write_df(df)\n return Outputs(data_1=data_1, data_2=None, data_3=None)\n","type":"Literal","bound_global_parameter":null},{"name":"post_run","value":"# 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。\ndef bigquant_run(outputs):\n return outputs\n","type":"Literal","bound_global_parameter":null},{"name":"input_ports","value":"","type":"Literal","bound_global_parameter":null},{"name":"params","value":"{}","type":"Literal","bound_global_parameter":null},{"name":"output_ports","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_1","node_id":"-1953"},{"name":"input_2","node_id":"-1953"},{"name":"input_3","node_id":"-1953"}],"output_ports":[{"name":"data_1","node_id":"-1953"},{"name":"data_2","node_id":"-1953"},{"name":"data_3","node_id":"-1953"}],"cacheable":true,"seq_num":10,"comment":"","comment_collapsed":true}],"node_layout":"<node_postions><node_position Node='-505' Position='139,-159,200,200'/><node_position Node='-512' Position='623,-44,200,200'/><node_position Node='-519' Position='423,176,200,200'/><node_position Node='-666' Position='445,-164,200,200'/><node_position Node='-161' Position='322,-49,200,200'/><node_position Node='-760' Position='6,48,200,200'/><node_position Node='-7412' Position='361,400,200,200'/><node_position Node='-645' Position='603,50,200,200'/><node_position Node='-549' Position='302,50,200,200'/><node_position Node='-1953' Position='405,279,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
    In [4]:
    # 本代码由可视化策略环境自动生成 2023年5月24日 18:28
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
     
    # 显式导入 BigQuant 相关 SDK 模块
    import datetime
    import pandas as pd
    from bigdatasource.api import DataSource
    from zipline.finance.commission import PerOrder
    from biglearning.api import M
    from biglearning.api import tools as T
    from biglearning.module2.common.data import Outputs
    
    # Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端
    def m8_run_bigquant_run(input_1, input_2, input_3):
        # 示例代码如下。在这里编写您的代码
        df = input_1.read()
        df['list_date'] = df['list_date'].astype(str)
        df['delist_date'] = df['delist_date'].astype(str)
        df = df.loc[:,['instrument','list_date','delist_date']]
        
        data_1 = DataSource.write_df(df)
        return Outputs(data_1=data_1, data_2=None, data_3=None)
    
    # 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。
    def m8_post_run_bigquant_run(outputs):
        return outputs
    
    # Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端
    def m9_run_bigquant_run(input_1, input_2, input_3):
        # 示例代码如下。在这里编写您的代码
        df = input_1.read()
        
        df = df.loc[:,['date','instrument','close','bond_prem_ratio','double_low','remain_size']]
        
        data_1 = DataSource.write_df(df)
        return Outputs(data_1=data_1, data_2=None, data_3=None)
    
    # 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。
    def m9_post_run_bigquant_run(outputs):
        return outputs
    
    # Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端
    def m10_run_bigquant_run(input_1, input_2, input_3):
        # 示例代码如下。在这里编写您的代码
        df = input_1.read()
        
        df['date'] = pd.to_datetime(df['date'])
        df['list_date'] = pd.to_datetime(df['list_date'])
        df['delist_date'] = pd.to_datetime(df['delist_date'])
        
        #买入规则:上市满30天才能买入
        df['can_buy'] = df['date'] > (df['list_date'] + datetime.timedelta(days=30))
    
        #卖出规则:离退市日期差6个月时清仓
        df['to_clean'] = (df['date'] + datetime.timedelta(days=180)) > df['delist_date']
        
        data_1 = DataSource.write_df(df)
        return Outputs(data_1=data_1, data_2=None, data_3=None)
    
    # 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。
    def m10_post_run_bigquant_run(outputs):
        return outputs
    
    # 交易引擎:初始化函数,只执行一次
    def m7_initialize_bigquant_run(context):
        print("initializing")
           # 加载股票指标数据,数据继承自m6模块
        context.indicator_data = context.options['data'].read_df()
    
        # 系统已经设置了默认的交易手续费和滑点,要修改手续费可使用如下函数
        context.set_commission(PerOrder(buy_cost=0.0003, sell_cost=0.0013, min_cost=5))
        
        # 设置股票数量
        context.stock_num = 20
        
        # 调仓天数,22个交易日大概就是一个月。可以理解为一个月换仓一次
        context.rebalance_days = 22
        
        # 如果策略运行中,需要将数据进行保存,可以借用extension这个对象,类型为dict
        # 比如当前运行的k线的索引,比如个股持仓天数、买入均价
        try:
            print(f"check idx: {context.extension.idx}")
        except AttributeError as e:
            context.extension.idx = 0
     
    # 交易引擎:每个单位时间开盘前调用一次。
    def m7_before_trading_start_bigquant_run(context, data):
        context.subscribe(context.instruments)
        pass
    # 交易引擎:tick数据处理函数,每个tick执行一次
    def m7_handle_tick_bigquant_run(context, data):
        pass
    
    # 回测引擎:每日数据处理函数,每天执行一次
    def m7_handle_data_bigquant_run(context, data):
        
        context.extension.idx += 1
        # 不在换仓日就return,相当于后面的代码只会一个月运行一次,买入的股票会持有1个月
        if  context.extension.idx % context.rebalance_days != 0:
            return
        
        # 当前的日期
        date = data.current_dt.strftime('%Y-%m-%d')
        cur_data = context.indicator_data[context.indicator_data['date'] == date]
        
        #建仓条件判断:市场双低均值达到170可进行建仓
        if cur_data['double_low'].mean() > 170:
            print(date,':该调仓日市场双低均值为',cur_data['double_low'].mean(),",无需建仓")
            return
        
        
        # 设定股票池
        # 条件1:上市超过1个月
        stock_can_buy = cur_data[cur_data['can_buy'] == 1]
        # 条件2:剩余期限小于180个自然日
        stock_to_clean = cur_data[cur_data['to_clean'] == 1]
        
        symbols = list(set(stock_can_buy['instrument'].values).difference(set(stock_to_clean['instrument'].values)))
        cur_data = cur_data.set_index('instrument').loc[symbols,:].reset_index().sort_values('double_low')
        stock_to_buy = list(cur_data.instrument[:context.stock_num])
       
        # 通过positions对象,使用列表生成式的方法获取目前持仓的股票列表
        stock_hold_now = [equity 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:
            context.order_target_percent(stock, 0)
        
        # 如果当天没有买入的股票,就返回
        if len(stock_to_buy) == 0:
            print(date,'当天没有买入的股票')
            return
    
        # 等权重买入 
        weight =  1 / len(stock_to_buy)
        
        # 买入
        for stock in stock_to_buy:
            context.order_target_percent(stock, weight)
     
    # 交易引擎:成交回报处理函数,每个成交发生时执行一次
    def m7_handle_trade_bigquant_run(context, data):
        pass
    
    # 交易引擎:委托回报处理函数,每个委托变化时执行一次
    def m7_handle_order_bigquant_run(context, data):
        pass
    
    # 交易引擎:盘后处理函数,每日盘后执行一次
    def m7_after_trading_bigquant_run(context, data):
        pass
    
    
    m1 = M.use_datasource.v1(
        datasource_id='market_performance_CN_CONBOND',
        start_date='2018-01-01',
        end_date='2020-12-31'
    )
    
    m6 = M.trade_data_generation.v1(
        input=m1.data,
        category='CN_STOCK',
        m_cached=False
    )
    
    m2 = M.use_datasource.v1(
        datasource_id='basic_info_CN_CONBOND',
        start_date='2018-01-01',
        end_date='2020-12-31'
    )
    
    m8 = M.cached.v3(
        input_1=m2.data,
        run=m8_run_bigquant_run,
        post_run=m8_post_run_bigquant_run,
        input_ports='',
        params='{}',
        output_ports=''
    )
    
    m4 = M.input_features.v1(
        features="""
    # #号开始的表示注释,注释需单独一行
    # 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征
    double_low = close + bond_prem_ratio
    remain_size > 1.5
    """
    )
    
    m5 = M.derived_feature_extractor.v3(
        input_data=m1.data,
        features=m4.data,
        date_col='date',
        instrument_col='instrument',
        drop_na=False,
        remove_extra_columns=False,
        user_functions={}
    )
    
    m9 = M.cached.v3(
        input_1=m5.data,
        run=m9_run_bigquant_run,
        post_run=m9_post_run_bigquant_run,
        input_ports='',
        params='{}',
        output_ports=''
    )
    
    m3 = M.join.v3(
        data1=m9.data_1,
        data2=m8.data_1,
        on='instrument',
        how='inner',
        sort=False
    )
    
    m10 = M.cached.v3(
        input_1=m3.data,
        run=m10_run_bigquant_run,
        post_run=m10_post_run_bigquant_run,
        input_ports='',
        params='{}',
        output_ports=''
    )
    
    m7 = M.hftrade.v2(
        instruments=m6.instrument_list,
        options_data=m10.data_1,
        start_date='',
        end_date='',
        initialize=m7_initialize_bigquant_run,
        before_trading_start=m7_before_trading_start_bigquant_run,
        handle_tick=m7_handle_tick_bigquant_run,
        handle_data=m7_handle_data_bigquant_run,
        handle_trade=m7_handle_trade_bigquant_run,
        handle_order=m7_handle_order_bigquant_run,
        after_trading=m7_after_trading_bigquant_run,
        capital_base=1000001,
        frequency='daily',
        price_type='真实价格',
        product_type='可转债',
        before_start_days='0',
        volume_limit=1,
        order_price_field_buy='close',
        order_price_field_sell='close',
        benchmark='000300.HIX',
        plot_charts=True,
        disable_cache=False,
        replay_bdb=False,
        show_debug_info=False,
        backtest_only=False
    )
    
    [2023-05-24 18:29:15.181265] INFO moduleinvoker: use_datasource.v1 开始运行..
    [2023-05-24 18:29:15.186877] INFO moduleinvoker: 命中缓存
    [2023-05-24 18:29:15.188429] INFO moduleinvoker: use_datasource.v1 运行完成[0.007216s].
    [2023-05-24 18:29:15.198955] INFO moduleinvoker: trade_data_generation.v1 开始运行..
    [2023-05-24 18:29:16.887663] INFO moduleinvoker: trade_data_generation.v1 运行完成[1.688636s].
    [2023-05-24 18:29:16.896052] INFO moduleinvoker: use_datasource.v1 开始运行..
    [2023-05-24 18:29:16.902982] INFO moduleinvoker: 命中缓存
    [2023-05-24 18:29:16.904568] INFO moduleinvoker: use_datasource.v1 运行完成[0.008536s].
    [2023-05-24 18:29:16.924144] INFO moduleinvoker: cached.v3 开始运行..
    [2023-05-24 18:29:16.930098] INFO moduleinvoker: 命中缓存
    [2023-05-24 18:29:16.931703] INFO moduleinvoker: cached.v3 运行完成[0.0076s].
    [2023-05-24 18:29:16.936875] INFO moduleinvoker: input_features.v1 开始运行..
    [2023-05-24 18:29:16.942212] INFO moduleinvoker: 命中缓存
    [2023-05-24 18:29:16.943893] INFO moduleinvoker: input_features.v1 运行完成[0.007039s].
    [2023-05-24 18:29:16.956891] INFO moduleinvoker: derived_feature_extractor.v3 开始运行..
    [2023-05-24 18:29:16.962102] INFO moduleinvoker: 命中缓存
    [2023-05-24 18:29:16.964207] INFO moduleinvoker: derived_feature_extractor.v3 运行完成[0.007361s].
    [2023-05-24 18:29:16.977156] INFO moduleinvoker: cached.v3 开始运行..
    [2023-05-24 18:29:16.987667] INFO moduleinvoker: 命中缓存
    [2023-05-24 18:29:16.989301] INFO moduleinvoker: cached.v3 运行完成[0.012178s].
    [2023-05-24 18:29:17.000334] INFO moduleinvoker: join.v3 开始运行..
    [2023-05-24 18:29:17.006278] INFO moduleinvoker: 命中缓存
    [2023-05-24 18:29:17.008191] INFO moduleinvoker: join.v3 运行完成[0.007869s].
    [2023-05-24 18:29:17.021609] INFO moduleinvoker: cached.v3 开始运行..
    [2023-05-24 18:29:17.028136] INFO moduleinvoker: 命中缓存
    [2023-05-24 18:29:17.029640] INFO moduleinvoker: cached.v3 运行完成[0.00805s].
    [2023-05-24 18:29:17.053817] INFO moduleinvoker: hfbacktest.v1 开始运行..
    [2023-05-24 18:29:17.057654] INFO hfbacktest: biglearning V1.4.21
    [2023-05-24 18:29:17.059095] INFO hfbacktest: bigtrader v1.10.2 2023-05-18
    [2023-05-24 18:29:17.074195] INFO moduleinvoker: cached.v2 开始运行..
    [2023-05-24 18:29:17.079298] INFO moduleinvoker: 命中缓存
    [2023-05-24 18:29:17.080666] INFO moduleinvoker: cached.v2 运行完成[0.006478s].
    [2023-05-24 18:29:17.351430] INFO moduleinvoker: cached.v2 开始运行..
    [2023-05-24 18:29:17.357949] INFO moduleinvoker: 命中缓存
    [2023-05-24 18:29:17.360752] INFO moduleinvoker: cached.v2 运行完成[0.009342s].
    initializing
    
    /usr/local/python3/lib/python3.8/site-packages/empyrical/stats.py:710: RuntimeWarning: divide by zero encountered in divide
      np.divide(
    /usr/local/python3/lib/python3.8/site-packages/empyrical/stats.py:799: RuntimeWarning: invalid value encountered in divide
      np.divide(average_annual_return, annualized_downside_risk, out=out)
    /usr/local/python3/lib/python3.8/site-packages/pandas/core/generic.py:2605: PerformanceWarning: 
    your performance may suffer as PyTables will pickle object types that it cannot
    map directly to c-types [inferred_type->mixed,key->block3_values] [items->Index(['orders', 'transactions', 'positions', 'POS_FAC', 'TRA_FAC', 'LOG'], dtype='object')]
    
      pytables.to_hdf(
    
    [2023-05-24 18:29:48.576407] INFO hfbacktest: backtest done, raw_perf_ds:DataSource(b1b65011c15a4a228edaddc8be3eeff2T)
    
    /usr/local/python3/lib/python3.8/site-packages/pandas/core/indexing.py:1637: SettingWithCopyWarning: 
    A value is trying to be set on a copy of a slice from a DataFrame
    
    See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
      self._setitem_single_block(indexer, value, name)
    [2023-05-24 18:29:53.958569] INFO: bigcharts.impl.render:render.py:407:render_chart Data is None, skip loading it to chart.
    
    • 收益率36.93%
    • 年化收益率10.98%
    • 基准收益率27.5%
    • 阿尔法0.06
    • 贝塔0.38
    • 夏普比率0.67
    • 胜率0.55
    • 盈亏比2.56
    • 收益波动率12.96%
    • 信息比率0.0
    • 最大回撤14.77%
    日期 时间 股票代码 股票名称 买/卖 数量 成交价 总成本 交易佣金
    Loading... (need help?)
    日期 标的代码 标的名称 持仓均价 收盘价 数量 持仓价值 收益
    Loading... (need help?)
    时间 级别 内容
    Loading... (need help?)
    [2023-05-24 18:29:59.653334] INFO moduleinvoker: hfbacktest.v1 运行完成[42.599457s].
    
    INFO:moduleinvoker:hfbacktest.v1 运行完成[42.599457s].
    
    [2023-05-24 18:29:59.658044] INFO moduleinvoker: hftrade.v2 运行完成[42.620044s].
    
    INFO:moduleinvoker:hftrade.v2 运行完成[42.620044s].