@Override
    public Num calculate(BarSeries series, Position position) {
        return numberOfPositionsCriterion.calculate(series, position);
    }
@Test
    public void calculateWithShortPositions() {
        BarSeries series = new MockBarSeries(numFunction, 100d, 95d, 102d, 105d, 97d, 113d);
        TradingRecord tradingRecord = new BaseTradingRecord(Trade.sellAt(0, series), Trade.buyAt(2, series),
                Trade.sellAt(3, series), Trade.buyAt(4, series));

        // there are 3 positions with 1 winning positions
        AnalysisCriterion winningPositionsRatio = getCriterion(PositionFilter.PROFIT);
        assertNumEquals(0.5, winningPositionsRatio.calculate(series, tradingRecord));

        // there are 3 positions with 1 losing positions
        AnalysisCriterion losingPositionsRatio = getCriterion(PositionFilter.LOSS);
        assertNumEquals(0.5, losingPositionsRatio.calculate(series, tradingRecord));
    }