Faza 4 — precompute feature-a

2026-05-20 infra

13.8 miliona feature redova za 412 od 413 parova. Cache-hit put 4.5x brži, auto-recompute zakačen na dnevni catchup, 4/4 validacije prošle.

↑ Svi izveštaji ← Faza 3 — dnevni catchup i symbol churn Faza 5.2 — multi-exchange sanity check →

Status: deploy gotov, 4/4 validation tests PASS

Posle Faze 4, svi generatori automatski koriste precomputed features iz cache-a (RSI, EMA-20/50/200, ADX/+DI/-DI, BB width, ATR, supertrend, taker_buy_ratio, vol_z, BTC cross-features). Daily catchup automatski recompute-uje features za simbole sa novim klines-ima.

Šta je deploy-ovano

1. Initial features backfill

Pokrenut tools/history_cache/build_features_cache.py --all — preračunato compute_features() za sve (symbol, timeframe) iz klines_cache.db.

Rezultat:

Patch-ovano build_features_cache.py da printuje progres live — future runs imaju vidljiv progres.

2. Auto-recompute u catchup-u (src/klines_cache_maintenance.py)

daily_catchup() sad ima recompute_features=True flag (default ON):

Summary output:

{
  "status": "finished",
  "touched_symbols": ["..."],
  "features_recompute": {"pairs_recomputed": N, "rows_written": M, "errors": 0}
}

3. Generator integracija (već postojala)

_build_context.get_features() u generator_manager.py već postoji od ranije (IMPROVEMENT_PLAN A.1). Cache-first sa fallback-om na compute:

if config is None:
    conn = _features_conn()
    if conn is not None:
        cached = _feature_store.get_features(conn, symbol, tf, start=start_dt, end=end_dt)
        if cached is not None and not cached.empty:
            return cached  # cache hit
# Fallback: compute on the fly
return _feature_store.compute_features(klines, config=config)

Generator code (growth_threshold_quality_*) već poziva get_features(...) — bez izmena.

Validacija (4/4 PASS)

Skripta: tools/analysis/faza4_verify.py

Test 1: cache hit speedup

Test 2: feature_store.get_features direct read

Test 3: daily_catchup auto-recompute hook

Test 4: feature values consistency (cached vs fresh compute)

Drift od 0.002 u ADX je posledica EWM beskonačne memorije: cached features su computed nad celom 5y istorijom, fresh compute samo nad 30-dnevnim test prozorom. Apsolutno neuticajno za signal generation.

Operativni značaj

Pre Faze 4

Posle Faze 4

Hotspot smanjen za walkforward

Backtest over 5y više ne mora da:

  1. Fetch klines (već u cache-u — Faza 2)
  2. Compute RSI/EMA/ADX/BB inline (već u cache-u — Faza 4)

Promene parametara koje BIRAJU druge indikatore (canonical config) ne troše ništa — cache se koristi. Promene parametara koje MODIFIKUJU indikator parametre (npr. ema_fast=21 umesto 20) padaju na fallback compute, kao i pre.

Pre-flight provere (sve ✅)

Faza 5 (kasnije, nije ovde)

Multi-exchange podrška kroz ccxt — Kraken, Bybit, OKX, Coinbase. Treba exchange kolonu u klines PRIMARY KEY, sanity-check eksperiment BTC tri-exchange compare, manifest per-generator "exchange" polje.

Provenance

Izvor: crypto_scanner/reports/analysis/2026-05-20_faza4_features_precompute.md