Search in sources :

Example 1 with Volatility

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));
}
Also used : Volatility(name.abuchen.portfolio.math.Risk.Volatility) Test(org.junit.Test)

Example 2 with Volatility

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());
    });
}
Also used : Volatility(name.abuchen.portfolio.math.Risk.Volatility) ILineSeries(org.swtchart.ILineSeries) Color(org.eclipse.swt.graphics.Color) PerformanceIndex(name.abuchen.portfolio.snapshot.PerformanceIndex)

Example 3 with Volatility

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));
}
Also used : Volatility(name.abuchen.portfolio.math.Risk.Volatility) Test(org.junit.Test)

Example 4 with Volatility

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));
}
Also used : Volatility(name.abuchen.portfolio.math.Risk.Volatility) Test(org.junit.Test)

Aggregations

Volatility (name.abuchen.portfolio.math.Risk.Volatility)4 Test (org.junit.Test)3 PerformanceIndex (name.abuchen.portfolio.snapshot.PerformanceIndex)1 Color (org.eclipse.swt.graphics.Color)1 ILineSeries (org.swtchart.ILineSeries)1