Skip to content

Commit a61061b

Browse files
make DV01 per basis point and not per point (#97)
1 parent 19f7053 commit a61061b

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/financial_math.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,10 @@ Calculates the Macaulay, Modified, or DV01 duration. `times` may be ommitted and
277277
278278
When not given `Modified()` or `Macaulay()` as an argument, will default to `Modified()`.
279279
280+
- Modified duration: the relative change per point of yield change.
281+
- Macaulay: the cashflow-weighted average time.
282+
- DV01: the absolute change per basis point (hundredth of a percentage point).
283+
280284
# Examples
281285
282286
Using vectors of cashflows and times
@@ -341,7 +345,7 @@ function duration(d::Duration, yield, cfs)
341345
end
342346

343347
function duration(::DV01, yield, valuation_function::Y) where {Y<:Function}
344-
return duration(yield, valuation_function) * valuation_function(yield) / 100
348+
return duration(yield, valuation_function) * valuation_function(yield) / 10000
345349
end
346350

347351
"""

test/runtests.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,16 @@ end
176176
@test duration(Macaulay(), 0.04, cfs, times) 1.777570320376649
177177
@test duration(Modified(), 0.04, cfs, times) 1.777570320376649 / (1 + 0.04)
178178
@test duration(0.04, cfs, times) 1.777570320376649 / (1 + 0.04)
179-
@test duration(DV01(), 0.04, cfs, times) 1.777570320376649 / (1 + 0.04) * V / 100
179+
180+
# wikipedia example defines DV01 as a per point change, but industry practice is per basis point. Ref Issue #96
181+
@test duration(DV01(), 0.04, cfs, times) 1.777570320376649 / (1 + 0.04) * V / 10000
180182

181183
# test with a Rate
182184
r = Yields.Periodic(0.04,1)
183185
@test duration(Macaulay(), r, cfs, times) 1.777570320376649
184186
@test duration(Modified(), r, cfs, times) 1.777570320376649 / (1 + 0.04)
185187
@test duration(r, cfs, times) 1.777570320376649 / (1 + 0.04)
186-
@test duration(DV01(), r, cfs, times) 1.777570320376649 / (1 + 0.04) * V / 100
188+
@test duration(DV01(), r, cfs, times) 1.777570320376649 / (1 + 0.04) * V / 10000
187189

188190
#test without times
189191
r = Yields.Periodic(0.04,1)

0 commit comments

Comments
 (0)