Skip to main content

PyPI Anaconda Tests PyPI Coverage Status GitHub issues PyPI - License Discourse users Twitter Follow

Alphalens is a Python library for performance analysis of predictive (alpha) stock factors. Alphalens works great with the Zipline open source backtesting library, and Pyfolio which provides performance and risk analysis of financial portfolios.

The main function of Alphalens is to surface the most relevant statistics and plots about an alpha factor, including:

  • Returns Analysis
  • Information Coefficient Analysis
  • Turnover Analysis
  • Grouped Analysis

Maintenance and new projects

We continue to maintain Alphalens Reloaded for bug, security and compatibility fixes. Our new development focuses on ML4T Diagnostic. For new projects, evaluate it through the factor-analysis migration guide, which includes a runnable example and explains the differences between the workflows. See the Diagnostic documentation and the ML4T website for the current libraries and their workflows.

Getting started

With a signal and pricing data creating a factor "tear sheet" is a two step process:

import alphalens

# Ingest and format data
factor_data = alphalens.utils.get_clean_factor_and_forward_returns(my_factor,
                                                                   pricing,
                                                                   quantiles=5,
                                                                   groupby=ticker_sector,
                                                                   groupby_labels=sector_names)

# Run analysis
alphalens.tears.create_full_tear_sheet(factor_data)

Learn more

Check out the example notebooks for more on how to read and use the factor tear sheet.

Installation

The next release supports Python 3.11-3.15. Python 3.10 and older are no longer supported; previous release artifacts remain available. Python 3.15 requires pandas 3; earlier supported Python versions also support pandas 1.5 and 2.x. Native tests, built wheels and Conda packages have been qualified on Linux, macOS and Windows. These source changes do not alter previously published releases.

Install with pip:

pip install alphalens-reloaded

Install with conda:

conda install -c ml4t alphalens-reloaded

Install from the master branch of Alphalens repository (development code):

pip install git+https://github.com/stefan-jansen/alphalens-reloaded

Alphalens depends on:

NumPy >=2.0 requires pandas >=2.2.2. Upgrade older pandas versions before using NumPy 2 to avoid compatibility issues.

Usage

A good way to get started is to run the examples in a Jupyter notebook.

To get set up with an example, you can:

Run a Jupyter notebook server via:

jupyter notebook

From the notebook list page(usually found at http://localhost:8888/), navigate over to the examples directory, and open any file with a .ipynb extension.

Execute the code in a notebook cell by clicking on it and hitting Shift+Enter.

Questions?

If you find a bug, feel free to open an issue on our github tracker.

Contribute

Read the contribution guide for maintenance scope, review requirements and local checks.

If you want to contribute, a great place to start would be the help-wanted issues.

Credits

For a full list of contributors see the contributors page.

Example Tear Sheets

Example factor courtesy of ExtractAlpha

Peformance Metrics Tables

image

Returns Tear Sheet

image

Information Coefficient Tear Sheet

image

Sector Tear Sheet

image

Metadata

Release files for alphalens-reloaded 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for alphalens-reloaded 0.5.1
File Size Uploaded Provenance Actions
alphalens_reloaded-0.5.1.tar.gz 109.4 kB Without provenance Details for alphalens_reloaded-0.5.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for alphalens-reloaded 0.5.1
File Interpreter ABI Platform Actions
alphalens_reloaded-0.5.1-py3-none-any.whl Python 3 none any Details for alphalens_reloaded-0.5.1-py3-none-any.whl

Total release size: 174.5 kB

Release files / alphalens_reloaded-0.5.1.tar.gz

Download URL alphalens_reloaded-0.5.1.tar.gz
Size 109.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e04d84e14dca5d376c41e9762be295b02093db9017645af94d730b4a66755b71
BLAKE2b-256 checksum
How to use checksums
f3f019b3696ee8fc3891ea8a9a9e4eff68e914474f461bf55d397c6959661499
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / alphalens_reloaded-0.5.1-py3-none-any.whl

Download URL alphalens_reloaded-0.5.1-py3-none-any.whl
Size 65.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1455c630a8a5822bcbc605c08d6ddab37360f27a317c8b64e936be6bc1d50c66
BLAKE2b-256 checksum
How to use checksums
2c06bac91ae6f05e8a95fd7f5ef2ddc9e40911e7f633ae9061cbb68b4dfe068a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for alphalens-reloaded 0.5.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page