# Rate Models Audit — Round 3

Third pass over all rate models to verify accuracy and detect any remaining bugs or inconsistencies.

---

## 1. Implementation Verification

### 1.1 BaseRateModel (base.py)

| Check | Status |
|-------|--------|
| Parameter validation | OK |
| TOML from_config / to_config | OK |
| get_metadata() | OK |
| Class attributes for deterministic/constant | OK |

### 1.2 Built-in Models (builtin.py, _builtin_impl.py)

| Model | Status | Notes |
|-------|--------|-------|
| Trailing30, Optimistic, Conservative | OK | |
| UserRateModel | OK | Length-4 validation |
| HistoricalRateModel | OK | to defaults to frm |
| HistoricalAverageRateModel | OK | |
| GaussianRateModel | OK | |
| LognormalRateModel | OK | means > -100% validated |
| HistolognormalRateModel | OK | |
| HistogaussianRateModel | OK | |

### 1.3 DataFrameRateModel (dataframe.py)

| Check | Status |
|-------|--------|
| Class attributes, validation, programmatic-only note | OK |

### 1.4 BootstrapSORRateModel (bootstrap_sor.py)

| Check | Status |
|-------|--------|
| All bootstrap types, crisis weighting | OK |
| Redundant weights.sum() removed | OK (fixed in round 2) |

### 1.5 VARRateModel, GARCHDCCRateModel

| Check | Status |
|-------|--------|
| OLS, spectral shrinkage, Cholesky | OK |
| GARCH + DCC two-step, generation loop | OK |

---

## 2. Naming Consistency

| Item | Status |
|------|--------|
| Class: HistogaussianRateModel (was HistochasticRateModel) | OK (renamed in round 2) |
| Alias: HistochasticRateModel = HistogaussianRateModel | OK |
| **Function: `generate_histochastic_series` in _builtin_impl** | **Inconsistent** — still uses "histochastic"; consider renaming to `generate_histogaussian_series` for consistency |

---

## 3. Validation Gaps

| Model | Gap | Severity |
|-------|-----|----------|
| **GaussianRateModel** | No validation that stdev ≥ 0 | Low — negative stdev would produce invalid covariance |
| **LognormalRateModel** | No validation that stdev ≥ 0 | Low — same as above |
| **generate_histolognormal_series** | If any historical return = -100%, log(1+r)=log(0)=-inf | Very low — rare in real data; data quality issue |
| **UserRateModel** | No validation for NaN/inf in values | Very low — would propagate to output |

---

## 4. Data and Constants

| Check | Status |
|-------|--------|
| rates.csv columns match REQUIRED_RATE_COLUMNS | OK |
| README.md column names | OK (fixed in round 2) |
| Loader registry ↔ constants sync | OK |

---

## 5. Summary

### Resolved (from prior rounds)

- HistogaussianRateModel class rename
- README column names
- BootstrapSOR redundant normalization
- Lognormal means > -100% validation

### Remaining (low priority)

1. **Naming**: Rename `generate_histochastic_series` → `generate_histogaussian_series` in _builtin_impl.py for consistency with HistogaussianRateModel.
2. **Validation**: Add stdev ≥ 0 check in `generate_stochastic_series` and `generate_lognormal_series` (or in GaussianRateModel/LognormalRateModel __init__).

### No critical issues found

All rate models produce correct (N, 4) decimal arrays. Mathematical formulations are correct. Config flow and TOML serialization work as intended.
