use of name.abuchen.portfolio.math.Risk.Volatility in project portfolio by buchen.
the class RiskTest method testVolatilityWithConstantReturns.
@Test
public void testVolatilityWithConstantReturns() {
double[] returns = new double[20];
Arrays.fill(returns, 0.1);
Volatility volatility = new Volatility(returns, index -> true);
assertThat(volatility.getStandardDeviation(), closeTo(0d, 0.1e-10));
assertThat(volatility.getSemiDeviation(), closeTo(0d, 0.1e-10));
}
use of name.abuchen.portfolio.math.Risk.Volatility in project portfolio by buchen.
the class ReturnsVolatilityChartView method setChartSeries.
private void setChartSeries() {
configurator.getSelectedDataSeries().forEach(series -> {
PerformanceIndex index = cache.lookup(series, getReportingPeriod());
Volatility volatility = index.getVolatility();
ILineSeries lineSeries = chart.addScatterSeries(new double[] { volatility.getStandardDeviation() }, new double[] { index.getFinalAccumulatedPercentage() }, series.getLabel());
Color color = resources.createColor(series.getColor());
lineSeries.setLineColor(color);
lineSeries.setSymbolColor(color);
lineSeries.enableArea(series.isShowArea());
lineSeries.setLineStyle(series.getLineStyle());
});
}
use of name.abuchen.portfolio.math.Risk.Volatility in project portfolio by buchen.
the class RiskTest method testVolatility.
@Test
public void testVolatility() {
double[] delta = new double[] { 0.005, -1 / 300d, -0.005, 0.01, 0.01, -0.005 };
Volatility volatility = new Volatility(delta, index -> true);
// calculated reference values with excel
assertThat(volatility.getStandardDeviation(), closeTo(0.017736692475, 0.1e-10));
assertThat(volatility.getSemiDeviation(), closeTo(0.012188677034, 0.1e-10));
}
use of name.abuchen.portfolio.math.Risk.Volatility in project portfolio by buchen.
the class RiskTest method testVolatilityWithSkip.
@Test
public void testVolatilityWithSkip() {
double[] delta = new double[] { 0, 0.005, -1 / 300d, -0.005, 0.01, 0.01, -0.005 };
Volatility volatility = new Volatility(delta, index -> index > 0);
assertThat(volatility.getStandardDeviation(), closeTo(0.017736692475, 0.1e-10));
assertThat(volatility.getSemiDeviation(), closeTo(0.012188677034, 0.1e-10));
}
Aggregations