【模板案例】因子分析测试

策略分享
标签: #<Tag:0x00007fc57a00a0e0>

(iQuant) #1

7月30日Meetup 模板案例:

因子分析测试

克隆策略

    {"Description":"实验创建于7/17/2020","Summary":"","Graph":{"EdgesInternal":[{"DestinationInputPortId":"-568:features","SourceOutputPortId":"-584:data"},{"DestinationInputPortId":"-568:user_factor_data","SourceOutputPortId":"-2872:data"}],"ModuleNodes":[{"Id":"-568","ModuleId":"BigQuantSpace.factorlens.factorlens-v1","ModuleParameters":[{"Name":"title","Value":"因子分析: {factor_name}","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"start_date","Value":"2019-12-01","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"end_date","Value":"2019-12-31","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"rebalance_period","Value":"5","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"stock_pool","Value":"全市场","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"quantile_count","Value":5,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"commission_rate","Value":0.0016,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"drop_price_limit_stocks","Value":"True","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"drop_st_stocks","Value":"True","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"drop_new_stocks","Value":"True","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"normalization","Value":"True","ValueType":"Literal","LinkedGlobalParameter":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%3Atrue%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%3Atrue%7D%5D%7D","ValueType":"Literal","LinkedGlobalParameter":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%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","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-568"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"user_factor_data","NodeId":"-568"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-568","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":19,"Comment":"","CommentCollapsed":true},{"Id":"-584","ModuleId":"BigQuantSpace.input_features.input_features-v1","ModuleParameters":[{"Name":"features","Value":"\n# #号开始的表示注释,注释需单独一行\n# 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征\ngap_ind_0\n#gap_ind_1\n#gap_ind_2\n# gap_ix300_0\n# gap_ix300_1\n# gap_ix300_2\n# gap_ix001_0\n# gap_ix001_1\n# gap_ix001_2\n","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features_ds","NodeId":"-584"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-584","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":20,"Comment":"","CommentCollapsed":true},{"Id":"-2872","ModuleId":"BigQuantSpace.input_csv.input_csv-v5","ModuleParameters":[{"Name":"file","Value":"data.csv","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"coding","Value":"utf8","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"dtypes","Value":"{}","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"date_type","Value":"%Y-%m-%d","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"date_cols","Value":"['date']","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[],"OutputPortsInternal":[{"Name":"data","NodeId":"-2872","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":1,"Comment":"","CommentCollapsed":true}],"SerializedClientData":"<?xml version='1.0' encoding='utf-16'?><DataV1 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><Meta /><NodePositions><NodePosition Node='-568' Position='-79.58888244628906,943.9741821289062,200,200'/><NodePosition Node='-584' Position='-307,778,200,200'/><NodePosition Node='-2872' Position='85.03511047363281,780.6598815917969,200,200'/></NodePositions><NodeGroups /></DataV1>"},"IsDraft":true,"ParentExperimentId":null,"WebService":{"IsWebServiceExperiment":false,"Inputs":[],"Outputs":[],"Parameters":[{"Name":"交易日期","Value":"","ParameterDefinition":{"Name":"交易日期","FriendlyName":"交易日期","DefaultValue":"","ParameterType":"String","HasDefaultValue":true,"IsOptional":true,"ParameterRules":[],"HasRules":false,"MarkupType":0,"CredentialDescriptor":null}}],"WebServiceGroupId":null,"SerializedClientData":"<?xml version='1.0' encoding='utf-16'?><DataV1 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><Meta /><NodePositions></NodePositions><NodeGroups /></DataV1>"},"DisableNodesUpdate":false,"Category":"user","Tags":[],"IsPartialRun":true}
    In [23]:
    # 本代码由可视化策略环境自动生成 2020年7月30日 10:43
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    m20 = M.input_features.v1(
        features="""
    # #号开始的表示注释,注释需单独一行
    # 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征
    gap_ind_0
    #gap_ind_1
    #gap_ind_2
    # gap_ix300_0
    # gap_ix300_1
    # gap_ix300_2
    # gap_ix001_0
    # gap_ix001_1
    # gap_ix001_2
    """
    )
    
    m1 = M.input_csv.v5(
        file='data.csv',
        coding='utf8',
        dtypes={},
        date_type='%Y-%m-%d',
        date_cols=['date']
    )
    
    m19 = M.factorlens.v1(
        features=m20.data,
        user_factor_data=m1.data,
        title='因子分析: {factor_name}',
        start_date='2019-12-01',
        end_date='2019-12-31',
        rebalance_period=5,
        stock_pool='全市场',
        quantile_count=5,
        commission_rate=0.0016,
        drop_price_limit_stocks=True,
        drop_st_stocks=True,
        drop_new_stocks=True,
        normalization=True,
        neutralization=['行业', '市值'],
        metrics=['因子表现概览', '因子分布', '因子行业分布', '因子市值分布', 'IC分析', '买入信号重合分析', '因子估值分析', '因子拥挤度分析', '因子值最大/最小股票', '多因子相关性分析']
    )
    

    因子分析: gap_ind_0

    { "type": "factor-track", "data": { "exprs": ["gap_ind_0"], "options": {"BacktestInterval": ["2019-12-01", "2019-12-31"], "StockPool": "all", "DropSTStocks": 1, "DropPriceLimitStocks": 1, "DropNewStocks": 1, "QuantileCount": 5, "CommissionRates": 0.0016, "Normalization": 1, "Neutralization": "industry,size", "RebalancePeriod": 5, "ReturnsCalculationMethod": "cumprod", "_HASH": "fa63b2a6fbfac4ad00d8ce1e9c748122"} } }

    因子表现概览

      累计收益 近1年收益 近3月收益 近1月收益 近1周收益 昨日收益 最大回撤 盈亏比 胜率 夏普比率 收益波动率
    最小分位 5.43% 5.43% 5.43% 5.43% 0.75% 0.39% 3.25% 0.79 0.73 4.23 13.73%
    最大分位 4.06% 4.06% 4.06% 4.06% 0.24% 0.07% 3.45% 0.66 0.73 3.16 13.63%
    多空组合 0.66% 0.66% 0.66% 0.66% 0.25% 0.16% 0.33% 1.33 0.64 2.80 1.43%

    基本特征分析

    IC分析

    IC均值

    -0.03

    IC标准差

    0.05

    IR值

    -0.63

    |IC| > 0.02比率

    100.00%

    买入信号重合分析

    因子估值分析

    因子拥挤度分析

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

    股票名称 股票代码 因子值
    美联新材 300586.SZA -0.0921
    万邦德 002082.SZA -0.0902
    浪莎股份 600137.SHA -0.0830
    容大感光 300576.SZA -0.0668
    粤泰股份 600393.SHA -0.0656
    三房巷 600370.SHA -0.0654
    阳普医疗 300030.SZA -0.0630
    美邦服饰 002269.SZA -0.0575
    德威新材 300325.SZA -0.0565
    金鸿顺 603922.SHA -0.0549
    万润科技 002654.SZA -0.0540
    中昌数据 600242.SHA -0.0536
    亚玛顿 002623.SZA -0.0534
    正裕工业 603089.SHA -0.0522
    大丰实业 603081.SHA -0.0522
    恒通科技 300374.SZA -0.0512
    乐凯新材 300446.SZA -0.0503
    华测导航 300627.SZA -0.0489
    金利华电 300069.SZA -0.0487
    万里石 002785.SZA -0.0484

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

    股票名称 股票代码 因子值
    久远银海 002777.SZA 0.0609
    上海瀚讯 300762.SZA 0.0611
    大金重工 002487.SZA 0.0619
    华扬联众 603825.SHA 0.0620
    富邦股份 300387.SZA 0.0631
    尚纬股份 603333.SHA 0.0638
    鼎龙股份 300054.SZA 0.0638
    同兴达 002845.SZA 0.0638
    中潜股份 300526.SZA 0.0641
    拉卡拉 300773.SZA 0.0652
    南风股份 300004.SZA 0.0657
    倍加洁 603059.SHA 0.0705
    新宁物流 300013.SZA 0.0711
    融捷股份 002192.SZA 0.0724
    高伟达 300465.SZA 0.0746
    汉鼎宇佑 300300.SZA 0.0766
    雅化集团 002497.SZA 0.0768
    凯众股份 603037.SHA 0.0804
    引力传媒 603598.SHA 0.0822
    山煤国际 600546.SHA 0.0831

    BigQuant AI量化专家Meetup(7月30日场回放及案例模板)