qntjs-lib 1.0.1 → 1.1.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/README.md +71 -5
- package/dist/bundle/index.d.ts +466 -206
- package/dist/bundle/index.js +2353 -1767
- package/dist/index.d.ts +3 -0
- package/dist/perf/dd.d.ts +80 -0
- package/dist/perf/distribution.d.ts +43 -0
- package/dist/perf/index.d.ts +5 -0
- package/dist/perf/returns.d.ts +47 -0
- package/dist/perf/volatility.d.ts +61 -0
- package/dist/untyped/index.d.ts +230 -1
- package/dist/untyped/index.js +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -55,12 +55,78 @@ ta.sma(pricesWithGaps, 5);
|
|
|
55
55
|
ta.sma(densePrices, 5, false);
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
##
|
|
58
|
+
## Modules and examples
|
|
59
|
+
|
|
60
|
+
Overview of top-level modules and minimal examples showing common usage patterns.
|
|
61
|
+
|
|
62
|
+
### `ta` — technical indicators (moving averages, oscillators, volatility measures).
|
|
63
|
+
|
|
64
|
+
Example: compute an exponential moving average (EMA)
|
|
65
|
+
|
|
66
|
+
```js
|
|
67
|
+
import { ta } from 'qntjs-lib';
|
|
68
|
+
const prices = [1,2,3,4,5,6,7];
|
|
69
|
+
const ema3 = ta.ema(prices, 3); // Float64Array
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### `math` — array-oriented math primitives and elementwise operations.
|
|
73
|
+
|
|
74
|
+
Example: elementwise subtract and scale
|
|
75
|
+
|
|
76
|
+
```js
|
|
77
|
+
import { math } from 'qntjs-lib';
|
|
78
|
+
const a = [1,2,3];
|
|
79
|
+
const b = [0.1,0.1,0.1];
|
|
80
|
+
const diff = math.sub(a, b); // Float64Array of a-b
|
|
81
|
+
const scaled = math.scale(diff, 100);
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### `perf` — performance and risk helpers (returns, drawdowns, volatility, VaR/ES, ratios).
|
|
85
|
+
|
|
86
|
+
Example: compute daily returns, Sharpe, and parametric VaR
|
|
87
|
+
|
|
88
|
+
```js
|
|
89
|
+
import { perf } from 'qntjs-lib';
|
|
90
|
+
const prices = [100, 110, 105, 120];
|
|
91
|
+
const rets = perf.returns(prices); // simple returns (Float32Array)
|
|
92
|
+
const daily = perf.dailyReturns([Date.now(), Date.now() + 86400000], [0.01, 0.02]);
|
|
93
|
+
const sr = perf.sharpe([0.01, -0.02, 0.03]);
|
|
94
|
+
const varP = perf.valueAtRisk([0.01, -0.02, 0.03], 0.05, 'parametric');
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### `stats` — aggregations, percentiles, variance, sampling utilities.
|
|
98
|
+
|
|
99
|
+
Example: quantile and sample
|
|
100
|
+
|
|
101
|
+
```js
|
|
102
|
+
import { stats } from 'qntjs-lib';
|
|
103
|
+
const v = stats.quantile([1,2,3,4,5], 0.1);
|
|
104
|
+
const sample = stats.sample([1,2,3,4,5], 3);
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### `arr` — low-level array utilities (NaN handling, masks, fill/shift helpers).
|
|
108
|
+
|
|
109
|
+
Example: drop NaNs and forward-fill
|
|
110
|
+
|
|
111
|
+
```js
|
|
112
|
+
import { arr } from 'qntjs-lib';
|
|
113
|
+
const a = [NaN, 1, NaN, 2];
|
|
114
|
+
const clean = arr.dropna(a);
|
|
115
|
+
const filled = arr.ffill(a);
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## List of available API
|
|
119
|
+
|
|
120
|
+
- **`arr.*`** : `isna`, `notna`, `fillna`, `ffill`, `bfill`, `replace`, `dropna`, `allna`, `equals`, `countna`, `havena`, `lag`
|
|
121
|
+
|
|
122
|
+
- **`math.*`** : `add`, `sub`, `avg`, `mul`, `div`, `scale`, `abs`, `sign`, `round`, `floor`, `ceil`, `eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `and`, `or`, `not`, `clamp`, `sum`, `prod`, `min`, `max`, `argmin`, `argmax`, `cumsum`, `cumprod`, `cummax`, `cummin`, `rollsum`, `rollmin`, `rollmax`, `rollminmax`, `rollprod`, `rollargmin`, `rollargmax`, `diff`, `randuniform`, `randnormal`, `dot`, `norm`, `ols`, `olsMulti`
|
|
123
|
+
|
|
124
|
+
- **`stats.*`** : `mean`, `hmean`, `gmean`, `mad`, `skew`, `kurtosis`, `median`, `quantile`, `percentiles`, `var`, `covar`, `stdev`, `corr`, `zscore`, `norminmax`, `winsorize`, `sample`, `shuffle`, `bootstrap`
|
|
125
|
+
|
|
126
|
+
- **`ta.*`** : `dema`, `ema`, `hma`, `kama`, `sma`, `wma`, `vwma`, `trima`, `t3`, `tema`, `rma`, `ao`, `apo`, `aroon`, `change`, `cmo`, `kst`, `macd`, `mom`, `ppo`, `roc`, `rsi`, `stoch`, `stochrsi`, `ultosc`, `wpr`, `supertrend`, `adx`, `adxr`, `dx`, `cci`, `di`, `dpo`, `ichimoku`, `psar`, `atr`, `tr`, `natr`, `bb`, `bbw`, `donchian`, `keltner`, `adosc`, `obv`, `pnvi`, `wad`, `ad`, `mfi`, `cross`, `crossover`, `crossunder`, `rising`, `falling`
|
|
127
|
+
|
|
128
|
+
- **`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`
|
|
59
129
|
|
|
60
|
-
- `arr.*` — array utilities: `isna`, `notna`, `fillna`, `ffill`, `bfill`, `replace`, `dropna`, `allna`, `equals`, `countna`, `havena`, `lag`
|
|
61
|
-
- `math.*` — math helpers: `add`, `sub`, `avg`, `mul`, `div`, `scale`, `abs`, `sign`, `round`, `floor`, `ceil`, `eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `and`, `or`, `not`, `clamp`, `sum`, `prod`, `min`, `max`, `argmin`, `argmax`, `cumsum`, `cumprod`, `cummax`, `cummin`, `rollsum`, `rollmin`, `rollmax`, `rollminmax`, `rollprod`, `rollargmin`, `rollargmax`, `diff`, `randuniform`, `randnormal`, `dot`, `norm`, `ols`, `olsMulti`
|
|
62
|
-
- `stats.*` — statistical helpers: `mean`, `hmean`, `gmean`, `mad`, `skew`, `kurtosis`, `median`, `quantile`, `percentiles`, `var`, `covar`, `stdev`, `corr`, `zscore`, `norminmax`, `winsorize`, `sample`, `shuffle`, `bootstrap`
|
|
63
|
-
- `ta.*` — technical indicators: `dema`, `ema`, `hma`, `kama`, `sma`, `wma`, `vwma`, `trima`, `t3`, `tema`, `rma`, `ao`, `apo`, `aroon`, `change`, `cmo`, `kst`, `macd`, `mom`, `ppo`, `roc`, `rsi`, `stoch`, `stochrsi`, `ultosc`, `wpr`, `supertrend`, `adx`, `adxr`, `dx`, `cci`, `di`, `dpo`, `ichimoku`, `psar`, `atr`, `tr`, `natr`, `bb`, `bbw`, `donchian`, `keltner`, `adosc`, `obv`, `pnvi`, `wad`, `ad`, `mfi`, `cross`, `crossover`, `crossunder`, `rising`, `falling`
|
|
64
130
|
|
|
65
131
|
## Tests & development
|
|
66
132
|
|