from .date cimport TDateInterval, TStubMethod from .curve cimport TCurve ctypedef int TBoolean ctypedef long TDate cdef extern from "isda/cx.h": ctypedef struct TContingentLeg: TDate startDate TDate endDate double notional TBoolean protectStart ctypedef enum TAccrualPayConv: pass ctypedef struct TFeeLeg: int nbDates TDate* accStartDates TDate* accEndDates TDate* payDates double notional double couponRate long dcc TAccrualPayConv accrualPayConv TBoolean obsStartOfDay cdef extern from "isda/bastypes.h": ctypedef struct TCashFlow: TDate fDate double fAmount ctypedef struct TCashFlowList: int fNumItems TCashFlow *fArray cdef extern from "isda/cds.h" nogil: cdef TContingentLeg* JpmcdsCdsContingentLegMake( # Date when protection begins. Either at start or end of day (depends # on protectStart) TDate startDate, # Date when protection ends (end of day) TDate endDate, # Notional value protected double notional, # Should protection include the start date TBoolean protectStart) cdef TFeeLeg* JpmcdsCdsFeeLegMake( # Date when protection begins. Either at start or end of day (depends # on protectStart) TDate startDate, # Date when protection ends (end of day) TDate endDate, # Should accrued interest be paid on default. Usually set to TRUE TBoolean payAccOnDefault, # Interval between coupon payments. Can be NULL when 3M is assumed TDateInterval *couponInterval, # If the startDate and endDate are not on cycle, then this parameter # determines location of coupon dates. TStubMethod *stubType, # Notional value protected double notional, # Fixed coupon rate (a.k.a. spread) for the fee leg double couponRate, # Day count convention for coupon payment. Normal is ACT_360 long paymentDcc, # Bad day convention for adjusting coupon payment dates. long badDayConv, # Calendar used when adjusting coupon dates. Can be NULL which equals # a calendar with no holidays and including weekends. const char *calendar, # Should protection include the start date */ TBoolean protectStart) cdef extern from "isda/contingentleg.h" nogil: cdef int JpmcdsContingentLegPV(TContingentLeg *cl, # Contingent leg TDate today, # No observations before today TDate valueDate, # Value date for discounting TDate stepinDate, # Step-in date TCurve *discountCurve, # Risk-free curve TCurve *spreadCurve, # Spread curve double recoveryRate, # Recovery rate double *pv) cdef extern from "isda/feeleg.h" nogil: cdef int JpmcdsFeeLegPV(TFeeLeg *fl, TDate today, TDate stepinDate, TDate valueDate, TCurve *discCurve, TCurve *spreadCurve, TBoolean payAccruedAtStart, double *pv) cdef TCashFlowList* JpmcdsFeeLegFlows(TFeeLeg *fl) cdef void JpmcdsFeeLegFree(TFeeLeg *p) cdef void FeeLegAI(TFeeLeg* fl, TDate today, double* ai) cdef class ContingentLeg: cdef TContingentLeg* _thisptr cdef class FeeLeg: cdef TFeeLeg* _thisptr cdef void fee_leg_copy(TFeeLeg* orig, TFeeLeg* copy) noexcept nogil