"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
docs(quantlib): describe the CDS hazard as the triangle approximation it is
Haozhe Wu9fd62d33f170
diff --git a/agent/src/quantlib/credit.py b/agent/src/quantlib/credit.pyindex 5cddeb591..8ab96f9fc 100644--- a/agent/src/quantlib/credit.py+++ b/agent/src/quantlib/credit.py@@ -702,12 +702,19 @@ def cds_price(notional: float = 10_000_000.0,payment_frequency: int = 4,) -> dict:- """ISDA standard model single-name Credit Default Swap (CDS) valuation engine.+ """Flat-hazard single-name Credit Default Swap (CDS) valuation engine.Computes the implied hazard rate, survival probability curve, Risky Present Valueof a Basis Point (RPV01), protection leg PV, premium leg PV, fair par spread,and mark-to-market (MTM) upfront cash payment.+ The hazard rate comes from the credit triangle (``lambda = s / (1 - R)``) rather+ than being bootstrapped by root-finding the way the ISDA Standard Model does, so+ ``par_spread_bps`` -- recomputed from the discretised legs -- lands near, not+ exactly on, the quoted ``spread_bps`` (~0.4% apart for a 5y investment-grade+ name). Value the contract against ``par_spread_bps``; read ``hazard_rate`` as the+ triangle approximation it is.+Args:spread_bps: Market quoted par CDS spread in basis points (e.g. 150.0 for 150 bps).recovery_rate: Expected recovery rate on default in [0.0, 1.0) (standard senior unsecured = 0.40).diff --git a/agent/src/quantlib/eventstudy.py b/agent/src/quantlib/eventstudy.pyindex be00368ba..3485179a2 100644--- a/agent/src/quantlib/eventstudy.py+++ b/agent/src/quantlib/eventstudy.py@@ -59,6 +59,7 @@ from dataclasses import dataclassimport numpy as npimport pandas as pdfrom scipy.stats import norm, rankdata, t as student_t+__all__ = ["DEFAULT_ESTIMATION_GAP","DEFAULT_ESTIMATION_WINDOW",@@ -178,6 +179,7 @@ class EventStudyResult:cowan_sign_p_value: Two-sided p-value of ``cowan_sign_z``.positive_car_fraction: Fraction of events with positive cumulative abnormal return."""+event_window: tuple[int, int]events: tuple[EventOutcome, ...]dropped: tuple[tuple[str, object, str], ...]