<-- Previous || Up || Next -->

Coupon Days Three Way Test Sub
Math Financial Class

Public Sub CouponDaysThreeWayTest()
    'Ensure consistency between the CouponDaysBeforeSettlement, CouponDaysAfterSettlement, and
    ' CouponDays functions.

    Const FmDate = #1/1/1991#
    Const ToDate = #1/1/1998#

    Dim datSettl As Date, datMatur As Date, intFreqLog2%, intFreq%, intBasis%, varBS, varAS, varDS

    For datSettl = FmDate To ToDate
        DoEvents
        If Day(datSettl) = 5 Then datSettl = datSettl + 20
        If Day(datSettl) = 1 Then Debug.Print Now, datSettl

        For datMatur = datSettl + 1 To ToDate
            If Day(datMatur) = 5 Then datMatur = datMatur + 20

            For intFreqLog2 = 0 To 2
                intFreq = 2 ^ intFreqLog2

                For intBasis = 0 To 4
                    If intBasis <> Actual_360 _
                    And intBasis <> Actual_365 Then
                        varBS = CouponDaysBeforeSettlement(datSettl, datMatur, intFreq, intBasis, False)
                        varAS = CouponDaysAfterSettlement(datSettl, datMatur, intFreq, intBasis)
                        varDS = CouponDays(datSettl, datMatur, intFreq, intBasis)

                        If varBS + varAS <> varDS Then
                            Debug.Print datSettl, datMatur, intFreq & ", " & intBasis, varBS, varAS, varBS + varAS, varDS
                        End If
                    End If
                Next intBasis
            Next intFreqLog2
        Next datMatur
    Next datSettl

End Sub

Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.