Skip to content

Commit 59558be

Browse files
committed
modified BPV calculation
1 parent 0cfcc73 commit 59558be

File tree

2 files changed

+69
-77
lines changed

2 files changed

+69
-77
lines changed

financepy/products/rates/ibor_swap.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,11 @@ def payer_side_BPV(self, value_dt, discount_curve,payment_periods: float,):
481481
times one basis point (0.0001)
482482
"""
483483
bp=0.0001
484+
# Get coupon frequency
485+
coupon_frequency = self.fixed_leg.freq_type.value
484486
modi_dur = self.payer_side_modified_duration(value_dt, discount_curve,payment_periods)
485-
return modi_dur*self.fixed_leg.notional*bp
487+
annualized_modi_dur= modi_dur/coupon_frequency
488+
return annualized_modi_dur*self.fixed_leg.notional*bp
486489

487490
###########################################################################
488491

notebooks/products/rates/FINIBORSWAP_ReplicationgBONDMATHDurationExample3M.ipynb

Lines changed: 65 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,24 @@
66
"metadata": {
77
"collapsed": true,
88
"ExecuteTime": {
9-
"end_time": "2025-05-23T02:54:25.031837Z",
10-
"start_time": "2025-05-23T02:54:25.027815Z"
9+
"end_time": "2025-05-23T03:01:38.516595Z",
10+
"start_time": "2025-05-23T03:01:38.512089Z"
1111
}
1212
},
1313
"source": [
1414
"from financepy.utils import *\n",
1515
"from financepy.products.rates import *\n",
1616
"from financepy.market.curves import *\n",
17-
"import datetime as dt\n",
18-
"\n",
19-
"from notebooks.products.rates.FINIBORSWAP_ReplicationgBONDMATHDurationExample import payment_periods"
17+
"import datetime as dt\n"
2018
],
2119
"outputs": [],
22-
"execution_count": 34
20+
"execution_count": 22
2321
},
2422
{
2523
"metadata": {
2624
"ExecuteTime": {
27-
"end_time": "2025-05-23T02:54:25.043454Z",
28-
"start_time": "2025-05-23T02:54:25.039940Z"
25+
"end_time": "2025-05-23T03:01:38.528444Z",
26+
"start_time": "2025-05-23T03:01:38.524597Z"
2927
}
3028
},
3129
"cell_type": "code",
@@ -65,13 +63,13 @@
6563
],
6664
"id": "1ebf43316efee835",
6765
"outputs": [],
68-
"execution_count": 35
66+
"execution_count": 23
6967
},
7068
{
7169
"metadata": {
7270
"ExecuteTime": {
73-
"end_time": "2025-05-23T02:54:25.056980Z",
74-
"start_time": "2025-05-23T02:54:25.052895Z"
71+
"end_time": "2025-05-23T03:01:38.542275Z",
72+
"start_time": "2025-05-23T03:01:38.537531Z"
7573
}
7674
},
7775
"cell_type": "code",
@@ -91,18 +89,18 @@
9189
"31-MAR-2024"
9290
]
9391
},
94-
"execution_count": 36,
92+
"execution_count": 24,
9593
"metadata": {},
9694
"output_type": "execute_result"
9795
}
9896
],
99-
"execution_count": 36
97+
"execution_count": 24
10098
},
10199
{
102100
"metadata": {
103101
"ExecuteTime": {
104-
"end_time": "2025-05-23T02:54:25.078736Z",
105-
"start_time": "2025-05-23T02:54:25.073700Z"
102+
"end_time": "2025-05-23T03:01:38.569014Z",
103+
"start_time": "2025-05-23T03:01:38.564129Z"
106104
}
107105
},
108106
"cell_type": "code",
@@ -125,13 +123,13 @@
125123
],
126124
"id": "290b7a06932da41d",
127125
"outputs": [],
128-
"execution_count": 37
126+
"execution_count": 25
129127
},
130128
{
131129
"metadata": {
132130
"ExecuteTime": {
133-
"end_time": "2025-05-23T02:54:25.092695Z",
134-
"start_time": "2025-05-23T02:54:25.087190Z"
131+
"end_time": "2025-05-23T03:01:38.585724Z",
132+
"start_time": "2025-05-23T03:01:38.579955Z"
135133
}
136134
},
137135
"cell_type": "code",
@@ -144,18 +142,18 @@
144142
"0.030065619962567392"
145143
]
146144
},
147-
"execution_count": 38,
145+
"execution_count": 26,
148146
"metadata": {},
149147
"output_type": "execute_result"
150148
}
151149
],
152-
"execution_count": 38
150+
"execution_count": 26
153151
},
154152
{
155153
"metadata": {
156154
"ExecuteTime": {
157-
"end_time": "2025-05-23T02:54:25.120452Z",
158-
"start_time": "2025-05-23T02:54:25.116135Z"
155+
"end_time": "2025-05-23T03:01:38.610747Z",
156+
"start_time": "2025-05-23T03:01:38.606021Z"
159157
}
160158
},
161159
"cell_type": "code",
@@ -168,18 +166,18 @@
168166
"-404094.769553849"
169167
]
170168
},
171-
"execution_count": 39,
169+
"execution_count": 27,
172170
"metadata": {},
173171
"output_type": "execute_result"
174172
}
175173
],
176-
"execution_count": 39
174+
"execution_count": 27
177175
},
178176
{
179177
"metadata": {
180178
"ExecuteTime": {
181-
"end_time": "2025-05-23T02:54:25.148481Z",
182-
"start_time": "2025-05-23T02:54:25.143313Z"
179+
"end_time": "2025-05-23T03:01:38.645126Z",
180+
"start_time": "2025-05-23T03:01:38.640384Z"
183181
}
184182
},
185183
"cell_type": "code",
@@ -192,18 +190,18 @@
192190
"-6.794198629548404"
193191
]
194192
},
195-
"execution_count": 40,
193+
"execution_count": 28,
196194
"metadata": {},
197195
"output_type": "execute_result"
198196
}
199197
],
200-
"execution_count": 40
198+
"execution_count": 28
201199
},
202200
{
203201
"metadata": {
204202
"ExecuteTime": {
205-
"end_time": "2025-05-23T02:54:25.169741Z",
206-
"start_time": "2025-05-23T02:54:25.164469Z"
203+
"end_time": "2025-05-23T03:01:38.686342Z",
204+
"start_time": "2025-05-23T03:01:38.681347Z"
207205
}
208206
},
209207
"cell_type": "code",
@@ -216,18 +214,18 @@
216214
"6.794198629548404"
217215
]
218216
},
219-
"execution_count": 41,
217+
"execution_count": 29,
220218
"metadata": {},
221219
"output_type": "execute_result"
222220
}
223221
],
224-
"execution_count": 41
222+
"execution_count": 29
225223
},
226224
{
227225
"metadata": {
228226
"ExecuteTime": {
229-
"end_time": "2025-05-23T02:54:25.199176Z",
230-
"start_time": "2025-05-23T02:54:25.193898Z"
227+
"end_time": "2025-05-23T03:01:38.722907Z",
228+
"start_time": "2025-05-23T03:01:38.717909Z"
231229
}
232230
},
233231
"cell_type": "code",
@@ -240,18 +238,18 @@
240238
"-6.743511664816526"
241239
]
242240
},
243-
"execution_count": 42,
241+
"execution_count": 30,
244242
"metadata": {},
245243
"output_type": "execute_result"
246244
}
247245
],
248-
"execution_count": 42
246+
"execution_count": 30
249247
},
250248
{
251249
"metadata": {
252250
"ExecuteTime": {
253-
"end_time": "2025-05-23T02:54:25.228763Z",
254-
"start_time": "2025-05-23T02:54:25.224367Z"
251+
"end_time": "2025-05-23T03:01:38.756278Z",
252+
"start_time": "2025-05-23T03:01:38.751727Z"
255253
}
256254
},
257255
"cell_type": "code",
@@ -264,18 +262,18 @@
264262
"6.743511664816526"
265263
]
266264
},
267-
"execution_count": 43,
265+
"execution_count": 31,
268266
"metadata": {},
269267
"output_type": "execute_result"
270268
}
271269
],
272-
"execution_count": 43
270+
"execution_count": 31
273271
},
274272
{
275273
"metadata": {
276274
"ExecuteTime": {
277-
"end_time": "2025-05-23T02:54:25.264697Z",
278-
"start_time": "2025-05-23T02:54:25.260233Z"
275+
"end_time": "2025-05-23T03:01:38.790007Z",
276+
"start_time": "2025-05-23T03:01:38.786002Z"
279277
}
280278
},
281279
"cell_type": "code",
@@ -325,13 +323,13 @@
325323
]
326324
}
327325
],
328-
"execution_count": 44
326+
"execution_count": 32
329327
},
330328
{
331329
"metadata": {
332330
"ExecuteTime": {
333-
"end_time": "2025-05-23T02:54:25.286790Z",
334-
"start_time": "2025-05-23T02:54:25.282897Z"
331+
"end_time": "2025-05-23T03:01:38.821049Z",
332+
"start_time": "2025-05-23T03:01:38.816897Z"
335333
}
336334
},
337335
"cell_type": "code",
@@ -363,13 +361,13 @@
363361
]
364362
}
365363
],
366-
"execution_count": 45
364+
"execution_count": 33
367365
},
368366
{
369367
"metadata": {
370368
"ExecuteTime": {
371-
"end_time": "2025-05-23T02:54:25.315781Z",
372-
"start_time": "2025-05-23T02:54:25.311063Z"
369+
"end_time": "2025-05-23T03:01:38.907291Z",
370+
"start_time": "2025-05-23T03:01:38.903054Z"
373371
}
374372
},
375373
"cell_type": "code",
@@ -401,13 +399,13 @@
401399
]
402400
}
403401
],
404-
"execution_count": 46
402+
"execution_count": 34
405403
},
406404
{
407405
"metadata": {
408406
"ExecuteTime": {
409-
"end_time": "2025-05-23T02:54:25.345988Z",
410-
"start_time": "2025-05-23T02:54:25.341966Z"
407+
"end_time": "2025-05-23T03:01:39.014637Z",
408+
"start_time": "2025-05-23T03:01:39.009932Z"
411409
}
412410
},
413411
"cell_type": "code",
@@ -424,18 +422,18 @@
424422
"-404610.6998889916"
425423
]
426424
},
427-
"execution_count": 47,
425+
"execution_count": 35,
428426
"metadata": {},
429427
"output_type": "execute_result"
430428
}
431429
],
432-
"execution_count": 47
430+
"execution_count": 35
433431
},
434432
{
435433
"metadata": {
436434
"ExecuteTime": {
437-
"end_time": "2025-05-23T02:54:25.433818Z",
438-
"start_time": "2025-05-23T02:54:25.427828Z"
435+
"end_time": "2025-05-23T03:01:39.056730Z",
436+
"start_time": "2025-05-23T03:01:39.050609Z"
439437
}
440438
},
441439
"cell_type": "code",
@@ -448,18 +446,18 @@
448446
"404610.6998889916"
449447
]
450448
},
451-
"execution_count": 48,
449+
"execution_count": 36,
452450
"metadata": {},
453451
"output_type": "execute_result"
454452
}
455453
],
456-
"execution_count": 48
454+
"execution_count": 36
457455
},
458456
{
459457
"metadata": {
460458
"ExecuteTime": {
461-
"end_time": "2025-05-23T02:54:25.518531Z",
462-
"start_time": "2025-05-23T02:54:25.513863Z"
459+
"end_time": "2025-05-23T03:01:39.100675Z",
460+
"start_time": "2025-05-23T03:01:39.095809Z"
463461
}
464462
},
465463
"cell_type": "code",
@@ -472,36 +470,27 @@
472470
"-40461.06998889916"
473471
]
474472
},
475-
"execution_count": 49,
473+
"execution_count": 37,
476474
"metadata": {},
477475
"output_type": "execute_result"
478476
}
479477
],
480-
"execution_count": 49
478+
"execution_count": 37
481479
},
482480
{
483481
"metadata": {
482+
"jupyter": {
483+
"is_executing": true
484+
},
484485
"ExecuteTime": {
485-
"end_time": "2025-05-23T02:54:25.578843Z",
486-
"start_time": "2025-05-23T02:54:25.574712Z"
486+
"start_time": "2025-05-23T03:01:55.128551Z"
487487
}
488488
},
489489
"cell_type": "code",
490490
"source": "swap.receiver_side_BPV(value_dt, zero_curve,payment_periods)",
491491
"id": "8f8630e90883e3b5",
492-
"outputs": [
493-
{
494-
"data": {
495-
"text/plain": [
496-
"40461.06998889916"
497-
]
498-
},
499-
"execution_count": 50,
500-
"metadata": {},
501-
"output_type": "execute_result"
502-
}
503-
],
504-
"execution_count": 50
492+
"outputs": [],
493+
"execution_count": null
505494
}
506495
],
507496
"metadata": {

0 commit comments

Comments
 (0)