复制链接
克隆策略

    {"description":"实验创建于7/5/2021","graph":{"edges":[{"to_node_id":"-374:input","from_node_id":"-824:data"},{"to_node_id":"-1639:options_data","from_node_id":"-824:data"},{"to_node_id":"-1639:instruments","from_node_id":"-374:instrument_list"}],"nodes":[{"node_id":"-824","module_id":"BigQuantSpace.use_datasource.use_datasource-v2","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":"2022-11-30","type":"Literal","bound_global_parameter":null},{"name":"before_start_days","value":"0","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-824"},{"name":"features","node_id":"-824"}],"output_ports":[{"name":"data","node_id":"-824"}],"cacheable":true,"seq_num":13,"comment":"","comment_collapsed":true},{"node_id":"-1639","module_id":"BigQuantSpace.hftrade.hftrade-v2","parameters":[{"name":"start_date","value":"2018-01-01","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2022-11-30","type":"Literal","bound_global_parameter":null},{"name":"initialize","value":"# 交易引擎:初始化函数,只执行一次\ndef bigquant_run(context):\n # 加载预测数据\n pass\n","type":"Literal","bound_global_parameter":null},{"name":"before_trading_start","value":"# 交易引擎:每个单位时间开盘前调用一次。\ndef bigquant_run(context, data):\n # 盘前处理,订阅行情等\n pass\n","type":"Literal","bound_global_parameter":null},{"name":"handle_tick","value":"# 交易引擎:tick数据处理函数,每个tick执行一次\ndef bigquant_run(context, tick):\n pass\n","type":"Literal","bound_global_parameter":null},{"name":"handle_data","value":"# 交易引擎:bar数据处理函数,每个时间单位执行一次\ndef bigquant_run(context, data):\n pass\n","type":"Literal","bound_global_parameter":null},{"name":"handle_trade","value":"# 交易引擎:成交回报处理函数,每个成交发生时执行一次\ndef bigquant_run(context, trade):\n pass\n","type":"Literal","bound_global_parameter":null},{"name":"handle_order","value":"# 交易引擎:委托回报处理函数,每个委托变化时执行一次\ndef bigquant_run(context, order):\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":1000000,"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":"180","type":"Literal","bound_global_parameter":null},{"name":"volume_limit","value":1,"type":"Literal","bound_global_parameter":null},{"name":"order_price_field_buy","value":"open","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":"-1639"},{"name":"options_data","node_id":"-1639"},{"name":"history_ds","node_id":"-1639"},{"name":"benchmark_ds","node_id":"-1639"}],"output_ports":[{"name":"raw_perf","node_id":"-1639"}],"cacheable":false,"seq_num":1,"comment":"","comment_collapsed":true},{"node_id":"-374","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":"-374"}],"output_ports":[{"name":"history_data","node_id":"-374"},{"name":"instrument_list","node_id":"-374"},{"name":"calendar","node_id":"-374"}],"cacheable":true,"seq_num":6,"comment":"","comment_collapsed":true}],"node_layout":"<node_postions><node_position Node='-824' Position='46.99995422363281,-205,200,200'/><node_position Node='-1639' Position='317.384033203125,126.3934326171875,200,200'/><node_position Node='-374' Position='51,-42,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
    In [21]:
    # 本代码由可视化策略环境自动生成 2022年12月13日 15:47
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    # 交易引擎:初始化函数,只执行一次
    def m1_initialize_bigquant_run(context):
        # 加载预测数据
        pass
    
    # 交易引擎:每个单位时间开盘前调用一次。
    def m1_before_trading_start_bigquant_run(context, data):
        # 盘前处理,订阅行情等
        pass
    
    # 交易引擎:tick数据处理函数,每个tick执行一次
    def m1_handle_tick_bigquant_run(context, tick):
        pass
    
    # 交易引擎:bar数据处理函数,每个时间单位执行一次
    def m1_handle_data_bigquant_run(context, data):
        pass
    
    # 交易引擎:成交回报处理函数,每个成交发生时执行一次
    def m1_handle_trade_bigquant_run(context, trade):
        pass
    
    # 交易引擎:委托回报处理函数,每个委托变化时执行一次
    def m1_handle_order_bigquant_run(context, order):
        pass
    
    # 交易引擎:盘后处理函数,每日盘后执行一次
    def m1_after_trading_bigquant_run(context, data):
        pass
    
    
    m13 = M.use_datasource.v2(
        datasource_id='market_performance_CN_CONBOND',
        start_date='2018-01-01',
        end_date='2022-11-30',
        before_start_days=0
    )
    
    m6 = M.trade_data_generation.v1(
        input=m13.data,
        category='CN_STOCK'
    )
    
    m1 = M.hftrade.v2(
        instruments=m6.instrument_list,
        options_data=m13.data,
        start_date='2018-01-01',
        end_date='2022-11-30',
        initialize=m1_initialize_bigquant_run,
        before_trading_start=m1_before_trading_start_bigquant_run,
        handle_tick=m1_handle_tick_bigquant_run,
        handle_data=m1_handle_data_bigquant_run,
        handle_trade=m1_handle_trade_bigquant_run,
        handle_order=m1_handle_order_bigquant_run,
        after_trading=m1_after_trading_bigquant_run,
        capital_base=1000000,
        frequency='daily',
        price_type='真实价格',
        product_type='可转债',
        before_start_days='180',
        volume_limit=1,
        order_price_field_buy='open',
        order_price_field_sell='close',
        benchmark='000300.HIX',
        plot_charts=True,
        disable_cache=False,
        replay_bdb=False,
        show_debug_info=False,
        backtest_only=False
    )
    
    ---------------------------------------------------------------------------
    AttributeError                            Traceback (most recent call last)
    <ipython-input-21-ff797519c5f7> in <module>
         46 )
         47 
    ---> 48 m1 = M.hftrade.v2(
         49     instruments=m6.instrument_list,
         50     options_data=m13.data,
    
    AttributeError: 'BigQuantModule' object has no attribute '_basic_info_ds'