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.
- package/build/cjs/MCPLocal.js +328 -306
- package/build/cjs/MCPLocal.js.map +4 -4
- package/build/esm/MCPLocal.mjs +330 -308
- package/build/esm/MCPLocal.mjs.map +4 -4
- package/build-examples/cjs/example_mcp_local.js +7 -42
- package/build-examples/cjs/example_mcp_local.js.map +4 -4
- package/build-examples/esm/example_mcp_local.mjs +3 -38
- package/build-examples/esm/example_mcp_local.mjs.map +4 -4
- package/package.json +4 -4
- package/types/schemas/index.d.ts +6 -2
- package/types/schemas/schemas.d.ts +1 -1
- package/types/tools/index.d.ts +6 -3
- package/types/tools/marketData.d.ts +9 -3
package/build/esm/MCPLocal.mjs
CHANGED
|
@@ -1,18 +1,249 @@
|
|
|
1
1
|
// src/MCPLocal.ts
|
|
2
2
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
3
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
-
import { Fields as Fields3, Messages as Messages3 } from "fixparser";
|
|
4
|
+
import { Fields as Fields3, MDEntryType as MDEntryType2, Messages as Messages3 } from "fixparser";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
|
|
7
|
+
// src/schemas/schemas.ts
|
|
8
|
+
var toolSchemas = {
|
|
9
|
+
parse: {
|
|
10
|
+
description: "Parses a FIX message and describes it in plain language",
|
|
11
|
+
schema: {
|
|
12
|
+
type: "object",
|
|
13
|
+
properties: {
|
|
14
|
+
fixString: { type: "string" }
|
|
15
|
+
},
|
|
16
|
+
required: ["fixString"]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
parseToJSON: {
|
|
20
|
+
description: "Parses a FIX message into JSON",
|
|
21
|
+
schema: {
|
|
22
|
+
type: "object",
|
|
23
|
+
properties: {
|
|
24
|
+
fixString: { type: "string" }
|
|
25
|
+
},
|
|
26
|
+
required: ["fixString"]
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
verifyOrder: {
|
|
30
|
+
description: "Verifies order parameters before execution. verifyOrder must be called before executeOrder.",
|
|
31
|
+
schema: {
|
|
32
|
+
type: "object",
|
|
33
|
+
properties: {
|
|
34
|
+
clOrdID: { type: "string" },
|
|
35
|
+
handlInst: {
|
|
36
|
+
type: "string",
|
|
37
|
+
enum: ["1", "2", "3"],
|
|
38
|
+
description: "Handling Instructions: 1=Automated Execution No Intervention, 2=Automated Execution Intervention OK, 3=Manual Order"
|
|
39
|
+
},
|
|
40
|
+
quantity: { type: "string" },
|
|
41
|
+
price: { type: "string" },
|
|
42
|
+
ordType: {
|
|
43
|
+
type: "string",
|
|
44
|
+
enum: [
|
|
45
|
+
"1",
|
|
46
|
+
"2",
|
|
47
|
+
"3",
|
|
48
|
+
"4",
|
|
49
|
+
"5",
|
|
50
|
+
"6",
|
|
51
|
+
"7",
|
|
52
|
+
"8",
|
|
53
|
+
"9",
|
|
54
|
+
"A",
|
|
55
|
+
"B",
|
|
56
|
+
"C",
|
|
57
|
+
"D",
|
|
58
|
+
"E",
|
|
59
|
+
"F",
|
|
60
|
+
"G",
|
|
61
|
+
"H",
|
|
62
|
+
"I",
|
|
63
|
+
"J",
|
|
64
|
+
"K",
|
|
65
|
+
"L",
|
|
66
|
+
"M",
|
|
67
|
+
"P",
|
|
68
|
+
"Q",
|
|
69
|
+
"R",
|
|
70
|
+
"S"
|
|
71
|
+
],
|
|
72
|
+
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"
|
|
73
|
+
},
|
|
74
|
+
side: {
|
|
75
|
+
type: "string",
|
|
76
|
+
enum: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H"],
|
|
77
|
+
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"
|
|
78
|
+
},
|
|
79
|
+
symbol: { type: "string" },
|
|
80
|
+
timeInForce: {
|
|
81
|
+
type: "string",
|
|
82
|
+
enum: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C"],
|
|
83
|
+
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"
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
required: ["clOrdID", "handlInst", "quantity", "price", "ordType", "side", "symbol", "timeInForce"]
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
executeOrder: {
|
|
90
|
+
description: "Executes a verified order. verifyOrder must be called before executeOrder. user has to explicitly allow executeOrder.",
|
|
91
|
+
schema: {
|
|
92
|
+
type: "object",
|
|
93
|
+
properties: {
|
|
94
|
+
clOrdID: { type: "string" },
|
|
95
|
+
handlInst: {
|
|
96
|
+
type: "string",
|
|
97
|
+
enum: ["1", "2", "3"],
|
|
98
|
+
description: "Handling Instructions: 1=Automated Execution No Intervention, 2=Automated Execution Intervention OK, 3=Manual Order"
|
|
99
|
+
},
|
|
100
|
+
quantity: { type: "string" },
|
|
101
|
+
price: { type: "string" },
|
|
102
|
+
ordType: {
|
|
103
|
+
type: "string",
|
|
104
|
+
enum: [
|
|
105
|
+
"1",
|
|
106
|
+
"2",
|
|
107
|
+
"3",
|
|
108
|
+
"4",
|
|
109
|
+
"5",
|
|
110
|
+
"6",
|
|
111
|
+
"7",
|
|
112
|
+
"8",
|
|
113
|
+
"9",
|
|
114
|
+
"A",
|
|
115
|
+
"B",
|
|
116
|
+
"C",
|
|
117
|
+
"D",
|
|
118
|
+
"E",
|
|
119
|
+
"F",
|
|
120
|
+
"G",
|
|
121
|
+
"H",
|
|
122
|
+
"I",
|
|
123
|
+
"J",
|
|
124
|
+
"K",
|
|
125
|
+
"L",
|
|
126
|
+
"M",
|
|
127
|
+
"P",
|
|
128
|
+
"Q",
|
|
129
|
+
"R",
|
|
130
|
+
"S"
|
|
131
|
+
],
|
|
132
|
+
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"
|
|
133
|
+
},
|
|
134
|
+
side: {
|
|
135
|
+
type: "string",
|
|
136
|
+
enum: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H"],
|
|
137
|
+
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"
|
|
138
|
+
},
|
|
139
|
+
symbol: { type: "string" },
|
|
140
|
+
timeInForce: {
|
|
141
|
+
type: "string",
|
|
142
|
+
enum: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C"],
|
|
143
|
+
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"
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
required: ["clOrdID", "handlInst", "quantity", "price", "ordType", "side", "symbol", "timeInForce"]
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
marketDataRequest: {
|
|
150
|
+
description: "Requests market data for specified symbols",
|
|
151
|
+
schema: {
|
|
152
|
+
type: "object",
|
|
153
|
+
properties: {
|
|
154
|
+
mdUpdateType: {
|
|
155
|
+
type: "string",
|
|
156
|
+
enum: ["0", "1"],
|
|
157
|
+
description: "Market Data Update Type: 0=Full Refresh, 1=Incremental Refresh"
|
|
158
|
+
},
|
|
159
|
+
symbols: { type: "array", items: { type: "string" } },
|
|
160
|
+
mdReqID: { type: "string" },
|
|
161
|
+
subscriptionRequestType: {
|
|
162
|
+
type: "string",
|
|
163
|
+
enum: ["0", "1", "2"],
|
|
164
|
+
description: "Subscription Request Type: 0=Snapshot, 1=Snapshot + Updates, 2=Disable Previous Snapshot + Update Request"
|
|
165
|
+
},
|
|
166
|
+
mdEntryTypes: {
|
|
167
|
+
type: "array",
|
|
168
|
+
items: {
|
|
169
|
+
type: "string",
|
|
170
|
+
enum: [
|
|
171
|
+
"0",
|
|
172
|
+
"1",
|
|
173
|
+
"2",
|
|
174
|
+
"3",
|
|
175
|
+
"4",
|
|
176
|
+
"5",
|
|
177
|
+
"6",
|
|
178
|
+
"7",
|
|
179
|
+
"8",
|
|
180
|
+
"9",
|
|
181
|
+
"A",
|
|
182
|
+
"B",
|
|
183
|
+
"C",
|
|
184
|
+
"D",
|
|
185
|
+
"E",
|
|
186
|
+
"F",
|
|
187
|
+
"G",
|
|
188
|
+
"H",
|
|
189
|
+
"I",
|
|
190
|
+
"J",
|
|
191
|
+
"K",
|
|
192
|
+
"L",
|
|
193
|
+
"M",
|
|
194
|
+
"N",
|
|
195
|
+
"O",
|
|
196
|
+
"P",
|
|
197
|
+
"Q",
|
|
198
|
+
"R",
|
|
199
|
+
"S",
|
|
200
|
+
"T",
|
|
201
|
+
"U",
|
|
202
|
+
"V",
|
|
203
|
+
"W",
|
|
204
|
+
"X",
|
|
205
|
+
"Y",
|
|
206
|
+
"Z"
|
|
207
|
+
]
|
|
208
|
+
},
|
|
209
|
+
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"
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
required: ["mdUpdateType", "symbols", "mdReqID", "subscriptionRequestType"]
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
getStockGraph: {
|
|
216
|
+
description: "Generates a price chart for a given symbol",
|
|
217
|
+
schema: {
|
|
218
|
+
type: "object",
|
|
219
|
+
properties: {
|
|
220
|
+
symbol: { type: "string" }
|
|
221
|
+
},
|
|
222
|
+
required: ["symbol"]
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
getStockPriceHistory: {
|
|
226
|
+
description: "Returns price history for a given symbol",
|
|
227
|
+
schema: {
|
|
228
|
+
type: "object",
|
|
229
|
+
properties: {
|
|
230
|
+
symbol: { type: "string" }
|
|
231
|
+
},
|
|
232
|
+
required: ["symbol"]
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
|
|
7
237
|
// src/tools/marketData.ts
|
|
8
|
-
import { Field, Fields, Messages } from "fixparser";
|
|
9
|
-
import
|
|
238
|
+
import { Field, Fields, MDEntryType, Messages } from "fixparser";
|
|
239
|
+
import QuickChart from "quickchart-js";
|
|
10
240
|
var createMarketDataRequestHandler = (parser, pendingRequests) => {
|
|
11
241
|
return async (args) => {
|
|
12
242
|
try {
|
|
13
243
|
const response = new Promise((resolve) => {
|
|
14
244
|
pendingRequests.set(args.mdReqID, resolve);
|
|
15
245
|
});
|
|
246
|
+
const entryTypes = args.mdEntryTypes || [MDEntryType.Bid, MDEntryType.Offer, MDEntryType.TradeVolume];
|
|
16
247
|
const messageFields = [
|
|
17
248
|
new Field(Fields.MsgType, Messages.MarketDataRequest),
|
|
18
249
|
new Field(Fields.SenderCompID, parser.sender),
|
|
@@ -28,8 +259,8 @@ var createMarketDataRequestHandler = (parser, pendingRequests) => {
|
|
|
28
259
|
args.symbols.forEach((symbol) => {
|
|
29
260
|
messageFields.push(new Field(Fields.Symbol, symbol));
|
|
30
261
|
});
|
|
31
|
-
messageFields.push(new Field(Fields.NoMDEntryTypes,
|
|
32
|
-
|
|
262
|
+
messageFields.push(new Field(Fields.NoMDEntryTypes, entryTypes.length));
|
|
263
|
+
entryTypes.forEach((entryType) => {
|
|
33
264
|
messageFields.push(new Field(Fields.MDEntryType, entryType));
|
|
34
265
|
});
|
|
35
266
|
const mdr = parser.createMessage(...messageFields);
|
|
@@ -86,74 +317,79 @@ var createGetStockGraphHandler = (marketDataPrices) => {
|
|
|
86
317
|
]
|
|
87
318
|
};
|
|
88
319
|
}
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const
|
|
93
|
-
const
|
|
94
|
-
const
|
|
95
|
-
const
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
320
|
+
const chart = new QuickChart();
|
|
321
|
+
chart.setWidth(600);
|
|
322
|
+
chart.setHeight(300);
|
|
323
|
+
const labels = priceHistory.map((point) => new Date(point.timestamp).toLocaleTimeString());
|
|
324
|
+
const bidData = priceHistory.map((point) => point.bid);
|
|
325
|
+
const offerData = priceHistory.map((point) => point.offer);
|
|
326
|
+
const spreadData = priceHistory.map((point) => point.spread);
|
|
327
|
+
const volumeData = priceHistory.map((point) => point.volume);
|
|
328
|
+
const config = {
|
|
329
|
+
type: "line",
|
|
330
|
+
data: {
|
|
331
|
+
labels,
|
|
332
|
+
datasets: [
|
|
333
|
+
{
|
|
334
|
+
label: "Bid",
|
|
335
|
+
data: bidData,
|
|
336
|
+
borderColor: "#28a745",
|
|
337
|
+
backgroundColor: "rgba(40, 167, 69, 0.1)",
|
|
338
|
+
fill: false,
|
|
339
|
+
tension: 0.4
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
label: "Offer",
|
|
343
|
+
data: offerData,
|
|
344
|
+
borderColor: "#dc3545",
|
|
345
|
+
backgroundColor: "rgba(220, 53, 69, 0.1)",
|
|
346
|
+
fill: false,
|
|
347
|
+
tension: 0.4
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
label: "Spread",
|
|
351
|
+
data: spreadData,
|
|
352
|
+
borderColor: "#6c757d",
|
|
353
|
+
backgroundColor: "rgba(108, 117, 125, 0.1)",
|
|
354
|
+
fill: false,
|
|
355
|
+
tension: 0.4
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
label: "Volume",
|
|
359
|
+
data: volumeData,
|
|
360
|
+
borderColor: "#007bff",
|
|
361
|
+
backgroundColor: "rgba(0, 123, 255, 0.1)",
|
|
362
|
+
fill: true,
|
|
363
|
+
tension: 0.4
|
|
364
|
+
}
|
|
365
|
+
]
|
|
366
|
+
},
|
|
367
|
+
options: {
|
|
368
|
+
responsive: true,
|
|
369
|
+
plugins: {
|
|
370
|
+
title: {
|
|
371
|
+
display: true,
|
|
372
|
+
text: `${symbol} Market Data`
|
|
373
|
+
}
|
|
374
|
+
},
|
|
375
|
+
scales: {
|
|
376
|
+
y: {
|
|
377
|
+
beginAtZero: false
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
chart.setConfig(config);
|
|
383
|
+
const imageBuffer = await chart.toBinary();
|
|
384
|
+
const base64Image = imageBuffer.toString("base64");
|
|
151
385
|
return {
|
|
152
386
|
content: [
|
|
153
387
|
{
|
|
154
388
|
type: "image",
|
|
155
|
-
|
|
156
|
-
|
|
389
|
+
source: {
|
|
390
|
+
filename: "graph.png",
|
|
391
|
+
data: `data:image/png;base64,${base64Image}`
|
|
392
|
+
},
|
|
157
393
|
mimeType: "image/png"
|
|
158
394
|
}
|
|
159
395
|
]
|
|
@@ -163,7 +399,7 @@ var createGetStockGraphHandler = (marketDataPrices) => {
|
|
|
163
399
|
content: [
|
|
164
400
|
{
|
|
165
401
|
type: "text",
|
|
166
|
-
text: `Error: ${error instanceof Error ? error.message : "Failed to generate
|
|
402
|
+
text: `Error: ${error instanceof Error ? error.message : "Failed to generate chart"}`,
|
|
167
403
|
uri: "getStockGraph"
|
|
168
404
|
}
|
|
169
405
|
],
|
|
@@ -196,9 +432,12 @@ var createGetStockPriceHistoryHandler = (marketDataPrices) => {
|
|
|
196
432
|
{
|
|
197
433
|
symbol,
|
|
198
434
|
count: priceHistory.length,
|
|
199
|
-
|
|
435
|
+
data: priceHistory.map((point) => ({
|
|
200
436
|
timestamp: new Date(point.timestamp).toISOString(),
|
|
201
|
-
|
|
437
|
+
bid: point.bid,
|
|
438
|
+
offer: point.offer,
|
|
439
|
+
spread: point.spread,
|
|
440
|
+
volume: point.volume
|
|
202
441
|
}))
|
|
203
442
|
},
|
|
204
443
|
null,
|
|
@@ -520,236 +759,6 @@ var createToolHandlers = (parser, verifiedOrders, pendingRequests, marketDataPri
|
|
|
520
759
|
getStockPriceHistory: createGetStockPriceHistoryHandler(marketDataPrices)
|
|
521
760
|
});
|
|
522
761
|
|
|
523
|
-
// src/schemas/schemas.ts
|
|
524
|
-
var toolSchemas = {
|
|
525
|
-
parse: {
|
|
526
|
-
description: "Parses a FIX message and describes it in plain language",
|
|
527
|
-
schema: {
|
|
528
|
-
type: "object",
|
|
529
|
-
properties: {
|
|
530
|
-
fixString: { type: "string" }
|
|
531
|
-
},
|
|
532
|
-
required: ["fixString"]
|
|
533
|
-
}
|
|
534
|
-
},
|
|
535
|
-
parseToJSON: {
|
|
536
|
-
description: "Parses a FIX message into JSON",
|
|
537
|
-
schema: {
|
|
538
|
-
type: "object",
|
|
539
|
-
properties: {
|
|
540
|
-
fixString: { type: "string" }
|
|
541
|
-
},
|
|
542
|
-
required: ["fixString"]
|
|
543
|
-
}
|
|
544
|
-
},
|
|
545
|
-
verifyOrder: {
|
|
546
|
-
description: "Verifies order parameters before execution. verifyOrder must be called before executeOrder.",
|
|
547
|
-
schema: {
|
|
548
|
-
type: "object",
|
|
549
|
-
properties: {
|
|
550
|
-
clOrdID: { type: "string" },
|
|
551
|
-
handlInst: {
|
|
552
|
-
type: "string",
|
|
553
|
-
enum: ["1", "2", "3"],
|
|
554
|
-
description: "Handling Instructions: 1=Automated Execution No Intervention, 2=Automated Execution Intervention OK, 3=Manual Order"
|
|
555
|
-
},
|
|
556
|
-
quantity: { type: "string" },
|
|
557
|
-
price: { type: "string" },
|
|
558
|
-
ordType: {
|
|
559
|
-
type: "string",
|
|
560
|
-
enum: [
|
|
561
|
-
"1",
|
|
562
|
-
"2",
|
|
563
|
-
"3",
|
|
564
|
-
"4",
|
|
565
|
-
"5",
|
|
566
|
-
"6",
|
|
567
|
-
"7",
|
|
568
|
-
"8",
|
|
569
|
-
"9",
|
|
570
|
-
"A",
|
|
571
|
-
"B",
|
|
572
|
-
"C",
|
|
573
|
-
"D",
|
|
574
|
-
"E",
|
|
575
|
-
"F",
|
|
576
|
-
"G",
|
|
577
|
-
"H",
|
|
578
|
-
"I",
|
|
579
|
-
"J",
|
|
580
|
-
"K",
|
|
581
|
-
"L",
|
|
582
|
-
"M",
|
|
583
|
-
"P",
|
|
584
|
-
"Q",
|
|
585
|
-
"R",
|
|
586
|
-
"S"
|
|
587
|
-
],
|
|
588
|
-
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"
|
|
589
|
-
},
|
|
590
|
-
side: {
|
|
591
|
-
type: "string",
|
|
592
|
-
enum: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H"],
|
|
593
|
-
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"
|
|
594
|
-
},
|
|
595
|
-
symbol: { type: "string" },
|
|
596
|
-
timeInForce: {
|
|
597
|
-
type: "string",
|
|
598
|
-
enum: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C"],
|
|
599
|
-
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"
|
|
600
|
-
}
|
|
601
|
-
},
|
|
602
|
-
required: ["clOrdID", "handlInst", "quantity", "price", "ordType", "side", "symbol", "timeInForce"]
|
|
603
|
-
}
|
|
604
|
-
},
|
|
605
|
-
executeOrder: {
|
|
606
|
-
description: "Executes a verified order. verifyOrder must be called before executeOrder. user has to explicitly allow executeOrder.",
|
|
607
|
-
schema: {
|
|
608
|
-
type: "object",
|
|
609
|
-
properties: {
|
|
610
|
-
clOrdID: { type: "string" },
|
|
611
|
-
handlInst: {
|
|
612
|
-
type: "string",
|
|
613
|
-
enum: ["1", "2", "3"],
|
|
614
|
-
description: "Handling Instructions: 1=Automated Execution No Intervention, 2=Automated Execution Intervention OK, 3=Manual Order"
|
|
615
|
-
},
|
|
616
|
-
quantity: { type: "string" },
|
|
617
|
-
price: { type: "string" },
|
|
618
|
-
ordType: {
|
|
619
|
-
type: "string",
|
|
620
|
-
enum: [
|
|
621
|
-
"1",
|
|
622
|
-
"2",
|
|
623
|
-
"3",
|
|
624
|
-
"4",
|
|
625
|
-
"5",
|
|
626
|
-
"6",
|
|
627
|
-
"7",
|
|
628
|
-
"8",
|
|
629
|
-
"9",
|
|
630
|
-
"A",
|
|
631
|
-
"B",
|
|
632
|
-
"C",
|
|
633
|
-
"D",
|
|
634
|
-
"E",
|
|
635
|
-
"F",
|
|
636
|
-
"G",
|
|
637
|
-
"H",
|
|
638
|
-
"I",
|
|
639
|
-
"J",
|
|
640
|
-
"K",
|
|
641
|
-
"L",
|
|
642
|
-
"M",
|
|
643
|
-
"P",
|
|
644
|
-
"Q",
|
|
645
|
-
"R",
|
|
646
|
-
"S"
|
|
647
|
-
],
|
|
648
|
-
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"
|
|
649
|
-
},
|
|
650
|
-
side: {
|
|
651
|
-
type: "string",
|
|
652
|
-
enum: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H"],
|
|
653
|
-
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"
|
|
654
|
-
},
|
|
655
|
-
symbol: { type: "string" },
|
|
656
|
-
timeInForce: {
|
|
657
|
-
type: "string",
|
|
658
|
-
enum: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C"],
|
|
659
|
-
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"
|
|
660
|
-
}
|
|
661
|
-
},
|
|
662
|
-
required: ["clOrdID", "handlInst", "quantity", "price", "ordType", "side", "symbol", "timeInForce"]
|
|
663
|
-
}
|
|
664
|
-
},
|
|
665
|
-
marketDataRequest: {
|
|
666
|
-
description: "Requests market data for specified symbols",
|
|
667
|
-
schema: {
|
|
668
|
-
type: "object",
|
|
669
|
-
properties: {
|
|
670
|
-
mdUpdateType: {
|
|
671
|
-
type: "string",
|
|
672
|
-
enum: ["0", "1"],
|
|
673
|
-
description: "Market Data Update Type: 0=Full Refresh, 1=Incremental Refresh"
|
|
674
|
-
},
|
|
675
|
-
symbols: { type: "array", items: { type: "string" } },
|
|
676
|
-
mdReqID: { type: "string" },
|
|
677
|
-
subscriptionRequestType: {
|
|
678
|
-
type: "string",
|
|
679
|
-
enum: ["0", "1", "2"],
|
|
680
|
-
description: "Subscription Request Type: 0=Snapshot, 1=Snapshot + Updates, 2=Disable Previous Snapshot + Update Request"
|
|
681
|
-
},
|
|
682
|
-
mdEntryTypes: {
|
|
683
|
-
type: "array",
|
|
684
|
-
items: {
|
|
685
|
-
type: "string",
|
|
686
|
-
enum: [
|
|
687
|
-
"0",
|
|
688
|
-
"1",
|
|
689
|
-
"2",
|
|
690
|
-
"3",
|
|
691
|
-
"4",
|
|
692
|
-
"5",
|
|
693
|
-
"6",
|
|
694
|
-
"7",
|
|
695
|
-
"8",
|
|
696
|
-
"9",
|
|
697
|
-
"A",
|
|
698
|
-
"B",
|
|
699
|
-
"C",
|
|
700
|
-
"D",
|
|
701
|
-
"E",
|
|
702
|
-
"F",
|
|
703
|
-
"G",
|
|
704
|
-
"H",
|
|
705
|
-
"I",
|
|
706
|
-
"J",
|
|
707
|
-
"K",
|
|
708
|
-
"L",
|
|
709
|
-
"M",
|
|
710
|
-
"N",
|
|
711
|
-
"O",
|
|
712
|
-
"P",
|
|
713
|
-
"Q",
|
|
714
|
-
"R",
|
|
715
|
-
"S",
|
|
716
|
-
"T",
|
|
717
|
-
"U",
|
|
718
|
-
"V",
|
|
719
|
-
"W",
|
|
720
|
-
"X",
|
|
721
|
-
"Y",
|
|
722
|
-
"Z"
|
|
723
|
-
],
|
|
724
|
-
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"
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
},
|
|
728
|
-
required: ["mdUpdateType", "symbols", "mdReqID", "subscriptionRequestType", "mdEntryTypes"]
|
|
729
|
-
}
|
|
730
|
-
},
|
|
731
|
-
getStockGraph: {
|
|
732
|
-
description: "Generates a price chart for a given symbol",
|
|
733
|
-
schema: {
|
|
734
|
-
type: "object",
|
|
735
|
-
properties: {
|
|
736
|
-
symbol: { type: "string" }
|
|
737
|
-
},
|
|
738
|
-
required: ["symbol"]
|
|
739
|
-
}
|
|
740
|
-
},
|
|
741
|
-
getStockPriceHistory: {
|
|
742
|
-
description: "Returns price history for a given symbol",
|
|
743
|
-
schema: {
|
|
744
|
-
type: "object",
|
|
745
|
-
properties: {
|
|
746
|
-
symbol: { type: "string" }
|
|
747
|
-
},
|
|
748
|
-
required: ["symbol"]
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
};
|
|
752
|
-
|
|
753
762
|
// src/MCPLocal.ts
|
|
754
763
|
var MCPLocal = class {
|
|
755
764
|
parser;
|
|
@@ -799,30 +808,43 @@ var MCPLocal = class {
|
|
|
799
808
|
let id;
|
|
800
809
|
if (msgType === Messages3.MarketDataIncrementalRefresh || msgType === Messages3.MarketDataSnapshotFullRefresh) {
|
|
801
810
|
const symbol = message.getField(Fields3.Symbol);
|
|
811
|
+
const entryType = message.getField(Fields3.MDEntryType);
|
|
802
812
|
const price = message.getField(Fields3.MDEntryPx);
|
|
813
|
+
const size = message.getField(Fields3.MDEntrySize);
|
|
803
814
|
const timestamp = message.getField(Fields3.MDEntryTime)?.value || Date.now();
|
|
804
815
|
if (symbol?.value && price?.value) {
|
|
805
816
|
const symbolStr = String(symbol.value);
|
|
806
817
|
const priceNum = Number(price.value);
|
|
818
|
+
const sizeNum = size?.value ? Number(size.value) : 0;
|
|
807
819
|
const priceHistory = this.marketDataPrices.get(symbolStr) || [];
|
|
808
|
-
priceHistory.
|
|
820
|
+
const lastEntry = priceHistory[priceHistory.length - 1] || {
|
|
821
|
+
timestamp: 0,
|
|
822
|
+
bid: 0,
|
|
823
|
+
offer: 0,
|
|
824
|
+
spread: 0,
|
|
825
|
+
volume: 0
|
|
826
|
+
};
|
|
827
|
+
const newEntry = {
|
|
809
828
|
timestamp: Number(timestamp),
|
|
810
|
-
|
|
811
|
-
|
|
829
|
+
bid: entryType?.value === MDEntryType2.Bid ? priceNum : lastEntry.bid,
|
|
830
|
+
offer: entryType?.value === MDEntryType2.Offer ? priceNum : lastEntry.offer,
|
|
831
|
+
spread: entryType?.value === MDEntryType2.Offer ? priceNum - lastEntry.bid : entryType?.value === MDEntryType2.Bid ? lastEntry.offer - priceNum : lastEntry.spread,
|
|
832
|
+
volume: entryType?.value === MDEntryType2.TradeVolume ? sizeNum : lastEntry.volume
|
|
833
|
+
};
|
|
834
|
+
priceHistory.push(newEntry);
|
|
812
835
|
if (priceHistory.length > this.MAX_PRICE_HISTORY) {
|
|
813
836
|
priceHistory.shift();
|
|
814
837
|
}
|
|
815
838
|
this.marketDataPrices.set(symbolStr, priceHistory);
|
|
816
839
|
this.parser?.logger.log({
|
|
817
840
|
level: "info",
|
|
818
|
-
message: `MCP Server added ${symbol}: ${
|
|
841
|
+
message: `MCP Server added ${symbol}: ${JSON.stringify(newEntry)}`
|
|
819
842
|
});
|
|
820
843
|
this.server.notification({
|
|
821
844
|
method: "priceUpdate",
|
|
822
845
|
params: {
|
|
823
846
|
symbol: symbolStr,
|
|
824
|
-
|
|
825
|
-
timestamp: Number(timestamp)
|
|
847
|
+
...newEntry
|
|
826
848
|
}
|
|
827
849
|
});
|
|
828
850
|
}
|