Skip to main content

基于alphalens-reloaded新增功能

安装

pip install alphalens-cn

原仓库信息

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

新增功能

# tear_sheet输出到html中,使用示例
create_full_tear_sheet_html(
    ret,
    long_short=False,
    group_neutral=False,
    by_group=False,
    output_file='factor_analysis.html'
)

Metadata

Release files for alphalens-cn 0.4.8

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-cn 0.4.8
File Size Uploaded Provenance Actions
alphalens_cn-0.4.8.tar.gz 104.9 kB Without provenance Details for alphalens_cn-0.4.8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for alphalens-cn 0.4.8
File Interpreter ABI Platform Actions
alphalens_cn-0.4.8-py3-none-any.whl Python 3 none any Details for alphalens_cn-0.4.8-py3-none-any.whl

Total release size: 175.3 kB

Release files / alphalens_cn-0.4.8.tar.gz

Download URL alphalens_cn-0.4.8.tar.gz
Size 104.9 kB
Tags Source
SHA-256 checksum
How to use checksums
635b83e76a789158a87d57db34403797d70452e2609849d861c0d2af94f5c53a
BLAKE2b-256 checksum
How to use checksums
fe2dc0a1cd0cb7f096a8fa1a79f077a6b7048f2403cc08a993086c1e28a7f6cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.0

Release files / alphalens_cn-0.4.8-py3-none-any.whl

Download URL alphalens_cn-0.4.8-py3-none-any.whl
Size 70.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2807b1cda9e973724fefdc8f171cd51be1330d0dec9e0d96bc3567f8d11d7666
BLAKE2b-256 checksum
How to use checksums
e2c6e6c69ad3ed0ca7e6eff253ebddd1c83323f65042b558d83db5bf758d21f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.0

Security for alphalens-cn 0.4.8

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