コード例 #1
0
 @Test
 public void yieldFromPrice() {
   final double yieldComputedIAM = METHOD_SECURITY.yieldFromPrice(BILL_IAM_SEC, PRICE);
   final double yieldExpectedIAM = (1.0 / PRICE - 1.0) / BILL_IAM_SEC.getAccrualFactor();
   assertEquals(
       "Bill Security: discounting method - yield",
       yieldExpectedIAM,
       yieldComputedIAM,
       TOLERANCE_YIELD);
   final double yieldComputedDSC = METHOD_SECURITY.yieldFromPrice(BILL_DSC_SEC, PRICE);
   final double yieldExpectedDSC = (1.0 - PRICE) / BILL_DSC_SEC.getAccrualFactor();
   assertEquals(
       "Bill Security: discounting method - yield",
       yieldExpectedDSC,
       yieldComputedDSC,
       TOLERANCE_YIELD);
 }
コード例 #2
0
 @Test
 public void priceFromYield() {
   final double[] yields = new double[] {0.0010, 0.0, -0.0010};
   for (final double yield2 : yields) {
     final double priceComputed = METHOD_SECURITY.priceFromYield(BILL_IAM_SEC, yield2);
     final double priceExpected = 1.0 / (1 + BILL_IAM_SEC.getAccrualFactor() * yield2);
     assertEquals(
         "Bill Security: discounting method - price",
         priceExpected,
         priceComputed,
         TOLERANCE_PRICE);
   }
 }