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)

需要做的:

  • 多空累计净值_空头择时
  • 空头累计净值_空头择时
  • 空头择时_多空_年化收益
  • 空头择时_空头_年化收益
相关推荐
云析赢指标公式网414 分钟前
文华财经指标源码笔记:WINNER筹码函数、控盘变量与MACD变体的调试记录
java·笔记·算法
无心水28 分钟前
22、数学与经济管理(运筹学) 核心考点与学习笔记
人工智能·笔记·学习·架构师·软考·软考架构师·软考系统架构师
xxwl5851 小时前
Nginx 基础学习笔记
笔记·学习·nginx
January12072 小时前
【AI方法笔记】2026-11-02:模型流式吐 JSON 时,前端会遇到四种崩法
前端·人工智能·笔记·json
snysy2 小时前
# 磁盘IO性能fio测试实操笔记
笔记·磁盘io·fio
无心水4 小时前
20、大数据架构设计理论与实践 核心考点与学习笔记
大数据·笔记·学习·架构师·系统架构设计师·软考系统架构设计师·架构设计师
snysy4 小时前
WordPress伪静态404故障排查笔记
android·笔记·wordpress
Z21-X4 小时前
云原生运维实战笔记:华为云计算与网络类服务全景解析
运维·笔记·学习·云原生·华为云
半壶清水4 小时前
[软考网规考点笔记]-局域网之冗余网关技术
网络·笔记·智能路由器
LK_074 小时前
【Agent】工具调用的安全边界:从模型输出到程序执行
人工智能·笔记·python·agent