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