The world's most elegant, institutional-grade quantitative risk API.
Project description
Nexus: The Enterprise Quantitative Risk Framework
Welcome to Nexus. Nexus is an institutional-grade library implementing 40+ advanced risk measurements, including classical metrics, downside asymmetry, tail exceedance, and convex entropic bounds (EVaR, EDaR, RLDaR).
Inspired by scikit-learn and Google's core architectures, Nexus seamlessly abstracts disjointed mathematical scripts into a devastatingly powerful execution manifold: the NexusAnalyzer. Whether you are an indie quant building alpha models who has identified undervalued opportunities, or a Wall Street hedge fund requiring millisecond precision optimizations via MOSEK/CVXPY, Nexus provides the native mathematical infrastructure needed to evaluate and construct risk-efficient portfolios.
| Documentation · Tutorials · Release Notes | |
|---|---|
| Open Source | |
| Tutorials | |
| Community | |
| CI/CD | |
| Code | |
| Downloads |
Table of contents
- 📚 Official Documentation
- Why Nexus?
- Getting started
- Features & Mathematical Supremacy
- Unparalleled Solver Routing
- Project Principles
- Installation
- Testing & Developer Setup
- License & Disclaimer
📚 Official Documentation
Nexus is built with the rigor and scale of Tier-1 technology groups (such as DeepMind or Google Research), cleanly abstracting extreme mathematical theories into a functional programmatic mesh.
For an exhaustive and mathematically rigorous breakdown of our architectural patterns, Entropic bounds, solver routing algorithms, and a complete API reference, please consult the official ReadTheDocs portal:
📖 Read the Full Documentation on ReadTheDocs ➔
The documentation deeply covers:
- Core Architecture & The Analyzer Facade
- Dynamic Solver Fallbacks (MOSEK/CVXPY Integration)
- Entropic Mathematics & Chernoff Boundaries
- Comprehensive Data Handling Pipelines
Why Nexus?
Nexus was explicitly engineered for absolute scale and mathematical extremity.
- Convex Entropic Supremacy: Standard libraries rely on empirical Historical VaR or CVaR. Nexus natively implements Entropic Value at Risk (EVaR) and Relativistic VaR (RLVaR), bounding tail risks using strict Chernoff inequalities that are completely invisible to standard historical sampling.
- Path-Dependent Drawdown Cones: Nexus introduces Entropic Drawdown at Risk (EDaR), a revolutionary metric mapping underwater geometric capital erosion onto exponential mathematically-bound cones, rather than just simple peak-to-trough calculations.
- Dynamic Solver Fallbacks: Nexus detects institutional optimization licenses (MOSEK/GUROBI) and perfectly routes extreme thermodynamics through them via
cvxpy. If licenses are missing, it flawlessly falls back to high-gradescipyoptimizers without crashing your analytical pipeline.
Getting started
Gone are the days of importing disjointed functions. Nexus abstracts the entire mathematical realm into a single NexusAnalyzer object. Here is an example demonstrating how easy it is to fetch real-life stock data and construct an exhaustive mathematical risk report matrix natively.
import numpy as np
from nexus.data.loader import NexusDataLoader
from nexus.analytics.analyzer import NexusAnalyzer
# 1. Effortless Market Ingestion
loader = NexusDataLoader()
asset_names, historical_returns = loader.fetch(
['AAPL', 'MSFT', 'JPM'],
start_date='2020-01-01'
)
# Build an equal-weighted portfolio combination
weights = np.ones(len(asset_names)) / len(asset_names)
portfolio_returns = np.sum(historical_returns * weights, axis=1)
# 2. Institutional Calibration
analyzer = NexusAnalyzer()
analyzer.calibrate(portfolio_returns)
# 3. Exhaustive Mathematical Execution
report_df = analyzer.compute(alpha=0.05, annualization_factor=252)
# Specific Dictionary Retrieval
cvar = analyzer.fetch('Cond VaR (0.05)')
print(report_df)
The Output
Asset_0
Volatility (Ann) 0.230763
Mean Abs Dev (MAD) 2.388695
Gini Mean Diff 3.579301
Lower Part Moment (LPM1) 1.096828
Value at Risk (0.05) 0.019100
Cond VaR (0.05) 0.033262
Entropic VaR (0.05) 0.067949
Cond DaR (0.05) -0.232770
Entropic DaR (0.05) 0.259398
Max Drawdown (MDD) -0.344122
Ulcer Index 0.091181
Calmar Ratio 0.884100
...
Features & Mathematical Supremacy
In this section, we detail Nexus' primary architectural pillars. More exhaustive equations can be found in our core modules.
Return Regimes & Asset Efficiency
Institutional portfolio management relies on hierarchical clustering of temporal returns and risk-adjusted efficiency plotting.
- Chronological Return Clustering: QuantStats-style Y/M grids isolating momentum drifts, tax-loss harvesting impacts, and macro-regime seasonality across annual structures.
- Asset Efficiency Hierarchies: Volatility vs. Return distributions mapping exactly which singular assets dominate the local efficient frontier.
Multivariate Dynamics & Temporal Regimes
Understanding how risks evolve over time and across asset classes is paramount. Nexus natively maps high-dimensional data flows into temporal matrices, detecting structural regime shifts before they breach limits.
- Rolling Structural Volatility: Maps moving-window variance structures directly against overlapping 95% Historical VaR clusters, instantly revealing structural macro-regime changes.
- Cross-Asset Covariance & Pearson Dependencies: Instantly maps deep empirical correlation heatmaps to guarantee zero concentration overlaps across distinct asset silos (Equities, Bonds, Crypto, Commodities).
Dispersion & Volatility
- Standard Deviation & Variance: The classical unbiased measures of historical risk.
- Mean Absolute Deviation (MAD): A perfectly robust scale metric lacking the extreme parabolic sensitivity of squared variance.
- Gini Mean Difference: A powerful absolute deviation measurement utilized in modern asset allocation.
- L-Scale: The second L-Moment representing linear combinations of order statistics.
Downside Asymmetry
- Semi-Deviation: A measure of risk that focuses purely on downside variation heavily penalized by investors.
- Lower Partial Moments (LPM): Generalized objective functions for asymmetric downside measurements parameterized by target acceptable return (
MAR).
Tail Exceedance
- Value at Risk (VaR): The industry-standard empirical percentile of the maximum loss over a targeted confidence interval $\alpha$.
- Conditional VaR (CVaR/Expected Shortfall): The expected loss given that the VaR threshold has been breached. Structurally coherent.
- Tail Gini: A unique generalized formulation merging CVaR with Gini mean difference within extreme domains.
Convex Entropic Bounds
- Entropic Value at Risk (EVaR): The tightest coherent upper bound on VaR historically derived strictly from the Chernoff inequality. Extremely responsive to extreme market shocks.
- Relativistic VaR (RLVaR): A massive 3D power-cone deformation scaling Entropic bounds to asymmetric generalized logarithmic divergences.
- Entropic Drawdown at Risk (EDaR): A revolutionary path-dependent risk metric combining geometric Chernoff bounds with historical peak-to-trough waterfall drawdowns.
Unparalleled Solver Routing
Nexus was built to scale from individual traders directly to high-frequency servers natively.
Its generalized convex penalty equations computationally detect commercial optimization licenses (like MOSEK or GUROBI via CVXPY).
- If found, it natively routes extreme computations (EVaR, EDaR, RLVaR) through absolute mathematical exponential cones, achieving millisecond precision over millions of market datapoints.
- If not found, it miraculously falls back to high-grade
scipy.optimize.minimizeopen-source algorithmic optimization without crashing.
Project principles and design decisions
- Modularity: It should be easy to swap out individual components of the analytical process with the user's proprietary improvements.
- Mathematical Transparency: All functions are internally documented with strict $\LaTeX$ formulations.
- Object-Oriented Supremacy: There is no point in portfolio optimization unless it can be practically applied to real asset matrices easily. The Facade pattern rules.
- Robustness: Extensively guarded against arrays of
NaNfragments and disjointed dimensions.
🚀 Installation
Using pip
The primary stable architecture.
pip install nexus-quant
For institutional scaling (which enforces CVXPY tensor integrations; optimally paired with a local MOSEK license instance):
pip install "nexus-quant[enterprise]"
From source
Clone the repository, navigate to the folder, and install directly using pip:
git clone https://github.com/Anagatam/Nexus.git
cd Nexus
pip install -e .
Testing & Developer Setup
Tests are written natively in pytest utilizing deterministic NumPy architectures to completely bypass yfinance REST rate limits.
Run the native Makefile to instantly configure the repository for contributing:
make install
make format
make test
License
Nexus is distributed freely under the standard MIT License. Open-source rules quantitative finance.
Disclaimer: Nothing about this project constitutes investment advice, and the author bears no responsibility for your subsequent investment decisions. Please rigorously validate all models statistically in out-of-sample data before committing live capital.
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 nexus_quant-2.0.1.tar.gz.
File metadata
- Download URL: nexus_quant-2.0.1.tar.gz
- Upload date:
- Size: 20.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd3117b100415faba2a183476b70c64421e3d232bb88cb342af91dd19b537583
|
|
| MD5 |
66f865506cfa32382c9f3ff3ba23056b
|
|
| BLAKE2b-256 |
3aabc7d04c3b4039202bdeda514c55c788cffd9ff63bb32365f5ad00f7348038
|
File details
Details for the file nexus_quant-2.0.1-py3-none-any.whl.
File metadata
- Download URL: nexus_quant-2.0.1-py3-none-any.whl
- Upload date:
- Size: 15.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ca9a09bb31ef4d2ec82ae79f78f30902a28cf2975a37b5beb4fbb721a454903
|
|
| MD5 |
796fe7db7faa00092248ab3482b741e0
|
|
| BLAKE2b-256 |
dc5aa802229b60cf7966746384a11c83ba4b201f9253e5e23a0a3c56bbc011fe
|