trading-signals 6.2.0 → 6.3.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/dist/index.cjs CHANGED
@@ -1707,11 +1707,15 @@ var FasterStochasticOscillator = class extends TechnicalIndicator {
1707
1707
  // src/STOCH/StochasticRSI.ts
1708
1708
  var import_big23 = __toESM(require("big.js"), 1);
1709
1709
  var StochasticRSI = class extends BigIndicatorSeries {
1710
- constructor(interval, SmoothingIndicator = WSMA) {
1710
+ constructor(interval, SmoothingRSI = WSMA, smoothing = {
1711
+ d: new SMA(3),
1712
+ k: new SMA(3)
1713
+ }) {
1711
1714
  super();
1712
1715
  this.interval = interval;
1716
+ this.smoothing = smoothing;
1713
1717
  this.period = new Period(interval);
1714
- this.rsi = new RSI(interval, SmoothingIndicator);
1718
+ this.rsi = new RSI(interval, SmoothingRSI);
1715
1719
  }
1716
1720
  period;
1717
1721
  rsi;
@@ -1724,21 +1728,30 @@ var StochasticRSI = class extends BigIndicatorSeries {
1724
1728
  const max = periodResult.highest;
1725
1729
  const denominator = max.minus(min);
1726
1730
  if (denominator.eq(0)) {
1727
- return this.setResult(new import_big23.default(100), false);
1731
+ return this.setResult(new import_big23.default(100), replace);
1728
1732
  }
1729
1733
  const numerator = rsiResult.minus(min);
1730
- return this.setResult(numerator.div(denominator), false);
1734
+ const stochRSI = numerator.div(denominator);
1735
+ const k = this.smoothing.k.update(stochRSI, replace);
1736
+ if (k) {
1737
+ this.smoothing.d.update(k, replace);
1738
+ }
1739
+ return this.setResult(stochRSI, replace);
1731
1740
  }
1732
1741
  }
1733
1742
  return null;
1734
1743
  }
1735
1744
  };
1736
1745
  var FasterStochasticRSI = class extends NumberIndicatorSeries {
1737
- constructor(interval, SmoothingIndicator = FasterWSMA) {
1746
+ constructor(interval, SmoothingRSI = FasterWSMA, smoothing = {
1747
+ d: new FasterSMA(3),
1748
+ k: new FasterSMA(3)
1749
+ }) {
1738
1750
  super();
1739
1751
  this.interval = interval;
1752
+ this.smoothing = smoothing;
1740
1753
  this.period = new FasterPeriod(interval);
1741
- this.rsi = new FasterRSI(interval, SmoothingIndicator);
1754
+ this.rsi = new FasterRSI(interval, SmoothingRSI);
1742
1755
  }
1743
1756
  period;
1744
1757
  rsi;
@@ -1754,7 +1767,12 @@ var FasterStochasticRSI = class extends NumberIndicatorSeries {
1754
1767
  return this.setResult(100, replace);
1755
1768
  }
1756
1769
  const numerator = rsiResult - min;
1757
- return this.setResult(numerator / denominator, replace);
1770
+ const stochRSI = numerator / denominator;
1771
+ const k = this.smoothing.k.update(stochRSI, replace);
1772
+ if (k) {
1773
+ this.smoothing.d.update(k, replace);
1774
+ }
1775
+ return this.setResult(stochRSI, replace);
1758
1776
  }
1759
1777
  }
1760
1778
  return null;
package/dist/index.d.cts CHANGED
@@ -612,16 +612,30 @@ declare class FasterStochasticOscillator extends TechnicalIndicator<FasterStocha
612
612
 
613
613
  declare class StochasticRSI extends BigIndicatorSeries {
614
614
  readonly interval: number;
615
+ readonly smoothing: {
616
+ readonly k: MovingAverage;
617
+ readonly d: MovingAverage;
618
+ };
615
619
  private readonly period;
616
620
  private readonly rsi;
617
- constructor(interval: number, SmoothingIndicator?: MovingAverageTypes);
621
+ constructor(interval: number, SmoothingRSI?: MovingAverageTypes, smoothing?: {
622
+ readonly k: MovingAverage;
623
+ readonly d: MovingAverage;
624
+ });
618
625
  update(price: BigSource, replace: boolean): Big__default.Big | null;
619
626
  }
