예제 #1
0
        //-------------------------------------------------------------------------
        public virtual void test_requirementsAndCurrency()
        {
            OvernightFutureTradeCalculationFunction <OvernightFutureTrade> function = OvernightFutureTradeCalculationFunction.TRADE;
            ISet <Measure>       measures = function.supportedMeasures();
            FunctionRequirements reqs     = function.requirements(TRADE, measures, PARAMS, REF_DATA);

            assertThat(reqs.OutputCurrencies).Empty;
            assertThat(reqs.ValueRequirements).isEqualTo(ImmutableSet.of(FORWARD_CURVE_ID, QUOTE_KEY));
            assertThat(reqs.TimeSeriesRequirements).isEqualTo(ImmutableSet.of(IndexQuoteId.of(INDEX)));
            assertThat(function.naturalCurrency(TRADE, REF_DATA)).isEqualTo(CURRENCY);
        }
예제 #2
0
        public virtual void test_simpleMeasures()
        {
            OvernightFutureTradeCalculationFunction <OvernightFutureTrade> function = OvernightFutureTradeCalculationFunction.TRADE;
            ScenarioMarketData md                = marketData(FORWARD_CURVE_ID.CurveName);
            RatesProvider      provider          = RATES_LOOKUP.ratesProvider(md.scenario(0));
            double             expectedPrice     = TRADE_PRICER.price(RESOLVED_TRADE, provider);
            CurrencyAmount     expectedPv        = TRADE_PRICER.presentValue(RESOLVED_TRADE, provider, MARKET_PRICE / 100d);
            double             expectedParSpread = TRADE_PRICER.parSpread(RESOLVED_TRADE, provider, MARKET_PRICE / 100d);

            ISet <Measure> measures = ImmutableSet.of(Measures.UNIT_PRICE, Measures.PRESENT_VALUE, Measures.PAR_SPREAD, Measures.RESOLVED_TARGET);

            assertThat(function.calculate(TRADE, measures, PARAMS, md, REF_DATA)).containsEntry(Measures.UNIT_PRICE, Result.success(DoubleScenarioArray.of(ImmutableList.of(expectedPrice)))).containsEntry(Measures.PRESENT_VALUE, Result.success(CurrencyScenarioArray.of(ImmutableList.of(expectedPv)))).containsEntry(Measures.PAR_SPREAD, Result.success(DoubleScenarioArray.of(ImmutableList.of(expectedParSpread)))).containsEntry(Measures.RESOLVED_TARGET, Result.success(RESOLVED_TRADE));
        }