{"id":37666124,"url":"https://github.com/factorpricingmodel/factor-pricing-model-risk-model","last_synced_at":"2026-01-16T11:59:02.906Z","repository":{"id":65145003,"uuid":"570112336","full_name":"factorpricingmodel/factor-pricing-model-risk-model","owner":"factorpricingmodel","description":"Package to build risk model for factor pricing model","archived":false,"fork":false,"pushed_at":"2024-07-26T08:31:50.000Z","size":47822,"stargazers_count":27,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-09T05:19:39.281Z","etag":null,"topics":["factor-model","quantitative-finance","risk-model","risk-models"],"latest_commit_sha":null,"homepage":"https://factor-pricing-model-risk-model.readthedocs.io/en/latest/index.html","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/factorpricingmodel.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["factorpricingmodel"]}},"created_at":"2022-11-24T11:16:20.000Z","updated_at":"2025-09-19T07:16:15.000Z","dependencies_parsed_at":"2023-12-15T21:24:13.996Z","dependency_job_id":"e9bfee66-e7a0-4a5f-b4b7-90463595910f","html_url":"https://github.com/factorpricingmodel/factor-pricing-model-risk-model","commit_stats":{"total_commits":77,"total_committers":2,"mean_commits":38.5,"dds":0.06493506493506496,"last_synced_commit":"dcfe636591ea5f18f8b59a78b6eaa818f22d1fd8"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/factorpricingmodel/factor-pricing-model-risk-model","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/factorpricingmodel%2Ffactor-pricing-model-risk-model","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/factorpricingmodel%2Ffactor-pricing-model-risk-model/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/factorpricingmodel%2Ffactor-pricing-model-risk-model/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/factorpricingmodel%2Ffactor-pricing-model-risk-model/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/factorpricingmodel","download_url":"https://codeload.github.com/factorpricingmodel/factor-pricing-model-risk-model/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/factorpricingmodel%2Ffactor-pricing-model-risk-model/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28478391,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T06:30:42.265Z","status":"ssl_error","status_checked_at":"2026-01-16T06:30:16.248Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["factor-model","quantitative-finance","risk-model","risk-models"],"created_at":"2026-01-16T11:59:02.833Z","updated_at":"2026-01-16T11:59:02.891Z","avatar_url":"https://github.com/factorpricingmodel.png","language":"Python","funding_links":["https://github.com/sponsors/factorpricingmodel"],"categories":[],"sub_categories":[],"readme":"# Factor Pricing Model Risk Model\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/factorpricingmodel/factor-pricing-model-risk-model/actions?query=workflow%3ACI\"\u003e\n    \u003cimg src=\"https://github.com/factorpricingmodel/factor-pricing-model-risk-model/actions/workflows/ci.yml/badge.svg\" alt=\"CI Status\" \u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://factor-pricing-model-risk-model.readthedocs.io\"\u003e\n    \u003cimg src=\"https://img.shields.io/readthedocs/factor-pricing-model-risk-model.svg?logo=read-the-docs\u0026logoColor=fff\u0026style=flat-square\" alt=\"Documentation Status\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://codecov.io/gh/factorpricingmodel/factor-pricing-model-risk-model\"\u003e\n    \u003cimg src=\"https://img.shields.io/codecov/c/github/factorpricingmodel/factor-pricing-model-risk-model.svg?logo=codecov\u0026logoColor=fff\u0026style=flat-square\" alt=\"Test coverage percentage\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://python-poetry.org/\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/packaging-poetry-299bd7?style=flat-square\u0026logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAASCAYAAABrXO8xAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAJJSURBVHgBfZLPa1NBEMe/s7tNXoxW1KJQKaUHkXhQvHgW6UHQQ09CBS/6V3hKc/AP8CqCrUcpmop3Cx48eDB4yEECjVQrlZb80CRN8t6OM/teagVxYZi38+Yz853dJbzoMV3MM8cJUcLMSUKIE8AzQ2PieZzFxEJOHMOgMQQ+dUgSAckNXhapU/NMhDSWLs1B24A8sO1xrN4NECkcAC9ASkiIJc6k5TRiUDPhnyMMdhKc+Zx19l6SgyeW76BEONY9exVQMzKExGKwwPsCzza7KGSSWRWEQhyEaDXp6ZHEr416ygbiKYOd7TEWvvcQIeusHYMJGhTwF9y7sGnSwaWyFAiyoxzqW0PM/RjghPxF2pWReAowTEXnDh0xgcLs8l2YQmOrj3N7ByiqEoH0cARs4u78WgAVkoEDIDoOi3AkcLOHU60RIg5wC4ZuTC7FaHKQm8Hq1fQuSOBvX/sodmNJSB5geaF5CPIkUeecdMxieoRO5jz9bheL6/tXjrwCyX/UYBUcjCaWHljx1xiX6z9xEjkYAzbGVnB8pvLmyXm9ep+W8CmsSHQQY77Zx1zboxAV0w7ybMhQmfqdmmw3nEp1I0Z+FGO6M8LZdoyZnuzzBdjISicKRnpxzI9fPb+0oYXsNdyi+d3h9bm9MWYHFtPeIZfLwzmFDKy1ai3p+PDls1Llz4yyFpferxjnyjJDSEy9CaCx5m2cJPerq6Xm34eTrZt3PqxYO1XOwDYZrFlH1fWnpU38Y9HRze3lj0vOujZcXKuuXm3jP+s3KbZVra7y2EAAAAAASUVORK5CYII=\" alt=\"Poetry\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/ambv/black\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/code%20style-black-000000.svg?style=flat-square\" alt=\"black\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/pre-commit/pre-commit\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit\u0026logoColor=white\u0026style=flat-square\" alt=\"pre-commit\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://pypi.org/project/factor-pricing-model-risk-model/\"\u003e\n    \u003cimg src=\"https://img.shields.io/pypi/v/factor-pricing-model-risk-model.svg?logo=python\u0026logoColor=fff\u0026style=flat-square\" alt=\"PyPI Version\"\u003e\n  \u003c/a\u003e\n  \u003cimg src=\"https://img.shields.io/pypi/pyversions/factor-pricing-model-risk-model.svg?style=flat-square\u0026logo=python\u0026amp;logoColor=fff\" alt=\"Supported Python versions\"\u003e\n  \u003cimg src=\"https://img.shields.io/pypi/l/factor-pricing-model-risk-model.svg?style=flat-square\" alt=\"License\"\u003e\n\u003c/p\u003e\n\nPackage to build risk model for factor pricing model. For further details, please refer\nto the [documentation](https://factor-pricing-model-risk-model.readthedocs.io/en/latest/)\n\n## Installation\n\nInstall this via pip (or your favourite package manager):\n\n`pip install factor-pricing-model-risk-model`\n\n## Usage\n\nThe library contains the pipelines to build the risk model. You can\nrun the pipelines interactively in Jupyter Notebook.\n\n```python\nimport fpm_risk_model\n```\n\n## Objective\n\nThe project provides frameworks to create multi-factor risk\nmodel on an \"enterprise-like\" level.\n\nThe target audiences are researchers, developers and fund\nmanagement looking for flexibility in creating risk models.\n\n## Examples\n\nFor end-to-end examples, please refer to [examples](https://github.com/factorpricingmodel/factor-pricing-model-risk-model/tree/main/examples) for the below notebooks\n\n- [Cryptocurrency Statistical Risk Model](https://colab.research.google.com/github/factorpricingmodel/factor-pricing-model-risk-model/blob/main/examples/notebook/crypto_statistical_risk_model.ipynb)\n\n- [NumPy Backend Engine](https://colab.research.google.com/github/factorpricingmodel/factor-pricing-model-risk-model/blob/main/examples/notebook/numpy_backend_engine.ipynb)\n\n- [Empirical Analysis of Alpha Sizing Rules in Cryptocurrency](https://colab.research.google.com/github/factorpricingmodel/factor-pricing-model-risk-model/blob/main/examples/notebook/crypto_empirical_analysis_alpha_sizing_rules.ipynb)\n\n## Features\n\nBasically, there are three major features provided in the library\n\n- Factor risk model creation\n- Covariance estimator\n- Tracking risk model accuracy\n\n## Factor risk model\n\nThe factor risk model is created by fitting instrument returns (which\ncould be weekly, daily, or even higher granularity) and other related\nparameters into the model, and its products are factor exposures,\nfactor returns, factor covariance, and residual returns (idiosyncratic\nreturns).\n\nFor example, to create a simple statistical PCA risk model,\n\n```\nfrom fpm_risk_model.statistics import PCA\n\nrisk_model = PCA(n_components=5)\nrisk_model.fit(X=returns)\n\n# Get fitted factor exposures\nrisk_model.factor_exposures\n```\n\nThen, the risk model can be transformed by the returns of a\nlarger homogeneous universe.\n\n```\nrisk_model.transform(y=model_returns)\n```\n\nFor further details, please refer to the [section](https://factor-pricing-model-risk-model.readthedocs.io/en/latest/risk_model/factor_risk_model.html) in the documentation.\n\n## Covariance estimation\n\nCurrently, covariance estimation is supported in factor risk model,\nand the estimation depends on the fitted results.\n\nFor example, a risk model transformed by model universe returns can\nderive the pairwise covariance and correlation for the model universe.\n\n```\nrisk_model.transform(y=model_returns)\n\ncov = risk_model.cov()\ncorr = risk_model.corr()\n```\n\nAlternatively, covariance estimator `CovarianceEstimator`\n(or `RollingCovarianceEstimator` in a rolling basis) provides advanced\nfeatures, including covariance shrinkage and variance adjustment.\nThe following shrinkage methods are supported\n\n- Constant\n- Ledoit Wolf shrinkage (Q3 2023)\n- Oracle Approximating shrinkage (Q3 2023)\n\nFor example, to construct a rolling covariance estimator with constant\nshrinkage delta 0.2,\n\n```\nfrom fpm_risk_model import RollingCovarianceEstimator\n\nestimator = RollingCovarianceEstimator(\n  rolling_risk_model,\n  shrinkage_method=\"constant\",\n  delta=0.2\n)\n```\n\nthen the covariance can be computed with the rolling risk model and\nvolatilities with better forecasting accuracy\n\n```\nestimator.cov(volatility=another_estimated_vol)\n```\n\nFor further details, please refer to the [section](https://factor-pricing-model-risk-model.readthedocs.io/en/latest/risk_model/covariance.html) in the documentation.\n\n## Tracking risk model accuracy\n\nThe library also focuses on the predictability interpretation of the risk\nmodel, and provides a few benchmarks to examine the following metrics\n\n- [Bias](https://factor-pricing-model-risk-model.readthedocs.io/en/latest/accuracy/bias.html)\n- [Value at Risk (VaR)](https://factor-pricing-model-risk-model.readthedocs.io/en/latest/accuracy/value_at_risk.html)\n\nFor example, to examine the bias statistics of a risk model regarding\nan equally weighted portfolio (of which its weights are denoted as `weights`),\npass the instrument observed returns (denoted as `returns`), and either\na rolling risk model (to compute the volatility forecast) or a time series\nof volatility forecasts.\n\n```\nfrom fpm_risk_model.accuracy import compute_bias_statistics\ncompute_bias_statistics(\n  X=returns,\n  weights=weights,\n  window=window\n  ...\n)\n```\n\n## Roadmap\n\nThe following major features will be enhanced\n\n- Factor exposures computation from factor returns (Q3 2023)\n- Shrinking covariance (Q3 2023)\n- Multi-asset class factor model (Q4 2023)\n- Fundamental type risk model (Q4 2023)\n\n## Contribution\n\nAll levels of contributions are welcomed. Please refer to the [contributing](https://factor-pricing-model-risk-model.readthedocs.io/en/latest/contributing.html)\nsection for development and release guidelines.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffactorpricingmodel%2Ffactor-pricing-model-risk-model","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffactorpricingmodel%2Ffactor-pricing-model-risk-model","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffactorpricingmodel%2Ffactor-pricing-model-risk-model/lists"}