openassetpricing
Retrieve Open Source Asset Pricing Data (Chen and Zimmermann)
openassetpricing is a Python package to download data from Open Source Asset Pricing (OSAP).
There are 212 cross-sectional predictors.
- Download predictor portfolio returns: various portfolio construction methods: original paper methods, deciles, quintiles, equal-weighted, value-weighted, price filter, and so on ...
- Download firm characteristics: 209 from OSAP + 3 from CRSP (Price, Size, STreversal)
Learn more about Chen and Zimmermann data: Data website | Github code | Publication
Installation
- Option 1: install from PyPI
pip install openassetpricing
# To upgrade
pip install -U openassetpricing
- Option 2: local installation
- Download the package
If you have git installed, run in the terminal
git clone https://github.com/mk0417/open-asset-pricing-download.git
If you do not have git, you can download the pakage by clicking
the green Code button on top of the page and then clicking Download ZIP.
- Install on your local machine
Run in the terminal
pip install <local path to the package>
Or, navigate to the package directory first, then run in the terminal
pip install .
- Optional example dependencies
If you plan to run the example scripts and notebooks, install with extras:
pip install '.[examples]'
Usage
Both Pandas and Polars dataframes are supported. You can choose the one that fits your workflow.
Import package
import openassetpricing as oap
# List available release versions
oap.list_release()
# By default, it initializes the data source of most recent release
openap = oap.OpenAP()
# Specify the release version if you need vintage data, for example, 202408
openap = oap.OpenAP(202408)
Data source: Hugging Face
All releases download from Hugging Face (OpenSourceAP/CrossSection), one dataset branch per release: 2021.03 through 2026.10 (the default). Earlier versions of this package downloaded from Google Drive.
# Releases are named yyyymm; the older names 2023 and 2022 still work
openap = oap.OpenAP(202308)
# Or point at any branch of the dataset repo directly
openap = oap.OpenAP(hf_revision='Data-Release-2026.10')
Besides the portfolio sets above, releases include holding-period,
FF93-style, VW-forced, placebo, and daily portfolios. Older releases have
fewer files (no daily portfolios before 2021.04 or in 2022.04; 2021.03 has
only op, placebo_op, and firm characteristics), so run
openap.list_port() to see what a release has. Only the requested columns
and predictors are downloaded, so dl_signal and
dl_port(..., predictor=[...]) are fast. The 2020.05 and 2020.07 releases
are on Hugging Face in an older format that this package does not read.
List available portfolios (various implementations)
You will see original portfolio names of Chen and Zimmermann and the corresponding download names.
openap.list_port()
Download list of predictors
# Use Polars dataframe
df = openap.dl_signal_doc('polars')
# Use Pandas dataframe
df = openap.dl_signal_doc('pandas')
Download portfolio returns
Download all predictors
# Download OP portfolio returns in Polars dataframe
df = openap.dl_port('op', 'polars')
# Download equal-weighted decile portfolio returns in Pandas dataframe
df = openap.dl_port('deciles_ew', 'pandas')
Download specific predictors
# Download BM portfolio returns based on NYSE stocks only in Polars dataframe
df = openap.dl_port('nyse', 'polars', ['BM'])
# Download BM and 12-month momentum value-weighted
# quintile portfolio returns in Polars dataframe
df = openap.dl_port('quintiles_vw', 'polars', ['BM', 'Mom12m'])
# Use Pandas dataframe
df = openap.dl_port('nyse', 'pandas', ['BM'])
df = openap.dl_port('quintiles_vw', 'pandas', ['BM', 'Mom12m'])
Download firm characteristics
Download all firm characteristics
# Use Polars dataframe
df = openap.dl_all_signals('polars')
# Use Pandas dataframe
df = openap.dl_all_signals('pandas')
Download specific firm characteristics
# Use Polars dataframe
df = openap.dl_signal('polars', ['BM'])
# Use Pandas dataframe
df = openap.dl_signal('pandas', ['BM'])
Note
- To download all signals, you need a WRDS account.
Price,Size, andSTreversalare computed from WRDScrsp.msf_v2(CRSP CIZ). The signed formulas remain-log(abs(price)),-log(abs(price) * shrout / 1000), and-return, respectively; missing returns remain zero and nonfinite size remains missing.dl_signaldefaults to unsigned values;dl_all_signalsreturns signed values. CIZ monthly returns use different dividend reinvestment and delisting conventions, so historicalSTreversalvalues can differ from the legacycrsp.msfdata. Revised prices, shares, and coverage can also changePriceandSize. See the WRDS transition guide. These three signals use the WRDS data available when called, independently of the selected OpenAP release vintage.- The code has been tested with Python 3.10.14.
Offline CRSP regression checks can be run with
python3 -m unittest discover -s tests -p test_crsp_signals.py -v.
Contacts
- Peng Li (pl750@bath.ac.uk)
- Andrew Chen (andrew.y.chen@frb.gov)
- Tom Zimmermann (tom.zimmermann@uni-koeln.de)
Metadata
Release files for openassetpricing 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| openassetpricing-0.1.0.tar.gz | 20.4 kB | Without provenance | Details for openassetpricing-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| openassetpricing-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for openassetpricing-0.1.0-py3-none-any.whl |
Total release size: 29.5 kB
Release files / openassetpricing-0.1.0.tar.gz
| Download URL | openassetpricing-0.1.0.tar.gz |
|---|---|
| Size | 20.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5ca1bd477e2e5aaa720e3bf41a7fe76c351ba4c2251707befa1ca32d2276effd
|
|
BLAKE2b-256 checksum How to use checksums |
2eb807017c93ad75c3acc54e1bfb116e4759abe9e26fb0aec7bf525f0cb41ffc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / openassetpricing-0.1.0-py3-none-any.whl
| Download URL | openassetpricing-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6d458b4fcb46299ed1b777459238d6ae88478ae42ca4997b1477a8418339c4be
|
|
BLAKE2b-256 checksum How to use checksums |
4d83ac7c1c57ab3f5b7d25cca9ae35bd4dd8b1443f846ab0339b1b48c20a0e32
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Security for openassetpricing 0.1.0
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.