@@ -51,3 +51,31 @@ module SpotTests =
51
51
tryTBillPrice sd md disc
52
52
==>
53
53
lazy ( Financial.TBillPrice( sd, md, disc) - 100. < PRECISION))
54
+
55
+ [<Test>]
56
+ let ``vdb in the period should be the same as the sum by subperiods`` () =
57
+ fsCheck ( fun c s len switchToStraightLine ->
58
+ let start , life = 0. , 10.
59
+ let cost , salvage , period = toFloat c * 1000. , toFloat s * 100. , toFloat len
60
+ let p1 , p2 = period, period * 2.
61
+
62
+ tryVdb cost salvage life start p2 1. switchToStraightLine
63
+ ==>
64
+ lazy ( let inline vdb sd ed = Financial.Vdb( cost, salvage, life, sd, ed, 1. , switchToStraightLine)
65
+ abs ( vdb start p1 + vdb p1 p2 - vdb start p2) < PRECISION))
66
+
67
+ [<Test>]
68
+ let ``cumulative accrint should be the same as the sum of payments`` () =
69
+ fsCheck ( fun ( issue : DateTime ) p r freq basis frac ->
70
+ let par , rate = toFloat p * 1000000. , toFloat r
71
+ let fd , md = issue.AddDays 30. , issue.AddYears 10
72
+ let ncd = Financial.CoupNCD( fd, md, freq, basis)
73
+
74
+ tryAccrInt issue ncd fd rate par freq basis
75
+ ==>
76
+ lazy ( let inline accrint interest settlement =
77
+ Financial.AccrInt( issue, interest, settlement, rate, par, freq, basis)
78
+
79
+ let daysTillInterest = max ( 360. / float freq * toFloat frac) 1.
80
+ let interest = ncd.AddDays daysTillInterest
81
+ abs ( accrint ncd fd + accrint interest ncd - accrint interest fd) < PRECISION))
0 commit comments