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

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

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:

Note that Numpy>=2.0 requires pandas>=2.2.2. If you are using an older version of pandas, you may need to upgrade accordingly, otherwise you may encounter 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

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

Release files for alphalens-reloaded 0.4.6

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.4.6
File Size Uploaded
alphalens_reloaded-0.4.6.tar.gz 94.6 kB Details

Built distribution (wheel)

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

Total release size: 157.7 kB

Release files / alphalens_reloaded-0.4.6.tar.gz

Download URL alphalens_reloaded-0.4.6.tar.gz
Size 94.6 kB
Tags Source
SHA-256 checksum
How to use checksums
24fe8cc289965e53b22cef91f1060b8ef9ab2561b4b37752d3d068f31b4ce744
BLAKE2b-256 checksum
How to use checksums
3d6c052bf919e25928d60b624cc5a57c4f3a2779c3b63604328b79d7db7e18e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

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

Download URL alphalens_reloaded-0.4.6-py3-none-any.whl
Size 63.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
02ad352449752b5c8fc02a1eba1572a400f484f50b4a0bf0780d78822e8486fb
BLAKE2b-256 checksum
How to use checksums
46105c53e7b8984de8c75b67e1677b1ec2d24756ff9de25335209ab7b9c73728
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release history Release notifications | RSS feed

This release

0.4.6 This release

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

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