@Override
    public Num calculate(BarSeries series, Position position) {
        if (position.isClosed()) {
            Num entryPrice = position.getEntry().getValue();
            return position.getProfit().dividedBy(entryPrice).multipliedBy(series.hundred());
        }
        return series.zero();
    }
@Test
    public void calculateWithWinningShortPositions() {
        MockBarSeries series = new MockBarSeries(numFunction, 100, 90, 100, 95, 95, 100);
        TradingRecord tradingRecord = new BaseTradingRecord(Trade.sellAt(0, series), Trade.buyAt(1, series),
                Trade.sellAt(2, series), Trade.buyAt(3, series));
        AnalysisCriterion profit = getCriterion();
        assertNumEquals(10 + 5, profit.calculate(series, tradingRecord));
    }