Add relevant metrics to backtest breakdowns
This commit is contained in:
@@ -132,18 +132,18 @@ def text_table_periodic_breakdown(
|
|||||||
"""
|
"""
|
||||||
headers = [
|
headers = [
|
||||||
period.capitalize(),
|
period.capitalize(),
|
||||||
|
"Trades",
|
||||||
f"Tot Profit {stake_currency}",
|
f"Tot Profit {stake_currency}",
|
||||||
"Wins",
|
"Profit Factor",
|
||||||
"Draws",
|
"Win Draw Loss Win%",
|
||||||
"Losses",
|
|
||||||
]
|
]
|
||||||
output = [
|
output = [
|
||||||
[
|
[
|
||||||
d["date"],
|
d["date"],
|
||||||
|
d["trades"],
|
||||||
fmt_coin(d["profit_abs"], stake_currency, False),
|
fmt_coin(d["profit_abs"], stake_currency, False),
|
||||||
d["wins"],
|
d["profit_factor"],
|
||||||
d["draws"],
|
generate_wins_draws_losses(d["wins"], d["draws"], d["losses"]),
|
||||||
d["loses"],
|
|
||||||
]
|
]
|
||||||
for d in days_breakdown_stats
|
for d in days_breakdown_stats
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -231,8 +231,11 @@ def generate_periodic_breakdown_stats(
|
|||||||
profit_abs = day["profit_abs"].sum().round(10)
|
profit_abs = day["profit_abs"].sum().round(10)
|
||||||
wins = sum(day["profit_abs"] > 0)
|
wins = sum(day["profit_abs"] > 0)
|
||||||
draws = sum(day["profit_abs"] == 0)
|
draws = sum(day["profit_abs"] == 0)
|
||||||
loses = sum(day["profit_abs"] < 0)
|
losses = sum(day["profit_abs"] < 0)
|
||||||
trades = wins + draws + loses
|
trades = wins + draws + losses
|
||||||
|
winning_profit = day.loc[day["profit_abs"] > 0, "profit_abs"].sum()
|
||||||
|
losing_profit = day.loc[day["profit_abs"] < 0, "profit_abs"].sum()
|
||||||
|
profit_factor = winning_profit / abs(losing_profit) if losing_profit else 0.0
|
||||||
stats.append(
|
stats.append(
|
||||||
{
|
{
|
||||||
"date": name.strftime("%d/%m/%Y"),
|
"date": name.strftime("%d/%m/%Y"),
|
||||||
@@ -240,8 +243,9 @@ def generate_periodic_breakdown_stats(
|
|||||||
"profit_abs": profit_abs,
|
"profit_abs": profit_abs,
|
||||||
"wins": wins,
|
"wins": wins,
|
||||||
"draws": draws,
|
"draws": draws,
|
||||||
"loses": loses,
|
"losses": losses,
|
||||||
"winrate": wins / trades if trades else 0.0,
|
"trades" : trades,
|
||||||
|
'profit_factor': round(profit_factor, 2),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
return stats
|
return stats
|
||||||
|
|||||||
Reference in New Issue
Block a user