@Override
    public Num calculate(BarSeries series, Position position) {
        if (position == null || position.getEntry() == null || position.getExit() == null) {
            return series.zero();
        }
        CashFlow cashFlow = new CashFlow(series, position);
        return calculateMaximumDrawdown(series, null, cashFlow);
    }
@Test
    public void calculateWithNullSeriesSizeShouldReturn0() {
        MockBarSeries series = new MockBarSeries(numFunction, new double[] {});
        AnalysisCriterion mdd = getCriterion();
        assertNumEquals(0d, mdd.calculate(series, new BaseTradingRecord()));
    }