How cavack/wfh works
Purpose and Safety Boundary
WaterfallHunter is an observational research/monitoring system for USDT perpetual-futures “waterfall” setups. It evaluates and records signals but is explicitly non-trading: LIVE_TRADING_ENABLED=false is the invariant. Decision outputs, execution suitability, and AI advice remain gated evidence rather than order-routing authority. Core runtime: backend/src/waterfallhunter/main.py, backend/src/waterfallhunter/config.py, backend/src/waterfallhunter/core/lbank_execution.py.
Service Entry Points
The FastAPI backend is the evaluator, persistence/API boundary, and likely dashboard-data provider, entered through backend/src/waterfallhunter/main.py. The Next.js frontend provides the read-only monitoring UI via frontend/app/dashboard/page.tsx, composed from evidence, ranking, and funnel views. A separate health/notification process runs from watchdog/main.py.
Market Discovery and Evidence Acquisition
Discovery adapters collect tradable-market and supporting evidence from exchange, DEX, and on-chain sources. LBank scanning feeds the focused execution/evidence path; DEX Screener and on-chain collection provide complementary discovery signals. Provider selection is centralized to isolate external integrations. Key paths: backend/src/waterfallhunter/discovery/lbank_scanner.py, backend/src/waterfallhunter/discovery/dexscreener.py, backend/src/waterfallhunter/core/provider_registry.py.
Signal Evaluation Waterfall
Candidates pass staged deterministic analysis: candle and channel patterns, derivatives and microstructure context, market-regime assessment, anti-chase protection, scoring, then final ranking. The funnel and lifecycle modules represent stage progression and protect against stale or improperly persisted triggers. Key paths: backend/src/waterfallhunter/core/signal_funnel.py, backend/src/waterfallhunter/core/score_v2.py, backend/src/waterfallhunter/core/final_ranking.py; backend/src/waterfallhunter/core/stage_lifecycle.py.
Validation, Risk, and Advisory Gates
The system applies cross-exchange validation, position/risk calculations, and an advisory AI veto. Gemini is the configured AI provider; failure must leave deterministic evaluation operating without local-model fallback. Execution suitability is a separate observational judgment and cannot replace established proxies until evidence-based promotion. Key paths: backend/src/waterfallhunter/core/multi_exchange_validator.py, backend/src/waterfallhunter/core/risk_manager.py, backend/src/waterfallhunter/core/ai_veto.py; backend/src/waterfallhunter/core/lbank_execution_suitability.py.
Persistence, Outcomes, and Replay
Database-backed lifecycle state separates production/natural outcomes from historical imports. Signal ledgers and execution stores retain decisions and outcomes; provenance/evidence recording makes decision packets auditable and feature replayable. API route modules expose these records without making them trading controls. Key paths: backend/src/waterfallhunter/core/db.py, backend/src/waterfallhunter/core/lbank_signal_ledger.py, backend/src/waterfallhunter/core/historical_outcome_store.py; backend/src/waterfallhunter/core/feature_replay.py.
Operations and Infrastructure
Docker Compose runs backend, frontend, and watchdog, with application state in the externalized waterfall_data volume. Monitoring infrastructure is Prometheus, Alertmanager, and Grafana; backend notification support forms the bridge from evaluated conditions to operators. Key paths: docker-compose.yml, deploy/prometheus/prometheus.yml, deploy/grafana/dashboards/operations.json; backend/src/waterfallhunter/core/notifier.py.
Main entry points: main.py Backend API and evaluator · signal_funnel.py Signal funnel · docker-compose.yml Docker Compose · stage_lifecycle.py Stage lifecycle
Components 24
Read-only UI
- Monitoring dashboard · Read-only evidence, ranking, and funnel views.
frontend/app/dashboard/page.tsx
Evidence acquisition
- Provider registry · Centralizes external-provider selection.
backend/src/waterfallhunter/core/provider_registry.py - LBank scanner
backend/src/waterfallhunter/discovery/lbank_scanner.py - DEX Screener
backend/src/waterfallhunter/discovery/dexscreener.py
Signal evaluation
- Backend API and evaluator · Primary evaluation, persistence, and API boundary.
backend/src/waterfallhunter/main.py - Trading safety invariant · LIVE_TRADING_ENABLED remains false.
backend/src/waterfallhunter/config.py - Signal funnel · Advances candidates through analysis stages.
backend/src/waterfallhunter/core/signal_funnel.py - Stage lifecycle · Prevents stale or improperly persisted triggers.
backend/src/waterfallhunter/core/stage_lifecycle.py - Signal scoring · Scores pattern, derivatives, microstructure, regime, and anti-chase evidence.
backend/src/waterfallhunter/core/score_v2.py - Final ranking
backend/src/waterfallhunter/core/final_ranking.py - Cross-exchange validation
backend/src/waterfallhunter/core/multi_exchange_validator.py - Risk calculation
backend/src/waterfallhunter/core/risk_manager.py - Gemini advisory veto · Failure preserves deterministic evaluation without local fallback.
backend/src/waterfallhunter/core/ai_veto.py - Execution suitability · Evidence-gated judgment, never order authority.
backend/src/waterfallhunter/core/lbank_execution_suitability.py - LBank execution boundary · Retains no-live-trading execution constraint.
backend/src/waterfallhunter/core/lbank_execution.py
Records and replay
- Lifecycle database · Stores lifecycle state and application records.
backend/src/waterfallhunter/core/db.py - Signal ledger · Retains auditable signal decisions.
backend/src/waterfallhunter/core/lbank_signal_ledger.py - Historical outcomes · Separates historical imports from natural production outcomes.
backend/src/waterfallhunter/core/historical_outcome_store.py - Feature replay · Replays recorded evidence and features.
backend/src/waterfallhunter/core/feature_replay.py
Operations
- Backend notifier · Sends evaluated-condition notifications to operators.
backend/src/waterfallhunter/core/notifier.py - Watchdog process
watchdog/main.py - Docker Compose · Runs backend, frontend, watchdog, and externalized state volume.
docker-compose.yml - Prometheus
deploy/prometheus/prometheus.yml - Grafana operations dashboard
deploy/grafana/dashboards/operations.json
Connections 28
- Monitoring dashboard → Backend API and evaluator: reads monitoring records
- Provider registry → LBank scanner: selects
- Provider registry → DEX Screener: selects
- LBank scanner → Signal funnel: market candidates
- DEX Screener → Signal funnel: discovery evidence
- Signal funnel → Stage lifecycle: stage progression
- Stage lifecycle → Signal scoring: valid candidates
- Signal scoring → Cross-exchange validation: scored signals
- Cross-exchange validation → Risk calculation: validated evidence
- Risk calculation → Gemini advisory veto: risk context
- Gemini advisory veto → Final ranking: advisory-gated evidence
- Final ranking → Execution suitability: ranked candidates
- Execution suitability → LBank execution boundary: observational suitability only
- Trading safety invariant → LBank execution boundary: disables live trading
- Backend API and evaluator → Provider registry: runs acquisition
- Backend API and evaluator → Signal funnel: runs evaluation
- Final ranking → Signal ledger: decision packets
- Stage lifecycle → Lifecycle database: persists state
- Signal ledger → Lifecycle database: stores records
- Historical outcomes → Lifecycle database: stores outcomes
- Signal ledger → Feature replay: recorded evidence
- Historical outcomes → Feature replay: historical outcomes
- Backend API and evaluator → Backend notifier: evaluated conditions
- Watchdog process → Backend notifier: health events
- Prometheus → Grafana operations dashboard: metrics
- Docker Compose → Backend API and evaluator: runs
- Docker Compose → Monitoring dashboard: runs
- Docker Compose → Watchdog process: runs