Producer (market-data-service):
- Backpressure: smart drop policy (heartbeats→quotes→trades preserved)
- Heartbeat monitor: synthetic HeartbeatEvent on provider silence
- Graceful shutdown: WS→bus→storage→DB engine cleanup sequence
- Bybit V5 public WS provider (backup for Binance, no API key needed)
- FailoverManager: health-based provider switching with recovery
- NATS output adapter: md.events.{type}.{symbol} for SenpAI
- /bus-stats endpoint for backpressure monitoring
- Dockerfile + docker-compose.node1.yml integration
- 36 tests (parsing + bus + failover), requirements.lock
Consumer (senpai-md-consumer):
- NATSConsumer: subscribe md.events.>, queue group senpai-md, backpressure
- State store: LatestState + RollingWindow (deque, 60s)
- Feature engine: 11 features (mid, spread, VWAP, return, vol, latency)
- Rule-based signals: long/short on return+volume+spread conditions
- Publisher: rate-limited features + signals + alerts to NATS
- HTTP API: /health, /metrics, /state/latest, /features/latest, /stats
- 10 Prometheus metrics
- Dockerfile + docker-compose.senpai.yml
- 41 tests (parsing + state + features + rate-limit), requirements.lock
CI: ruff + pytest + smoke import for both services
Tests: 77 total passed, lint clean
Co-authored-by: Cursor <cursoragent@cursor.com>
39 lines
2.0 KiB
Plaintext
39 lines
2.0 KiB
Plaintext
# SenpAI Market-Data Consumer Configuration
|
|
# Copy to .env and adjust as needed
|
|
|
|
# ── NATS ──────────────────────────────────────────────────────────────
|
|
NATS_URL=nats://localhost:4222
|
|
NATS_SUBJECT=md.events.>
|
|
NATS_QUEUE_GROUP=senpai-md
|
|
USE_JETSTREAM=false
|
|
|
|
# ── Internal queue ────────────────────────────────────────────────────
|
|
QUEUE_SIZE=50000
|
|
QUEUE_DROP_THRESHOLD=0.9
|
|
|
|
# ── Features / signals ───────────────────────────────────────────────
|
|
FEATURES_ENABLED=true
|
|
FEATURES_PUB_RATE_HZ=10
|
|
FEATURES_PUB_SUBJECT=senpai.features
|
|
SIGNALS_PUB_SUBJECT=senpai.signals
|
|
ALERTS_PUB_SUBJECT=senpai.alerts
|
|
|
|
# ── Rolling window ───────────────────────────────────────────────────
|
|
ROLLING_WINDOW_SECONDS=60.0
|
|
|
|
# ── Signal rules ─────────────────────────────────────────────────────
|
|
SIGNAL_RETURN_THRESHOLD=0.003
|
|
SIGNAL_VOLUME_THRESHOLD=1.0
|
|
SIGNAL_SPREAD_MAX_BPS=20.0
|
|
|
|
# ── Alert thresholds ─────────────────────────────────────────────────
|
|
ALERT_LATENCY_MS=1000.0
|
|
ALERT_GAP_SECONDS=30.0
|
|
|
|
# ── HTTP API ─────────────────────────────────────────────────────────
|
|
HTTP_HOST=0.0.0.0
|
|
HTTP_PORT=8892
|
|
|
|
# ── Logging ──────────────────────────────────────────────────────────
|
|
LOG_LEVEL=INFO
|