garch 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/build/index.cjs +1 -0
- package/build/index.mjs +1 -1
- package/package.json +48 -48
- package/types.d.ts +9 -1
package/README.md
CHANGED
|
@@ -556,13 +556,13 @@ where RV_t is Parkinson per-candle realized variance and sigma_t^2 is the model'
|
|
|
556
556
|
|
|
557
557
|
## Tests
|
|
558
558
|
|
|
559
|
-
**
|
|
559
|
+
**932 tests** across **22 test files**. All passing.
|
|
560
560
|
|
|
561
561
|
| Category | Files | Tests | What's covered |
|
|
562
562
|
|----------|-------|-------|----------------|
|
|
563
563
|
| Mathematical formulas | `math.test.ts` | 45 | GARCH/EGARCH variance recursion, log-likelihood, forecast formulas, AIC/BIC, QLIKE, Yang-Zhang, Garman-Klass, Ljung-Box, chi-squared |
|
|
564
564
|
| Math coverage | `math-coverage.test.ts` | 79 | Parkinson formula verification, rv↔returns alignment, H=L fallback, Parkinson-based forecast, candle validation, reliable flag cascade, backtest validity, numerical precision, cross-model consistency, Realized GARCH/EGARCH/GJR-GARCH Candle[] vs number[], perCandleParkinson shared function |
|
|
565
|
-
| Full pipeline coverage | `plan-coverage.test.ts` |
|
|
565
|
+
| Full pipeline coverage | `plan-coverage.test.ts` | 82 | End-to-end: fit, forecast, predict, predictRange, backtest, model selection |
|
|
566
566
|
| GARCH unit | `garch.test.ts` | 10 | Parameter estimation, variance series, forecast convergence, candle vs price input |
|
|
567
567
|
| EGARCH unit | `egarch.test.ts` | 11 | Leverage detection, asymmetric volatility, model comparison |
|
|
568
568
|
| GJR-GARCH unit | `gjr-garch.test.ts` | 86 | Variance recursion (r² and Parkinson), indicator function I(r<0), forecast formula (one-step + multi-step), constraint barriers, computed fields, AIC/BIC numParams=5, estimation properties (perturbation, determinism), numerical stability, degenerate params, Realized path (Candle[] vs number[], flat candles, bad OHLC), options forwarding, immutability, instance isolation, cross-model consistency, scale invariance, property-based fuzz, predict/predictRange/backtest integration |
|
package/build/index.cjs
CHANGED
|
@@ -1879,6 +1879,7 @@ exports.nelderMeadMultiStart = nelderMeadMultiStart;
|
|
|
1879
1879
|
exports.perCandleParkinson = perCandleParkinson;
|
|
1880
1880
|
exports.predict = predict;
|
|
1881
1881
|
exports.predictRange = predictRange;
|
|
1882
|
+
exports.probit = probit;
|
|
1882
1883
|
exports.profileStudentTDf = profileStudentTDf;
|
|
1883
1884
|
exports.qlike = qlike;
|
|
1884
1885
|
exports.sampleVariance = sampleVariance;
|
package/build/index.mjs
CHANGED
|
@@ -1853,4 +1853,4 @@ function backtest(candles, interval, confidence = 0.6827, requiredPercent = 68)
|
|
|
1853
1853
|
return (hits / total) * 100 >= requiredPercent;
|
|
1854
1854
|
}
|
|
1855
1855
|
|
|
1856
|
-
export { EXPECTED_ABS_NORMAL, Egarch, Garch, GjrGarch, HarRv, NoVaS, backtest, calculateReturns, calculateReturnsFromPrices, calibrateEgarch, calibrateGarch, calibrateGjrGarch, calibrateHarRv, calibrateNoVaS, checkLeverageEffect, expectedAbsStudentT, garmanKlassVariance, ljungBox, logGamma, nelderMead, nelderMeadMultiStart, perCandleParkinson, predict, predictRange, profileStudentTDf, qlike, sampleVariance, sampleVarianceWithMean, studentTNegLL, yangZhangVariance };
|
|
1856
|
+
export { EXPECTED_ABS_NORMAL, Egarch, Garch, GjrGarch, HarRv, NoVaS, backtest, calculateReturns, calculateReturnsFromPrices, calibrateEgarch, calibrateGarch, calibrateGjrGarch, calibrateHarRv, calibrateNoVaS, checkLeverageEffect, expectedAbsStudentT, garmanKlassVariance, ljungBox, logGamma, nelderMead, nelderMeadMultiStart, perCandleParkinson, predict, predictRange, probit, profileStudentTDf, qlike, sampleVariance, sampleVarianceWithMean, studentTNegLL, yangZhangVariance };
|
package/package.json
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "garch",
|
|
3
|
-
"version": "1.2.
|
|
4
|
-
"description": "GARCH and EGARCH volatility models for TypeScript",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "./build/index.cjs",
|
|
7
|
-
"module": "./build/index.mjs",
|
|
8
|
-
"types": "./types.d.ts",
|
|
9
|
-
"exports": {
|
|
10
|
-
".": {
|
|
11
|
-
"types": "./types.d.ts",
|
|
12
|
-
"import": "./build/index.mjs",
|
|
13
|
-
"require": "./build/index.cjs"
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
"files": [
|
|
17
|
-
"build",
|
|
18
|
-
"types.d.ts",
|
|
19
|
-
"README.md"
|
|
20
|
-
],
|
|
21
|
-
"scripts": {
|
|
22
|
-
"build": "rollup -c",
|
|
23
|
-
"test": "vitest run",
|
|
24
|
-
"test:watch": "vitest",
|
|
25
|
-
"prepublishOnly": "npm run build"
|
|
26
|
-
},
|
|
27
|
-
"keywords": [
|
|
28
|
-
"garch",
|
|
29
|
-
"egarch",
|
|
30
|
-
"volatility",
|
|
31
|
-
"finance",
|
|
32
|
-
"econometrics",
|
|
33
|
-
"time-series"
|
|
34
|
-
],
|
|
35
|
-
"author": "",
|
|
36
|
-
"license": "MIT",
|
|
37
|
-
"devDependencies": {
|
|
38
|
-
"@rollup/plugin-typescript": "^12.3.0",
|
|
39
|
-
"@types/node": "^20.10.0",
|
|
40
|
-
"@vitest/coverage-v8": "^1.6.1",
|
|
41
|
-
"rollup": "^4.57.1",
|
|
42
|
-
"rollup-plugin-dts": "^6.3.0",
|
|
43
|
-
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
44
|
-
"tslib": "^2.8.1",
|
|
45
|
-
"typescript": "^5.3.0",
|
|
46
|
-
"vitest": "^1.0.0"
|
|
47
|
-
}
|
|
48
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "garch",
|
|
3
|
+
"version": "1.2.1",
|
|
4
|
+
"description": "GARCH and EGARCH volatility models for TypeScript",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./build/index.cjs",
|
|
7
|
+
"module": "./build/index.mjs",
|
|
8
|
+
"types": "./types.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./types.d.ts",
|
|
12
|
+
"import": "./build/index.mjs",
|
|
13
|
+
"require": "./build/index.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"build",
|
|
18
|
+
"types.d.ts",
|
|
19
|
+
"README.md"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "rollup -c",
|
|
23
|
+
"test": "vitest run",
|
|
24
|
+
"test:watch": "vitest",
|
|
25
|
+
"prepublishOnly": "npm run build"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"garch",
|
|
29
|
+
"egarch",
|
|
30
|
+
"volatility",
|
|
31
|
+
"finance",
|
|
32
|
+
"econometrics",
|
|
33
|
+
"time-series"
|
|
34
|
+
],
|
|
35
|
+
"author": "",
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@rollup/plugin-typescript": "^12.3.0",
|
|
39
|
+
"@types/node": "^20.10.0",
|
|
40
|
+
"@vitest/coverage-v8": "^1.6.1",
|
|
41
|
+
"rollup": "^4.57.1",
|
|
42
|
+
"rollup-plugin-dts": "^6.3.0",
|
|
43
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
44
|
+
"tslib": "^2.8.1",
|
|
45
|
+
"typescript": "^5.3.0",
|
|
46
|
+
"vitest": "^1.0.0"
|
|
47
|
+
}
|
|
48
|
+
}
|
package/types.d.ts
CHANGED
|
@@ -487,6 +487,14 @@ declare function profileStudentTDf(returns: number[], varianceSeries: number[]):
|
|
|
487
487
|
* of how the model was calibrated (MLE, OLS, D², etc.).
|
|
488
488
|
*/
|
|
489
489
|
declare function qlike(varianceSeries: number[], rv: number[]): number;
|
|
490
|
+
/**
|
|
491
|
+
* Inverse standard normal CDF (probit function).
|
|
492
|
+
* Converts a two-sided confidence level (e.g. 0.95) to the corresponding
|
|
493
|
+
* z-score (e.g. 1.96).
|
|
494
|
+
*
|
|
495
|
+
* Uses Acklam's rational approximation (max relative error < 1.15e-9).
|
|
496
|
+
*/
|
|
497
|
+
declare function probit(confidence: number): number;
|
|
490
498
|
|
|
491
499
|
type CandleInterval = '1m' | '3m' | '5m' | '15m' | '30m' | '1h' | '2h' | '4h' | '6h' | '8h';
|
|
492
500
|
interface PredictionResult {
|
|
@@ -541,5 +549,5 @@ declare function nelderMeadMultiStart(fn: (x: number[]) => number, x0: number[],
|
|
|
541
549
|
restarts?: number;
|
|
542
550
|
}): OptimizerResult;
|
|
543
551
|
|
|
544
|
-
export { EXPECTED_ABS_NORMAL, Egarch, Garch, GjrGarch, HarRv, NoVaS, backtest, calculateReturns, calculateReturnsFromPrices, calibrateEgarch, calibrateGarch, calibrateGjrGarch, calibrateHarRv, calibrateNoVaS, checkLeverageEffect, expectedAbsStudentT, garmanKlassVariance, ljungBox, logGamma, nelderMead, nelderMeadMultiStart, perCandleParkinson, predict, predictRange, profileStudentTDf, qlike, sampleVariance, sampleVarianceWithMean, studentTNegLL, yangZhangVariance };
|
|
552
|
+
export { EXPECTED_ABS_NORMAL, Egarch, Garch, GjrGarch, HarRv, NoVaS, backtest, calculateReturns, calculateReturnsFromPrices, calibrateEgarch, calibrateGarch, calibrateGjrGarch, calibrateHarRv, calibrateNoVaS, checkLeverageEffect, expectedAbsStudentT, garmanKlassVariance, ljungBox, logGamma, nelderMead, nelderMeadMultiStart, perCandleParkinson, predict, predictRange, probit, profileStudentTDf, qlike, sampleVariance, sampleVarianceWithMean, studentTNegLL, yangZhangVariance };
|
|
545
553
|
export type { CalibrationResult, Candle, CandleInterval, EgarchOptions, EgarchParams, GarchOptions, GarchParams, GjrGarchOptions, GjrGarchParams, HarRvOptions, HarRvParams, LeverageStats, NoVaSOptions, NoVaSParams, OptimizerResult, PredictionResult, VolatilityForecast };
|