def test_zero_rate_curve(self):
        rate = 0.02
        curve = ZeroRateCurve(self.domain, [rate] * self.len)
        for d in self.domain:
            for p in self.periods:
                self.assertAlmostEqual(curve.get_discount_factor(d + p, d + p),
                                       1.)

                self.assertAlmostEqual(curve.get_zero_rate(self.today, d + p),
                                       rate)
                self.assertAlmostEqual(curve.get_short_rate(d + p), rate)
                yf = curve.day_count(d + p, (d + p) + curve.forward_tenor)
                cr = simple_compounding(curve.get_cash_rate(d + p), yf)
                self.assertAlmostEqual(continuous_rate(cr, yf), rate)
 def test_discount_factor_curve(self):
     zr_curve = ZeroRateCurve([self.today, self.today + '1d'], [.02, .02])
     df_curve = DiscountFactorCurve(
         zr_curve.domain,
         [1., zr_curve.get_discount_factor(self.today + '1d')])
     for p in self.periods:
         x = self.today + p
         self.assertAlmostEqual(df_curve.get_discount_factor(x, x), 1.)
         z = zr_curve.get_zero_rate(x)
         d = df_curve.get_zero_rate(x)
         self.assertAlmostEqual(z, d)
         z = zr_curve.get_discount_factor(x)
         d = df_curve.get_discount_factor(x)
         self.assertAlmostEqual(z, d)
         z = zr_curve.get_short_rate(x)
         d = df_curve.get_short_rate(x)
         self.assertAlmostEqual(z, d)
         z = zr_curve.get_cash_rate(x)
         d = df_curve.get_cash_rate(x)
         self.assertAlmostEqual(z, d)