@Test public void withTradesThatSellBeforeBuying() { MockTimeSeries series = new MockTimeSeries(2, 1, 3, 5, 6, 3, 20); MaximumDrawdownCriterion mdd = new MaximumDrawdownCriterion(); TradingRecord tradingRecord = new BaseTradingRecord( Order.buyAt(0), Order.sellAt(1), Order.buyAt(3), Order.sellAt(4), Order.sellAt(5), Order.buyAt(6)); assertEquals(.91, mdd.calculate(series, tradingRecord), TATestsUtils.TA_OFFSET); }
@Override public double calculate(TimeSeries series, TradingRecord tradingRecord) { CashFlow cashFlow = new CashFlow(series, tradingRecord); Decimal maximumDrawdown = calculateMaximumDrawdown(series, cashFlow); return maximumDrawdown.toDouble(); }
MaximumDrawdownCriterion extends AbstractAnalysisCriterion { @Override public double calculate(TimeSeries series, TradingRecord tradingRecord) { CashFlow cashFlow = new CashFlow(series, tradingRecord); Decimal maximumDrawdown = calculateMaximumDrawdown(series, cashFlow); return maximumDrawdown.toDouble(); } }
MaximumDrawdownCriterion extends AbstractAnalysisCriterion { @Override public double calculate(TimeSeries series, TradingRecord tradingRecord) { CashFlow cashFlow = new CashFlow(series, tradingRecord); Decimal maximumDrawdown = calculateMaximumDrawdown(series, cashFlow); return maximumDrawdown.toDouble(); }  }
MaximumDrawdownCriterion extends AbstractAnalysisCriterion { @Override public double calculate(TimeSeries series, TradingRecord tradingRecord) { CashFlow cashFlow = new CashFlow(series, tradingRecord); Decimal maximumDrawdown = calculateMaximumDrawdown(series, cashFlow); return maximumDrawdown.toDouble(); }  @Override double calculate(TimeSeries series, TradingRecord tradingRecord); @Override double calculate(TimeSeries series, Trade trade); @Override boolean betterThan(double criterionValue1, double criterionValue2); }
MaximumDrawdownCriterion extends AbstractAnalysisCriterion { @Override public double calculate(TimeSeries series, TradingRecord tradingRecord) { CashFlow cashFlow = new CashFlow(series, tradingRecord); Decimal maximumDrawdown = calculateMaximumDrawdown(series, cashFlow); return maximumDrawdown.toDouble(); }  @Override double calculate(TimeSeries series, TradingRecord tradingRecord); @Override double calculate(TimeSeries series, Trade trade); @Override boolean betterThan(double criterionValue1, double criterionValue2);  }