fixparser-plugin-mcp 9.1.7-46844c62 → 9.1.7-4a216645

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.
@@ -38,15 +38,246 @@ var import_stdio = require("@modelcontextprotocol/sdk/server/stdio.js");
38
38
  var import_fixparser3 = require("fixparser");
39
39
  var import_zod = require("zod");
40
40
 
41
+ // src/schemas/schemas.ts
42
+ var toolSchemas = {
43
+ parse: {
44
+ description: "Parses a FIX message and describes it in plain language",
45
+ schema: {
46
+ type: "object",
47
+ properties: {
48
+ fixString: { type: "string" }
49
+ },
50
+ required: ["fixString"]
51
+ }
52
+ },
53
+ parseToJSON: {
54
+ description: "Parses a FIX message into JSON",
55
+ schema: {
56
+ type: "object",
57
+ properties: {
58
+ fixString: { type: "string" }
59
+ },
60
+ required: ["fixString"]
61
+ }
62
+ },
63
+ verifyOrder: {
64
+ description: "Verifies order parameters before execution. verifyOrder must be called before executeOrder.",
65
+ schema: {
66
+ type: "object",
67
+ properties: {
68
+ clOrdID: { type: "string" },
69
+ handlInst: {
70
+ type: "string",
71
+ enum: ["1", "2", "3"],
72
+ description: "Handling Instructions: 1=Automated Execution No Intervention, 2=Automated Execution Intervention OK, 3=Manual Order"
73
+ },
74
+ quantity: { type: "string" },
75
+ price: { type: "string" },
76
+ ordType: {
77
+ type: "string",
78
+ enum: [
79
+ "1",
80
+ "2",
81
+ "3",
82
+ "4",
83
+ "5",
84
+ "6",
85
+ "7",
86
+ "8",
87
+ "9",
88
+ "A",
89
+ "B",
90
+ "C",
91
+ "D",
92
+ "E",
93
+ "F",
94
+ "G",
95
+ "H",
96
+ "I",
97
+ "J",
98
+ "K",
99
+ "L",
100
+ "M",
101
+ "P",
102
+ "Q",
103
+ "R",
104
+ "S"
105
+ ],
106
+ description: "Order Type: 1=Market, 2=Limit, 3=Stop, 4=StopLimit, 5=MarketOnClose, 6=WithOrWithout, 7=LimitOrBetter, 8=LimitWithOrWithout, 9=OnBasis, A=OnClose, B=LimitOnClose, C=ForexMarket, D=PreviouslyQuoted, E=PreviouslyIndicated, F=ForexLimit, G=ForexSwap, H=ForexPreviouslyQuoted, I=Funari, J=MarketIfTouched, K=MarketWithLeftOverAsLimit, L=PreviousFundValuationPoint, M=NextFundValuationPoint, P=Pegged, Q=CounterOrderSelection, R=StopOnBidOrOffer, S=StopLimitOnBidOrOffer"
107
+ },
108
+ side: {
109
+ type: "string",
110
+ enum: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H"],
111
+ description: "Side: 1=Buy, 2=Sell, 3=BuyMinus, 4=SellPlus, 5=SellShort, 6=SellShortExempt, 7=Undisclosed, 8=Cross, 9=CrossShort, A=CrossShortExempt, B=AsDefined, C=Opposite, D=Subscribe, E=Redeem, F=Lend, G=Borrow, H=SellUndisclosed"
112
+ },
113
+ symbol: { type: "string" },
114
+ timeInForce: {
115
+ type: "string",
116
+ enum: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C"],
117
+ description: "Time In Force: 0=Day, 1=GoodTillCancel, 2=AtTheOpening, 3=ImmediateOrCancel, 4=FillOrKill, 5=GoodTillCrossing, 6=GoodTillDate, 7=AtTheClose, 8=GoodThroughCrossing, 9=AtCrossing, A=GoodForTime, B=GoodForAuction, C=GoodForMonth"
118
+ }
119
+ },
120
+ required: ["clOrdID", "handlInst", "quantity", "price", "ordType", "side", "symbol", "timeInForce"]
121
+ }
122
+ },
123
+ executeOrder: {
124
+ description: "Executes a verified order. verifyOrder must be called before executeOrder. user has to explicitly allow executeOrder.",
125
+ schema: {
126
+ type: "object",
127
+ properties: {
128
+ clOrdID: { type: "string" },
129
+ handlInst: {
130
+ type: "string",
131
+ enum: ["1", "2", "3"],
132
+ description: "Handling Instructions: 1=Automated Execution No Intervention, 2=Automated Execution Intervention OK, 3=Manual Order"
133
+ },
134
+ quantity: { type: "string" },
135
+ price: { type: "string" },
136
+ ordType: {
137
+ type: "string",
138
+ enum: [
139
+ "1",
140
+ "2",
141
+ "3",
142
+ "4",
143
+ "5",
144
+ "6",
145
+ "7",
146
+ "8",
147
+ "9",
148
+ "A",
149
+ "B",
150
+ "C",
151
+ "D",
152
+ "E",
153
+ "F",
154
+ "G",
155
+ "H",
156
+ "I",
157
+ "J",
158
+ "K",
159
+ "L",
160
+ "M",
161
+ "P",
162
+ "Q",
163
+ "R",
164
+ "S"
165
+ ],
166
+ description: "Order Type: 1=Market, 2=Limit, 3=Stop, 4=StopLimit, 5=MarketOnClose, 6=WithOrWithout, 7=LimitOrBetter, 8=LimitWithOrWithout, 9=OnBasis, A=OnClose, B=LimitOnClose, C=ForexMarket, D=PreviouslyQuoted, E=PreviouslyIndicated, F=ForexLimit, G=ForexSwap, H=ForexPreviouslyQuoted, I=Funari, J=MarketIfTouched, K=MarketWithLeftOverAsLimit, L=PreviousFundValuationPoint, M=NextFundValuationPoint, P=Pegged, Q=CounterOrderSelection, R=StopOnBidOrOffer, S=StopLimitOnBidOrOffer"
167
+ },
168
+ side: {
169
+ type: "string",
170
+ enum: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H"],
171
+ description: "Side: 1=Buy, 2=Sell, 3=BuyMinus, 4=SellPlus, 5=SellShort, 6=SellShortExempt, 7=Undisclosed, 8=Cross, 9=CrossShort, A=CrossShortExempt, B=AsDefined, C=Opposite, D=Subscribe, E=Redeem, F=Lend, G=Borrow, H=SellUndisclosed"
172
+ },
173
+ symbol: { type: "string" },
174
+ timeInForce: {
175
+ type: "string",
176
+ enum: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C"],
177
+ description: "Time In Force: 0=Day, 1=GoodTillCancel, 2=AtTheOpening, 3=ImmediateOrCancel, 4=FillOrKill, 5=GoodTillCrossing, 6=GoodTillDate, 7=AtTheClose, 8=GoodThroughCrossing, 9=AtCrossing, A=GoodForTime, B=GoodForAuction, C=GoodForMonth"
178
+ }
179
+ },
180
+ required: ["clOrdID", "handlInst", "quantity", "price", "ordType", "side", "symbol", "timeInForce"]
181
+ }
182
+ },
183
+ marketDataRequest: {
184
+ description: "Requests market data for specified symbols",
185
+ schema: {
186
+ type: "object",
187
+ properties: {
188
+ mdUpdateType: {
189
+ type: "string",
190
+ enum: ["0", "1"],
191
+ description: "Market Data Update Type: 0=Full Refresh, 1=Incremental Refresh"
192
+ },
193
+ symbols: { type: "array", items: { type: "string" } },
194
+ mdReqID: { type: "string" },
195
+ subscriptionRequestType: {
196
+ type: "string",
197
+ enum: ["0", "1", "2"],
198
+ description: "Subscription Request Type: 0=Snapshot, 1=Snapshot + Updates, 2=Disable Previous Snapshot + Update Request"
199
+ },
200
+ mdEntryTypes: {
201
+ type: "array",
202
+ items: {
203
+ type: "string",
204
+ enum: [
205
+ "0",
206
+ "1",
207
+ "2",
208
+ "3",
209
+ "4",
210
+ "5",
211
+ "6",
212
+ "7",
213
+ "8",
214
+ "9",
215
+ "A",
216
+ "B",
217
+ "C",
218
+ "D",
219
+ "E",
220
+ "F",
221
+ "G",
222
+ "H",
223
+ "I",
224
+ "J",
225
+ "K",
226
+ "L",
227
+ "M",
228
+ "N",
229
+ "O",
230
+ "P",
231
+ "Q",
232
+ "R",
233
+ "S",
234
+ "T",
235
+ "U",
236
+ "V",
237
+ "W",
238
+ "X",
239
+ "Y",
240
+ "Z"
241
+ ]
242
+ },
243
+ description: "Market Data Entry Types: 0=Bid, 1=Offer, 2=Trade, 3=Index Value, 4=Opening Price, 5=Closing Price, 6=Settlement Price, 7=High Price, 8=Low Price, 9=Trade Volume, A=Open Interest, B=Simulated Sell Price, C=Simulated Buy Price, D=Empty Book, E=Session High Bid, F=Session Low Offer, G=Fixing Price, H=Electronic Volume, I=Threshold Limits and Price Band Variation, J=Clearing Price, K=Open Interest Change, L=Last Trade Price, M=Last Trade Volume, N=Last Trade Time, O=Last Trade Tick, P=Last Trade Exchange, Q=Last Trade ID, R=Last Trade Side, S=Last Trade Price Change, T=Last Trade Price Change Percent, U=Last Trade Price Change Basis Points, V=Last Trade Price Change Points, W=Last Trade Price Change Ticks, X=Last Trade Price Change Ticks Percent, Y=Last Trade Price Change Ticks Basis Points, Z=Last Trade Price Change Ticks Points"
244
+ }
245
+ },
246
+ required: ["mdUpdateType", "symbols", "mdReqID", "subscriptionRequestType"]
247
+ }
248
+ },
249
+ getStockGraph: {
250
+ description: "Generates a price chart for a given symbol",
251
+ schema: {
252
+ type: "object",
253
+ properties: {
254
+ symbol: { type: "string" }
255
+ },
256
+ required: ["symbol"]
257
+ }
258
+ },
259
+ getStockPriceHistory: {
260
+ description: "Returns price history for a given symbol",
261
+ schema: {
262
+ type: "object",
263
+ properties: {
264
+ symbol: { type: "string" }
265
+ },
266
+ required: ["symbol"]
267
+ }
268
+ }
269
+ };
270
+
41
271
  // src/tools/marketData.ts
