Commit graph

9 commits

Author SHA1 Message Date
Viktor Barzin
52b3c76482 feat(kevin): correct exits, realized P&L, wire exit scanner
- executor: EXIT/SELL signals close the FULL held broker position (not a target_dollars-sized fresh order) and skip when flat

- executor: book realized P&L on the closing trade ((fill - avg_entry)*qty) so the dashboard P&L + win-rate populate; entries leave pnl=None

- exit scanner: wired into the bridge run loop on kevin_bridge_exit_scan_cron (daily ET gate; croniter intentionally not a dependency) plus an offsetting-SELL guard so it only emits exits for currently-held tickers

[ci skip]

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-04 22:13:30 +00:00
Viktor Barzin
14407d37dc feat(kevin-exec): size from target_dollars, propagate price, bracket entries
Kevin signals never placed orders: the executor sized only from
sentiment_context["current_price"] (None for Kevin) so qty=0, and orders
were always built SIMPLE (stop/take pcts ignored).

- TradeSignal gains `current_price`; the bridge now sets it on publish
- risk_manager honors `target_dollars` directly (no strength re-scale) and
  resolves price from current_price then sentiment_context
- executor builds BRACKET orders for LONG entries carrying stop/take pcts;
  EXIT/SELL signals stay SIMPLE (the bridge sets pcts even on exits)

[ci skip]

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-04 21:56:59 +00:00
Viktor Barzin
35707a5c8a fix(kevin_bridge): persist signal to signals table before audit row
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
End-to-end Phase 2 verification surfaced a FK violation: the bridge
publishes a TradeSignal to the Redis stream and writes
kevin_signal_bridge_state with signal_id, but signal_id has a FK to
the signals table — which was never populated for Kevin-emitted
signals (only the news+sentiment path wrote there).

AuditWriter.persist_signal() inserts the TradeSignal into the
signals table idempotently (on_conflict_do_nothing on the UUID PK)
before the bridge publishes to Redis. Bridge calls it as a new step
right before the XADD, so:
  1. Signal row exists in signals table
  2. XADD to signals:generated
  3. Audit row with signal_id FK now resolves

Verified live: mention #84 (synthetic NVDA buy, conviction 0.85)
emitted a signal, trade-executor consumed and correctly rejected
with outside_market_hours (market was closed at the time).
2026-05-26 21:23:59 +00:00
552f5a18f7 fix(kevin_bridge): use PositionInfo.ticker + qty*avg_entry for cost basis
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
PositionInfo schema in shared/schemas/trading.py has ticker (not symbol)
and no cost_basis field. Compute cost basis as qty * avg_entry.
Production logs showed AttributeError on every mention process.
2026-05-24 01:22:40 +00:00
db103df9b1 feat(kevin_bridge): service entrypoint with concrete wiring
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Wires the dependency-injected KevinBridge to concrete Redis cursor +
DB session factory + AlpacaBroker (or stub when creds missing). Includes
TradeSignalPublisher (Pydantic -> dict for the redis stream) and
SIGINT/SIGTERM graceful shutdown. Adds is_asset_tradable + get_latest_price
to AlpacaBroker so the bridge can query asset metadata.
2026-05-24 01:06:18 +00:00
cff2564428 feat(kevin_bridge): exit-scan daily job + cursor + audit writer
Some checks failed
ci/woodpecker/push/woodpecker Pipeline was canceled
2026-05-24 01:03:53 +00:00
a417cae77b feat(kevin_bridge): blocklist + daily risk counters
Some checks failed
ci/woodpecker/push/woodpecker Pipeline was canceled
2026-05-24 01:01:54 +00:00
3347847e38 feat(kevin_bridge): multi-mention aggregator with capped conviction boost
Some checks failed
ci/woodpecker/push/woodpecker Pipeline was canceled
2026-05-24 01:01:02 +00:00
adbd7f3c65 feat(kevin_bridge): main orchestrator with dependency injection
Some checks failed
ci/woodpecker/push/woodpecker Pipeline was canceled
Composable: cursor/aggregator/strategy/publisher/audit_writer/broker
all injected. Master kill-switch (kevin_enable_trading=false) routes to
audit-only path. Cursor advances ONLY after XADD succeeds (race fix).
Concrete collaborators wired in subsequent tasks.

Also extends TradeSignal + SignalDirection.EXIT with the optional
fields Kevin paths need (strategy_id, target_dollars, stop_loss_pct,
take_profit_pct).
2026-05-24 00:59:56 +00:00