fintech-algorithms
Using a coding agent? Give it the skill: npx skills add IslamBaraka90/Fintech-Algorithms-Library What it does →

Financial Risk and Performance Statistics

10 algorithms in Financial Mathematics, Statistics, and Data Foundations · 10 with asserted arithmetic.

In this family#

  1. Volatility and Annualized Volatility verified

    Takes the sample standard deviation of a return series and rescales it to an annual horizon by the square root of the observations per year.

    volatilityAndAnnualizedVolatility(input)
  2. Downside Deviation and Target Shortfall verified

    Measures dispersion of returns below a target only, so upside swings do not count as risk.

    downsideDeviationAndTargetShortfall(input)
  3. Drawdown and Maximum Drawdown verified

    Compounds a return series into a wealth path and tracks how far that path sits below its own running peak.

    drawdownAndMaximumDrawdown(input)
  4. Loss Distributions and Loss Quantiles verified

    Flips a return series into losses, sorts them, and reads off the quantile at the requested confidence by linear interpolation between neighbours.

    lossDistributionsAndLossQuantiles(input)
  5. Value at Risk Intuition verified

    Reads historical value at risk straight off the sorted loss series and counts how many observed losses ran past it.

    valueAtRiskIntuition(input)
  6. Expected Shortfall Intuition verified

    Averages the losses that sit at or beyond the value-at-risk threshold, describing the tail rather than only its edge.

    expectedShortfallIntuition(input)
  7. Beta and Market-Relative Risk verified

    Divides the sample covariance between a return series and its benchmark by the benchmark's sample variance.

    betaAndMarketRelativeRisk(input)
  8. Sharpe, Sortino, and Information Ratio Intuition verified

    Computes three reward-per-unit-of-risk ratios from the same series, each dividing an average by a different notion of risk.

    sharpeSortinoAndInformationRatioIntuition(input)
  9. Active Return and Tracking Error verified

    Subtracts the benchmark from the portfolio period by period, then reports the average and the annualized volatility of that difference.

    activeReturnAndTrackingError(input)
  10. Covariance Matrices, Portfolio Variance, and Diversification verified

    Combines portfolio weights with a covariance matrix into portfolio variance, and isolates the share of it that comes from the off-diagonal terms.

    covarianceMatricesPortfolioVarianceAndDiversification(input)

What they share#

Every topic here is a record-transform, so once you have called one the rest follow the same shape. Import paths differ only in the final segment:

ts
import { volatilityAndAnnualizedVolatility } from "fintech-algorithms/foundations/financial-risk-and-performance-statistics/volatility-and-annualized-volatility";
import { downsideDeviationAndTargetShortfall } from "fintech-algorithms/foundations/financial-risk-and-performance-statistics/downside-deviation-and-target-shortfall";

Read them in the order above — the sequence is pedagogical, not alphabetical.

Where this sits#

Financial Mathematics, Statistics, and Data Foundations collects 120 algorithms across 12 families. For the concept behind this family rather than the call signatures, see the concept guides.