fixparser-plugin-mcp 9.1.7-4e8fe3d5 → 9.1.7-52ccb1d5

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.
@@ -285,7 +285,52 @@ var createMarketDataRequestHandler = (parser, pendingRequests) => {
285
285
  const response = new Promise((resolve) => {
286
286
  pendingRequests.set(args.mdReqID, resolve);
287
287
  });
288
- const entryTypes = args.mdEntryTypes || [MDEntryType.Bid, MDEntryType.Offer, MDEntryType.TradeVolume];
288
+ const entryTypes = args.mdEntryTypes || [
289
+ MDEntryType.Bid,
290
+ MDEntryType.Offer,
291
+ MDEntryType.Trade,
292
+ MDEntryType.IndexValue,
293
+ MDEntryType.OpeningPrice,
294
+ MDEntryType.ClosingPrice,
295
+ MDEntryType.SettlementPrice,
296
+ MDEntryType.TradingSessionHighPrice,
297
+ MDEntryType.TradingSessionLowPrice,
298
+ MDEntryType.VWAP,
299
+ MDEntryType.Imbalance,
300
+ MDEntryType.TradeVolume,
301
+ MDEntryType.OpenInterest,
302
+ MDEntryType.CompositeUnderlyingPrice,
303
+ MDEntryType.SimulatedSellPrice,
304
+ MDEntryType.SimulatedBuyPrice,
305
+ MDEntryType.MarginRate,
306
+ MDEntryType.MidPrice,
307
+ MDEntryType.EmptyBook,
308
+ MDEntryType.SettleHighPrice,
309
+ MDEntryType.SettleLowPrice,
310
+ MDEntryType.PriorSettlePrice,
311
+ MDEntryType.SessionHighBid,
312
+ MDEntryType.SessionLowOffer,
313
+ MDEntryType.EarlyPrices,
314
+ MDEntryType.AuctionClearingPrice,
315
+ MDEntryType.SwapValueFactor,
316
+ MDEntryType.DailyValueAdjustmentForLongPositions,
317
+ MDEntryType.CumulativeValueAdjustmentForLongPositions,
318
+ MDEntryType.DailyValueAdjustmentForShortPositions,
319
+ MDEntryType.CumulativeValueAdjustmentForShortPositions,
320
+ MDEntryType.FixingPrice,
321
+ MDEntryType.CashRate,
322
+ MDEntryType.RecoveryRate,
323
+ MDEntryType.RecoveryRateForLong,
324
+ MDEntryType.RecoveryRateForShort,
325
+ MDEntryType.MarketBid,
326
+ MDEntryType.MarketOffer,
327
+ MDEntryType.ShortSaleMinPrice,
328
+ MDEntryType.PreviousClosingPrice,
329
+ MDEntryType.ThresholdLimitPriceBanding,
330
+ MDEntryType.DailyFinancingValue,
331
+ MDEntryType.AccruedFinancingValue,
332
+ MDEntryType.TWAP
333
+ ];
289
334
  const messageFields = [
290
335
  new Field(Fields.MsgType, Messages.MarketDataRequest),
291
336
  new Field(Fields.SenderCompID, parser.sender),
@@ -368,6 +413,9 @@ var createGetStockGraphHandler = (marketDataPrices) => {
368
413
  const offerData = priceHistory.map((point) => point.offer);
369
414
  const spreadData = priceHistory.map((point) => point.spread);
370
415
  const volumeData = priceHistory.map((point) => point.volume);
416
+ const tradeData = priceHistory.map((point) => point.trade);
417
+ const vwapData = priceHistory.map((point) => point.vwap);
418
+ const twapData = priceHistory.map((point) => point.twap);
371
419
  const config = {
372
420
  type: "line",
373
421
  data: {
@@ -397,6 +445,30 @@ var createGetStockGraphHandler = (marketDataPrices) => {
397
445
  fill: false,
398
446
  tension: 0.4
399
447
  },
448
+ {
449
+ label: "Trade",
450
+ data: tradeData,
451
+ borderColor: "#ffc107",
452
+ backgroundColor: "rgba(255, 193, 7, 0.1)",
453
+ fill: false,
454
+ tension: 0.4
455
+ },
456
+ {
457
+ label: "VWAP",
458
+ data: vwapData,
459
+ borderColor: "#17a2b8",
460
+ backgroundColor: "rgba(23, 162, 184, 0.1)",
461
+ fill: false,
462
+ tension: 0.4
463
+ },
464
+ {
465
+ label: "TWAP",
466
+ data: twapData,
467
+ borderColor: "#6610f2",
468
+ backgroundColor: "rgba(102, 16, 242, 0.1)",
469
+ fill: false,
470
+ tension: 0.4
471
+ },
400
472
  {
401
473
  label: "Volume",
402
474
  data: volumeData,
@@ -442,7 +514,7 @@ var createGetStockGraphHandler = (marketDataPrices) => {
442
514
  content: [
443
515
  {
444
516
  type: "text",
445
- text: `Error: ${error instanceof Error ? error.message : "Failed to generate chart"}`,
517
+ text: `Error: ${error instanceof Error ? error.message : "Failed to generate graph"}`,
446
518
  uri: "getStockGraph"
447
519
  }
448
520
  ],
@@ -480,7 +552,48 @@ var createGetStockPriceHistoryHandler = (marketDataPrices) => {
480
552
  bid: point.bid,
481
553
  offer: point.offer,
482
554
  spread: point.spread,
483
- volume: point.volume
555
+ volume: point.volume,
556
+ trade: point.trade,
557
+ indexValue: point.indexValue,
558
+ openingPrice: point.openingPrice,
559
+ closingPrice: point.closingPrice,
560
+ settlementPrice: point.settlementPrice,
561
+ tradingSessionHighPrice: point.tradingSessionHighPrice,
562
+ tradingSessionLowPrice: point.tradingSessionLowPrice,
563
+ vwap: point.vwap,
564
+ imbalance: point.imbalance,
565
+ openInterest: point.openInterest,
566
+ compositeUnderlyingPrice: point.compositeUnderlyingPrice,
567
+ simulatedSellPrice: point.simulatedSellPrice,
568
+ simulatedBuyPrice: point.simulatedBuyPrice,
569
+ marginRate: point.marginRate,
570
+ midPrice: point.midPrice,
571
+ emptyBook: point.emptyBook,
572
+ settleHighPrice: point.settleHighPrice,
573
+ settleLowPrice: point.settleLowPrice,
574
+ priorSettlePrice: point.priorSettlePrice,
575
+ sessionHighBid: point.sessionHighBid,
576
+ sessionLowOffer: point.sessionLowOffer,
577
+ earlyPrices: point.earlyPrices,
578
+ auctionClearingPrice: point.auctionClearingPrice,
579
+ swapValueFactor: point.swapValueFactor,
580
+ dailyValueAdjustmentForLongPositions: point.dailyValueAdjustmentForLongPositions,
581
+ cumulativeValueAdjustmentForLongPositions: point.cumulativeValueAdjustmentForLongPositions,
582
+ dailyValueAdjustmentForShortPositions: point.dailyValueAdjustmentForShortPositions,
583
+ cumulativeValueAdjustmentForShortPositions: point.cumulativeValueAdjustmentForShortPositions,
584
+ fixingPrice: point.fixingPrice,
585
+ cashRate: point.cashRate,
586
+ recoveryRate: point.recoveryRate,
587
+ recoveryRateForLong: point.recoveryRateForLong,
588
+ recoveryRateForShort: point.recoveryRateForShort,
589
+ marketBid: point.marketBid,
590
+ marketOffer: point.marketOffer,
591
+ shortSaleMinPrice: point.shortSaleMinPrice,
592
+ previousClosingPrice: point.previousClosingPrice,
593
+ thresholdLimitPriceBanding: point.thresholdLimitPriceBanding,
594
+ dailyFinancingValue: point.dailyFinancingValue,
595
+ accruedFinancingValue: point.accruedFinancingValue,
596
+ twap: point.twap
484
597
  }))
485
598
  },
486
599
  null,
@@ -495,7 +608,7 @@ var createGetStockPriceHistoryHandler = (marketDataPrices) => {
495
608
  content: [
496
609
  {
497
610
  type: "text",
498
- text: `Error: ${error instanceof Error ? error.message : "Failed to get stock price history"}`,
611
+ text: `Error: ${error instanceof Error ? error.message : "Failed to get price history"}`,
499
612
  uri: "getStockPriceHistory"
500
613
  }
501
614
  ],
@@ -810,37 +923,198 @@ function handleMessage(message, parser, pendingRequests, marketDataPrices, maxPr
810
923
  message: `MCP Server received message: ${message.messageType}: ${message.description}`
811
924
  });
812
925
  const msgType = message.messageType;
813
- if (msgType === Messages3.MarketDataSnapshotFullRefresh) {
926
+ if (msgType === Messages3.MarketDataSnapshotFullRefresh || msgType === Messages3.MarketDataIncrementalRefresh) {
814
927
  const symbol = message.getField(Fields3.Symbol)?.value;
815
- const entries = message.getField(Fields3.NoMDEntries)?.value;
816
- let bid = 0;
817
- let offer = 0;
818
- let volume = 0;
819
- const entryTypes = message.getFields(Fields3.MDEntryType);
820
- const entryPrices = message.getFields(Fields3.MDEntryPx);
821
- const entrySizes = message.getFields(Fields3.MDEntrySize);
822
- if (entryTypes && entryPrices && entrySizes) {
823
- for (let i = 0; i < entries; i++) {
824
- const entryType = entryTypes[i]?.value;
825
- const entryPrice = Number.parseFloat(entryPrices[i]?.value);
826
- const entrySize = Number.parseFloat(entrySizes[i]?.value);
827
- if (entryType === MDEntryType2.Bid) {
828
- bid = entryPrice;
829
- } else if (entryType === MDEntryType2.Offer) {
830
- offer = entryPrice;
831
- }
832
- volume += entrySize;
833
- }
834
- }
835
- const spread = offer - bid;
836
- const timestamp = Date.now();
928
+ const fixJson = message.toFIXJSON();
929
+ const entries = fixJson.Body?.NoMDEntries || [];
837
930
  const data = {
838
- timestamp,
839
- bid,
840
- offer,
841
- spread,
842
- volume
931
+ timestamp: Date.now(),
932
+ bid: 0,
933
+ offer: 0,
934
+ spread: 0,
935
+ volume: 0,
936
+ trade: 0,
937
+ indexValue: 0,
938
+ openingPrice: 0,
939
+ closingPrice: 0,
940
+ settlementPrice: 0,
941
+ tradingSessionHighPrice: 0,
942
+ tradingSessionLowPrice: 0,
943
+ vwap: 0,
944
+ imbalance: 0,
945
+ openInterest: 0,
946
+ compositeUnderlyingPrice: 0,
947
+ simulatedSellPrice: 0,
948
+ simulatedBuyPrice: 0,
949
+ marginRate: 0,
950
+ midPrice: 0,
951
+ emptyBook: 0,
952
+ settleHighPrice: 0,
953
+ settleLowPrice: 0,
954
+ priorSettlePrice: 0,
955
+ sessionHighBid: 0,
956
+ sessionLowOffer: 0,
957
+ earlyPrices: 0,
958
+ auctionClearingPrice: 0,
959
+ swapValueFactor: 0,
960
+ dailyValueAdjustmentForLongPositions: 0,
961
+ cumulativeValueAdjustmentForLongPositions: 0,
962
+ dailyValueAdjustmentForShortPositions: 0,
963
+ cumulativeValueAdjustmentForShortPositions: 0,
964
+ fixingPrice: 0,
965
+ cashRate: 0,
966
+ recoveryRate: 0,
967
+ recoveryRateForLong: 0,
968
+ recoveryRateForShort: 0,
969
+ marketBid: 0,
970
+ marketOffer: 0,
971
+ shortSaleMinPrice: 0,
972
+ previousClosingPrice: 0,
973
+ thresholdLimitPriceBanding: 0,
974
+ dailyFinancingValue: 0,
975
+ accruedFinancingValue: 0,
976
+ twap: 0
843
977
  };
978
+ for (const entry of entries) {
979
+ const entryType = entry.MDEntryType;
980
+ const price = entry.MDEntryPx ? Number.parseFloat(entry.MDEntryPx) : 0;
981
+ const size = entry.MDEntrySize ? Number.parseFloat(entry.MDEntrySize) : 0;
982
+ switch (entryType) {
983
+ case MDEntryType2.Bid:
984
+ data.bid = price;
985
+ break;
986
+ case MDEntryType2.Offer:
987
+ data.offer = price;
988
+ break;
989
+ case MDEntryType2.Trade:
990
+ data.trade = price;
991
+ break;
992
+ case MDEntryType2.IndexValue:
993
+ data.indexValue = price;
994
+ break;
995
+ case MDEntryType2.OpeningPrice:
996
+ data.openingPrice = price;
997
+ break;
998
+ case MDEntryType2.ClosingPrice:
999
+ data.closingPrice = price;
1000
+ break;
1001
+ case MDEntryType2.SettlementPrice:
1002
+ data.settlementPrice = price;
1003
+ break;
1004
+ case MDEntryType2.TradingSessionHighPrice:
1005
+ data.tradingSessionHighPrice = price;
1006
+ break;
1007
+ case MDEntryType2.TradingSessionLowPrice:
1008
+ data.tradingSessionLowPrice = price;
1009
+ break;
1010
+ case MDEntryType2.VWAP:
1011
+ data.vwap = price;
1012
+ break;
1013
+ case MDEntryType2.Imbalance:
1014
+ data.imbalance = size;
1015
+ break;
1016
+ case MDEntryType2.TradeVolume:
1017
+ data.volume = size;
1018
+ break;
1019
+ case MDEntryType2.OpenInterest:
1020
+ data.openInterest = size;
1021
+ break;
1022
+ case MDEntryType2.CompositeUnderlyingPrice:
1023
+ data.compositeUnderlyingPrice = price;
1024
+ break;
1025
+ case MDEntryType2.SimulatedSellPrice:
1026
+ data.simulatedSellPrice = price;
1027
+ break;
1028
+ case MDEntryType2.SimulatedBuyPrice:
1029
+ data.simulatedBuyPrice = price;
1030
+ break;
1031
+ case MDEntryType2.MarginRate:
1032
+ data.marginRate = price;
1033
+ break;
1034
+ case MDEntryType2.MidPrice:
1035
+ data.midPrice = price;
1036
+ break;
1037
+ case MDEntryType2.EmptyBook:
1038
+ data.emptyBook = 1;
1039
+ break;
1040
+ case MDEntryType2.SettleHighPrice:
1041
+ data.settleHighPrice = price;
1042
+ break;
1043
+ case MDEntryType2.SettleLowPrice:
1044
+ data.settleLowPrice = price;
1045
+ break;
1046
+ case MDEntryType2.PriorSettlePrice:
1047
+ data.priorSettlePrice = price;
1048
+ break;
1049
+ case MDEntryType2.SessionHighBid:
1050
+ data.sessionHighBid = price;
1051
+ break;
1052
+ case MDEntryType2.SessionLowOffer:
1053
+ data.sessionLowOffer = price;
1054
+ break;
1055
+ case MDEntryType2.EarlyPrices:
1056
+ data.earlyPrices = price;
1057
+ break;
1058
+ case MDEntryType2.AuctionClearingPrice:
1059
+ data.auctionClearingPrice = price;
1060
+ break;
1061
+ case MDEntryType2.SwapValueFactor:
1062
+ data.swapValueFactor = price;
1063
+ break;
1064
+ case MDEntryType2.DailyValueAdjustmentForLongPositions:
1065
+ data.dailyValueAdjustmentForLongPositions = price;
1066
+ break;
1067
+ case MDEntryType2.CumulativeValueAdjustmentForLongPositions:
1068
+ data.cumulativeValueAdjustmentForLongPositions = price;
1069
+ break;
1070
+ case MDEntryType2.DailyValueAdjustmentForShortPositions:
1071
+ data.dailyValueAdjustmentForShortPositions = price;
1072
+ break;
1073
+ case MDEntryType2.CumulativeValueAdjustmentForShortPositions:
1074
+ data.cumulativeValueAdjustmentForShortPositions = price;
1075
+ break;
1076
+ case MDEntryType2.FixingPrice:
1077
+ data.fixingPrice = price;
1078
+ break;
1079
+ case MDEntryType2.CashRate:
1080
+ data.cashRate = price;
1081
+ break;
1082
+ case MDEntryType2.RecoveryRate:
1083
+ data.recoveryRate = price;
1084
+ break;
1085
+ case MDEntryType2.RecoveryRateForLong:
1086
+ data.recoveryRateForLong = price;
1087
+ break;
1088
+ case MDEntryType2.RecoveryRateForShort:
1089
+ data.recoveryRateForShort = price;
1090
+ break;
1091
+ case MDEntryType2.MarketBid:
1092
+ data.marketBid = price;
1093
+ break;
1094
+ case MDEntryType2.MarketOffer:
1095
+ data.marketOffer = price;
1096
+ break;
1097
+ case MDEntryType2.ShortSaleMinPrice:
1098
+ data.shortSaleMinPrice = price;
1099
+ break;
1100
+ case MDEntryType2.PreviousClosingPrice:
1101
+ data.previousClosingPrice = price;
1102
+ break;
1103
+ case MDEntryType2.ThresholdLimitPriceBanding:
1104
+ data.thresholdLimitPriceBanding = price;
1105
+ break;
1106
+ case MDEntryType2.DailyFinancingValue:
1107
+ data.dailyFinancingValue = price;
1108
+ break;
1109
+ case MDEntryType2.AccruedFinancingValue:
1110
+ data.accruedFinancingValue = price;
1111
+ break;
1112
+ case MDEntryType2.TWAP:
1113
+ data.twap = price;
1114
+ break;
1115
+ }
1116
+ }
1117
+ data.spread = data.offer - data.bid;
844
1118
  if (!marketDataPrices.has(symbol)) {
845
1119
  marketDataPrices.set(symbol, []);
846
1120
  }
@@ -850,6 +1124,14 @@ function handleMessage(message, parser, pendingRequests, marketDataPrices, maxPr
850
1124
  prices.splice(0, prices.length - maxPriceHistory);
851
1125
  }
852
1126
  onPriceUpdate?.(symbol, data);
1127
+ const mdReqID = message.getField(Fields3.MDReqID)?.value;
1128
+ if (mdReqID) {
1129
+ const callback = pendingRequests.get(mdReqID);
1130
+ if (callback) {
1131
+ callback(message);
1132
+ pendingRequests.delete(mdReqID);
1133
+ }
1134
+ }
853
1135
  } else if (msgType === Messages3.ExecutionReport) {
854
1136
  const reqId = message.getField(Fields3.ClOrdID)?.value;
855
1137
  const callback = pendingRequests.get(reqId);
@@ -878,7 +1160,7 @@ var MCPLocal = class extends MCPBase {
878
1160
  */
879
1161
  marketDataPrices = /* @__PURE__ */ new Map();
880
1162
  /**
881
- * Maximum number of price points to store per symbol
1163
+ * Maximum number of price history entries to keep per symbol
882
1164
  * @private
883
1165
  */
884
1166
  MAX_PRICE_HISTORY = 1e5;
@@ -1062,7 +1344,7 @@ var MCPRemote = class extends MCPBase {
1062
1344
  */
1063
1345
  marketDataPrices = /* @__PURE__ */ new Map();
1064
1346
  /**
1065
- * Maximum number of price points to store per symbol
1347
+ * Maximum number of price history entries to keep per symbol
1066
1348
  * @private
1067
1349
  */
1068
1350
  MAX_PRICE_HISTORY = 1e5;
@@ -1084,31 +1366,7 @@ var MCPRemote = class extends MCPBase {
1084
1366
  this.parser,
1085
1367
  this.pendingRequests,
1086
1368
  this.marketDataPrices,
1087
- this.MAX_PRICE_HISTORY,
1088
- (symbol, data) => {
1089
- this.mcpServer?.tool(
1090
- "priceUpdate",
1091
- {
1092
- description: "Price update notification",
1093
- schema: z2.object({
1094
- symbol: z2.string(),
1095
- timestamp: z2.number(),
1096
- bid: z2.number(),
1097
- offer: z2.number(),
1098
- spread: z2.number(),
1099
- volume: z2.number()
1100
- })
1101
- },
1102
- () => ({
1103
- content: [
1104
- {
1105
- type: "text",
1106
- text: JSON.stringify({ symbol, ...data })
1107
- }
1108
- ]
1109
- })
1110
- );
1111
- }
1369
+ this.MAX_PRICE_HISTORY
1112
1370
  );
1113
1371
  }
1114
1372
  });