Open asset pricing package with example dependencies
Project description
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)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openassetpricing-0.0.2.tar.gz.
File metadata
- Download URL: openassetpricing-0.0.2.tar.gz
- Upload date:
- Size: 18.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6dc4310af2903b19f468ad99a05c43ff71b30ba9283cc27845baa305fae605f8
|
|
| MD5 |
e0c2b9fdbe6da5dcaf3bb7c401bd0866
|
|
| BLAKE2b-256 |
909465acea494d154cb42752ea5c412e8b0872d21a0bfc26e7ec6284482e9d69
|
File details
Details for the file openassetpricing-0.0.2-py3-none-any.whl.
File metadata
- Download URL: openassetpricing-0.0.2-py3-none-any.whl
- Upload date:
- Size: 18.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05cb3c4bd633b677bdcb26f2bfb19afea2d8ff3d2f9445ba644b54904a89c381
|
|
| MD5 |
f9a4c91f8b96971532f5d46ff83b200a
|
|
| BLAKE2b-256 |
e4bf3150898a8e432408169d7524aa7ff290611cb35aacf944b0ee1b84df7e8d
|