@Test public void calculateOnlyWithLossTrade() { List<Double> prices = IntStream.rangeClosed(1, 100).asDoubleStream().boxed().sorted(Collections.reverseOrder()) .collect(Collectors.toList()); series = new MockBarSeries(numFunction, prices); Trade trade = new Trade(Order.buyAt(series.getBeginIndex(), series), Order.sellAt(series.getEndIndex(), series)); AnalysisCriterion esCriterion = getCriterion(); assertNumEquals(numOf(-0.35835189384561106), esCriterion.calculate(series, trade)); }
@Override public Num calculate(BarSeries series, TradingRecord tradingRecord) { Returns returns = new Returns(series, tradingRecord, Returns.ReturnType.LOG); return calculateES(returns, confidence); }
ExpectedShortfallCriterion extends AbstractAnalysisCriterion { @Override public Num calculate(BarSeries series, TradingRecord tradingRecord) { Returns returns = new Returns(series, tradingRecord, Returns.ReturnType.LOG); return calculateES(returns, confidence); } }
ExpectedShortfallCriterion extends AbstractAnalysisCriterion { @Override public Num calculate(BarSeries series, TradingRecord tradingRecord) { Returns returns = new Returns(series, tradingRecord, Returns.ReturnType.LOG); return calculateES(returns, confidence); } ExpectedShortfallCriterion(Double confidence); }
ExpectedShortfallCriterion extends AbstractAnalysisCriterion { @Override public Num calculate(BarSeries series, TradingRecord tradingRecord) { Returns returns = new Returns(series, tradingRecord, Returns.ReturnType.LOG); return calculateES(returns, confidence); } ExpectedShortfallCriterion(Double confidence); @Override Num calculate(BarSeries series, TradingRecord tradingRecord); @Override Num calculate(BarSeries series, Trade trade); @Override boolean betterThan(Num criterionValue1, Num criterionValue2); }
ExpectedShortfallCriterion extends AbstractAnalysisCriterion { @Override public Num calculate(BarSeries series, TradingRecord tradingRecord) { Returns returns = new Returns(series, tradingRecord, Returns.ReturnType.LOG); return calculateES(returns, confidence); } ExpectedShortfallCriterion(Double confidence); @Override Num calculate(BarSeries series, TradingRecord tradingRecord); @Override Num calculate(BarSeries series, Trade trade); @Override boolean betterThan(Num criterionValue1, Num criterionValue2);  }