Exemplo n.º 1
0
 def testBondEquivalentYieldForMaturityOver182Days(self):
     self.assertAlmostEqual(
         discountInstrumentBondEquivalentYield(8, 182,
                                               ACT360_DAYS_IN_YEAR(),
                                               ACT365_DAYS_IN_YEAR()),
         8.4530, 4)
     self.assertAlmostEqual(
         discountInstrumentBondEquivalentYield(8, 183,
                                               ACT360_DAYS_IN_YEAR(),
                                               ACT365_DAYS_IN_YEAR()),
         8.4540, 2)
Exemplo n.º 2
0
 def testCleanBondPriceNoAccrued(self):
     self.assertAlmostEqual(
         cleanBondPrice(100, 6, 3, 1, 9, 0, 100, ACT360_DAYS_IN_YEAR()),
         dirtyBondPrice(100, 6, 3, 1, 9, 100, ACT360_DAYS_IN_YEAR()), 2)
Exemplo n.º 3
0
 def testCleanBondPrice(self):
     self.assertAlmostEqual(
         cleanBondPrice(100, 6, 3, 1, 9, 260, 100, ACT360_DAYS_IN_YEAR(),
                        ACT360_DAYS_IN_YEAR()), 121.69, 2)
Exemplo n.º 4
0
 def testBondAccruedCoupon(self):
     self.assertAlmostEqual(
         bondAccruedInterest(100, 6, 260, ACT360_DAYS_IN_YEAR()), 4.3333, 4)
Exemplo n.º 5
0
 def testFRASettlementPriceFromFuture(self):
     self.assertAlmostEqual(
         forwardRateAgreementSettlementPriceFromFuturePrice(
             1000000, 95.25, 6.5, 100, ACT360_DAYS_IN_YEAR()), -4774.90, 2)
Exemplo n.º 6
0
 def testFRASettlementPrice(self):
     self.assertAlmostEqual(
         forwardRateAgreementSettlementPrice(1000000, 3, 1.5, 100,
                                             ACT360_DAYS_IN_YEAR()),
         4149.38, 2)
Exemplo n.º 7
0
 def testBondCashAndCarryArbitrage(self):
     self.assertAlmostEqual(
         bondCashAndCarryArbitrage(100000, 105, 104, 10.2, 2.1, 2.8, 1.034,
                                   100, ACT360_DAYS_IN_YEAR()), 194.87, 2)
Exemplo n.º 8
0
 def testDirtyBondPrice(self):
     self.assertAlmostEqual(
         dirtyBondPrice(100, 6, 3, 1, 9, 100, ACT360_DAYS_IN_YEAR()),
         126.0201, 4)
Exemplo n.º 9
0
 def testBondFuturesHedgeNotional(self):
     self.assertAlmostEqual(
         bondFuturesHedgeNotional(1000000, 5.4, 1.0087, 100,
                                  ACT360_DAYS_IN_YEAR()), 993793.10, 2)
Exemplo n.º 10
0
 def testBondFuturesPrice(self):
     self.assertAlmostEqual(
         bondFuturesPrice(105, 6, 5.4, 2, 1.0087, 23, 100, 184,
                          ACT360_DAYS_IN_YEAR()), 104.04, 2)
Exemplo n.º 11
0
 def testMoosmullerYieldForBond(self):
     self.assertAlmostEqual(
         bondPriceUsingMoosmullerYield(100, 6, 5.4, 1, 9, 100,
                                       ACT360_DAYS_IN_YEAR()), 108.1931, 4)
Exemplo n.º 12
0
 def testMoneyMarketYieldForBond(self):
     self.assertAlmostEqual(
         bondMoneyMarketYield(100, 107.7133, 6, 1, 9, 100,
                              ACT360_DAYS_IN_YEAR(), ACT365_DAYS_IN_YEAR()),
         5.4, 4)
Exemplo n.º 13
0
 def testBondPriceUsingSimpleInterestForCalculator(self):
     self.assertAlmostEqual(
         bondPriceUsingMoneyMarketYieldForCalculators(
             100, 6, 5.4, 1, 9, 100, ACT360_DAYS_IN_YEAR(),
             ACT365_DAYS_IN_YEAR()), 107.7133, 4)
Exemplo n.º 14
0
 def testNumberOfInterestRateFutureContractsRequiredForHedge(self):
     self.assertAlmostEqual(
         interestRateFutureNumberContracts(3000000, 1000000, 6.5, 100, 90,
                                           ACT360_DAYS_IN_YEAR()), 3, 0)
Exemplo n.º 15
0
 def testDirtyBondPriceFormulationResults(self):
     self.assertAlmostEqual(
         dirtyBondPrice(100, 6, 3, 1, 9, 100, ACT360_DAYS_IN_YEAR()),
         dirtyBondPriceForCalculators(100, 6, 3, 1, 9, 100,
                                      ACT360_DAYS_IN_YEAR()), 4)
Exemplo n.º 16
0
 def testBondEquivalentYieldForMaturityUnder182Days(self):
     self.assertAlmostEqual(
         discountInstrumentBondEquivalentYield(8, 100,
                                               ACT360_DAYS_IN_YEAR(),
                                               ACT365_DAYS_IN_YEAR()),
         8.2955, 4)
Exemplo n.º 17
0
 def testBondImpliedRepoRate(self):
     self.assertAlmostEqual(
         bondImpliedRepoRate(105, 104, 2.1, 2.8, 0, 1.034, 100,
                             ACT360_DAYS_IN_YEAR()), 10.8773, 4)
Exemplo n.º 18
0
 def testCleanBondPriceExDividend(self):
     self.assertAlmostEqual(
         cleanBondPriceExDividend(100, 6, 3, 1, 9, 4,
                                  ACT360_DAYS_IN_YEAR()), 127.08, 2)