-- Phase 4: 앙상블 가중치 저장.
-- (code, horizon) 별로 Chronos vs LGBM 가중치. 일요일 02:00 재학습 잡에서 갱신.

\set ON_ERROR_STOP on

CREATE TABLE IF NOT EXISTS ensemble_weights (
  code        TEXT NOT NULL REFERENCES symbols(code),
  horizon     INT NOT NULL,
  w_chronos   REAL NOT NULL DEFAULT 0.6,
  w_lgbm      REAL NOT NULL DEFAULT 0.4,
  hit_rate_chronos REAL,
  hit_rate_lgbm    REAL,
  sample_count     INT,
  updated_at  TIMESTAMPTZ DEFAULT NOW(),
  PRIMARY KEY (code, horizon)
);

COMMENT ON TABLE ensemble_weights IS
  'Phase 4: (code, horizon) 별 Chronos/LGBM 가중치. 최근 30일 prediction_outcomes hit_rate 기반 매주 갱신.';
