From a7f7ceabc31a1a7d2cc70c8301c07cd643efcf35 Mon Sep 17 00:00:00 2001 From: Caceresenzo Date: Wed, 20 Dec 2023 14:25:41 +0100 Subject: [PATCH] fix(pdf): return `-` if metric not found --- backtest/export/pdf.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backtest/export/pdf.py b/backtest/export/pdf.py index af8d20f..fa6438c 100644 --- a/backtest/export/pdf.py +++ b/backtest/export/pdf.py @@ -115,6 +115,10 @@ def get_metric(column: str, name: str): except: pass + if name not in df_metrics.index: + print(f"[warning] invalid metric name: `{name}`: not in index: {df_metrics.index}") + return "-" + value = df_metrics.loc[name, column] if name in NOT_PERCENT: return value