From cf65def41714951fa78a4589553883c3d5846108 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 4 May 2024 14:52:19 -0400 Subject: [PATCH] xo-unit: + 30-day volatility unit, factory function --- include/xo/unit/natural_unit.hpp | 1 + include/xo/unit/quantity.hpp | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/xo/unit/natural_unit.hpp b/include/xo/unit/natural_unit.hpp index c06faa4c..0acbd93f 100644 --- a/include/xo/unit/natural_unit.hpp +++ b/include/xo/unit/natural_unit.hpp @@ -410,6 +410,7 @@ namespace xo { constexpr auto price = natural_unit::from_bu(bu::price); + constexpr auto volatility_30d = natural_unit::from_bu(bu::month, power_ratio_type(-1,2)); constexpr auto volatility_250d = natural_unit::from_bu(bu::year250, power_ratio_type(-1,2)); constexpr auto volatility_360d = natural_unit::from_bu(bu::year360, power_ratio_type(-1,2)); } /*namespace nu*/ diff --git a/include/xo/unit/quantity.hpp b/include/xo/unit/quantity.hpp index af8ee94f..be93f8c7 100644 --- a/include/xo/unit/quantity.hpp +++ b/include/xo/unit/quantity.hpp @@ -419,7 +419,12 @@ namespace xo { // ----- volatility ----- - /* volatility in units of 1/yr */ + /* variance expressed has dimension 1/t; + * volatility ~ sqrt(variance), has dimension 1/sqrt(t) + */ + + template + inline constexpr auto volatility_30d(Repr x) { return quantity(x); } template inline constexpr auto volatility_250d(Repr x) { return quantity(x); } template