Skip to content

Methodology

How calculations are validated

Every financial calculation in Ardentum is covered by automated tests with independently known answers. This page summarises what is tested and against what.

AreaVerified against
Returns, CAGR, annualisationHand-computed examples (e.g. 12 monthly returns of 1% give a CAGR of 1.0112−11.01^{12}-1; doubling over 24 months gives 2−1\sqrt2-1)
Volatility, Sharpe, Sortino, drawdown, Calmar, VaR/CVaR, beta, tracking errorClosed-form examples; brute-force drawdown; OLS slope for beta
Consistency of conventionsEx-ante Sharpe from sample estimates equals ex-post Sharpe on the same data
Risk decompositionContributions sum to volatility; marginal contributions equal numerical gradients (property-based tests)
Ledoit–Wolf (identity)scikit-learn, to machine precision
Ledoit–Wolf (constant correlation)Direct loop implementation of the paper's formulas; PyPortfolioOpt within O(1/T)O(1/T)
Bayes–SteinExplicit formula; limiting cases (equal means give full shrinkage)
Minimum variance, tangency, utility portfoliosClosed-form solutions with unrestricted weights
Efficient frontierMerton's (1972) hyperbola; monotonicity and convexity; max-Sharpe dominates every frontier point
Long-only optimisationSciPy SLSQP (multi-start), PyPortfolioOpt, brute-force grid search, KKT conditions
ConstraintsEach constraint's binding behaviour; infeasibility detection with specific messages
ESGMinimum-score satisfaction; Sharpe cannot improve under a constraint; tilt raises ESG score monotonically; ESG-Sharpe frontier non-increasing
Monte CarloAnalytic lognormal mean and median; i.i.d.-bootstrap expectation; autocorrelation preserved by the block bootstrap and destroyed by the i.i.d. bootstrap; bit-identical reproducibility with a seed
BacktestingManual replication of rebalanced portfolios; transaction-cost accounting; look-ahead invariance; strategy only sees the trailing window
AttributionLinked contributions sum to the compounded return; Brinson–Fachler effects sum to the active return
Crisis replayClosed-form value paths (constant returns); a brute-force share-count calculation; the general buy-and-hold function; contributions sum to the return; nothing before the purchase affects the result
Factor exposurestatsmodels OLS with Newey-West (HAC) standard errors, t-statistics and p-values; least-squares identities (the average return splits exactly; portfolio loadings are weighted asset loadings); hand-compounded weekly factors
Trade listClosed forms for all-purchase and full-switch cases; the cash identity and target weights for random inputs
APIEvery endpoint end-to-end on SQLite and PostgreSQL, including authentication, ownership isolation and error messages

The test suite runs on every change in continuous integration. A calculation is not considered valid until it has such a test.