histcondvar(): number
Historical Conditional Value-At-Risk (CVaR).
Univariate historical simulation for Conditional Value-At-Risk. Also known as Expected Shortfall (ES) or Expected Tail Loss (ETL). The CVaR is the expected loss exceeding the VaR.
Historical conditional VaR for single asset
Historical conditional VaR for single asset
import { assertEquals } from "jsr:@std/assert"; const x = [0.003, 0.026, 0.015, -0.009, 0.014, 0.024, 0.015, 0.066, -0.014, 0.039]; assertEquals(histcondvar(x, 0.95), 0.014);
Historical conditional VaR with custom amount
Historical conditional VaR with custom amount
import { assertEquals } from "jsr:@std/assert"; const x = [0.003, 0.026, 0.015, -0.009, 0.014, 0.024, 0.015, 0.066, -0.014, 0.039]; assertEquals(histcondvar(x, 0.99, 100000), 1400);
Historical conditional VaR for matrix (row-wise)
Historical conditional VaR for matrix (row-wise)
import { assertEquals } from "jsr:@std/assert"; const x = [0.003, 0.026, 0.015, -0.009, 0.014, 0.024, 0.015, 0.066, -0.014, 0.039]; const y = [-0.005, 0.081, 0.04, -0.037, -0.061, 0.058, -0.049, -0.021, 0.062, 0.058]; const matrix = [x, y]; assertEquals(histcondvar(matrix, 0.95, 1, 0), [0.014, 0.061]);
x: array
array or matrix of values
histcondvar(): array | matrix
Historical Conditional Value-At-Risk (CVaR).
Univariate historical simulation for Conditional Value-At-Risk. Also known as Expected Shortfall (ES) or Expected Tail Loss (ETL). The CVaR is the expected loss exceeding the VaR.
Historical conditional VaR for single asset
Historical conditional VaR for single asset
import { assertEquals } from "jsr:@std/assert"; const x = [0.003, 0.026, 0.015, -0.009, 0.014, 0.024, 0.015, 0.066, -0.014, 0.039]; assertEquals(histcondvar(x, 0.95), 0.014);
Historical conditional VaR with custom amount
Historical conditional VaR with custom amount
import { assertEquals } from "jsr:@std/assert"; const x = [0.003, 0.026, 0.015, -0.009, 0.014, 0.024, 0.015, 0.066, -0.014, 0.039]; assertEquals(histcondvar(x, 0.99, 100000), 1400);
Historical conditional VaR for matrix (row-wise)
Historical conditional VaR for matrix (row-wise)
import { assertEquals } from "jsr:@std/assert"; const x = [0.003, 0.026, 0.015, -0.009, 0.014, 0.024, 0.015, 0.066, -0.014, 0.039]; const y = [-0.005, 0.081, 0.04, -0.037, -0.061, 0.058, -0.049, -0.021, 0.062, 0.058]; const matrix = [x, y]; assertEquals(histcondvar(matrix, 0.95, 1, 0), [0.014, 0.061]);
x: matrix
array or matrix of values