620
627
  declare class FasterStochasticRSI extends NumberIndicatorSeries {
621
628
  readonly interval: number;
629
+ readonly smoothing: {
630
+ readonly k: FasterMovingAverage;
631
+ readonly d: FasterMovingAverage;
632
+ };
622
633
  private readonly period;
623
634
  private readonly rsi;
624
- constructor(interval: number, SmoothingIndicator?: FasterMovingAverageTypes);
635
+ constructor(interval: number, SmoothingRSI?: FasterMovingAverageTypes, smoothing?: {
636
+ readonly k: FasterMovingAverage;
637
+ readonly d: FasterMovingAverage;
638
+ });
625
639
  update(price: number, replace: boolean): number | null;
626
640
  }
627
641
 
package/dist/index.d.ts CHANGED
@@ -612,16 +612,30 @@ declare class FasterStochasticOscillator extends TechnicalIndicator<FasterStocha
612
612
 
613
613
  declare class StochasticRSI extends BigIndicatorSeries {
614
614
  readonly interval: number;
615
+ readonly smoothing: {
616
+ readonly k: MovingAverage;
617
+ readonly d: MovingAverage;
618
+ };
615
619
  private readonly period;
616
620
  private readonly rsi;
617
- constructor(interval: number, SmoothingIndicator?: MovingAverageTypes);
621
+ constructor(interval: number, SmoothingRSI?: MovingAverageTypes, smoothing?: {
622
+ readonly k: MovingAverage;
623
+ readonly d: MovingAverage;
624
+ });
618
625
  update(price: BigSource, replace: boolean): Big__default.Big | null;
619
626
  }
620
627
  declare class FasterStochasticRSI extends NumberIndicatorSeries {
621
628
  readonly interval: number;
629
+ readonly smoothing: {
630
+ readonly k: FasterMovingAverage;
631
+ readonly d: FasterMovingAverage;
632
+ };
622
633
  private readonly period;
623
634
  private readonly rsi;
624
- constructor(interval: number, SmoothingIndicator?: FasterMovingAverageTypes);
635
+ constructor(interval: number, SmoothingRSI?: FasterMovingAverageTypes, smoothing?: {
636
+ readonly k: FasterMovingAverage;
637
+ readonly d: FasterMovingAverage;
638
+ });
625
639
  update(price: number, replace: boolean): number | null;
626
640
  }
627
641
 
package/dist/index.js CHANGED
@@ -1602,11 +1602,15 @@ var FasterStochasticOscillator = class extends TechnicalIndicator {
1602
1602
  // src/STOCH/StochasticRSI.ts
1603
1603
  import Big23 from "big.js";
1604
1604
  var StochasticRSI = class extends BigIndicatorSeries {
1605
- constructor(interval, SmoothingIndicator = WSMA) {
1605
+ constructor(interval, SmoothingRSI = WSMA, smoothing = {
1606
+ d: new SMA(3),
1607
+ k: new SMA(3)
1608
+ }) {
1606
1609
  super();
1607
1610
  this.interval = interval;
1611
+ this.smoothing = smoothing;
1608
1612
  this.period = new Period(interval);
1609
- this.rsi = new RSI(interval, SmoothingIndicator);
1613
+ this.rsi = new RSI(interval, SmoothingRSI);
1610
1614
  }
1611
1615
  period;
1612
1616
  rsi;
@@ -1619,21 +1623,30 @@ var StochasticRSI = class extends BigIndicatorSeries {
1619
1623
  const max = periodResult.highest;
1620
1624
  const denominator = max.minus(min);
1621
1625
  if (denominator.eq(0)) {
1622
- return this.setResult(new Big23(100), false);
1626
+ return this.setResult(new Big23(100), replace);
1623
1627
  }
1624
1628
  const numerator = rsiResult.minus(min);
1625
- return this.setResult(numerator.div(denominator), false);
1629
+ const stochRSI = numerator.div(denominator);
1630
+ const k = this.smoothing.k.update(stochRSI, replace);
1631
+ if (k) {
1632
+ this.smoothing.d.update(k, replace);
1633
+ }
1634
+ return this.setResult(stochRSI, replace);
1626
1635
  }
1627
1636
  }
1628
1637
  return null;
1629
1638
  }
1630
1639
  };
