Skip to main content

Performance analysis of predictive (alpha) stock factors

Project description

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:

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

alphalens_tej-2.0.3.tar.gz (7.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

alphalens_tej-2.0.3-py3-none-any.whl (42.3 kB view details)

Uploaded Python 3

File details

Details for the file alphalens_tej-2.0.3.tar.gz.

File metadata

  • Download URL: alphalens_tej-2.0.3.tar.gz
  • Upload date:
  • Size: 7.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.23

File hashes

Hashes for alphalens_tej-2.0.3.tar.gz
Algorithm Hash digest
SHA256 5f49d666c8e1bb3b7201acf646f12a35d8c2422d11256c3d260750f1aa30f6ca
MD5 e436f299a21401b58e81536050d973bd
BLAKE2b-256 1cc20debb8c1b7ee016a6ff589f6038b32d270d9a7ecb27efd2228f005f1ac13

See more details on using hashes here.

File details

Details for the file alphalens_tej-2.0.3-py3-none-any.whl.

File metadata

  • Download URL: alphalens_tej-2.0.3-py3-none-any.whl
  • Upload date:
  • Size: 42.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.23

File hashes

Hashes for alphalens_tej-2.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 16d85cac6eba2f9efc26cafd8bbcc5e1e2df02fec981befe041f79be2b9c1b14
MD5 979724661029ea03ee782e46f03eec21
BLAKE2b-256 ae897d41874a00f1d307ebc73c5dafc85cf27d6103b1d4f0e72a66e4ec6c578f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page