def sample_935_2(): """ 9.3.5_2 不同权重的评分: 只考虑胜率 :return: """ from abupy import ABuFileUtil score_fn = '../gen/score_tuple_array' if not ABuFileUtil.file_exist(score_fn): print( '../gen/score_tuple_array not exist! please execute sample_933 first!' ) return """ 直接读取本地序列化文件 """ score_tuple_array = ABuFileUtil.load_pickle(score_fn) from abupy import WrsmScorer # 只有第一项为1,其他都是0代表只考虑胜率来评分 scorer = WrsmScorer(score_tuple_array, weights=[1, 0, 0, 0]) # 返回按照评分排序后的队列 scorer_returns_max = scorer.fit_score() # index[-1]为最优参数序号 best_score_tuple_grid = score_tuple_array[scorer_returns_max.index[-1]] AbuMetricsBase.show_general(best_score_tuple_grid.orders_pd, best_score_tuple_grid.action_pd, best_score_tuple_grid.capital, best_score_tuple_grid.benchmark, only_info=False) # 最后打印出只考虑胜率下最优结果使用的买入策略和卖出策略 print( 'best_score_tuple_grid.buy_factors, best_score_tuple_grid.sell_factors:\n', best_score_tuple_grid.buy_factors, best_score_tuple_grid.sell_factors)
def sample_934(): """ 9.3.4 度量结果的评分 :return: """ from abupy import ABuFileUtil score_fn = '../gen/score_tuple_array' if not ABuFileUtil.file_exist(score_fn): print( '../gen/score_tuple_array not exist! please execute sample_933 first!' ) return """ 直接读取本地序列化文件 """ score_tuple_array = ABuFileUtil.load_pickle(score_fn) from abupy import WrsmScorer # 实例化一个评分类WrsmScorer,它的参数为之前GridSearch返回的score_tuple_array对象 scorer = WrsmScorer(score_tuple_array) print('scorer.score_pd.tail():\n', scorer.score_pd.tail()) # score_tuple_array[658]与grid_search.best_score_tuple_grid是一致的 sfs = scorer.fit_score() # 打印前15个高分组合 print('sfs[::-1][:15]:\n', sfs[::-1][:15])
def sample_935_2(): """ 9.3.5_2 不同权重的评分: 只考虑胜率 :return: """ from abupy import ABuFileUtil score_fn = '../gen/score_tuple_array' if not ABuFileUtil.file_exist(score_fn): print('../gen/score_tuple_array not exist! please execute sample_933 first!') return """ 直接读取本地序列化文件 """ score_tuple_array = ABuFileUtil.load_pickle(score_fn) from abupy import WrsmScorer # 只有第一项为1,其他都是0代表只考虑胜率来评分 scorer = WrsmScorer(score_tuple_array, weights=[1, 0, 0, 0]) # 返回按照评分排序后的队列 scorer_returns_max = scorer.fit_score() # index[-1]为最优参数序号 best_score_tuple_grid = score_tuple_array[scorer_returns_max.index[-1]] AbuMetricsBase.show_general(best_score_tuple_grid.orders_pd, best_score_tuple_grid.action_pd, best_score_tuple_grid.capital, best_score_tuple_grid.benchmark, only_info=False) # 最后打印出只考虑胜率下最优结果使用的买入策略和卖出策略 print('best_score_tuple_grid.buy_factors, best_score_tuple_grid.sell_factors:\n', best_score_tuple_grid.buy_factors, best_score_tuple_grid.sell_factors)
def sample_935_1(): """ 9.3.5_1 不同权重的评分: 只考虑投资回报来评分 :return: """ from abupy import ABuFileUtil score_fn = '../gen/score_tuple_array' if not ABuFileUtil.file_exist(score_fn): print('../gen/score_tuple_array not exist! please execute sample_933 first!') return """ 直接读取本地序列化文件 """ score_tuple_array = ABuFileUtil.load_pickle(score_fn) from abupy import WrsmScorer # 实例化WrsmScorer,参数weights,只有第二项为1,其他都是0, # 代表只考虑投资回报来评分 scorer = WrsmScorer(score_tuple_array, weights=[0, 1, 0, 0]) # 返回排序后的队列 scorer_returns_max = scorer.fit_score() # 因为是倒序排序,所以index最后一个为最优参数 best_score_tuple_grid = score_tuple_array[scorer_returns_max.index[-1]] # 由于篇幅,最优结果只打印文字信息 AbuMetricsBase.show_general(best_score_tuple_grid.orders_pd, best_score_tuple_grid.action_pd, best_score_tuple_grid.capital, best_score_tuple_grid.benchmark, only_info=True) # 最后打印出只考虑投资回报下最优结果使用的买入策略和卖出策略 print('best_score_tuple_grid.buy_factors, best_score_tuple_grid.sell_factors:\n', best_score_tuple_grid.buy_factors, best_score_tuple_grid.sell_factors)
def sample_935_1(): """ 9.3.5_1 不同权重的评分: 只考虑投资回报来评分 :return: """ from abupy import ABuFileUtil score_fn = '../gen/score_tuple_array' if not ABuFileUtil.file_exist(score_fn): print('../gen/score_tuple_array not exist! please execute sample_933 first!') return """ 直接读取本地序列化文件 """ score_tuple_array = ABuFileUtil.load_pickle(score_fn) from abupy import WrsmScorer # 实例化WrsmScorer,参数weights,只有第二项为1,其他都是0, # 代表只考虑投资回报来评分 scorer = WrsmScorer(score_tuple_array, weights=[0, 1, 0, 0]) # 返回排序后的队列 scorer_returns_max = scorer.fit_score() # 因为是倒序排序,所以index最后一个为最优参数 best_score_tuple_grid = score_tuple_array[scorer_returns_max.index[-1]] # 由于篇幅,最优结果只打印文字信息 AbuMetricsBase.show_general(best_score_tuple_grid.orders_pd, best_score_tuple_grid.action_pd, best_score_tuple_grid.capital, best_score_tuple_grid.benchmark, only_info=True) # 最后打印出只考虑投资回报下最优结果使用的买入策略和卖出策略 print('best_score_tuple_grid.buy_factors, best_score_tuple_grid.sell_factors:\n', best_score_tuple_grid.buy_factors, best_score_tuple_grid.sell_factors)
def sample_934(): """ 9.3.4 度量结果的评分 :return: """ from abupy import ABuFileUtil score_fn = '../gen/score_tuple_array' if not ABuFileUtil.file_exist(score_fn): print('../gen/score_tuple_array not exist! please execute sample_933 first!') return """ 直接读取本地序列化文件 """ score_tuple_array = ABuFileUtil.load_pickle(score_fn) from abupy import WrsmScorer # 实例化一个评分类WrsmScorer,它的参数为之前GridSearch返回的score_tuple_array对象 scorer = WrsmScorer(score_tuple_array) print('scorer.score_pd.tail():\n', scorer.score_pd.tail()) # score_tuple_array[658]与grid_search.best_score_tuple_grid是一致的 sfs = scorer.fit_score() # 打印前15个高分组合 print('sfs[::-1][:15]:\n', sfs[::-1][:15])