1631
1640
  var FasterStochasticRSI = class extends NumberIndicatorSeries {
1632
- constructor(interval, SmoothingIndicator = FasterWSMA) {
1641
+ constructor(interval, SmoothingRSI = FasterWSMA, smoothing = {
1642
+ d: new FasterSMA(3),
1643
+ k: new FasterSMA(3)
1644
+ }) {
1633
1645
  super();
1634
1646
  this.interval = interval;
1647
+ this.smoothing = smoothing;
1635
1648
  this.period = new FasterPeriod(interval);
1636
- this.rsi = new FasterRSI(interval, SmoothingIndicator);
1649
+ this.rsi = new FasterRSI(interval, SmoothingRSI);
1637
1650
  }
1638
1651
  period;
1639
1652
  rsi;
@@ -1649,7 +1662,12 @@ var FasterStochasticRSI = class extends NumberIndicatorSeries {
1649
1662
  return this.setResult(100, replace);
1650
1663
  }
1651
1664
  const numerator = rsiResult - min;
1652
- return this.setResult(numerator / denominator, replace);
1665
+ const stochRSI = numerator / denominator;
1666
+ const k = this.smoothing.k.update(stochRSI, replace);
1667
+ if (k) {
1668
+ this.smoothing.d.update(k, replace);
1669
+ }
1670
+ return this.setResult(stochRSI, replace);
1653
1671
  }
1654
1672
  }
1655
1673
  return null;
package/package.json CHANGED
@@ -3,31 +3,31 @@
3
3
  "url": "https://github.com/bennycode/trading-signals/issues"
4
4
  },
5
5
  "dependencies": {
6
- "@types/big.js": "^6.2.0",
7
- "big.js": "^6.2.1"
6
+ "@types/big.js": "^6.2.2",
7
+ "big.js": "^6.2.2"
8
8
  },
9
9
  "description": "Technical indicators to run technical analysis with JavaScript / TypeScript.",
10
10
  "devDependencies": {
11
- "@arethetypeswrong/cli": "^0.17.3",
12
- "@tstv/eslint-config": "^3.1.6",
13
- "@types/benchmark": "^2.1.3",
14
- "@types/node": "^18.15.11",
15
- "@vitest/coverage-v8": "^1.1.1",
11
+ "@arethetypeswrong/cli": "^0.17.4",
12
+ "@tstv/eslint-config": "^3.2.4",
13
+ "@types/benchmark": "^2.1.5",
14
+ "@types/node": "^18.19.86",
15
+ "@vitest/coverage-v8": "^3.1.2",
16
16
  "benchmark": "^2.1.4",
17
- "dependency-cruiser": "^16.9.0",
18
- "eslint": "^8.57.0",
17
+ "dependency-cruiser": "^16.10.1",
18
+ "eslint": "^8.57.1",
19
19
  "generate-changelog": "^1.8.0",
20
20
  "husky": "^4.3.8",
21
- "lint-staged": "^15.0.2",
22
- "prettier": "^3.2.5",
23
- "pretty-quick": "^4.0.0",
21
+ "lint-staged": "^15.5.1",
22
+ "prettier": "^3.5.3",
23
+ "pretty-quick": "^4.1.1",
24
24
  "rimraf": "^6.0.1",
25
- "ts-node": "^10.9.1",
26
- "tsup": "^8.3.5",
27
- "typedoc": "0.27.6",
28
- "typedoc-plugin-markdown": "^4.0.3",
29
- "typescript": "^5.2.2",
30
- "vitest": "^1.1.1"
25
+ "ts-node": "^10.9.2",
26
+ "tsup": "^8.4.0",
27
+ "typedoc": "^0.28.3",
28
+ "typedoc-plugin-markdown": "^4.6.3",
29
+ "typescript": "^5.7.3",
30
+ "vitest": "^3.1.2"
31
31
  },
32
32
  "exports": {
33
33
  ".": {
@@ -104,5 +104,5 @@
104
104
  "test:types": "npm run lint:types"
105
105
  },
106
106
  "type": "module",
107
- "version": "6.2.0"
107
+ "version": "6.3.0"
108
108
  }