@Override
    public Num calculate(BarSeries series, Position position) {
        return numberOfPositionsCriterion.calculate(series, position);
    }
@Test
    public void calculateWithOnePosition() {
        BarSeries series = new MockBarSeries(numFunction, 100d, 95d, 102d, 105d, 97d, 113d);
        Position position = new Position(Trade.buyAt(0, series), Trade.sellAt(1, series));

        // 0 winning position
        AnalysisCriterion winningPositionsRatio = getCriterion(PositionFilter.PROFIT);
        assertNumEquals(numOf(0), winningPositionsRatio.calculate(series, position));

        // 1 winning position
        position = new Position(Trade.buyAt(1, series), Trade.sellAt(2, series));
        assertNumEquals(1, winningPositionsRatio.calculate(series, position));

        // 1 losing position
        position = new Position(Trade.buyAt(0, series), Trade.sellAt(1, series));
        AnalysisCriterion losingPositionsRatio = getCriterion(PositionFilter.LOSS);
        assertNumEquals(numOf(1), losingPositionsRatio.calculate(series, position));

        // 0 losing position
        position = new Position(Trade.buyAt(1, series), Trade.sellAt(2, series));
        assertNumEquals(0, losingPositionsRatio.calculate(series, position));

    }