Skip to content

Commit

Permalink
fix(pdf): use quantstats' as_pct
Browse files Browse the repository at this point in the history
  • Loading branch information
Caceresenzo committed Sep 26, 2023
1 parent 152116b commit 2752707
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions backtest/export/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def finalize(self) -> None:
df_metrics, df_drowdowns = None, None
if df_returns is not None:
df_returns.name = "Strategy"
df_metrics = quantstats.reports.metrics(df_returns, benchmark=df_benchmark, display=False, mode="full")
df_metrics = quantstats.reports.metrics(df_returns, benchmark=df_benchmark, display=False, mode="full", as_pct=True)
df_metrics.index = df_metrics.index.map(slugify.slugify)
df_metrics.columns = df_metrics.columns.map(slugify.slugify)

Expand Down Expand Up @@ -119,9 +119,6 @@ def get_metric(column: str, name: str):
if name in NOT_PERCENT:
return value
else:
value *= 100
value = round(value, 2)

return f"{value}%"

def get_drawdown(n: int, key: typing.Union[typing.Literal["dates"], typing.Literal["value"]]):
Expand Down

0 comments on commit 2752707

Please sign in to comment.