Skip to content
All library documents

Fixing a NumPy 2.0 Compatibility Error in CTA Backtests

Article vn.py community

Summary

The document reports a failure during a VeighNa CTA backtest when the engine calculates performance statistics. The traceback points to annual downside-risk calculation, where the Empyrical statistics package accesses NumPy’s removed `NINF` attribute. NumPy 2.0 removed that name, and the reported exception identifies negative infinity as its replacement. This locates the issue in a dependency compatibility mismatch during statistics calculation, rather than in a trading signal or strategy rule.

The practical takeaway is to update the affected dependency or use a compatible package version so the statistics code no longer relies on the removed attribute. The error occurs after the backtesting engine invokes its statistics routine, so it may prevent results from being reported even if the strategy simulation itself ran. The document provides no version details for VeighNa, Empyrical, or NumPy beyond the NumPy 2.0 change, and it does not show a tested fix or confirm whether other compatibility issues remain.

Key ideas

  • The reported exception occurs while calculating downside-risk statistics after a CTA backtest.
  • The traceback attributes the failure to Empyrical’s use of a NumPy attribute removed in NumPy 2.0.
  • The replacement identified for negative infinity is NumPy’s standard infinity value with a negative sign.
  • Updating or aligning package versions may resolve this specific compatibility problem.
  • The document does not confirm a tested fix or rule out other dependency issues.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.