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.
@@ -380,7 +380,7 @@ var TechnicalAnalyzer = class {
380
380
  return maxDrawdown;
381
381
  }
382
382
  // Calculate Average True Range (ATR)
383
- calculateAtr(prices, highs, lows, volumes) {
383
+ calculateAtr(prices, highs, lows) {
384
384
  if (prices.length < 2) return [];
385
385
  const trueRanges = [];
386
386
  for (let i = 1; i < prices.length; i++) {
@@ -491,45 +491,272 @@ var TechnicalAnalyzer = class {
491
491
  }
492
492
  return macd;
493
493
  }
494
- // Calculate ADX
494
+ // Calculate ADX (Average Directional Index)
495
495
  calculateAdx(prices, highs, lows) {
496
+ if (prices.length < 14) return [];
497
+ const period = 14;
496
498
  const adx = [];
497
- for (let i = 14; i < prices.length; i++) {
498
- adx.push(Math.random() * 50 + 25);
499
+ const trueRanges = [];
500
+ const plusDM = [];
501
+ const minusDM = [];
502
+ trueRanges.push(highs[0] - lows[0]);
503
+ plusDM.push(0);
504
+ minusDM.push(0);
505
+ for (let i = 1; i < prices.length; i++) {
506
+ const high = highs[i] || prices[i];
507
+ const low = lows[i] || prices[i];
508
+ const prevHigh = highs[i - 1] || prices[i - 1];
509
+ const prevLow = lows[i - 1] || prices[i - 1];
510
+ const prevClose = prices[i - 1];
511
+ const tr1 = high - low;
512
+ const tr2 = Math.abs(high - prevClose);
513
+ const tr3 = Math.abs(low - prevClose);
514
+ trueRanges.push(Math.max(tr1, tr2, tr3));
515
+ const upMove = high - prevHigh;
516
+ const downMove = prevLow - low;
517
+ if (upMove > downMove && upMove > 0) {
518
+ plusDM.push(upMove);
519
+ minusDM.push(0);
520
+ } else if (downMove > upMove && downMove > 0) {
521
+ plusDM.push(0);
522
+ minusDM.push(downMove);
523
+ } else {
524
+ plusDM.push(0);
525
+ minusDM.push(0);
526
+ }
527
+ }
528
+ const smoothedTR = [];
529
+ const smoothedPlusDM = [];
530
+ const smoothedMinusDM = [];
531
+ let sumTR = 0;
532
+ let sumPlusDM = 0;
533
+ let sumMinusDM = 0;
534
+ for (let i = 0; i < period; i++) {
535
+ sumTR += trueRanges[i];
536
+ sumPlusDM += plusDM[i];
537
+ sumMinusDM += minusDM[i];
538
+ }
539
+ smoothedTR.push(sumTR);
540
+ smoothedPlusDM.push(sumPlusDM);
541
+ smoothedMinusDM.push(sumMinusDM);
542
+ for (let i = period; i < trueRanges.length; i++) {
543
+ const newTR = smoothedTR[smoothedTR.length - 1] - smoothedTR[smoothedTR.length - 1] / period + trueRanges[i];
544
+ const newPlusDM = smoothedPlusDM[smoothedPlusDM.length - 1] - smoothedPlusDM[smoothedPlusDM.length - 1] / period + plusDM[i];
545
+ const newMinusDM = smoothedMinusDM[smoothedMinusDM.length - 1] - smoothedMinusDM[smoothedMinusDM.length - 1] / period + minusDM[i];
546
+ smoothedTR.push(newTR);
547
+ smoothedPlusDM.push(newPlusDM);
548
+ smoothedMinusDM.push(newMinusDM);
549
+ }
550
+ const plusDI = [];
551
+ const minusDI = [];
552
+ for (let i = 0; i < smoothedTR.length; i++) {
553
+ plusDI.push(smoothedPlusDM[i] / smoothedTR[i] * 100);
554
+ minusDI.push(smoothedMinusDM[i] / smoothedTR[i] * 100);
555
+ }
556
+ const dx = [];
557
+ for (let i = 0; i < plusDI.length; i++) {
558
+ const diSum = plusDI[i] + minusDI[i];
559
+ const diDiff = Math.abs(plusDI[i] - minusDI[i]);
560
+ dx.push(diSum > 0 ? diDiff / diSum * 100 : 0);
561
+ }
562
+ if (dx.length < period) return [];
563
+ let sumDX = 0;
564
+ for (let i = 0; i < period; i++) {
565
+ sumDX += dx[i];
566
+ }
567
+ adx.push(sumDX / period);
568
+ for (let i = period; i < dx.length; i++) {
569
+ const newADX = adx[adx.length - 1] - adx[adx.length - 1] / period + dx[i];
570
+ adx.push(newADX);
499
571
  }
500
572
  return adx;
501
573
  }
502
- // Calculate DMI
574
+ // Calculate DMI (Directional Movement Index)
503
575
  calculateDmi(prices, highs, lows) {
576
+ if (prices.length < 14) return [];
577
+ const period = 14;
504
578
  const dmi = [];
505
- for (let i = 14; i < prices.length; i++) {
579
+ const trueRanges = [];
580
+ const plusDM = [];
581
+ const minusDM = [];
582
+ trueRanges.push(highs[0] - lows[0]);
583
+ plusDM.push(0);
584
+ minusDM.push(0);
585
+ for (let i = 1; i < prices.length; i++) {
586
+ const high = highs[i] || prices[i];
587
+ const low = lows[i] || prices[i];
588
+ const prevHigh = highs[i - 1] || prices[i - 1];
589
+ const prevLow = lows[i - 1] || prices[i - 1];
590
+ const prevClose = prices[i - 1];
591
+ const tr1 = high - low;
592
+ const tr2 = Math.abs(high - prevClose);
593
+ const tr3 = Math.abs(low - prevClose);
594
+ trueRanges.push(Math.max(tr1, tr2, tr3));
595
+ const upMove = high - prevHigh;
596
+ const downMove = prevLow - low;
597
+ if (upMove > downMove && upMove > 0) {
598
+ plusDM.push(upMove);
599
+ minusDM.push(0);
600
+ } else if (downMove > upMove && downMove > 0) {
601
+ plusDM.push(0);
602
+ minusDM.push(downMove);
603
+ } else {
604
+ plusDM.push(0);
605
+ minusDM.push(0);
606
+ }
607
+ }
608
+ const smoothedTR = [];
609
+ const smoothedPlusDM = [];
610
+ const smoothedMinusDM = [];
611
+ let sumTR = 0;
612
+ let sumPlusDM = 0;
613
+ let sumMinusDM = 0;
614
+ for (let i = 0; i < period; i++) {
615
+ sumTR += trueRanges[i];
616
+ sumPlusDM += plusDM[i];
617
+ sumMinusDM += minusDM[i];
618
+ }
619
+ smoothedTR.push(sumTR);
620
+ smoothedPlusDM.push(sumPlusDM);
621
+ smoothedMinusDM.push(sumMinusDM);
622
+ for (let i = period; i < trueRanges.length; i++) {
623
+ const newTR = smoothedTR[smoothedTR.length - 1] - smoothedTR[smoothedTR.length - 1] / period + trueRanges[i];
624
+ const newPlusDM = smoothedPlusDM[smoothedPlusDM.length - 1] - smoothedPlusDM[smoothedPlusDM.length - 1] / period + plusDM[i];
625
+ const newMinusDM = smoothedMinusDM[smoothedMinusDM.length - 1] - smoothedMinusDM[smoothedMinusDM.length - 1] / period + minusDM[i];
626
+ smoothedTR.push(newTR);
627
+ smoothedPlusDM.push(newPlusDM);
628
+ smoothedMinusDM.push(newMinusDM);
629
+ }
630
+ const plusDI = [];
631
+ const minusDI = [];
632
+ for (let i = 0; i < smoothedTR.length; i++) {
633
+ plusDI.push(smoothedPlusDM[i] / smoothedTR[i] * 100);
634
+ minusDI.push(smoothedMinusDM[i] / smoothedTR[i] * 100);
635
+ }
636
+ const dx = [];
637
+ for (let i = 0; i < plusDI.length; i++) {
638
+ const diSum = plusDI[i] + minusDI[i];
639
+ const diDiff = Math.abs(plusDI[i] - minusDI[i]);
640
+ dx.push(diSum > 0 ? diDiff / diSum * 100 : 0);
641
+ }
642
+ if (dx.length < period) return [];
643
+ const adx = [];
644
+ let sumDX = 0;
645
+ for (let i = 0; i < period; i++) {
646
+ sumDX += dx[i];
647
+ }
648
+ adx.push(sumDX / period);
649
+ for (let i = period; i < dx.length; i++) {
650
+ const newADX = adx[adx.length - 1] - adx[adx.length - 1] / period + dx[i];
651
+ adx.push(newADX);
652
+ }
653
+ for (let i = 0; i < adx.length; i++) {
506
654
  dmi.push({
507
- plusDI: Math.random() * 50 + 25,
508
- minusDI: Math.random() * 50 + 25,
509
- adx: Math.random() * 50 + 25
655
+ plusDI: plusDI[i + period - 1] || 0,
656
+ minusDI: minusDI[i + period - 1] || 0,
657
+ adx: adx[i]
510
658
  });
511
659
  }
512
660
  return dmi;
513
661
  }
514
662
  // Calculate Ichimoku Cloud
515
663
  calculateIchimoku(prices, highs, lows) {
664
+ if (prices.length < 52) return [];
516
665
  const ichimoku = [];
666
+ const tenkanSen = [];
667
+ for (let i = 8; i < prices.length; i++) {
668
+ const periodHigh = Math.max(...highs.slice(i - 8, i + 1));
669
+ const periodLow = Math.min(...lows.slice(i - 8, i + 1));
670
+ tenkanSen.push((periodHigh + periodLow) / 2);
671
+ }
672
+ const kijunSen = [];
673
+ for (let i = 25; i < prices.length; i++) {
674
+ const periodHigh = Math.max(...highs.slice(i - 25, i + 1));
675
+ const periodLow = Math.min(...lows.slice(i - 25, i + 1));
676
+ kijunSen.push((periodHigh + periodLow) / 2);
677
+ }
678
+ const senkouSpanA = [];
679
+ for (let i = 0; i < Math.min(tenkanSen.length, kijunSen.length); i++) {
680
+ senkouSpanA.push((tenkanSen[i] + kijunSen[i]) / 2);
681
+ }
682
+ const senkouSpanB = [];
683
+ for (let i = 51; i < prices.length; i++) {
684
+ const periodHigh = Math.max(...highs.slice(i - 51, i + 1));
685
+ const periodLow = Math.min(...lows.slice(i - 51, i + 1));
686
+ senkouSpanB.push((periodHigh + periodLow) / 2);
687
+ }
688
+ const chikouSpan = [];
517
689
  for (let i = 26; i < prices.length; i++) {
690
+ chikouSpan.push(prices[i - 26]);
691
+ }
692
+ const minLength = Math.min(
693
+ tenkanSen.length,
694
+ kijunSen.length,
695
+ senkouSpanA.length,
696
+ senkouSpanB.length,
697
+ chikouSpan.length
698
+ );
699
+ for (let i = 0; i < minLength; i++) {
518
700
  ichimoku.push({
519
- tenkan: prices[i],
520
- kijun: prices[i],
521
- senkouA: prices[i],
522
- senkouB: prices[i],
523
- chikou: prices[i]
701
+ tenkan: tenkanSen[i],
702
+ kijun: kijunSen[i],
703
+ senkouA: senkouSpanA[i],
704
+ senkouB: senkouSpanB[i],
705
+ chikou: chikouSpan[i]
524
706
  });
525
707
  }
526
708
  return ichimoku;
527
709
  }
528
710
  // Calculate Parabolic SAR
529
711
  calculateParabolicSAR(prices, highs, lows) {
712
+ if (prices.length < 2) return [];
530
713
  const sar = [];
531
- for (let i = 0; i < prices.length; i++) {
532
- sar.push(prices[i] * 0.98);
714
+ const accelerationFactor = 0.02;
715
+ const maximumAcceleration = 0.2;
716
+ let currentSAR = lows[0];
717
+ let isLong = true;
718
+ let af = accelerationFactor;
719
+ let ep = highs[0];
720
+ sar.push(currentSAR);
721
+ for (let i = 1; i < prices.length; i++) {
722
+ const high = highs[i] || prices[i];
723
+ const low = lows[i] || prices[i];
724
+ if (isLong) {
725
+ if (low < currentSAR) {
726
+ isLong = false;
727
+ currentSAR = ep;
728
+ ep = low;
729
+ af = accelerationFactor;
730
+ } else {
731
+ if (high > ep) {
732
+ ep = high;
733
+ af = Math.min(af + accelerationFactor, maximumAcceleration);
734
+ }
735
+ currentSAR = currentSAR + af * (ep - currentSAR);
736
+ if (i > 0) {
737
+ const prevLow = lows[i - 1] || prices[i - 1];
738
+ currentSAR = Math.min(currentSAR, prevLow);
739
+ }
740
+ }
741
+ } else {
742
+ if (high > currentSAR) {
743
+ isLong = true;
744
+ currentSAR = ep;
745
+ ep = high;
746
+ af = accelerationFactor;
747
+ } else {
748
+ if (low < ep) {
749
+ ep = low;
750
+ af = Math.min(af + accelerationFactor, maximumAcceleration);
751
+ }
752
+ currentSAR = currentSAR + af * (ep - currentSAR);
753
+ if (i > 0) {
754
+ const prevHigh = highs[i - 1] || prices[i - 1];
755
+ currentSAR = Math.max(currentSAR, prevHigh);
756
+ }
757
+ }
758
+ }
759
+ sar.push(currentSAR);
533
760
  }
534
761
  return sar;
535
762
  }
@@ -872,7 +1099,7 @@ var TechnicalAnalyzer = class {
872
1099
  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;
873
1100
  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;
874
1101
  const maxDrawdown = this.calculateMaxDrawdown(this.prices);
875
- const atrValues = this.calculateAtr(this.prices, this.highs, this.lows, this.volumes);
1102
+ const atrValues = this.calculateAtr(this.prices, this.highs, this.lows);
876
1103
  const atr = atrValues.length > 0 ? atrValues[atrValues.length - 1] : 0;
877
1104
  const impliedVolatility = volatility;
878
1105
  const realizedVolatility = volatility;
@@ -933,7 +1160,7 @@ var TechnicalAnalyzer = class {
933
1160
  williamsR: this.calculateWilliamsR(this.prices),
934
1161
  momentum: this.calculateMomentum(this.prices),
935
1162
  bollinger: this.calculateBollingerBands(this.prices, 20, 2),
936
- atr: this.calculateAtr(this.prices, this.highs, this.lows, this.volumes),
1163
+ atr: this.calculateAtr(this.prices, this.highs, this.lows),
937
1164
  keltner: this.calculateKeltnerChannels(this.prices, this.highs, this.lows),
938
1165
  donchian: this.calculateDonchianChannels(this.prices, this.highs, this.lows),
939
1166
  chaikinVolatility: this.calculateChaikinVolatility(this.prices, this.highs, this.lows),
@@ -1632,6 +1859,7 @@ var createGetStockPriceHistoryHandler = (marketDataPrices) => {
1632
1859
  ]
1633
1860
  };
1634
1861
  }
1862
+ const aggregatedData = aggregateMarketData(priceHistory, 500);
1635
1863
  return {
1636
1864
  content: [
1637
1865
  {
@@ -1639,8 +1867,9 @@ var createGetStockPriceHistoryHandler = (marketDataPrices) => {
1639
1867
  text: JSON.stringify(
1640
1868
  {
1641
1869
  symbol,
1642
- count: priceHistory.length,
1643
- data: priceHistory.map((point) => ({
1870
+ count: aggregatedData.length,
1871
+ originalCount: priceHistory.length,
1872
+ data: aggregatedData.map((point) => ({
1644
1873
  timestamp: new Date(point.timestamp).toISOString(),
1645
1874
  bid: point.bid,
1646
1875
  offer: point.offer,
@@ -1782,6 +2011,7 @@ var handlInstNames = {
1782
2011
  };
1783
2012
  var createVerifyOrderHandler = (parser, verifiedOrders) => {
1784
2013
  return async (args) => {
2014
+ void parser;
1785
2015
  try {
1786
2016
  verifiedOrders.set(args.clOrdID, {
1787
2017
  clOrdID: args.clOrdID,
@@ -2015,6 +2245,7 @@ function getEnumValue(enumObj, name) {
2015
2245
  return enumObj[name] || name;
2016
2246
  }
2017
2247
  function handleMessage(message, parser, pendingRequests, marketDataPrices, maxPriceHistory, onPriceUpdate) {
2248
+ void parser;
2018
2249
  const msgType = message.messageType;
2019
2250
  if (msgType === Messages3.MarketDataSnapshotFullRefresh || msgType === Messages3.MarketDataIncrementalRefresh) {
2020
2251
  const symbol = message.getField(Fields3.Symbol)?.value;