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