qntjs-lib 1.1.1 → 1.1.2
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 +19 -17
- package/dist/untyped/index.d.ts +3 -3
- package/dist/untyped/index.js +4 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,10 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
A pure fast JavaScript/TypeScript library of technical‑analysis indicators, trading performance/risk metrics, array utilities, and numerical helpers.
|
|
4
4
|
|
|
5
|
-
This
|
|
6
|
-
|
|
7
|
-
- NaN‑aware workflows (default): functions are NaN‑aware and will skip NaN values where appropriate.
|
|
8
|
-
- Dense fast‑path: when you know inputs contain no NaNs you can opt into a dense, faster implementation by passing `skipna=false` to supported functions.
|
|
5
|
+
This package implements several TA indicators (EMA, TEMA, T3, MFI, KAMA, etc.), common trading performance metrics/utilities, vectorized math functions, and statistical helpers.
|
|
9
6
|
|
|
10
7
|
By default the main (typed) build returns typed arrays (e.g. `Float64Array`) for better numeric performance and predictable memory layout. A companion "untyped" build exposes the same API but returns plain `number[]` values for easier interoperability with plain JavaScript code.
|
|
11
8
|
|
|
@@ -43,19 +40,7 @@ When to use each:
|
|
|
43
40
|
- Use the default import (`qntjs-lib`) when you want outputs as `Float64Array` for numeric performance and predictable memory layout.
|
|
44
41
|
- Use `qntjs-lib/untyped` when you prefer plain `number[]` outputs for easier inspection or serialization.
|
|
45
42
|
|
|
46
|
-
##
|
|
47
|
-
|
|
48
|
-
Many indicators accept an optional `skipna` boolean (default `true`). Example:
|
|
49
|
-
|
|
50
|
-
```js
|
|
51
|
-
// NaN-aware (default)
|
|
52
|
-
ta.sma(pricesWithGaps, 5);
|
|
53
|
-
|
|
54
|
-
// Dense fast-path (assume no NaNs)
|
|
55
|
-
ta.sma(densePrices, 5, false);
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
## Modules and examples
|
|
43
|
+
## Modules
|
|
59
44
|
|
|
60
45
|
Overview of top-level modules and minimal examples showing common usage patterns.
|
|
61
46
|
|
|
@@ -128,8 +113,25 @@ const filled = arr.ffill(a);
|
|
|
128
113
|
- **`perf.*`** : `returns`, `logreturns`, `cumreturns`, `cagr`, `dailyReturns`, `dd`, `maxdd`, `maxddDetails`, `dduration`, `rollmaxdd`, `recoveryFactor`, `calmarRatio`, `ulcerIndex`, `rollUlcerIndex`, `sharpe`, `sortino`, `rollsharpe`, `rollsortino`, `vol`, `rollvol`, `valueAtRisk`, `expectedShortfall`, `tailRatio`, `omegaRatio`
|
|
129
114
|
|
|
130
115
|
|
|
116
|
+
## skipna and dense fast-path
|
|
117
|
+
|
|
118
|
+
Where applicable, implementations are optimized for two common usage patterns:
|
|
119
|
+
|
|
120
|
+
- NaN‑aware workflows (default): functions are NaN‑aware and will skip NaN values where appropriate.
|
|
121
|
+
- Dense fast‑path: when you know inputs contain no NaNs you can opt into a dense, faster implementation by passing `skipna=false` to supported functions.
|
|
122
|
+
|
|
123
|
+
```js
|
|
124
|
+
// NaN-aware (default)
|
|
125
|
+
ta.sma(pricesWithGaps, 5);
|
|
126
|
+
|
|
127
|
+
// Dense fast-path (assume no NaNs)
|
|
128
|
+
ta.sma(densePrices, 5, false);
|
|
129
|
+
```
|
|
130
|
+
|
|
131
131
|
## Tests & development
|
|
132
132
|
|
|
133
|
+
Many functions, especially TA indicators are tested for correctness against Tulind library.
|
|
134
|
+
|
|
133
135
|
Run tests:
|
|
134
136
|
|
|
135
137
|
```bash
|
package/dist/untyped/index.d.ts
CHANGED
|
@@ -1243,7 +1243,7 @@ declare namespace perf {
|
|
|
1243
1243
|
*/
|
|
1244
1244
|
export function dailyReturns(tsMs: ArrayLike<number>, returnsArr: ArrayLike<number>, tzOffsetMinutes?: number): {
|
|
1245
1245
|
days: number[];
|
|
1246
|
-
dailyReturns:
|
|
1246
|
+
dailyReturns: number[];
|
|
1247
1247
|
};
|
|
1248
1248
|
/**
|
|
1249
1249
|
* Compute the drawdown series from an equity/price series.
|
|
@@ -1276,7 +1276,7 @@ declare namespace perf {
|
|
|
1276
1276
|
* @param source Input level series (prices/equity)
|
|
1277
1277
|
* @returns Float32Array of log returns (same length as `source`)
|
|
1278
1278
|
*/
|
|
1279
|
-
export function logreturns(source: ArrayLike<number>):
|
|
1279
|
+
export function logreturns(source: ArrayLike<number>): number[];
|
|
1280
1280
|
/**
|
|
1281
1281
|
* Compute the maximum drawdown magnitude over the entire series.
|
|
1282
1282
|
* Returns a positive number (0..+inf) or NaN when no valid points.
|
|
@@ -1314,7 +1314,7 @@ declare namespace perf {
|
|
|
1314
1314
|
* @param source Input level series (prices/equity)
|
|
1315
1315
|
* @returns Float32Array of simple returns (same length as `source`)
|
|
1316
1316
|
*/
|
|
1317
|
-
export function returns(source: ArrayLike<number>):
|
|
1317
|
+
export function returns(source: ArrayLike<number>): number[];
|
|
1318
1318
|
/**
|
|
1319
1319
|
* Rolling Ulcer Index computed over a trailing window.
|
|
1320
1320
|
* Returns NaN for windows with insufficient valid samples (< minPeriod) or invalid window.
|
package/dist/untyped/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
// Generated untyped wrapper — converts
|
|
1
|
+
// Generated untyped wrapper — converts numeric TypedArrays -> number[] and recursively maps tuples/arrays
|
|
2
2
|
import * as core from '../bundle/index.js';
|
|
3
3
|
|
|
4
4
|
function convert(val) {
|
|
5
|
-
if (val instanceof Float64Array
|
|
5
|
+
if (val instanceof Float64Array || val instanceof Float32Array || val instanceof Int32Array || val instanceof Uint32Array || val instanceof Int16Array || val instanceof Uint16Array || val instanceof Int8Array || val instanceof Uint8Array) {
|
|
6
|
+
return Array.from(val);
|
|
7
|
+
}
|
|
6
8
|
if (Array.isArray(val)) return val.map(convert);
|
|
7
9
|
return val;
|
|
8
10
|
}
|