fixparser-plugin-mcp 9.1.7-70d519a1 → 9.1.7-74db6dbc

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.
@@ -414,7 +414,7 @@ var TechnicalAnalyzer = class {
414
414
  return maxDrawdown;
415
415
  }
416
416
  // Calculate Average True Range (ATR)
417
- calculateAtr(prices, highs, lows, volumes) {
417
+ calculateAtr(prices, highs, lows) {
418
418
  if (prices.length < 2) return [];
419
419
  const trueRanges = [];
420
420
  for (let i = 1; i < prices.length; i++) {
@@ -525,45 +525,272 @@ var TechnicalAnalyzer = class {
525
525
  }
526
526
  return macd;
527
527
  }
528
- // Calculate ADX
528
+ // Calculate ADX (Average Directional Index)
529
529
  calculateAdx(prices, highs, lows) {
530
+ if (prices.length < 14) return [];
531
+ const period = 14;
530
532
  const adx = [];
531
- for (let i = 14; i < prices.length; i++) {
532
- adx.push(Math.random() * 50 + 25);
533
+ const trueRanges = [];
534
+ const plusDM = [];
535
+ const minusDM = [];
536
+ trueRanges.push(highs[0] - lows[0]);
537
+ plusDM.push(0);
538
+ minusDM.push(0);
539
+ for (let i = 1; i < prices.length; i++) {
540
+ const high = highs[i] || prices[i];
541
+ const low = lows[i] || prices[i];
542
+ const prevHigh = highs[i - 1] || prices[i - 1];
543
+ const prevLow = lows[i - 1] || prices[i - 1];
544
+ const prevClose = prices[i - 1];
545
+ const tr1 = high - low;
546
+ const tr2 = Math.abs(high - prevClose);
547
+ const tr3 = Math.abs(low - prevClose);
548
+ trueRanges.push(Math.max(tr1, tr2, tr3));
549
+ const upMove = high - prevHigh;
550
+ const downMove = prevLow - low;
551
+ if (upMove > downMove && upMove > 0) {
552
+ plusDM.push(upMove);
553
+ minusDM.push(0);
554
+ } else if (downMove > upMove && downMove > 0) {
555
+ plusDM.push(0);
556
+ minusDM.push(downMove);
557
+ } else {
558
+ plusDM.push(0);
559
+ minusDM.push(0);
560
+ }
561
+ }
562
+ const smoothedTR = [];
563
+ const smoothedPlusDM = [];
564
+ const smoothedMinusDM = [];
565
+ let sumTR = 0;
566
+ let sumPlusDM = 0;
567
+ let sumMinusDM = 0;
568
+ for (let i = 0; i < period; i++) {
569
+ sumTR += trueRanges[i];
570
+ sumPlusDM += plusDM[i];
571
+ sumMinusDM += minusDM[i];
572
+ }
573
+ smoothedTR.push(sumTR);
574
+ smoothedPlusDM.push(sumPlusDM);
575
+ smoothedMinusDM.push(sumMinusDM);
576
+ for (let i = period; i < trueRanges.length; i++) {
577
+ const newTR = smoothedTR[smoothedTR.length - 1] - smoothedTR[smoothedTR.length - 1] / period + trueRanges[i];
578
+ const newPlusDM = smoothedPlusDM[smoothedPlusDM.length - 1] - smoothedPlusDM[smoothedPlusDM.length - 1] / period + plusDM[i];
579
+ const newMinusDM = smoothedMinusDM[smoothedMinusDM.length - 1] - smoothedMinusDM[smoothedMinusDM.length - 1] / period + minusDM[i];
580
+ smoothedTR.push(newTR);
581
+ smoothedPlusDM.push(newPlusDM);
582
+ smoothedMinusDM.push(newMinusDM);
583
+ }
584
+ const plusDI = [];
585
+ const minusDI = [];
586
+ for (let i = 0; i < smoothedTR.length; i++) {
587
+ plusDI.push(smoothedPlusDM[i] / smoothedTR[i] * 100);
588
+ minusDI.push(smoothedMinusDM[i] / smoothedTR[i] * 100);
589
+ }
590
+ const dx = [];
591
+ for (let i = 0; i < plusDI.length; i++) {
592
+ const diSum = plusDI[i] + minusDI[i];
593
+ const diDiff = Math.abs(plusDI[i] - minusDI[i]);
594
+ dx.push(diSum > 0 ? diDiff / diSum * 100 : 0);
595
+ }
596
+ if (dx.length < period) return [];
597
+ let sumDX = 0;
598
+ for (let i = 0; i < period; i++) {
599
+ sumDX += dx[i];
600
+ }
601
+ adx.push(sumDX / period);
602
+ for (let i = period; i < dx.length; i++) {
603
+ const newADX = adx[adx.length - 1] - adx[adx.length - 1] / period + dx[i];
604
+ adx.push(newADX);
533
605
  }
534
606
  return adx;
535
607
  }
536
- // Calculate DMI
608
+ // Calculate DMI (Directional Movement Index)
537
609
  calculateDmi(prices, highs, lows) {
610
+ if (prices.length < 14) return [];
611
+ const period = 14;
538
612
  const dmi = [];
539
- for (let i = 14; i < prices.length; i++) {
613
+ const trueRanges = [];
614
+ const plusDM = [];
615
+ const minusDM = [];
616
+ trueRanges.push(highs[0] - lows[0]);
617
+ plusDM.push(0);
618
+ minusDM.push(0);
619
+ for (let i = 1; i < prices.length; i++) {
620
+ const high = highs[i] || prices[i];
621
+ const low = lows[i] || prices[i];
622
+ const prevHigh = highs[i - 1] || prices[i - 1];
623
+ const prevLow = lows[i - 1] || prices[i - 1];
624
+ const prevClose = prices[i - 1];
625
+ const tr1 = high - low;
626
+ const tr2 = Math.abs(high - prevClose);
627
+ const tr3 = Math.abs(low - prevClose);
628
+ trueRanges.push(Math.max(tr1, tr2, tr3));
629
+ const upMove = high - prevHigh;
630
+ const downMove = prevLow - low;
631
+ if (upMove > downMove && upMove > 0) {
632
+ plusDM.push(upMove);
633
+ minusDM.push(0);
634
+ } else if (downMove > upMove && downMove > 0) {
635
+ plusDM.push(0);
636
+ minusDM.push(downMove);
637
+ } else {
638
+ plusDM.push(0);
639
+ minusDM.push(0);
640
+ }
641
+ }
642
+ const smoothedTR = [];
643
+ const smoothedPlusDM = [];
644
+ const smoothedMinusDM = [];
645
+ let sumTR = 0;
646
+ let sumPlusDM = 0;
647
+ let sumMinusDM = 0;
648
+ for (let i = 0; i < period; i++) {
649
+ sumTR += trueRanges[i];
650
+ sumPlusDM += plusDM[i];
651
+ sumMinusDM += minusDM[i];
652
+ }
653
+ smoothedTR.push(sumTR);
654
+ smoothedPlusDM.push(sumPlusDM);
655
+ smoothedMinusDM.push(sumMinusDM);
656
+ for (let i = period; i < trueRanges.length; i++) {
657
+ const newTR = smoothedTR[smoothedTR.length - 1] - smoothedTR[smoothedTR.length - 1] / period + trueRanges[i];
658
+ const newPlusDM = smoothedPlusDM[smoothedPlusDM.length - 1] - smoothedPlusDM[smoothedPlusDM.length - 1] / period + plusDM[i];
659
+ const newMinusDM = smoothedMinusDM[smoothedMinusDM.length - 1] - smoothedMinusDM[smoothedMinusDM.length - 1] / period + minusDM[i];
660
+ smoothedTR.push(newTR);
661
+ smoothedPlusDM.push(newPlusDM);
662
+ smoothedMinusDM.push(newMinusDM);
663
+ }
664
+ const plusDI = [];
665
+ const minusDI = [];
666
+ for (let i = 0; i < smoothedTR.length; i++) {
667
+ plusDI.push(smoothedPlusDM[i] / smoothedTR[i] * 100);
668
+ minusDI.push(smoothedMinusDM[i] / smoothedTR[i] * 100);
669
+ }
670
+ const dx = [];
671
+ for (let i = 0; i < plusDI.length; i++) {
672
+ const diSum = plusDI[i] + minusDI[i];
673
+ const diDiff = Math.abs(plusDI[i] - minusDI[i]);
674
+ dx.push(diSum > 0 ? diDiff / diSum * 100 : 0);
675
+ }
676
+ if (dx.length < period) return [];
677
+ const adx = [];
678
+ let sumDX = 0;
679
+ for (let i = 0; i < period; i++) {
680
+ sumDX += dx[i];
681
+ }
682
+ adx.push(sumDX / period);
683
+ for (let i = period; i < dx.length; i++) {
684
+ const newADX = adx[adx.length - 1] - adx[adx.length - 1] / period + dx[i];
685
+ adx.push(newADX);
686
+ }
687
+ for (let i = 0; i < adx.length; i++) {
540
688
  dmi.push({
541
- plusDI: Math.random() * 50 + 25,
542
- minusDI: Math.random() * 50 + 25,
543
- adx: Math.random() * 50 + 25
689
+ plusDI: plusDI[i + period - 1] || 0,
690
+ minusDI: minusDI[i + period - 1] || 0,
691
+ adx: adx[i]
544
692
  });
545
693
  }
546
694
  return dmi;
547
695
  }
548
696
  // Calculate Ichimoku Cloud
549
697
  calculateIchimoku(prices, highs, lows) {
698
+ if (prices.length < 52) return [];
550
699
  const ichimoku = [];
700
+ const tenkanSen = [];
701
+ for (let i = 8; i < prices.length; i++) {
702
+ const periodHigh = Math.max(...highs.slice(i - 8, i + 1));
703
+ const periodLow = Math.min(...lows.slice(i - 8, i + 1));
704
+ tenkanSen.push((periodHigh + periodLow) / 2);
705
+ }
706
+ const kijunSen = [];
707
+ for (let i = 25; i < prices.length; i++) {
708
+ const periodHigh = Math.max(...highs.slice(i - 25, i + 1));
709
+ const periodLow = Math.min(...lows.slice(i - 25, i + 1));
710
+ kijunSen.push((periodHigh + periodLow) / 2);
711
+ }
712
+ const senkouSpanA = [];
713
+ for (let i = 0; i < Math.min(tenkanSen.length, kijunSen.length); i++) {
714
+ senkouSpanA.push((tenkanSen[i] + kijunSen[i]) / 2);
715
+ }
716
+ const senkouSpanB = [];
717
+ for (let i = 51; i < prices.length; i++) {
718
+ const periodHigh = Math.max(...highs.slice(i - 51, i + 1));
719
+ const periodLow = Math.min(...lows.slice(i - 51, i + 1));
720
+ senkouSpanB.push((periodHigh + periodLow) / 2);
721
+ }
722
+ const chikouSpan = [];
551
723
  for (let i = 26; i < prices.length; i++) {
724
+ chikouSpan.push(prices[i - 26]);
725
+ }
726
+ const minLength = Math.min(
727
+ tenkanSen.length,
728
+ kijunSen.length,
729
+ senkouSpanA.length,
730
+ senkouSpanB.length,
731
+ chikouSpan.length
732
+ );
733
+ for (let i = 0; i < minLength; i++) {
552
734
  ichimoku.push({
553
- tenkan: prices[i],
554
- kijun: prices[i],
555
- senkouA: prices[i],
556
- senkouB: prices[i],
557
- chikou: prices[i]
735
+ tenkan: tenkanSen[i],
736
+ kijun: kijunSen[i],
737
+ senkouA: senkouSpanA[i],
738
+ senkouB: senkouSpanB[i],
739
+ chikou: chikouSpan[i]
558
740
  });
559
741
  }
560
742
  return ichimoku;
561
743
  }
562
744
  // Calculate Parabolic SAR
563
745
  calculateParabolicSAR(prices, highs, lows) {
746
+ if (prices.length < 2) return [];
564
747
  const sar = [];
565
- for (let i = 0; i < prices.length; i++) {
566
- sar.push(prices[i] * 0.98);
748
+ const accelerationFactor = 0.02;
749
+ const maximumAcceleration = 0.2;
750
+ let currentSAR = lows[0];
751
+ let isLong = true;
752
+ let af = accelerationFactor;
753
+ let ep = highs[0];
754
+ sar.push(currentSAR);
755
+ for (let i = 1; i < prices.length; i++) {
756
+ const high = highs[i] || prices[i];
757
+ const low = lows[i] || prices[i];
758
+ if (isLong) {
759
+ if (low < currentSAR) {
760
+ isLong = false;
761
+ currentSAR = ep;
762
+ ep = low;
763
+ af = accelerationFactor;
764
+ } else {
765
+ if (high > ep) {
766
+ ep = high;
767
+ af = Math.min(af + accelerationFactor, maximumAcceleration);
768
+ }
769
+ currentSAR = currentSAR + af * (ep - currentSAR);
770
+ if (i > 0) {
771
+ const prevLow = lows[i - 1] || prices[i - 1];
772
+ currentSAR = Math.min(currentSAR, prevLow);
773
+ }
774
+ }
775
+ } else {
776
+ if (high > currentSAR) {
777
+ isLong = true;
778
+ currentSAR = ep;
779
+ ep = high;
780
+ af = accelerationFactor;
781
+ } else {
782
+ if (low < ep) {
783
+ ep = low;
784
+ af = Math.min(af + accelerationFactor, maximumAcceleration);
785
+ }
786
+ currentSAR = currentSAR + af * (ep - currentSAR);
787
+ if (i > 0) {
788
+ const prevHigh = highs[i - 1] || prices[i - 1];
789
+ currentSAR = Math.max(currentSAR, prevHigh);
790
+ }
791
+ }
792
+ }
793
+ sar.push(currentSAR);
567
794
  }
568
795
  return sar;
569
796
  }
@@ -906,7 +1133,7 @@ var TechnicalAnalyzer = class {
906
1133
  const momentum5 = this.prices.length > 5 ? (currentPrice - this.prices[Math.max(0, this.prices.length - 6)]) / this.prices[Math.max(0, this.prices.length - 6)] * 100 : 0;
907
1134
  const momentum10 = this.prices.length > 10 ? (currentPrice - this.prices[Math.max(0, this.prices.length - 11)]) / this.prices[Math.max(0, this.prices.length - 11)] * 100 : 0;
908
1135
  const maxDrawdown = this.calculateMaxDrawdown(this.prices);
909
- const atrValues = this.calculateAtr(this.prices, this.highs, this.lows, this.volumes);
1136
+ const atrValues = this.calculateAtr(this.prices, this.highs, this.lows);
910
1137
  const atr = atrValues.length > 0 ? atrValues[atrValues.length - 1] : 0;
911
1138
  const impliedVolatility = volatility;
912
1139
  const realizedVolatility = volatility;
@@ -967,7 +1194,7 @@ var TechnicalAnalyzer = class {
967
1194
  williamsR: this.calculateWilliamsR(this.prices),
968
1195
  momentum: this.calculateMomentum(this.prices),
969
1196
  bollinger: this.calculateBollingerBands(this.prices, 20, 2),
970
- atr: this.calculateAtr(this.prices, this.highs, this.lows, this.volumes),
1197
+ atr: this.calculateAtr(this.prices, this.highs, this.lows),
971
1198
  keltner: this.calculateKeltnerChannels(this.prices, this.highs, this.lows),
972
1199
  donchian: this.calculateDonchianChannels(this.prices, this.highs, this.lows),
973
1200
  chaikinVolatility: this.calculateChaikinVolatility(this.prices, this.highs, this.lows),
@@ -1666,6 +1893,7 @@ var createGetStockPriceHistoryHandler = (marketDataPrices) => {
1666
1893
  ]
1667
1894
  };
1668
1895
  }
1896
+ const aggregatedData = aggregateMarketData(priceHistory, 500);
1669
1897
  return {
1670
1898
  content: [
1671
1899
  {
@@ -1673,8 +1901,9 @@ var createGetStockPriceHistoryHandler = (marketDataPrices) => {
1673
1901
  text: JSON.stringify(
1674
1902
  {
1675
1903
  symbol,
1676
- count: priceHistory.length,
1677
- data: priceHistory.map((point) => ({
1904
+ count: aggregatedData.length,
1905
+ originalCount: priceHistory.length,
1906
+ data: aggregatedData.map((point) => ({
1678
1907
  timestamp: new Date(point.timestamp).toISOString(),
1679
1908
  bid: point.bid,
1680
1909
  offer: point.offer,
@@ -1816,6 +2045,7 @@ var handlInstNames = {
1816
2045
  };
1817
2046
  var createVerifyOrderHandler = (parser, verifiedOrders) => {
1818
2047
  return async (args) => {
2048
+ void parser;
1819
2049
  try {
1820
2050
  verifiedOrders.set(args.clOrdID, {
1821
2051
  clOrdID: args.clOrdID,
@@ -2049,6 +2279,7 @@ function getEnumValue(enumObj, name) {
2049
2279
  return enumObj[name] || name;
2050
2280
  }
2051
2281
  function handleMessage(message, parser, pendingRequests, marketDataPrices, maxPriceHistory, onPriceUpdate) {
2282
+ void parser;
2052
2283
  const msgType = message.messageType;
2053
2284
  if (msgType === import_fixparser3.Messages.MarketDataSnapshotFullRefresh || msgType === import_fixparser3.Messages.MarketDataIncrementalRefresh) {
2054
2285
  const symbol = message.getField(import_fixparser3.Fields.Symbol)?.value;