trading-signals 2.4.1 → 3.2.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 +28 -14
- package/dist/ABANDS/AccelerationBands.d.ts +17 -6
- package/dist/ABANDS/AccelerationBands.js +36 -13
- package/dist/ABANDS/AccelerationBands.js.map +1 -1
- package/dist/AC/AC.d.ts +18 -9
- package/dist/AC/AC.js +27 -14
- package/dist/AC/AC.js.map +1 -1
- package/dist/ADX/ADX.d.ts +20 -23
- package/dist/ADX/ADX.js +42 -66
- package/dist/ADX/ADX.js.map +1 -1
- package/dist/AO/AO.d.ts +18 -10
- package/dist/AO/AO.js +25 -18
- package/dist/AO/AO.js.map +1 -1
- package/dist/ATR/ATR.d.ts +13 -11
- package/dist/ATR/ATR.js +21 -36
- package/dist/ATR/ATR.js.map +1 -1
- package/dist/BBANDS/BollingerBands.d.ts +2 -2
- package/dist/BBANDS/BollingerBands.js +6 -6
- package/dist/BBANDS/BollingerBands.js.map +1 -1
- package/dist/CCI/CCI.d.ts +23 -0
- package/dist/CCI/CCI.js +66 -0
- package/dist/CCI/CCI.js.map +1 -0
- package/dist/CG/CG.d.ts +0 -1
- package/dist/CG/CG.js +0 -7
- package/dist/CG/CG.js.map +1 -1
- package/dist/DEMA/DEMA.d.ts +0 -1
- package/dist/DEMA/DEMA.js +0 -6
- package/dist/DEMA/DEMA.js.map +1 -1
- package/dist/DMA/DMA.d.ts +16 -4
- package/dist/DMA/DMA.js +24 -6
- package/dist/DMA/DMA.js.map +1 -1
- package/dist/DX/DX.d.ts +28 -0
- package/dist/DX/DX.js +101 -0
- package/dist/DX/DX.js.map +1 -0
- package/dist/EMA/EMA.js +2 -8
- package/dist/EMA/EMA.js.map +1 -1
- package/dist/Indicator.d.ts +15 -19
- package/dist/Indicator.js +25 -8
- package/dist/Indicator.js.map +1 -1
- package/dist/MA/MovingAverage.d.ts +1 -5
- package/dist/MA/MovingAverage.js +0 -19
- package/dist/MA/MovingAverage.js.map +1 -1
- package/dist/MA/MovingAverageTypes.d.ts +5 -0
- package/dist/MA/{MovingAverageTypeContext.js → MovingAverageTypes.js} +1 -1
- package/dist/MA/MovingAverageTypes.js.map +1 -0
- package/dist/MACD/MACD.js +1 -1
- package/dist/MACD/MACD.js.map +1 -1
- package/dist/MAD/MAD.d.ts +16 -0
- package/dist/MAD/MAD.js +65 -0
- package/dist/MAD/MAD.js.map +1 -0
- package/dist/MOM/MOM.d.ts +11 -6
- package/dist/MOM/MOM.js +18 -13
- package/dist/MOM/MOM.js.map +1 -1
- package/dist/ROC/ROC.d.ts +0 -2
- package/dist/ROC/ROC.js +0 -10
- package/dist/ROC/ROC.js.map +1 -1
- package/dist/RSI/RSI.d.ts +15 -7
- package/dist/RSI/RSI.js +43 -33
- package/dist/RSI/RSI.js.map +1 -1
- package/dist/SMA/SMA.d.ts +2 -7
- package/dist/SMA/SMA.js +4 -14
- package/dist/SMA/SMA.js.map +1 -1
- package/dist/STOCH/StochasticOscillator.d.ts +3 -3
- package/dist/STOCH/StochasticOscillator.js +1 -1
- package/dist/STOCH/StochasticOscillator.js.map +1 -1
- package/dist/STOCH/StochasticRSI.d.ts +17 -0
- package/dist/STOCH/StochasticRSI.js +52 -0
- package/dist/STOCH/StochasticRSI.js.map +1 -0
- package/dist/TR/TR.d.ts +11 -0
- package/dist/TR/TR.js +40 -0
- package/dist/TR/TR.js.map +1 -0
- package/dist/WSMA/WSMA.d.ts +8 -2
- package/dist/WSMA/WSMA.js +19 -15
- package/dist/WSMA/WSMA.js.map +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/util/HighLowClose.d.ts +11 -2
- package/dist/util/Period.d.ts +22 -0
- package/dist/util/Period.js +48 -0
- package/dist/util/Period.js.map +1 -0
- package/dist/util/getAverage.js.map +1 -1
- package/dist/util/index.d.ts +1 -0
- package/dist/util/index.js +1 -0
- package/dist/util/index.js.map +1 -1
- package/package.json +11 -11
- package/dist/MA/MovingAverageTypeContext.d.ts +0 -5
- package/dist/MA/MovingAverageTypeContext.js.map +0 -1
- package/dist/SMMA/SMMA.d.ts +0 -11
- package/dist/SMMA/SMMA.js +0 -42
- package/dist/SMMA/SMMA.js.map +0 -1
package/README.md
CHANGED
|
@@ -8,20 +8,28 @@ Technical indicators and overlays to run technical analysis with JavaScript / Ty
|
|
|
8
8
|
|
|
9
9
|
The "trading-signals" library provides a TypeScript implementation for common technical indicators with arbitrary-precision decimal arithmetic.
|
|
10
10
|
|
|
11
|
-
The main focus of this library is on the accuracy of calculations, but using the [faster implementations]
|
|
11
|
+
The main focus of this library is on the accuracy of calculations, but using the provided [faster implementations][2] you can also use it where performance is important.
|
|
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
|
-
|
|
16
|
-
|
|
15
|
+
## Benefits & Features
|
|
16
|
+
|
|
17
|
+
- **Accurate.** Indicators with intervals will return a result only when the period is reached.
|
|
18
|
+
- **Convenient.** Indicators with intervals will save their all-time highs and lows.
|
|
19
|
+
- **Fast.** If you need high throughput, you can use the included [faster implementations][2].
|
|
20
|
+
- **Flexible.** All advanced indicators support different smoothing overlays (WSMA, etc.).
|
|
21
|
+
- **Precise.** Better accuracy than calculating with primitive numbers thanks to [big.js][1].
|
|
17
22
|
- **Tested.** Code coverage is 100%. No surprises when using it.
|
|
23
|
+
- **Typed.** Source code is 100% TypeScript. No need to install external typings.
|
|
24
|
+
- **Verified.** All results are verified with [other libraries](#alternatives) to guarantee correctness.
|
|
25
|
+
- **Versatile.** Indicators can be updated up-front or by streaming prices.
|
|
18
26
|
|
|
19
27
|
## Technical Indicator Types
|
|
20
28
|
|
|
21
|
-
- Trend indicators: Measure the direction of a trend
|
|
29
|
+
- Trend indicators: Measure the direction of a trend (uptrend, downtrend or sideways trend)
|
|
22
30
|
- Volume indicators: Measure the strength of a trend (based on volume)
|
|
23
|
-
- Volatility indicators: Measure
|
|
24
|
-
- Momentum indicators: Measure the speed of price movement
|
|
31
|
+
- Volatility indicators: Measure how much disagreement there is in the market based on price (statistical measure of its dispersion)
|
|
32
|
+
- Momentum indicators: Measure the strength of a trend (based on price / speed of price movement)
|
|
25
33
|
|
|
26
34
|
## Supported Technical Indicators
|
|
27
35
|
|
|
@@ -32,21 +40,25 @@ The main focus of this library is on the accuracy of calculations, but using the
|
|
|
32
40
|
1. Awesome Oscillator (AO)
|
|
33
41
|
1. Bollinger Bands (BBANDS)
|
|
34
42
|
1. Center of Gravity (CG)
|
|
43
|
+
1. Commodity Channel Index (CCI)
|
|
44
|
+
1. Directional Movement Index (DMI / DX)
|
|
35
45
|
1. Double Exponential Moving Average (DEMA)
|
|
36
46
|
1. Dual Moving Average (DMA)
|
|
37
47
|
1. Exponential Moving Average (EMA)
|
|
48
|
+
1. Mean Absolute Deviation (MAD)
|
|
38
49
|
1. Momentum (MOM)
|
|
39
50
|
1. Moving Average Convergence Divergence (MACD)
|
|
40
51
|
1. Rate-of-Change (ROC)
|
|
41
52
|
1. Relative Strength Index (RSI)
|
|
42
53
|
1. Simple Moving Average (SMA)
|
|
43
|
-
1. Smoothed Moving Average (SMMA)
|
|
44
54
|
1. Stochastic Oscillator (STOCH)
|
|
45
|
-
1.
|
|
55
|
+
1. Stochastic RSI (STOCHRSI)
|
|
56
|
+
1. True Range (TR)
|
|
57
|
+
1. Wilder's Smoothed Moving Average (WSMA / WMA / WWS / SMMA / MEMA)
|
|
46
58
|
|
|
47
59
|
Utility Methods:
|
|
48
60
|
|
|
49
|
-
1. Average
|
|
61
|
+
1. Average / Mean
|
|
50
62
|
1. Standard Deviation
|
|
51
63
|
1. Rolling Standard Deviation
|
|
52
64
|
|
|
@@ -136,13 +148,14 @@ It is very important to do your own analysis before making any investment based
|
|
|
136
148
|
|
|
137
149
|
## Alternatives
|
|
138
150
|
|
|
139
|
-
- [Tulip Indicators (ANSI C)](https://github.com/TulipCharts/tulipindicators)
|
|
140
|
-
- [Pandas TA (Python)](https://github.com/twopirllc/pandas-ta)
|
|
141
|
-
- [Jesse Trading Bot Indicators (Python)](https://docs.jesse.trade/docs/indicators/reference.html)
|
|
142
|
-
- [libindicators (C#)](https://github.com/mgfx/libindicators)
|
|
143
151
|
- [Cloud9Trader Indicators (JavaScript)](https://github.com/Cloud9Trader/TechnicalIndicators)
|
|
144
152
|
- [Crypto Trading Hub Indicators (TypeScript)](https://github.com/anandanand84/technicalindicators)
|
|
153
|
+
- [Jesse Trading Bot Indicators (Python)](https://docs.jesse.trade/docs/indicators/reference.html)
|
|
154
|
+
- [libindicators (C#)](https://github.com/mgfx/libindicators)
|
|
155
|
+
- [Pandas TA (Python)](https://github.com/twopirllc/pandas-ta)
|
|
156
|
+
- [Technical Analysis for Rust (Rust)](https://github.com/greyblake/ta-rs)
|
|
145
157
|
- [Technical Analysis Library using Pandas and Numpy (Python)](https://github.com/bukosabino/ta)
|
|
158
|
+
- [Tulip Indicators (ANSI C)](https://github.com/TulipCharts/tulipindicators)
|
|
146
159
|
|
|
147
160
|
## Maintainers
|
|
148
161
|
|
|
@@ -169,5 +182,6 @@ If you like this project, you might also like these related projects:
|
|
|
169
182
|
- [**binance-api-node**](https://github.com/Ashlar/binance-api-node), Heavily tested and Promise-based Binance API with TypeScript definitions.
|
|
170
183
|
|
|
171
184
|
[1]: http://mikemcl.github.io/big.js/
|
|
185
|
+
[2]: #faster-implementations
|
|
172
186
|
[stack_exchange_bennycode_badge]: https://stackexchange.com/users/flair/203782.png?theme=default
|
|
173
187
|
[stack_exchange_bennycode_url]: https://stackexchange.com/users/203782/benny-neugebauer?tab=accounts
|
|
@@ -1,15 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BandsResult } from '../util/BandsResult';
|
|
1
|
+
import { BandsResult, FasterBandsResult } from '../util/BandsResult';
|
|
3
2
|
import { Indicator } from '../Indicator';
|
|
4
|
-
import {
|
|
5
|
-
|
|
3
|
+
import { FasterMovingAverageTypes, MovingAverageTypes } from '../MA/MovingAverageTypes';
|
|
4
|
+
import { HighLowClose, HighLowCloseNumber } from '../util';
|
|
5
|
+
export declare class AccelerationBands implements Indicator<BandsResult, HighLowClose> {
|
|
6
6
|
readonly interval: number;
|
|
7
7
|
readonly width: number;
|
|
8
8
|
private readonly lowerBand;
|
|
9
9
|
private readonly middleBand;
|
|
10
10
|
private readonly upperBand;
|
|
11
|
-
constructor(interval: number, width: number,
|
|
11
|
+
constructor(interval: number, width: number, SmoothingIndicator?: MovingAverageTypes);
|
|
12
12
|
get isStable(): boolean;
|
|
13
|
-
update(high
|
|
13
|
+
update({ high, low, close }: HighLowClose): void;
|
|
14
14
|
getResult(): BandsResult;
|
|
15
15
|
}
|
|
16
|
+
export declare class FasterAccelerationBands implements Indicator<FasterBandsResult, HighLowCloseNumber> {
|
|
17
|
+
readonly interval: number;
|
|
18
|
+
readonly width: number;
|
|
19
|
+
private readonly lowerBand;
|
|
20
|
+
private readonly middleBand;
|
|
21
|
+
private readonly upperBand;
|
|
22
|
+
constructor(interval: number, width: number, SmoothingIndicator?: FasterMovingAverageTypes);
|
|
23
|
+
update({ high, low, close }: HighLowCloseNumber): void;
|
|
24
|
+
get isStable(): boolean;
|
|
25
|
+
getResult(): FasterBandsResult;
|
|
26
|
+
}
|
|
@@ -3,28 +3,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.AccelerationBands = void 0;
|
|
6
|
+
exports.FasterAccelerationBands = exports.AccelerationBands = void 0;
|
|
7
7
|
const SMA_1 = require("../SMA/SMA");
|
|
8
8
|
const big_js_1 = __importDefault(require("big.js"));
|
|
9
9
|
const error_1 = require("../error");
|
|
10
10
|
class AccelerationBands {
|
|
11
|
-
constructor(interval, width,
|
|
11
|
+
constructor(interval, width, SmoothingIndicator = SMA_1.SMA) {
|
|
12
12
|
this.interval = interval;
|
|
13
13
|
this.width = width;
|
|
14
|
-
this.lowerBand = new
|
|
15
|
-
this.middleBand = new
|
|
16
|
-
this.upperBand = new
|
|
14
|
+
this.lowerBand = new SmoothingIndicator(interval);
|
|
15
|
+
this.middleBand = new SmoothingIndicator(interval);
|
|
16
|
+
this.upperBand = new SmoothingIndicator(interval);
|
|
17
17
|
}
|
|
18
18
|
get isStable() {
|
|
19
|
-
|
|
20
|
-
this.middleBand.getResult();
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
23
|
-
catch (error) {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
19
|
+
return this.middleBand.isStable;
|
|
26
20
|
}
|
|
27
|
-
update(high, low, close) {
|
|
21
|
+
update({ high, low, close }) {
|
|
28
22
|
const coefficient = new big_js_1.default(high).minus(low).div(new big_js_1.default(high).plus(low)).mul(this.width);
|
|
29
23
|
this.lowerBand.update(new big_js_1.default(low).mul(new big_js_1.default(1).minus(coefficient)));
|
|
30
24
|
this.middleBand.update(close);
|
|
@@ -42,4 +36,33 @@ class AccelerationBands {
|
|
|
42
36
|
}
|
|
43
37
|
}
|
|
44
38
|
exports.AccelerationBands = AccelerationBands;
|
|
39
|
+
class FasterAccelerationBands {
|
|
40
|
+
constructor(interval, width, SmoothingIndicator = SMA_1.FasterSMA) {
|
|
41
|
+
this.interval = interval;
|
|
42
|
+
this.width = width;
|
|
43
|
+
this.lowerBand = new SmoothingIndicator(interval);
|
|
44
|
+
this.middleBand = new SmoothingIndicator(interval);
|
|
45
|
+
this.upperBand = new SmoothingIndicator(interval);
|
|
46
|
+
}
|
|
47
|
+
update({ high, low, close }) {
|
|
48
|
+
const coefficient = ((high - low) / (high + low)) * this.width;
|
|
49
|
+
this.lowerBand.update(low * (1 - coefficient));
|
|
50
|
+
this.middleBand.update(close);
|
|
51
|
+
this.upperBand.update(high * (1 + coefficient));
|
|
52
|
+
}
|
|
53
|
+
get isStable() {
|
|
54
|
+
return this.middleBand.isStable;
|
|
55
|
+
}
|
|
56
|
+
getResult() {
|
|
57
|
+
if (!this.isStable) {
|
|
58
|
+
throw new error_1.NotEnoughDataError();
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
lower: this.lowerBand.getResult(),
|
|
62
|
+
middle: this.middleBand.getResult(),
|
|
63
|
+
upper: this.upperBand.getResult(),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.FasterAccelerationBands = FasterAccelerationBands;
|
|
45
68
|
//# sourceMappingURL=AccelerationBands.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccelerationBands.js","sourceRoot":"","sources":["../../src/ABANDS/AccelerationBands.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"AccelerationBands.js","sourceRoot":"","sources":["../../src/ABANDS/AccelerationBands.ts"],"names":[],"mappings":";;;;;;AAAA,oCAA0C;AAC1C,oDAAyB;AACzB,oCAA4C;AAO5C,MAAa,iBAAiB;IAyB5B,YACkB,QAAgB,EAChB,KAAa,EAC7B,qBAAyC,SAAG;QAF5B,aAAQ,GAAR,QAAQ,CAAQ;QAChB,UAAK,GAAL,KAAK,CAAQ;QAG7B,IAAI,CAAC,SAAS,GAAG,IAAI,kBAAkB,CAAC,QAAQ,CAAC,CAAC;QAClD,IAAI,CAAC,UAAU,GAAG,IAAI,kBAAkB,CAAC,QAAQ,CAAC,CAAC;QACnD,IAAI,CAAC,SAAS,GAAG,IAAI,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IACpD,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;IAClC,CAAC;IAED,MAAM,CAAC,EAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAe;QACrC,MAAM,WAAW,GAAG,IAAI,gBAAG,CAAC,IAAI,CAAC,CAAC,KAAK,CAA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pD,CAAC;IAED,MAAM,CAAC,EAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAqB;QAC3C,MAAM,WAAW,GAAG,CAAC,CAAC,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;QAC/D,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC;QAC/C,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC9B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC;IAClD,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;IAClC,CAAC;IAED,SAAS;QACP,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAClB,MAAM,IAAI,0BAAkB,EAAE,CAAC;SAChC;QAED,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE;YACjC,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE;YACnC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE;SAClC,CAAC;IACJ,CAAC;CACF;AArCD,0DAqCC"}
|
package/dist/AC/AC.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { BigIndicatorSeries } from '../Indicator';
|
|
2
|
-
import Big
|
|
3
|
-
import { AO } from '../AO/AO';
|
|
4
|
-
import { SMA } from '../SMA/SMA';
|
|
5
|
-
import { MOM } from '../MOM/MOM';
|
|
6
|
-
|
|
1
|
+
import { BigIndicatorSeries, NumberIndicatorSeries } from '../Indicator';
|
|
2
|
+
import Big from 'big.js';
|
|
3
|
+
import { AO, FasterAO } from '../AO/AO';
|
|
4
|
+
import { FasterSMA, SMA } from '../SMA/SMA';
|
|
5
|
+
import { FasterMOM, MOM } from '../MOM/MOM';
|
|
6
|
+
import { HighLow, HighLowNumber } from '../util';
|
|
7
|
+
export declare class AC extends BigIndicatorSeries<HighLow> {
|
|
7
8
|
readonly shortAO: number;
|
|
8
9
|
readonly longAO: number;
|
|
9
10
|
readonly signalInterval: number;
|
|
@@ -11,7 +12,15 @@ export declare class AC extends BigIndicatorSeries {
|
|
|
11
12
|
readonly momentum: MOM;
|
|
12
13
|
readonly signal: SMA;
|
|
13
14
|
constructor(shortAO: number, longAO: number, signalInterval: number);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
update(input: HighLow): void | Big;
|
|
16
|
+
}
|
|
17
|
+
export declare class FasterAC extends NumberIndicatorSeries<HighLowNumber> {
|
|
18
|
+
readonly shortAO: number;
|
|
19
|
+
readonly longAO: number;
|
|
20
|
+
readonly signalInterval: number;
|
|
21
|
+
readonly ao: FasterAO;
|
|
22
|
+
readonly momentum: FasterMOM;
|
|
23
|
+
readonly signal: FasterSMA;
|
|
24
|
+
constructor(shortAO: number, longAO: number, signalInterval: number);
|
|
25
|
+
update(input: HighLowNumber): void | number;
|
|
17
26
|
}
|
package/dist/AC/AC.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AC = void 0;
|
|
3
|
+
exports.FasterAC = exports.AC = void 0;
|
|
4
4
|
const Indicator_1 = require("../Indicator");
|
|
5
|
-
const error_1 = require("../error");
|
|
6
5
|
const AO_1 = require("../AO/AO");
|
|
7
6
|
const SMA_1 = require("../SMA/SMA");
|
|
8
7
|
const MOM_1 = require("../MOM/MOM");
|
|
@@ -13,20 +12,11 @@ class AC extends Indicator_1.BigIndicatorSeries {
|
|
|
13
12
|
this.longAO = longAO;
|
|
14
13
|
this.signalInterval = signalInterval;
|
|
15
14
|
this.ao = new AO_1.AO(shortAO, longAO);
|
|
16
|
-
this.signal = new SMA_1.SMA(signalInterval);
|
|
17
15
|
this.momentum = new MOM_1.MOM(1);
|
|
16
|
+
this.signal = new SMA_1.SMA(signalInterval);
|
|
18
17
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
getResult() {
|
|
23
|
-
if (!this.result) {
|
|
24
|
-
throw new error_1.NotEnoughDataError();
|
|
25
|
-
}
|
|
26
|
-
return this.result;
|
|
27
|
-
}
|
|
28
|
-
update(low, high) {
|
|
29
|
-
const ao = this.ao.update(low, high);
|
|
18
|
+
update(input) {
|
|
19
|
+
const ao = this.ao.update(input);
|
|
30
20
|
if (ao) {
|
|
31
21
|
this.signal.update(ao);
|
|
32
22
|
if (this.signal.isStable) {
|
|
@@ -38,4 +28,27 @@ class AC extends Indicator_1.BigIndicatorSeries {
|
|
|
38
28
|
}
|
|
39
29
|
}
|
|
40
30
|
exports.AC = AC;
|
|
31
|
+
class FasterAC extends Indicator_1.NumberIndicatorSeries {
|
|
32
|
+
constructor(shortAO, longAO, signalInterval) {
|
|
33
|
+
super();
|
|
34
|
+
this.shortAO = shortAO;
|
|
35
|
+
this.longAO = longAO;
|
|
36
|
+
this.signalInterval = signalInterval;
|
|
37
|
+
this.ao = new AO_1.FasterAO(shortAO, longAO);
|
|
38
|
+
this.momentum = new MOM_1.FasterMOM(1);
|
|
39
|
+
this.signal = new SMA_1.FasterSMA(signalInterval);
|
|
40
|
+
}
|
|
41
|
+
update(input) {
|
|
42
|
+
const ao = this.ao.update(input);
|
|
43
|
+
if (ao) {
|
|
44
|
+
this.signal.update(ao);
|
|
45
|
+
if (this.signal.isStable) {
|
|
46
|
+
const result = this.setResult(ao - this.signal.getResult());
|
|
47
|
+
this.momentum.update(result);
|
|
48
|
+
return this.result;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.FasterAC = FasterAC;
|
|
41
54
|
//# sourceMappingURL=AC.js.map
|
package/dist/AC/AC.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AC.js","sourceRoot":"","sources":["../../src/AC/AC.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"AC.js","sourceRoot":"","sources":["../../src/AC/AC.ts"],"names":[],"mappings":";;;AAAA,4CAAuE;AAEvE,iCAAsC;AACtC,oCAA0C;AAC1C,oCAA0C;AAe1C,MAAa,EAAG,SAAQ,8BAA2B;IAKjD,YAA4B,OAAe,EAAkB,MAAc,EAAkB,cAAsB;QACjH,KAAK,EAAE,CAAC;QADkB,YAAO,GAAP,OAAO,CAAQ;QAAkB,WAAM,GAAN,MAAM,CAAQ;QAAkB,mBAAc,GAAd,cAAc,CAAQ;QAEjH,IAAI,CAAC,EAAE,GAAG,IAAI,OAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAClC,IAAI,CAAC,QAAQ,GAAG,IAAI,SAAG,CAAC,CAAC,CAAC,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,IAAI,SAAG,CAAC,cAAc,CAAC,CAAC;IACxC,CAAC;IAEQ,MAAM,CAAC,KAAc;QAC5B,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACjC,IAAI,EAAE,EAAE;YACN,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YACvB,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;gBACxB,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;gBAC/D,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;gBAC7B,OAAO,IAAI,CAAC,MAAM,CAAC;aACpB;SACF;IACH,CAAC;CACF;AAvBD,gBAuBC;AAED,MAAa,QAAS,SAAQ,iCAAoC;IA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22
|
-
update(candle: HighLowClose): void;
|
|
23
|
-
getResult(): ADXResult;
|
|
24
|
-
private directionalMovement;
|
|
2
|
+
import { BigIndicatorSeries, NumberIndicatorSeries } from '../Indicator';
|
|
3
|
+
import { HighLowClose, HighLowCloseNumber } from '../util/HighLowClose';
|
|
4
|
+
import { FasterMovingAverageTypes, MovingAverageTypes } from '../MA/MovingAverageTypes';
|
|
5
|
+
export declare class ADX extends BigIndicatorSeries<HighLowClose> {
|
|
6
|
+
readonly interval: number;
|
|
7
|
+
private readonly dx;
|
|
8
|
+
private readonly adx;
|
|
9
|
+
constructor(interval: number, SmoothingIndicator?: MovingAverageTypes);
|
|
10
|
+
get mdi(): Big | void;
|
|
11
|
+
get pdi(): Big | void;
|
|
12
|
+
update(candle: HighLowClose): Big | void;
|
|
13
|
+
}
|
|
14
|
+
export declare class FasterADX extends NumberIndicatorSeries<HighLowCloseNumber> {
|
|
15
|
+
readonly interval: number;
|
|
16
|
+
private readonly dx;
|
|
17
|
+
private readonly adx;
|
|
18
|
+
constructor(interval: number, SmoothingIndicator?: FasterMovingAverageTypes);
|
|
19
|
+
get mdi(): number | void;
|
|
20
|
+
get pdi(): number | void;
|
|
21
|
+
update(candle: HighLowCloseNumber): void | number;
|
|
25
22
|
}
|
package/dist/ADX/ADX.js
CHANGED
|
@@ -1,79 +1,55 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ADX = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
exports.FasterADX = exports.ADX = void 0;
|
|
4
|
+
const Indicator_1 = require("../Indicator");
|
|
5
|
+
const WSMA_1 = require("../WSMA/WSMA");
|
|
6
|
+
const DX_1 = require("../DX/DX");
|
|
7
|
+
class ADX extends Indicator_1.BigIndicatorSeries {
|
|
8
|
+
constructor(interval, SmoothingIndicator = WSMA_1.WSMA) {
|
|
9
|
+
super();
|
|
10
10
|
this.interval = interval;
|
|
11
|
-
this.
|
|
12
|
-
this.
|
|
13
|
-
this.pdi = new big_js_1.Big(0);
|
|
14
|
-
this.mdi = new big_js_1.Big(0);
|
|
15
|
-
this.atr = new __1.ATR(interval, SmoothingIndicator);
|
|
16
|
-
this.smoothedPDM = new SmoothingIndicator(interval);
|
|
17
|
-
this.smoothedMDM = new SmoothingIndicator(interval);
|
|
11
|
+
this.adx = new SmoothingIndicator(this.interval);
|
|
12
|
+
this.dx = new DX_1.DX(interval, SmoothingIndicator);
|
|
18
13
|
}
|
|
19
|
-
get
|
|
20
|
-
return this.
|
|
14
|
+
get mdi() {
|
|
15
|
+
return this.dx.mdi;
|
|
16
|
+
}
|
|
17
|
+
get pdi() {
|
|
18
|
+
return this.dx.pdi;
|
|
21
19
|
}
|
|
22
20
|
update(candle) {
|
|
23
|
-
this.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
this.prevCandle = candle;
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const { mdm, pdm } = this.directionalMovement(this.prevCandle, candle);
|
|
30
|
-
this.smoothedMDM.update(mdm);
|
|
31
|
-
this.smoothedPDM.update(pdm);
|
|
32
|
-
this.prevCandle = candle;
|
|
33
|
-
if (this.candles.length <= this.interval) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
this.pdi = this.smoothedPDM.getResult().div(atrResult).times(100);
|
|
37
|
-
this.mdi = this.smoothedMDM.getResult().div(atrResult).times(100);
|
|
38
|
-
const dx = this.pdi.sub(this.mdi).abs().div(this.pdi.add(this.mdi)).times(100);
|
|
39
|
-
this.dxValues.push(dx);
|
|
40
|
-
if (this.dxValues.length > this.interval) {
|
|
41
|
-
this.dxValues.shift();
|
|
42
|
-
}
|
|
43
|
-
if (this.dxValues.length < this.interval) {
|
|
44
|
-
return;
|
|
21
|
+
const result = this.dx.update(candle);
|
|
22
|
+
if (result) {
|
|
23
|
+
this.adx.update(result);
|
|
45
24
|
}
|
|
46
|
-
if (
|
|
47
|
-
this.
|
|
48
|
-
return;
|
|
25
|
+
if (this.adx.isStable) {
|
|
26
|
+
return this.setResult(this.adx.getResult());
|
|
49
27
|
}
|
|
50
|
-
this.adx = this.adx
|
|
51
|
-
.times(this.interval - 1)
|
|
52
|
-
.add(dx)
|
|
53
|
-
.div(this.interval);
|
|
54
28
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
29
|
+
}
|
|
30
|
+
exports.ADX = ADX;
|
|
31
|
+
class FasterADX extends Indicator_1.NumberIndicatorSeries {
|
|
32
|
+
constructor(interval, SmoothingIndicator = WSMA_1.FasterWSMA) {
|
|
33
|
+
super();
|
|
34
|
+
this.interval = interval;
|
|
35
|
+
this.adx = new SmoothingIndicator(this.interval);
|
|
36
|
+
this.dx = new DX_1.FasterDX(interval, SmoothingIndicator);
|
|
37
|
+
}
|
|
38
|
+
get mdi() {
|
|
39
|
+
return this.dx.mdi;
|
|
64
40
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
41
|
+
get pdi() {
|
|
42
|
+
return this.dx.pdi;
|
|
43
|
+
}
|
|
44
|
+
update(candle) {
|
|
45
|
+
const result = this.dx.update(candle);
|
|
46
|
+
if (result) {
|
|
47
|
+
this.adx.update(result);
|
|
48
|
+
}
|
|
49
|
+
if (this.adx.isStable) {
|
|
50
|
+
return this.setResult(this.adx.getResult());
|
|
51
|
+
}
|
|
76
52
|
}
|
|
77
53
|
}
|
|
78
|
-
exports.
|
|
54
|
+
exports.FasterADX = FasterADX;
|
|
79
55
|
//# sourceMappingURL=ADX.js.map
|
package/dist/ADX/ADX.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ADX.js","sourceRoot":"","sources":["../../src/ADX/ADX.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"ADX.js","sourceRoot":"","sources":["../../src/ADX/ADX.ts"],"names":[],"mappings":";;;AACA,4CAAuE;AAIvE,uCAA8C;AAC9C,iCAAsC;AAyBtC,MAAa,GAAI,SAAQ,8BAAgC;IAIvD,YAA4B,QAAgB,EAAE,qBAAyC,WAAI;QACzF,KAAK,EAAE,CAAC;QADkB,aAAQ,GAAR,QAAQ,CAAQ;QAE1C,IAAI,CAAC,GAAG,GAAG,IAAI,kBAAkB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACjD,IAAI,CAAC,EAAE,GAAG,IAAI,OAAE,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;IACjD,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC;IACrB,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC;IACrB,CAAC;IAED,MAAM,CAAC,MAAoB;QACzB,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACtC,IAAI,MAAM,EAAE;YACV,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;SACzB;QACD,IAAI,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE;YACrB,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC;SAC7C;IACH,CAAC;CACF;AA3BD,kBA2BC;AAED,MAAa,SAAU,SAAQ,iCAAyC;IAItE,YAA4B,QAAgB,EAAE,qBAA+C,iBAAU;QACrG,KAAK,EAAE,CAAC;QADkB,aAAQ,GAAR,QAAQ,CAAQ;QAE1C,IAAI,CAAC,GAAG,GAAG,IAAI,kBAAkB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACjD,IAAI,CAAC,EAAE,GAAG,IAAI,aAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;IACvD,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC;IACrB,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC;IACrB,CAAC;IAED,MAAM,CAAC,MAA0B;QAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACtC,IAAI,MAAM,EAAE;YACV,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;SACzB;QACD,IAAI,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE;YACrB,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC;SAC7C;IACH,CAAC;CACF;AA3BD,8BA2BC"}
|
package/dist/AO/AO.d.ts
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
import { BigIndicatorSeries } from '../Indicator';
|
|
2
|
-
import Big
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { BigIndicatorSeries, NumberIndicatorSeries } from '../Indicator';
|
|
2
|
+
import Big from 'big.js';
|
|
3
|
+
import { HighLow, HighLowNumber } from '../util';
|
|
4
|
+
import { FasterMovingAverageTypes, MovingAverageTypes } from '../MA/MovingAverageTypes';
|
|
5
|
+
import { FasterMovingAverage, MovingAverage } from '../MA/MovingAverage';
|
|
6
|
+
export declare class AO extends BigIndicatorSeries<HighLow> {
|
|
5
7
|
readonly shortInterval: number;
|
|
6
8
|
readonly longInterval: number;
|
|
7
|
-
readonly long:
|
|
8
|
-
readonly short:
|
|
9
|
-
constructor(shortInterval: number, longInterval: number);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
readonly long: MovingAverage;
|
|
10
|
+
readonly short: MovingAverage;
|
|
11
|
+
constructor(shortInterval: number, longInterval: number, SmoothingIndicator?: MovingAverageTypes);
|
|
12
|
+
update({ low, high }: HighLow): void | Big;
|
|
13
|
+
}
|
|
14
|
+
export declare class FasterAO extends NumberIndicatorSeries<HighLowNumber> {
|
|
15
|
+
readonly shortInterval: number;
|
|
16
|
+
readonly longInterval: number;
|
|
17
|
+
readonly long: FasterMovingAverage;
|
|
18
|
+
readonly short: FasterMovingAverage;
|
|
19
|
+
constructor(shortInterval: number, longInterval: number, SmoothingIndicator?: FasterMovingAverageTypes);
|
|
20
|
+
update({ low, high }: HighLowNumber): void | number;
|
|
13
21
|
}
|
package/dist/AO/AO.js
CHANGED
|
@@ -3,38 +3,45 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.AO = void 0;
|
|
6
|
+
exports.FasterAO = exports.AO = void 0;
|
|
7
7
|
const Indicator_1 = require("../Indicator");
|
|
8
8
|
const big_js_1 = __importDefault(require("big.js"));
|
|
9
9
|
const SMA_1 = require("../SMA/SMA");
|
|
10
|
-
const error_1 = require("../error");
|
|
11
10
|
class AO extends Indicator_1.BigIndicatorSeries {
|
|
12
|
-
constructor(shortInterval, longInterval) {
|
|
11
|
+
constructor(shortInterval, longInterval, SmoothingIndicator = SMA_1.SMA) {
|
|
13
12
|
super();
|
|
14
13
|
this.shortInterval = shortInterval;
|
|
15
14
|
this.longInterval = longInterval;
|
|
16
|
-
this.short = new
|
|
17
|
-
this.long = new
|
|
15
|
+
this.short = new SmoothingIndicator(shortInterval);
|
|
16
|
+
this.long = new SmoothingIndicator(longInterval);
|
|
18
17
|
}
|
|
19
|
-
|
|
20
|
-
return this.result !== undefined;
|
|
21
|
-
}
|
|
22
|
-
getResult() {
|
|
23
|
-
if (!this.result) {
|
|
24
|
-
throw new error_1.NotEnoughDataError();
|
|
25
|
-
}
|
|
26
|
-
return this.result;
|
|
27
|
-
}
|
|
28
|
-
update(low, high) {
|
|
18
|
+
update({ low, high }) {
|
|
29
19
|
const candleSum = new big_js_1.default(low).add(high);
|
|
30
20
|
const medianPrice = candleSum.div(2);
|
|
31
21
|
this.short.update(medianPrice);
|
|
32
22
|
this.long.update(medianPrice);
|
|
33
|
-
if (this.
|
|
34
|
-
|
|
35
|
-
return result;
|
|
23
|
+
if (this.long.isStable) {
|
|
24
|
+
return this.setResult(this.short.getResult().sub(this.long.getResult()));
|
|
36
25
|
}
|
|
37
26
|
}
|
|
38
27
|
}
|
|
39
28
|
exports.AO = AO;
|
|
29
|
+
class FasterAO extends Indicator_1.NumberIndicatorSeries {
|
|
30
|
+
constructor(shortInterval, longInterval, SmoothingIndicator = SMA_1.FasterSMA) {
|
|
31
|
+
super();
|
|
32
|
+
this.shortInterval = shortInterval;
|
|
33
|
+
this.longInterval = longInterval;
|
|
34
|
+
this.short = new SmoothingIndicator(shortInterval);
|
|
35
|
+
this.long = new SmoothingIndicator(longInterval);
|
|
36
|
+
}
|
|
37
|
+
update({ low, high }) {
|
|
38
|
+
const medianPrice = (low + high) / 2;
|
|
39
|
+
this.short.update(medianPrice);
|
|
40
|
+
this.long.update(medianPrice);
|
|
41
|
+
if (this.long.isStable) {
|
|
42
|
+
return this.setResult(this.short.getResult() - this.long.getResult());
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.FasterAO = FasterAO;
|
|
40
47
|
//# sourceMappingURL=AO.js.map
|
package/dist/AO/AO.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AO.js","sourceRoot":"","sources":["../../src/AO/AO.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"AO.js","sourceRoot":"","sources":["../../src/AO/AO.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAuE;AACvE,oDAAy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