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

Loss Distributions and Loss Quantiles

Install and import#

bash
npm install fintech-algorithms
ts
import { lossDistributionsAndLossQuantiles } from "fintech-algorithms/financial-mathematics-statistics-and-data-foundations/financial-risk-and-performance-statistics/loss-distributions-and-loss-quantiles";

Signature#

lossDistributionsAndLossQuantiles(input)

Worked example#

verified This is the worked example published in the article, replayed by the test suite on every run. The output cannot drift.

Input#

input
{
  "returns": [0.01, -0.02, 0.015, -0.01, 0.03],
  "benchmark": [0.008, -0.01, 0.012, -0.006, 0.02],
  "frequency": 252,
  "target": 0,
  "confidence": 0.8,
  "riskFree": 0.0001,
  "weights": [0.6, 0.4],
  "covarianceMatrix": [
    [0.04, 0.01],
    [0.01, 0.09]
  ]
}

Call#

lossDistributionsAndLossQuantiles(input)

Returns#

object with 2 fields: losses, lossQuantile

{
  "losses": [-0.03, -0.015, -0.01, 0.01, 0.02],
  "lossQuantile": 0.012000000000000002
}

Diagrams#

Loss Distributions and Loss Quantiles — article hero
Loss Distributions and Loss Quantiles — calculation ledger
Loss Distributions and Loss Quantiles — concept anatomy
Loss Distributions and Loss Quantiles — failure boundary
Loss Distributions and Loss Quantiles — method map
Loss Distributions and Loss Quantiles — scenario contrast

How it works#

This page states the contract — how to call it correctly. The article explains the concept: why it works, and where it breaks.

Read the article →

References#

The rest of the Financial Risk and Performance Statistics family#