public void testCash() {
final double t = 7 / 365.0;
final YieldAndDiscountCurve curve = CURVES.getCurve(FIVE_PC_CURVE_NAME);
final double df = curve.getDiscountFactor(t);
double r = 1 / t * (1 / df - 1);
Cash cash = new Cash(CUR, 0, t, 1, r, t, FIVE_PC_CURVE_NAME);
Map<String, List<DoublesPair>> sense = cash.accept(PVSC, CURVES);
assertTrue(sense.containsKey(FIVE_PC_CURVE_NAME));
assertFalse(sense.containsKey(ZERO_PC_CURVE_NAME));
List<DoublesPair> temp = sense.get(FIVE_PC_CURVE_NAME);
for (final DoublesPair pair : temp) {
if (pair.getFirst() == 0.0) {
assertEquals(0.0, pair.getSecond(), 1e-12);
} else if (Double.compare(pair.getFirst(), t) == 0) {
assertEquals(-t * df * (1 + r * t), pair.getSecond(), 1e-12);
} else {
assertFalse(true);
}
}
final double tradeTime = 2.0 / 365.0;
final double yearFrac = 5.0 / 360.0;
final double dfa = curve.getDiscountFactor(tradeTime);
r = 1 / yearFrac * (dfa / df - 1);
cash = new Cash(CUR, tradeTime, t, 1, r, yearFrac, FIVE_PC_CURVE_NAME);
sense = cash.accept(PVSC, CURVES);
temp = sense.get(FIVE_PC_CURVE_NAME);
for (final DoublesPair pair : temp) {
if (Double.compare(pair.getFirst(), tradeTime) == 0) {
assertEquals(dfa * tradeTime, pair.getSecond(), 1e-12);
} else if (Double.compare(pair.getFirst(), t) == 0) {