Passa al contenuto principale

capital-manager — Runbook

Avvio rapido (local)

docker compose -f docker-compose.local.yml --env-file .env.local build capital-manager
docker compose -f docker-compose.local.yml --env-file .env.local up -d --no-deps capital-manager
docker compose -f docker-compose.local.yml logs -f capital-manager

Check operativi

# Health
curl -f http://localhost:3010/status/health

# Info + versione
curl http://localhost:3010/status/info
curl http://localhost:3010/release

# Test quote (con ibkr-bridge e liquidity-manager attivi)
curl -X POST http://localhost:3010/allocation/quote \
-H "Content-Type: application/json" \
-d '{"userId":7,"symbol":"AAPL","market":"US","clientRequestId":"test-001"}'

Problemi comuni

SintomoCausa probabileRecovery
maxInvestable = 0 sempreibkr-bridge non raggiungibile → cashAvailable = 0Verificare GET /ibkr-bridge/status/health e che il container sia attivo
usedFallback: true sempreliquidity-manager non raggiungibile o confidence = 0Verificare GET /liquidity-manager/status/health; controllare FRED_API_KEY nel liquidity-manager
ok: false, code: INSUFFICIENT_CAPITALCash disponibile insufficiente o riserva troppo altaVerificare cash IBKR; se necessario abbassare SCORE_RESERVED_MAX
Prenotazioni non scadonoRedis non disponibileVerificare connessione Redis (REDIS_URL); le prenotazioni usano TTL Redis nativo
listReservations restituisce array vuotoPrenotazioni scadute o userId erratoNormale dopo TTL; controllare userId nella query

Osservabilità

# Metriche runtime
curl http://localhost:3010/status/metrics

# Canali comunicazione Redis
curl http://localhost:3010/status/communicationChannels

# Log live
docker compose -f docker-compose.local.yml logs -f capital-manager

# Prenotazioni attive per utente
curl "http://localhost:3010/allocation/reservations?userId=7"

Verifica integrazione con decision-engine

Il decision-engine chiama il capital-manager in modalità fire-and-forget. Per testare l'integrazione end-to-end:

  1. Avviare capital-manager, ibkr-bridge, liquidity-manager
  2. Attivare il live mode del decision-engine (GET /decision-engine/spot-finder/live/0)
  3. Quando arriva un segnale, nei log del decision-engine verificare:
    [capitalManager] AAPL dollars=3240.50 qty=17
  4. Nei log del capital-manager verificare:
    [computeQuote] userId=7 symbol=AAPL market=US
    [decisionEngine] AAPL maxInvestable=3240.50 (cash=5000, reservedPct=0.350, ...)

Tuning in produzione

ScenarioParametro da modificare
Investire più aggressivamente in bull marketAbbassare SCORE_RESERVED_MAX (es. 0.50)
Maggiore prudenza in tutti i regimiAlzare FALLBACK_RESERVED_CASH_PCT (es. 0.70)
Prenotazioni più brevi (segnali veloci)Abbassare RESERVATION_TTL_SEC (es. 60)
Ignorare la volatilità nel calcoloImpostare VOL_SCALE=99999
Soglia minima ordine più altaAlzare MIN_ORDER_NOTIONAL (es. 100)