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)
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.
- The code has been tested with Python 3.10.14.
Contacts
- Peng Li (pl750@bath.ac.uk)
- Andrew Chen (andrew.y.chen@frb.gov)
- Tom Zimmermann (tom.zimmermann@uni-koeln.de)
Release files for openassetpricing 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| openassetpricing-0.0.2.tar.gz | 18.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| openassetpricing-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size:37.2 kB
Release files / openassetpricing-0.0.2.tar.gz
| Download URL | openassetpricing-0.0.2.tar.gz |
|---|---|
| Size | 18.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6dc4310af2903b19f468ad99a05c43ff71b30ba9283cc27845baa305fae605f8
|
|
BLAKE2b-256 checksum How to use checksums |
909465acea494d154cb42752ea5c412e8b0872d21a0bfc26e7ec6284482e9d69
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Release files / openassetpricing-0.0.2-py3-none-any.whl
| Download URL | openassetpricing-0.0.2-py3-none-any.whl |
|---|---|
| Size | 18.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
05cb3c4bd633b677bdcb26f2bfb19afea2d8ff3d2f9445ba644b54904a89c381
|
|
BLAKE2b-256 checksum How to use checksums |
e4bf3150898a8e432408169d7524aa7ff290611cb35aacf944b0ee1b84df7e8d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|