qntjs-lib 1.0.0
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/LICENSE +695 -0
- package/README.md +60 -0
- package/dist/arr/arr.d.ts +81 -0
- package/dist/bundle/index.d.ts +1573 -0
- package/dist/bundle/index.js +3169 -0
- package/dist/index.d.ts +4 -0
- package/dist/math/basic.d.ts +174 -0
- package/dist/math/index.d.ts +11 -0
- package/dist/math/linalg.d.ts +36 -0
- package/dist/math/minmax.d.ts +81 -0
- package/dist/math/prod.d.ts +20 -0
- package/dist/math/random.d.ts +22 -0
- package/dist/math/sum.d.ts +26 -0
- package/dist/stats/index.d.ts +10 -0
- package/dist/stats/mean.d.ts +53 -0
- package/dist/stats/quantile.d.ts +42 -0
- package/dist/stats/sampling.d.ts +23 -0
- package/dist/stats/skew.d.ts +26 -0
- package/dist/stats/transforms.d.ts +48 -0
- package/dist/stats/var.d.ts +42 -0
- package/dist/ta/index.d.ts +13 -0
- package/dist/ta/momentum-oscillators/ao.d.ts +11 -0
- package/dist/ta/momentum-oscillators/apo.d.ts +11 -0
- package/dist/ta/momentum-oscillators/aroon.d.ts +11 -0
- package/dist/ta/momentum-oscillators/cmo.d.ts +10 -0
- package/dist/ta/momentum-oscillators/index.d.ts +14 -0
- package/dist/ta/momentum-oscillators/kst.d.ts +29 -0
- package/dist/ta/momentum-oscillators/macd.d.ts +12 -0
- package/dist/ta/momentum-oscillators/mom.d.ts +9 -0
- package/dist/ta/momentum-oscillators/ppo.d.ts +11 -0
- package/dist/ta/momentum-oscillators/roc.d.ts +18 -0
- package/dist/ta/momentum-oscillators/rsi.d.ts +14 -0
- package/dist/ta/momentum-oscillators/stoch.d.ts +14 -0
- package/dist/ta/momentum-oscillators/stochrsi.d.ts +9 -0
- package/dist/ta/momentum-oscillators/ultosc.d.ts +17 -0
- package/dist/ta/momentum-oscillators/wpr.d.ts +12 -0
- package/dist/ta/moving-averages/dema.d.ts +10 -0
- package/dist/ta/moving-averages/ema.d.ts +10 -0
- package/dist/ta/moving-averages/hma.d.ts +10 -0
- package/dist/ta/moving-averages/index.d.ts +11 -0
- package/dist/ta/moving-averages/kama.d.ts +14 -0
- package/dist/ta/moving-averages/rma.d.ts +11 -0
- package/dist/ta/moving-averages/sma.d.ts +11 -0
- package/dist/ta/moving-averages/t3.d.ts +24 -0
- package/dist/ta/moving-averages/tema.d.ts +10 -0
- package/dist/ta/moving-averages/trima.d.ts +9 -0
- package/dist/ta/moving-averages/vwma.d.ts +17 -0
- package/dist/ta/moving-averages/wma.d.ts +11 -0
- package/dist/ta/trend/cci.d.ts +13 -0
- package/dist/ta/trend/di.d.ts +36 -0
- package/dist/ta/trend/dpo.d.ts +10 -0
- package/dist/ta/trend/ichimoku.d.ts +20 -0
- package/dist/ta/trend/index.d.ts +6 -0
- package/dist/ta/trend/psar.d.ts +10 -0
- package/dist/ta/trend/supertrend.d.ts +14 -0
- package/dist/ta/util.d.ts +53 -0
- package/dist/ta/volatility/atr.d.ts +23 -0
- package/dist/ta/volatility/bb.d.ts +11 -0
- package/dist/ta/volatility/bbw.d.ts +10 -0
- package/dist/ta/volatility/donchian.d.ts +11 -0
- package/dist/ta/volatility/index.d.ts +5 -0
- package/dist/ta/volatility/keltner.d.ts +12 -0
- package/dist/ta/volume-money-flow/ad.d.ts +12 -0
- package/dist/ta/volume-money-flow/adosc.d.ts +15 -0
- package/dist/ta/volume-money-flow/index.d.ts +6 -0
- package/dist/ta/volume-money-flow/mfi.d.ts +12 -0
- package/dist/ta/volume-money-flow/obv.d.ts +9 -0
- package/dist/ta/volume-money-flow/pnvi.d.ts +10 -0
- package/dist/ta/volume-money-flow/wad.d.ts +11 -0
- package/dist/untyped/index.d.ts +1194 -0
- package/dist/untyped/index.js +29 -0
- package/package.json +58 -0
package/README.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# qntjs-lib
|
|
2
|
+
|
|
3
|
+
A compact JavaScript/TypeScript library of numerical helpers and technical-analysis indicators.
|
|
4
|
+
|
|
5
|
+
This repository provides a comprehensive set of TA indicators (EMA, TEMA, T3, MFI, KAMA, etc.), vectorized math functions, array utilities, and statistical helpers.
|
|
6
|
+
|
|
7
|
+
For best performance, functions operate and return typed arrays like Float64Array.
|
|
8
|
+
For convenience, the same functions are also exposed with number[] return types.
|
|
9
|
+
|
|
10
|
+
Most functions skip NaN by default in their calculations.
|
|
11
|
+
Some functions accept boolean skipna to skip or not NaN.
|
|
12
|
+
When skipna=false is passed to these functions, a fast dense path is executed.
|
|
13
|
+
|
|
14
|
+
**Quick Start**
|
|
15
|
+
|
|
16
|
+
Install:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install qntjs-lib
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Basic usage:
|
|
23
|
+
|
|
24
|
+
```js
|
|
25
|
+
import { ta, arr } from 'qntjs-lib';
|
|
26
|
+
|
|
27
|
+
const prices = [1,2,3,4,5,6,7];
|
|
28
|
+
const out = ta.ema(prices, 3);
|
|
29
|
+
console.log(out);
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
API highlights
|
|
33
|
+
|
|
34
|
+
- `ta.*` — technical indicators (e.g. `ta.ema`, `ta.t3`, `ta.mfi`, `ta.kama`)
|
|
35
|
+
- `arr.*` — array utilities
|
|
36
|
+
- `math.*` — math helpers
|
|
37
|
+
|
|
38
|
+
Tests & development
|
|
39
|
+
|
|
40
|
+
Run tests:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npm test
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Run build (produce distributable artifacts):
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npm run build
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Contributing
|
|
53
|
+
|
|
54
|
+
- Open an issue to discuss larger changes.
|
|
55
|
+
- Run tests and keep coverage high for changes to core algorithms.
|
|
56
|
+
- Follow the existing style and types in `src/`.
|
|
57
|
+
|
|
58
|
+
License
|
|
59
|
+
|
|
60
|
+
See `LICENSE` in the repo root.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Elementwise equality comparison of two arrays, treating NaNs as equal.
|
|
3
|
+
* If `precision` is provided, numeric comparison uses a tolerance of 10^-precision.
|
|
4
|
+
* @param source1 First input array
|
|
5
|
+
* @param source2 Second input array
|
|
6
|
+
* @param precision Optional decimal precision for fuzzy equality
|
|
7
|
+
* @returns `true` if arrays are equal, `false` otherwise
|
|
8
|
+
*/
|
|
9
|
+
declare function equals(source1: ArrayLike<number>, source2: ArrayLike<number>, precision?: number): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Return true if all elements are NaN.
|
|
12
|
+
* @param source Input array
|
|
13
|
+
* @returns `true` when every entry is NaN
|
|
14
|
+
*/
|
|
15
|
+
declare function allna(source: ArrayLike<number>): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Count NaN entries in `source`.
|
|
18
|
+
* @param source Input array
|
|
19
|
+
* @returns Number of NaNs in the array
|
|
20
|
+
*/
|
|
21
|
+
declare function countna(source: ArrayLike<number>): number;
|
|
22
|
+
/**
|
|
23
|
+
* Test whether any of the provided arrays contains a NaN at the same index.
|
|
24
|
+
* Performs a single-pass scan across arrays and exits early on the first NaN.
|
|
25
|
+
* @param sources One or more input arrays
|
|
26
|
+
* @returns `true` if any NaN is found, otherwise `false`
|
|
27
|
+
*/
|
|
28
|
+
declare function havena(...sources: ArrayLike<number>[]): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Return a mask indicating NaN positions: 1 for NaN, 0 otherwise.
|
|
31
|
+
* @param source Input array
|
|
32
|
+
* @returns Float64Array mask of 0/1 values
|
|
33
|
+
*/
|
|
34
|
+
declare function isna(source: ArrayLike<number>): Float64Array;
|
|
35
|
+
/**
|
|
36
|
+
* Inverse of `isna`: mask with 1 for valid numbers and 0 for NaNs.
|
|
37
|
+
* @param source Input array
|
|
38
|
+
* @returns Float64Array mask of 0/1 values
|
|
39
|
+
*/
|
|
40
|
+
declare function notna(source: ArrayLike<number>): Float64Array;
|
|
41
|
+
/**
|
|
42
|
+
* Replace NaNs with `value`. When `inplace=true` and `source` is a Float64Array,
|
|
43
|
+
* the original buffer is mutated.
|
|
44
|
+
* @param source Input array
|
|
45
|
+
* @param value Replacement value for NaNs
|
|
46
|
+
* @param inplace Whether to mutate the input when possible
|
|
47
|
+
* @returns Float64Array with NaNs replaced
|
|
48
|
+
*/
|
|
49
|
+
declare function fillna(source: ArrayLike<number>, value: number, inplace?: boolean): Float64Array;
|
|
50
|
+
/**
|
|
51
|
+
* Forward-fill NaNs: propagate the last valid value forward. Leading NaNs remain NaN.
|
|
52
|
+
* @param source Input array
|
|
53
|
+
* @param inplace Whether to mutate the input when possible
|
|
54
|
+
* @returns Float64Array with forward-filled values
|
|
55
|
+
*/
|
|
56
|
+
declare function ffill(source: ArrayLike<number>, inplace?: boolean): Float64Array;
|
|
57
|
+
/**
|
|
58
|
+
* Backward-fill NaNs: propagate the next valid value backward. Trailing NaNs remain NaN.
|
|
59
|
+
* @param source Input array
|
|
60
|
+
* @param inplace Whether to mutate the input when possible
|
|
61
|
+
* @returns Float64Array with backward-filled values
|
|
62
|
+
*/
|
|
63
|
+
declare function bfill(source: ArrayLike<number>, inplace?: boolean): Float64Array;
|
|
64
|
+
export declare function lag(source: ArrayLike<number>, shift?: number): Float64Array;
|
|
65
|
+
/**
|
|
66
|
+
* Replace occurrences of `fromValue` with `toValue`. If `fromValue` is NaN,
|
|
67
|
+
* NaN entries are replaced.
|
|
68
|
+
* @param source Input array
|
|
69
|
+
* @param fromValue Value to replace (may be NaN)
|
|
70
|
+
* @param toValue Replacement value
|
|
71
|
+
* @param inplace Whether to mutate the input when possible
|
|
72
|
+
* @returns Float64Array with replacements applied
|
|
73
|
+
*/
|
|
74
|
+
declare function replace(source: ArrayLike<number>, fromValue: number, toValue: number, inplace?: boolean): Float64Array;
|
|
75
|
+
/**
|
|
76
|
+
* Remove NaN entries from `source` and return a compacted Float64Array.
|
|
77
|
+
* @param source Input array
|
|
78
|
+
* @returns New Float64Array containing only the non-NaN values
|
|
79
|
+
*/
|
|
80
|
+
declare function dropna(source: ArrayLike<number>): Float64Array;
|
|
81
|
+
export { isna, notna, fillna, ffill, bfill, replace, dropna, allna, equals, countna, havena };
|