复制链接
克隆策略

    {"description":"实验创建于2022/3/30","graph":{"edges":[{"to_node_id":"-1972:instruments","from_node_id":"-184:data"},{"to_node_id":"-1972:features","from_node_id":"-271:data"},{"to_node_id":"-6207:input_1","from_node_id":"-1972:data"},{"to_node_id":"-1123:user_factor_data","from_node_id":"-6207:data_1"},{"to_node_id":"-1123:features","from_node_id":"-804:data"}],"nodes":[{"node_id":"-184","module_id":"BigQuantSpace.instruments.instruments-v2","parameters":[{"name":"start_date","value":"2015-01-01","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2020-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":"-184"}],"output_ports":[{"name":"data","node_id":"-184"}],"cacheable":true,"seq_num":1,"comment":"","comment_collapsed":true},{"node_id":"-271","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"\n# #号开始的表示注释,注释需单独一行\n# 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征\nclose_0","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features_ds","node_id":"-271"}],"output_ports":[{"name":"data","node_id":"-271"}],"cacheable":true,"seq_num":2,"comment":"","comment_collapsed":true},{"node_id":"-1972","module_id":"BigQuantSpace.general_feature_extractor.general_feature_extractor-v7","parameters":[{"name":"start_date","value":"","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"","type":"Literal","bound_global_parameter":null},{"name":"before_start_days","value":90,"type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-1972"},{"name":"features","node_id":"-1972"}],"output_ports":[{"name":"data","node_id":"-1972"}],"cacheable":true,"seq_num":3,"comment":"","comment_collapsed":true},{"node_id":"-6207","module_id":"BigQuantSpace.cached.cached-v3","parameters":[{"name":"run","value":"# Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端\ndef bigquant_run(input_1, count, input_3):\n #读取输入数据\n df = input_1.read_df()\n \n #计算主函数\n new_df = pd.DataFrame()\n for k,v in df.groupby('instrument'):\n group = v.sort_values('date').reset_index(drop=True) #读取每一只股票的区间行情数据\n close = group['close_0'] #提取历史收盘价\n group['factor'] = (close / close.rolling(count).mean()) - 1 #计算因子值\n new_df = pd.concat([new_df, group],ignore_index=True)\n new_df = new_df.loc[:,['date', 'instrument', 'factor']]\n \n #封装结果\n data_1 = DataSource.write_df(new_df)\n return Outputs(data_1=data_1, data_2=None, data_3=None)","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":"{\n 'count': 44,\n}","type":"Literal","bound_global_parameter":null},{"name":"output_ports","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_1","node_id":"-6207"},{"name":"input_2","node_id":"-6207"},{"name":"input_3","node_id":"-6207"}],"output_ports":[{"name":"data_1","node_id":"-6207"},{"name":"data_2","node_id":"-6207"},{"name":"data_3","node_id":"-6207"}],"cacheable":true,"seq_num":4,"comment":"计算因子值","comment_collapsed":false},{"node_id":"-804","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"\n# #号开始的表示注释,注释需单独一行\n# 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征\nfactor\n","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features_ds","node_id":"-804"}],"output_ports":[{"name":"data","node_id":"-804"}],"cacheable":true,"seq_num":5,"comment":"","comment_collapsed":true},{"node_id":"-1123","module_id":"BigQuantSpace.factorlens.factorlens-v2","parameters":[{"name":"title","value":"因子分析: {factor_name}","type":"Literal","bound_global_parameter":null},{"name":"start_date","value":"2015-01-01","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2021-12-31","type":"Literal","bound_global_parameter":null},{"name":"rebalance_period","value":22,"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":"5","type":"Literal","bound_global_parameter":null},{"name":"commission_rate","value":"0","type":"Literal","bound_global_parameter":null},{"name":"returns_calculation_method","value":"累乘","type":"Literal","bound_global_parameter":null},{"name":"benchmark","value":"无","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":"cutoutliers","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":"left","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features","node_id":"-1123"},{"name":"user_factor_data","node_id":"-1123"}],"output_ports":[{"name":"data","node_id":"-1123"},{"name":"save_data","node_id":"-1123"}],"cacheable":true,"seq_num":6,"comment":"","comment_collapsed":true}],"node_layout":"<node_postions><node_position Node='-184' Position='-949,-145,200,200'/><node_position Node='-271' Position='-576,-143,200,200'/><node_position Node='-1972' Position='-785,-29,200,200'/><node_position Node='-6207' Position='-650,75,200,200'/><node_position Node='-804' Position='-1015,89,200,200'/><node_position Node='-1123' Position='-811,224,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
    In [51]:
    # 本代码由可视化策略环境自动生成 2022年3月30日 15:36
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    # Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端
    def m4_run_bigquant_run(input_1, count, input_3):
        #读取输入数据
        df = input_1.read_df()
        
        #计算主函数
        new_df = pd.DataFrame()
        for k,v in df.groupby('instrument'):
            group = v.sort_values('date').reset_index(drop=True)      #读取每一只股票的区间行情数据
            close = group['close_0']        #提取历史收盘价
            group['factor'] = (close / close.rolling(count).mean()) - 1        #计算因子值
            new_df = pd.concat([new_df, group],ignore_index=True)
        new_df = new_df.loc[:,['date', 'instrument', 'factor']]
        
        #封装结果
        data_1 = DataSource.write_df(new_df)
        return Outputs(data_1=data_1, data_2=None, data_3=None)
    # 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。
    def m4_post_run_bigquant_run(outputs):
        return outputs
    
    
    m1 = M.instruments.v2(
        start_date='2015-01-01',
        end_date='2020-12-31',
        market='CN_STOCK_A',
        instrument_list='',
        max_count=0
    )
    
    m2 = M.input_features.v1(
        features="""
    # #号开始的表示注释,注释需单独一行
    # 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征
    close_0"""
    )
    
    m3 = M.general_feature_extractor.v7(
        instruments=m1.data,
        features=m2.data,
        start_date='',
        end_date='',
        before_start_days=90
    )
    
    m4 = M.cached.v3(
        input_1=m3.data,
        run=m4_run_bigquant_run,
        post_run=m4_post_run_bigquant_run,
        input_ports='',
        params="""{
        'count': 44,
    }""",
        output_ports=''
    )
    
    m5 = M.input_features.v1(
        features="""
    # #号开始的表示注释,注释需单独一行
    # 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征
    factor
    """
    )
    
    m6 = M.factorlens.v2(
        features=m5.data,
        user_factor_data=m4.data_1,
        title='因子分析: {factor_name}',
        start_date='2015-01-01',
        end_date='2021-12-31',
        rebalance_period=22,
        delay_rebalance_days=0,
        rebalance_price='close_0',
        stock_pool='全市场',
        quantile_count=5,
        commission_rate=0,
        returns_calculation_method='累乘',
        benchmark='无',
        drop_new_stocks=60,
        drop_price_limit_stocks=True,
        drop_st_stocks=True,
        drop_suspended_stocks=True,
        cutoutliers=True,
        normalization=True,
        neutralization=[],
        metrics=['因子表现概览', '因子分布', '因子行业分布', '因子市值分布', 'IC分析', '买入信号重合分析', '因子估值分析', '因子拥挤度分析', '因子值最大/最小股票', '表达式因子值', '多因子相关性分析'],
        factor_coverage=0.5,
        user_data_merge='left'
    )
    

    因子分析: factor

    { "type": "factor-track", "data": { "exprs": ["factor"], "options": {"BacktestInterval": ["2015-01-01", "2021-12-31"], "Benchmark": "none", "StockPool": "all", "UserDataMerge": "left", "DropSTStocks": 1, "DropPriceLimitStocks": 1, "DropNewStocks": 60, "DropSuspendedStocks": 1, "QuantileCount": 5, "CommissionRates": 0, "Cutoutliers": 1, "Normalization": 1, "Neutralization": "", "DelayRebalanceDays": 0, "RebalancePeriod": 22, "RebalancePeriodsReturns": 0, "RebalancePrice": "close_0", "ReturnsCalculationMethod": "cumprod", "FactorCoverage": 0.5, "_HASH": "93728225e53f68723083386b7f3411c5"} } }

    因子表现概览

      累计收益 近1年收益 近3月收益 近1月收益 近1周收益 昨日收益 最大回撤 盈亏比 胜率 夏普比率 收益波动率
    最小分位 -42.53% -7.21% -11.16% -8.55% 1.18% 1.75% 71.05% 0.88 0.52 -0.27 30.93%
    最大分位 -79.11% -16.33% -7.91% -3.87% 1.03% 1.36% 87.11% 0.84 0.51 -0.89 29.30%
    多空组合 65.80% 4.56% -1.88% -2.46% 0.06% 0.19% 10.80% 1.06 0.54 0.78 6.97%

    基本特征分析

    IC分析

    -0.07

    0.17

    -0.41

    93.94%

    买入信号重合分析

    因子估值分析

    因子拥挤度分析

    因子值最小的20只股票 (2020-12-31)

    股票名称 股票代码 因子值
    仁东控股 002647.SZA -0.6921
    济民医疗 603222.SHA -0.6145
    朗博科技 603655.SHA -0.5238
    苏州龙杰 603332.SHA -0.4516
    *ST圣亚 600593.SHA -0.4262
    实丰文化 002862.SZA -0.4139
    南岭民爆 002096.SZA -0.3875
    *ST数知 300038.SZA -0.3649
    科思科技 688788.SHA -0.3413
    昊志机电 300503.SZA -0.3321
    力盛赛车 002858.SZA -0.3229
    汇纳科技 300609.SZA -0.3210
    每日互动 300766.SZA -0.3186
    南京化纤 600889.SHA -0.3115
    *ST德威 300325.SZA -0.3077
    永和智控 002795.SZA -0.3069
    光莆股份 300632.SZA -0.3050
    荣科科技 300290.SZA -0.3028
    华孚时尚 002042.SZA -0.2997
    惠程科技 002168.SZA -0.2986

    因子值最大的20只股票 (2020-12-31)

    股票名称 股票代码 因子值
    中航重机 600765.SHA 0.3796
    宁波海运 600798.SHA 0.3863
    上机数控 603185.SHA 0.3934
    古越龙山 600059.SHA 0.4127
    华友钴业 603799.SHA 0.4154
    妙可蓝多 600882.SHA 0.4175
    金枫酒业 600616.SHA 0.4211
    东方日升 300118.SZA 0.4272
    老白干酒 600559.SHA 0.4281
    金龙鱼 300999.SZA 0.4659
    晋控电力 000767.SZA 0.4684
    京运通 601908.SHA 0.4685
    丰乐种业 000713.SZA 0.5058
    西部材料 002149.SZA 0.5271
    金种子酒 600199.SHA 0.5785
    长春燃气 600333.SHA 0.5893
    金博股份 688598.SHA 0.6059
    豫能控股 001896.SZA 0.9198
    郑州煤电 600121.SHA 1.2201
    皇台酒业 000995.SZA 1.5594