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.
@@ -322,7 +322,52 @@ var createMarketDataRequestHandler = (parser, pendingRequests) => {
322
322
  const response = new Promise((resolve) => {
323
323
  pendingRequests.set(args.mdReqID, resolve);
324
324
  });
325
- const entryTypes = args.mdEntryTypes || [import_fixparser.MDEntryType.Bid, import_fixparser.MDEntryType.Offer, import_fixparser.MDEntryType.TradeVolume];
325
+ const entryTypes = args.mdEntryTypes || [
326
+ import_fixparser.MDEntryType.Bid,
327
+ import_fixparser.MDEntryType.Offer,
328
+ import_fixparser.MDEntryType.Trade,
329
+ import_fixparser.MDEntryType.IndexValue,
330
+ import_fixparser.MDEntryType.OpeningPrice,
331
+ import_fixparser.MDEntryType.ClosingPrice,
332
+ import_fixparser.MDEntryType.SettlementPrice,
333
+ import_fixparser.MDEntryType.TradingSessionHighPrice,
334
+ import_fixparser.MDEntryType.TradingSessionLowPrice,
335
+ import_fixparser.MDEntryType.VWAP,
336
+ import_fixparser.MDEntryType.Imbalance,
337
+ import_fixparser.MDEntryType.TradeVolume,
338
+ import_fixparser.MDEntryType.OpenInterest,
339
+ import_fixparser.MDEntryType.CompositeUnderlyingPrice,
340
+ import_fixparser.MDEntryType.SimulatedSellPrice,
341
+ import_fixparser.MDEntryType.SimulatedBuyPrice,
342
+ import_fixparser.MDEntryType.MarginRate,
343
+ import_fixparser.MDEntryType.MidPrice,
344
+ import_fixparser.MDEntryType.EmptyBook,
345
+ import_fixparser.MDEntryType.SettleHighPrice,
346
+ import_fixparser.MDEntryType.SettleLowPrice,
347
+ import_fixparser.MDEntryType.PriorSettlePrice,
348
+ import_fixparser.MDEntryType.SessionHighBid,
349
+ import_fixparser.MDEntryType.SessionLowOffer,
350
+ import_fixparser.MDEntryType.EarlyPrices,
351
+ import_fixparser.MDEntryType.AuctionClearingPrice,
352
+ import_fixparser.MDEntryType.SwapValueFactor,
353
+ import_fixparser.MDEntryType.DailyValueAdjustmentForLongPositions,
354
+ import_fixparser.MDEntryType.CumulativeValueAdjustmentForLongPositions,
355
+ import_fixparser.MDEntryType.DailyValueAdjustmentForShortPositions,
356
+ import_fixparser.MDEntryType.CumulativeValueAdjustmentForShortPositions,
357
+ import_fixparser.MDEntryType.FixingPrice,
358
+ import_fixparser.MDEntryType.CashRate,
359
+ import_fixparser.MDEntryType.RecoveryRate,
360
+ import_fixparser.MDEntryType.RecoveryRateForLong,
361
+ import_fixparser.MDEntryType.RecoveryRateForShort,
362
+ import_fixparser.MDEntryType.MarketBid,
363
+ import_fixparser.MDEntryType.MarketOffer,
364
+ import_fixparser.MDEntryType.ShortSaleMinPrice,
365
+ import_fixparser.MDEntryType.PreviousClosingPrice,
366
+ import_fixparser.MDEntryType.ThresholdLimitPriceBanding,
367
+ import_fixparser.MDEntryType.DailyFinancingValue,
368
+ import_fixparser.MDEntryType.AccruedFinancingValue,
369
+ import_fixparser.MDEntryType.TWAP
370
+ ];
326
371
  const messageFields = [
327
372
  new import_fixparser.Field(import_fixparser.Fields.MsgType, import_fixparser.Messages.MarketDataRequest),
328
373
  new import_fixparser.Field(import_fixparser.Fields.SenderCompID, parser.sender),
@@ -405,6 +450,9 @@ var createGetStockGraphHandler = (marketDataPrices) => {
405
450
  const offerData = priceHistory.map((point) => point.offer);
406
451
  const spreadData = priceHistory.map((point) => point.spread);
407
452
  const volumeData = priceHistory.map((point) => point.volume);
453
+ const tradeData = priceHistory.map((point) => point.trade);
454
+ const vwapData = priceHistory.map((point) => point.vwap);
455
+ const twapData = priceHistory.map((point) => point.twap);
408
456
  const config = {
409
457
  type: "line",
410
458
  data: {
@@ -434,6 +482,30 @@ var createGetStockGraphHandler = (marketDataPrices) => {
434
482
  fill: false,
435
483
  tension: 0.4
436
484
  },
485
+ {
486
+ label: "Trade",
487
+ data: tradeData,
488
+ borderColor: "#ffc107",
489
+ backgroundColor: "rgba(255, 193, 7, 0.1)",
490
+ fill: false,
491
+ tension: 0.4
492
+ },
493
+ {
494
+ label: "VWAP",
495
+ data: vwapData,
496
+ borderColor: "#17a2b8",
497
+ backgroundColor: "rgba(23, 162, 184, 0.1)",
498
+ fill: false,
499
+ tension: 0.4
500
+ },
501
+ {
502
+ label: "TWAP",
503
+ data: twapData,
504
+ borderColor: "#6610f2",
505
+ backgroundColor: "rgba(102, 16, 242, 0.1)",
506
+ fill: false,
507
+ tension: 0.4
508
+ },
437
509
  {
438
510
  label: "Volume",
439
511
  data: volumeData,
@@ -479,7 +551,7 @@ var createGetStockGraphHandler = (marketDataPrices) => {
479
551
  content: [
480
552
  {
481
553
  type: "text",
482
- text: `Error: ${error instanceof Error ? error.message : "Failed to generate chart"}`,
554
+ text: `Error: ${error instanceof Error ? error.message : "Failed to generate graph"}`,
483
555
  uri: "getStockGraph"
484
556
  }
485
557
  ],
@@ -517,7 +589,48 @@ var createGetStockPriceHistoryHandler = (marketDataPrices) => {
517
589
  bid: point.bid,
518
590
  offer: point.offer,
519
591
  spread: point.spread,
520
- volume: point.volume
592
+ volume: point.volume,
593
+ trade: point.trade,
594
+ indexValue: point.indexValue,
595
+ openingPrice: point.openingPrice,
596
+ closingPrice: point.closingPrice,
597
+ settlementPrice: point.settlementPrice,
598
+ tradingSessionHighPrice: point.tradingSessionHighPrice,
599
+ tradingSessionLowPrice: point.tradingSessionLowPrice,
600
+ vwap: point.vwap,
601
+ imbalance: point.imbalance,
602
+ openInterest: point.openInterest,
603
+ compositeUnderlyingPrice: point.compositeUnderlyingPrice,
604
+ simulatedSellPrice: point.simulatedSellPrice,
605
+ simulatedBuyPrice: point.simulatedBuyPrice,
606
+ marginRate: point.marginRate,
607
+ midPrice: point.midPrice,
608
+ emptyBook: point.emptyBook,
609
+ settleHighPrice: point.settleHighPrice,
610
+ settleLowPrice: point.settleLowPrice,
611
+ priorSettlePrice: point.priorSettlePrice,
612
+ sessionHighBid: point.sessionHighBid,
613
+ sessionLowOffer: point.sessionLowOffer,
614
+ earlyPrices: point.earlyPrices,
615
+ auctionClearingPrice: point.auctionClearingPrice,
616
+ swapValueFactor: point.swapValueFactor,
617
+ dailyValueAdjustmentForLongPositions: point.dailyValueAdjustmentForLongPositions,
618
+ cumulativeValueAdjustmentForLongPositions: point.cumulativeValueAdjustmentForLongPositions,
619
+ dailyValueAdjustmentForShortPositions: point.dailyValueAdjustmentForShortPositions,
620
+ cumulativeValueAdjustmentForShortPositions: point.cumulativeValueAdjustmentForShortPositions,
621
+ fixingPrice: point.fixingPrice,
622
+ cashRate: point.cashRate,
623
+ recoveryRate: point.recoveryRate,
624
+ recoveryRateForLong: point.recoveryRateForLong,
625
+ recoveryRateForShort: point.recoveryRateForShort,
626
+ marketBid: point.marketBid,
627
+ marketOffer: point.marketOffer,
628
+ shortSaleMinPrice: point.shortSaleMinPrice,
629
+ previousClosingPrice: point.previousClosingPrice,
630
+ thresholdLimitPriceBanding: point.thresholdLimitPriceBanding,
631
+ dailyFinancingValue: point.dailyFinancingValue,
632
+ accruedFinancingValue: point.accruedFinancingValue,
633
+ twap: point.twap
521
634
  }))
522
635
  },
523
636
  null,
@@ -532,7 +645,7 @@ var createGetStockPriceHistoryHandler = (marketDataPrices) => {
532
645
  content: [
533
646
  {
534
647
  type: "text",
535
- text: `Error: ${error instanceof Error ? error.message : "Failed to get stock price history"}`,
648
+ text: `Error: ${error instanceof Error ? error.message : "Failed to get price history"}`,
536
649
  uri: "getStockPriceHistory"
537
650
  }
538
651
  ],
@@ -847,37 +960,198 @@ function handleMessage(message, parser, pendingRequests, marketDataPrices, maxPr
847
960
  message: `MCP Server received message: ${message.messageType}: ${message.description}`
848
961
  });
849
962
  const msgType = message.messageType;
850
- if (msgType === import_fixparser3.Messages.MarketDataSnapshotFullRefresh) {
963
+ if (msgType === import_fixparser3.Messages.MarketDataSnapshotFullRefresh || msgType === import_fixparser3.Messages.MarketDataIncrementalRefresh) {
851
964
  const symbol = message.getField(import_fixparser3.Fields.Symbol)?.value;
852
- const entries = message.getField(import_fixparser3.Fields.NoMDEntries)?.value;
853
- let bid = 0;
854
- let offer = 0;
855
- let volume = 0;
856
- const entryTypes = message.getFields(import_fixparser3.Fields.MDEntryType);
857
- const entryPrices = message.getFields(import_fixparser3.Fields.MDEntryPx);
858
- const entrySizes = message.getFields(import_fixparser3.Fields.MDEntrySize);
859
- if (entryTypes && entryPrices && entrySizes) {
860
- for (let i = 0; i < entries; i++) {
861
- const entryType = entryTypes[i]?.value;
862
- const entryPrice = Number.parseFloat(entryPrices[i]?.value);
863
- const entrySize = Number.parseFloat(entrySizes[i]?.value);
864
- if (entryType === import_fixparser3.MDEntryType.Bid) {
865
- bid = entryPrice;
866
- } else if (entryType === import_fixparser3.MDEntryType.Offer) {
867
- offer = entryPrice;
868
- }
869
- volume += entrySize;
870
- }
871
- }
872
- const spread = offer - bid;
873
- const timestamp = Date.now();
965
+ const fixJson = message.toFIXJSON();
966
+ const entries = fixJson.Body?.NoMDEntries || [];
874
967
  const data = {
875
- timestamp,
876
- bid,
877
- offer,
878
- spread,
879
- volume
968
+ timestamp: Date.now(),
969
+ bid: 0,
970
+ offer: 0,
971
+ spread: 0,
972
+ volume: 0,
973
+ trade: 0,
974
+ indexValue: 0,
975
+ openingPrice: 0,
976
+ closingPrice: 0,
977
+ settlementPrice: 0,
978
+ tradingSessionHighPrice: 0,
979
+ tradingSessionLowPrice: 0,
980
+ vwap: 0,
981
+ imbalance: 0,
982
+ openInterest: 0,
983
+ compositeUnderlyingPrice: 0,
984
+ simulatedSellPrice: 0,
985
+ simulatedBuyPrice: 0,
986
+ marginRate: 0,
987
+ midPrice: 0,
988
+ emptyBook: 0,
989
+ settleHighPrice: 0,
990
+ settleLowPrice: 0,
991
+ priorSettlePrice: 0,
992
+ sessionHighBid: 0,
993
+ sessionLowOffer: 0,
994
+ earlyPrices: 0,
995
+ auctionClearingPrice: 0,
996
+ swapValueFactor: 0,
997
+ dailyValueAdjustmentForLongPositions: 0,
998
+ cumulativeValueAdjustmentForLongPositions: 0,
999
+ dailyValueAdjustmentForShortPositions: 0,
1000
+ cumulativeValueAdjustmentForShortPositions: 0,
1001
+ fixingPrice: 0,
1002
+ cashRate: 0,
1003
+ recoveryRate: 0,
1004
+ recoveryRateForLong: 0,
1005
+ recoveryRateForShort: 0,
1006
+ marketBid: 0,
1007
+ marketOffer: 0,
1008
+ shortSaleMinPrice: 0,
1009
+ previousClosingPrice: 0,
1010
+ thresholdLimitPriceBanding: 0,
1011
+ dailyFinancingValue: 0,
1012
+ accruedFinancingValue: 0,
1013
+ twap: 0
880
1014
  };
1015
+ for (const entry of entries) {
1016
+ const entryType = entry.MDEntryType;
1017
+ const price = entry.MDEntryPx ? Number.parseFloat(entry.MDEntryPx) : 0;
1018
+ const size = entry.MDEntrySize ? Number.parseFloat(entry.MDEntrySize) : 0;
1019
+ switch (entryType) {
1020
+ case import_fixparser3.MDEntryType.Bid:
1021
+ data.bid = price;
1022
+ break;
1023
+ case import_fixparser3.MDEntryType.Offer:
1024
+ data.offer = price;
1025
+ break;
1026
+ case import_fixparser3.MDEntryType.Trade:
1027
+ data.trade = price;
1028
+ break;
1029
+ case import_fixparser3.MDEntryType.IndexValue:
1030
+ data.indexValue = price;
1031
+ break;
1032
+ case import_fixparser3.MDEntryType.OpeningPrice:
1033
+ data.openingPrice = price;
1034
+ break;
1035
+ case import_fixparser3.MDEntryType.ClosingPrice:
1036
+ data.closingPrice = price;
1037
+ break;
1038
+ case import_fixparser3.MDEntryType.SettlementPrice:
1039
+ data.settlementPrice = price;
1040
+ break;
1041
+ case import_fixparser3.MDEntryType.TradingSessionHighPrice:
1042
+ data.tradingSessionHighPrice = price;
1043
+ break;
1044
+ case import_fixparser3.MDEntryType.TradingSessionLowPrice:
1045
+ data.tradingSessionLowPrice = price;
1046
+ break;
1047
+ case import_fixparser3.MDEntryType.VWAP:
1048
+ data.vwap = price;
1049
+ break;
1050
+ case import_fixparser3.MDEntryType.Imbalance:
1051
+ data.imbalance = size;
1052
+ break;
1053
+ case import_fixparser3.MDEntryType.TradeVolume:
1054
+ data.volume = size;
1055
+ break;
1056
+ case import_fixparser3.MDEntryType.OpenInterest:
1057
+ data.openInterest = size;
1058
+ break;
1059
+ case import_fixparser3.MDEntryType.CompositeUnderlyingPrice:
1060
+ data.compositeUnderlyingPrice = price;
1061
+ break;
1062
+ case import_fixparser3.MDEntryType.SimulatedSellPrice:
1063
+ data.simulatedSellPrice = price;
1064
+ break;
1065
+ case import_fixparser3.MDEntryType.SimulatedBuyPrice:
1066
+ data.simulatedBuyPrice = price;
1067
+ break;
1068
+ case import_fixparser3.MDEntryType.MarginRate:
1069
+ data.marginRate = price;
1070
+ break;
1071
+ case import_fixparser3.MDEntryType.MidPrice:
1072
+ data.midPrice = price;
1073
+ break;
1074
+ case import_fixparser3.MDEntryType.EmptyBook:
1075
+ data.emptyBook = 1;
1076
+ break;
1077
+ case import_fixparser3.MDEntryType.SettleHighPrice:
1078
+ data.settleHighPrice = price;
1079
+ break;
1080
+ case import_fixparser3.MDEntryType.SettleLowPrice:
1081
+ data.settleLowPrice = price;
1082
+ break;
1083
+ case import_fixparser3.MDEntryType.PriorSettlePrice:
1084
+ data.priorSettlePrice = price;
1085
+ break;
1086
+ case import_fixparser3.MDEntryType.SessionHighBid:
1087
+ data.sessionHighBid = price;
1088
+ break;
1089
+ case import_fixparser3.MDEntryType.SessionLowOffer:
1090
+ data.sessionLowOffer = price;
1091
+ break;
1092
+ case import_fixparser3.MDEntryType.EarlyPrices:
1093
+ data.earlyPrices = price;
1094
+ break;
1095
+ case import_fixparser3.MDEntryType.AuctionClearingPrice:
1096
+ data.auctionClearingPrice = price;
1097
+ break;
1098
+ case import_fixparser3.MDEntryType.SwapValueFactor:
1099
+ data.swapValueFactor = price;
1100
+ break;
1101
+ case import_fixparser3.MDEntryType.DailyValueAdjustmentForLongPositions:
1102
+ data.dailyValueAdjustmentForLongPositions = price;
1103
+ break;
1104
+ case import_fixparser3.MDEntryType.CumulativeValueAdjustmentForLongPositions:
1105
+ data.cumulativeValueAdjustmentForLongPositions = price;
1106
+ break;
1107
+ case import_fixparser3.MDEntryType.DailyValueAdjustmentForShortPositions:
1108
+ data.dailyValueAdjustmentForShortPositions = price;
1109
+ break;
1110
+ case import_fixparser3.MDEntryType.CumulativeValueAdjustmentForShortPositions:
1111
+ data.cumulativeValueAdjustmentForShortPositions = price;
1112
+ break;
1113
+ case import_fixparser3.MDEntryType.FixingPrice:
1114
+ data.fixingPrice = price;
1115
+ break;
1116
+ case import_fixparser3.MDEntryType.CashRate:
1117
+ data.cashRate = price;
1118
+ break;
1119
+ case import_fixparser3.MDEntryType.RecoveryRate:
1120
+ data.recoveryRate = price;
1121
+ break;
1122
+ case import_fixparser3.MDEntryType.RecoveryRateForLong:
1123
+ data.recoveryRateForLong = price;
1124
+ break;
1125
+ case import_fixparser3.MDEntryType.RecoveryRateForShort:
1126
+ data.recoveryRateForShort = price;
1127
+ break;
1128
+ case import_fixparser3.MDEntryType.MarketBid:
1129
+ data.marketBid = price;
1130
+ break;
1131
+ case import_fixparser3.MDEntryType.MarketOffer:
1132
+ data.marketOffer = price;
1133
+ break;
1134
+ case import_fixparser3.MDEntryType.ShortSaleMinPrice:
1135
+ data.shortSaleMinPrice = price;
1136
+ break;
1137
+ case import_fixparser3.MDEntryType.PreviousClosingPrice:
1138
+ data.previousClosingPrice = price;
1139
+ break;
1140
+ case import_fixparser3.MDEntryType.ThresholdLimitPriceBanding:
1141
+ data.thresholdLimitPriceBanding = price;
1142
+ break;
1143
+ case import_fixparser3.MDEntryType.DailyFinancingValue:
1144
+ data.dailyFinancingValue = price;
1145
+ break;
1146
+ case import_fixparser3.MDEntryType.AccruedFinancingValue:
1147
+ data.accruedFinancingValue = price;
1148
+ break;
1149
+ case import_fixparser3.MDEntryType.TWAP:
1150
+ data.twap = price;
1151
+ break;
1152
+ }
1153
+ }
1154
+ data.spread = data.offer - data.bid;
881
1155
  if (!marketDataPrices.has(symbol)) {
882
1156
  marketDataPrices.set(symbol, []);
883
1157
  }
@@ -887,6 +1161,14 @@ function handleMessage(message, parser, pendingRequests, marketDataPrices, maxPr
887
1161
  prices.splice(0, prices.length - maxPriceHistory);
888
1162
  }
889
1163
  onPriceUpdate?.(symbol, data);
1164
+ const mdReqID = message.getField(import_fixparser3.Fields.MDReqID)?.value;
1165
+ if (mdReqID) {
1166
+ const callback = pendingRequests.get(mdReqID);
1167
+ if (callback) {
1168
+ callback(message);
1169
+ pendingRequests.delete(mdReqID);
1170
+ }
1171
+ }
890
1172
  } else if (msgType === import_fixparser3.Messages.ExecutionReport) {
891
1173
  const reqId = message.getField(import_fixparser3.Fields.ClOrdID)?.value;
892
1174
  const callback = pendingRequests.get(reqId);
@@ -915,7 +1197,7 @@ var MCPLocal = class extends MCPBase {
915
1197
  */
916
1198
  marketDataPrices = /* @__PURE__ */ new Map();
917
1199
  /**
918
- * Maximum number of price points to store per symbol
1200
+ * Maximum number of price history entries to keep per symbol
919
1201
  * @private
920
1202
  */
921
1203
  MAX_PRICE_HISTORY = 1e5;
@@ -1099,7 +1381,7 @@ var MCPRemote = class extends MCPBase {
1099
1381
  */
1100
1382
  marketDataPrices = /* @__PURE__ */ new Map();
1101
1383
  /**
1102
- * Maximum number of price points to store per symbol
1384
+ * Maximum number of price history entries to keep per symbol
1103
1385
  * @private
1104
1386
  */
1105
1387
  MAX_PRICE_HISTORY = 1e5;
@@ -1121,31 +1403,7 @@ var MCPRemote = class extends MCPBase {
1121
1403
  this.parser,
1122
1404
  this.pendingRequests,
1123
1405
  this.marketDataPrices,
1124
- this.MAX_PRICE_HISTORY,
1125
- (symbol, data) => {
1126
- this.mcpServer?.tool(
1127
- "priceUpdate",
1128
- {
1129
- description: "Price update notification",
1130
- schema: import_zod2.z.object({
1131
- symbol: import_zod2.z.string(),
1132
- timestamp: import_zod2.z.number(),
1133
- bid: import_zod2.z.number(),
1134
- offer: import_zod2.z.number(),
1135
- spread: import_zod2.z.number(),
1136
- volume: import_zod2.z.number()
1137
- })
1138
- },
1139
- () => ({
1140
- content: [
1141
- {
1142
- type: "text",
1143
- text: JSON.stringify({ symbol, ...data })
1144
- }
1145
- ]
1146
- })
1147
- );
1148
- }
1406
+ this.MAX_PRICE_HISTORY
1149
1407
  );
1150
1408
  }
1151
1409
  });