Skip to main content

Factor Pricing Model Universe

CI Status Documentation Status Test coverage percentage

Poetry black pre-commit

PyPI Version Supported Python versions License

Package to build universes for factor pricing model. For further details, please refer to the documentation

Installation

Install this via pip (or your favourite package manager):

pip install factor-pricing-model-universe

Usage

The library contains the pipelines to build the universe. You can run the pipelines interactively in Jupyter Notebook.

from fpm_universe import pipeline

Alternatively, for scheduled runs, you can create a configuration and run the command line entry point to create the universe.

Configuration

The configuration is in yaml format and contains a few inputs

Name Description
output_filename Output filename
intermediate_directory Intermediate directory to export the pipeline outputs
start_datetime Start datetime of the universe
last_datetime Last datetime of the universe
frequency Frequency of the universe. For further details, please see the "Offset aliases" in pandas documentation
pipeline List of pipelines to filter the universe
data Defines the data used by pipeline, or referred by yaml tag !data

Each pipeline returns a pandas dataframe indicating if the instrument is included into the universe on the specified date / time. For example, the pipeline returns the following dataframe

+------------+--------+-------+
|    date    |  AAPL  | GOOGL |
+------------+--------+-------+
| 2022-11-17 |  True  | False |
+------------+--------+-------+
| 2022-11-18 |  True  |  True |
+------------+--------+-------+

and it indicates AAPL is included in the universe on both 2022-11-17 and 2022-11-18 while GOOGL only on 2022-11-18.

By default, the pipeline functions are imported from module fpm_universe.pipeline.

Each data defines the method to retrieve from the source, or the operator on the source data. The return type of each data is unconstrained. It can be a json-like dict, a list, a pandas series, or even a pandas dataframe.

In the configuration, Each data can be referred by yaml tag !data, and it is loaded in lazy only when it is referred by another data object or a pipeline.

Command

The entry point factor-pricing-model-universe is to generate the universe regarding the given configuration to the destination, with dynamically passing the parameters to format the configuration.

The arguments of the entry point are

Argument Description
-c, --config TEXT Required. Configuration file path.
-p, --parameter TEXT Parameters to be formatted in the configuration.

For example, given the configuration as follows,

output_filename: "{output_directory}/{date}.parquet"
intermediate_directory: "{output_directory}/{date}"
start_datetime: "2015-01-01"
last_datetime: "{date}"
frequency: "B"
pipeline:
  - name: range_validity
    function: range_validity
    parameters:
      values: !data initial_validity
data:
  symbols:
    function: jq_compile
    parameters:
      json_filename: "{data_directory}/index/sp500/default/{date}.json"
      pattern: "[.[] | .tickers[]] | sort | unique | .[]"
  initial_validity:
    function: jq_compile
    parameters:
      json_filename: "{data_directory}/listings/{date}.json"
      pattern: ".[] | {{ symbol: .symbol, valid_start_datetime: .ipoDate, valid_last_datetime: .delistingDate }}"
      includes:
        symbol: !data symbols

and run the following command

factor-pricing-model-universe \
  --config <path> \
  --parameter output_directory=$HOME/output \
  --parameter data_directory=$HOME/data \
  --parameter date=2022-10-20

the universe dataframe is output to $HOME/output/2022-10-20.parquet (formatted with the parameter output_directory and date).

Metadata

Release files for factor-pricing-model-universe 2024.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for factor-pricing-model-universe 2024.0.0
File Size Uploaded Provenance Actions
factor_pricing_model_universe-2024.0.0.tar.gz 15.7 kB Without provenance Details for factor_pricing_model_universe-2024.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for factor-pricing-model-universe 2024.0.0
File Interpreter ABI Platform Actions
factor_pricing_model_universe-2024.0.0-py3-none-any.whl Python 3 none any Details for factor_pricing_model_universe-2024.0.0-py3-none-any.whl

Total release size: 30.4 kB

Release files / factor_pricing_model_universe-2024.0.0.tar.gz

Download URL factor_pricing_model_universe-2024.0.0.tar.gz
Size 15.7 kB
Tags Source
SHA-256 checksum
How to use checksums
66aa6639398f6ee0dc5ad705c36c1671e1ce1e681f46c3505797cf42053c7b98
BLAKE2b-256 checksum
How to use checksums
755b9ee94d167e8755d030efa3859f6a6cb4f2b6d180b3a9f1055a4ba21ce357
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.9.6 readme-renderer/42.0 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/1.26.5 tqdm/4.66.1 importlib-metadata/6.8.0 keyring/24.3.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.12

Release files / factor_pricing_model_universe-2024.0.0-py3-none-any.whl

Download URL factor_pricing_model_universe-2024.0.0-py3-none-any.whl
Size 14.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
10beeab4f4005046db12b5278e8f9fdb32c7d621e7333f3503b0beae4950d3cf
BLAKE2b-256 checksum
How to use checksums
eb855471e42edb473ba0eb1ed227eea986f11dec17cbdd1d9303ed4a92ab6ac5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.9.6 readme-renderer/42.0 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/1.26.5 tqdm/4.66.1 importlib-metadata/6.8.0 keyring/24.3.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.12

Security for factor-pricing-model-universe 2024.0.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.

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