diff --git a/calculate/stats.go b/calculate/stats.go index d80ce88..5265e59 100644 --- a/calculate/stats.go +++ b/calculate/stats.go @@ -73,7 +73,7 @@ func ValueAtRisk(values []float64, portfolioValue, confidenceLevel, periodsPerYe Sigma: 1.0, } zScore := normal.Quantile(confidenceLevel) - return portfolioValue * zScore * AnnualizeRisk(stat.PopStdDev(values, nil), periodsPerYear) + return portfolioValue * -zScore * AnnualizeRisk(stat.PopStdDev(values, nil), periodsPerYear) } func negativeValues(out, in []float64) []float64 { diff --git a/calculate/stats_test.go b/calculate/stats_test.go index 6b8fc7c..7d1a8a3 100644 --- a/calculate/stats_test.go +++ b/calculate/stats_test.go @@ -86,7 +86,7 @@ func TestMetrics(t *testing.T) { confidenceLevel = 0.95 ) result := ValueAtRisk(portfolio, portfolioValue, confidenceLevel, PeriodsPerYear) - assert.InDelta(t, 2148.94, result, 0.01) + assert.InDelta(t, -2148.94, result, 0.01) }) }