#390·gs-quant

[BUG] annualize and prices docstrings describe a different calculation from the code

Author: AstralchemistCreated Sep 28, 2026Updated Sep 28, 2026

Describe the bug Two docstrings in gs_quant/timeseries/econometrics.py describe a calculation the code does not do.

  1. annualize says it is "useful for annualizing daily or monthly returns" and gives the example annualize(returns(prices)), but the function multiplies by the square root of the annualisation factor. That is the scaling for a volatility. A mean return annualises by the factor itself, so a user following the docstring gets a number that is off by sqrt(F). On a random daily series the example yields a "mean annual return" of about -0.021 where mean * 252 is about -0.333.

  2. prices gives the formula Y_t = (1 + X_{t-1}) Y_{t-1}, but the code computes product(1 + series) * initial, which is Y_t = (1 + X_t) Y_{t-1}. The index in the formula is off by one.

To Reproduce

python
import numpy as np, pandas as pd
from gs_quant.timeseries import econometrics as ec
px = pd.Series(100 * np.cumprod(1 + np.random.default_rng(3).normal(0.0005, 0.012, 120)), index=pd.bdate_range("2024-01-01", periods=120))
r = ec.returns(px).dropna()
print(ec.annualize(r).mean())   # about -0.021, mean return times sqrt(252)
print(r.mean() * 252)           # about -0.333, what "annualised return" means

Expected behavior The annualize docstring restricted to inputs with a volatility dimension, or the function offered a returns mode that multiplies by F. The prices formula written as Y_t = (1 + X_t) Y_{t-1}.

Screenshots Not applicable.

Systems setup:

  • OS: macOS 26 (Darwin 25.6.0), arm64
  • Python version: 3.12
  • GS-Quant version: 2.1.17, commit f2a505a; pandas 3.0.6, numpy 2.3.5

Additional context The annualize point was also part of the closed PR #362, which its author withdrew without review.