42
272
  var import_fixparser = require("fixparser");
43
- var import_sharp = __toESM(require("sharp"), 1);
273
+ var import_quickchart_js = __toESM(require("quickchart-js"), 1);
44
274
  var createMarketDataRequestHandler = (parser, pendingRequests) => {
45
275
  return async (args) => {
46
276
  try {
47
277
  const response = new Promise((resolve) => {
48
278
  pendingRequests.set(args.mdReqID, resolve);
49
279
  });
280
+ const entryTypes = args.mdEntryTypes || [import_fixparser.MDEntryType.Bid, import_fixparser.MDEntryType.Offer, import_fixparser.MDEntryType.TradeVolume];
50
281
  const messageFields = [
51
282
  new import_fixparser.Field(import_fixparser.Fields.MsgType, import_fixparser.Messages.MarketDataRequest),
52
283
  new import_fixparser.Field(import_fixparser.Fields.SenderCompID, parser.sender),
@@ -62,8 +293,8 @@ var createMarketDataRequestHandler = (parser, pendingRequests) => {
62
293
  args.symbols.forEach((symbol) => {
63
294
  messageFields.push(new import_fixparser.Field(import_fixparser.Fields.Symbol, symbol));
64
295
  });
65
- messageFields.push(new import_fixparser.Field(import_fixparser.Fields.NoMDEntryTypes, args.mdEntryTypes.length));
66
- args.mdEntryTypes.forEach((entryType) => {
296
+ messageFields.push(new import_fixparser.Field(import_fixparser.Fields.NoMDEntryTypes, entryTypes.length));
297
+ entryTypes.forEach((entryType) => {
67
298
  messageFields.push(new import_fixparser.Field(import_fixparser.Fields.MDEntryType, entryType));
68
299
  });
69
300
  const mdr = parser.createMessage(...messageFields);
@@ -120,74 +351,79 @@ var createGetStockGraphHandler = (marketDataPrices) => {
120
351
  ]
121
352
  };
122
353
  }
123
- const width = 600;
124
- const height = 300;
125
- const padding = 40;
126
- const xScale = (width - 2 * padding) / (priceHistory.length - 1);
127
- const yMin = Math.min(...priceHistory.map((d) => d.price));
128
- const yMax = Math.max(...priceHistory.map((d) => d.price));
129
- const yScale = (height - 2 * padding) / (yMax - yMin);
130
- const points = priceHistory.map((d, i) => {
131
- const x = padding + i * xScale;
132
- const y = height - padding - (d.price - yMin) * yScale;
133
- return `${x},${y}`;
134
- }).join(" L ");
135
- const svg = `<?xml version="1.0" encoding="UTF-8"?>
136
- <svg width="${width}" height="${height}" xmlns="http://www.w3.org/2000/svg">
137
- <!-- Background -->
138
- <rect width="100%" height="100%" fill="#f8f9fa"/>
139
-
140
- <!-- Grid lines -->
141
- <g stroke="#e9ecef" stroke-width="1">
142
- ${Array.from({ length: 5 }, (_, i) => {
143
- const y = padding + (height - 2 * padding) * i / 4;
144
- return `<line x1="${padding}" y1="${y}" x2="${width - padding}" y2="${y}"/>`;
145
- }).join("\n")}
146
- </g>
147
-
148
- <!-- Price line -->
149
- <path d="M ${points}"
150
- fill="none"
151
- stroke="#007bff"
152
- stroke-width="2"/>
153
-
154
- <!-- Data points -->
155
- ${priceHistory.map((d, i) => {
156
- const x = padding + i * xScale;
157
- const y = height - padding - (d.price - yMin) * yScale;
158
- return `<circle cx="${x}" cy="${y}" r="3" fill="#007bff"/>`;
159
- }).join("\n")}
160
-
161
- <!-- Labels -->
162
- <g font-family="Arial" font-size="12" fill="#495057">
163
- ${Array.from({ length: 5 }, (_, i) => {
164
- const x = padding + (width - 2 * padding) * i / 4;
165
- const index = Math.floor((priceHistory.length - 1) * i / 4);
166
- const timestamp = new Date(priceHistory[index].timestamp).toLocaleTimeString();
167
- return `<text x="${x + padding}" y="${height - padding + 20}" text-anchor="middle">${timestamp}</text>`;
168
- }).join("\n")}
169
- ${Array.from({ length: 5 }, (_, i) => {
170
- const y = padding + (height - 2 * padding) * i / 4;
171
- const price = yMax - (yMax - yMin) * i / 4;
172
- return `<text x="${padding - 5}" y="${y + 4}" text-anchor="end">$${price.toFixed(2)}</text>`;
173
- }).join("\n")}
174
- </g>
175
-
176
- <!-- Title -->
177
- <text x="${width / 2}" y="${padding / 2}"
178
- font-family="Arial" font-size="16" font-weight="bold"
179
- text-anchor="middle" fill="#212529">
180
- ${symbol} - Price Chart (${priceHistory.length} points)
181
- </text>
182
- </svg>`;
183
- const pngBuffer = await (0, import_sharp.default)(Buffer.from(svg)).png().toBuffer();
184
- const base64Png = pngBuffer.toString("base64");
354
+ const chart = new import_quickchart_js.default();
355
+ chart.setWidth(600);
356
+ chart.setHeight(300);
357
+ const labels = priceHistory.map((point) => new Date(point.timestamp).toLocaleTimeString());
358
+ const bidData = priceHistory.map((point) => point.bid);
359
+ const offerData = priceHistory.map((point) => point.offer);
360
+ const spreadData = priceHistory.map((point) => point.spread);
361
+ const volumeData = priceHistory.map((point) => point.volume);
362
+ const config = {
363
+ type: "line",
364
+ data: {
365
+ labels,
366
+ datasets: [
367
+ {
368
+ label: "Bid",
369
+ data: bidData,
370
+ borderColor: "#28a745",
371
+ backgroundColor: "rgba(40, 167, 69, 0.1)",
372
+ fill: false,
373
+ tension: 0.4
374
+ },
375
+ {
376
+ label: "Offer",
377
+ data: offerData,
378
+ borderColor: "#dc3545",
379
+ backgroundColor: "rgba(220, 53, 69, 0.1)",
380
+ fill: false,
381
+ tension: 0.4
382
+ },
383
+ {
384
+ label: "Spread",
385
+ data: spreadData,
386
+ borderColor: "#6c757d",
387
+ backgroundColor: "rgba(108, 117, 125, 0.1)",
388
+ fill: false,
389
+ tension: 0.4
390
+ },
391
+ {
392
+ label: "Volume",
393
+ data: volumeData,
394
+ borderColor: "#007bff",
395
+ backgroundColor: "rgba(0, 123, 255, 0.1)",
396
+ fill: true,
397
+ tension: 0.4
398
+ }
399
+ ]
400
+ },
401
+ options: {
402
+ responsive: true,
403
+ plugins: {
404
+ title: {
405
+ display: true,
406
+ text: `${symbol} Market Data`
407
+ }
408
+ },
409
+ scales: {
410
+ y: {
411
+ beginAtZero: false
412
+ }
413
+ }
414
+ }
415
+ };
416
+ chart.setConfig(config);
417
+ const imageBuffer = await chart.toBinary();
418
+ const base64Image = imageBuffer.toString("base64");
185
419
  return {
186
420
  content: [
187
421
  {
188
422
  type: "image",
189
- text: base64Png,
190
- uri: "getStockGraph",
423
+ source: {
424
+ filename: "graph.png",
425
+ data: `data:image/png;base64,${base64Image}`
426
+ },
191
427
  mimeType: "image/png"
192
428
  }
193
429
  ]
@@ -197,7 +433,7 @@ var createGetStockGraphHandler = (marketDataPrices) => {
197
433
  content: [
198
434
  {
199
435
  type: "text",
200
- text: `Error: ${error instanceof Error ? error.message : "Failed to generate stock graph"}`,
436
+ text: `Error: ${error instanceof Error ? error.message : "Failed to generate chart"}`,
201
437
  uri: "getStockGraph"
202
438
  }
203
439
  ],
@@ -230,9 +466,12 @@ var createGetStockPriceHistoryHandler = (marketDataPrices) => {
230
466
  {
231
467
  symbol,
232
468
  count: priceHistory.length,
233
- prices: priceHistory.map((point) => ({
469
+ data: priceHistory.map((point) => ({
234
470
  timestamp: new Date(point.timestamp).toISOString(),
235
- price: point.price
471
+ bid: point.bid,
472
+ offer: point.offer,
473
+ spread: point.spread,
474
+ volume: point.volume
236
475
  }))
237
476
  },
238
477
  null,
@@ -554,236 +793,6 @@ var createToolHandlers = (parser, verifiedOrders, pendingRequests, marketDataPri
554
793
  getStockPriceHistory: createGetStockPriceHistoryHandler(marketDataPrices)
555
794
  });
556
795
 
557
- // src/schemas/schemas.ts
558
- var toolSchemas = {
559
- parse: {
560
- description: "Parses a FIX message and describes it in plain language",
561
- schema: {
562
- type: "object",
563
- properties: {
564
- fixString: { type: "string" }
565
- },
566
- required: ["fixString"]
567
- }
568
- },
569
- parseToJSON: {
570
- description: "Parses a FIX message into JSON",
571
- schema: {
572
- type: "object",
573
- properties: {
574
- fixString: { type: "string" }
575
- },
576
- required: ["fixString"]
577
- }
578
- },
579
- verifyOrder: {
580
- description: "Verifies order parameters before execution. verifyOrder must be called before executeOrder.",
581
- schema: {
582
- type: "object",
583
- properties: {
584
- clOrdID: { type: "string" },
585
- handlInst: {
586
- type: "string",
587
- enum: ["1", "2", "3"],
588
- description: "Handling Instructions: 1=Automated Execution No Intervention, 2=Automated Execution Intervention OK, 3=Manual Order"
589
- },
590
- quantity: { type: "string" },
591
- price: { type: "string" },
592
- ordType: {
593
- type: "string",
594
- enum: [
595
- "1",
596
- "2",
597
- "3",
598
- "4",
599
- "5",
600
- "6",
601
- "7",
602
- "8",
603
- "9",
604
- "A",
605
- "B",
606
- "C",
607
- "D",
608
- "E",
609
- "F",
610
- "G",
611
- "H",
612
- "I",
613
- "J",
614
- "K",
615
- "L",
616
- "M",
617
- "P",
618
- "Q",
619
- "R",
620
- "S"
621
- ],
622
- description: "Order Type: 1=Market, 2=Limit, 3=Stop, 4=StopLimit, 5=MarketOnClose, 6=WithOrWithout, 7=LimitOrBetter, 8=LimitWithOrWithout, 9=OnBasis, A=OnClose, B=LimitOnClose, C=ForexMarket, D=PreviouslyQuoted, E=PreviouslyIndicated, F=ForexLimit, G=ForexSwap, H=ForexPreviouslyQuoted, I=Funari, J=MarketIfTouched, K=MarketWithLeftOverAsLimit, L=PreviousFundValuationPoint, M=NextFundValuationPoint, P=Pegged, Q=CounterOrderSelection, R=StopOnBidOrOffer, S=StopLimitOnBidOrOffer"
623
- },
624
- side: {
625
- type: "string",
626
- enum: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H"],
627
- description: "Side: 1=Buy, 2=Sell, 3=BuyMinus, 4=SellPlus, 5=SellShort, 6=SellShortExempt, 7=Undisclosed, 8=Cross, 9=CrossShort, A=CrossShortExempt, B=AsDefined, C=Opposite, D=Subscribe, E=Redeem, F=Lend, G=Borrow, H=SellUndisclosed"
628
- },
629
- symbol: { type: "string" },
630
- timeInForce: {
631
- type: "string",
632
- enum: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C"],
633
- description: "Time In Force: 0=Day, 1=GoodTillCancel, 2=AtTheOpening, 3=ImmediateOrCancel, 4=FillOrKill, 5=GoodTillCrossing, 6=GoodTillDate, 7=AtTheClose, 8=GoodThroughCrossing, 9=AtCrossing, A=GoodForTime, B=GoodForAuction, C=GoodForMonth"
634
- }
635
- },
636
- required: ["clOrdID", "handlInst", "quantity", "price", "ordType", "side", "symbol", "timeInForce"]
637
- }
638
- },
639
- executeOrder: {
640
- description: "Executes a verified order. verifyOrder must be called before executeOrder. user has to explicitly allow executeOrder.",
641
- schema: {
642
- type: "object",
643
- properties: {
644
- clOrdID: { type: "string" },
645
- handlInst: {
646
- type: "string",
647
- enum: ["1", "2", "3"],
648
- description: "Handling Instructions: 1=Automated Execution No Intervention, 2=Automated Execution Intervention OK, 3=Manual Order"
649
- },
650
- quantity: { type: "string" },
651
- price: { type: "string" },
652
- ordType: {
653
- type: "string",
654
- enum: [
655
- "1",
656
- "2",
657
- "3",
658
- "4",
659
- "5",
660
- "6",
661
- "7",
662
- "8",
663
- "9",
664
- "A",
665
- "B",
666
- "C",
667
- "D",
668
- "E",
669
- "F",
670
- "G",
671
- "H",
672
- "I",
673
- "J",
674
- "K",
675
- "L",
676
- "M",
677
- "P",
678
- "Q",
679
- "R",
680
- "S"
681
- ],
682
- description: "Order Type: 1=Market, 2=Limit, 3=Stop, 4=StopLimit, 5=MarketOnClose, 6=WithOrWithout, 7=LimitOrBetter, 8=LimitWithOrWithout, 9=OnBasis, A=OnClose, B=LimitOnClose, C=ForexMarket, D=PreviouslyQuoted, E=PreviouslyIndicated, F=ForexLimit, G=ForexSwap, H=ForexPreviouslyQuoted, I=Funari, J=MarketIfTouched, K=MarketWithLeftOverAsLimit, L=PreviousFundValuationPoint, M=NextFundValuationPoint, P=Pegged, Q=CounterOrderSelection, R=StopOnBidOrOffer, S=StopLimitOnBidOrOffer"
683
- },
684
- side: {
685
- type: "string",
686
- enum: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H"],
687
- description: "Side: 1=Buy, 2=Sell, 3=BuyMinus, 4=SellPlus, 5=SellShort, 6=SellShortExempt, 7=Undisclosed, 8=Cross, 9=CrossShort, A=CrossShortExempt, B=AsDefined, C=Opposite, D=Subscribe, E=Redeem, F=Lend, G=Borrow, H=SellUndisclosed"
688
- },
689
- symbol: { type: "string" },
690
- timeInForce: {
691
- type: "string",
692
- enum: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C"],
693
- description: "Time In Force: 0=Day, 1=GoodTillCancel, 2=AtTheOpening, 3=ImmediateOrCancel, 4=FillOrKill, 5=GoodTillCrossing, 6=GoodTillDate, 7=AtTheClose, 8=GoodThroughCrossing, 9=AtCrossing, A=GoodForTime, B=GoodForAuction, C=GoodForMonth"
694
- }
695
- },
696
- required: ["clOrdID", "handlInst", "quantity", "price", "ordType", "side", "symbol", "timeInForce"]
697
- }
698
- },
699
- marketDataRequest: {
700
- description: "Requests market data for specified symbols",
701
- schema: {
702
- type: "object",
703
- properties: {
704
- mdUpdateType: {
705
- type: "string",
706
- enum: ["0", "1"],
707
- description: "Market Data Update Type: 0=Full Refresh, 1=Incremental Refresh"
708
- },
709
- symbols: { type: "array", items: { type: "string" } },
710
- mdReqID: { type: "string" },
711
- subscriptionRequestType: {
712
- type: "string",
713
- enum: ["0", "1", "2"],
714
- description: "Subscription Request Type: 0=Snapshot, 1=Snapshot + Updates, 2=Disable Previous Snapshot + Update Request"
715
- },
716
- mdEntryTypes: {
717
- type: "array",
718
- items: {
719
- type: "string",
720
- enum: [
721
- "0",
722
- "1",
723
- "2",
724
- "3",
725
- "4",
726
- "5",
727
- "6",
728
- "7",
729
- "8",
730
- "9",
731
- "A",
732
- "B",
733
- "C",
734
- "D",
735
- "E",
736
- "F",
737
- "G",
738
- "H",
739
- "I",
740
- "J",
741
- "K",
742
- "L",
743
- "M",
744
- "N",
745
- "O",
746
- "P",
747
- "Q",
748
- "R",
749
- "S",
750
- "T",
751
- "U",
752
- "V",
753
- "W",
754
- "X",
755
- "Y",
756
- "Z"
757
- ],
758
- description: "Market Data Entry Types: 0=Bid, 1=Offer, 2=Trade, 3=Index Value, 4=Opening Price, 5=Closing Price, 6=Settlement Price, 7=High Price, 8=Low Price, 9=Trade Volume, A=Open Interest, B=Simulated Sell Price, C=Simulated Buy Price, D=Empty Book, E=Session High Bid, F=Session Low Offer, G=Fixing Price, H=Electronic Volume, I=Threshold Limits and Price Band Variation, J=Clearing Price, K=Open Interest Change, L=Last Trade Price, M=Last Trade Volume, N=Last Trade Time, O=Last Trade Tick, P=Last Trade Exchange, Q=Last Trade ID, R=Last Trade Side, S=Last Trade Price Change, T=Last Trade Price Change Percent, U=Last Trade Price Change Basis Points, V=Last Trade Price Change Points, W=Last Trade Price Change Ticks, X=Last Trade Price Change Ticks Percent, Y=Last Trade Price Change Ticks Basis Points, Z=Last Trade Price Change Ticks Points"
759
- }
760
- }
761
- },
762
- required: ["mdUpdateType", "symbols", "mdReqID", "subscriptionRequestType", "mdEntryTypes"]
763
- }
764
- },
765
- getStockGraph: {
766
- description: "Generates a price chart for a given symbol",
767
- schema: {
768
- type: "object",
769
- properties: {
770
- symbol: { type: "string" }
771
- },
772
- required: ["symbol"]
773
- }
774
- },
775
- getStockPriceHistory: {
776
- description: "Returns price history for a given symbol",
777
- schema: {
778
- type: "object",
779
- properties: {
780
- symbol: { type: "string" }
781
- },
782
- required: ["symbol"]
783
- }
784
- }
785
- };
786
-
787
796
  // src/MCPLocal.ts
788
797
  var MCPLocal = class {
789
798
  parser;
@@ -833,30 +842,43 @@ var MCPLocal = class {
833
842
  let id;
834
843
  if (msgType === import_fixparser3.Messages.MarketDataIncrementalRefresh || msgType === import_fixparser3.Messages.MarketDataSnapshotFullRefresh) {
835
844
  const symbol = message.getField(import_fixparser3.Fields.Symbol);
845
+ const entryType = message.getField(import_fixparser3.Fields.MDEntryType);
836
846
  const price = message.getField(import_fixparser3.Fields.MDEntryPx);
847
+ const size = message.getField(import_fixparser3.Fields.MDEntrySize);
837
848
  const timestamp = message.getField(import_fixparser3.Fields.MDEntryTime)?.value || Date.now();
838
849
  if (symbol?.value && price?.value) {
839
850
  const symbolStr = String(symbol.value);
840
851
  const priceNum = Number(price.value);
852
+ const sizeNum = size?.value ? Number(size.value) : 0;
841
853
  const priceHistory = this.marketDataPrices.get(symbolStr) || [];
842
- priceHistory.push({
854
+ const lastEntry = priceHistory[priceHistory.length - 1] || {
855
+ timestamp: 0,
856
+ bid: 0,
857
+ offer: 0,
858
+ spread: 0,
859
+ volume: 0
860
+ };
861
+ const newEntry = {
843
862
  timestamp: Number(timestamp),
844
- price: priceNum
845
- });
863
+ bid: entryType?.value === import_fixparser3.MDEntryType.Bid ? priceNum : lastEntry.bid,
864
+ offer: entryType?.value === import_fixparser3.MDEntryType.Offer ? priceNum : lastEntry.offer,
865
+ spread: entryType?.value === import_fixparser3.MDEntryType.Offer ? priceNum - lastEntry.bid : entryType?.value === import_fixparser3.MDEntryType.Bid ? lastEntry.offer - priceNum : lastEntry.spread,
866
+ volume: entryType?.value === import_fixparser3.MDEntryType.TradeVolume ? sizeNum : lastEntry.volume
867
+ };
868
+ priceHistory.push(newEntry);
846
869
  if (priceHistory.length > this.MAX_PRICE_HISTORY) {
847
870
  priceHistory.shift();
848
871
  }
849
872
  this.marketDataPrices.set(symbolStr, priceHistory);
850
873
  this.parser?.logger.log({
851
874
  level: "info",
852
- message: `MCP Server added ${symbol}: ${priceNum}`
875
+ message: `MCP Server added ${symbol}: ${JSON.stringify(newEntry)}`
853
876
  });
854
877
  this.server.notification({
855
878
  method: "priceUpdate",
856
879
  params: {
857
880
  symbol: symbolStr,
858
- price: priceNum,
859
- timestamp: Number(timestamp)
881
+ ...newEntry
860
882
  }
861
883
  });
862
884
  }