How Barfinex Works
Inspector — risk policies and configuration
How the Inspector classifies positions, applies risk rules, and what main configuration options control its behavior.
Position ownership
The Inspector classifies every position into one of two types:
| Type | Meaning | Inspector behavior |
|---|---|---|
| Legacy | Position existed before the current Inspector session started | Notify only — no auto-close, no auto-modification of stops. Alerts (e.g. Telegram) when risk factors appear. |
| Runtime-managed | Position was opened while the Inspector is running | Full control — ensures stops, trailing, and can close via Provider API when rules are breached. |
This keeps existing positions safe from automatic closure while giving the Inspector full control over positions it “saw” from the moment they were opened.
What the Inspector does for runtime-managed positions
- Protective orders — Places stop-loss (STOP_MARKET) and take-profit (TAKE_PROFIT_MARKET) via Provider
POST /api/orders. Source is Inspector. - Risk checks — Evaluates stop breach, max hold time, portfolio exposure. Can close the position with an opposite-side market order when a rule is breached.
- Trailing and breakeven — Optional trailing stop and breakeven logic based on config (e.g. trailing stop %, breakeven %).
- Liquidity awareness — Can defer closing if spread or depth is outside configured limits (e.g. max spread for close, min depth).
For Legacy positions, the same risk metrics are computed but the only action is notification; the Inspector never closes or modifies them automatically.
Notifications
The Inspector can send:
- Startup summary (e.g. how many legacy positions exist)
- Legacy risk alerts (notify-only)
- Runtime stop placement and close success/failure
- Order book liquidity warnings (e.g. when spread exceeds tolerance)
Configure your notification channel (e.g. Telegram) in the Inspector or Provider setup. See Telegram notifications for detector/advisor alerts; Inspector can use the same or a dedicated channel.
Main configuration areas
Risk behavior is driven by the Inspector config file (e.g. config.inspector.json). Typical groups:
- riskManagement — Stop loss %, take profit %, breakeven %, max trades per day, max daily loss/profit %, max drawdown %, max losing trades per day, risk per trade %, correlated positions limits.
- tradeSettings — Max position hold time, max position size %, trailing stop %.
- assetManagement — Spread tolerance %, max spread for close, min depth for close.
- strategyLogic — Stress policy, spread trigger for stress, max consecutive losses, auto-throttle of detectors (emit risk events so Detector can pause).
Exact field names and defaults depend on your Barfinex version; use the Inspector API GET /inspector/options (via Provider proxy) to see the current runtime config.
Audit and analytics
- Live audit — Recent risk events are available via the Inspector API (e.g. risk audit endpoint). Useful for dashboards and debugging.
- QuestDB — When enabled, risk events can be written to time-series storage (e.g.
inspector_risk_audit) for long-term reporting and analysis.
Next steps
- Inspector overview — Role, data sources, installation
- Inspector API reference — Endpoints for options, dashboard, audit