复制链接
克隆策略

    {"description":"实验创建于2017/8/26","graph":{"edges":[{"to_node_id":"-52:features","from_node_id":"-331:data"},{"to_node_id":"-52:instruments","from_node_id":"-312:data"},{"to_node_id":"-783:input_1","from_node_id":"-52:data"},{"to_node_id":"-41:features","from_node_id":"-64:data"},{"to_node_id":"-783:input_2","from_node_id":"-64:data"},{"to_node_id":"-52:user_functions","from_node_id":"-726:functions"},{"to_node_id":"-41:user_factor_data","from_node_id":"-783:data_1"}],"nodes":[{"node_id":"-331","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"#_amt = amount\n#_ret = ret_sim(close, open)\n#big_order_ret = np.prod(1 + _ret*where(_amt >= _amt.sort_values(ascending=False).iloc[np.int(240*0.4-1)], 1, 0))\n#######财务因子##########\n# 净资产收益率\nfs_roe_0\t\n# 企业自由现金流\nfs_free_cash_flow_0\t\n# 每股收益\nfs_eps_0\t\n# 归属母公司股东净利润季度环比增长率\nfs_net_profit_qoq_0\t\nclose_0*avg_turn_0+close_1*avg_turn_1+close_2*avg_turn_2\n\n#######估值因子##########\n# 动态市盈率\npe_ttm_0\t\n# 市值\nmarket_cap_0\n\n#######股东因子##########\n# 户均持股比例\nsh_holder_avg_pct_0\t\t\n\n\navg_amount_0/avg_amount_20\n\nrank(sum(amount_0*sign(max(open_0+close_0-high_0-low_0,close_0-open_0)/max(high_0-close_1,high_0-low_0,close_1-low_0)-0.1),20))\n\n#######Beta值因子##########\t\n# 上证50\nbeta_sse50_5_0\n# 上证综指\nbeta_szzs_5_0\t\n\nreturn_20\n\nrank_return_20\n\nrank_avg_amount_20\n\n\n","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features_ds","node_id":"-331"}],"output_ports":[{"name":"data","node_id":"-331"}],"cacheable":true,"seq_num":1,"comment":"","comment_collapsed":true},{"node_id":"-312","module_id":"BigQuantSpace.instruments.instruments-v2","parameters":[{"name":"start_date","value":"2021-01-01","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2022-12-31","type":"Literal","bound_global_parameter":null},{"name":"market","value":"CN_STOCK_A","type":"Literal","bound_global_parameter":null},{"name":"instrument_list","value":"","type":"Literal","bound_global_parameter":null},{"name":"max_count","value":0,"type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"rolling_conf","node_id":"-312"}],"output_ports":[{"name":"data","node_id":"-312"}],"cacheable":true,"seq_num":2,"comment":"","comment_collapsed":true},{"node_id":"-52","module_id":"BigQuantSpace.feature_extractor_1m.feature_extractor_1m-v2","parameters":[{"name":"start_date","value":"2021-01-01","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2022-12-31","type":"Literal","bound_global_parameter":null},{"name":"before_start_days","value":"20","type":"Literal","bound_global_parameter":null},{"name":"workers","value":"20","type":"Literal","bound_global_parameter":null},{"name":"parallel_mode","value":"集群","type":"Literal","bound_global_parameter":null},{"name":"table_1m","value":"level2_bar1m_CN_STOCK_A","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-52"},{"name":"features","node_id":"-52"},{"name":"user_functions","node_id":"-52"}],"output_ports":[{"name":"data","node_id":"-52"}],"cacheable":true,"seq_num":7,"comment":"V2","comment_collapsed":true},{"node_id":"-41","module_id":"BigQuantSpace.factorlens.factorlens-v1","parameters":[{"name":"title","value":"因子分析: {factor_name}","type":"Literal","bound_global_parameter":null},{"name":"start_date","value":"2021-01-01","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2022-12-31","type":"Literal","bound_global_parameter":null},{"name":"rebalance_period","value":"2","type":"Literal","bound_global_parameter":null},{"name":"delay_rebalance_days","value":0,"type":"Literal","bound_global_parameter":null},{"name":"rebalance_price","value":"close_0","type":"Literal","bound_global_parameter":null},{"name":"stock_pool","value":"全市场","type":"Literal","bound_global_parameter":null},{"name":"quantile_count","value":"10","type":"Literal","bound_global_parameter":null},{"name":"commission_rate","value":"0.0002","type":"Literal","bound_global_parameter":null},{"name":"returns_calculation_method","value":"累乘","type":"Literal","bound_global_parameter":null},{"name":"benchmark","value":"沪深300","type":"Literal","bound_global_parameter":null},{"name":"drop_new_stocks","value":60,"type":"Literal","bound_global_parameter":null},{"name":"drop_price_limit_stocks","value":"True","type":"Literal","bound_global_parameter":null},{"name":"drop_st_stocks","value":"True","type":"Literal","bound_global_parameter":null},{"name":"drop_suspended_stocks","value":"True","type":"Literal","bound_global_parameter":null},{"name":"normalization","value":"True","type":"Literal","bound_global_parameter":null},{"name":"neutralization","value":"%7B%22enumItems%22%3A%5B%7B%22value%22%3A%22%E8%A1%8C%E4%B8%9A%22%2C%22displayValue%22%3A%22%E8%A1%8C%E4%B8%9A%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E5%B8%82%E5%80%BC%22%2C%22displayValue%22%3A%22%E5%B8%82%E5%80%BC%22%2C%22selected%22%3Afalse%7D%5D%7D","type":"Literal","bound_global_parameter":null},{"name":"metrics","value":"%7B%22enumItems%22%3A%5B%7B%22value%22%3A%22%E5%9B%A0%E5%AD%90%E8%A1%A8%E7%8E%B0%E6%A6%82%E8%A7%88%22%2C%22displayValue%22%3A%22%E5%9B%A0%E5%AD%90%E8%A1%A8%E7%8E%B0%E6%A6%82%E8%A7%88%22%2C%22selected%22%3Atrue%7D%2C%7B%22value%22%3A%22%E5%9B%A0%E5%AD%90%E5%88%86%E5%B8%83%22%2C%22displayValue%22%3A%22%E5%9B%A0%E5%AD%90%E5%88%86%E5%B8%83%22%2C%22selected%22%3Atrue%7D%2C%7B%22value%22%3A%22%E5%9B%A0%E5%AD%90%E8%A1%8C%E4%B8%9A%E5%88%86%E5%B8%83%22%2C%22displayValue%22%3A%22%E5%9B%A0%E5%AD%90%E8%A1%8C%E4%B8%9A%E5%88%86%E5%B8%83%22%2C%22selected%22%3Atrue%7D%2C%7B%22value%22%3A%22%E5%9B%A0%E5%AD%90%E5%B8%82%E5%80%BC%E5%88%86%E5%B8%83%22%2C%22displayValue%22%3A%22%E5%9B%A0%E5%AD%90%E5%B8%82%E5%80%BC%E5%88%86%E5%B8%83%22%2C%22selected%22%3Atrue%7D%2C%7B%22value%22%3A%22IC%E5%88%86%E6%9E%90%22%2C%22displayValue%22%3A%22IC%E5%88%86%E6%9E%90%22%2C%22selected%22%3Atrue%7D%2C%7B%22value%22%3A%22%E4%B9%B0%E5%85%A5%E4%BF%A1%E5%8F%B7%E9%87%8D%E5%90%88%E5%88%86%E6%9E%90%22%2C%22displayValue%22%3A%22%E4%B9%B0%E5%85%A5%E4%BF%A1%E5%8F%B7%E9%87%8D%E5%90%88%E5%88%86%E6%9E%90%22%2C%22selected%22%3Atrue%7D%2C%7B%22value%22%3A%22%E5%9B%A0%E5%AD%90%E4%BC%B0%E5%80%BC%E5%88%86%E6%9E%90%22%2C%22displayValue%22%3A%22%E5%9B%A0%E5%AD%90%E4%BC%B0%E5%80%BC%E5%88%86%E6%9E%90%22%2C%22selected%22%3Atrue%7D%2C%7B%22value%22%3A%22%E5%9B%A0%E5%AD%90%E6%8B%A5%E6%8C%A4%E5%BA%A6%E5%88%86%E6%9E%90%22%2C%22displayValue%22%3A%22%E5%9B%A0%E5%AD%90%E6%8B%A5%E6%8C%A4%E5%BA%A6%E5%88%86%E6%9E%90%22%2C%22selected%22%3Atrue%7D%2C%7B%22value%22%3A%22%E5%9B%A0%E5%AD%90%E5%80%BC%E6%9C%80%E5%A4%A7%2F%E6%9C%80%E5%B0%8F%E8%82%A1%E7%A5%A8%22%2C%22displayValue%22%3A%22%E5%9B%A0%E5%AD%90%E5%80%BC%E6%9C%80%E5%A4%A7%2F%E6%9C%80%E5%B0%8F%E8%82%A1%E7%A5%A8%22%2C%22selected%22%3Atrue%7D%2C%7B%22value%22%3A%22%E8%A1%A8%E8%BE%BE%E5%BC%8F%E5%9B%A0%E5%AD%90%E5%80%BC%22%2C%22displayValue%22%3A%22%E8%A1%A8%E8%BE%BE%E5%BC%8F%E5%9B%A0%E5%AD%90%E5%80%BC%22%2C%22selected%22%3Atrue%7D%2C%7B%22value%22%3A%22%E5%A4%9A%E5%9B%A0%E5%AD%90%E7%9B%B8%E5%85%B3%E6%80%A7%E5%88%86%E6%9E%90%22%2C%22displayValue%22%3A%22%E5%A4%9A%E5%9B%A0%E5%AD%90%E7%9B%B8%E5%85%B3%E6%80%A7%E5%88%86%E6%9E%90%22%2C%22selected%22%3Atrue%7D%5D%7D","type":"Literal","bound_global_parameter":null},{"name":"factor_coverage","value":0.5,"type":"Literal","bound_global_parameter":null},{"name":"user_data_merge","value":"inner","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features","node_id":"-41"},{"name":"user_factor_data","node_id":"-41"}],"output_ports":[{"name":"data","node_id":"-41"}],"cacheable":true,"seq_num":8,"comment":"","comment_collapsed":true},{"node_id":"-64","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"big_order_ret","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features_ds","node_id":"-64"}],"output_ports":[{"name":"data","node_id":"-64"}],"cacheable":false,"seq_num":9,"comment":"","comment_collapsed":true},{"node_id":"-726","module_id":"BigQuantSpace.feature_extractor_user_function.feature_extractor_user_function-v1","parameters":[{"name":"name","value":"ret_sim","type":"Literal","bound_global_parameter":null},{"name":"func","value":"def bigquant_run(df, close, op):\n res = close.pct_change()\n res.iloc[0] = close.iloc[0] / op.iloc[0] - 1\n return res\n","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_functions","node_id":"-726"}],"output_ports":[{"name":"functions","node_id":"-726"}],"cacheable":false,"seq_num":4,"comment":"","comment_collapsed":true},{"node_id":"-783","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 print(input_1)\n print(input_2)\n df = input_1.read() \n f = input_2.read()[0]\n df[f] = df[f] * -1\n data_1 = DataSource.write_df(df)\n return Outputs(data_1=data_1)","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":"-783"},{"name":"input_2","node_id":"-783"},{"name":"input_3","node_id":"-783"}],"output_ports":[{"name":"data_1","node_id":"-783"},{"name":"data_2","node_id":"-783"},{"name":"data_3","node_id":"-783"}],"cacheable":true,"seq_num":5,"comment":"因子值越大越好","comment_collapsed":false}],"node_layout":"<node_postions><node_position Node='-331' Position='-544,-760,200,200'/><node_position Node='-312' Position='-870,-649,200,200'/><node_position Node='-52' Position='-552,-556,200,200'/><node_position Node='-41' Position='-546,-134,200,200'/><node_position Node='-64' Position='-223,-484,200,200'/><node_position Node='-726' Position='-212,-663,200,200'/><node_position Node='-783' Position='-525,-324,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
    In [ ]:
    # 本代码由可视化策略环境自动生成 2023年1月2日 15:09
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    def m4_func_bigquant_run(df, close, op):
        res = close.pct_change()
        res.iloc[0] = close.iloc[0] / op.iloc[0] - 1
        return res
    
    # Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端
    def m5_run_bigquant_run(input_1, input_2, input_3):
        # 示例代码如下。在这里编写您的代码
        print(input_1)
        print(input_2)
        df = input_1.read() 
        f = input_2.read()[0]
        df[f] = df[f] * -1
        data_1 = DataSource.write_df(df)
        return Outputs(data_1=data_1)
    # 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。
    def m5_post_run_bigquant_run(outputs):
        return outputs
    
    
    m1 = M.input_features.v1(
        features="""#_amt = amount
    #_ret = ret_sim(close, open)
    #big_order_ret = np.prod(1 + _ret*where(_amt >= _amt.sort_values(ascending=False).iloc[np.int(240*0.4-1)], 1, 0))
    #######财务因子##########
    # 净资产收益率
    fs_roe_0	
    # 企业自由现金流
    fs_free_cash_flow_0	
    # 每股收益
    fs_eps_0	
    # 归属母公司股东净利润季度环比增长率
    fs_net_profit_qoq_0	
    close_0*avg_turn_0+close_1*avg_turn_1+close_2*avg_turn_2
    
    #######估值因子##########
    # 动态市盈率
    pe_ttm_0	
    # 市值
    market_cap_0
    
    #######股东因子##########
    # 户均持股比例
    sh_holder_avg_pct_0		
    
    
    avg_amount_0/avg_amount_20
    
    rank(sum(amount_0*sign(max(open_0+close_0-high_0-low_0,close_0-open_0)/max(high_0-close_1,high_0-low_0,close_1-low_0)-0.1),20))
    
    #######Beta值因子##########	
    # 上证50
    beta_sse50_5_0
    # 上证综指
    beta_szzs_5_0	
    
    return_20
    
    rank_return_20
    
    rank_avg_amount_20
    
    
    """
    )
    
    m2 = M.instruments.v2(
        start_date='2021-01-01',
        end_date='2022-12-31',
        market='CN_STOCK_A',
        instrument_list='',
        max_count=0
    )
    
    m9 = M.input_features.v1(
        features='big_order_ret',
        m_cached=False
    )
    
    m4 = M.feature_extractor_user_function.v1(
        name='ret_sim',
        func=m4_func_bigquant_run
    )
    
    m7 = M.feature_extractor_1m.v2(
        instruments=m2.data,
        features=m1.data,
        user_functions=m4.functions,
        start_date='2021-01-01',
        end_date='2022-12-31',
        before_start_days=20,
        workers=20,
        parallel_mode='集群',
        table_1m='level2_bar1m_CN_STOCK_A'
    )
    
    m5 = M.cached.v3(
        input_1=m7.data,
        input_2=m9.data,
        run=m5_run_bigquant_run,
        post_run=m5_post_run_bigquant_run,
        input_ports='',
        params='{}',
        output_ports=''
    )
    
    m8 = M.factorlens.v1(
        features=m9.data,
        user_factor_data=m5.data_1,
        title='因子分析: {factor_name}',
        start_date='2021-01-01',
        end_date='2022-12-31',
        rebalance_period=2,
        delay_rebalance_days=0,
        rebalance_price='close_0',
        stock_pool='全市场',
        quantile_count=10,
        commission_rate=0.0002,
        returns_calculation_method='累乘',
        benchmark='沪深300',
        drop_new_stocks=60,
        drop_price_limit_stocks=True,
        drop_st_stocks=True,
        drop_suspended_stocks=True,
        normalization=True,
        neutralization=[],
        metrics=['因子表现概览', '因子分布', '因子行业分布', '因子市值分布', 'IC分析', '买入信号重合分析', '因子估值分析', '因子拥挤度分析', '因子值最大/最小股票', '表达式因子值', '多因子相关性分析'],
        factor_coverage=0.5,
        user_data_merge='inner'
    )