trading-signals 3.5.0 → 3.6.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 CHANGED
@@ -50,6 +50,7 @@ All indicators can be updated over time by streaming data (prices or candles) to
50
50
  1. Mean Absolute Deviation (MAD)
51
51
  1. Momentum (MOM / MTM)
52
52
  1. Moving Average Convergence Divergence (MACD)
53
+ 1. On-Balance Volume (OBV)
53
54
  1. Rate-of-Change (ROC)
54
55
  1. Relative Strength Index (RSI)
55
56
  1. Simple Moving Average (SMA)
@@ -0,0 +1,11 @@
1
+ import Big from 'big.js';
2
+ import { BigIndicatorSeries, NumberIndicatorSeries } from '../Indicator';
3
+ import { OpenHighLowCloseVolume, OpenHighLowCloseVolumeNumber } from '../util';
4
+ export declare class OBV extends BigIndicatorSeries<OpenHighLowCloseVolume> {
5
+ readonly candles: OpenHighLowCloseVolume[];
6
+ update(candle: OpenHighLowCloseVolume): Big | void;
7
+ }
8
+ export declare class FasterOBV extends NumberIndicatorSeries<OpenHighLowCloseVolumeNumber> {
9
+ readonly candles: OpenHighLowCloseVolumeNumber[];
10
+ update(candle: OpenHighLowCloseVolumeNumber): void | number;
11
+ }
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.FasterOBV = exports.OBV = void 0;
7
+ const big_js_1 = __importDefault(require("big.js"));
8
+ const Indicator_1 = require("../Indicator");
9
+ class OBV extends Indicator_1.BigIndicatorSeries {
10
+ constructor() {
11
+ super(...arguments);
12
+ this.candles = [];
13
+ }
14
+ update(candle) {
15
+ var _a;
16
+ this.candles.push(candle);
17
+ if (this.candles.length === 1) {
18
+ return;
19
+ }
20
+ const prevCandle = this.candles[this.candles.length - 2];
21
+ const prevPrice = prevCandle.close;
22
+ const prevResult = (_a = this.result) !== null && _a !== void 0 ? _a : new big_js_1.default(0);
23
+ const currentPrice = new big_js_1.default(candle.close);
24
+ const nextResult = currentPrice.gt(prevPrice) ? candle.volume : currentPrice.lt(prevPrice) ? -candle.volume : 0;
25
+ return this.setResult(prevResult.add(nextResult));
26
+ }
27
+ }
28
+ exports.OBV = OBV;
29
+ class FasterOBV extends Indicator_1.NumberIndicatorSeries {
30
+ constructor() {
31
+ super(...arguments);
32
+ this.candles = [];
33
+ }
34
+ update(candle) {
35
+ var _a;
36
+ this.candles.push(candle);
37
+ if (this.candles.length === 1) {
38
+ return;
39
+ }
40
+ const prevCandle = this.candles[this.candles.length - 2];
41
+ const prevPrice = prevCandle.close;
42
+ const prevResult = (_a = this.result) !== null && _a !== void 0 ? _a : 0;
43
+ const currentPrice = candle.close;
44
+ const nextResult = currentPrice > prevPrice ? candle.volume : currentPrice < prevPrice ? -candle.volume : 0;
45
+ return this.setResult(prevResult + nextResult);
46
+ }
47
+ }
48
+ exports.FasterOBV = FasterOBV;
49
+ //# sourceMappingURL=OBV.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OBV.js","sourceRoot":"","sources":["../../src/OBV/OBV.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAyB;AACzB,4CAAuE;AAYvE,MAAa,GAAI,SAAQ,8BAA0C;IAAnE;;QACkB,YAAO,GAA6B,EAAE,CAAC;IAiBzD,CAAC;IAfU,MAAM,CAAC,MAA8B;;QAC5C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAE1B,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;YAC7B,OAAO;SACR;QAED,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACzD,MAAM,SAAS,GAAG,UAAU,CAAC,KAAK,CAAC;QACnC,MAAM,UAAU,GAAG,MAAA,IAAI,CAAC,MAAM,mCAAI,I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AC;CACF;AAlBD,8BAkBC"}
package/dist/index.d.ts CHANGED
@@ -18,6 +18,7 @@ export * from './MA/MovingAverageTypes';
18
18
  export * from './MACD/MACD';
19
19
  export * from './MAD/MAD';
20
20
  export * from './MOM/MOM';
21
+ export * from './OBV/OBV';
21
22
  export * from './ROC/ROC';
22
23
  export * from './RSI/RSI';
23
24
  export * from './SMA/SMA';
package/dist/index.js CHANGED
@@ -30,6 +30,7 @@ __exportStar(require("./MA/MovingAverageTypes"), exports);
30
30
  __exportStar(require("./MACD/MACD"), exports);
31
31
  __exportStar(require("./MAD/MAD"), exports);
32
32
  __exportStar(require("./MOM/MOM"), exports);
33
+ __exportStar(require("./OBV/OBV"), exports);
33
34
  __exportStar(require("./ROC/ROC"), exports);
34
35
  __exportStar(require("./RSI/RSI"), exports);
