How Barfinex Works
Barfinex glossary
Definitions of Barfinex terms — services, infrastructure, AI pipeline concepts, and event system.
Services
- Provider — The market data gateway and single source of truth. Connects to exchanges (REST + WebSocket), normalizes market data, detects and repairs candle gaps, maintains the app registry, proxies to all other services, and exposes a unified REST API and WebSocket
/wsfor Studio. All traffic from Studio and external clients routes through Provider. - Detector — The strategy runtime. Evaluates typed rule configurations against live market data from Provider. Each instance runs independently; a scored signal event is emitted when rule conditions cross the configured threshold. Multiple instances run in parallel without shared state.
- Advisor — The AI decision engine. Runs an 8-stage reasoning pipeline on every signal from Detector: market quality gate, ML conviction scoring, per-regime calibration, LLM synthesis, decision validation. Emits execution intents to Inspector. Exposes its API as MCP tools through Provider.
- Inspector — The risk governor. Validates every execution intent from Advisor against configured risk policies before any order reaches the exchange. Manages protective orders (stop-loss, take-profit) for all runtime-managed positions. Audits every fill.
- Studio — The operations terminal (Next.js). Connects exclusively through Provider's gateway. Surfaces signals, AI decisions, risk state, and capital efficiency metrics in real time. Read-only with respect to execution.
Infrastructure
- Event bus — The Redis pub/sub backbone. All services publish and subscribe through typed channels. Channel names and payload shapes are defined in
libs/types. - App Registry — Provider's registry of running services. Detector, Advisor, and Inspector register at startup via register + heartbeat. Provider uses the registry for proxy routing and to surface service availability in Studio.
- MCP (Model Context Protocol) — Provider exposes its full REST API as MCP tools, making it callable by any LLM that supports tool use. Advisor's API is also exposed via MCP through Provider.
- libs/types — The shared TypeScript package that defines all event channel names, payload schemas, and subscription types. Changes to this package are caught by the TypeScript compiler before they reach production.
AI Pipeline Concepts
- Conviction score — A normalized [0, 1] value representing Advisor's confidence in a signal after aggregating rule and ML inputs. Calibrated before use.
- Conviction calibration — The process of adjusting raw conviction scores using logistic regression with per-regime scaling (Platt scaling or isotonic regression). Accounts for historical performance distribution across different market regimes.
- Market quality score — A score computed by Provider's quality engine representing data freshness, spread stability, and liquidity depth. Advisor blocks signals when quality falls below threshold.
- Market regime — A classification of current market conditions (e.g. trending, ranging, volatile). Used by Advisor to select the appropriate calibration parameters.
- Execution intent — The typed event Advisor emits after its pipeline completes. Contains the directional decision, conviction score, reasoning, and sizing recommendation. Inspector subscribes to execution intents.
- Hallucination detection — An Advisor event emitted when LLM output is programmatically inconsistent with the quantitative signal. Blocks the cycle.
Risk Concepts
- Runtime-managed position — A position opened while Inspector is running. Inspector has full control: places stops, trails them, can close by policy or trigger.
- Legacy position — A position that existed before the current Inspector session. Inspector detects it and sends a notification but does not modify or close it automatically.
- THROTTLE — An Inspector action that reduces signal generation frequency. Published to Detector when a soft risk limit is reached.
- STAND_DOWN — An Inspector action that pauses new entries while keeping existing positions under management.
- CLOSE_ALL — An Inspector action that immediately closes all runtime-managed positions. Used when a hard risk limit is reached.
- Reconciliation — Inspector's periodic check that its internal position state matches the actual account state on the exchange. Discrepancies trigger a reconciliation event.
Environment
- Testnet — Exchange test environment (e.g. Binance Testnet). Keys and URLs differ from production; configured separately.
- Production — Live environment with real exchange keys and real funds. Requires care over secrets, HTTPS, and network access.
For architecture and data flow, see Barfinex architecture. For API details, see Provider API reference.