3.5 KiB
3.5 KiB
Observer Visualizer V1
Ten dokument opisuje pierwszy panel UI dla bot-observer
w visualizerze.
Cel
Pokazać operatorowi stan observera bez liczenia logiki bota po stronie frontendu.
UI ma:
- czytać gotowy stan z control plane
- pokazywać bieżącą decyzję, gates i feature snapshot
- pokazywać heartbeat, błędy i feed eventów
Źródła danych
Panel czyta przez istniejący trade-api:
GET /api/v1/bots?limit=100GET /api/v1/bots/:id/stateGET /api/v1/bots/:id/events?limit=100
Frontend nie odpytuje Hasury bezpośrednio dla panelu observera.
Zasada wyboru aktywnego bota
Panel rozwiązuje bota w kolejności:
VITE_BOT_IDjeśli ustawioneVITE_BOT_NAMEjeśli ustawione- pierwszy bot, którego
market_name === aktualny symbol na wykresie
Jeśli żaden bot nie pasuje, panel pokazuje stan
No bot configured.
Schema danych w UI
bot_config
UI używa:
idnamemarket_namemarket_typemodekill_switchupdated_at
bot_state
UI używa:
last_heartbeat_atlast_action_atlast_errorupdated_atstate
bot_state.state
Observer zapisuje już gotowy summary payload. UI czyta tylko:
{
"service": "bot-observer",
"version": "observer-sol-v1",
"observe_only": true,
"market_name": "SOL-PERP",
"market_type": "perp",
"mode": "observe",
"kill_switch": false,
"status": "observe",
"strategy_type": "predictive_observer_v1",
"loop_ms": 1000,
"last_snapshot": {
"query_latency_ms": 82,
"data_age_ms": 214,
"candles_count": 64,
"stats_age_ms": 180,
"depth_age_ms": 210,
"buy_slippage_age_ms": 205,
"sell_slippage_age_ms": 208
},
"last_features": {
"mark_price": 182.12,
"oracle_price": 182.08,
"mid_price": 182.11,
"spread_bps": 2.1,
"stats_imbalance": 0.08,
"depth_bid_usd": 12400,
"depth_ask_usd": 9700,
"depth_imbalance": 0.12,
"buy_slippage_bps": 4.2,
"sell_slippage_bps": 4.0,
"mark_vs_oracle_bps": 0.22,
"mom_3s": 3.8,
"mom_10s": 6.1,
"mom_30s": -12.5,
"vol_30s": 5.9
},
"last_gates": {
"fresh": true,
"spread_ok": true,
"slippage_ok": true,
"depth_ok": true,
"has_candles": true,
"all": true
},
"last_decision": {
"side": "long",
"confidence": 0.72,
"long_score": 1.91,
"short_score": -2.34,
"target_notional_usd": 500,
"horizon_s": 60,
"skip_reason": null
},
"counters": {
"loops": 1012,
"decisions": 620,
"skips": 382,
"errors": 1
}
}Sekcje panelu
1. Status
modekill_switchstatusobserve_onlyheartbeat agelast_error
2. Current Decision
sideconfidencetarget_notional_usdhorizon_slong_scoreshort_scoreskip_reason
3. Gates
freshspread_okslippage_okdepth_okhas_candles
4. Feature Snapshot
spread_bpsmark_vs_oracle_bpsmom_3smom_10smom_30svol_30sdepth_bid_usddepth_ask_usddepth_imbalancebuy_slippage_bpssell_slippage_bpsdata_age_msquery_latency_ms
5. Event Feed
Pokazujemy ostatnie eventy:
decisionskipstatuserror
UI nie renderuje pełnego JSON, tylko krótkie summary + timestamp.
Zakres V1
V1 to tylko wizualizacja aktualnego stanu observera.
Poza zakresem:
- edycja
bot_config - ręczne sterowanie
mode - wykres historyczny decyzji na świecach
- live subscriptions
V2 może dodać:
- markery decyzji na wykresie
- odtwarzanie
decision history - mutacje control-plane z UI