xo-unit: + 30-day volatility unit, factory function

This commit is contained in:
Roland Conybeare 2024-05-04 14:52:19 -04:00
commit cf65def417
2 changed files with 7 additions and 1 deletions

View file

@ -410,6 +410,7 @@ namespace xo {
constexpr auto price = natural_unit<std::int64_t>::from_bu(bu::price);
constexpr auto volatility_30d = natural_unit<std::int64_t>::from_bu(bu::month, power_ratio_type(-1,2));
constexpr auto volatility_250d = natural_unit<std::int64_t>::from_bu(bu::year250, power_ratio_type(-1,2));
constexpr auto volatility_360d = natural_unit<std::int64_t>::from_bu(bu::year360, power_ratio_type(-1,2));
} /*namespace nu*/

View file

@ -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 <typename Repr>
inline constexpr auto volatility_30d(Repr x) { return quantity<nu::volatility_30d, Repr>(x); }
template <typename Repr>
inline constexpr auto volatility_250d(Repr x) { return quantity<nu::volatility_250d, Repr>(x); }
template <typename Repr>