Commit Graph

10 Commits

Author SHA1 Message Date
Variet Agent
cc55acc330 feat(analysis): v3 re-analysis with 31 ECOS variables
Best model: CREDIT_SPREAD_LAG1 + USDKRW + HOUSING_PRICE (R²=0.646)
- 31 raw vars → 80+ features (DIFF/LAG1/PCT/spreads)
- 2267 valid combos searched (collinearity filtered)
- All Top 10 sign-consistent
- Zt sign corrected: Z+ = 호황 (Belkin convention)
2026-03-11 07:55:36 +09:00
Variet Agent
49c7661888 feat(data): expand to 31 macro variables with full fallback
Added 10 new variables:
- FACILITY_INVEST (설비투자지수)
- RETAIL_SALES (소매판매액지수)
- CURRENT_ACCOUNT (경상수지)
- EMPLOYED (취업자수)
- EMPLOYMENT_RATE (고용률)
- OIL_PRICE (두바이유 연평균)
- COINCIDENT (동행종합지수)
- BSI_MANUF (제조업 BSI 전망)
- CONSTRUCTION_DONE (건설기성액)
- SPI (서비스업생산지수)

Total: 31 variables × 26 years (2000-2025)
2026-03-11 07:52:04 +09:00
Variet Agent
92ce84ad96 feat(data): comprehensive ECOS fetcher with 21+ variables, CSV caching
New variables: KOSPI, GOVT_10Y, IMPORT_PRICE, DISHONOR_RATE,
HOUSING_PRICE, HOUSEHOLD_DEBT, IMPORT_AMT, USDKRW, CSI, M2
- CSV cache: data/cache/macro_ecos.csv (no repeated API calls)
- --force to refresh, --no-api for fallback only
- 26 years (2000-2025) fallback data for all variables
2026-03-11 07:45:52 +09:00
Variet Agent
d61c538308 fix(critical): complete Zt sign alignment across all modules
Fixed ALL instances of (d - sqrt_rho*z) -> (d + sqrt_rho*z):
- models/vasicek.py: conditional_transition_matrix() (used by lifetime PD)
- data/transition_matrices.py: _generate_model_consistent_matrix()
- models/credit_cycle.py: already fixed in previous commit

Added sign convention docs:
- vasicek.py conditional_pd() uses Basel convention (Z↑=loss↑)
- conditional_transition_matrix() uses Belkin convention (Z↑=호황)
- Both conventions documented in module docstrings

Pipeline 8/8 validation pass after fix
2026-03-11 07:36:52 +09:00
Variet Agent
1a4cc873d9 fix(critical): Zt sign convention — align with Belkin & Suchower (1998)
BUG: Formula used (d - sqrt_rho*z) but correct is (d + sqrt_rho*z)
- Our thresholds are cumulative ascending (AAA→CCC→D)
- Higher Z should push probability mass left (better ratings)
- Previous: Z+ = higher PD = bad economy (WRONG)
- Fixed:    Z+ = lower PD = good economy (matches paper)

Verification:
- 1998 IMF crisis: Zt=-2.12 (negative = bad )
- 2006 boom:       Zt=+1.53 (positive = good )
- Pipeline 8/8 validation pass
2026-03-11 07:30:15 +09:00
Variet Agent
93887f49dd refactor(macro): sign-consistent re-analysis, rate DIFF only
- Removed CORP_AA_LOGR (log of rate = problematic near zero)
- Rate variables restricted to DIFF only (no LOG/PCT/LOGR)
- Added economic sign consistency checks for all 45 features
- New optimal 3-var: CREDIT_SPREAD_LAG1, IPI_LAG1, EXPORT_DIFF
  - All coefficient signs economically consistent
  - R²=0.586 (trade-off: lower R² but correct economics)
- Added IPI + EXPORT to ECOS queries and fallback data
- Zt restricted to 2000-2025 in analysis (26 obs)
- Pipeline 8/8 validation pass
2026-03-11 07:17:33 +09:00
Variet Agent
811d6ee843 feat(macro): comprehensive variable exploration, R²=0.028→0.747
- New: data/macro_analysis.py (15 base × 6 transforms = 116 candidates)
  - Top correlations: CORP_AA_LOGR(r=-0.75), credit spread, term spread
  - Exhaustive 3-var search (1749 combos), best adj.R²=0.71
- Modified: data/macro_data.py
  - Added GOVT_3Y, CORP_AA, CORP_BBB ECOS queries + fallback data
  - New: compute_derived_features() for optimal 3 predictors
- Modified: main.py
  - Computes derived features + passes combined input to stepwise
  - Scenario paths now include derived features for prediction
- Selected 3 variables: CORP_AA_LOGR, CPI_GROWTH, CREDIT_SPREAD_LAG1
- All 8/8 validation tests pass (incl. R² now Pass)
2026-03-11 06:55:02 +09:00
Variet Agent
8af743e6f3 feat(data): parse 3-agency PDF transition matrices to CSV #task-290
- New: data/parse_pdf_matrices.py (KR/NICE/SCI PDF parser)
  - KR: text-based parser (space-separated numbers + dashes)
  - NICE: text-based parser (clean numeric format)
  - SCI: pdfplumber table extraction (column-position-aware)
  - WR redistribution, B이하→B mapping, CCC extrapolation from PD patterns
- Modified: data/transition_matrices.py (added source='real' loader)
- Modified: config.yaml (data.transition_source: 'real')
- Modified: main.py (reads transition source from config)
- Output: 112 CSV files (KR/NICE/SCI/AVG × 28 years)
2026-03-11 01:07:27 +09:00
Variet Agent
9fba224623 fix(ecos): correct all 6 ECOS API stat/item codes #task-292
- GDP: 111Y002/10111 -> 902Y015/KOR (international comparative stats)
- Unemployment: 901Y027/3 -> 901Y027/I61BC (correct item for rate)
- CD rate: 817Y002/010502000 -> 721Y001/2010000 (market interest rates)
- CPI: now computes YoY growth from level index (pct_change)
- Leading index: monthly (M) fetch + annual average (no annual data available)
- Fix DataFrame merge: dedup index, dropna before concat
- Fix NaN in scenario Z paths: fallback to z_scenario
- Update config.yaml with verified stat codes
2026-03-10 22:53:51 +09:00
Variet Agent
3a9374c61a feat: Lifetime PD (50yr) - Belkin & Suchower + Vasicek model
- Belkin & Suchower (1998) credit cycle index (Zt) estimation via WLS
- Vasicek single-factor conditional PD/TM model
- Macro-Zt OLS regression with stepwise variable selection
- 3-scenario (boom/neutral/recession) 50yr PD projection
- Statistical validation suite (ADF, Ljung-Box, R2, ARCH)
- BOK ECOS API integration with fallback data
- Visualization module (7 chart types)
- Detailed theoretical methodology docs/methodology.md
2026-03-10 21:57:34 +09:00