{
  "markdown": "# visual-factor-timing\n\nReplication of **Jia, Li, Zhang & Zhao (2025), \"Timing the Factor Zoo via Deep Visualization\"** applied to the T2 and GDELT factor panels.\n\n## Approach\nPer-factor historical return trajectories are rendered as two complementary images — a JKX-style OHLC candlestick chart with a moving-average overlay and a monthly realized-volatility strip, and an MXX-style cumulative-return bar chart — then processed by CNN and CNN-LSTM networks to produce factor-specific timing weights.\n\n## Data sources\nExternal xlsx files live outside the repo:\n- **T2 daily**   — `A Complete/T2 Factor Timing Fuzzy Daily/T2_Optimizer.xlsx`\n- **T2 monthly** — `A Complete/T2 Factor Timing Fuzzy/T2_Optimizer.xlsx`\n- **GDELT daily**   — `A Complete/GDELT Factor Timing Fuzzy Daily/T2-Factor-Timing-Daily/GDELT_Optimizer.xlsx`\n- **GDELT monthly** — `A Complete/T2 GDELT/GDELT_Optimizer.xlsx`\n\nDaily returns are stored in percent; the loader rescales before cumulating.\n\n## Pipeline\n```\nfactor_timing/\n  data/factor_loader.py      daily returns → synthetic price → monthly OHLC + vol parquet\n  imaging/build_cache.py     monthly OHLC → JKX image memmap cache (window=12 or 24)\n  (planned)\n  imaging/mxx_renderer.py    cumulative-return trajectory (1D CNN input)\n  models/cnn.py              1D CNN (64 filters, kernel 5, SiLU, dropout 0.25)\n  models/cnn_lstm.py         CNN + LSTM(64) variant\n  train/targets.py           raw, σ-standardized, Φ⁻¹, percentile targets; EW/EWPM weighting\n  train/ensemble.py          64-model IC-weighted ensemble\n  train/clustering.py        expanding-window Ward k=8 clustering for GDELT pooled training\n  backtest/factor_timing.py  IC tables, α tables, OOS R², HML quintile sort\n  backtest/mechanism.py      LTA, risk aversion, macro PC analysis\n```\n\n## Build\n\n```bash\n# T2\npython -m factor_timing.data.factor_loader --panel t2\npython -m factor_timing.imaging.build_cache --panel t2 --window 12\npython -m factor_timing.imaging.build_cache --panel t2 --window 24\n\n# GDELT\npython -m factor_timing.data.factor_loader --panel gdelt\npython -m factor_timing.imaging.build_cache --panel gdelt --window 12\npython -m factor_timing.imaging.build_cache --panel gdelt --window 24\n```\n\n## Training strategy\n- **T2** (83 factors, ~270 months each): per-factor training per the paper.\n- **GDELT** (86 factors, ~129 months each): pooled training in 8 groups discovered by expanding-window Ward clustering on the factor return correlation matrix — no forward leakage since the clustering is refit at each retrain date using only data available at that point.\n\n## Reference\nJia, Y., Li, J., Zhang, H., & Zhao, J. (2025). Timing the Factor Zoo via Deep Visualization. *Working paper, March 24, 2025.*\n",
  "bytes": 2712,
  "sha": "61cb67112b5b2e4e49de2e93547ae5a538b06b916d8d0ffa2cf48440655aaeb7",
  "repo_slug": "arjundivecha/visual-factor-timing",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/okf_arjundivecha_visual_factor_timing_openwi_7d2251b1/readme"
}