Readable financial contagion library from market data to portfolio analytics
Project description
fincontagion
fincontagion is a Python library for financial contagion analysis, from market data preparation to network-aware portfolio analytics.
It provides:
- price download and cleaning utilities
- infection-state construction using volatility and SIR-like states
- tail-dependence estimation and multiplex network construction
- crisis-window parameter estimation and Monte Carlo simulation
- contagion-aware portfolio rebalancing and performance summaries
- optional Plotly visualizations
Installation
Install the core package:
pip install fincontagion
Install with optional extras:
pip install "fincontagion[full]"
fullincludes:networkx,cvxpy,plotlydevincludes:pytest
Quick Start
import fincontagion as fc
universe = {
"AAPL": {"region": "USA", "sector": "Technology"},
"MSFT": {"region": "USA", "sector": "Technology"},
"JPM": {"region": "USA", "sector": "Finance"},
}
config = fc.PipelineConfig(
tickers=list(universe.keys()),
start="2020-01-01",
end="2024-12-31",
crises={"COVID_2020": ("2020-02-20", "2020-05-31")},
universe=universe,
)
result = fc.run_full_pipeline(config)
print(result["portfolio"]["summary"])
Main API
run_full_pipeline,PipelineConfigprepare_market_data,prices_to_log_returnscompute_infection_statescompute_tail_dependencebuild_network_layersestimate_parameters,simulate_sir,predict_crisesrebalance_portfolio
Visualization helpers:
plot_infection_timelineplot_region_infection_heatmapplot_sector_infection_breakdownplot_tail_dependence_heatmapplot_firm_networkplot_portfolio_performanceplot_portfolio_weights
Development
Run tests:
pytest -q
License
MIT License.
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 fincontagion-0.2.0.tar.gz.
File metadata
- Download URL: fincontagion-0.2.0.tar.gz
- Upload date:
- Size: 16.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c2257b604f4ee357b85c1394c8de0871f22cd180043841cef66a59881930e07
|
|
| MD5 |
3760c80fdc092ac75701970a1d3c575c
|
|
| BLAKE2b-256 |
100a940aa05fa136783153f415ffc8053c847e00037caa3a9e555612aa115db2
|
File details
Details for the file fincontagion-0.2.0-py3-none-any.whl.
File metadata
- Download URL: fincontagion-0.2.0-py3-none-any.whl
- Upload date:
- Size: 20.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
efedee7c3b1f470a45f6e63dd09c23a01952793d56ea196cdd7ae4f0da4df2b5
|
|
| MD5 |
e4c207075e60b1e24b30c08a510f7491
|
|
| BLAKE2b-256 |
2802a9604945dc0beab6acce0592c26501b83ba3d30475d85d2e8eb8bfb83b9a
|