mirror of
https://github.com/freqtrade/freqtrade.git
synced 2026-01-21 14:30:24 +00:00
fix: update total_volume calculation to actually reflect volume
closes #11268
This commit is contained in:
@@ -108,7 +108,14 @@ def _generate_result_line(
|
||||
}
|
||||
|
||||
|
||||
def generate_pair_metrics(
|
||||
def calculate_trade_volume(trades_dict: list[dict[str, Any]]) -> float:
|
||||
# Aggregate the total volume traded from orders.cost.
|
||||
# Orders is a nested dictionary within the trades list.
|
||||
|
||||
return sum(sum(order["cost"] for order in trade.get("orders", [])) for trade in trades_dict)
|
||||
|
||||
|
||||
def generate_pair_metrics( #
|
||||
pairlist: list[str],
|
||||
stake_currency: str,
|
||||
starting_balance: float,
|
||||
@@ -431,8 +438,9 @@ def generate_strategy_stats(
|
||||
|
||||
expectancy, expectancy_ratio = calculate_expectancy(results)
|
||||
backtest_days = (max_date - min_date).days or 1
|
||||
trades_dict = results.to_dict(orient="records")
|
||||
strat_stats = {
|
||||
"trades": results.to_dict(orient="records"),
|
||||
"trades": trades_dict,
|
||||
"locks": [lock.to_json() for lock in content["locks"]],
|
||||
"best_pair": best_pair,
|
||||
"worst_pair": worst_pair,
|
||||
@@ -444,7 +452,7 @@ def generate_strategy_stats(
|
||||
"total_trades": len(results),
|
||||
"trade_count_long": len(results.loc[~results["is_short"]]),
|
||||
"trade_count_short": len(results.loc[results["is_short"]]),
|
||||
"total_volume": float(results["stake_amount"].sum()),
|
||||
"total_volume": calculate_trade_volume(trades_dict),
|
||||
"avg_stake_amount": results["stake_amount"].mean() if len(results) > 0 else 0,
|
||||
"profit_mean": results["profit_ratio"].mean() if len(results) > 0 else 0,
|
||||
"profit_median": results["profit_ratio"].median() if len(results) > 0 else 0,
|
||||
|
||||
Reference in New Issue
Block a user