New service at services/signal_engine/ implementing concurrent heuristic (deterministic scoring) and probabilistic (Bayesian inference) pipelines that evaluate technical signals across 6 timeframes (M30-M) and produce independent BUY/WATCH/SKIP verdicts per ticker per evaluation tick. Components: - Input Normalizer: multi-source data assembly with sentinel fallbacks - Signal Library: Fibonacci, MA Stack, RSI, Cup & Handle, Elliott Wave - Multi-Timeframe Confluence Engine: weighted scoring with D/W/M anchors - Hard Filter Engine: macro_bias, valuation, earnings proximity gating - Heuristic Pipeline: S_total scoring with confidence-gated verdicts - Probabilistic Pipeline: Bayesian log-odds with regime priors, entropy gating, EV_R calculation, and signal correlation penalty - Exit Engine: stop-loss, targets, trailing ATR-based stops - Delta Analyzer: pipeline agreement tracking with rolling Redis metrics - Output Formatter: SignalOutput contract + Recommendation schema mapping - Worker orchestrator: concurrent pipelines with failure isolation - Main entry point: queue polling with fail-safe config loading Infrastructure: - Migration 039: signal_engine_outputs table with 3 indexes - Helm chart: signalEngine service entry (processing tier) - Redis key: QUEUE_SIGNAL_ENGINE constant Tests: 390 tests (unit + property-based) covering all components Config: dual_pipeline_enabled=false by default (safe rollout)
52 lines
1.6 KiB
SQL
52 lines
1.6 KiB
SQL
-- Migration 039: Signal Engine Outputs
|
|
-- Creates the signal_engine_outputs table for persisting dual-pipeline evaluations.
|
|
|
|
CREATE TABLE IF NOT EXISTS signal_engine_outputs (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
ticker TEXT NOT NULL,
|
|
evaluated_at TIMESTAMPTZ NOT NULL,
|
|
price NUMERIC NOT NULL,
|
|
|
|
-- Heuristic pipeline
|
|
heuristic_verdict TEXT NOT NULL,
|
|
heuristic_confidence NUMERIC NOT NULL,
|
|
heuristic_s_total NUMERIC NOT NULL,
|
|
|
|
-- Probabilistic pipeline
|
|
probabilistic_verdict TEXT NOT NULL,
|
|
probabilistic_p_up NUMERIC NOT NULL,
|
|
probabilistic_entropy NUMERIC NOT NULL,
|
|
probabilistic_ev_r NUMERIC NOT NULL,
|
|
|
|
-- Delta analysis
|
|
delta_agreement BOOLEAN NOT NULL,
|
|
delta_confidence_delta NUMERIC NOT NULL,
|
|
delta_reasons JSONB NOT NULL DEFAULT '[]'::jsonb,
|
|
|
|
-- Trade plan (null when no BUY verdict)
|
|
trade_plan JSONB,
|
|
|
|
-- Full output for audit
|
|
full_output JSONB NOT NULL,
|
|
|
|
-- Exit signals
|
|
exit_signals JSONB NOT NULL DEFAULT '[]'::jsonb,
|
|
|
|
-- Metadata
|
|
pipeline_mode TEXT NOT NULL DEFAULT 'dual_pipeline',
|
|
shadow_mode BOOLEAN NOT NULL DEFAULT FALSE,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
|
);
|
|
|
|
-- Index for per-ticker time-range queries
|
|
CREATE INDEX IF NOT EXISTS idx_signal_engine_outputs_ticker_time
|
|
ON signal_engine_outputs (ticker, evaluated_at);
|
|
|
|
-- Index for global time-range queries
|
|
CREATE INDEX IF NOT EXISTS idx_signal_engine_outputs_evaluated
|
|
ON signal_engine_outputs (evaluated_at);
|
|
|
|
-- Index for filtering by verdict
|
|
CREATE INDEX IF NOT EXISTS idx_signal_engine_outputs_verdicts
|
|
ON signal_engine_outputs (heuristic_verdict, probabilistic_verdict);
|