Why jaxfolio¶
Portfolio construction has splintered into many methods — mean–variance, risk parity, hierarchical clustering, learned policies — and, increasingly, options overlays layered on top of an equity book. Each is powerful, but in practice they arrive as disconnected tools: a QP solver here, a clustering script there, a separate options pricer, each with its own inputs, quirks, and no common way to compare them or hedge across them.
That fragmentation is the real cost. Swapping one strategy for another means rewriting glue code; comparing them fairly means re-implementing the same backtest three times; and taking a gradient through an allocation — the thing modern, learning-based methods depend on — is simply impossible when the pieces do not share a numerical foundation.
jaxfolio unifies them on a single differentiable core. Sixteen optimizers —
classical, learning-based, and graph-based — sit behind one interface,
method(returns) → PortfolioResult, and every constrained method is the same
JIT-compiled projected-gradient solver with a different objective. Because the
whole pipeline (moment estimation → optimization → backtest) is JAX, it is
end-to-end differentiable and fast: you can backtest thousands of rebalances,
differentiate through an optimizer to train an allocation policy, and get exact
option Greeks for an entire chain from the same autodiff that prices it.
viz.dashboard.What is inside¶
Optimizers¶
Sixteen methods — classical, learning, and graph-based — behind one interface.
Backtesting¶
A vectorized walk-forward engine with costs, turnover, and a full metric suite.
LLM strategies¶
Local-model views routed through Black–Litterman — no API keys, fully offline.
Custom strategies¶
Register your own method; it works everywhere the built-ins do.
Visualization¶
Publication-quality dark-themed plots for every stage of the workflow.
Benchmark¶
Because every constrained optimizer is the same cached JIT kernel with a different objective, a rolling-rebalance backtest compiles once and reuses the compiled solve at every rebalance. jaxfolio matches the dedicated QP solvers' optimum while being the fastest on minimum-variance and risk parity — and competitive on maximum-Sharpe.
examples/benchmark.
Quickstart¶
import jaxfolio as jf
from jaxfolio.backtest import compare
from jaxfolio import viz
returns = jf.generate_returns(n_assets=10, seed=7) # or load_yfinance / load_csv
results = compare(returns, {
"Max Sharpe": jf.maximum_sharpe,
"HRP": jf.hierarchical_risk_parity,
"Risk Parity": jf.risk_parity,
"1/N": jf.equal_weight,
})
viz.save(viz.dashboard(results, returns), "dashboard.png")
Capabilities at a glance¶
| Family | Methods |
|---|---|
| Traditional | min-variance · mean-variance · max-Sharpe · max-diversification · risk parity (ERC) · Kelly · min-CVaR · Black–Litterman |
| Learning | differentiable MLP Sharpe policy · online exponentiated-gradient |
| Graph | hierarchical risk parity (HRP) · HERC · MST centrality |
| LLM (local) | LLM → Black–Litterman views · news-sentiment tilt · multi-agent debate |
| Options | Black–Scholes pricing · Greeks via autodiff · implied vol · 10+ multi-leg strategies · collar / covered-call overlays |
| Backtest | walk-forward engine · costs & turnover · Sharpe / Sortino / Calmar / VaR / CVaR / drawdown |
| Data | synthetic GBM · CSV · Parquet · Yahoo Finance · option chains |
New here?
Start with Installation, then the
Quickstart. To understand how the pieces
fit together — the shared solver, PortfolioResult, and the moment
pipeline — read Core concepts.