9.25工作笔记

复制代码
            stg_res = pd.DataFrame()
            stg_res.loc[0, '选币因子'] = str(factor_list)
            stg_res.loc[0, '过滤因子'] = str(filter_list)
            stg_res.loc[0, '持仓周期'] = hold_period
            stg_res.loc[0, 'offset'] = offset
            stg_res.loc[0, '选币数量'] = select_factor_num_str
            stg_res.loc[0, '是否使用现货'] = if_use_spot
            year_return['涨跌幅'] = year_return['涨跌幅'].map(lambda x: float(x[:-1]))
            stg_res['各年收益'] = [year_return.values.reshape(-1).tolist()]

            # 记录回测的各项指标
            cols = ['累积净值', '年化收益', '最大回撤']
            long_rename_cols = {'累积净值': '多头累积净值', '年化收益': '多头年化收益', '最大回撤': '多头最大回撤'}
            long_rename_cols1 = {'累积净值': '多头累积净值_择时', '年化收益': '多头年化收益_择时', '最大回撤': '多头最大回撤_择时'}
            short_rename_cols = {'累积净值': '空头累积净值', '年化收益': '空头年化收益', '最大回撤': '空头最大回撤'}
            short_rename_cols1 = {'累积净值': '空头累积净值_择时', '年化收益': '空头年化收益_择时', '最大回撤': '空头最大回撤_择时'}
            short_rename_cols2 = {'累积净值': '空头累积净值_定投', '年化收益': '空头年化收益_定投', '最大回撤': '空头最大回撤_定投'}

            long_rtn = long_rtn.T
            long_rtn = long_rtn[cols]
            long_rtn = long_rtn.rename(columns=long_rename_cols)
            short_rtn = short_rtn.T
            short_rtn = short_rtn[cols]
            short_rtn = short_rtn.rename(columns=short_rename_cols)

            # 记录回测的各项指标
            stg_res = pd.concat([stg_res, rtn.T, long_rtn, short_rtn], axis=1)
            # 保存文件
            if os.path.exists(result_path):  # 如果文件存在,往原有的文件中添加新的结果
                stg_res.to_csv(result_path, encoding='gbk', index=False, header=False, mode='a')
            else:  # 如果文不件存在,常规的to_csv操作
                stg_res.to_csv(result_path, encoding='gbk', index=False)

需要做的:

  • 多空累计净值_空头择时
  • 空头累计净值_空头择时
  • 空头择时_多空_年化收益
  • 空头择时_空头_年化收益
相关推荐
cao233315 小时前
关于 y0 y1 yn 变量名冲突说法的指正
笔记
~patience~1 天前
WAV 逆向分析工具使用笔记
笔记
滴啦嘟啦哒1 天前
【具身笔记】【π0.5 微调与仿真】五、在MuJoCo中实现可视化仿真
笔记·python·vla·具身
xier_ran1 天前
【infra之路】AI 编译器学习笔记(十三):AI 编译器全景——TVM、XLA、IREE 与其他
人工智能·笔记·学习
连山齐名1 天前
ai应用开发的学习笔记
服务器·笔记·学习
乔旭伟1 天前
中小厂生产管理系统选型笔记:驱动方式、主线链路与成本结构
笔记·需求分析·规格说明书
xier_ran1 天前
【infra之路】AI 编译器学习笔记(十四):为什么要 tiling,以及矩阵计算单元的“固定“
人工智能·笔记·学习
如旧呀1 天前
origin绘制等距的HSD置信区间
笔记·origin
问心无愧05131 天前
[极客大挑战 2019]Upload
笔记
蒸蒸yyyyzwd1 天前
CMU 11-768 p1-3 笔记
笔记