@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 @@
|
|
|
1
|
+
{"version":3,"file":"kagi.js","sourceRoot":"","sources":["../../src/indicator/kagi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C,MAAM,cAAc,GAAG,MAAM,CAAC;AAE9B,MAAM,CAAC,OAAO;IACV,MAAM,IAAI,GAAG,aAAa,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAElD,MAAM,mBAAmB,GAAG,IAAI,EAAE,CAAC;IAEnC,MAAM,SAAS,GAAG,mBAAmB,CAAC;IAEtC,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAChE,MAAM,CAAC,SAAS,EAAE,mBAAmB,EAAE,cAAc,EAAE,aAAa,EAAE,SAAS,CAAC,CAAC;IAEjF,OAAO,SAAS,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { MACDOptions } from "../calculator/macd";
|
|
2
|
+
interface MACDIndicator {
|
|
3
|
+
(data: any[], options?: {
|
|
4
|
+
merge: boolean;
|
|
5
|
+
}): any;
|
|
6
|
+
id(): number;
|
|
7
|
+
id(x: number): MACDIndicator;
|
|
8
|
+
accessor(): any;
|
|
9
|
+
accessor(x: any): MACDIndicator;
|
|
10
|
+
stroke(): string | any;
|
|
11
|
+
stroke(x: string | any): MACDIndicator;
|
|
12
|
+
fill(): string | any;
|
|
13
|
+
fill(x: string | any): MACDIndicator;
|
|
14
|
+
echo(): any;
|
|
15
|
+
echo(x: any): MACDIndicator;
|
|
16
|
+
type(): string;
|
|
17
|
+
type(x: string): MACDIndicator;
|
|
18
|
+
merge(): any;
|
|
19
|
+
merge(newMerge: any): MACDIndicator;
|
|
20
|
+
options(): MACDOptions;
|
|
21
|
+
options(newOptions: MACDOptions): MACDIndicator;
|
|
22
|
+
}
|
|
23
|
+
export default function (): MACDIndicator;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { merge, rebind } from "../utils";
|
|
2
|
+
import { macd } from "../calculator";
|
|
3
|
+
import baseIndicator from "./baseIndicator";
|
|
4
|
+
import { MACD as appearanceOptions } from "./defaultOptionsForAppearance";
|
|
5
|
+
const ALGORITHM_TYPE = "MACD";
|
|
6
|
+
export default function () {
|
|
7
|
+
const base = baseIndicator()
|
|
8
|
+
.type(ALGORITHM_TYPE)
|
|
9
|
+
.fill(appearanceOptions.fill)
|
|
10
|
+
.stroke(appearanceOptions.stroke)
|
|
11
|
+
.accessor((d) => d.macd);
|
|
12
|
+
const underlyingAlgorithm = macd();
|
|
13
|
+
const mergedAlgorithm = merge()
|
|
14
|
+
.algorithm(underlyingAlgorithm)
|
|
15
|
+
.merge((datum, i) => {
|
|
16
|
+
datum.macd = i;
|
|
17
|
+
});
|
|
18
|
+
const indicator = (data, options = { merge: true }) => {
|
|
19
|
+
if (options.merge) {
|
|
20
|
+
if (!base.accessor()) {
|
|
21
|
+
throw new Error(`Set an accessor to ${ALGORITHM_TYPE} before calculating`);
|
|
22
|
+
}
|
|
23
|
+
return mergedAlgorithm(data);
|
|
24
|
+
}
|
|
25
|
+
return underlyingAlgorithm(data);
|
|
26
|
+
};
|
|
27
|
+
rebind(indicator, base, "id", "accessor", "stroke", "fill", "echo", "type");
|
|
28
|
+
rebind(indicator, underlyingAlgorithm, "options", "undefinedLength");
|
|
29
|
+
rebind(indicator, mergedAlgorithm, "merge", "skipUndefined");
|
|
30
|
+
return indicator;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=macd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"macd.js","sourceRoot":"","sources":["../../src/indicator/macd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AA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C;IAE7D,OAAO,SAA0B,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export default function (): {
|
|
2
|
+
(rawData: any[]): any[];
|
|
3
|
+
options(newOptions?: any): {
|
|
4
|
+
boxSize: number;
|
|
5
|
+
reversal: number;
|
|
6
|
+
sourcePath: string;
|
|
7
|
+
} | any;
|
|
8
|
+
dateMutator(newDateMutator?: any): ((d: any, date: any) => void) | any;
|
|
9
|
+
dateAccessor(newDateAccessor?: any): ((d: any) => any) | any;
|
|
10
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { rebind } from "../utils";
|
|
2
|
+
import { pointAndFigure } from "../calculator";
|
|
3
|
+
import baseIndicator from "./baseIndicator";
|
|
4
|
+
const ALGORITHM_TYPE = "PointAndFigure";
|
|
5
|
+
export default function () {
|
|
6
|
+
const base = baseIndicator().type(ALGORITHM_TYPE);
|
|
7
|
+
const underlyingAlgorithm = pointAndFigure();
|
|
8
|
+
const indicator = underlyingAlgorithm;
|
|
9
|
+
rebind(indicator, base, "id", "stroke", "fill", "echo", "type");
|
|
10
|
+
rebind(indicator, underlyingAlgorithm, "dateAccessor", "dateMutator", "options");
|
|
11
|
+
return indicator;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=pointAndFigure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pointAndFigure.js","sourceRoot":"","sources":["../../src/indicator/pointAndFigure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAExC,MAAM,CAAC,OAAO;IACV,MAAM,IAAI,GAAG,aAAa,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAElD,MAAM,mBAAmB,GAAG,cAAc,EAAE,CAAC;IAE7C,MAAM,SAAS,GAAG,mBAAmB,CAAC;IAEtC,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAChE,MAAM,CAAC,SAAS,EAAE,mBAAmB,EAAE,cAAc,EAAE,aAAa,EAAE,SAAS,CAAC,CAAC;IAEjF,OAAO,SAAS,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default function (): {
|
|
2
|
+
(rawData: any[]): any[];
|
|
3
|
+
options(newOptions?: any): {
|
|
4
|
+
reversalType: string;
|
|
5
|
+
windowSize: number;
|
|
6
|
+
fixedBrickSize: number;
|
|
7
|
+
sourcePath: string;
|
|
8
|
+
percentage: number;
|
|
9
|
+
} | any;
|
|
10
|
+
dateMutator(newDateMutator?: any): ((d: any, date: any) => void) | any;
|
|
11
|
+
dateAccessor(newDateAccessor?: any): ((d: any) => any) | any;
|
|
12
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { rebind } from "../utils";
|
|
2
|
+
import { renko } from "../calculator";
|
|
3
|
+
import baseIndicator from "./baseIndicator";
|
|
4
|
+
const ALGORITHM_TYPE = "Renko";
|
|
5
|
+
export default function () {
|
|
6
|
+
const base = baseIndicator().type(ALGORITHM_TYPE);
|
|
7
|
+
const underlyingAlgorithm = renko();
|
|
8
|
+
const indicator = underlyingAlgorithm;
|
|
9
|
+
rebind(indicator, base, "id", "stroke", "fill", "echo", "type");
|
|
10
|
+
rebind(indicator, underlyingAlgorithm, "options", "dateAccessor", "dateMutator");
|
|
11
|
+
return indicator;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=renko.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renko.js","sourceRoot":"","sources":["../../src/indicator/renko.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C,MAAM,cAAc,GAAG,OAAO,CAAC;AAE/B,MAAM,CAAC,OAAO;IACV,MAAM,IAAI,GAAG,aAAa,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAElD,MAAM,mBAAmB,GAAG,KAAK,EAAE,CAAC;IAEpC,MAAM,SAAS,GAAG,mBAAmB,CAAC;IAEtC,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAChE,MAAM,CAAC,SAAS,EAAE,mBAAmB,EAAE,SAAS,EAAE,cAAc,EAAE,aAAa,CAAC,CAAC;IAEjF,OAAO,SAAS,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RSIOptions } from "../calculator/rsi";
|
|
2
|
+
interface RSIIndicator {
|
|
3
|
+
(data: any[], options?: {
|
|
4
|
+
merge: boolean;
|
|
5
|
+
}): any;
|
|
6
|
+
id(): number;
|
|
7
|
+
id(x: number): RSIIndicator;
|
|
8
|
+
accessor(): any;
|
|
9
|
+
accessor(x: any): RSIIndicator;
|
|
10
|
+
stroke(): string | any;
|
|
11
|
+
stroke(x: string | any): RSIIndicator;
|
|
12
|
+
fill(): string | any;
|
|
13
|
+
fill(x: string | any): RSIIndicator;
|
|
14
|
+
echo(): any;
|
|
15
|
+
echo(x: any): RSIIndicator;
|
|
16
|
+
type(): string;
|
|
17
|
+
type(x: string): RSIIndicator;
|
|
18
|
+
merge(): any;
|
|
19
|
+
merge(newMerge: any): RSIIndicator;
|
|
20
|
+
options(): RSIOptions;
|
|
21
|
+
options(newOptions: RSIOptions): RSIIndicator;
|
|
22
|
+
}
|
|
23
|
+
export default function (): RSIIndicator;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { merge, rebind } from "../utils";
|
|
2
|
+
import { rsi } from "../calculator";
|
|
3
|
+
import baseIndicator from "./baseIndicator";
|
|
4
|
+
const ALGORITHM_TYPE = "RSI";
|
|
5
|
+
export default function () {
|
|
6
|
+
const base = baseIndicator()
|
|
7
|
+
.type(ALGORITHM_TYPE)
|
|
8
|
+
.accessor((d) => d.rsi);
|
|
9
|
+
const underlyingAlgorithm = rsi();
|
|
10
|
+
const mergedAlgorithm = merge()
|
|
11
|
+
.algorithm(underlyingAlgorithm)
|
|
12
|
+
.merge((datum, i) => {
|
|
13
|
+
datum.rsi = i;
|
|
14
|
+
});
|
|
15
|
+
const indicator = (data, options = { merge: true }) => {
|
|
16
|
+
if (options.merge) {
|
|
17
|
+
if (!base.accessor()) {
|
|
18
|
+
throw new Error(`Set an accessor to ${ALGORITHM_TYPE} before calculating`);
|
|
19
|
+
}
|
|
20
|
+
return mergedAlgorithm(data);
|
|
21
|
+
}
|
|
22
|
+
return underlyingAlgorithm(data);
|
|
23
|
+
};
|
|
24
|
+
rebind(indicator, base, "id", "accessor", "stroke", "fill", "echo", "type");
|
|
25
|
+
rebind(indicator, underlyingAlgorithm, "options", "undefinedLength");
|
|
26
|
+
rebind(indicator, mergedAlgorithm, "merge", "skipUndefined");
|
|
27
|
+
return indicator;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=rsi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rsi.js","sourceRoot":"","sources":["../../src/indicator/rsi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C,MAAM,cAAc,GAAG,KAAK,CAAC;AAsB7B,MAAM,CAAC,OAAO;IACV,MAAM,IAAI,GAAG,aAAa,EAAE;SACvB,IAAI,CAAC,cAAc,CAAC;SACpB,QAAQ,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAEjC,MAAM,mBAAmB,GAAG,GAAG,EAAE,CAAC;IAElC,MAAM,eAAe,GAAG,KAAK,EAAE;SAC1B,SAAS,CAAC,mBAAmB,CAAC;SAC9B,KAAK,CAAC,CAAC,KAAU,EAAE,CAAS,EAAE,EAAE;QAC7B,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IAEP,MAAM,SAAS,GAAG,CAAC,IAAW,EAAE,OAAO,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE;QACzD,IAAI,OAAO,CAAC,KAAK,EAAE;YACf,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE;gBAClB,MAAM,IAAI,KAAK,CAAC,sBAAsB,cAAc,qBAAqB,CAAC,CAAC;aAC9E;YAED,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC;SAChC;QAED,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC,CAAC;IAEF,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5E,MAAM,CAAC,SAAS,EAAE,mBAAmB,EAAE,SAAS,EAAE,iBAAiB,CAAC,CAAC;IACrE,MAAM,CAAC,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC;IAE7D,OAAO,SAAyB,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SAROptions } from "../calculator/sar";
|
|
2
|
+
interface SARIndicator {
|
|
3
|
+
(data: any[], options?: {
|
|
4
|
+
merge: boolean;
|
|
5
|
+
}): any;
|
|
6
|
+
id(): number;
|
|
7
|
+
id(x: number): SARIndicator;
|
|
8
|
+
accessor(): any;
|
|
9
|
+
accessor(x: any): SARIndicator;
|
|
10
|
+
stroke(): string | any;
|
|
11
|
+
stroke(x: string | any): SARIndicator;
|
|
12
|
+
fill(): string | any;
|
|
13
|
+
fill(x: string | any): SARIndicator;
|
|
14
|
+
echo(): any;
|
|
15
|
+
echo(x: any): SARIndicator;
|
|
16
|
+
type(): string;
|
|
17
|
+
type(x: string): SARIndicator;
|
|
18
|
+
merge(): any;
|
|
19
|
+
merge(newMerge: any): SARIndicator;
|
|
20
|
+
options(): SAROptions;
|
|
21
|
+
options(newOptions: SAROptions): SARIndicator;
|
|
22
|
+
}
|
|
23
|
+
export default function (): SARIndicator;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { merge, rebind } from "../utils";
|
|
2
|
+
import { sar } from "../calculator";
|
|
3
|
+
import baseIndicator from "./baseIndicator";
|
|
4
|
+
const ALGORITHM_TYPE = "SMA";
|
|
5
|
+
export default function () {
|
|
6
|
+
const base = baseIndicator()
|
|
7
|
+
.type(ALGORITHM_TYPE)
|
|
8
|
+
.accessor((d) => d.sar);
|
|
9
|
+
const underlyingAlgorithm = sar();
|
|
10
|
+
const mergedAlgorithm = merge()
|
|
11
|
+
.algorithm(underlyingAlgorithm)
|
|
12
|
+
.merge((datum, i) => {
|
|
13
|
+
datum.sar = i;
|
|
14
|
+
});
|
|
15
|
+
const indicator = (data, options = { merge: true }) => {
|
|
16
|
+
if (options.merge) {
|
|
17
|
+
if (!base.accessor()) {
|
|
18
|
+
throw new Error(`Set an accessor to ${ALGORITHM_TYPE} before calculating`);
|
|
19
|
+
}
|
|
20
|
+
return mergedAlgorithm(data);
|
|
21
|
+
}
|
|
22
|
+
return underlyingAlgorithm(data);
|
|
23
|
+
};
|
|
24
|
+
rebind(indicator, base, "id", "accessor", "stroke", "echo", "type");
|
|
25
|
+
rebind(indicator, underlyingAlgorithm, "options", "undefinedLength");
|
|
26
|
+
rebind(indicator, mergedAlgorithm, "merge");
|
|
27
|
+
return indicator;
|
|
28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,EAAE,mBAAmB,EAAE,SAAS,EAAE,iBAAiB,CAAC,CAAC;IACrE,MAAM,CAAC,SAAS,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;IAE5C,OAAO,SAAyB,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SMAOptions } from "../calculator/sma";
|
|
2
|
+
interface SMAIndicator {
|
|
3
|
+
(data: any[], options?: {
|
|
4
|
+
merge: boolean;
|
|
5
|
+
}): any;
|
|
6
|
+
id(): number;
|
|
7
|
+
id(x: number): SMAIndicator;
|
|
8
|
+
accessor(): any;
|
|
9
|
+
accessor(x: any): SMAIndicator;
|
|
10
|
+
stroke(): string | any;
|
|
11
|
+
stroke(x: string | any): SMAIndicator;
|
|
12
|
+
fill(): string | any;
|
|
13
|
+
fill(x: string | any): SMAIndicator;
|
|
14
|
+
echo(): any;
|
|
15
|
+
echo(x: any): SMAIndicator;
|
|
16
|
+
type(): string;
|
|
17
|
+
type(x: string): SMAIndicator;
|
|
18
|
+
merge(): any;
|
|
19
|
+
merge(newMerge: any): SMAIndicator;
|
|
20
|
+
options(): SMAOptions;
|
|
21
|
+
options(newOptions: SMAOptions): SMAIndicator;
|
|
22
|
+
}
|
|
23
|
+
export default function (): SMAIndicator;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { merge, rebind } from "../utils";
|
|
2
|
+
import { sma } from "../calculator";
|
|
3
|
+
import baseIndicator from "./baseIndicator";
|
|
4
|
+
const ALGORITHM_TYPE = "SMA";
|
|
5
|
+
export default function () {
|
|
6
|
+
const base = baseIndicator()
|
|
7
|
+
.type(ALGORITHM_TYPE)
|
|
8
|
+
.accessor((d) => d.sma);
|
|
9
|
+
const underlyingAlgorithm = sma();
|
|
10
|
+
const mergedAlgorithm = merge()
|
|
11
|
+
.algorithm(underlyingAlgorithm)
|
|
12
|
+
.merge((datum, i) => {
|
|
13
|
+
datum.sma = i;
|
|
14
|
+
});
|
|
15
|
+
const indicator = (data, options = { merge: true }) => {
|
|
16
|
+
if (options.merge) {
|
|
17
|
+
if (!base.accessor()) {
|
|
18
|
+
throw new Error(`Set an accessor to ${ALGORITHM_TYPE} before calculating`);
|
|
19
|
+
}
|
|
20
|
+
return mergedAlgorithm(data);
|
|
21
|
+
}
|
|
22
|
+
return underlyingAlgorithm(data);
|
|
23
|
+
};
|
|
24
|
+
rebind(indicator, base, "id", "accessor", "stroke", "fill", "echo", "type");
|
|
25
|
+
rebind(indicator, underlyingAlgorithm, "options", "undefinedLength");
|
|
26
|
+
rebind(indicator, mergedAlgorithm, "merge", "skipUndefined");
|
|
27
|
+
return indicator;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=sma.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sma.js","sourceRoot":"","sources":["../../src/indicator/sma.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C,MAAM,cAAc,GAAG,KAAK,CAAC;AAsB7B,MAAM,CAAC,OAAO;IACV,MAAM,IAAI,GAAG,aAAa,EAAE;SACvB,IAAI,CAAC,cAAc,CAAC;SACpB,QAAQ,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAEjC,MAAM,mBAAmB,GAAG,GAAG,EAAE,CAAC;IAElC,MAAM,eAAe,GAAG,KAAK,EAAE;SAC1B,SAAS,CAAC,mBAAmB,CAAC;SAC9B,KAAK,CAAC,CAAC,KAAU,EAAE,CAAS,EAAE,EAAE;QAC7B,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IAEP,MAAM,SAAS,GAAG,CAAC,IAAW,EAAE,OAAO,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE;QACzD,IAAI,OAAO,CAAC,KAAK,EAAE;YACf,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE;gBAClB,MAAM,IAAI,KAAK,CAAC,sBAAsB,cAAc,qBAAqB,CAAC,CAAC;aAC9E;YAED,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC;SAChC;QAED,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC,CAAC;IACF,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5E,MAAM,CAAC,SAAS,EAAE,mBAAmB,EAAE,SAAS,EAAE,iBAAiB,CAAC,CAAC;IACrE,MAAM,CAAC,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC;IAE7D,OAAO,SAAyB,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { STOOptions } from "../calculator/sto";
|
|
2
|
+
interface StochasticOscillatorIndicator {
|
|
3
|
+
(data: any[], options?: {
|
|
4
|
+
merge: boolean;
|
|
5
|
+
}): any;
|
|
6
|
+
id(): number;
|
|
7
|
+
id(x: number): StochasticOscillatorIndicator;
|
|
8
|
+
accessor(): any;
|
|
9
|
+
accessor(x: any): StochasticOscillatorIndicator;
|
|
10
|
+
stroke(): string | any;
|
|
11
|
+
stroke(x: string | any): StochasticOscillatorIndicator;
|
|
12
|
+
fill(): string | any;
|
|
13
|
+
fill(x: string | any): StochasticOscillatorIndicator;
|
|
14
|
+
echo(): any;
|
|
15
|
+
echo(x: any): StochasticOscillatorIndicator;
|
|
16
|
+
type(): string;
|
|
17
|
+
type(x: string): StochasticOscillatorIndicator;
|
|
18
|
+
merge(): any;
|
|
19
|
+
merge(newMerge: any): StochasticOscillatorIndicator;
|
|
20
|
+
options(): STOOptions;
|
|
21
|
+
options(newOptions: STOOptions): StochasticOscillatorIndicator;
|
|
22
|
+
}
|
|
23
|
+
export default function (): StochasticOscillatorIndicator;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { merge, rebind } from "../utils";
|
|
2
|
+
import { sto } from "../calculator";
|
|
3
|
+
import baseIndicator from "./baseIndicator";
|
|
4
|
+
const ALGORITHM_TYPE = "STO";
|
|
5
|
+
export default function () {
|
|
6
|
+
const base = baseIndicator().type(ALGORITHM_TYPE);
|
|
7
|
+
const underlyingAlgorithm = sto();
|
|
8
|
+
const mergedAlgorithm = merge()
|
|
9
|
+
.algorithm(underlyingAlgorithm)
|
|
10
|
+
.merge((datum, i) => {
|
|
11
|
+
datum.sto = i;
|
|
12
|
+
});
|
|
13
|
+
const indicator = (data, options = { merge: true }) => {
|
|
14
|
+
if (options.merge) {
|
|
15
|
+
if (!base.accessor()) {
|
|
16
|
+
throw new Error(`Set an accessor to ${ALGORITHM_TYPE} before calculating`);
|
|
17
|
+
}
|
|
18
|
+
return mergedAlgorithm(data);
|
|
19
|
+
}
|
|
20
|
+
return underlyingAlgorithm(data);
|
|
21
|
+
};
|
|
22
|
+
rebind(indicator, base, "id", "accessor", "stroke", "fill", "echo", "type");
|
|
23
|
+
rebind(indicator, underlyingAlgorithm, "options", "undefinedLength");
|
|
24
|
+
rebind(indicator, mergedAlgorithm, "merge", "skipUndefined");
|
|
25
|
+
return indicator;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=stochasticOscillator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stochasticOscillator.js","sourceRoot":"","sources":["../../src/indicator/stochasticOscillator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C,MAAM,cAAc,GAAG,KAAK,CAAC;AAsB7B,MAAM,CAAC,OAAO;IACV,MAAM,IAAI,GAAG,aAAa,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAElD,MAAM,mBAAmB,GAAG,GAAG,EAAE,CAAC;IAElC,MAAM,eAAe,GAAG,KAAK,EAAE;SAC1B,SAAS,CAAC,mBAAmB,CAAC;SAC9B,KAAK,CAAC,CAAC,KAAU,EAAE,CAAS,EAAE,EAAE;QAC7B,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IAEP,MAAM,SAAS,GAAG,CAAC,IAAW,EAAE,OAAO,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE;QACzD,IAAI,OAAO,CAAC,KAAK,EAAE;YACf,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE;gBAClB,MAAM,IAAI,KAAK,CAAC,sBAAsB,cAAc,qBAAqB,CAAC,CAAC;aAC9E;YAED,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC;SAChC;QAED,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC,CAAC;IAEF,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5E,MAAM,CAAC,SAAS,EAAE,mBAAmB,EAAE,SAAS,EAAE,iBAAiB,CAAC,CAAC;IACrE,MAAM,CAAC,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC;IAE7D,OAAO,SAA0C,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { TMAOptions } from "../calculator/tma";
|
|
2
|
+
interface TMAIndicator {
|
|
3
|
+
(data: any[], options?: {
|
|
4
|
+
merge: boolean;
|
|
5
|
+
}): any;
|
|
6
|
+
id(): number;
|
|
7
|
+
id(x: number): TMAIndicator;
|
|
8
|
+
accessor(): any;
|
|
9
|
+
accessor(x: any): TMAIndicator;
|
|
10
|
+
stroke(): string | any;
|
|
11
|
+
stroke(x: string | any): TMAIndicator;
|
|
12
|
+
fill(): string | any;
|
|
13
|
+
fill(x: string | any): TMAIndicator;
|
|
14
|
+
echo(): any;
|
|
15
|
+
echo(x: any): TMAIndicator;
|
|
16
|
+
type(): string;
|
|
17
|
+
type(x: string): TMAIndicator;
|
|
18
|
+
merge(): any;
|
|
19
|
+
merge(newMerge: any): TMAIndicator;
|
|
20
|
+
options(): TMAOptions;
|
|
21
|
+
options(newOptions: TMAOptions): TMAIndicator;
|
|
22
|
+
}
|
|
23
|
+
export default function (): TMAIndicator;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { merge, rebind } from "../utils";
|
|
2
|
+
import { tma } from "../calculator";
|
|
3
|
+
import baseIndicator from "./baseIndicator";
|
|
4
|
+
const ALGORITHM_TYPE = "TMA";
|
|
5
|
+
export default function () {
|
|
6
|
+
const base = baseIndicator()
|
|
7
|
+
.type(ALGORITHM_TYPE)
|
|
8
|
+
.accessor((d) => d.tma);
|
|
9
|
+
const underlyingAlgorithm = tma();
|
|
10
|
+
const mergedAlgorithm = merge()
|
|
11
|
+
.algorithm(underlyingAlgorithm)
|
|
12
|
+
.merge((datum, i) => {
|
|
13
|
+
datum.tma = i;
|
|
14
|
+
});
|
|
15
|
+
const indicator = (data, options = { merge: true }) => {
|
|
16
|
+
if (options.merge) {
|
|
17
|
+
if (!base.accessor()) {
|
|
18
|
+
throw new Error(`Set an accessor to ${ALGORITHM_TYPE} before calculating`);
|
|
19
|
+
}
|
|
20
|
+
return mergedAlgorithm(data);
|
|
21
|
+
}
|
|
22
|
+
return underlyingAlgorithm(data);
|
|
23
|
+
};
|
|
24
|
+
rebind(indicator, base, "id", "accessor", "stroke", "fill", "echo", "type");
|
|
25
|
+
rebind(indicator, underlyingAlgorithm, "options", "undefinedLength");
|
|
26
|
+
rebind(indicator, mergedAlgorithm, "merge", "skipUndefined");
|
|
27
|
+
return indicator;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=tma.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tma.js","sourceRoot":"","sources":["../../src/indicator/tma.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C,MAAM,cAAc,GAAG,KAAK,CAAC;AAsB7B,MAAM,CAAC,OAAO;IACV,MAAM,IAAI,GAAG,aAAa,EAAE;SACvB,IAAI,CAAC,cAAc,CAAC;SACpB,QAAQ,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAEjC,MAAM,mBAAmB,GAAG,GAAG,EAAE,CAAC;IAElC,MAAM,eAAe,GAAG,KAAK,EAAE;SAC1B,SAAS,CAAC,mBAAmB,CAAC;SAC9B,KAAK,CAAC,CAAC,KAAU,EAAE,CAAS,EAAE,EAAE;QAC7B,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IAEP,MAAM,SAAS,GAAG,CAAC,IAAW,EAAE,OAAO,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE;QACzD,IAAI,OAAO,CAAC,KAAK,EAAE;YACf,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE;gBAClB,MAAM,IAAI,KAAK,CAAC,sBAAsB,cAAc,qBAAqB,CAAC,CAAC;aAC9E;YAED,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC;SAChC;QAED,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC,CAAC;IACF,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5E,MAAM,CAAC,SAAS,EAAE,mBAAmB,EAAE,SAAS,EAAE,iBAAiB,CAAC,CAAC;IACrE,MAAM,CAAC,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC;IAE7D,OAAO,SAAyB,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { WMAOptions } from "../calculator/wma";
|
|
2
|
+
interface WMAIndicator {
|
|
3
|
+
(data: any[], options?: {
|
|
4
|
+
merge: boolean;
|
|
5
|
+
}): any;
|
|
6
|
+
id(): number;
|
|
7
|
+
id(x: number): WMAIndicator;
|
|
8
|
+
accessor(): any;
|
|
9
|
+
accessor(x: any): WMAIndicator;
|
|
10
|
+
stroke(): string | any;
|
|
11
|
+
stroke(x: string | any): WMAIndicator;
|
|
12
|
+
fill(): string | any;
|
|
13
|
+
fill(x: string | any): WMAIndicator;
|
|
14
|
+
echo(): any;
|
|
15
|
+
echo(x: any): WMAIndicator;
|
|
16
|
+
type(): string;
|
|
17
|
+
type(x: string): WMAIndicator;
|
|
18
|
+
merge(): any;
|
|
19
|
+
merge(newMerge: any): WMAIndicator;
|
|
20
|
+
options(): WMAOptions;
|
|
21
|
+
options(newOptions: WMAOptions): WMAIndicator;
|
|
22
|
+
}
|
|
23
|
+
export default function (): WMAIndicator;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { merge, rebind } from "../utils";
|
|
2
|
+
import { wma } from "../calculator";
|
|
3
|
+
import baseIndicator from "./baseIndicator";
|
|
4
|
+
const ALGORITHM_TYPE = "WMA";
|
|
5
|
+
export default function () {
|
|
6
|
+
const base = baseIndicator()
|
|
7
|
+
.type(ALGORITHM_TYPE)
|
|
8
|
+
.accessor((d) => d.wma);
|
|
9
|
+
const underlyingAlgorithm = wma();
|
|
10
|
+
const mergedAlgorithm = merge()
|
|
11
|
+
.algorithm(underlyingAlgorithm)
|
|
12
|
+
.merge((datum, i) => {
|
|
13
|
+
datum.wma = i;
|
|
14
|
+
});
|
|
15
|
+
const indicator = (data, options = { merge: true }) => {
|
|
16
|
+
if (options.merge) {
|
|
17
|
+
if (!base.accessor()) {
|
|
18
|
+
throw new Error(`Set an accessor to ${ALGORITHM_TYPE} before calculating`);
|
|
19
|
+
}
|
|
20
|
+
return mergedAlgorithm(data);
|
|
21
|
+
}
|
|
22
|
+
return underlyingAlgorithm(data);
|
|
23
|
+
};
|
|
24
|
+
rebind(indicator, base, "id", "accessor", "stroke", "fill", "echo", "type");
|
|
25
|
+
rebind(indicator, underlyingAlgorithm, "options", "undefinedLength");
|
|
26
|
+
rebind(indicator, mergedAlgorithm, "merge", "skipUndefined");
|
|
27
|
+
return indicator;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=wma.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wma.js","sourceRoot":"","sources":["../../src/indicator/wma.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C,MAAM,cAAc,GAAG,KAAK,CAAC;AAsB7B,MAAM,CAAC,OAAO;IACV,MAAM,IAAI,GAAG,aAAa,EAAE;SACvB,IAAI,CAAC,cAAc,CAAC;SACpB,QAAQ,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAEjC,MAAM,mBAAmB,GAAG,GAAG,EAAE,CAAC;IAElC,MAAM,eAAe,GAAG,KAAK,EAAE;SAC1B,SAAS,CAAC,mBAAmB,CAAC;SAC9B,KAAK,CAAC,CAAC,KAAU,EAAE,CAAS,EAAE,EAAE;QAC7B,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IAEP,MAAM,SAAS,GAAG,CAAC,IAAW,EAAE,OAAO,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE;QACzD,IAAI,OAAO,CAAC,KAAK,EAAE;YACf,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE;gBAClB,MAAM,IAAI,KAAK,CAAC,sBAAsB,cAAc,qBAAqB,CAAC,CAAC;aAC9E;YAED,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC;SAChC;QAED,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC,CAAC;IAEF,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5E,MAAM,CAAC,SAAS,EAAE,mBAAmB,EAAE,SAAS,EAAE,iBAAiB,CAAC,CAAC;IACrE,MAAM,CAAC,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC;IAE7D,OAAO,SAAyB,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const functor: (v: any) => any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functor.js","sourceRoot":"","sources":["../../src/utils/functor.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAM,EAAE,EAAE;IAC9B,OAAO,OAAO,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;AACjD,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const identity: <T>(d: T) => T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/utils/identity.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAI,CAAI,EAAE,EAAE,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./functor";
|
|
2
|
+
export * from "./identity";
|
|
3
|
+
export { default as mappedSlidingWindow } from "./mappedSlidingWindow";
|
|
4
|
+
export { default as merge } from "./merge";
|
|
5
|
+
export * from "./path";
|
|
6
|
+
export { default as rebind } from "./rebind";
|
|
7
|
+
export { default as slidingWindow } from "./slidingWindow";
|
|
8
|
+
export { default as zipper } from "./zipper";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./functor";
|
|
2
|
+
export * from "./identity";
|
|
3
|
+
export { default as mappedSlidingWindow } from "./mappedSlidingWindow";
|
|
4
|
+
export { default as merge } from "./merge";
|
|
5
|
+
export * from "./path";
|
|
6
|
+
export { default as rebind } from "./rebind";
|
|
7
|
+
export { default as slidingWindow } from "./slidingWindow";
|
|
8
|
+
export { default as zipper } from "./zipper";
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
interface MappedSlidingWindow {
|
|
2
|
+
(data: any[]): any;
|
|
3
|
+
accumulator(): any;
|
|
4
|
+
accumulator(x: any): MappedSlidingWindow;
|
|
5
|
+
skipInitial(): number;
|
|
6
|
+
skipInitial(x: number): MappedSlidingWindow;
|
|
7
|
+
source(): any;
|
|
8
|
+
source(x: any): MappedSlidingWindow;
|
|
9
|
+
undefinedValue(): any;
|
|
10
|
+
undefinedValue(x: any): MappedSlidingWindow;
|
|
11
|
+
windowSize(): number;
|
|
12
|
+
windowSize(x: number): MappedSlidingWindow;
|
|
13
|
+
}
|
|
14
|
+
export default function (): MappedSlidingWindow;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { functor } from "./functor";
|
|
2
|
+
import { identity } from "./identity";
|
|
3
|
+
export default function () {
|
|
4
|
+
let undefinedValue;
|
|
5
|
+
let windowSize = 10;
|
|
6
|
+
let accumulator = () => {
|
|
7
|
+
/** Do Nothing */
|
|
8
|
+
};
|
|
9
|
+
let source = identity;
|
|
10
|
+
let skipInitial = 0;
|
|
11
|
+
const mappedSlidingWindow = function (data) {
|
|
12
|
+
// @ts-ignore
|
|
13
|
+
const size = functor(windowSize).apply(this, arguments);
|
|
14
|
+
const windowData = [];
|
|
15
|
+
let accumulatorIdx = 0;
|
|
16
|
+
const undef = functor(undefinedValue);
|
|
17
|
+
const result = [];
|
|
18
|
+
data.forEach(function (d, i) {
|
|
19
|
+
let mapped;
|
|
20
|
+
if (i < skipInitial + size - 1) {
|
|
21
|
+
mapped = undef(d, i);
|
|
22
|
+
result.push(mapped);
|
|
23
|
+
windowData.push(mapped);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (i >= skipInitial + size) {
|
|
27
|
+
windowData.shift();
|
|
28
|
+
}
|
|
29
|
+
// @ts-ignore
|
|
30
|
+
windowData.push(source(d, i));
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
mapped = accumulator(windowData, i, accumulatorIdx++);
|
|
33
|
+
result.push(mapped);
|
|
34
|
+
windowData.pop();
|
|
35
|
+
windowData.push(mapped);
|
|
36
|
+
return;
|
|
37
|
+
});
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
mappedSlidingWindow.undefinedValue = function (x) {
|
|
41
|
+
if (!arguments.length) {
|
|
42
|
+
return undefinedValue;
|
|
43
|
+
}
|
|
44
|
+
undefinedValue = x;
|
|
45
|
+
return mappedSlidingWindow;
|
|
46
|
+
};
|
|
47
|
+
mappedSlidingWindow.windowSize = function (x) {
|
|
48
|
+
if (!arguments.length) {
|
|
49
|
+
return windowSize;
|
|
50
|
+
}
|
|
51
|
+
windowSize = x;
|
|
52
|
+
return mappedSlidingWindow;
|
|
53
|
+
};
|
|
54
|
+
mappedSlidingWindow.accumulator = function (x) {
|
|
55
|
+
if (!arguments.length) {
|
|
56
|
+
return accumulator;
|
|
57
|
+
}
|
|
58
|
+
accumulator = x;
|
|
59
|
+
return mappedSlidingWindow;
|
|
60
|
+
};
|
|
61
|
+
mappedSlidingWindow.skipInitial = function (x) {
|
|
62
|
+
if (!arguments.length) {
|
|
63
|
+
return skipInitial;
|
|
64
|
+
}
|
|
65
|
+
skipInitial = x;
|
|
66
|
+
return mappedSlidingWindow;
|
|
67
|
+
};
|
|
68
|
+
mappedSlidingWindow.source = function (x) {
|
|
69
|
+
if (!arguments.length) {
|
|
70
|
+
return source;
|
|
71
|
+
}
|
|
72
|
+
source = x;
|
|
73
|
+
return mappedSlidingWindow;
|
|
74
|
+
};
|
|
75
|
+
return mappedSlidingWindow;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=mappedSlidingWindow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mappedSlidingWindow.js","sourceRoot":"","sources":["../../src/utils/mappedSlidingWindow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAgBtC,MAAM,CAAC,OAAO;IACV,IAAI,cAAmB,CAAC;IACxB,IAAI,UAAU,GAAG,EAAE,CAAC;IACpB,IAAI,WAAW,GAAG,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