def build_fixed_income_html(model_info, cfg, weights): fixed_income_html = "" port_dur = model_info.get("portfolio_duration", 0.0) bond_meta = cfg.get("bond_metadata", {}) bonds_in_port = [t for t in weights.index if t in bond_meta and abs(weights.get(t, 0)) > 0.001] if bonds_in_port or port_dur > 0.01: fi_rows = "" for t in bonds_in_port: w_pct = weights.get(t, 0) * 100 meta = bond_meta[t] dur = meta.get("modified_duration", 0.0) cpn = meta.get("coupon", 0.0) fi_rows += ( f"{t}" f"{w_pct:.1f}%" f"{dur:.2f} yrs" f"{cpn*100:.2f}%\n" ) fixed_income_html = ( f'

Fixed Income Profile

' f'
Portfolio Duration
' f'
{port_dur:.2f} yrs
' ) if fi_rows: fixed_income_html += ( f'
' f'' f'{fi_rows}
BondWeightDurationCoupon
' ) return fixed_income_html