This commit is contained in:
Boki 2025-06-11 10:35:15 -04:00
parent 8955544593
commit 9d38f9a7b6
91 changed files with 2224 additions and 1400 deletions

View file

@ -242,7 +242,7 @@ export function identifyVolatilityRegimes(
// Classify returns into regimes
const regimeSequence = absReturns.map(absRet => {
for (let i = 0; i < thresholds.length; i++) {
if (absRet <= thresholds[i]) return i;
if (absRet <= thresholds[i]) {return i;}
}
return numRegimes - 1;
});
@ -537,7 +537,7 @@ export function calculateYangZhangVolatility(
* Parkinson volatility estimator
*/
export function parkinsonVolatility(ohlcv: OHLCVData[], annualizationFactor: number = 252): number {
if (ohlcv.length < 2) return 0;
if (ohlcv.length < 2) {return 0;}
const sum = ohlcv.slice(1).reduce((acc, curr) => {
const range = Math.log(curr.high / curr.low);
return acc + range * range;