-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathtestSwapPricing.py
More file actions
58 lines (48 loc) · 1.14 KB
/
testSwapPricing.py
File metadata and controls
58 lines (48 loc) · 1.14 KB
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
import QuantLib as ql
import QuantLibWrapper.YieldCurve as yc
import QuantLibWrapper.Swap as sw
today = ql.Date(3,9,2018)
ql.Settings.setEvaluationDate(ql.Settings.instance(),today)
terms = [ \
'1y', \
'2y', \
'3y', \
'4y', \
'5y', \
'6y', \
'7y', \
'8y', \
'9y', \
'10y',\
'12y',\
'15y',\
'20y',\
'25y',\
'30y' ]
rates = [ \
2.70e-2,\
2.75e-2,\
2.80e-2,\
3.00e-2,\
3.36e-2,\
3.68e-2,\
3.97e-2,\
4.24e-2,\
4.50e-2,\
4.75e-2,\
4.75e-2,\
4.70e-2,\
4.50e-2,\
4.30e-2,\
4.30e-2 ]
rates2 = [ r+0.005 for r in rates ]
discCurve = yc.YieldCurve(terms,rates)
projCurve = yc.YieldCurve(terms,rates2)
startDate = ql.Date(30, 10, 2018)
endDate = ql.Date(30, 10, 2038)
swap = sw.Swap(startDate,endDate,0.05,discCurve,projCurve)
print('NPV: %11.2f' % (swap.npv()))
print('FairRate: %11.6f' % (swap.fairRate()))
print('Annuity: %11.2f' % (swap.annuity()))
print(swap.fixedCashFlows())
print(swap.floatCashFlows())