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
|
from cdsone cimport TStubMethod
cdef extern from "isda/zerocurve.h":
ctypedef int TBoolean
ctypedef long int TDate
ctypedef struct TDateInterval:
pass
TCurve* JpmcdsBuildIRZeroCurve(TDate valueDate,
char* instrNames,
TDate* dates,
double* rates,
long nInstr,
long mmDCC,
long fixedSwapFreq,
long floatSwapFreq,
long fixedSwapDCC,
long floatSwapDCC,
long badDayConv,
char* holidayFile)
cdef extern from "isda/bastypes.h":
ctypedef struct TCurve:
int fNumItems
TRatePt* fArray
TDate fBaseDate
double fBasis
long fDayCountConv
ctypedef struct TRatePt:
TDate fDate
double fRate
cdef extern from "isda/cds.h":
TCurve* JpmcdsCleanSpreadCurve(
# Risk starts at the end of today
TDate today,
# Interest rate discount curve - assumes flat forward interpolation
TCurve *discCurve,
# Effective date of the benchmark CDS
TDate startDate,
# Step in date of the benchmark CDS
TDate stepinDate,
# Date when payment should be make
TDate cashSettleDate,
# Number of benchmark dates
long nbDate,
# Dates when protection ends for each benchmark (end of day).
# Array of size nbDate
TDate *endDates,
# Coupon rates for each benchmark instrument. Array of size nbDate
double *couponRates,
# Flags to denote that we include particular benchmarks. This makes it
# easy for the user to include or exclude benchmarks on a one-by-one
# basis. Can be NULL if all are included. Otherwise an array of size
# nbDate.
TBoolean *includes,
# Recovery rate in case of default
double recoveryRate,
# 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,
# Day count convention for coupon payment. Normal is ACT_360
long paymentDcc,
# If the startDate and endDate are not on cycle, then this parameter
# determines location of coupon dates. */
TStubMethod *stubType,
# 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
)
cdef extern from "isda/tcurve.h":
void JpmcdsFreeTCurve(TCurve* curve)
TCurve* JpmcdsMakeTCurve(TDate baseDate,
TDate *dates,
double *rates,
int numPts,
double basis,
long dayCountConv);
cdef extern from "isda/cxzerocurve.h":
double JpmcdsZeroPrice(TCurve* curve, TDate date)
cdef enum Basis:
CONTINUOUS = 5000
DISCOUNT_RATE = 512
SIMPLE_BASIS = 0
ANNUAL_BASIS = 1
DISCOUNT_FACTOR = -2
cdef class Curve:
cdef TCurve* _thisptr
cdef class ZeroCurve(Curve):
cdef TDate* _dates
cdef size_t _ninstr
cdef class SpreadCurve(Curve):
pass
cdef fArray_to_list(TRatePt* fArray, int fNumItems)
|