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)
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)
def testCleanBondPrice(self): self.assertAlmostEqual( cleanBondPrice(100, 6, 3, 1, 9, 260, 100, ACT360_DAYS_IN_YEAR(), ACT360_DAYS_IN_YEAR()), 121.69, 2)
def testBondAccruedCoupon(self): self.assertAlmostEqual( bondAccruedInterest(100, 6, 260, ACT360_DAYS_IN_YEAR()), 4.3333, 4)
def testFRASettlementPriceFromFuture(self): self.assertAlmostEqual( forwardRateAgreementSettlementPriceFromFuturePrice( 1000000, 95.25, 6.5, 100, ACT360_DAYS_IN_YEAR()), -4774.90, 2)
def testFRASettlementPrice(self): self.assertAlmostEqual( forwardRateAgreementSettlementPrice(1000000, 3, 1.5, 100, ACT360_DAYS_IN_YEAR()), 4149.38, 2)
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)
def testDirtyBondPrice(self): self.assertAlmostEqual( dirtyBondPrice(100, 6, 3, 1, 9, 100, ACT360_DAYS_IN_YEAR()), 126.0201, 4)
def testBondFuturesHedgeNotional(self): self.assertAlmostEqual( bondFuturesHedgeNotional(1000000, 5.4, 1.0087, 100, ACT360_DAYS_IN_YEAR()), 993793.10, 2)
def testBondFuturesPrice(self): self.assertAlmostEqual( bondFuturesPrice(105, 6, 5.4, 2, 1.0087, 23, 100, 184, ACT360_DAYS_IN_YEAR()), 104.04, 2)
def testMoosmullerYieldForBond(self): self.assertAlmostEqual( bondPriceUsingMoosmullerYield(100, 6, 5.4, 1, 9, 100, ACT360_DAYS_IN_YEAR()), 108.1931, 4)
def testMoneyMarketYieldForBond(self): self.assertAlmostEqual( bondMoneyMarketYield(100, 107.7133, 6, 1, 9, 100, ACT360_DAYS_IN_YEAR(), ACT365_DAYS_IN_YEAR()), 5.4, 4)
def testBondPriceUsingSimpleInterestForCalculator(self): self.assertAlmostEqual( bondPriceUsingMoneyMarketYieldForCalculators( 100, 6, 5.4, 1, 9, 100, ACT360_DAYS_IN_YEAR(), ACT365_DAYS_IN_YEAR()), 107.7133, 4)
def testNumberOfInterestRateFutureContractsRequiredForHedge(self): self.assertAlmostEqual( interestRateFutureNumberContracts(3000000, 1000000, 6.5, 100, 90, ACT360_DAYS_IN_YEAR()), 3, 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)
def testBondEquivalentYieldForMaturityUnder182Days(self): self.assertAlmostEqual( discountInstrumentBondEquivalentYield(8, 100, ACT360_DAYS_IN_YEAR(), ACT365_DAYS_IN_YEAR()), 8.2955, 4)
def testBondImpliedRepoRate(self): self.assertAlmostEqual( bondImpliedRepoRate(105, 104, 2.1, 2.8, 0, 1.034, 100, ACT360_DAYS_IN_YEAR()), 10.8773, 4)
def testCleanBondPriceExDividend(self): self.assertAlmostEqual( cleanBondPriceExDividend(100, 6, 3, 1, 9, 4, ACT360_DAYS_IN_YEAR()), 127.08, 2)