feat(bot): add [CYCLE SUMMARY] diagnostic block at end of each cycle
CI/CD / build-and-push (push) Successful in 2m16s
CI/CD / build-and-push (push) Successful in 2m16s
BayesianStrategy now tracks per-cycle counters (reset each cycle): - skip_prior_extreme, skip_family - skip_edge_net_nonpositive (edge_net ≤ 0) - skip_edge_net_below_regime (0 < edge_net < regime_min) - evaluated_edges list for max/pct computations main.py logs one structured [CYCLE SUMMARY] block per cycle with: markets_total, markets_uncertainty_zone, max_edge_gross, max_edge_net, pct_edge_gross_gt_002, pct_edge_gross_gt_004, all blocked_by_* counters, trades_executed, gnews_queries_used/cap Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+40
-3
@@ -10,7 +10,7 @@ from datetime import datetime, timezone
|
||||
from bot.data.polymarket import PolymarketClient, market_family_key
|
||||
from bot.data.external import ExternalDataClient
|
||||
from bot.data.news import NewsClient
|
||||
from bot.strategy.bayesian import BayesianStrategy, gnews_priority
|
||||
from bot.strategy.bayesian import BayesianStrategy, gnews_priority, MAX_NEWS_QUERIES_PER_CYCLE
|
||||
from bot.risk.manager import RiskManager
|
||||
from bot.executor.paper import PaperExecutor
|
||||
from bot.metrics.tracker import MetricsTracker
|
||||
@@ -124,9 +124,46 @@ async def run_trading_loop(
|
||||
occupied_families.add(signal.family_key)
|
||||
cycle_trades += 1
|
||||
|
||||
log.info("Cycle complete — trades this cycle: %d", cycle_trades)
|
||||
# 8. [CYCLE SUMMARY] — one block per cycle, stable format for grep/compare
|
||||
stats = strategy.get_cycle_stats()
|
||||
n_total = len(markets)
|
||||
n_uncertainty = sum(1 for m in markets if 0.35 <= m.yes_price <= 0.65)
|
||||
n_eval = stats["evaluated_count"]
|
||||
def _pct(n: int, denom: int) -> str:
|
||||
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
|
||||
|
||||
# 8. Update daily metrics
|
||||
log.info(
|
||||
"[CYCLE SUMMARY]\n"
|
||||
" markets_total: %d\n"
|
||||
" markets_uncertainty_zone: %d (prior 0.35-0.65)\n"
|
||||
" max_edge_gross: %+.3f\n"
|
||||
" max_edge_net: %+.3f\n"
|
||||
" pct_edge_gross_gt_002: %s\n"
|
||||
" pct_edge_gross_gt_004: %s\n"
|
||||
" blocked_by_family: %d\n"
|
||||
" blocked_by_prior_extreme: %d\n"
|
||||
" blocked_by_edge_net_nonpositive:%d\n"
|
||||
" blocked_by_edge_net_below_regime:%d\n"
|
||||
" trades_executed: %d\n"
|
||||
" gnews_queries_used: %d/%d",
|
||||
n_total,
|
||||
n_uncertainty,
|
||||
stats["max_edge_gross"],
|
||||
stats["max_edge_net"],
|
||||
_pct(stats["gross_gt_002"], n_total),
|
||||
_pct(stats["gross_gt_004"], n_total),
|
||||
stats["skip_family"],
|
||||
stats["skip_prior_extreme"],
|
||||
stats["skip_edge_net_nonpositive"],
|
||||
stats["skip_edge_net_below_regime"],
|
||||
cycle_trades,
|
||||
stats["gnews_queries_used"], MAX_NEWS_QUERIES_PER_CYCLE,
|
||||
)
|
||||
|
||||
# 9. Update daily metrics
|
||||
await metrics.update_daily_summary()
|
||||
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user