trading-signals 6.0.0 → 6.0.1
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 +20 -0
- package/dist/index.cjs +1 -12
- package/dist/index.d.cts +3 -5
- package/dist/index.d.ts +3 -5
- package/dist/index.js +1 -11
- package/package.json +1 -1
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
|
|
package/dist/index.cjs
CHANGED
|
@@ -93,7 +93,6 @@ __export(index_exports, {
|
|
|
93
93
|
getAverage: () => getAverage,
|
|
94
94
|
getFasterAverage: () => getFasterAverage,
|
|
95
95
|
getFasterStandardDeviation: () => getFasterStandardDeviation,
|
|
96
|
-
getLastFromForEach: () => getLastFromForEach,
|
|
97
96
|
getMaximum: () => getMaximum,
|
|
98
97
|
getMinimum: () => getMinimum,
|
|
99
98
|
getStandardDeviation: () => getStandardDeviation,
|
|
@@ -112,15 +111,6 @@ var NotEnoughDataError = class extends Error {
|
|
|
112
111
|
}
|
|
113
112
|
};
|
|
114
113
|
|
|
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
114
|
// src/Indicator.ts
|
|
125
115
|
var TechnicalIndicator = class {
|
|
126
116
|
result;
|
|
@@ -147,7 +137,7 @@ var TechnicalIndicator = class {
|
|
|
147
137
|
return this.update(input, true);
|
|
148
138
|
}
|
|
149
139
|
updates(inputs, replace = false) {
|
|
150
|
-
return
|
|
140
|
+
return inputs.map((input) => this.update(input, replace));
|
|
151
141
|
}
|
|
152
142
|
};
|
|
153
143
|
var BaseIndicatorSeries = class extends TechnicalIndicator {
|
|
@@ -1794,7 +1784,6 @@ var FasterWMA = class extends FasterMovingAverage {
|
|
|
1794
1784
|
getAverage,
|
|
1795
1785
|
getFasterAverage,
|
|
1796
1786
|
getFasterStandardDeviation,
|
|
1797
|
-
getLastFromForEach,
|
|
1798
1787
|
getMaximum,
|
|
1799
1788
|
getMinimum,
|
|
1800
1789
|
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;
|
|
@@ -119,8 +119,6 @@ interface FasterBandsResult {
|
|
|
119
119
|
declare function getAverage(values: BigSource[]): Big__default;
|
|
120
120
|
declare function getFasterAverage(values: number[]): number;
|
|
121
121
|
|
|
122
|
-
declare function getLastFromForEach<T, R>(array: readonly T[], callback: (value: T, index: number, array: readonly T[]) => R): R | null;
|
|
123
|
-
|
|
124
122
|
declare function getMaximum(values: BigSource[]): Big__default;
|
|
125
123
|
|
|
126
124
|
declare function getMinimum(values: BigSource[]): Big__default;
|
|
@@ -619,4 +617,4 @@ declare class FasterTR extends NumberIndicatorSeries<HighLowCloseNumber> {
|
|
|
619
617
|
update(candle: HighLowCloseNumber, replace: boolean): number;
|
|
620
618
|
}
|
|
621
619
|
|
|
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,
|
|
620
|
+
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, 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;
|
|
@@ -119,8 +119,6 @@ interface FasterBandsResult {
|
|
|
119
119
|
declare function getAverage(values: BigSource[]): Big__default;
|
|
120
120
|
declare function getFasterAverage(values: number[]): number;
|
|
121
121
|
|
|
122
|
-
declare function getLastFromForEach<T, R>(array: readonly T[], callback: (value: T, index: number, array: readonly T[]) => R): R | null;
|
|
123
|
-
|
|
124
122
|
declare function getMaximum(values: BigSource[]): Big__default;
|
|
125
123
|
|
|
126
124
|
declare function getMinimum(values: BigSource[]): Big__default;
|
|
@@ -619,4 +617,4 @@ declare class FasterTR extends NumberIndicatorSeries<HighLowCloseNumber> {
|
|
|
619
617
|
update(candle: HighLowCloseNumber, replace: boolean): number;
|
|
620
618
|
}
|
|
621
619
|
|
|
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,
|
|
620
|
+
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, 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 {
|
|
@@ -1691,7 +1682,6 @@ export {
|
|
|
1691
1682
|
getAverage,
|
|
1692
1683
|
getFasterAverage,
|
|
1693
1684
|
getFasterStandardDeviation,
|
|
1694
|
-
getLastFromForEach,
|
|
1695
1685
|
getMaximum,
|
|
1696
1686
|
getMinimum,
|
|
1697
1687
|
getStandardDeviation,
|
package/package.json
CHANGED