trading-signals 6.0.0 → 6.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 +23 -1
- package/dist/index.cjs +106 -33
- package/dist/index.d.cts +24 -7
- package/dist/index.d.ts +24 -7
- package/dist/index.js +102 -30
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -12,8 +12,28 @@ The main focus of this library is on the accuracy of calculations, but using the
|
|
|
12
12
|
|
|
13
13
|
All indicators can be updated over time by streaming data (prices or candles) to the `update` method. Some indicators also provide `static` batch methods for further performance improvements when providing data up-front during a backtest or historical data import.
|
|
14
14
|
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install trading-signals
|
|
19
|
+
```
|
|
20
|
+
|
|
15
21
|
## Usage
|
|
16
22
|
|
|
23
|
+
**CommonJS:**
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
const {Big, SMA} = require('trading-signals');
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**ESM:**
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import {Big, SMA} from 'trading-signals';
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Example:**
|
|
36
|
+
|
|
17
37
|
```typescript
|
|
18
38
|
import {Big, SMA} from 'trading-signals';
|
|
19
39
|
|
|
@@ -117,6 +137,7 @@ Most of the time, the minimum amount of data depends on the interval / time peri
|
|
|
117
137
|
1. Moving Average Convergence Divergence (MACD)
|
|
118
138
|
1. On-Balance Volume (OBV)
|
|
119
139
|
1. Rate-of-Change (ROC)
|
|
140
|
+
1. Relative Moving Average (RMA)
|
|
120
141
|
1. Relative Strength Index (RSI)
|
|
121
142
|
1. Simple Moving Average (SMA)
|
|
122
143
|
1. Stochastic Oscillator (STOCH)
|
|
@@ -181,12 +202,13 @@ It is very important to do your own analysis before making any investment based
|
|
|
181
202
|
- [Cloud9Trader Indicators (JavaScript)](https://github.com/Cloud9Trader/TechnicalIndicators)
|
|
182
203
|
- [Crypto Trading Hub Indicators (TypeScript)](https://github.com/anandanand84/technicalindicators)
|
|
183
204
|
- [Jesse Trading Bot Indicators (Python)](https://docs.jesse.trade/docs/indicators/reference.html)
|
|
205
|
+
- [LEAN Indicators](https://github.com/QuantConnect/Lean/tree/master/Indicators)
|
|
184
206
|
- [libindicators (C#)](https://github.com/mgfx/libindicators)
|
|
185
207
|
- [Pandas TA (Python)](https://github.com/twopirllc/pandas-ta)
|
|
208
|
+
- [ta4j (Java)](https://github.com/ta4j/ta4j)
|
|
186
209
|
- [Technical Analysis for Rust (Rust)](https://github.com/greyblake/ta-rs)
|
|
187
210
|
- [Technical Analysis Library using Pandas and Numpy (Python)](https://github.com/bukosabino/ta)
|
|
188
211
|
- [Tulip Indicators (ANSI C)](https://github.com/TulipCharts/tulipindicators)
|
|
189
|
-
- [ta4j (Java)](https://github.com/ta4j/ta4j)
|
|
190
212
|
|
|
191
213
|
## Maintainers
|
|
192
214
|
|
package/dist/index.cjs
CHANGED
|
@@ -36,7 +36,7 @@ __export(index_exports, {
|
|
|
36
36
|
ATR: () => ATR,
|
|
37
37
|
AccelerationBands: () => AccelerationBands,
|
|
38
38
|
BaseIndicatorSeries: () => BaseIndicatorSeries,
|
|
39
|
-
Big: () =>
|
|
39
|
+
Big: () => import_big25.default,
|
|
40
40
|
BigIndicatorSeries: () => BigIndicatorSeries,
|
|
41
41
|
BollingerBands: () => BollingerBands,
|
|
42
42
|
BollingerBandsWidth: () => BollingerBandsWidth,
|
|
@@ -65,6 +65,7 @@ __export(index_exports, {
|
|
|
65
65
|
FasterMovingAverage: () => FasterMovingAverage,
|
|
66
66
|
FasterOBV: () => FasterOBV,
|
|
67
67
|
FasterPeriod: () => FasterPeriod,
|
|
68
|
+
FasterRMA: () => FasterRMA,
|
|
68
69
|
FasterROC: () => FasterROC,
|
|
69
70
|
FasterRSI: () => FasterRSI,
|
|
70
71
|
FasterSMA: () => FasterSMA,
|
|
@@ -81,6 +82,7 @@ __export(index_exports, {
|
|
|
81
82
|
NumberIndicatorSeries: () => NumberIndicatorSeries,
|
|
82
83
|
OBV: () => OBV,
|
|
83
84
|
Period: () => Period,
|
|
85
|
+
RMA: () => RMA,
|
|
84
86
|
ROC: () => ROC,
|
|
85
87
|
RSI: () => RSI,
|
|
86
88
|
SMA: () => SMA,
|
|
@@ -93,7 +95,6 @@ __export(index_exports, {
|
|
|
93
95
|
getAverage: () => getAverage,
|
|
94
96
|
getFasterAverage: () => getFasterAverage,
|
|
95
97
|
getFasterStandardDeviation: () => getFasterStandardDeviation,
|
|
96
|
-
getLastFromForEach: () => getLastFromForEach,
|
|
97
98
|
getMaximum: () => getMaximum,
|
|
98
99
|
getMinimum: () => getMinimum,
|
|
99
100
|
getStandardDeviation: () => getStandardDeviation,
|
|
@@ -101,7 +102,7 @@ __export(index_exports, {
|
|
|
101
102
|
pushUpdate: () => pushUpdate
|
|
102
103
|
});
|
|
103
104
|
module.exports = __toCommonJS(index_exports);
|
|
104
|
-
var
|
|
105
|
+
var import_big25 = __toESM(require("big.js"), 1);
|
|
105
106
|
|
|
106
107
|
// src/error/NotEnoughDataError.ts
|
|
107
108
|
var NotEnoughDataError = class extends Error {
|
|
@@ -112,15 +113,6 @@ var NotEnoughDataError = class extends Error {
|
|
|
112
113
|
}
|
|
113
114
|
};
|
|
114
115
|
|
|
115
|
-
// src/util/getLastFromForEach.ts
|
|
116
|
-
function getLastFromForEach(array, callback) {
|
|
117
|
-
let lastValue = null;
|
|
118
|
-
array.forEach((item, index) => {
|
|
119
|
-
lastValue = callback(item, index, array);
|
|
120
|
-
});
|
|
121
|
-
return lastValue;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
116
|
// src/Indicator.ts
|
|
125
117
|
var TechnicalIndicator = class {
|
|
126
118
|
result;
|
|
@@ -147,7 +139,7 @@ var TechnicalIndicator = class {
|
|
|
147
139
|
return this.update(input, true);
|
|
148
140
|
}
|
|
149
141
|
updates(inputs, replace = false) {
|
|
150
|
-
return
|
|
142
|
+
return inputs.map((input) => this.update(input, replace));
|
|
151
143
|
}
|
|
152
144
|
};
|
|
153
145
|
var BaseIndicatorSeries = class extends TechnicalIndicator {
|
|
@@ -270,8 +262,7 @@ var FasterSMA = class extends FasterMovingAverage {
|
|
|
270
262
|
update(price, replace) {
|
|
271
263
|
pushUpdate(this.prices, replace, price, this.interval);
|
|
272
264
|
if (this.prices.length === this.interval) {
|
|
273
|
-
|
|
274
|
-
return this.setResult(sum / this.prices.length, replace);
|
|
265
|
+
return this.setResult(getFasterAverage(this.prices), replace);
|
|
275
266
|
}
|
|
276
267
|
return null;
|
|
277
268
|
}
|
|
@@ -1445,8 +1436,89 @@ var FasterOBV = class extends NumberIndicatorSeries {
|
|
|
1445
1436
|
}
|
|
1446
1437
|
};
|
|
1447
1438
|
|
|
1448
|
-
// src/
|
|
1439
|
+
// src/RMA/RMA.ts
|
|
1449
1440
|
var import_big19 = __toESM(require("big.js"), 1);
|
|
1441
|
+
var RMA = class extends MovingAverage {
|
|
1442
|
+
constructor(interval) {
|
|
1443
|
+
super(interval);
|
|
1444
|
+
this.interval = interval;
|
|
1445
|
+
this.weightFactor = 1 / this.interval;
|
|
1446
|
+
}
|
|
1447
|
+
pricesCounter = 0;
|
|
1448
|
+
weightFactor;
|
|
1449
|
+
update(_price, replace) {
|
|
1450
|
+
if (!replace) {
|
|
1451
|
+
this.pricesCounter++;
|
|
1452
|
+
} else if (replace && this.pricesCounter === 0) {
|
|
1453
|
+
this.pricesCounter++;
|
|
1454
|
+
}
|
|
1455
|
+
const price = new import_big19.default(_price);
|
|
1456
|
+
if (replace && this.previousResult) {
|
|
1457
|
+
return this.setResult(
|
|
1458
|
+
price.times(this.weightFactor).add(this.previousResult.times(1 - this.weightFactor)),
|
|
1459
|
+
replace
|
|
1460
|
+
);
|
|
1461
|
+
}
|
|
1462
|
+
return this.setResult(
|
|
1463
|
+
price.times(this.weightFactor).add((this.result ?? price).times(1 - this.weightFactor)),
|
|
1464
|
+
replace
|
|
1465
|
+
);
|
|
1466
|
+
}
|
|
1467
|
+
getResultOrThrow() {
|
|
1468
|
+
if (this.pricesCounter < this.interval) {
|
|
1469
|
+
throw new NotEnoughDataError();
|
|
1470
|
+
}
|
|
1471
|
+
return this.result;
|
|
1472
|
+
}
|
|
1473
|
+
get isStable() {
|
|
1474
|
+
try {
|
|
1475
|
+
this.getResultOrThrow();
|
|
1476
|
+
return true;
|
|
1477
|
+
} catch {
|
|
1478
|
+
return false;
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
};
|
|
1482
|
+
var FasterRMA = class extends FasterMovingAverage {
|
|
1483
|
+
constructor(interval) {
|
|
1484
|
+
super(interval);
|
|
1485
|
+
this.interval = interval;
|
|
1486
|
+
this.weightFactor = 1 / this.interval;
|
|
1487
|
+
}
|
|
1488
|
+
pricesCounter = 0;
|
|
1489
|
+
weightFactor;
|
|
1490
|
+
update(price, replace) {
|
|
1491
|
+
if (!replace) {
|
|
1492
|
+
this.pricesCounter++;
|
|
1493
|
+
} else if (replace && this.pricesCounter === 0) {
|
|
1494
|
+
this.pricesCounter++;
|
|
1495
|
+
}
|
|
1496
|
+
if (replace && this.previousResult !== void 0) {
|
|
1497
|
+
return this.setResult(price * this.weightFactor + this.previousResult * (1 - this.weightFactor), replace);
|
|
1498
|
+
}
|
|
1499
|
+
return this.setResult(
|
|
1500
|
+
price * this.weightFactor + (this.result !== void 0 ? this.result : price) * (1 - this.weightFactor),
|
|
1501
|
+
replace
|
|
1502
|
+
);
|
|
1503
|
+
}
|
|
1504
|
+
getResultOrThrow() {
|
|
1505
|
+
if (this.pricesCounter < this.interval) {
|
|
1506
|
+
throw new NotEnoughDataError();
|
|
1507
|
+
}
|
|
1508
|
+
return this.result;
|
|
1509
|
+
}
|
|
1510
|
+
get isStable() {
|
|
1511
|
+
try {
|
|
1512
|
+
this.getResultOrThrow();
|
|
1513
|
+
return true;
|
|
1514
|
+
} catch {
|
|
1515
|
+
return false;
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
};
|
|
1519
|
+
|
|
1520
|
+
// src/ROC/ROC.ts
|
|
1521
|
+
var import_big20 = __toESM(require("big.js"), 1);
|
|
1450
1522
|
var ROC = class extends BigIndicatorSeries {
|
|
1451
1523
|
constructor(interval) {
|
|
1452
1524
|
super();
|
|
@@ -1456,7 +1528,7 @@ var ROC = class extends BigIndicatorSeries {
|
|
|
1456
1528
|
update(price, replace) {
|
|
1457
1529
|
const comparePrice = pushUpdate(this.prices, replace, price, this.interval);
|
|
1458
1530
|
if (comparePrice) {
|
|
1459
|
-
return this.setResult(new
|
|
1531
|
+
return this.setResult(new import_big20.default(price).sub(comparePrice).div(comparePrice), replace);
|
|
1460
1532
|
}
|
|
1461
1533
|
return null;
|
|
1462
1534
|
}
|
|
@@ -1477,7 +1549,7 @@ var FasterROC = class extends NumberIndicatorSeries {
|
|
|
1477
1549
|
};
|
|
1478
1550
|
|
|
1479
1551
|
// src/RSI/RSI.ts
|
|
1480
|
-
var
|
|
1552
|
+
var import_big21 = __toESM(require("big.js"), 1);
|
|
1481
1553
|
var RSI = class extends BigIndicatorSeries {
|
|
1482
1554
|
constructor(interval, SmoothingIndicator = WSMA) {
|
|
1483
1555
|
super();
|
|
@@ -1488,25 +1560,25 @@ var RSI = class extends BigIndicatorSeries {
|
|
|
1488
1560
|
previousPrices = [];
|
|
1489
1561
|
avgGain;
|
|
1490
1562
|
avgLoss;
|
|
1491
|
-
maxValue = new
|
|
1563
|
+
maxValue = new import_big21.default(100);
|
|
1492
1564
|
update(price, replace) {
|
|
1493
1565
|
pushUpdate(this.previousPrices, replace, price, this.interval);
|
|
1494
1566
|
if (this.previousPrices.length < 2) {
|
|
1495
1567
|
return null;
|
|
1496
1568
|
}
|
|
1497
|
-
const currentPrice = new
|
|
1498
|
-
const previousPrice = new
|
|
1569
|
+
const currentPrice = new import_big21.default(price);
|
|
1570
|
+
const previousPrice = new import_big21.default(this.previousPrices[this.previousPrices.length - 2]);
|
|
1499
1571
|
if (currentPrice.gt(previousPrice)) {
|
|
1500
|
-
this.avgLoss.update(new
|
|
1572
|
+
this.avgLoss.update(new import_big21.default(0), replace);
|
|
1501
1573
|
this.avgGain.update(currentPrice.sub(previousPrice), replace);
|
|
1502
1574
|
} else {
|
|
1503
1575
|
this.avgLoss.update(previousPrice.sub(currentPrice), replace);
|
|
1504
|
-
this.avgGain.update(new
|
|
1576
|
+
this.avgGain.update(new import_big21.default(0), replace);
|
|
1505
1577
|
}
|
|
1506
1578
|
if (this.avgGain.isStable) {
|
|
1507
1579
|
const avgLoss = this.avgLoss.getResultOrThrow();
|
|
1508
1580
|
if (avgLoss.eq(0)) {
|
|
1509
|
-
return this.setResult(new
|
|
1581
|
+
return this.setResult(new import_big21.default(100), replace);
|
|
1510
1582
|
}
|
|
1511
1583
|
const relativeStrength = this.avgGain.getResultOrThrow().div(avgLoss);
|
|
1512
1584
|
return this.setResult(this.maxValue.minus(this.maxValue.div(relativeStrength.add(1))), replace);
|
|
@@ -1552,7 +1624,7 @@ var FasterRSI = class extends NumberIndicatorSeries {
|
|
|
1552
1624
|
};
|
|
1553
1625
|
|
|
1554
1626
|
// src/STOCH/StochasticOscillator.ts
|
|
1555
|
-
var
|
|
1627
|
+
var import_big22 = __toESM(require("big.js"), 1);
|
|
1556
1628
|
var StochasticOscillator = class extends TechnicalIndicator {
|
|
1557
1629
|
/**
|
|
1558
1630
|
* Constructs a Stochastic Oscillator.
|
|
@@ -1577,8 +1649,8 @@ var StochasticOscillator = class extends TechnicalIndicator {
|
|
|
1577
1649
|
if (this.candles.length === this.n) {
|
|
1578
1650
|
const highest = getMaximum(this.candles.map((candle2) => candle2.high));
|
|
1579
1651
|
const lowest = getMinimum(this.candles.map((candle2) => candle2.low));
|
|
1580
|
-
const divisor = new
|
|
1581
|
-
let fastK = new
|
|
1652
|
+
const divisor = new import_big22.default(highest).minus(lowest);
|
|
1653
|
+
let fastK = new import_big22.default(100).mul(new import_big22.default(candle.close).minus(lowest));
|
|
1582
1654
|
fastK = fastK.div(divisor.eq(0) ? 1 : divisor);
|
|
1583
1655
|
const stochK = this.periodM.update(fastK, replace);
|
|
1584
1656
|
const stochD = stochK && this.periodP.update(stochK, replace);
|
|
@@ -1631,7 +1703,7 @@ var FasterStochasticOscillator = class extends TechnicalIndicator {
|
|
|
1631
1703
|
};
|
|
1632
1704
|
|
|
1633
1705
|
// src/STOCH/StochasticRSI.ts
|
|
1634
|
-
var
|
|
1706
|
+
var import_big23 = __toESM(require("big.js"), 1);
|
|
1635
1707
|
var StochasticRSI = class extends BigIndicatorSeries {
|
|
1636
1708
|
constructor(interval, SmoothingIndicator = WSMA) {
|
|
1637
1709
|
super();
|
|
@@ -1650,7 +1722,7 @@ var StochasticRSI = class extends BigIndicatorSeries {
|
|
|
1650
1722
|
const max = periodResult.highest;
|
|
1651
1723
|
const denominator = max.minus(min);
|
|
1652
1724
|
if (denominator.eq(0)) {
|
|
1653
|
-
return this.setResult(new
|
|
1725
|
+
return this.setResult(new import_big23.default(100), false);
|
|
1654
1726
|
}
|
|
1655
1727
|
const numerator = rsiResult.minus(min);
|
|
1656
1728
|
return this.setResult(numerator.div(denominator), false);
|
|
@@ -1688,7 +1760,7 @@ var FasterStochasticRSI = class extends NumberIndicatorSeries {
|
|
|
1688
1760
|
};
|
|
1689
1761
|
|
|
1690
1762
|
// src/WMA/WMA.ts
|
|
1691
|
-
var
|
|
1763
|
+
var import_big24 = __toESM(require("big.js"), 1);
|
|
1692
1764
|
var WMA = class extends MovingAverage {
|
|
1693
1765
|
constructor(interval) {
|
|
1694
1766
|
super(interval);
|
|
@@ -1699,9 +1771,9 @@ var WMA = class extends MovingAverage {
|
|
|
1699
1771
|
pushUpdate(this.prices, replace, price, this.interval);
|
|
1700
1772
|
if (this.prices.length === this.interval) {
|
|
1701
1773
|
const weightedPricesSum = this.prices.reduce((acc, price2, index) => {
|
|
1702
|
-
const weightedPrice = new
|
|
1774
|
+
const weightedPrice = new import_big24.default(price2).mul(index + 1);
|
|
1703
1775
|
return acc.add(weightedPrice);
|
|
1704
|
-
}, new
|
|
1776
|
+
}, new import_big24.default(0));
|
|
1705
1777
|
const weightBase = this.interval * (this.interval + 1) / 2;
|
|
1706
1778
|
const weightedMa = weightedPricesSum.div(weightBase);
|
|
1707
1779
|
return this.setResult(weightedMa, replace);
|
|
@@ -1766,6 +1838,7 @@ var FasterWMA = class extends FasterMovingAverage {
|
|
|
1766
1838
|
FasterMovingAverage,
|
|
1767
1839
|
FasterOBV,
|
|
1768
1840
|
FasterPeriod,
|
|
1841
|
+
FasterRMA,
|
|
1769
1842
|
FasterROC,
|
|
1770
1843
|
FasterRSI,
|
|
1771
1844
|
FasterSMA,
|
|
@@ -1782,6 +1855,7 @@ var FasterWMA = class extends FasterMovingAverage {
|
|
|
1782
1855
|
NumberIndicatorSeries,
|
|
1783
1856
|
OBV,
|
|
1784
1857
|
Period,
|
|
1858
|
+
RMA,
|
|
1785
1859
|
ROC,
|
|
1786
1860
|
RSI,
|
|
1787
1861
|
SMA,
|
|
@@ -1794,7 +1868,6 @@ var FasterWMA = class extends FasterMovingAverage {
|
|
|
1794
1868
|
getAverage,
|
|
1795
1869
|
getFasterAverage,
|
|
1796
1870
|
getFasterStandardDeviation,
|
|
1797
|
-
getLastFromForEach,
|
|
1798
1871
|
getMaximum,
|
|
1799
1872
|
getMinimum,
|
|
1800
1873
|
getStandardDeviation,
|
package/dist/index.d.cts
CHANGED
|
@@ -10,7 +10,7 @@ interface Indicator<Result = Big, Input = BigSource> {
|
|
|
10
10
|
getResultOrThrow(): Result;
|
|
11
11
|
replace(input: Input): Nullable<Result>;
|
|
12
12
|
update(input: Input, replace: boolean): Nullable<Result>;
|
|
13
|
-
updates(input: Input[], replace: boolean): Nullable<Result
|
|
13
|
+
updates(input: Input[], replace: boolean): Nullable<Result>[];
|
|
14
14
|
}
|
|
15
15
|
declare abstract class TechnicalIndicator<Result, Input> implements Indicator<Result, Input> {
|
|
16
16
|
protected result: Result | undefined;
|
|
@@ -20,7 +20,7 @@ declare abstract class TechnicalIndicator<Result, Input> implements Indicator<Re
|
|
|
20
20
|
add(input: Input): Result | null;
|
|
21
21
|
replace(input: Input): Result | null;
|
|
22
22
|
abstract update(input: Input, replace: boolean): Result | null;
|
|
23
|
-
updates(inputs: readonly Input[], replace?: boolean): Result | null;
|
|
23
|
+
updates(inputs: readonly Input[], replace?: boolean): (Result | null)[];
|
|
24
24
|
}
|
|
25
25
|
declare abstract class BaseIndicatorSeries<Result, Input> extends TechnicalIndicator<Result, Input> {
|
|
26
26
|
protected previousHighest?: Result;
|
|
@@ -102,8 +102,27 @@ declare class FasterWMA extends FasterMovingAverage {
|
|
|
102
102
|
update(price: number, replace: boolean): number | null;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
declare class RMA extends MovingAverage {
|
|
106
|
+
readonly interval: number;
|
|
107
|
+
private pricesCounter;
|
|
108
|
+
private readonly weightFactor;
|
|
109
|
+
constructor(interval: number);
|
|
110
|
+
update(_price: BigSource, replace: boolean): Big__default;
|
|
111
|
+
getResultOrThrow(): Big__default;
|
|
112
|
+
get isStable(): boolean;
|
|
113
|
+
}
|
|
114
|
+
declare class FasterRMA extends FasterMovingAverage {
|
|
115
|
+
readonly interval: number;
|
|
116
|
+
private pricesCounter;
|
|
117
|
+
private readonly weightFactor;
|
|
118
|
+
constructor(interval: number);
|
|
119
|
+
update(price: number, replace: boolean): number;
|
|
120
|
+
getResultOrThrow(): number;
|
|
121
|
+
get isStable(): boolean;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
type MovingAverageTypes = typeof EMA | typeof RMA | typeof SMA | typeof WMA | typeof WSMA;
|
|
125
|
+
type FasterMovingAverageTypes = typeof FasterEMA | typeof FasterRMA | typeof FasterSMA | typeof FasterWMA | typeof FasterWSMA;
|
|
107
126
|
|
|
108
127
|
interface BandsResult {
|
|
109
128
|
lower: Big$2;
|
|
@@ -119,8 +138,6 @@ interface FasterBandsResult {
|
|
|
119
138
|
declare function getAverage(values: BigSource[]): Big__default;
|
|
120
139
|
declare function getFasterAverage(values: number[]): number;
|
|
121
140
|
|
|
122
|
-
declare function getLastFromForEach<T, R>(array: readonly T[], callback: (value: T, index: number, array: readonly T[]) => R): R | null;
|
|
123
|
-
|
|
124
141
|
declare function getMaximum(values: BigSource[]): Big__default;
|
|
125
142
|
|
|
126
143
|
declare function getMinimum(values: BigSource[]): Big__default;
|
|
@@ -619,4 +636,4 @@ declare class FasterTR extends NumberIndicatorSeries<HighLowCloseNumber> {
|
|
|
619
636
|
update(candle: HighLowCloseNumber, replace: boolean): number;
|
|
620
637
|
}
|
|
621
638
|
|
|
622
|
-
export { AC, ADX, AO, ATR, AccelerationBands, type BandsResult, BaseIndicatorSeries, BigIndicatorSeries, BollingerBands, BollingerBandsWidth, CCI, CG, DEMA, DMA, type DMAResult, DX, EMA, FasterAC, FasterADX, FasterAO, FasterATR, FasterAccelerationBands, type FasterBandsResult, FasterBollingerBands, FasterBollingerBandsWidth, FasterCCI, FasterCG, FasterDEMA, FasterDMA, type FasterDMAResult, FasterDX, FasterEMA, FasterMACD, type FasterMACDResult, FasterMAD, FasterMOM, FasterMovingAverage, type FasterMovingAverageTypes, FasterOBV, FasterPeriod, type FasterPeriodResult, FasterROC, FasterRSI, FasterSMA, FasterStochasticOscillator, FasterStochasticRSI, type FasterStochasticResult, FasterTR, FasterWMA, FasterWSMA, type HighLow, type HighLowClose, type HighLowCloseNumber, type HighLowNumber, MACD, type MACDConfig, type MACDResult, MAD, MOM, MovingAverage, type MovingAverageTypes, NotEnoughDataError, NumberIndicatorSeries, OBV, type OpenHighLowClose, type OpenHighLowCloseNumber, type OpenHighLowCloseVolume, type OpenHighLowCloseVolumeNumber, Period, type PeriodResult, ROC, RSI, SMA, StochasticOscillator, StochasticRSI, type StochasticResult, type Streak, TR, TechnicalIndicator, WMA, WSMA, getAverage, getFasterAverage, getFasterStandardDeviation,
|
|
639
|
+
export { AC, ADX, AO, ATR, AccelerationBands, type BandsResult, BaseIndicatorSeries, BigIndicatorSeries, BollingerBands, BollingerBandsWidth, CCI, CG, DEMA, DMA, type DMAResult, DX, EMA, FasterAC, FasterADX, FasterAO, FasterATR, FasterAccelerationBands, type FasterBandsResult, FasterBollingerBands, FasterBollingerBandsWidth, FasterCCI, FasterCG, FasterDEMA, FasterDMA, type FasterDMAResult, FasterDX, FasterEMA, FasterMACD, type FasterMACDResult, FasterMAD, FasterMOM, FasterMovingAverage, type FasterMovingAverageTypes, FasterOBV, FasterPeriod, type FasterPeriodResult, FasterRMA, FasterROC, FasterRSI, FasterSMA, FasterStochasticOscillator, FasterStochasticRSI, type FasterStochasticResult, FasterTR, FasterWMA, FasterWSMA, type HighLow, type HighLowClose, type HighLowCloseNumber, type HighLowNumber, MACD, type MACDConfig, type MACDResult, MAD, MOM, MovingAverage, type MovingAverageTypes, NotEnoughDataError, NumberIndicatorSeries, OBV, type OpenHighLowClose, type OpenHighLowCloseNumber, type OpenHighLowCloseVolume, type OpenHighLowCloseVolumeNumber, Period, type PeriodResult, RMA, ROC, RSI, SMA, StochasticOscillator, StochasticRSI, type StochasticResult, type Streak, TR, TechnicalIndicator, WMA, WSMA, getAverage, getFasterAverage, getFasterStandardDeviation, getMaximum, getMinimum, getStandardDeviation, getStreaks, pushUpdate };
|
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ interface Indicator<Result = Big, Input = BigSource> {
|
|
|
10
10
|
getResultOrThrow(): Result;
|
|
11
11
|
replace(input: Input): Nullable<Result>;
|
|
12
12
|
update(input: Input, replace: boolean): Nullable<Result>;
|
|
13
|
-
updates(input: Input[], replace: boolean): Nullable<Result
|
|
13
|
+
updates(input: Input[], replace: boolean): Nullable<Result>[];
|
|
14
14
|
}
|
|
15
15
|
declare abstract class TechnicalIndicator<Result, Input> implements Indicator<Result, Input> {
|
|
16
16
|
protected result: Result | undefined;
|
|
@@ -20,7 +20,7 @@ declare abstract class TechnicalIndicator<Result, Input> implements Indicator<Re
|
|
|
20
20
|
add(input: Input): Result | null;
|
|
21
21
|
replace(input: Input): Result | null;
|
|
22
22
|
abstract update(input: Input, replace: boolean): Result | null;
|
|
23
|
-
updates(inputs: readonly Input[], replace?: boolean): Result | null;
|
|
23
|
+
updates(inputs: readonly Input[], replace?: boolean): (Result | null)[];
|
|
24
24
|
}
|
|
25
25
|
declare abstract class BaseIndicatorSeries<Result, Input> extends TechnicalIndicator<Result, Input> {
|
|
26
26
|
protected previousHighest?: Result;
|
|
@@ -102,8 +102,27 @@ declare class FasterWMA extends FasterMovingAverage {
|
|
|
102
102
|
update(price: number, replace: boolean): number | null;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
declare class RMA extends MovingAverage {
|
|
106
|
+
readonly interval: number;
|
|
107
|
+
private pricesCounter;
|
|
108
|
+
private readonly weightFactor;
|
|
109
|
+
constructor(interval: number);
|
|
110
|
+
update(_price: BigSource, replace: boolean): Big__default;
|
|
111
|
+
getResultOrThrow(): Big__default;
|
|
112
|
+
get isStable(): boolean;
|
|
113
|
+
}
|
|
114
|
+
declare class FasterRMA extends FasterMovingAverage {
|
|
115
|
+
readonly interval: number;
|
|
116
|
+
private pricesCounter;
|
|
117
|
+
private readonly weightFactor;
|
|
118
|
+
constructor(interval: number);
|
|
119
|
+
update(price: number, replace: boolean): number;
|
|
120
|
+
getResultOrThrow(): number;
|
|
121
|
+
get isStable(): boolean;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
type MovingAverageTypes = typeof EMA | typeof RMA | typeof SMA | typeof WMA | typeof WSMA;
|
|
125
|
+
type FasterMovingAverageTypes = typeof FasterEMA | typeof FasterRMA | typeof FasterSMA | typeof FasterWMA | typeof FasterWSMA;
|
|
107
126
|
|
|
108
127
|
interface BandsResult {
|
|
109
128
|
lower: Big$2;
|
|
@@ -119,8 +138,6 @@ interface FasterBandsResult {
|
|
|
119
138
|
declare function getAverage(values: BigSource[]): Big__default;
|
|
120
139
|
declare function getFasterAverage(values: number[]): number;
|
|
121
140
|
|
|
122
|
-
declare function getLastFromForEach<T, R>(array: readonly T[], callback: (value: T, index: number, array: readonly T[]) => R): R | null;
|
|
123
|
-
|
|
124
141
|
declare function getMaximum(values: BigSource[]): Big__default;
|
|
125
142
|
|
|
126
143
|
declare function getMinimum(values: BigSource[]): Big__default;
|
|
@@ -619,4 +636,4 @@ declare class FasterTR extends NumberIndicatorSeries<HighLowCloseNumber> {
|
|
|
619
636
|
update(candle: HighLowCloseNumber, replace: boolean): number;
|
|
620
637
|
}
|
|
621
638
|
|
|
622
|
-
export { AC, ADX, AO, ATR, AccelerationBands, type BandsResult, BaseIndicatorSeries, BigIndicatorSeries, BollingerBands, BollingerBandsWidth, CCI, CG, DEMA, DMA, type DMAResult, DX, EMA, FasterAC, FasterADX, FasterAO, FasterATR, FasterAccelerationBands, type FasterBandsResult, FasterBollingerBands, FasterBollingerBandsWidth, FasterCCI, FasterCG, FasterDEMA, FasterDMA, type FasterDMAResult, FasterDX, FasterEMA, FasterMACD, type FasterMACDResult, FasterMAD, FasterMOM, FasterMovingAverage, type FasterMovingAverageTypes, FasterOBV, FasterPeriod, type FasterPeriodResult, FasterROC, FasterRSI, FasterSMA, FasterStochasticOscillator, FasterStochasticRSI, type FasterStochasticResult, FasterTR, FasterWMA, FasterWSMA, type HighLow, type HighLowClose, type HighLowCloseNumber, type HighLowNumber, MACD, type MACDConfig, type MACDResult, MAD, MOM, MovingAverage, type MovingAverageTypes, NotEnoughDataError, NumberIndicatorSeries, OBV, type OpenHighLowClose, type OpenHighLowCloseNumber, type OpenHighLowCloseVolume, type OpenHighLowCloseVolumeNumber, Period, type PeriodResult, ROC, RSI, SMA, StochasticOscillator, StochasticRSI, type StochasticResult, type Streak, TR, TechnicalIndicator, WMA, WSMA, getAverage, getFasterAverage, getFasterStandardDeviation,
|
|
639
|
+
export { AC, ADX, AO, ATR, AccelerationBands, type BandsResult, BaseIndicatorSeries, BigIndicatorSeries, BollingerBands, BollingerBandsWidth, CCI, CG, DEMA, DMA, type DMAResult, DX, EMA, FasterAC, FasterADX, FasterAO, FasterATR, FasterAccelerationBands, type FasterBandsResult, FasterBollingerBands, FasterBollingerBandsWidth, FasterCCI, FasterCG, FasterDEMA, FasterDMA, type FasterDMAResult, FasterDX, FasterEMA, FasterMACD, type FasterMACDResult, FasterMAD, FasterMOM, FasterMovingAverage, type FasterMovingAverageTypes, FasterOBV, FasterPeriod, type FasterPeriodResult, FasterRMA, FasterROC, FasterRSI, FasterSMA, FasterStochasticOscillator, FasterStochasticRSI, type FasterStochasticResult, FasterTR, FasterWMA, FasterWSMA, type HighLow, type HighLowClose, type HighLowCloseNumber, type HighLowNumber, MACD, type MACDConfig, type MACDResult, MAD, MOM, MovingAverage, type MovingAverageTypes, NotEnoughDataError, NumberIndicatorSeries, OBV, type OpenHighLowClose, type OpenHighLowCloseNumber, type OpenHighLowCloseVolume, type OpenHighLowCloseVolumeNumber, Period, type PeriodResult, RMA, ROC, RSI, SMA, StochasticOscillator, StochasticRSI, type StochasticResult, type Streak, TR, TechnicalIndicator, WMA, WSMA, getAverage, getFasterAverage, getFasterStandardDeviation, getMaximum, getMinimum, getStandardDeviation, getStreaks, pushUpdate };
|
package/dist/index.js
CHANGED
|
@@ -10,15 +10,6 @@ var NotEnoughDataError = class extends Error {
|
|
|
10
10
|
}
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
// src/util/getLastFromForEach.ts
|
|
14
|
-
function getLastFromForEach(array, callback) {
|
|
15
|
-
let lastValue = null;
|
|
16
|
-
array.forEach((item, index) => {
|
|
17
|
-
lastValue = callback(item, index, array);
|
|
18
|
-
});
|
|
19
|
-
return lastValue;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
13
|
// src/Indicator.ts
|
|
23
14
|
var TechnicalIndicator = class {
|
|
24
15
|
result;
|
|
@@ -45,7 +36,7 @@ var TechnicalIndicator = class {
|
|
|
45
36
|
return this.update(input, true);
|
|
46
37
|
}
|
|
47
38
|
updates(inputs, replace = false) {
|
|
48
|
-
return
|
|
39
|
+
return inputs.map((input) => this.update(input, replace));
|
|
49
40
|
}
|
|
50
41
|
};
|
|
51
42
|
var BaseIndicatorSeries = class extends TechnicalIndicator {
|
|
@@ -168,8 +159,7 @@ var FasterSMA = class extends FasterMovingAverage {
|
|
|
168
159
|
update(price, replace) {
|
|
169
160
|
pushUpdate(this.prices, replace, price, this.interval);
|
|
170
161
|
if (this.prices.length === this.interval) {
|
|
171
|
-
|
|
172
|
-
return this.setResult(sum / this.prices.length, replace);
|
|
162
|
+
return this.setResult(getFasterAverage(this.prices), replace);
|
|
173
163
|
}
|
|
174
164
|
return null;
|
|
175
165
|
}
|
|
@@ -1343,8 +1333,89 @@ var FasterOBV = class extends NumberIndicatorSeries {
|
|
|
1343
1333
|
}
|
|
1344
1334
|
};
|
|
1345
1335
|
|
|
1346
|
-
// src/
|
|
1336
|
+
// src/RMA/RMA.ts
|
|
1347
1337
|
import Big19 from "big.js";
|
|
1338
|
+
var RMA = class extends MovingAverage {
|
|
1339
|
+
constructor(interval) {
|
|
1340
|
+
super(interval);
|
|
1341
|
+
this.interval = interval;
|
|
1342
|
+
this.weightFactor = 1 / this.interval;
|
|
1343
|
+
}
|
|
1344
|
+
pricesCounter = 0;
|
|
1345
|
+
weightFactor;
|
|
1346
|
+
update(_price, replace) {
|
|
1347
|
+
if (!replace) {
|
|
1348
|
+
this.pricesCounter++;
|
|
1349
|
+
} else if (replace && this.pricesCounter === 0) {
|
|
1350
|
+
this.pricesCounter++;
|
|
1351
|
+
}
|
|
1352
|
+
const price = new Big19(_price);
|
|
1353
|
+
if (replace && this.previousResult) {
|
|
1354
|
+
return this.setResult(
|
|
1355
|
+
price.times(this.weightFactor).add(this.previousResult.times(1 - this.weightFactor)),
|
|
1356
|
+
replace
|
|
1357
|
+
);
|
|
1358
|
+
}
|
|
1359
|
+
return this.setResult(
|
|
1360
|
+
price.times(this.weightFactor).add((this.result ?? price).times(1 - this.weightFactor)),
|
|
1361
|
+
replace
|
|
1362
|
+
);
|
|
1363
|
+
}
|
|
1364
|
+
getResultOrThrow() {
|
|
1365
|
+
if (this.pricesCounter < this.interval) {
|
|
1366
|
+
throw new NotEnoughDataError();
|
|
1367
|
+
}
|
|
1368
|
+
return this.result;
|
|
1369
|
+
}
|
|
1370
|
+
get isStable() {
|
|
1371
|
+
try {
|
|
1372
|
+
this.getResultOrThrow();
|
|
1373
|
+
return true;
|
|
1374
|
+
} catch {
|
|
1375
|
+
return false;
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
};
|
|
1379
|
+
var FasterRMA = class extends FasterMovingAverage {
|
|
1380
|
+
constructor(interval) {
|
|
1381
|
+
super(interval);
|
|
1382
|
+
this.interval = interval;
|
|
1383
|
+
this.weightFactor = 1 / this.interval;
|
|
1384
|
+
}
|
|
1385
|
+
pricesCounter = 0;
|
|
1386
|
+
weightFactor;
|
|
1387
|
+
update(price, replace) {
|
|
1388
|
+
if (!replace) {
|
|
1389
|
+
this.pricesCounter++;
|
|
1390
|
+
} else if (replace && this.pricesCounter === 0) {
|
|
1391
|
+
this.pricesCounter++;
|
|
1392
|
+
}
|
|
1393
|
+
if (replace && this.previousResult !== void 0) {
|
|
1394
|
+
return this.setResult(price * this.weightFactor + this.previousResult * (1 - this.weightFactor), replace);
|
|
1395
|
+
}
|
|
1396
|
+
return this.setResult(
|
|
1397
|
+
price * this.weightFactor + (this.result !== void 0 ? this.result : price) * (1 - this.weightFactor),
|
|
1398
|
+
replace
|
|
1399
|
+
);
|
|
1400
|
+
}
|
|
1401
|
+
getResultOrThrow() {
|
|
1402
|
+
if (this.pricesCounter < this.interval) {
|
|
1403
|
+
throw new NotEnoughDataError();
|
|
1404
|
+
}
|
|
1405
|
+
return this.result;
|
|
1406
|
+
}
|
|
1407
|
+
get isStable() {
|
|
1408
|
+
try {
|
|
1409
|
+
this.getResultOrThrow();
|
|
1410
|
+
return true;
|
|
1411
|
+
} catch {
|
|
1412
|
+
return false;
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
};
|
|
1416
|
+
|
|
1417
|
+
// src/ROC/ROC.ts
|
|
1418
|
+
import Big20 from "big.js";
|
|
1348
1419
|
var ROC = class extends BigIndicatorSeries {
|
|
1349
1420
|
constructor(interval) {
|
|
1350
1421
|
super();
|
|
@@ -1354,7 +1425,7 @@ var ROC = class extends BigIndicatorSeries {
|
|
|
1354
1425
|
update(price, replace) {
|
|
1355
1426
|
const comparePrice = pushUpdate(this.prices, replace, price, this.interval);
|
|
1356
1427
|
if (comparePrice) {
|
|
1357
|
-
return this.setResult(new
|
|
1428
|
+
return this.setResult(new Big20(price).sub(comparePrice).div(comparePrice), replace);
|
|
1358
1429
|
}
|
|
1359
1430
|
return null;
|
|
1360
1431
|
}
|
|
@@ -1375,7 +1446,7 @@ var FasterROC = class extends NumberIndicatorSeries {
|
|
|
1375
1446
|
};
|
|
1376
1447
|
|
|
1377
1448
|
// src/RSI/RSI.ts
|
|
1378
|
-
import
|
|
1449
|
+
import Big21 from "big.js";
|
|
1379
1450
|
var RSI = class extends BigIndicatorSeries {
|
|
1380
1451
|
constructor(interval, SmoothingIndicator = WSMA) {
|
|
1381
1452
|
super();
|
|
@@ -1386,25 +1457,25 @@ var RSI = class extends BigIndicatorSeries {
|
|
|
1386
1457
|
previousPrices = [];
|
|
1387
1458
|
avgGain;
|
|
1388
1459
|
avgLoss;
|
|
1389
|
-
maxValue = new
|
|
1460
|
+
maxValue = new Big21(100);
|
|
1390
1461
|
update(price, replace) {
|
|
1391
1462
|
pushUpdate(this.previousPrices, replace, price, this.interval);
|
|
1392
1463
|
if (this.previousPrices.length < 2) {
|
|
1393
1464
|
return null;
|
|
1394
1465
|
}
|
|
1395
|
-
const currentPrice = new
|
|
1396
|
-
const previousPrice = new
|
|
1466
|
+
const currentPrice = new Big21(price);
|
|
1467
|
+
const previousPrice = new Big21(this.previousPrices[this.previousPrices.length - 2]);
|
|
1397
1468
|
if (currentPrice.gt(previousPrice)) {
|
|
1398
|
-
this.avgLoss.update(new
|
|
1469
|
+
this.avgLoss.update(new Big21(0), replace);
|
|
1399
1470
|
this.avgGain.update(currentPrice.sub(previousPrice), replace);
|
|
1400
1471
|
} else {
|
|
1401
1472
|
this.avgLoss.update(previousPrice.sub(currentPrice), replace);
|
|
1402
|
-
this.avgGain.update(new
|
|
1473
|
+
this.avgGain.update(new Big21(0), replace);
|
|
1403
1474
|
}
|
|
1404
1475
|
if (this.avgGain.isStable) {
|
|
1405
1476
|
const avgLoss = this.avgLoss.getResultOrThrow();
|
|
1406
1477
|
if (avgLoss.eq(0)) {
|
|
1407
|
-
return this.setResult(new
|
|
1478
|
+
return this.setResult(new Big21(100), replace);
|
|
1408
1479
|
}
|
|
1409
1480
|
const relativeStrength = this.avgGain.getResultOrThrow().div(avgLoss);
|
|
1410
1481
|
return this.setResult(this.maxValue.minus(this.maxValue.div(relativeStrength.add(1))), replace);
|
|
@@ -1450,7 +1521,7 @@ var FasterRSI = class extends NumberIndicatorSeries {
|
|
|
1450
1521
|
};
|
|
1451
1522
|
|
|
1452
1523
|
// src/STOCH/StochasticOscillator.ts
|
|
1453
|
-
import
|
|
1524
|
+
import Big22 from "big.js";
|
|
1454
1525
|
var StochasticOscillator = class extends TechnicalIndicator {
|
|
1455
1526
|
/**
|
|
1456
1527
|
* Constructs a Stochastic Oscillator.
|
|
@@ -1475,8 +1546,8 @@ var StochasticOscillator = class extends TechnicalIndicator {
|
|
|
1475
1546
|
if (this.candles.length === this.n) {
|
|
1476
1547
|
const highest = getMaximum(this.candles.map((candle2) => candle2.high));
|
|
1477
1548
|
const lowest = getMinimum(this.candles.map((candle2) => candle2.low));
|
|
1478
|
-
const divisor = new
|
|
1479
|
-
let fastK = new
|
|
1549
|
+
const divisor = new Big22(highest).minus(lowest);
|
|
1550
|
+
let fastK = new Big22(100).mul(new Big22(candle.close).minus(lowest));
|
|
1480
1551
|
fastK = fastK.div(divisor.eq(0) ? 1 : divisor);
|
|
1481
1552
|
const stochK = this.periodM.update(fastK, replace);
|
|
1482
1553
|
const stochD = stochK && this.periodP.update(stochK, replace);
|
|
@@ -1529,7 +1600,7 @@ var FasterStochasticOscillator = class extends TechnicalIndicator {
|
|
|
1529
1600
|
};
|
|
1530
1601
|
|
|
1531
1602
|
// src/STOCH/StochasticRSI.ts
|
|
1532
|
-
import
|
|
1603
|
+
import Big23 from "big.js";
|
|
1533
1604
|
var StochasticRSI = class extends BigIndicatorSeries {
|
|
1534
1605
|
constructor(interval, SmoothingIndicator = WSMA) {
|
|
1535
1606
|
super();
|
|
@@ -1548,7 +1619,7 @@ var StochasticRSI = class extends BigIndicatorSeries {
|
|
|
1548
1619
|
const max = periodResult.highest;
|
|
1549
1620
|
const denominator = max.minus(min);
|
|
1550
1621
|
if (denominator.eq(0)) {
|
|
1551
|
-
return this.setResult(new
|
|
1622
|
+
return this.setResult(new Big23(100), false);
|
|
1552
1623
|
}
|
|
1553
1624
|
const numerator = rsiResult.minus(min);
|
|
1554
1625
|
return this.setResult(numerator.div(denominator), false);
|
|
@@ -1586,7 +1657,7 @@ var FasterStochasticRSI = class extends NumberIndicatorSeries {
|
|
|
1586
1657
|
};
|
|
1587
1658
|
|
|
1588
1659
|
// src/WMA/WMA.ts
|
|
1589
|
-
import
|
|
1660
|
+
import Big24 from "big.js";
|
|
1590
1661
|
var WMA = class extends MovingAverage {
|
|
1591
1662
|
constructor(interval) {
|
|
1592
1663
|
super(interval);
|
|
@@ -1597,9 +1668,9 @@ var WMA = class extends MovingAverage {
|
|
|
1597
1668
|
pushUpdate(this.prices, replace, price, this.interval);
|
|
1598
1669
|
if (this.prices.length === this.interval) {
|
|
1599
1670
|
const weightedPricesSum = this.prices.reduce((acc, price2, index) => {
|
|
1600
|
-
const weightedPrice = new
|
|
1671
|
+
const weightedPrice = new Big24(price2).mul(index + 1);
|
|
1601
1672
|
return acc.add(weightedPrice);
|
|
1602
|
-
}, new
|
|
1673
|
+
}, new Big24(0));
|
|
1603
1674
|
const weightBase = this.interval * (this.interval + 1) / 2;
|
|
1604
1675
|
const weightedMa = weightedPricesSum.div(weightBase);
|
|
1605
1676
|
return this.setResult(weightedMa, replace);
|
|
@@ -1663,6 +1734,7 @@ export {
|
|
|
1663
1734
|
FasterMovingAverage,
|
|
1664
1735
|
FasterOBV,
|
|
1665
1736
|
FasterPeriod,
|
|
1737
|
+
FasterRMA,
|
|
1666
1738
|
FasterROC,
|
|
1667
1739
|
FasterRSI,
|
|
1668
1740
|
FasterSMA,
|
|
@@ -1679,6 +1751,7 @@ export {
|
|
|
1679
1751
|
NumberIndicatorSeries,
|
|
1680
1752
|
OBV,
|
|
1681
1753
|
Period,
|
|
1754
|
+
RMA,
|
|
1682
1755
|
ROC,
|
|
1683
1756
|
RSI,
|
|
1684
1757
|
SMA,
|
|
@@ -1691,7 +1764,6 @@ export {
|
|
|
1691
1764
|
getAverage,
|
|
1692
1765
|
getFasterAverage,
|
|
1693
1766
|
getFasterStandardDeviation,
|
|
1694
|
-
getLastFromForEach,
|
|
1695
1767
|
getMaximum,
|
|
1696
1768
|
getMinimum,
|
|
1697
1769
|
getStandardDeviation,
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"@vitest/coverage-v8": "^1.1.1",
|
|
16
16
|
"benchmark": "^2.1.4",
|
|
17
17
|
"dependency-cruiser": "^16.9.0",
|
|
18
|
-
"eslint": "^8.
|
|
18
|
+
"eslint": "^8.57.0",
|
|
19
19
|
"generate-changelog": "^1.8.0",
|
|
20
20
|
"husky": "^4.3.8",
|
|
21
21
|
"lint-staged": "^15.0.2",
|
|
@@ -104,5 +104,5 @@
|
|
|
104
104
|
"test:types": "npm run lint:types"
|
|
105
105
|
},
|
|
106
106
|
"type": "module",
|
|
107
|
-
"version": "6.
|
|
107
|
+
"version": "6.1.0"
|
|
108
108
|
}
|