@tradingaction/indicators 2.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/LICENSE +24 -0
- package/README.md +5 -0
- package/lib/calculator/atr.d.ts +18 -0
- package/lib/calculator/atr.js +51 -0
- package/lib/calculator/atr.js.map +1 -0
- package/lib/calculator/bollingerband.d.ts +14 -0
- package/lib/calculator/bollingerband.js +72 -0
- package/lib/calculator/bollingerband.js.map +1 -0
- package/lib/calculator/change.d.ts +14 -0
- package/lib/calculator/change.js +30 -0
- package/lib/calculator/change.js.map +1 -0
- package/lib/calculator/compare.d.ts +10 -0
- package/lib/calculator/compare.js +50 -0
- package/lib/calculator/compare.js.map +1 -0
- package/lib/calculator/defaultOptionsForComputation.d.ts +91 -0
- package/lib/calculator/defaultOptionsForComputation.js +100 -0
- package/lib/calculator/defaultOptionsForComputation.js.map +1 -0
- package/lib/calculator/elderRay.d.ts +23 -0
- package/lib/calculator/elderRay.js +69 -0
- package/lib/calculator/elderRay.js.map +1 -0
- package/lib/calculator/ema.d.ts +12 -0
- package/lib/calculator/ema.js +73 -0
- package/lib/calculator/ema.js.map +1 -0
- package/lib/calculator/forceIndex.d.ts +12 -0
- package/lib/calculator/forceIndex.js +27 -0
- package/lib/calculator/forceIndex.js.map +1 -0
- package/lib/calculator/heikinAshi.d.ts +4 -0
- package/lib/calculator/heikinAshi.js +30 -0
- package/lib/calculator/heikinAshi.js.map +1 -0
- package/lib/calculator/index.d.ts +19 -0
- package/lib/calculator/index.js +20 -0
- package/lib/calculator/index.js.map +1 -0
- package/lib/calculator/kagi.d.ts +11 -0
- package/lib/calculator/kagi.js +200 -0
- package/lib/calculator/kagi.js.map +1 -0
- package/lib/calculator/macd.d.ts +18 -0
- package/lib/calculator/macd.js +57 -0
- package/lib/calculator/macd.js.map +1 -0
- package/lib/calculator/pointAndFigure.d.ts +10 -0
- package/lib/calculator/pointAndFigure.js +215 -0
- package/lib/calculator/pointAndFigure.js.map +1 -0
- package/lib/calculator/renko.d.ts +12 -0
- package/lib/calculator/renko.js +170 -0
- package/lib/calculator/renko.js.map +1 -0
- package/lib/calculator/rsi.d.ts +12 -0
- package/lib/calculator/rsi.js +87 -0
- package/lib/calculator/rsi.js.map +1 -0
- package/lib/calculator/sar.d.ts +12 -0
- package/lib/calculator/sar.js +87 -0
- package/lib/calculator/sar.js.map +1 -0
- package/lib/calculator/sma.d.ts +12 -0
- package/lib/calculator/sma.js +27 -0
- package/lib/calculator/sma.js.map +1 -0
- package/lib/calculator/smoothedForceIndex.d.ts +13 -0
- package/lib/calculator/smoothedForceIndex.js +40 -0
- package/lib/calculator/smoothedForceIndex.js.map +1 -0
- package/lib/calculator/sto.d.ts +19 -0
- package/lib/calculator/sto.js +91 -0
- package/lib/calculator/sto.js.map +1 -0
- package/lib/calculator/tma.d.ts +12 -0
- package/lib/calculator/tma.js +66 -0
- package/lib/calculator/tma.js.map +1 -0
- package/lib/calculator/wma.d.ts +12 -0
- package/lib/calculator/wma.js +33 -0
- package/lib/calculator/wma.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -0
- package/lib/indicator/algorithm.d.ts +10 -0
- package/lib/indicator/algorithm.js +35 -0
- package/lib/indicator/algorithm.js.map +1 -0
- package/lib/indicator/atr.d.ts +26 -0
- package/lib/indicator/atr.js +27 -0
- package/lib/indicator/atr.js.map +1 -0
- package/lib/indicator/baseIndicator.d.ts +16 -0
- package/lib/indicator/baseIndicator.js +59 -0
- package/lib/indicator/baseIndicator.js.map +1 -0
- package/lib/indicator/bollingerBand.d.ts +24 -0
- package/lib/indicator/bollingerBand.js +27 -0
- package/lib/indicator/bollingerBand.js.map +1 -0
- package/lib/indicator/change.d.ts +24 -0
- package/lib/indicator/change.js +25 -0
- package/lib/indicator/change.js.map +1 -0
- package/lib/indicator/compare.d.ts +24 -0
- package/lib/indicator/compare.js +29 -0
- package/lib/indicator/compare.js.map +1 -0
- package/lib/indicator/defaultOptionsForAppearance.d.ts +105 -0
- package/lib/indicator/defaultOptionsForAppearance.js +77 -0
- package/lib/indicator/defaultOptionsForAppearance.js.map +1 -0
- package/lib/indicator/elderImpulse.d.ts +7 -0
- package/lib/indicator/elderImpulse.js +61 -0
- package/lib/indicator/elderImpulse.js.map +1 -0
- package/lib/indicator/elderRay.d.ts +24 -0
- package/lib/indicator/elderRay.js +29 -0
- package/lib/indicator/elderRay.js.map +1 -0
- package/lib/indicator/ema.d.ts +24 -0
- package/lib/indicator/ema.js +29 -0
- package/lib/indicator/ema.js.map +1 -0
- package/lib/indicator/forceIndex.d.ts +24 -0
- package/lib/indicator/forceIndex.js +29 -0
- package/lib/indicator/forceIndex.js.map +1 -0
- package/lib/indicator/heikinAshi.d.ts +3 -0
- package/lib/indicator/heikinAshi.js +28 -0
- package/lib/indicator/heikinAshi.js.map +1 -0
- package/lib/indicator/index.d.ts +23 -0
- package/lib/indicator/index.js +24 -0
- package/lib/indicator/index.js.map +1 -0
- package/lib/indicator/kagi.d.ts +11 -0
- package/lib/indicator/kagi.js +13 -0
- package/lib/indicator/kagi.js.map +1 -0
- package/lib/indicator/macd.d.ts +24 -0
- package/lib/indicator/macd.js +32 -0
- package/lib/indicator/macd.js.map +1 -0
- package/lib/indicator/pointAndFigure.d.ts +10 -0
- package/lib/indicator/pointAndFigure.js +13 -0
- package/lib/indicator/pointAndFigure.js.map +1 -0
- package/lib/indicator/renko.d.ts +12 -0
- package/lib/indicator/renko.js +13 -0
- package/lib/indicator/renko.js.map +1 -0
- package/lib/indicator/rsi.d.ts +24 -0
- package/lib/indicator/rsi.js +29 -0
- package/lib/indicator/rsi.js.map +1 -0
- package/lib/indicator/sar.d.ts +24 -0
- package/lib/indicator/sar.js +29 -0
- package/lib/indicator/sar.js.map +1 -0
- package/lib/indicator/sma.d.ts +24 -0
- package/lib/indicator/sma.js +29 -0
- package/lib/indicator/sma.js.map +1 -0
- package/lib/indicator/stochasticOscillator.d.ts +24 -0
- package/lib/indicator/stochasticOscillator.js +27 -0
- package/lib/indicator/stochasticOscillator.js.map +1 -0
- package/lib/indicator/tma.d.ts +24 -0
- package/lib/indicator/tma.js +29 -0
- package/lib/indicator/tma.js.map +1 -0
- package/lib/indicator/wma.d.ts +24 -0
- package/lib/indicator/wma.js +29 -0
- package/lib/indicator/wma.js.map +1 -0
- package/lib/utils/functor.d.ts +1 -0
- package/lib/utils/functor.js +4 -0
- package/lib/utils/functor.js.map +1 -0
- package/lib/utils/identity.d.ts +1 -0
- package/lib/utils/identity.js +2 -0
- package/lib/utils/identity.js.map +1 -0
- package/lib/utils/index.d.ts +8 -0
- package/lib/utils/index.js +9 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/mappedSlidingWindow.d.ts +15 -0
- package/lib/utils/mappedSlidingWindow.js +77 -0
- package/lib/utils/mappedSlidingWindow.js.map +1 -0
- package/lib/utils/merge.d.ts +11 -0
- package/lib/utils/merge.js +70 -0
- package/lib/utils/merge.js.map +1 -0
- package/lib/utils/path.d.ts +1 -0
- package/lib/utils/path.js +15 -0
- package/lib/utils/path.js.map +1 -0
- package/lib/utils/rebind.d.ts +1 -0
- package/lib/utils/rebind.js +18 -0
- package/lib/utils/rebind.js.map +1 -0
- package/lib/utils/slidingWindow.d.ts +19 -0
- package/lib/utils/slidingWindow.js +111 -0
- package/lib/utils/slidingWindow.js.map +1 -0
- package/lib/utils/zipper.d.ts +7 -0
- package/lib/utils/zipper.js +36 -0
- package/lib/utils/zipper.js.map +1 -0
- package/package.json +49 -0
- package/src/calculator/atr.ts +88 -0
- package/src/calculator/bollingerband.ts +102 -0
- package/src/calculator/change.ts +53 -0
- package/src/calculator/compare.ts +68 -0
- package/src/calculator/defaultOptionsForComputation.ts +117 -0
- package/src/calculator/elderRay.ts +90 -0
- package/src/calculator/ema.ts +92 -0
- package/src/calculator/forceIndex.ts +43 -0
- package/src/calculator/heikinAshi.ts +38 -0
- package/src/calculator/index.ts +19 -0
- package/src/calculator/kagi.ts +249 -0
- package/src/calculator/macd.ts +90 -0
- package/src/calculator/pointAndFigure.ts +255 -0
- package/src/calculator/renko.ts +227 -0
- package/src/calculator/rsi.ts +114 -0
- package/src/calculator/sar.ts +117 -0
- package/src/calculator/sma.ts +41 -0
- package/src/calculator/smoothedForceIndex.ts +53 -0
- package/src/calculator/sto.ts +118 -0
- package/src/calculator/tma.ts +82 -0
- package/src/calculator/wma.ts +49 -0
- package/src/index.ts +1 -0
- package/src/indicator/algorithm.ts +53 -0
- package/src/indicator/atr.ts +58 -0
- package/src/indicator/baseIndicator.ts +97 -0
- package/src/indicator/bollingerBand.ts +55 -0
- package/src/indicator/change.ts +51 -0
- package/src/indicator/compare.ts +57 -0
- package/src/indicator/defaultOptionsForAppearance.ts +77 -0
- package/src/indicator/elderImpulse.ts +73 -0
- package/src/indicator/elderRay.ts +56 -0
- package/src/indicator/ema.ts +58 -0
- package/src/indicator/forceIndex.ts +57 -0
- package/src/indicator/heikinAshi.ts +35 -0
- package/src/indicator/index.ts +25 -0
- package/src/indicator/kagi.ts +18 -0
- package/src/indicator/macd.ts +60 -0
- package/src/indicator/pointAndFigure.ts +18 -0
- package/src/indicator/renko.ts +18 -0
- package/src/indicator/rsi.ts +58 -0
- package/src/indicator/sar.ts +56 -0
- package/src/indicator/sma.ts +57 -0
- package/src/indicator/stochasticOscillator.ts +56 -0
- package/src/indicator/tma.ts +57 -0
- package/src/indicator/wma.ts +58 -0
- package/src/utils/functor.ts +3 -0
- package/src/utils/identity.ts +1 -0
- package/src/utils/index.ts +8 -0
- package/src/utils/mappedSlidingWindow.ts +95 -0
- package/src/utils/merge.ts +93 -0
- package/src/utils/path.ts +16 -0
- package/src/utils/rebind.ts +19 -0
- package/src/utils/slidingWindow.ts +142 -0
- package/src/utils/zipper.ts +45 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { elderRay } from "../calculator";
|
|
2
|
+
import { merge, rebind } from "../utils";
|
|
3
|
+
import { ElderRayOptions } from "../calculator/elderRay";
|
|
4
|
+
import baseIndicator from "./baseIndicator";
|
|
5
|
+
|
|
6
|
+
const ALGORITHM_TYPE = "ElderRay";
|
|
7
|
+
|
|
8
|
+
interface ElderRayIndicator {
|
|
9
|
+
(data: any[], options?: { merge: boolean }): any;
|
|
10
|
+
id(): number;
|
|
11
|
+
id(x: number): ElderRayIndicator;
|
|
12
|
+
accessor(): any;
|
|
13
|
+
accessor(x: any): ElderRayIndicator;
|
|
14
|
+
stroke(): string | any;
|
|
15
|
+
stroke(x: string | any): ElderRayIndicator;
|
|
16
|
+
fill(): string | any;
|
|
17
|
+
fill(x: string | any): ElderRayIndicator;
|
|
18
|
+
echo(): any;
|
|
19
|
+
echo(x: any): ElderRayIndicator;
|
|
20
|
+
type(): string;
|
|
21
|
+
type(x: string): ElderRayIndicator;
|
|
22
|
+
merge(): any;
|
|
23
|
+
merge(newMerge: any): ElderRayIndicator;
|
|
24
|
+
options(): ElderRayOptions;
|
|
25
|
+
options(newOptions: ElderRayOptions): ElderRayIndicator;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default function () {
|
|
29
|
+
const base = baseIndicator()
|
|
30
|
+
.type(ALGORITHM_TYPE)
|
|
31
|
+
.accessor((d: any) => d.elderRay);
|
|
32
|
+
|
|
33
|
+
const underlyingAlgorithm = elderRay();
|
|
34
|
+
|
|
35
|
+
const mergedAlgorithm = merge()
|
|
36
|
+
.algorithm(underlyingAlgorithm)
|
|
37
|
+
.merge((datum: any, i: number) => {
|
|
38
|
+
datum.elderRay = i;
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const indicator = (data: any[], options = { merge: true }) => {
|
|
42
|
+
if (options.merge) {
|
|
43
|
+
if (!base.accessor()) {
|
|
44
|
+
throw new Error(`Set an accessor to ${ALGORITHM_TYPE} before calculating`);
|
|
45
|
+
}
|
|
46
|
+
return mergedAlgorithm(data);
|
|
47
|
+
}
|
|
48
|
+
return underlyingAlgorithm(data);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
rebind(indicator, base, "id", "accessor", "stroke", "fill", "echo", "type");
|
|
52
|
+
rebind(indicator, underlyingAlgorithm, "options");
|
|
53
|
+
rebind(indicator, mergedAlgorithm, "merge", "skipUndefined");
|
|
54
|
+
|
|
55
|
+
return indicator as ElderRayIndicator;
|
|
56
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { merge, rebind } from "../utils";
|
|
2
|
+
import { ema } from "../calculator";
|
|
3
|
+
import { EMAOptions } from "../calculator/ema";
|
|
4
|
+
import baseIndicator from "./baseIndicator";
|
|
5
|
+
|
|
6
|
+
const ALGORITHM_TYPE = "EMA";
|
|
7
|
+
|
|
8
|
+
interface EMAIndicator {
|
|
9
|
+
(data: any[], options?: { merge: boolean }): any;
|
|
10
|
+
id(): number;
|
|
11
|
+
id(x: number): EMAIndicator;
|
|
12
|
+
accessor(): any;
|
|
13
|
+
accessor(x: any): EMAIndicator;
|
|
14
|
+
stroke(): string | any;
|
|
15
|
+
stroke(x: string | any): EMAIndicator;
|
|
16
|
+
fill(): string | any;
|
|
17
|
+
fill(x: string | any): EMAIndicator;
|
|
18
|
+
echo(): any;
|
|
19
|
+
echo(x: any): EMAIndicator;
|
|
20
|
+
type(): string;
|
|
21
|
+
type(x: string): EMAIndicator;
|
|
22
|
+
merge(): any;
|
|
23
|
+
merge(newMerge: any): EMAIndicator;
|
|
24
|
+
options(): EMAOptions;
|
|
25
|
+
options(newOptions: EMAOptions): EMAIndicator;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default function () {
|
|
29
|
+
const base = baseIndicator()
|
|
30
|
+
.type(ALGORITHM_TYPE)
|
|
31
|
+
.accessor((d: any) => d.ema);
|
|
32
|
+
|
|
33
|
+
const underlyingAlgorithm = ema();
|
|
34
|
+
|
|
35
|
+
const mergedAlgorithm = merge()
|
|
36
|
+
.algorithm(underlyingAlgorithm)
|
|
37
|
+
.merge((datum: any, i: number) => {
|
|
38
|
+
datum.ema = i;
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const indicator = (data: any[], options = { merge: true }) => {
|
|
42
|
+
if (options.merge) {
|
|
43
|
+
if (!base.accessor()) {
|
|
44
|
+
throw new Error(`Set an accessor to ${ALGORITHM_TYPE} before calculating`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return mergedAlgorithm(data);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return underlyingAlgorithm(data);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
rebind(indicator, base, "id", "accessor", "stroke", "fill", "echo", "type");
|
|
54
|
+
rebind(indicator, underlyingAlgorithm, "options", "undefinedLength");
|
|
55
|
+
rebind(indicator, mergedAlgorithm, "merge", "skipUndefined");
|
|
56
|
+
|
|
57
|
+
return indicator as EMAIndicator;
|
|
58
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { merge, rebind } from "../utils";
|
|
2
|
+
import { forceIndex } from "../calculator";
|
|
3
|
+
import { ForceIndexOptions } from "../calculator/forceIndex";
|
|
4
|
+
import baseIndicator from "./baseIndicator";
|
|
5
|
+
|
|
6
|
+
const ALGORITHM_TYPE = "ForceIndex";
|
|
7
|
+
|
|
8
|
+
interface ForceIndexIndicator {
|
|
9
|
+
(data: any[], options?: { merge: boolean }): any;
|
|
10
|
+
id(): number;
|
|
11
|
+
id(x: number): ForceIndexIndicator;
|
|
12
|
+
accessor(): any;
|
|
13
|
+
accessor(x: any): ForceIndexIndicator;
|
|
14
|
+
stroke(): string | any;
|
|
15
|
+
stroke(x: string | any): ForceIndexIndicator;
|
|
16
|
+
fill(): string | any;
|
|
17
|
+
fill(x: string | any): ForceIndexIndicator;
|
|
18
|
+
echo(): any;
|
|
19
|
+
echo(x: any): ForceIndexIndicator;
|
|
20
|
+
type(): string;
|
|
21
|
+
type(x: string): ForceIndexIndicator;
|
|
22
|
+
merge(): any;
|
|
23
|
+
merge(newMerge: any): ForceIndexIndicator;
|
|
24
|
+
options(): ForceIndexOptions;
|
|
25
|
+
options(newOptions: ForceIndexOptions): ForceIndexIndicator;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default function () {
|
|
29
|
+
const base = baseIndicator()
|
|
30
|
+
.type(ALGORITHM_TYPE)
|
|
31
|
+
.accessor((d: any) => d.forceIndex);
|
|
32
|
+
|
|
33
|
+
const underlyingAlgorithm = forceIndex();
|
|
34
|
+
|
|
35
|
+
const mergedAlgorithm = merge()
|
|
36
|
+
.algorithm(underlyingAlgorithm)
|
|
37
|
+
.merge((datum: any, i: number) => {
|
|
38
|
+
datum.forceIndex = i;
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const indicator = (data: any[], options = { merge: true }) => {
|
|
42
|
+
if (options.merge) {
|
|
43
|
+
if (!base.accessor()) {
|
|
44
|
+
throw new Error(`Set an accessor to ${ALGORITHM_TYPE} before calculating`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return mergedAlgorithm(data);
|
|
48
|
+
}
|
|
49
|
+
return underlyingAlgorithm(data);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
rebind(indicator, base, "id", "accessor", "stroke", "fill", "echo", "type");
|
|
53
|
+
rebind(indicator, underlyingAlgorithm, "options");
|
|
54
|
+
rebind(indicator, mergedAlgorithm, "merge", "skipUndefined");
|
|
55
|
+
|
|
56
|
+
return indicator as ForceIndexIndicator;
|
|
57
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { heikinAshi } from "../calculator";
|
|
2
|
+
import baseIndicator from "./baseIndicator";
|
|
3
|
+
import { merge, rebind } from "../utils";
|
|
4
|
+
|
|
5
|
+
const ALGORITHM_TYPE = "HeikinAshi";
|
|
6
|
+
|
|
7
|
+
export default function () {
|
|
8
|
+
const base = baseIndicator()
|
|
9
|
+
.type(ALGORITHM_TYPE)
|
|
10
|
+
.accessor((d: any) => d.ha);
|
|
11
|
+
|
|
12
|
+
const underlyingAlgorithm = heikinAshi();
|
|
13
|
+
|
|
14
|
+
const mergedAlgorithm = merge()
|
|
15
|
+
.algorithm(underlyingAlgorithm)
|
|
16
|
+
.merge((datum: any, i: any) => {
|
|
17
|
+
return { ...datum, ...i };
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const indicator = (data: any[], options = { merge: true }) => {
|
|
21
|
+
if (options.merge) {
|
|
22
|
+
if (!base.accessor()) {
|
|
23
|
+
throw new Error(`Set an accessor to ${ALGORITHM_TYPE} before calculating`);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return mergedAlgorithm(data);
|
|
27
|
+
}
|
|
28
|
+
return underlyingAlgorithm(data);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
rebind(indicator, base, "accessor", "stroke", "fill", "echo", "type");
|
|
32
|
+
rebind(indicator, mergedAlgorithm, "merge");
|
|
33
|
+
|
|
34
|
+
return indicator;
|
|
35
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export { default as algo } from "./algorithm";
|
|
2
|
+
export { default as ema } from "./ema";
|
|
3
|
+
export { default as sma } from "./sma";
|
|
4
|
+
export { default as wma } from "./wma";
|
|
5
|
+
export { default as tma } from "./tma";
|
|
6
|
+
export { default as bollingerBand } from "./bollingerBand";
|
|
7
|
+
export { default as heikinAshi } from "./heikinAshi";
|
|
8
|
+
export { default as kagi } from "./kagi";
|
|
9
|
+
export { default as pointAndFigure } from "./pointAndFigure";
|
|
10
|
+
export { default as renko } from "./renko";
|
|
11
|
+
export { default as macd } from "./macd";
|
|
12
|
+
export { default as rsi } from "./rsi";
|
|
13
|
+
export { default as atr } from "./atr";
|
|
14
|
+
export { default as stochasticOscillator } from "./stochasticOscillator";
|
|
15
|
+
export { default as forceIndex } from "./forceIndex";
|
|
16
|
+
export { default as sar } from "./sar";
|
|
17
|
+
export { default as elderRay } from "./elderRay";
|
|
18
|
+
export { default as change } from "./change";
|
|
19
|
+
export { default as elderImpulse } from "./elderImpulse";
|
|
20
|
+
export { default as compare } from "./compare";
|
|
21
|
+
|
|
22
|
+
import * as defaultOptionsForComputation from "../calculator/defaultOptionsForComputation";
|
|
23
|
+
import * as defaultOptionsForAppearance from "./defaultOptionsForAppearance";
|
|
24
|
+
|
|
25
|
+
export { defaultOptionsForComputation, defaultOptionsForAppearance };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { rebind } from "../utils";
|
|
2
|
+
import { kagi } from "../calculator";
|
|
3
|
+
import baseIndicator from "./baseIndicator";
|
|
4
|
+
|
|
5
|
+
const ALGORITHM_TYPE = "Kagi";
|
|
6
|
+
|
|
7
|
+
export default function () {
|
|
8
|
+
const base = baseIndicator().type(ALGORITHM_TYPE);
|
|
9
|
+
|
|
10
|
+
const underlyingAlgorithm = kagi();
|
|
11
|
+
|
|
12
|
+
const indicator = underlyingAlgorithm;
|
|
13
|
+
|
|
14
|
+
rebind(indicator, base, "id", "stroke", "fill", "echo", "type");
|
|
15
|
+
rebind(indicator, underlyingAlgorithm, "dateAccessor", "dateMutator", "options");
|
|
16
|
+
|
|
17
|
+
return indicator;
|
|
18
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { merge, rebind } from "../utils";
|
|
2
|
+
import { macd } from "../calculator";
|
|
3
|
+
import { MACDOptions } from "../calculator/macd";
|
|
4
|
+
import baseIndicator from "./baseIndicator";
|
|
5
|
+
import { MACD as appearanceOptions } from "./defaultOptionsForAppearance";
|
|
6
|
+
|
|
7
|
+
const ALGORITHM_TYPE = "MACD";
|
|
8
|
+
|
|
9
|
+
interface MACDIndicator {
|
|
10
|
+
(data: any[], options?: { merge: boolean }): any;
|
|
11
|
+
id(): number;
|
|
12
|
+
id(x: number): MACDIndicator;
|
|
13
|
+
accessor(): any;
|
|
14
|
+
accessor(x: any): MACDIndicator;
|
|
15
|
+
stroke(): string | any;
|
|
16
|
+
stroke(x: string | any): MACDIndicator;
|
|
17
|
+
fill(): string | any;
|
|
18
|
+
fill(x: string | any): MACDIndicator;
|
|
19
|
+
echo(): any;
|
|
20
|
+
echo(x: any): MACDIndicator;
|
|
21
|
+
type(): string;
|
|
22
|
+
type(x: string): MACDIndicator;
|
|
23
|
+
merge(): any;
|
|
24
|
+
merge(newMerge: any): MACDIndicator;
|
|
25
|
+
options(): MACDOptions;
|
|
26
|
+
options(newOptions: MACDOptions): MACDIndicator;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default function () {
|
|
30
|
+
const base = baseIndicator()
|
|
31
|
+
.type(ALGORITHM_TYPE)
|
|
32
|
+
.fill(appearanceOptions.fill)
|
|
33
|
+
.stroke(appearanceOptions.stroke)
|
|
34
|
+
.accessor((d: any) => d.macd);
|
|
35
|
+
|
|
36
|
+
const underlyingAlgorithm = macd();
|
|
37
|
+
|
|
38
|
+
const mergedAlgorithm = merge()
|
|
39
|
+
.algorithm(underlyingAlgorithm)
|
|
40
|
+
.merge((datum: any, i: number) => {
|
|
41
|
+
datum.macd = i;
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const indicator = (data: any[], options = { merge: true }) => {
|
|
45
|
+
if (options.merge) {
|
|
46
|
+
if (!base.accessor()) {
|
|
47
|
+
throw new Error(`Set an accessor to ${ALGORITHM_TYPE} before calculating`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return mergedAlgorithm(data);
|
|
51
|
+
}
|
|
52
|
+
return underlyingAlgorithm(data);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
rebind(indicator, base, "id", "accessor", "stroke", "fill", "echo", "type");
|
|
56
|
+
rebind(indicator, underlyingAlgorithm, "options", "undefinedLength");
|
|
57
|
+
rebind(indicator, mergedAlgorithm, "merge", "skipUndefined");
|
|
58
|
+
|
|
59
|
+
return indicator as MACDIndicator;
|
|
60
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { rebind } from "../utils";
|
|
2
|
+
import { pointAndFigure } from "../calculator";
|
|
3
|
+
import baseIndicator from "./baseIndicator";
|
|
4
|
+
|
|
5
|
+
const ALGORITHM_TYPE = "PointAndFigure";
|
|
6
|
+
|
|
7
|
+
export default function () {
|
|
8
|
+
const base = baseIndicator().type(ALGORITHM_TYPE);
|
|
9
|
+
|
|
10
|
+
const underlyingAlgorithm = pointAndFigure();
|
|
11
|
+
|
|
12
|
+
const indicator = underlyingAlgorithm;
|
|
13
|
+
|
|
14
|
+
rebind(indicator, base, "id", "stroke", "fill", "echo", "type");
|
|
15
|
+
rebind(indicator, underlyingAlgorithm, "dateAccessor", "dateMutator", "options");
|
|
16
|
+
|
|
17
|
+
return indicator;
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { rebind } from "../utils";
|
|
2
|
+
import { renko } from "../calculator";
|
|
3
|
+
import baseIndicator from "./baseIndicator";
|
|
4
|
+
|
|
5
|
+
const ALGORITHM_TYPE = "Renko";
|
|
6
|
+
|
|
7
|
+
export default function () {
|
|
8
|
+
const base = baseIndicator().type(ALGORITHM_TYPE);
|
|
9
|
+
|
|
10
|
+
const underlyingAlgorithm = renko();
|
|
11
|
+
|
|
12
|
+
const indicator = underlyingAlgorithm;
|
|
13
|
+
|
|
14
|
+
rebind(indicator, base, "id", "stroke", "fill", "echo", "type");
|
|
15
|
+
rebind(indicator, underlyingAlgorithm, "options", "dateAccessor", "dateMutator");
|
|
16
|
+
|
|
17
|
+
return indicator;
|
|
18
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { merge, rebind } from "../utils";
|
|
2
|
+
import { rsi } from "../calculator";
|
|
3
|
+
import { RSIOptions } from "../calculator/rsi";
|
|
4
|
+
import baseIndicator from "./baseIndicator";
|
|
5
|
+
|
|
6
|
+
const ALGORITHM_TYPE = "RSI";
|
|
7
|
+
|
|
8
|
+
interface RSIIndicator {
|
|
9
|
+
(data: any[], options?: { merge: boolean }): any;
|
|
10
|
+
id(): number;
|
|
11
|
+
id(x: number): RSIIndicator;
|
|
12
|
+
accessor(): any;
|
|
13
|
+
accessor(x: any): RSIIndicator;
|
|
14
|
+
stroke(): string | any;
|
|
15
|
+
stroke(x: string | any): RSIIndicator;
|
|
16
|
+
fill(): string | any;
|
|
17
|
+
fill(x: string | any): RSIIndicator;
|
|
18
|
+
echo(): any;
|
|
19
|
+
echo(x: any): RSIIndicator;
|
|
20
|
+
type(): string;
|
|
21
|
+
type(x: string): RSIIndicator;
|
|
22
|
+
merge(): any;
|
|
23
|
+
merge(newMerge: any): RSIIndicator;
|
|
24
|
+
options(): RSIOptions;
|
|
25
|
+
options(newOptions: RSIOptions): RSIIndicator;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default function () {
|
|
29
|
+
const base = baseIndicator()
|
|
30
|
+
.type(ALGORITHM_TYPE)
|
|
31
|
+
.accessor((d: any) => d.rsi);
|
|
32
|
+
|
|
33
|
+
const underlyingAlgorithm = rsi();
|
|
34
|
+
|
|
35
|
+
const mergedAlgorithm = merge()
|
|
36
|
+
.algorithm(underlyingAlgorithm)
|
|
37
|
+
.merge((datum: any, i: number) => {
|
|
38
|
+
datum.rsi = i;
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const indicator = (data: any[], options = { merge: true }) => {
|
|
42
|
+
if (options.merge) {
|
|
43
|
+
if (!base.accessor()) {
|
|
44
|
+
throw new Error(`Set an accessor to ${ALGORITHM_TYPE} before calculating`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return mergedAlgorithm(data);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return underlyingAlgorithm(data);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
rebind(indicator, base, "id", "accessor", "stroke", "fill", "echo", "type");
|
|
54
|
+
rebind(indicator, underlyingAlgorithm, "options", "undefinedLength");
|
|
55
|
+
rebind(indicator, mergedAlgorithm, "merge", "skipUndefined");
|
|
56
|
+
|
|
57
|
+
return indicator as RSIIndicator;
|
|
58
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { merge, rebind } from "../utils";
|
|
2
|
+
import { sar } from "../calculator";
|
|
3
|
+
import { SAROptions } from "../calculator/sar";
|
|
4
|
+
import baseIndicator from "./baseIndicator";
|
|
5
|
+
|
|
6
|
+
const ALGORITHM_TYPE = "SMA";
|
|
7
|
+
|
|
8
|
+
interface SARIndicator {
|
|
9
|
+
(data: any[], options?: { merge: boolean }): any;
|
|
10
|
+
id(): number;
|
|
11
|
+
id(x: number): SARIndicator;
|
|
12
|
+
accessor(): any;
|
|
13
|
+
accessor(x: any): SARIndicator;
|
|
14
|
+
stroke(): string | any;
|
|
15
|
+
stroke(x: string | any): SARIndicator;
|
|
16
|
+
fill(): string | any;
|
|
17
|
+
fill(x: string | any): SARIndicator;
|
|
18
|
+
echo(): any;
|
|
19
|
+
echo(x: any): SARIndicator;
|
|
20
|
+
type(): string;
|
|
21
|
+
type(x: string): SARIndicator;
|
|
22
|
+
merge(): any;
|
|
23
|
+
merge(newMerge: any): SARIndicator;
|
|
24
|
+
options(): SAROptions;
|
|
25
|
+
options(newOptions: SAROptions): SARIndicator;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default function () {
|
|
29
|
+
const base = baseIndicator()
|
|
30
|
+
.type(ALGORITHM_TYPE)
|
|
31
|
+
.accessor((d: any) => d.sar);
|
|
32
|
+
|
|
33
|
+
const underlyingAlgorithm = sar();
|
|
34
|
+
|
|
35
|
+
const mergedAlgorithm = merge()
|
|
36
|
+
.algorithm(underlyingAlgorithm)
|
|
37
|
+
.merge((datum: any, i: number) => {
|
|
38
|
+
datum.sar = i;
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const indicator = (data: any[], options = { merge: true }) => {
|
|
42
|
+
if (options.merge) {
|
|
43
|
+
if (!base.accessor()) {
|
|
44
|
+
throw new Error(`Set an accessor to ${ALGORITHM_TYPE} before calculating`);
|
|
45
|
+
}
|
|
46
|
+
return mergedAlgorithm(data);
|
|
47
|
+
}
|
|
48
|
+
return underlyingAlgorithm(data);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
rebind(indicator, base, "id", "accessor", "stroke", "echo", "type");
|
|
52
|
+
rebind(indicator, underlyingAlgorithm, "options", "undefinedLength");
|
|
53
|
+
rebind(indicator, mergedAlgorithm, "merge");
|
|
54
|
+
|
|
55
|
+
return indicator as SARIndicator;
|
|
56
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { merge, rebind } from "../utils";
|
|
2
|
+
import { sma } from "../calculator";
|
|
3
|
+
import { SMAOptions } from "../calculator/sma";
|
|
4
|
+
import baseIndicator from "./baseIndicator";
|
|
5
|
+
|
|
6
|
+
const ALGORITHM_TYPE = "SMA";
|
|
7
|
+
|
|
8
|
+
interface SMAIndicator {
|
|
9
|
+
(data: any[], options?: { merge: boolean }): any;
|
|
10
|
+
id(): number;
|
|
11
|
+
id(x: number): SMAIndicator;
|
|
12
|
+
accessor(): any;
|
|
13
|
+
accessor(x: any): SMAIndicator;
|
|
14
|
+
stroke(): string | any;
|
|
15
|
+
stroke(x: string | any): SMAIndicator;
|
|
16
|
+
fill(): string | any;
|
|
17
|
+
fill(x: string | any): SMAIndicator;
|
|
18
|
+
echo(): any;
|
|
19
|
+
echo(x: any): SMAIndicator;
|
|
20
|
+
type(): string;
|
|
21
|
+
type(x: string): SMAIndicator;
|
|
22
|
+
merge(): any;
|
|
23
|
+
merge(newMerge: any): SMAIndicator;
|
|
24
|
+
options(): SMAOptions;
|
|
25
|
+
options(newOptions: SMAOptions): SMAIndicator;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default function () {
|
|
29
|
+
const base = baseIndicator()
|
|
30
|
+
.type(ALGORITHM_TYPE)
|
|
31
|
+
.accessor((d: any) => d.sma);
|
|
32
|
+
|
|
33
|
+
const underlyingAlgorithm = sma();
|
|
34
|
+
|
|
35
|
+
const mergedAlgorithm = merge()
|
|
36
|
+
.algorithm(underlyingAlgorithm)
|
|
37
|
+
.merge((datum: any, i: number) => {
|
|
38
|
+
datum.sma = i;
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const indicator = (data: any[], options = { merge: true }) => {
|
|
42
|
+
if (options.merge) {
|
|
43
|
+
if (!base.accessor()) {
|
|
44
|
+
throw new Error(`Set an accessor to ${ALGORITHM_TYPE} before calculating`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return mergedAlgorithm(data);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return underlyingAlgorithm(data);
|
|
51
|
+
};
|
|
52
|
+
rebind(indicator, base, "id", "accessor", "stroke", "fill", "echo", "type");
|
|
53
|
+
rebind(indicator, underlyingAlgorithm, "options", "undefinedLength");
|
|
54
|
+
rebind(indicator, mergedAlgorithm, "merge", "skipUndefined");
|
|
55
|
+
|
|
56
|
+
return indicator as SMAIndicator;
|
|
57
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { merge, rebind } from "../utils";
|
|
2
|
+
import { sto } from "../calculator";
|
|
3
|
+
import { STOOptions } from "../calculator/sto";
|
|
4
|
+
import baseIndicator from "./baseIndicator";
|
|
5
|
+
|
|
6
|
+
const ALGORITHM_TYPE = "STO";
|
|
7
|
+
|
|
8
|
+
interface StochasticOscillatorIndicator {
|
|
9
|
+
(data: any[], options?: { merge: boolean }): any;
|
|
10
|
+
id(): number;
|
|
11
|
+
id(x: number): StochasticOscillatorIndicator;
|
|
12
|
+
accessor(): any;
|
|
13
|
+
accessor(x: any): StochasticOscillatorIndicator;
|
|
14
|
+
stroke(): string | any;
|
|
15
|
+
stroke(x: string | any): StochasticOscillatorIndicator;
|
|
16
|
+
fill(): string | any;
|
|
17
|
+
fill(x: string | any): StochasticOscillatorIndicator;
|
|
18
|
+
echo(): any;
|
|
19
|
+
echo(x: any): StochasticOscillatorIndicator;
|
|
20
|
+
type(): string;
|
|
21
|
+
type(x: string): StochasticOscillatorIndicator;
|
|
22
|
+
merge(): any;
|
|
23
|
+
merge(newMerge: any): StochasticOscillatorIndicator;
|
|
24
|
+
options(): STOOptions;
|
|
25
|
+
options(newOptions: STOOptions): StochasticOscillatorIndicator;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default function () {
|
|
29
|
+
const base = baseIndicator().type(ALGORITHM_TYPE);
|
|
30
|
+
|
|
31
|
+
const underlyingAlgorithm = sto();
|
|
32
|
+
|
|
33
|
+
const mergedAlgorithm = merge()
|
|
34
|
+
.algorithm(underlyingAlgorithm)
|
|
35
|
+
.merge((datum: any, i: number) => {
|
|
36
|
+
datum.sto = i;
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const indicator = (data: any[], options = { merge: true }) => {
|
|
40
|
+
if (options.merge) {
|
|
41
|
+
if (!base.accessor()) {
|
|
42
|
+
throw new Error(`Set an accessor to ${ALGORITHM_TYPE} before calculating`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return mergedAlgorithm(data);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return underlyingAlgorithm(data);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
rebind(indicator, base, "id", "accessor", "stroke", "fill", "echo", "type");
|
|
52
|
+
rebind(indicator, underlyingAlgorithm, "options", "undefinedLength");
|
|
53
|
+
rebind(indicator, mergedAlgorithm, "merge", "skipUndefined");
|
|
54
|
+
|
|
55
|
+
return indicator as StochasticOscillatorIndicator;
|
|
56
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { merge, rebind } from "../utils";
|
|
2
|
+
import { tma } from "../calculator";
|
|
3
|
+
import { TMAOptions } from "../calculator/tma";
|
|
4
|
+
import baseIndicator from "./baseIndicator";
|
|
5
|
+
|
|
6
|
+
const ALGORITHM_TYPE = "TMA";
|
|
7
|
+
|
|
8
|
+
interface TMAIndicator {
|
|
9
|
+
(data: any[], options?: { merge: boolean }): any;
|
|
10
|
+
id(): number;
|
|
11
|
+
id(x: number): TMAIndicator;
|
|
12
|
+
accessor(): any;
|
|
13
|
+
accessor(x: any): TMAIndicator;
|
|
14
|
+
stroke(): string | any;
|
|
15
|
+
stroke(x: string | any): TMAIndicator;
|
|
16
|
+
fill(): string | any;
|
|
17
|
+
fill(x: string | any): TMAIndicator;
|
|
18
|
+
echo(): any;
|
|
19
|
+
echo(x: any): TMAIndicator;
|
|
20
|
+
type(): string;
|
|
21
|
+
type(x: string): TMAIndicator;
|
|
22
|
+
merge(): any;
|
|
23
|
+
merge(newMerge: any): TMAIndicator;
|
|
24
|
+
options(): TMAOptions;
|
|
25
|
+
options(newOptions: TMAOptions): TMAIndicator;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default function () {
|
|
29
|
+
const base = baseIndicator()
|
|
30
|
+
.type(ALGORITHM_TYPE)
|
|
31
|
+
.accessor((d: any) => d.tma);
|
|
32
|
+
|
|
33
|
+
const underlyingAlgorithm = tma();
|
|
34
|
+
|
|
35
|
+
const mergedAlgorithm = merge()
|
|
36
|
+
.algorithm(underlyingAlgorithm)
|
|
37
|
+
.merge((datum: any, i: number) => {
|
|
38
|
+
datum.tma = i;
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const indicator = (data: any[], options = { merge: true }) => {
|
|
42
|
+
if (options.merge) {
|
|
43
|
+
if (!base.accessor()) {
|
|
44
|
+
throw new Error(`Set an accessor to ${ALGORITHM_TYPE} before calculating`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return mergedAlgorithm(data);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return underlyingAlgorithm(data);
|
|
51
|
+
};
|
|
52
|
+
rebind(indicator, base, "id", "accessor", "stroke", "fill", "echo", "type");
|
|
53
|
+
rebind(indicator, underlyingAlgorithm, "options", "undefinedLength");
|
|
54
|
+
rebind(indicator, mergedAlgorithm, "merge", "skipUndefined");
|
|
55
|
+
|
|
56
|
+
return indicator as TMAIndicator;
|
|
57
|
+
}
|