Skip to content

Versions

0.9.0

The first release of the Python package, and the version that produced every result in the paper. Install it with pip install "assayinganomalies[analytics]==0.9.0".

Version numbers start at 0.9.0; fixes are 0.9.x. The installed version is assayinganomalies.__version__ and aa --version. Database builds and protocol runs record it in their manifests, and the report prints it in its first footnote.

The releases numbered 0.1 to 2.0.6 that PyPI lists under the same name (2024) are an earlier, unrelated Python implementation. They are withdrawn, and their numbers say nothing about this package.

What the package contains

  • A database build from your own WRDS account into one DuckDB file (aa setup-database): CRSP monthly and daily, Compustat annual and quarterly, the Fama-French factors, the Chen-Zimmerman anomalies, trading costs and betas.
  • Univariate and bivariate portfolio sorts, factor regressions, Fama-MacBeth regressions, trading costs and generalized alphas, as public functions.
  • The anomaly-testing protocol of Novy-Marx and Velikov, "Assaying Anomalies", with its LaTeX/PDF report (aa run-protocol, aa.test_signal).
  • A JSON run manifest for every database build and protocol run: package version, data vintage, sample, input hashes and seeds.

Differences from the MATLAB toolkit

Results are deliberately not identical to MATLAB's.

  • Held legs. A sort buys each portfolio in a month in which the signal has values and holds it, without rebalancing, until the next such month. Trading costs are those of the trades this takes, and the first purchase is reported separately and not charged. The Fama-French factor costs are computed the same way.
  • Annual Compustat columns are stored in the June they become available only, so a signal built from them trades once a year. aa.fill_months and aa.load(..., fill_annual=True) carry the June value through the following May.
  • CRSP's CIZ format (Flat File Format 2.0) is the default. The legacy SIZ format, which ends in December 2024, can still be selected; the two give slightly different numbers.
  • Chen-Zimmerman files come from Hugging Face, for any release from 2022.03 to 2026.10; pin a release to reproduce a set of anomalies.
  • Randomness is seeded: tie-breaking noise and cross-validation folds are reproducible, and the seed is part of the specification of a result.
  • Bugs in the MATLAB code are corrected, among them trading-cost inputs that dropped NASDAQ spreads for part of the sample, a ranking step that ran within stock instead of across stocks, and errors in report tables and figure labels.

The tutorial's appendix maps the MATLAB functions to the package's.

The MATLAB toolkit

The protocol's first implementation was a MATLAB toolkit. It is no longer maintained, and remains available on the matlab-legacy branch of the repository. Reports made with it are not comparable number for number with reports from the Python package, for the reasons above.

The paper's replication code

The code that produces the paper's tables and figures from version 0.9.0 of the package is in a repository of its own, github.com/velikov-mihail/AssayingAnomalies-paper.

This site

The manual on this site describes version 0.9.0.