35
36
  __exportStar(require("./SMA/SMA"), exports);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6DAA2C;AAC3C,0CAAwB;AACxB,4CAA0B;AAC1B,0CAAwB;AACxB,4CAA0B;AAC1B,0DAAwC;AACxC,4DAA0C;AAC1C,4CAA0B;AAC1B,0CAAwB;AACxB,8CAA4B;AAC5B,4CAA0B;AAC1B,0CAAwB;AACxB,4CAA0B;AAC1B,0CAAwB;AACxB,8CAA4B;AAC5B,qDAAmC;AACnC,0DAAwC;AACxC,8CAA4B;AAC5B,4CAA0B;AAC1B,4CAA0B;AAC1B,4CAA0B;AAC1B,4CAA0B;AAC1B,4CAA0B;AAC1B,+DAA6C;AAC7C,wDAAsC;AACtC,0CAAwB;AACxB,yCAAuB;AACvB,8CAA4B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6DAA2C;AAC3C,0CAAwB;AACxB,4CAA0B;AAC1B,0CAAwB;AACxB,4CAA0B;AAC1B,0DAAwC;AACxC,4DAA0C;AAC1C,4CAA0B;AAC1B,0CAAwB;AACxB,8CAA4B;AAC5B,4CAA0B;AAC1B,0CAAwB;AACxB,4CAA0B;AAC1B,0CAAwB;AACxB,8CAA4B;AAC5B,qDAAmC;AACnC,0DAAwC;AACxC,8CAA4B;AAC5B,4CAA0B;AAC1B,4CAA0B;AAC1B,4CAA0B;AAC1B,4CAA0B;AAC1B,4CAA0B;AAC1B,4CAA0B;AAC1B,+DAA6C;AAC7C,wDAAsC;AACtC,0CAAwB;AACxB,yCAAuB;AACvB,8CAA4B"}
@@ -6,6 +6,12 @@ export declare type HighLow = {
6
6
  export declare type HighLowClose = HighLow & {
7
7
  close: BigSource;
8
8
  };
9
+ export declare type OpenHighLowClose = HighLowClose & {
10
+ open: BigSource;
11
+ };
12
+ export declare type OpenHighLowCloseVolume = OpenHighLowClose & {
13
+ volume: BigSource;
14
+ };
9
15
  export declare type HighLowNumber = {
10
16
  high: number;
11
17
  low: number;
@@ -13,3 +19,9 @@ export declare type HighLowNumber = {
13
19
  export declare type HighLowCloseNumber = HighLowNumber & {
14
20
  close: number;
15
21
  };
22
+ export declare type OpenHighLowCloseNumber = HighLowCloseNumber & {
23
+ open: number;
24
+ };
25
+ export declare type OpenHighLowCloseVolumeNumber = OpenHighLowCloseNumber & {
26
+ volume: number;
27
+ };
package/package.json CHANGED
@@ -9,19 +9,19 @@
9
9
  "description": "Technical indicators to run technical analysis with JavaScript / TypeScript.",
10
10
  "devDependencies": {
11
11
  "@types/benchmark": "2.1.1",
12
- "@types/jest": "27.0.3",
13
- "@types/node": "16.11.13",
14
- "@typescript-eslint/eslint-plugin": "5.8.1",
15
- "@typescript-eslint/parser": "5.8.1",
12
+ "@types/jest": "27.4.0",
13
+ "@types/node": "16.11.18",
14
+ "@typescript-eslint/eslint-plugin": "5.9.0",
15
+ "@typescript-eslint/parser": "5.9.0",
16
16
  "benchmark": "2.1.4",
17
- "eslint": "8.5.0",
17
+ "eslint": "8.6.0",
18
18
  "eslint-config-prettier": "8.3.0",
19
19
  "eslint-plugin-prettier": "4.0.0",
20
20
  "eslint-plugin-typescript-sort-keys": "2.1.0",
21
21
  "generate-changelog": "1.8.0",
22
22
  "husky": "4.3.8",
23
23
  "jest": "27.4.5",
24
- "lint-staged": "12.1.4",
24
+ "lint-staged": "12.1.5",
25
25
  "prettier": "2.5.1",
26
26
  "pretty-quick": "3.1.3",
27
27
  "rimraf": "3.0.2",
@@ -85,7 +85,7 @@
85
85
  "lint:other": "yarn prettier --list-different",
86
86
  "lint:types": "tsc --noEmit",
87
87
  "postversion": "git push origin && git push origin --tags && npm publish",
88
- "prettier": "prettier --ignore-path .gitignore --loglevel silent \"**/*.{json,scss,yml}\"",
88
+ "prettier": "prettier --ignore-path .gitignore --loglevel error \"**/*.{json,scss,yml}\"",
89
89
  "preversion": "git checkout main && git pull && yarn && yarn test && yarn dist",
90
90
  "release:major": "generate-changelog -M -x \"chore,test\" && yarn changelog:commit && npm version major",
91
91
  "release:minor": "generate-changelog -m -x \"chore,test\" && yarn changelog:commit && npm version minor",
@@ -95,5 +95,5 @@
95
95
  "test:dev": "jest ./src",
96
96
  "test:types": "yarn lint:types"
97
97
  },
98
- "version": "3.5.0"
98
+ "version": "3.6.0"
99
99
  }