@Test public void calculateWithASimpleTrade() { series = new MockBarSeries(numFunction, 100d, 104d, 90d, 100d, 95d, 105d); TradingRecord tradingRecord = new BaseTradingRecord(Order.buyAt(0, series), Order.sellAt(2, series)); AnalysisCriterion varCriterion = getCriterion(); assertNumEquals(numOf(Math.log(90d / 104)), varCriterion.calculate(series, tradingRecord)); }
@Override public Num calculate(BarSeries series, TradingRecord tradingRecord) { Returns returns = new Returns(series, tradingRecord, Returns.ReturnType.LOG); return calculateVaR(returns, confidence); }
ValueAtRiskCriterion extends AbstractAnalysisCriterion { @Override public Num calculate(BarSeries series, TradingRecord tradingRecord) { Returns returns = new Returns(series, tradingRecord, Returns.ReturnType.LOG); return calculateVaR(returns, confidence); } }
ValueAtRiskCriterion extends AbstractAnalysisCriterion { @Override public Num calculate(BarSeries series, TradingRecord tradingRecord) { Returns returns = new Returns(series, tradingRecord, Returns.ReturnType.LOG); return calculateVaR(returns, confidence); } ValueAtRiskCriterion(Double confidence); }
ValueAtRiskCriterion extends AbstractAnalysisCriterion { @Override public Num calculate(BarSeries series, TradingRecord tradingRecord) { Returns returns = new Returns(series, tradingRecord, Returns.ReturnType.LOG); return calculateVaR(returns, confidence); } ValueAtRiskCriterion(Double confidence); @Override Num calculate(BarSeries series, TradingRecord tradingRecord); @Override Num calculate(BarSeries series, Trade trade); @Override boolean betterThan(Num criterionValue1, Num criterionValue2); }
ValueAtRiskCriterion extends AbstractAnalysisCriterion { @Override public Num calculate(BarSeries series, TradingRecord tradingRecord) { Returns returns = new Returns(series, tradingRecord, Returns.ReturnType.LOG); return calculateVaR(returns, confidence); } ValueAtRiskCriterion(Double confidence); @Override Num calculate(BarSeries series, TradingRecord tradingRecord); @Override Num calculate(BarSeries series, Trade trade); @Override boolean betterThan(Num criterionValue1, Num criterionValue2);  }