chore: cleanup duplicate trade save, misleading cycle counters, and /api/summary inconsistencies
CI/CD / build-and-push (push) Successful in 7s
CI/CD / build-and-push (push) Successful in 7s
Bug #5: metrics.record_trade() only delegated to save_trade(), which executor.execute() already calls — every trade was written twice (deduped only by ON CONFLICT DO NOTHING). Remove the redundant call and the now-dead method. RealExecutor.execute() raises NotImplementedError, so real mode is unaffected. Bug #6 (CYCLE SUMMARY): manifold accepted/rejected counters only increment on the active-signal path, so with MANIFOLD_SIGNAL_ENABLED=false they always printed 0/0 — print 'manifold_signal: disabled' instead. family_conflicts_prevented duplicated blocked_by_family (same counter printed twice); removed. gnews_cap was a dead variable with a misleading comment; removed. Bug #7 (/api/summary): total_trades was len() over a LIMIT-500 query — capped once history grows; counts now come from COUNT(*) via compute_metrics_from_db. cash_available was reimplemented in the API; extract cash_available() in paper.py (same formula, unchanged) and feed it from get_open_position_data() — the exact source/helper PaperExecutor.initialize() uses. Test asserts API and executor report identical cash for the same DB state. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
02cbfc0b94
commit
7ebb87aede
+19
-9
@@ -11,7 +11,12 @@ from bot.data.polymarket import PolymarketClient, Market, market_family_key
|
||||
from bot.data.external import ExternalDataClient
|
||||
from bot.data.news import NewsClient
|
||||
from bot.data.manifold import ManifoldClient
|
||||
from bot.strategy.bayesian import BayesianStrategy, gnews_priority, MAX_NEWS_QUERIES_PER_CYCLE
|
||||
from bot.strategy.bayesian import (
|
||||
BayesianStrategy,
|
||||
gnews_priority,
|
||||
MAX_NEWS_QUERIES_PER_CYCLE,
|
||||
MANIFOLD_SIGNAL_ENABLED,
|
||||
)
|
||||
from bot.risk.manager import RiskManager
|
||||
from bot.executor.paper import PaperExecutor
|
||||
from bot.metrics.tracker import MetricsTracker
|
||||
@@ -199,7 +204,6 @@ async def run_trading_loop(
|
||||
# 7. Execute (paper)
|
||||
trade = await executor.execute(order)
|
||||
if trade:
|
||||
await metrics.record_trade(trade)
|
||||
log.info("Trade executed: %s", trade)
|
||||
# Block this family for the rest of the cycle (Phase 2)
|
||||
occupied_families.add(signal.family_key)
|
||||
@@ -221,7 +225,17 @@ async def run_trading_loop(
|
||||
if denom == 0:
|
||||
return "0% (0/0)"
|
||||
return f"{n * 100 // denom}% ({n}/{denom})"
|
||||
gnews_cap = strategy._news_queries_this_cycle # already updated by reset below
|
||||
|
||||
# The accepted/rejected counters only increment on the active-signal
|
||||
# path, so with the signal disabled they always print 0/0 — say
|
||||
# "disabled" instead of pretending the matcher found nothing.
|
||||
if MANIFOLD_SIGNAL_ENABLED:
|
||||
manifold_summary = (
|
||||
f" manifold_matches_accepted: {stats['manifold_matches_accepted']}\n"
|
||||
f" manifold_matches_rejected: {stats['manifold_matches_rejected']}"
|
||||
)
|
||||
else:
|
||||
manifold_summary = " manifold_signal: disabled"
|
||||
|
||||
log.info(
|
||||
"[CYCLE SUMMARY]\n"
|
||||
@@ -239,9 +253,7 @@ async def run_trading_loop(
|
||||
" gnews_queries_used: %d/%d\n"
|
||||
" reentry_guard_blocked: %d\n"
|
||||
" legacy_incomplete_seen: %d\n"
|
||||
" family_conflicts_prevented: %d\n"
|
||||
" manifold_matches_accepted: %d\n"
|
||||
" manifold_matches_rejected: %d",
|
||||
"%s",
|
||||
n_total,
|
||||
n_uncertainty,
|
||||
stats["max_edge_gross"],
|
||||
@@ -256,9 +268,7 @@ async def run_trading_loop(
|
||||
stats["gnews_queries_used"], MAX_NEWS_QUERIES_PER_CYCLE,
|
||||
reentry_guard_count,
|
||||
legacy_incomplete_count,
|
||||
stats["skip_family"],
|
||||
stats["manifold_matches_accepted"],
|
||||
stats["manifold_matches_rejected"],
|
||||
manifold_summary,
|
||||
)
|
||||
|
||||
# 9. Update daily metrics
|
||||
|
||||
Reference in New Issue
Block a user