UNPKG

quant-zero

Version:

Node-Quant is a powerful Node.js package for developing and testing quantitative trading strategies in cryptocurrency markets, offering tools for backtesting and performance analysis.

8 lines (7 loc) 255 B
export function calcVariance(returns: number[]): number { const meanReturn = returns.reduce((sum, r) => sum + r, 0) / returns.length return ( returns.reduce((varSum, r) => varSum + Math.pow(r - meanReturn, 2), 0) / returns.length ) }