NUMERICAL AUDIT · 4 DECEMBER 2026
Goldman Sachs’ gs-quant max_drawdown looks back twice as far as its window
Xamit Kadirbekov and Daniyal Kadirbekov, GERO Numerical Assurance
OPEN. Fix and test submitted as gs-quant pull request #423 on 4 December 2026; not merged at the time of writing. Reproduced on gs-quant main at commit 0e3cc8e (release 2.3.4, 27 November 2026). Reproduction script: gs-quant-max-drawdown-check.py.
gs-quant is Goldman Sachs’ open-source Python package for quantitative finance (Apache 2.0). Its function gs_quant.timeseries.econometrics.max_drawdown(x, w) is documented as computing “the maximum peak to trough drawdown over a rolling window as a ratio.” With an integer window of w observations, the peak it uses can lie up to w−1 observations before the window starts, so the effective window is 2w−1, not w.
A four-point example
Take the series [100, 50, 50, 50] and a window of 3. In the last window, [50, 50, 50], there is no drawdown, so the correct value is 0. The function returns −0.5 at the last point. The same happens with the date window '3d'.
Where it comes from
The integer-window branch works in two rolling steps:
rolling_max = x.rolling(w.w, 0).max() result = (x / rolling_max - 1).rolling(w.w, 0).min()
The first step gives each point the maximum of its own trailing window. The second step takes the minimum of those ratios over the next trailing window. A point near the start of the final window is therefore compared with a maximum that may sit up to w−1 observations earlier, outside the window. The date-window branch is built the same way, in two steps.
The corrected logic computes each window on its own: for every window, divide by the running maximum inside that window only, and take the minimum. That is what our reference function in the script does, and what the pull request implements.
How large it is
We simulated one log-normal daily price path of 2,000 days (daily σ 1%, seed 1) and compared the function with a direct calculation over each window.
| Window (observations) | Largest error | Wrong values |
|---|---|---|
| 5 | 0.055 | 52% |
| 20 | 0.117 | 56% |
| 50 | 0.124 | 59% |
| 250 | 0.240 | 71% |
For a one-year window of 250 trading days, 71% of values are wrong, by up to 24 percentage points.
The existing test
The library’s own test fixes the behaviour. For Window(2, 0) on the series [1, 5, 5, 4, 4, 1], it expects −0.2 on 2019-01-07, where the window is [4, 4] and the correct value is 0.0.
How to reproduce
In a clean environment, install the release and run the script:
pip install gs-quant==2.3.4 python gs-quant-max-drawdown-check.py
The script prints the four-point example and the table above. Download it: gs-quant-max-drawdown-check.py. Output on gs-quant main at 0e3cc8e: last value −0.5 against a reference of 0.0, then the four rows of the table.
Fix and status
We submitted a fix and a regression test as pull request #423 on 4 December 2026. Both new tests fail on main and pass with the fix, and test_econometrics.py gives 24 passed. External pull requests were last merged into gs-quant in December 2024, and several external fixes remain open, so this article records the finding whether or not the pull request is merged. In our search of the project’s issues and pull requests, we found no earlier report of this.
Limits
The table comes from one simulated price path, not from market data. The function is marked with the @plot_function decorator, whose code comment in gs_quant/timeseries/helper.py says “Indicates that fn should be exported to plottool as a pure function”; so, by that comment, it is exported to PlotTool. We have not checked whether the same code runs on Marquee or what numbers any client sees. This is an implementation defect in one function, not a statement about other parts of the library.