# ─── Figure: Dynamic vs Static CRI Comparison ────────────────────────────────
fig, axes = plt.subplots(3, 1, figsize=(14, 14), sharex=True)
# USD
axes[0].plot(dyn_dates, CRI_static_usd, color='#90CAF9', linewidth=1.2, alpha=0.7, linestyle='--', label='Static CRI (USD)')
axes[0].plot(dyn_dates, CRI_dyn_usd, color='#0D47A1', linewidth=1.8, label='Dynamic CRI (USD)')
axes[0].axvspan(pd.Timestamp('2020-01-01'), pd.Timestamp('2021-12-31'), alpha=0.1, color='grey')
axes[0].axhline(y=0.3, color='green', linestyle=':', alpha=0.3)
axes[0].axhline(y=0.6, color='orange', linestyle=':', alpha=0.3)
axes[0].set_title('USD — Dynamic vs Static Credit Risk Index', fontweight='bold')
axes[0].set_ylabel('CRI')
axes[0].legend(loc='upper right', fontsize=9)
axes[0].grid(True, alpha=0.3)
axes[0].set_ylim(-0.02, 1.02)
# KHR
axes[1].plot(dyn_dates, CRI_static_khr, color='#EF9A9A', linewidth=1.2, alpha=0.7, linestyle='--', label='Static CRI (KHR)')
axes[1].plot(dyn_dates, CRI_dyn_khr, color='#B71C1C', linewidth=1.8, label='Dynamic CRI (KHR)')
axes[1].axvspan(pd.Timestamp('2020-01-01'), pd.Timestamp('2021-12-31'), alpha=0.1, color='grey')
axes[1].axhline(y=0.3, color='green', linestyle=':', alpha=0.3)
axes[1].axhline(y=0.6, color='orange', linestyle=':', alpha=0.3)
axes[1].set_title('KHR — Dynamic vs Static Credit Risk Index', fontweight='bold')
axes[1].set_ylabel('CRI')
axes[1].legend(loc='upper right', fontsize=9)
axes[1].grid(True, alpha=0.3)
axes[1].set_ylim(-0.02, 1.02)
# System
axes[2].plot(dyn_dates, CRI_static_sys, color='#CE93D8', linewidth=1.2, alpha=0.7, linestyle='--', label='Static System CRI (80/20)')
axes[2].plot(dyn_dates, CRI_dyn_sys, color='#4A148C', linewidth=1.8, label='Dynamic System CRI (80/20)')
axes[2].axvspan(pd.Timestamp('2020-01-01'), pd.Timestamp('2021-12-31'), alpha=0.1, color='grey')
axes[2].axhline(y=0.3, color='green', linestyle=':', alpha=0.3)
axes[2].axhline(y=0.6, color='orange', linestyle=':', alpha=0.3)
axes[2].set_title('System — Dynamic vs Static Credit Risk Index (80/20 Loan-Share)', fontweight='bold')
axes[2].set_ylabel('CRI')
axes[2].set_xlabel('Date')
axes[2].legend(loc='upper right', fontsize=9)
axes[2].grid(True, alpha=0.3)
axes[2].set_ylim(-0.02, 1.02)
axes[2].xaxis.set_major_locator(mdates.YearLocator())
axes[2].xaxis.set_major_formatter(mdates.DateFormatter('%Y'))
plt.xticks(rotation=45)
fig.suptitle('Figure 15: Dynamic vs Static CRI — Full Comparison', fontweight='bold', fontsize=14, y=1.01)
plt.tight_layout()
plt.savefig('../figures/fig15_dynamic_vs_static_cri.png', dpi=300, bbox_inches='tight')
plt.show()
print('Saved: fig15_dynamic_vs_static_cri.png')