summaryrefslogtreecommitdiffstats
path: root/pyisda/legs.pxd
blob: d71120510e45a4f96cb211f9d604c36bf6ff6f16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
from date cimport TDate, TDateInterval
from cdsone cimport TStubMethod
from curve cimport TCurve

ctypedef int TBoolean

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":

    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.
        char           *calendar,
        # Should protection include the start date */
        TBoolean        protectStart)



cdef extern from "isda/contingentleg.h":
    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) nogil

cdef extern from "isda/feeleg.h":
   cdef int JpmcdsFeeLegPV(TFeeLeg *fl,
                           TDate today,
                           TDate stepinDate,
                           TDate valueDate,
                           TCurve *discCurve,
                           TCurve *spreadCurve,
                           TBoolean payAccruedAtStart,
                           double *pv) nogil

   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