Esempio n. 1
0
 def test_flat_hazard_with_quote(self):
     Settings.instance().evaluation_date = self.todays_date
     hazard_rate = SimpleQuote()
     flat_curve = FlatHazardRate(2, self.calendar, hazard_rate, Actual365Fixed())
     for h in [0.01, 0.02, 0.03]:
         hazard_rate.value =  h
         self.assertAlmostEqual(flat_curve.survival_probability(self.d),
                                math.exp(-h * flat_curve.time_from_reference(self.d)))
 def test_flat_hazard_with_quote(self):
     Settings.instance().evaluation_date = self.todays_date
     hazard_rate = SimpleQuote()
     flat_curve = FlatHazardRate(2, self.calendar, hazard_rate, Actual365Fixed())
     for h in [0.01, 0.02, 0.03]:
         hazard_rate.value =  h
         self.assertAlmostEqual(flat_curve.survival_probability(self.d),
                                math.exp(-h * flat_curve.time_from_reference(self.d)))
Esempio n. 3
0
 def test_create_flat_hazard(self):
     Settings.instance().evaluation_date = self.todays_date
     flat_curve = FlatHazardRate(2, self.calendar, 0.05, Actual365Fixed())
     flat_curve_from_reference_date = FlatHazardRate.from_reference_date(
         self.calendar.advance(self.todays_date, 2, Days), 0.05, Actual365Fixed())
     self.assertIsNotNone(flat_curve)
     self.assertIsNotNone(flat_curve_from_reference_date)
     self.assertEqual(flat_curve.time_from_reference(self.d),
                      flat_curve_from_reference_date.time_from_reference(self.d))
     self.assertAlmostEqual(flat_curve.hazard_rate(self.d), 0.05)
     self.assertAlmostEqual(flat_curve.survival_probability(self.d),
                            math.exp(-0.05*flat_curve.time_from_reference(self.d)))
 def test_create_flat_hazard(self):
     Settings.instance().evaluation_date = self.todays_date
     flat_curve = FlatHazardRate(2, self.calendar, 0.05, Actual365Fixed())
     flat_curve_from_reference_date = FlatHazardRate.from_reference_date(
         self.calendar.advance(self.todays_date, 2, Days), 0.05, Actual365Fixed())
     self.assertIsNotNone(flat_curve)
     self.assertIsNotNone(flat_curve_from_reference_date)
     self.assertEqual(flat_curve.time_from_reference(self.d),
                      flat_curve_from_reference_date.time_from_reference(self.d))
     self.assertAlmostEqual(flat_curve.hazard_rate(self.d), 0.05)
     self.assertAlmostEqual(flat_curve.survival_probability(self.d),
                            math.exp(-0.05*flat_curve.time_from_reference(self.d)))