Skip to content

"Vibe-Trading: Your Personal Trading Agent"

fix(trade-journal): keep dividend rows out of top_symbols too

Haozhe Wu10a285b59c67
diff --git a/agent/src/tools/trade_journal_tool.py b/agent/src/tools/trade_journal_tool.py
index eae9be958..da2418855 100644
--- a/agent/src/tools/trade_journal_tool.py
+++ b/agent/src/tools/trade_journal_tool.py
@@ -270,7 +270,7 @@ def _compute_profile(df: pd.DataFrame) -> dict[str, Any]:
total_pnl = total_dividends
top_symbols = (
- df.groupby("symbol")
+ trades_df.groupby("symbol")
.agg(trades=("symbol", "count"), total_amount=("amount", "sum"))
.sort_values("total_amount", ascending=False)
.head(10)
diff --git a/agent/tests/test_trade_journal.py b/agent/tests/test_trade_journal.py
index 620221059..8202ecfc7 100644
--- a/agent/tests/test_trade_journal.py
+++ b/agent/tests/test_trade_journal.py
@@ -469,6 +469,8 @@ def test_compute_profile_dividend_rows() -> None:
# A 09:00 dividend row must not leak into the trading-activity stats.
assert profile["market_distribution"] == {"china_a": 2}
assert profile["hourly_distribution"] == {10: 2}
+ # Nor into the per-symbol trade count and turnover.
+ assert profile["top_symbols"] == [{"symbol": "A.SH", "trades": 2, "total_amount": 2200.0}]
def test_compute_profile_without_dividends_is_unchanged() -> None: