Skip to main content

The world's most elegant, institutional-grade quantitative risk API.

Project description

Nexus Risk Engine

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 License: MIT Platform
Tutorials Binder
Community Discord LinkedIn
CI/CD CI/CD Validation Docs
Code PyPI Python Versions Code Style
Downloads Downloads Downloads Cumulative
Citation JOSS article

Nexus Risk Manifold


Table of contents


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.

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 Risk Regimes

  • 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).

Cross-Asset Correlation

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).

Nexus Drawdown Topography

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.

Extreme Tail Convexity Breakdown

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.minimize open-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 NaN fragments 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nexus_quant-2.0.0.tar.gz (17.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nexus_quant-2.0.0-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file nexus_quant-2.0.0.tar.gz.

File metadata

  • Download URL: nexus_quant-2.0.0.tar.gz
  • Upload date:
  • Size: 17.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for nexus_quant-2.0.0.tar.gz
Algorithm Hash digest
SHA256 4686ee1dec26ec90f85864f6c7086623a8568c1b7b6add558c2e8836263c85cb
MD5 12a141e4e63e0370dfdbcb2325efe17b
BLAKE2b-256 89d2437c6729539a61854eff321e4f985958cc790ff31021e389688516c771d0

See more details on using hashes here.

File details

Details for the file nexus_quant-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: nexus_quant-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for nexus_quant-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 89dcf408d0caca89df72a22d31e303460319c15a116f040b3d04bce9ae45dc88
MD5 d587690c8a8502a30462f9efc2a3dbd5
BLAKE2b-256 2d8aa8f3d67ddc50e9c386654bcd56c76e61a1ab03a4cc7d4803946a5a127785

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page