From cf34fedfafa663ac1c5cacba6b13a82d6fbacd7c Mon Sep 17 00:00:00 2001 From: Nora Date: Tue, 15 Aug 2023 00:36:51 +0800 Subject: [PATCH] =?UTF-8?q?=20=20=20=20evaluate=5Fpairs=20=E5=85=BC?= =?UTF-8?q?=E5=AE=B9=E5=8F=82=E6=95=B0pairs=E4=B8=BA=E7=A9=BAdataframe?= =?UTF-8?q?=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- czsc/utils/stats.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/czsc/utils/stats.py b/czsc/utils/stats.py index 1dcff36ce..07d00a530 100644 --- a/czsc/utils/stats.py +++ b/czsc/utils/stats.py @@ -160,7 +160,11 @@ def evaluate_pairs(pairs: pd.DataFrame, trade_dir: str = "多空") -> dict: """ from czsc.objects import cal_break_even_point - pairs = pairs.copy() + if pairs.empty: + pairs = pairs.reindex(columns=["标的代码", "策略标记", "交易方向", "开仓时间","平仓时间", "开仓价格", "平 +仓价格", "持仓K线数", "事件序列", "持仓天数", "盈亏比例"]) + else: + pairs = pairs.copy() if trade_dir in ["多头", "空头"]: pairs = pairs[pairs["交易方向"] == trade_dir] else: