复制链接
克隆策略

    {"description":"实验创建于2022/5/20","graph":{"edges":[{"to_node_id":"-866:instruments","from_node_id":"-855:data"}],"nodes":[{"node_id":"-855","module_id":"BigQuantSpace.instruments.instruments-v2","parameters":[{"name":"start_date","value":"2022-03-01","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2022-03-05","type":"Literal","bound_global_parameter":null},{"name":"market","value":"CN_STOCK_A","type":"Literal","bound_global_parameter":null},{"name":"instrument_list","value":"000001.SZA","type":"Literal","bound_global_parameter":null},{"name":"max_count","value":0,"type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"rolling_conf","node_id":"-855"}],"output_ports":[{"name":"data","node_id":"-855"}],"cacheable":true,"seq_num":1,"comment":"","comment_collapsed":true},{"node_id":"-866","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 # 加载预测数据\n context.ins = context.instruments[0]\n","type":"Literal","bound_global_parameter":null},{"name":"before_trading_start","value":"# 交易引擎:每个单位时间开盘前调用一次。\ndef bigquant_run(context, data):\n # 盘前处理,订阅行情等\n context.subscribe(context.ins)\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# print(data.current_dt.strftime(\"%H:%M\"))\n if data.current_dt.strftime(\"%H:%M\") == \"14:50\":\n price = data.current(context.ins, \"close\")\n context.order(context.ins, 100, price, order_type=OrderType.LIMIT)\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":"minute","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":"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":"-866"},{"name":"options_data","node_id":"-866"},{"name":"history_ds","node_id":"-866"},{"name":"benchmark_ds","node_id":"-866"}],"output_ports":[{"name":"raw_perf","node_id":"-866"}],"cacheable":false,"seq_num":2,"comment":"","comment_collapsed":true}],"node_layout":"<node_postions><node_position Node='-855' Position='437,215,200,200'/><node_position Node='-866' Position='397,334,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
    In [11]:
    # 本代码由可视化策略环境自动生成 2022年5月20日 18:35
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    # 交易引擎:初始化函数,只执行一次
    def m2_initialize_bigquant_run(context):
        # 加载预测数据
        context.ins = context.instruments[0]
    
    # 交易引擎:每个单位时间开盘前调用一次。
    def m2_before_trading_start_bigquant_run(context, data):
        # 盘前处理,订阅行情等
        context.subscribe(context.ins)
    
    # 交易引擎:tick数据处理函数,每个tick执行一次
    def m2_handle_tick_bigquant_run(context, tick):
        pass
    
    # 交易引擎:bar数据处理函数,每个时间单位执行一次
    def m2_handle_data_bigquant_run(context, data):
    #     print(data.current_dt.strftime("%H:%M"))
        if data.current_dt.strftime("%H:%M") == "14:50":
            price = data.current(context.ins, "close")
            context.order(context.ins, 100, price, order_type=OrderType.LIMIT)
    
    # 交易引擎:成交回报处理函数,每个成交发生时执行一次
    def m2_handle_trade_bigquant_run(context, trade):
        pass
    
    # 交易引擎:委托回报处理函数,每个委托变化时执行一次
    def m2_handle_order_bigquant_run(context, order):
        pass
    
    # 交易引擎:盘后处理函数,每日盘后执行一次
    def m2_after_trading_bigquant_run(context, data):
        pass
    
    
    m1 = M.instruments.v2(
        start_date='2022-03-01',
        end_date='2022-03-05',
        market='CN_STOCK_A',
        instrument_list='000001.SZA',
        max_count=0
    )
    
    m2 = M.hftrade.v2(
        instruments=m1.data,
        start_date='',
        end_date='',
        initialize=m2_initialize_bigquant_run,
        before_trading_start=m2_before_trading_start_bigquant_run,
        handle_tick=m2_handle_tick_bigquant_run,
        handle_data=m2_handle_data_bigquant_run,
        handle_trade=m2_handle_trade_bigquant_run,
        handle_order=m2_handle_order_bigquant_run,
        after_trading=m2_after_trading_bigquant_run,
        capital_base=1000000,
        frequency='minute',
        price_type='真实价格',
        product_type='股票',
        before_start_days='0',
        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
    )
    
    • 收益率-0.01%
    • 年化收益率nan%
    • 基准收益率-2.67%
    • 阿尔法-0.03
    • 贝塔0.0
    • 夏普比率-116.98
    • 胜率0.0
    • 盈亏比0.0
    • 收益波动率0.03%
    • 信息比率0.52
    • 最大回撤0.01%
    bigcharts-data-start/{"__type":"tabs","__id":"bigchart-b33f02d1b9374fd684146318a1a3abff"}/bigcharts-data-end