• Stars
    star
    3,094
  • Rank 13,952 (Top 0.3 %)
  • Language
    Jupyter Notebook
  • License
    Apache License 2.0
  • Created almost 8 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Performance analysis of predictive (alpha) stock factors

https://media.quantopian.com/logos/open_source/alphalens-logo-03.png

Alphalens

GitHub Actions status

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. You can try Alphalens at Quantopian -- a free, community-centered, hosted platform for researching and testing alpha ideas. Quantopian also offers a fully managed service for professionals that includes Zipline, Alphalens, Pyfolio, FactSet data, and more.

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. A good starting point could be this

Installation

Install with pip:

pip install alphalens

Install with conda:

conda install -c conda-forge alphalens

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

pip install git+https://github.com/quantopian/alphalens

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 Sheet

Example factor courtesy of ExtractAlpha

https://github.com/quantopian/alphalens/raw/master/alphalens/examples/table_tear.png

https://github.com/quantopian/alphalens/raw/master/alphalens/examples/returns_tear.png

https://github.com/quantopian/alphalens/raw/master/alphalens/examples/ic_tear.png

More Repositories

1

zipline

Zipline, a Pythonic Algorithmic Trading Library
Python
16,969
star
2

pyfolio

Portfolio and risk analytics in Python
Jupyter Notebook
5,379
star
3

qgrid

An interactive grid for sorting, filtering, and editing DataFrames in Jupyter notebooks
Python
3,018
star
4

research_public

Quantitative research and educational materials
Jupyter Notebook
2,301
star
5

empyrical

Common financial risk and performance metrics. Used by zipline and pyfolio.
Python
1,210
star
6

trading_calendars

Calendars for various securities exchanges.
Python
602
star
7

qdb

Quantopian Remote Debugger for Python
Python
313
star
8

quantopian-algos

Library of algorithm scripts for Quantopian
Python
171
star
9

pgcontents

A Postgres-backed ContentsManager implementation for Jupyter
Python
149
star
10

coal-mine

Coal Mine - Periodic task execution monitor
Python
110
star
11

bayesalpha

Bayesian models to compute performance and uncertainty of returns and alpha.
Python
100
star
12

algorithm-component-library

A collection of code snippets that can be constructed into larger trading algorithms.
Python
100
star
13

PenguinDome

Simple Linux Mobile Device Management
Python
87
star
14

libpy

Utilities for writing C++ extension modules.
C++
79
star
15

warp_prism

Quickly move data from postgres to numpy or pandas.
C
63
star
16

qgrid-notebooks

Notebooks which will provide a demo of Qgrid functionality
Jupyter Notebook
20
star
17

serializable-traitlets

JSON-Serializable IPython Traitlets
Python
13
star
18

metautils

Utilities for writing metaclasses.
Python
8
star
19

DockORM

An object-relational mapper for docker containers.
Python
8
star
20

quantopian-drafts

Drafts for new Quantopian features.
6
star
21

aqueduct-client

Python wrapper for Quantopian's Aqueduct API
Python
2
star
22

nose_xunit_gevent

Xunit for the nose_gevented_multiprocess plugin
Python
2
star
23

quantopian.github.io

CSS
1
star