fixparser-plugin-mcp 9.1.7-a24bdbec → 9.1.7-abf6e45c
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 +963 -533
- package/build/cjs/MCPLocal.js.map +2 -2
- package/build/esm/MCPLocal.mjs +963 -539
- package/build/esm/MCPLocal.mjs.map +2 -2
- package/build-examples/cjs/example_mcp_local.js +49 -4
- package/build-examples/cjs/example_mcp_local.js.map +4 -4
- package/build-examples/esm/example_mcp_local.mjs +49 -4
- package/build-examples/esm/example_mcp_local.mjs.map +4 -4
- package/package.json +4 -5
- package/types/MCPLocal.d.ts +3 -0
package/build/cjs/MCPLocal.js
CHANGED
|
@@ -25,173 +25,106 @@ __export(MCPLocal_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(MCPLocal_exports);
|
|
26
26
|
var import_server = require("@modelcontextprotocol/sdk/server/index.js");
|
|
27
27
|
var import_stdio = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
28
|
-
var import_types = require("@modelcontextprotocol/sdk/types.js");
|
|
29
28
|
var import_fixparser = require("fixparser");
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
|
-
type: "string",
|
|
129
|
-
description: "Trading symbol"
|
|
130
|
-
},
|
|
131
|
-
mdReqID: {
|
|
132
|
-
type: "string",
|
|
133
|
-
description: "Market data request ID"
|
|
134
|
-
},
|
|
135
|
-
subscriptionRequestType: {
|
|
136
|
-
type: "string",
|
|
137
|
-
enum: ["0", "1", "2"],
|
|
138
|
-
description: 'Subscription request type (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use "0" for Snapshot + Updates, "1" for Snapshot, "2" for Unsubscribe)'
|
|
139
|
-
},
|
|
140
|
-
mdEntryType: {
|
|
141
|
-
type: "string",
|
|
142
|
-
enum: [
|
|
143
|
-
"0",
|
|
144
|
-
"1",
|
|
145
|
-
"2",
|
|
146
|
-
"3",
|
|
147
|
-
"4",
|
|
148
|
-
"5",
|
|
149
|
-
"6",
|
|
150
|
-
"7",
|
|
151
|
-
"8",
|
|
152
|
-
"9",
|
|
153
|
-
"A",
|
|
154
|
-
"B",
|
|
155
|
-
"C",
|
|
156
|
-
"D",
|
|
157
|
-
"E",
|
|
158
|
-
"F",
|
|
159
|
-
"G",
|
|
160
|
-
"H",
|
|
161
|
-
"J",
|
|
162
|
-
"K",
|
|
163
|
-
"L",
|
|
164
|
-
"M",
|
|
165
|
-
"N",
|
|
166
|
-
"O",
|
|
167
|
-
"P",
|
|
168
|
-
"Q",
|
|
169
|
-
"S",
|
|
170
|
-
"R",
|
|
171
|
-
"T",
|
|
172
|
-
"U",
|
|
173
|
-
"V",
|
|
174
|
-
"W",
|
|
175
|
-
"X",
|
|
176
|
-
"Y",
|
|
177
|
-
"Z",
|
|
178
|
-
"a",
|
|
179
|
-
"b",
|
|
180
|
-
"c",
|
|
181
|
-
"d",
|
|
182
|
-
"e",
|
|
183
|
-
"g",
|
|
184
|
-
"h",
|
|
185
|
-
"i",
|
|
186
|
-
"t"
|
|
187
|
-
],
|
|
188
|
-
description: 'Market data entry type (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use "0" for Bid, "1" for Offer, "2" for Trade, "3" for Index Value, "4" for Opening Price)'
|
|
189
|
-
}
|
|
190
|
-
},
|
|
191
|
-
required: ["symbol", "mdReqID"]
|
|
192
|
-
};
|
|
29
|
+
var import_zod = require("zod");
|
|
30
|
+
var symbolSchema = import_zod.z.object({
|
|
31
|
+
symbol: import_zod.z.string()
|
|
32
|
+
});
|
|
33
|
+
var fixStringSchema = import_zod.z.object({
|
|
34
|
+
fixString: import_zod.z.string()
|
|
35
|
+
});
|
|
36
|
+
var orderSchema = import_zod.z.object({
|
|
37
|
+
clOrdID: import_zod.z.string(),
|
|
38
|
+
handlInst: import_zod.z.enum(["1", "2", "3"]),
|
|
39
|
+
quantity: import_zod.z.string(),
|
|
40
|
+
price: import_zod.z.string(),
|
|
41
|
+
ordType: import_zod.z.enum([
|
|
42
|
+
"1",
|
|
43
|
+
"2",
|
|
44
|
+
"3",
|
|
45
|
+
"4",
|
|
46
|
+
"5",
|
|
47
|
+
"6",
|
|
48
|
+
"7",
|
|
49
|
+
"8",
|
|
50
|
+
"9",
|
|
51
|
+
"A",
|
|
52
|
+
"B",
|
|
53
|
+
"C",
|
|
54
|
+
"D",
|
|
55
|
+
"E",
|
|
56
|
+
"F",
|
|
57
|
+
"G",
|
|
58
|
+
"H",
|
|
59
|
+
"I",
|
|
60
|
+
"J",
|
|
61
|
+
"K",
|
|
62
|
+
"L",
|
|
63
|
+
"M",
|
|
64
|
+
"P",
|
|
65
|
+
"Q",
|
|
66
|
+
"R",
|
|
67
|
+
"S"
|
|
68
|
+
]),
|
|
69
|
+
side: import_zod.z.enum(["1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H"]),
|
|
70
|
+
symbol: import_zod.z.string(),
|
|
71
|
+
timeInForce: import_zod.z.enum(["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C"])
|
|
72
|
+
});
|
|
73
|
+
var marketDataRequestSchema = import_zod.z.object({
|
|
74
|
+
mdUpdateType: import_zod.z.enum(["0", "1"]),
|
|
75
|
+
symbols: import_zod.z.array(import_zod.z.string()),
|
|
76
|
+
mdReqID: import_zod.z.string(),
|
|
77
|
+
subscriptionRequestType: import_zod.z.enum(["0", "1", "2"]),
|
|
78
|
+
mdEntryTypes: import_zod.z.array(
|
|
79
|
+
import_zod.z.enum([
|
|
80
|
+
"0",
|
|
81
|
+
"1",
|
|
82
|
+
"2",
|
|
83
|
+
"3",
|
|
84
|
+
"4",
|
|
85
|
+
"5",
|
|
86
|
+
"6",
|
|
87
|
+
"7",
|
|
88
|
+
"8",
|
|
89
|
+
"9",
|
|
90
|
+
"A",
|
|
91
|
+
"B",
|
|
92
|
+
"C",
|
|
93
|
+
"D",
|
|
94
|
+
"E",
|
|
95
|
+
"F",
|
|
96
|
+
"G",
|
|
97
|
+
"H",
|
|
98
|
+
"J",
|
|
99
|
+
"K",
|
|
100
|
+
"L",
|
|
101
|
+
"M",
|
|
102
|
+
"N",
|
|
103
|
+
"O",
|
|
104
|
+
"P",
|
|
105
|
+
"Q",
|
|
106
|
+
"R",
|
|
107
|
+
"S",
|
|
108
|
+
"T",
|
|
109
|
+
"U",
|
|
110
|
+
"V",
|
|
111
|
+
"W",
|
|
112
|
+
"X",
|
|
113
|
+
"Y",
|
|
114
|
+
"Z",
|
|
115
|
+
"a",
|
|
116
|
+
"b",
|
|
117
|
+
"c",
|
|
118
|
+
"d",
|
|
119
|
+
"e",
|
|
120
|
+
"g",
|
|
121
|
+
"h",
|
|
122
|
+
"i",
|
|
123
|
+
"t"
|
|
124
|
+
])
|
|
125
|
+
)
|
|
126
|
+
});
|
|
193
127
|
var MCPLocal = class {
|
|
194
|
-
// private logger: Logger | undefined;
|
|
195
128
|
parser;
|
|
196
129
|
server = new import_server.Server(
|
|
197
130
|
{
|
|
@@ -200,43 +133,241 @@ var MCPLocal = class {
|
|
|
200
133
|
},
|
|
201
134
|
{
|
|
202
135
|
capabilities: {
|
|
203
|
-
tools: {
|
|
204
|
-
|
|
205
|
-
|
|
136
|
+
tools: {
|
|
137
|
+
parse: {
|
|
138
|
+
description: "Parses a FIX message and describes it in plain language",
|
|
139
|
+
parameters: {
|
|
140
|
+
type: "object",
|
|
141
|
+
properties: {
|
|
142
|
+
fixString: { type: "string" }
|
|
143
|
+
},
|
|
144
|
+
required: ["fixString"]
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
parseToJSON: {
|
|
148
|
+
description: "Parses a FIX message into JSON",
|
|
149
|
+
parameters: {
|
|
150
|
+
type: "object",
|
|
151
|
+
properties: {
|
|
152
|
+
fixString: { type: "string" }
|
|
153
|
+
},
|
|
154
|
+
required: ["fixString"]
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
verifyOrder: {
|
|
158
|
+
description: "Verifies order parameters before execution",
|
|
159
|
+
parameters: {
|
|
160
|
+
type: "object",
|
|
161
|
+
properties: {
|
|
162
|
+
clOrdID: { type: "string" },
|
|
163
|
+
handlInst: { type: "string", enum: ["1", "2", "3"] },
|
|
164
|
+
quantity: { type: "string" },
|
|
165
|
+
price: { type: "string" },
|
|
166
|
+
ordType: {
|
|
167
|
+
type: "string",
|
|
168
|
+
enum: [
|
|
169
|
+
"1",
|
|
170
|
+
"2",
|
|
171
|
+
"3",
|
|
172
|
+
"4",
|
|
173
|
+
"5",
|
|
174
|
+
"6",
|
|
175
|
+
"7",
|
|
176
|
+
"8",
|
|
177
|
+
"9",
|
|
178
|
+
"A",
|
|
179
|
+
"B",
|
|
180
|
+
"C",
|
|
181
|
+
"D",
|
|
182
|
+
"E",
|
|
183
|
+
"F",
|
|
184
|
+
"G",
|
|
185
|
+
"H",
|
|
186
|
+
"I",
|
|
187
|
+
"J",
|
|
188
|
+
"K",
|
|
189
|
+
"L",
|
|
190
|
+
"M",
|
|
191
|
+
"P",
|
|
192
|
+
"Q",
|
|
193
|
+
"R",
|
|
194
|
+
"S"
|
|
195
|
+
]
|
|
196
|
+
},
|
|
197
|
+
side: {
|
|
198
|
+
type: "string",
|
|
199
|
+
enum: [
|
|
200
|
+
"1",
|
|
201
|
+
"2",
|
|
202
|
+
"3",
|
|
203
|
+
"4",
|
|
204
|
+
"5",
|
|
205
|
+
"6",
|
|
206
|
+
"7",
|
|
207
|
+
"8",
|
|
208
|
+
"9",
|
|
209
|
+
"A",
|
|
210
|
+
"B",
|
|
211
|
+
"C",
|
|
212
|
+
"D",
|
|
213
|
+
"E",
|
|
214
|
+
"F",
|
|
215
|
+
"G",
|
|
216
|
+
"H"
|
|
217
|
+
]
|
|
218
|
+
},
|
|
219
|
+
symbol: { type: "string" },
|
|
220
|
+
timeInForce: {
|
|
221
|
+
type: "string",
|
|
222
|
+
enum: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C"]
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
required: [
|
|
226
|
+
"clOrdID",
|
|
227
|
+
"handlInst",
|
|
228
|
+
"quantity",
|
|
229
|
+
"price",
|
|
230
|
+
"ordType",
|
|
231
|
+
"side",
|
|
232
|
+
"symbol",
|
|
233
|
+
"timeInForce"
|
|
234
|
+
]
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
executeOrder: {
|
|
238
|
+
description: "Executes a verified order",
|
|
239
|
+
parameters: {
|
|
240
|
+
type: "object",
|
|
241
|
+
properties: {
|
|
242
|
+
clOrdID: { type: "string" },
|
|
243
|
+
handlInst: { type: "string", enum: ["1", "2", "3"] },
|
|
244
|
+
quantity: { type: "string" },
|
|
245
|
+
price: { type: "string" },
|
|
246
|
+
ordType: { type: "string" },
|
|
247
|
+
side: { type: "string" },
|
|
248
|
+
symbol: { type: "string" },
|
|
249
|
+
timeInForce: { type: "string" }
|
|
250
|
+
},
|
|
251
|
+
required: [
|
|
252
|
+
"clOrdID",
|
|
253
|
+
"handlInst",
|
|
254
|
+
"quantity",
|
|
255
|
+
"price",
|
|
256
|
+
"ordType",
|
|
257
|
+
"side",
|
|
258
|
+
"symbol",
|
|
259
|
+
"timeInForce"
|
|
260
|
+
]
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
marketDataRequest: {
|
|
264
|
+
description: "Requests market data for specified symbols",
|
|
265
|
+
parameters: {
|
|
266
|
+
type: "object",
|
|
267
|
+
properties: {
|
|
268
|
+
mdUpdateType: { type: "string", enum: ["0", "1"] },
|
|
269
|
+
symbols: { type: "array", items: { type: "string" } },
|
|
270
|
+
mdReqID: { type: "string" },
|
|
271
|
+
subscriptionRequestType: { type: "string", enum: ["0", "1", "2"] },
|
|
272
|
+
mdEntryTypes: { type: "array", items: { type: "string" } }
|
|
273
|
+
},
|
|
274
|
+
required: ["mdUpdateType", "symbols", "mdReqID", "subscriptionRequestType", "mdEntryTypes"]
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
resources: {
|
|
279
|
+
greeting: {
|
|
280
|
+
description: "A simple greeting resource",
|
|
281
|
+
uri: "greeting-resource"
|
|
282
|
+
},
|
|
283
|
+
stockGraph: {
|
|
284
|
+
description: "Generates a price chart for a given symbol",
|
|
285
|
+
uri: "stockGraph",
|
|
286
|
+
parameters: {
|
|
287
|
+
type: "object",
|
|
288
|
+
properties: {
|
|
289
|
+
symbol: { type: "string" }
|
|
290
|
+
},
|
|
291
|
+
required: ["symbol"]
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
stockPriceHistory: {
|
|
295
|
+
description: "Returns price history for a given symbol",
|
|
296
|
+
uri: "stockPriceHistory",
|
|
297
|
+
parameters: {
|
|
298
|
+
type: "object",
|
|
299
|
+
properties: {
|
|
300
|
+
symbol: { type: "string" }
|
|
301
|
+
},
|
|
302
|
+
required: ["symbol"]
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
206
306
|
}
|
|
207
307
|
}
|
|
208
308
|
);
|
|
209
309
|
transport = new import_stdio.StdioServerTransport();
|
|
210
310
|
onReady = void 0;
|
|
211
311
|
pendingRequests = /* @__PURE__ */ new Map();
|
|
312
|
+
verifiedOrders = /* @__PURE__ */ new Map();
|
|
313
|
+
// Store market data prices with timestamps
|
|
314
|
+
marketDataPrices = /* @__PURE__ */ new Map();
|
|
315
|
+
MAX_PRICE_HISTORY = 1e5;
|
|
316
|
+
// Maximum number of price points to store per symbol
|
|
212
317
|
constructor({ logger, onReady }) {
|
|
213
318
|
if (onReady) this.onReady = onReady;
|
|
214
319
|
}
|
|
215
320
|
async register(parser) {
|
|
216
321
|
this.parser = parser;
|
|
217
322
|
this.parser.addOnMessageCallback((message) => {
|
|
323
|
+
this.parser?.logger.log({
|
|
324
|
+
level: "info",
|
|
325
|
+
message: `MCP Server received message: ${message.messageType}: ${message.description}`
|
|
326
|
+
});
|
|
218
327
|
const msgType = message.messageType;
|
|
219
|
-
if (msgType === import_fixparser.Messages.MarketDataSnapshotFullRefresh || msgType === import_fixparser.Messages.ExecutionReport || msgType === import_fixparser.Messages.Reject) {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
328
|
+
if (msgType === import_fixparser.Messages.MarketDataSnapshotFullRefresh || msgType === import_fixparser.Messages.ExecutionReport || msgType === import_fixparser.Messages.Reject || msgType === import_fixparser.Messages.MarketDataIncrementalRefresh) {
|
|
329
|
+
this.parser?.logger.log({
|
|
330
|
+
level: "info",
|
|
331
|
+
message: `MCP Server handling message type: ${msgType}`
|
|
332
|
+
});
|
|
333
|
+
let id;
|
|
334
|
+
if (msgType === import_fixparser.Messages.MarketDataIncrementalRefresh || msgType === import_fixparser.Messages.MarketDataSnapshotFullRefresh) {
|
|
335
|
+
const symbol = message.getField(import_fixparser.Fields.Symbol);
|
|
336
|
+
const price = message.getField(import_fixparser.Fields.MDEntryPx);
|
|
337
|
+
const timestamp = message.getField(import_fixparser.Fields.MDEntryTime)?.value || Date.now();
|
|
338
|
+
if (symbol?.value && price?.value) {
|
|
339
|
+
const symbolStr = String(symbol.value);
|
|
340
|
+
const priceNum = Number(price.value);
|
|
341
|
+
const priceHistory = this.marketDataPrices.get(symbolStr) || [];
|
|
342
|
+
priceHistory.push({
|
|
343
|
+
timestamp: Number(timestamp),
|
|
344
|
+
price: priceNum
|
|
345
|
+
});
|
|
346
|
+
if (priceHistory.length > this.MAX_PRICE_HISTORY) {
|
|
347
|
+
priceHistory.shift();
|
|
239
348
|
}
|
|
349
|
+
this.marketDataPrices.set(symbolStr, priceHistory);
|
|
350
|
+
this.parser?.logger.log({
|
|
351
|
+
level: "info",
|
|
352
|
+
message: `MCP Server added ${symbol}: ${priceNum}`
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
if (msgType === import_fixparser.Messages.MarketDataSnapshotFullRefresh) {
|
|
357
|
+
const mdReqID = message.getField(import_fixparser.Fields.MDReqID);
|
|
358
|
+
if (mdReqID) id = String(mdReqID.value);
|
|
359
|
+
} else if (msgType === import_fixparser.Messages.ExecutionReport) {
|
|
360
|
+
const clOrdID = message.getField(import_fixparser.Fields.ClOrdID);
|
|
361
|
+
if (clOrdID) id = String(clOrdID.value);
|
|
362
|
+
} else if (msgType === import_fixparser.Messages.Reject) {
|
|
363
|
+
const refSeqNum = message.getField(import_fixparser.Fields.RefSeqNum);
|
|
364
|
+
if (refSeqNum) id = String(refSeqNum.value);
|
|
365
|
+
}
|
|
366
|
+
if (id) {
|
|
367
|
+
const callback = this.pendingRequests.get(id);
|
|
368
|
+
if (callback) {
|
|
369
|
+
callback(message);
|
|
370
|
+
this.pendingRequests.delete(id);
|
|
240
371
|
}
|
|
241
372
|
}
|
|
242
373
|
}
|
|
@@ -254,433 +385,732 @@ var MCPLocal = class {
|
|
|
254
385
|
if (!this.server) {
|
|
255
386
|
return;
|
|
256
387
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
388
|
+
this.server.setRequestHandler(
|
|
389
|
+
import_zod.z.object({ method: import_zod.z.literal("resources/list") }),
|
|
390
|
+
async (request, extra) => {
|
|
391
|
+
return {
|
|
392
|
+
resources: [
|
|
393
|
+
{
|
|
394
|
+
name: "greeting",
|
|
395
|
+
description: "A simple greeting resource",
|
|
396
|
+
uri: "greeting-resource"
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
name: "stockGraph",
|
|
400
|
+
description: "Generates a price chart for a given symbol",
|
|
401
|
+
uri: "stockGraph",
|
|
402
|
+
parameters: {
|
|
403
|
+
type: "object",
|
|
404
|
+
properties: {
|
|
405
|
+
symbol: { type: "string" }
|
|
406
|
+
},
|
|
407
|
+
required: ["symbol"]
|
|
408
|
+
}
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
name: "stockPriceHistory",
|
|
412
|
+
description: "Returns price history for a given symbol",
|
|
413
|
+
uri: "stockPriceHistory",
|
|
414
|
+
parameters: {
|
|
415
|
+
type: "object",
|
|
416
|
+
properties: {
|
|
417
|
+
symbol: { type: "string" }
|
|
418
|
+
},
|
|
419
|
+
required: ["symbol"]
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
]
|
|
423
|
+
};
|
|
270
424
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
425
|
+
);
|
|
426
|
+
this.server.setRequestHandler(
|
|
427
|
+
import_zod.z.object({ method: import_zod.z.literal("tools/list") }),
|
|
428
|
+
async (request, extra) => {
|
|
429
|
+
return {
|
|
430
|
+
tools: [
|
|
431
|
+
{
|
|
432
|
+
name: "parse",
|
|
433
|
+
description: "Parses a FIX message and describes it in plain language",
|
|
434
|
+
parameters: {
|
|
435
|
+
type: "object",
|
|
436
|
+
properties: {
|
|
437
|
+
fixString: { type: "string" }
|
|
438
|
+
},
|
|
439
|
+
required: ["fixString"]
|
|
440
|
+
}
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
name: "parseToJSON",
|
|
444
|
+
description: "Parses a FIX message into JSON",
|
|
445
|
+
parameters: {
|
|
446
|
+
type: "object",
|
|
447
|
+
properties: {
|
|
448
|
+
fixString: { type: "string" }
|
|
449
|
+
},
|
|
450
|
+
required: ["fixString"]
|
|
451
|
+
}
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
name: "verifyOrder",
|
|
455
|
+
description: "Verifies order parameters before execution",
|
|
456
|
+
parameters: {
|
|
457
|
+
type: "object",
|
|
458
|
+
properties: {
|
|
459
|
+
clOrdID: { type: "string" },
|
|
460
|
+
handlInst: { type: "string", enum: ["1", "2", "3"] },
|
|
461
|
+
quantity: { type: "string" },
|
|
462
|
+
price: { type: "string" },
|
|
463
|
+
ordType: {
|
|
464
|
+
type: "string",
|
|
465
|
+
enum: [
|
|
466
|
+
"1",
|
|
467
|
+
"2",
|
|
468
|
+
"3",
|
|
469
|
+
"4",
|
|
470
|
+
"5",
|
|
471
|
+
"6",
|
|
472
|
+
"7",
|
|
473
|
+
"8",
|
|
474
|
+
"9",
|
|
475
|
+
"A",
|
|
476
|
+
"B",
|
|
477
|
+
"C",
|
|
478
|
+
"D",
|
|
479
|
+
"E",
|
|
480
|
+
"F",
|
|
481
|
+
"G",
|
|
482
|
+
"H",
|
|
483
|
+
"I",
|
|
484
|
+
"J",
|
|
485
|
+
"K",
|
|
486
|
+
"L",
|
|
487
|
+
"M",
|
|
488
|
+
"P",
|
|
489
|
+
"Q",
|
|
490
|
+
"R",
|
|
491
|
+
"S"
|
|
492
|
+
]
|
|
493
|
+
},
|
|
494
|
+
side: {
|
|
495
|
+
type: "string",
|
|
496
|
+
enum: [
|
|
497
|
+
"1",
|
|
498
|
+
"2",
|
|
499
|
+
"3",
|
|
500
|
+
"4",
|
|
501
|
+
"5",
|
|
502
|
+
"6",
|
|
503
|
+
"7",
|
|
504
|
+
"8",
|
|
505
|
+
"9",
|
|
506
|
+
"A",
|
|
507
|
+
"B",
|
|
508
|
+
"C",
|
|
509
|
+
"D",
|
|
510
|
+
"E",
|
|
511
|
+
"F",
|
|
512
|
+
"G",
|
|
513
|
+
"H"
|
|
514
|
+
]
|
|
515
|
+
},
|
|
516
|
+
symbol: { type: "string" },
|
|
517
|
+
timeInForce: {
|
|
518
|
+
type: "string",
|
|
519
|
+
enum: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C"]
|
|
520
|
+
}
|
|
521
|
+
},
|
|
522
|
+
required: [
|
|
523
|
+
"clOrdID",
|
|
524
|
+
"handlInst",
|
|
525
|
+
"quantity",
|
|
526
|
+
"price",
|
|
527
|
+
"ordType",
|
|
528
|
+
"side",
|
|
529
|
+
"symbol",
|
|
530
|
+
"timeInForce"
|
|
531
|
+
]
|
|
532
|
+
}
|
|
533
|
+
},
|
|
534
|
+
{
|
|
535
|
+
name: "executeOrder",
|
|
536
|
+
description: "Executes a verified order",
|
|
537
|
+
parameters: {
|
|
538
|
+
type: "object",
|
|
539
|
+
properties: {
|
|
540
|
+
clOrdID: { type: "string" },
|
|
541
|
+
handlInst: { type: "string", enum: ["1", "2", "3"] },
|
|
542
|
+
quantity: { type: "string" },
|
|
543
|
+
price: { type: "string" },
|
|
544
|
+
ordType: { type: "string" },
|
|
545
|
+
side: { type: "string" },
|
|
546
|
+
symbol: { type: "string" },
|
|
547
|
+
timeInForce: { type: "string" }
|
|
548
|
+
},
|
|
549
|
+
required: [
|
|
550
|
+
"clOrdID",
|
|
551
|
+
"handlInst",
|
|
552
|
+
"quantity",
|
|
553
|
+
"price",
|
|
554
|
+
"ordType",
|
|
555
|
+
"side",
|
|
556
|
+
"symbol",
|
|
557
|
+
"timeInForce"
|
|
558
|
+
]
|
|
559
|
+
}
|
|
560
|
+
},
|
|
561
|
+
{
|
|
562
|
+
name: "marketDataRequest",
|
|
563
|
+
description: "Requests market data for specified symbols",
|
|
564
|
+
parameters: {
|
|
565
|
+
type: "object",
|
|
566
|
+
properties: {
|
|
567
|
+
mdUpdateType: { type: "string", enum: ["0", "1"] },
|
|
568
|
+
symbols: { type: "array", items: { type: "string" } },
|
|
569
|
+
mdReqID: { type: "string" },
|
|
570
|
+
subscriptionRequestType: { type: "string", enum: ["0", "1", "2"] },
|
|
571
|
+
mdEntryTypes: { type: "array", items: { type: "string" } }
|
|
572
|
+
},
|
|
573
|
+
required: [
|
|
574
|
+
"mdUpdateType",
|
|
575
|
+
"symbols",
|
|
576
|
+
"mdReqID",
|
|
577
|
+
"subscriptionRequestType",
|
|
578
|
+
"mdEntryTypes"
|
|
579
|
+
]
|
|
580
|
+
}
|
|
316
581
|
}
|
|
582
|
+
]
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
);
|
|
586
|
+
this.server.setRequestHandler(
|
|
587
|
+
import_zod.z.object({
|
|
588
|
+
method: import_zod.z.literal("resources/read"),
|
|
589
|
+
params: import_zod.z.object({
|
|
590
|
+
uri: import_zod.z.string()
|
|
591
|
+
})
|
|
592
|
+
}),
|
|
593
|
+
async (request, extra) => {
|
|
594
|
+
const { uri } = request.params;
|
|
595
|
+
switch (uri) {
|
|
596
|
+
case "greeting-resource":
|
|
317
597
|
return {
|
|
318
598
|
content: [
|
|
319
599
|
{
|
|
320
600
|
type: "text",
|
|
321
|
-
text:
|
|
322
|
-
${parsedMessage[0].messageTypeDescription}`
|
|
601
|
+
text: "Hello, world!"
|
|
323
602
|
}
|
|
324
603
|
]
|
|
325
604
|
};
|
|
326
|
-
|
|
605
|
+
case "stockGraph":
|
|
327
606
|
return {
|
|
328
|
-
isError: true,
|
|
329
607
|
content: [
|
|
330
608
|
{
|
|
331
609
|
type: "text",
|
|
332
|
-
text:
|
|
610
|
+
text: "This resource requires a symbol parameter. Please use the stockGraph resource with a symbol parameter."
|
|
333
611
|
}
|
|
334
612
|
]
|
|
335
613
|
};
|
|
336
|
-
|
|
337
|
-
}
|
|
338
|
-
case "parseToJSON": {
|
|
339
|
-
try {
|
|
340
|
-
const { fixString } = validateArgs(args, parseToJSONInputSchema);
|
|
341
|
-
const parsedMessage = this.parser?.parse(fixString);
|
|
342
|
-
if (!parsedMessage || parsedMessage.length === 0) {
|
|
343
|
-
return {
|
|
344
|
-
isError: true,
|
|
345
|
-
content: [{ type: "text", text: "Error: Failed to parse FIX string" }]
|
|
346
|
-
};
|
|
347
|
-
}
|
|
614
|
+
case "stockPriceHistory":
|
|
348
615
|
return {
|
|
349
616
|
content: [
|
|
350
617
|
{
|
|
351
618
|
type: "text",
|
|
352
|
-
text:
|
|
619
|
+
text: "This resource requires a symbol parameter. Please use the stockPriceHistory resource with a symbol parameter."
|
|
353
620
|
}
|
|
354
621
|
]
|
|
355
622
|
};
|
|
356
|
-
|
|
623
|
+
default:
|
|
357
624
|
return {
|
|
358
|
-
isError: true,
|
|
359
625
|
content: [
|
|
360
626
|
{
|
|
361
627
|
type: "text",
|
|
362
|
-
text: `
|
|
628
|
+
text: `Resource not found: ${uri}`
|
|
363
629
|
}
|
|
364
|
-
]
|
|
630
|
+
],
|
|
631
|
+
isError: true
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
);
|
|
636
|
+
this.server.setRequestHandler(
|
|
637
|
+
import_zod.z.object({
|
|
638
|
+
method: import_zod.z.literal("parse"),
|
|
639
|
+
params: fixStringSchema
|
|
640
|
+
}),
|
|
641
|
+
async (request, extra) => {
|
|
642
|
+
try {
|
|
643
|
+
const args = request.params;
|
|
644
|
+
const parsedMessage = this.parser?.parse(args.fixString);
|
|
645
|
+
if (!parsedMessage || parsedMessage.length === 0) {
|
|
646
|
+
return {
|
|
647
|
+
content: [{ type: "text", text: "Error: Failed to parse FIX string" }],
|
|
648
|
+
isError: true
|
|
365
649
|
};
|
|
366
650
|
}
|
|
651
|
+
return {
|
|
652
|
+
content: [
|
|
653
|
+
{
|
|
654
|
+
type: "text",
|
|
655
|
+
text: `${parsedMessage[0].description}
|
|
656
|
+
${parsedMessage[0].messageTypeDescription}`
|
|
657
|
+
}
|
|
658
|
+
]
|
|
659
|
+
};
|
|
660
|
+
} catch (error) {
|
|
661
|
+
return {
|
|
662
|
+
content: [
|
|
663
|
+
{
|
|
664
|
+
type: "text",
|
|
665
|
+
text: `Error: ${error instanceof Error ? error.message : "Failed to parse FIX string"}`
|
|
666
|
+
}
|
|
667
|
+
],
|
|
668
|
+
isError: true
|
|
669
|
+
};
|
|
367
670
|
}
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
new import_fixparser.Field(import_fixparser.Fields.ClOrdID, clOrdID),
|
|
381
|
-
new import_fixparser.Field(import_fixparser.Fields.Side, side),
|
|
382
|
-
new import_fixparser.Field(import_fixparser.Fields.Symbol, symbol),
|
|
383
|
-
new import_fixparser.Field(import_fixparser.Fields.OrderQty, quantity),
|
|
384
|
-
new import_fixparser.Field(import_fixparser.Fields.Price, price),
|
|
385
|
-
new import_fixparser.Field(import_fixparser.Fields.OrdType, ordType),
|
|
386
|
-
new import_fixparser.Field(import_fixparser.Fields.HandlInst, handlInst),
|
|
387
|
-
new import_fixparser.Field(import_fixparser.Fields.TimeInForce, timeInForce),
|
|
388
|
-
new import_fixparser.Field(import_fixparser.Fields.TransactTime, this.parser?.getTimestamp())
|
|
389
|
-
);
|
|
390
|
-
if (!this.parser?.connected) {
|
|
391
|
-
return {
|
|
392
|
-
isError: true,
|
|
393
|
-
content: [
|
|
394
|
-
{
|
|
395
|
-
type: "text",
|
|
396
|
-
text: "Error: Not connected. Ignoring message."
|
|
397
|
-
}
|
|
398
|
-
]
|
|
399
|
-
};
|
|
400
|
-
}
|
|
401
|
-
this.parser?.send(order);
|
|
402
|
-
const fixData = await response;
|
|
671
|
+
}
|
|
672
|
+
);
|
|
673
|
+
this.server.setRequestHandler(
|
|
674
|
+
import_zod.z.object({
|
|
675
|
+
method: import_zod.z.literal("parseToJSON"),
|
|
676
|
+
params: fixStringSchema
|
|
677
|
+
}),
|
|
678
|
+
async (request, extra) => {
|
|
679
|
+
try {
|
|
680
|
+
const args = request.params;
|
|
681
|
+
const parsedMessage = this.parser?.parse(args.fixString);
|
|
682
|
+
if (!parsedMessage || parsedMessage.length === 0) {
|
|
403
683
|
return {
|
|
404
|
-
content: [
|
|
405
|
-
|
|
406
|
-
type: "text",
|
|
407
|
-
text: fixData.messageType === import_fixparser.Messages.Reject ? `Reject message for order ${clOrdID}: ${JSON.stringify(fixData.toFIXJSON())}` : `Execution Report for order ${clOrdID}: ${JSON.stringify(fixData.toFIXJSON())}`
|
|
408
|
-
}
|
|
409
|
-
]
|
|
684
|
+
content: [{ type: "text", text: "Error: Failed to parse FIX string" }],
|
|
685
|
+
isError: true
|
|
410
686
|
};
|
|
411
|
-
}
|
|
687
|
+
}
|
|
688
|
+
return {
|
|
689
|
+
content: [
|
|
690
|
+
{
|
|
691
|
+
type: "text",
|
|
692
|
+
text: `${parsedMessage[0].toFIXJSON()}`
|
|
693
|
+
}
|
|
694
|
+
]
|
|
695
|
+
};
|
|
696
|
+
} catch (error) {
|
|
697
|
+
return {
|
|
698
|
+
content: [
|
|
699
|
+
{
|
|
700
|
+
type: "text",
|
|
701
|
+
text: `Error: ${error instanceof Error ? error.message : "Failed to parse FIX string"}`
|
|
702
|
+
}
|
|
703
|
+
],
|
|
704
|
+
isError: true
|
|
705
|
+
};
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
);
|
|
709
|
+
this.server.setRequestHandler(
|
|
710
|
+
import_zod.z.object({
|
|
711
|
+
method: import_zod.z.literal("verifyOrder"),
|
|
712
|
+
params: orderSchema
|
|
713
|
+
}),
|
|
714
|
+
async (request, extra) => {
|
|
715
|
+
try {
|
|
716
|
+
const args = request.params;
|
|
717
|
+
this.verifiedOrders.set(args.clOrdID, {
|
|
718
|
+
clOrdID: args.clOrdID,
|
|
719
|
+
handlInst: args.handlInst,
|
|
720
|
+
quantity: Number.parseFloat(args.quantity),
|
|
721
|
+
price: Number.parseFloat(args.price),
|
|
722
|
+
ordType: args.ordType,
|
|
723
|
+
side: args.side,
|
|
724
|
+
symbol: args.symbol,
|
|
725
|
+
timeInForce: args.timeInForce
|
|
726
|
+
});
|
|
727
|
+
const ordTypeNames = {
|
|
728
|
+
"1": "Market",
|
|
729
|
+
"2": "Limit",
|
|
730
|
+
"3": "Stop",
|
|
731
|
+
"4": "StopLimit",
|
|
732
|
+
"5": "MarketOnClose",
|
|
733
|
+
"6": "WithOrWithout",
|
|
734
|
+
"7": "LimitOrBetter",
|
|
735
|
+
"8": "LimitWithOrWithout",
|
|
736
|
+
"9": "OnBasis",
|
|
737
|
+
A: "OnClose",
|
|
738
|
+
B: "LimitOnClose",
|
|
739
|
+
C: "ForexMarket",
|
|
740
|
+
D: "PreviouslyQuoted",
|
|
741
|
+
E: "PreviouslyIndicated",
|
|
742
|
+
F: "ForexLimit",
|
|
743
|
+
G: "ForexSwap",
|
|
744
|
+
H: "ForexPreviouslyQuoted",
|
|
745
|
+
I: "Funari",
|
|
746
|
+
J: "MarketIfTouched",
|
|
747
|
+
K: "MarketWithLeftOverAsLimit",
|
|
748
|
+
L: "PreviousFundValuationPoint",
|
|
749
|
+
M: "NextFundValuationPoint",
|
|
750
|
+
P: "Pegged",
|
|
751
|
+
Q: "CounterOrderSelection",
|
|
752
|
+
R: "StopOnBidOrOffer",
|
|
753
|
+
S: "StopLimitOnBidOrOffer"
|
|
754
|
+
};
|
|
755
|
+
const sideNames = {
|
|
756
|
+
"1": "Buy",
|
|
757
|
+
"2": "Sell",
|
|
758
|
+
"3": "BuyMinus",
|
|
759
|
+
"4": "SellPlus",
|
|
760
|
+
"5": "SellShort",
|
|
761
|
+
"6": "SellShortExempt",
|
|
762
|
+
"7": "Undisclosed",
|
|
763
|
+
"8": "Cross",
|
|
764
|
+
"9": "CrossShort",
|
|
765
|
+
A: "CrossShortExempt",
|
|
766
|
+
B: "AsDefined",
|
|
767
|
+
C: "Opposite",
|
|
768
|
+
D: "Subscribe",
|
|
769
|
+
E: "Redeem",
|
|
770
|
+
F: "Lend",
|
|
771
|
+
G: "Borrow",
|
|
772
|
+
H: "SellUndisclosed"
|
|
773
|
+
};
|
|
774
|
+
const timeInForceNames = {
|
|
775
|
+
"0": "Day",
|
|
776
|
+
"1": "GoodTillCancel",
|
|
777
|
+
"2": "AtTheOpening",
|
|
778
|
+
"3": "ImmediateOrCancel",
|
|
779
|
+
"4": "FillOrKill",
|
|
780
|
+
"5": "GoodTillCrossing",
|
|
781
|
+
"6": "GoodTillDate",
|
|
782
|
+
"7": "AtTheClose",
|
|
783
|
+
"8": "GoodThroughCrossing",
|
|
784
|
+
"9": "AtCrossing",
|
|
785
|
+
A: "GoodForTime",
|
|
786
|
+
B: "GoodForAuction",
|
|
787
|
+
C: "GoodForMonth"
|
|
788
|
+
};
|
|
789
|
+
const handlInstNames = {
|
|
790
|
+
"1": "AutomatedExecutionNoIntervention",
|
|
791
|
+
"2": "AutomatedExecutionInterventionOK",
|
|
792
|
+
"3": "ManualOrder"
|
|
793
|
+
};
|
|
794
|
+
return {
|
|
795
|
+
content: [
|
|
796
|
+
{
|
|
797
|
+
type: "text",
|
|
798
|
+
text: `VERIFICATION: All parameters valid. Ready to proceed with order execution.
|
|
799
|
+
|
|
800
|
+
Parameters verified:
|
|
801
|
+
- ClOrdID: ${args.clOrdID}
|
|
802
|
+
- HandlInst: ${args.handlInst} (${handlInstNames[args.handlInst]})
|
|
803
|
+
- Quantity: ${args.quantity}
|
|
804
|
+
- Price: ${args.price}
|
|
805
|
+
- OrdType: ${args.ordType} (${ordTypeNames[args.ordType]})
|
|
806
|
+
- Side: ${args.side} (${sideNames[args.side]})
|
|
807
|
+
- Symbol: ${args.symbol}
|
|
808
|
+
- TimeInForce: ${args.timeInForce} (${timeInForceNames[args.timeInForce]})
|
|
809
|
+
|
|
810
|
+
To execute this order, call the executeOrder tool with these exact same parameters.`
|
|
811
|
+
}
|
|
812
|
+
]
|
|
813
|
+
};
|
|
814
|
+
} catch (error) {
|
|
815
|
+
return {
|
|
816
|
+
content: [
|
|
817
|
+
{
|
|
818
|
+
type: "text",
|
|
819
|
+
text: `Error: ${error instanceof Error ? error.message : "Failed to verify order parameters"}`
|
|
820
|
+
}
|
|
821
|
+
],
|
|
822
|
+
isError: true
|
|
823
|
+
};
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
);
|
|
827
|
+
this.server.setRequestHandler(
|
|
828
|
+
import_zod.z.object({
|
|
829
|
+
method: import_zod.z.literal("executeOrder"),
|
|
830
|
+
params: orderSchema
|
|
831
|
+
}),
|
|
832
|
+
async (request, extra) => {
|
|
833
|
+
try {
|
|
834
|
+
const args = request.params;
|
|
835
|
+
const verifiedOrder = this.verifiedOrders.get(args.clOrdID);
|
|
836
|
+
if (!verifiedOrder) {
|
|
412
837
|
return {
|
|
413
|
-
isError: true,
|
|
414
838
|
content: [
|
|
415
839
|
{
|
|
416
840
|
type: "text",
|
|
417
|
-
text: `Error: ${
|
|
841
|
+
text: `Error: Order ${args.clOrdID} has not been verified. Please call verifyOrder first.`
|
|
418
842
|
}
|
|
419
|
-
]
|
|
843
|
+
],
|
|
844
|
+
isError: true
|
|
420
845
|
};
|
|
421
846
|
}
|
|
422
|
-
|
|
423
|
-
case "marketDataRequest": {
|
|
424
|
-
try {
|
|
425
|
-
const { mdUpdateType, symbol, mdReqID, subscriptionRequestType, mdEntryType } = validateArgs(
|
|
426
|
-
args,
|
|
427
|
-
marketDataRequestInputSchema
|
|
428
|
-
);
|
|
429
|
-
const response = new Promise((resolve) => {
|
|
430
|
-
this.pendingRequests.set(mdReqID, resolve);
|
|
431
|
-
});
|
|
432
|
-
const marketDataRequest = this.parser?.createMessage(
|
|
433
|
-
new import_fixparser.Field(import_fixparser.Fields.MsgType, import_fixparser.Messages.MarketDataRequest),
|
|
434
|
-
new import_fixparser.Field(import_fixparser.Fields.SenderCompID, this.parser?.sender),
|
|
435
|
-
new import_fixparser.Field(import_fixparser.Fields.MsgSeqNum, this.parser?.getNextTargetMsgSeqNum()),
|
|
436
|
-
new import_fixparser.Field(import_fixparser.Fields.TargetCompID, this.parser?.target),
|
|
437
|
-
new import_fixparser.Field(import_fixparser.Fields.SendingTime, this.parser?.getTimestamp()),
|
|
438
|
-
new import_fixparser.Field(import_fixparser.Fields.MarketDepth, 0),
|
|
439
|
-
new import_fixparser.Field(import_fixparser.Fields.MDUpdateType, mdUpdateType),
|
|
440
|
-
new import_fixparser.Field(import_fixparser.Fields.NoRelatedSym, 1),
|
|
441
|
-
new import_fixparser.Field(import_fixparser.Fields.Symbol, symbol),
|
|
442
|
-
new import_fixparser.Field(import_fixparser.Fields.MDReqID, mdReqID),
|
|
443
|
-
new import_fixparser.Field(import_fixparser.Fields.SubscriptionRequestType, subscriptionRequestType),
|
|
444
|
-
new import_fixparser.Field(import_fixparser.Fields.NoMDEntryTypes, 1),
|
|
445
|
-
new import_fixparser.Field(import_fixparser.Fields.MDEntryType, mdEntryType)
|
|
446
|
-
);
|
|
447
|
-
if (!this.parser?.connected) {
|
|
448
|
-
return {
|
|
449
|
-
isError: true,
|
|
450
|
-
content: [
|
|
451
|
-
{
|
|
452
|
-
type: "text",
|
|
453
|
-
text: "Error: Not connected. Ignoring message."
|
|
454
|
-
}
|
|
455
|
-
]
|
|
456
|
-
};
|
|
457
|
-
}
|
|
458
|
-
this.parser?.send(marketDataRequest);
|
|
459
|
-
const fixData = await response;
|
|
847
|
+
if (verifiedOrder.handlInst !== args.handlInst || verifiedOrder.quantity !== Number.parseFloat(args.quantity) || verifiedOrder.price !== Number.parseFloat(args.price) || verifiedOrder.ordType !== args.ordType || verifiedOrder.side !== args.side || verifiedOrder.symbol !== args.symbol || verifiedOrder.timeInForce !== args.timeInForce) {
|
|
460
848
|
return {
|
|
461
849
|
content: [
|
|
462
850
|
{
|
|
463
851
|
type: "text",
|
|
464
|
-
text:
|
|
852
|
+
text: "Error: Order parameters do not match the verified order. Please use the exact same parameters that were verified."
|
|
465
853
|
}
|
|
466
|
-
]
|
|
854
|
+
],
|
|
855
|
+
isError: true
|
|
467
856
|
};
|
|
468
|
-
}
|
|
857
|
+
}
|
|
858
|
+
const response = new Promise((resolve) => {
|
|
859
|
+
this.pendingRequests.set(args.clOrdID, resolve);
|
|
860
|
+
});
|
|
861
|
+
const order = this.parser?.createMessage(
|
|
862
|
+
new import_fixparser.Field(import_fixparser.Fields.MsgType, import_fixparser.Messages.NewOrderSingle),
|
|
863
|
+
new import_fixparser.Field(import_fixparser.Fields.MsgSeqNum, this.parser?.getNextTargetMsgSeqNum()),
|
|
864
|
+
new import_fixparser.Field(import_fixparser.Fields.SenderCompID, this.parser?.sender),
|
|
865
|
+
new import_fixparser.Field(import_fixparser.Fields.TargetCompID, this.parser?.target),
|
|
866
|
+
new import_fixparser.Field(import_fixparser.Fields.SendingTime, this.parser?.getTimestamp()),
|
|
867
|
+
new import_fixparser.Field(import_fixparser.Fields.ClOrdID, args.clOrdID),
|
|
868
|
+
new import_fixparser.Field(import_fixparser.Fields.Side, args.side),
|
|
869
|
+
new import_fixparser.Field(import_fixparser.Fields.Symbol, args.symbol),
|
|
870
|
+
new import_fixparser.Field(import_fixparser.Fields.OrderQty, Number.parseFloat(args.quantity)),
|
|
871
|
+
new import_fixparser.Field(import_fixparser.Fields.Price, Number.parseFloat(args.price)),
|
|
872
|
+
new import_fixparser.Field(import_fixparser.Fields.OrdType, args.ordType),
|
|
873
|
+
new import_fixparser.Field(import_fixparser.Fields.HandlInst, args.handlInst),
|
|
874
|
+
new import_fixparser.Field(import_fixparser.Fields.TimeInForce, args.timeInForce),
|
|
875
|
+
new import_fixparser.Field(import_fixparser.Fields.TransactTime, this.parser?.getTimestamp())
|
|
876
|
+
);
|
|
877
|
+
if (!this.parser?.connected) {
|
|
469
878
|
return {
|
|
470
|
-
isError: true,
|
|
471
879
|
content: [
|
|
472
880
|
{
|
|
473
881
|
type: "text",
|
|
474
|
-
text:
|
|
882
|
+
text: "Error: Not connected. Ignoring message."
|
|
475
883
|
}
|
|
476
|
-
]
|
|
884
|
+
],
|
|
885
|
+
isError: true
|
|
477
886
|
};
|
|
478
887
|
}
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
this.server.setRequestHandler(import_types.ListPromptsRequestSchema, async () => {
|
|
485
|
-
return {
|
|
486
|
-
prompts: [
|
|
487
|
-
{
|
|
488
|
-
name: "parse",
|
|
489
|
-
description: "Parses a FIX message and describes it in plain language",
|
|
490
|
-
arguments: [
|
|
491
|
-
{
|
|
492
|
-
name: "fixString",
|
|
493
|
-
description: "FIX message string to parse",
|
|
494
|
-
required: true
|
|
495
|
-
}
|
|
496
|
-
]
|
|
497
|
-
},
|
|
498
|
-
{
|
|
499
|
-
name: "parseToJSON",
|
|
500
|
-
description: "Parses a FIX message into JSON",
|
|
501
|
-
arguments: [
|
|
502
|
-
{
|
|
503
|
-
name: "fixString",
|
|
504
|
-
description: "FIX message string to parse",
|
|
505
|
-
required: true
|
|
506
|
-
}
|
|
507
|
-
]
|
|
508
|
-
},
|
|
509
|
-
{
|
|
510
|
-
name: "newOrderSingle",
|
|
511
|
-
description: "Creates and sends a New Order Single. IMPORTANT: All parameters must be explicitly provided by the user - no assumptions will be made.",
|
|
512
|
-
arguments: [
|
|
513
|
-
{
|
|
514
|
-
name: "clOrdID",
|
|
515
|
-
description: "Client Order ID",
|
|
516
|
-
required: true
|
|
517
|
-
},
|
|
518
|
-
{
|
|
519
|
-
name: "handlInst",
|
|
520
|
-
description: "Handling instruction (1=Manual, 2=Automated, 3=AutomatedNoIntervention)",
|
|
521
|
-
required: true
|
|
522
|
-
},
|
|
523
|
-
{
|
|
524
|
-
name: "quantity",
|
|
525
|
-
description: "Order quantity",
|
|
526
|
-
required: true
|
|
527
|
-
},
|
|
528
|
-
{
|
|
529
|
-
name: "price",
|
|
530
|
-
description: "Order price",
|
|
531
|
-
required: true
|
|
532
|
-
},
|
|
533
|
-
{
|
|
534
|
-
name: "ordType",
|
|
535
|
-
description: "Order type (1=Market, 2=Limit, 3=Stop)",
|
|
536
|
-
required: true
|
|
537
|
-
},
|
|
538
|
-
{
|
|
539
|
-
name: "side",
|
|
540
|
-
description: "Order 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)",
|
|
541
|
-
required: true
|
|
542
|
-
},
|
|
543
|
-
{
|
|
544
|
-
name: "symbol",
|
|
545
|
-
description: "Trading symbol",
|
|
546
|
-
required: true
|
|
547
|
-
},
|
|
888
|
+
this.parser?.send(order);
|
|
889
|
+
const fixData = await response;
|
|
890
|
+
this.verifiedOrders.delete(args.clOrdID);
|
|
891
|
+
return {
|
|
892
|
+
content: [
|
|
548
893
|
{
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
required: true
|
|
894
|
+
type: "text",
|
|
895
|
+
text: fixData.messageType === import_fixparser.Messages.Reject ? `Reject message for order ${args.clOrdID}: ${JSON.stringify(fixData.toFIXJSON())}` : `Execution Report for order ${args.clOrdID}: ${JSON.stringify(fixData.toFIXJSON())}`
|
|
552
896
|
}
|
|
553
897
|
]
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
arguments: [
|
|
559
|
-
{
|
|
560
|
-
name: "mdUpdateType",
|
|
561
|
-
description: "Market data update type (0=FullRefresh, 1=IncrementalRefresh)",
|
|
562
|
-
required: true
|
|
563
|
-
},
|
|
564
|
-
{
|
|
565
|
-
name: "symbol",
|
|
566
|
-
description: "Trading symbol",
|
|
567
|
-
required: true
|
|
568
|
-
},
|
|
569
|
-
{
|
|
570
|
-
name: "mdReqID",
|
|
571
|
-
description: "Market data request ID",
|
|
572
|
-
required: true
|
|
573
|
-
},
|
|
574
|
-
{
|
|
575
|
-
name: "subscriptionRequestType",
|
|
576
|
-
description: "Subscription request type (0=Snapshot + Updates, 1=Snapshot, 2=Unsubscribe)",
|
|
577
|
-
required: true
|
|
578
|
-
},
|
|
898
|
+
};
|
|
899
|
+
} catch (error) {
|
|
900
|
+
return {
|
|
901
|
+
content: [
|
|
579
902
|
{
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
required: true
|
|
903
|
+
type: "text",
|
|
904
|
+
text: `Error: ${error instanceof Error ? error.message : "Failed to execute order"}`
|
|
583
905
|
}
|
|
584
|
-
]
|
|
906
|
+
],
|
|
907
|
+
isError: true
|
|
908
|
+
};
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
);
|
|
912
|
+
this.server.setRequestHandler(
|
|
913
|
+
import_zod.z.object({
|
|
914
|
+
method: import_zod.z.literal("marketDataRequest"),
|
|
915
|
+
params: marketDataRequestSchema
|
|
916
|
+
}),
|
|
917
|
+
async (request, extra) => {
|
|
918
|
+
try {
|
|
919
|
+
const args = request.params;
|
|
920
|
+
const response = new Promise((resolve) => {
|
|
921
|
+
this.pendingRequests.set(args.mdReqID, resolve);
|
|
922
|
+
});
|
|
923
|
+
const messageFields = [
|
|
924
|
+
new import_fixparser.Field(import_fixparser.Fields.MsgType, import_fixparser.Messages.MarketDataRequest),
|
|
925
|
+
new import_fixparser.Field(import_fixparser.Fields.SenderCompID, this.parser?.sender),
|
|
926
|
+
new import_fixparser.Field(import_fixparser.Fields.MsgSeqNum, this.parser?.getNextTargetMsgSeqNum()),
|
|
927
|
+
new import_fixparser.Field(import_fixparser.Fields.TargetCompID, this.parser?.target),
|
|
928
|
+
new import_fixparser.Field(import_fixparser.Fields.SendingTime, this.parser?.getTimestamp()),
|
|
929
|
+
new import_fixparser.Field(import_fixparser.Fields.MDReqID, args.mdReqID),
|
|
930
|
+
new import_fixparser.Field(import_fixparser.Fields.SubscriptionRequestType, args.subscriptionRequestType),
|
|
931
|
+
new import_fixparser.Field(import_fixparser.Fields.MarketDepth, 0),
|
|
932
|
+
new import_fixparser.Field(import_fixparser.Fields.MDUpdateType, args.mdUpdateType)
|
|
933
|
+
];
|
|
934
|
+
messageFields.push(new import_fixparser.Field(import_fixparser.Fields.NoRelatedSym, args.symbols.length));
|
|
935
|
+
args.symbols.forEach((symbol) => {
|
|
936
|
+
messageFields.push(new import_fixparser.Field(import_fixparser.Fields.Symbol, symbol));
|
|
937
|
+
});
|
|
938
|
+
messageFields.push(new import_fixparser.Field(import_fixparser.Fields.NoMDEntryTypes, args.mdEntryTypes.length));
|
|
939
|
+
args.mdEntryTypes.forEach((entryType) => {
|
|
940
|
+
messageFields.push(new import_fixparser.Field(import_fixparser.Fields.MDEntryType, entryType));
|
|
941
|
+
});
|
|
942
|
+
const mdr = this.parser?.createMessage(...messageFields);
|
|
943
|
+
if (!this.parser?.connected) {
|
|
944
|
+
return {
|
|
945
|
+
content: [
|
|
946
|
+
{
|
|
947
|
+
type: "text",
|
|
948
|
+
text: "Error: Not connected. Ignoring message."
|
|
949
|
+
}
|
|
950
|
+
],
|
|
951
|
+
isError: true
|
|
952
|
+
};
|
|
585
953
|
}
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
});
|
|
589
|
-
this.server.setRequestHandler(import_types.GetPromptRequestSchema, async (request) => {
|
|
590
|
-
const { name, arguments: args } = request.params;
|
|
591
|
-
switch (name) {
|
|
592
|
-
case "parse": {
|
|
593
|
-
const fixString = args?.fixString || "";
|
|
954
|
+
this.parser?.send(mdr);
|
|
955
|
+
const fixData = await response;
|
|
594
956
|
return {
|
|
595
|
-
|
|
957
|
+
content: [
|
|
596
958
|
{
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
type: "text",
|
|
600
|
-
text: `Please parse and explain this FIX message: ${fixString}`
|
|
601
|
-
}
|
|
959
|
+
type: "text",
|
|
960
|
+
text: `Market data for ${args.symbols.join(", ")}: ${JSON.stringify(fixData.toFIXJSON())}`
|
|
602
961
|
}
|
|
603
962
|
]
|
|
604
963
|
};
|
|
605
|
-
}
|
|
606
|
-
case "parseToJSON": {
|
|
607
|
-
const fixString = args?.fixString || "";
|
|
964
|
+
} catch (error) {
|
|
608
965
|
return {
|
|
609
|
-
|
|
966
|
+
content: [
|
|
610
967
|
{
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
type: "text",
|
|
614
|
-
text: `Please parse the FIX message to JSON: ${fixString}`
|
|
615
|
-
}
|
|
968
|
+
type: "text",
|
|
969
|
+
text: `Error: ${error instanceof Error ? error.message : "Failed to request market data"}`
|
|
616
970
|
}
|
|
617
|
-
]
|
|
971
|
+
],
|
|
972
|
+
isError: true
|
|
618
973
|
};
|
|
619
974
|
}
|
|
620
|
-
|
|
621
|
-
|
|
975
|
+
}
|
|
976
|
+
);
|
|
977
|
+
this.server.setRequestHandler(
|
|
978
|
+
import_zod.z.object({
|
|
979
|
+
method: import_zod.z.literal("stockGraph"),
|
|
980
|
+
params: symbolSchema
|
|
981
|
+
}),
|
|
982
|
+
async (request, extra) => {
|
|
983
|
+
this.parser?.logger.log({
|
|
984
|
+
level: "info",
|
|
985
|
+
message: "MCP Server Resource called: stockGraph"
|
|
986
|
+
});
|
|
987
|
+
const args = request.params;
|
|
988
|
+
const symbol = args.symbol;
|
|
989
|
+
const priceHistory = this.marketDataPrices.get(symbol) || [];
|
|
990
|
+
if (priceHistory.length === 0) {
|
|
622
991
|
return {
|
|
623
|
-
|
|
992
|
+
content: [
|
|
624
993
|
{
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
type: "text",
|
|
628
|
-
text: [
|
|
629
|
-
"Create a New Order Single FIX message with the following parameters:",
|
|
630
|
-
`- ClOrdID: ${clOrdID}`,
|
|
631
|
-
`- HandlInst: ${handlInst ?? "3"} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '1' for Manual, '2' for Automated, '3' for AutomatedNoIntervention)`,
|
|
632
|
-
`- Quantity: ${quantity}`,
|
|
633
|
-
`- Price: ${price}`,
|
|
634
|
-
`- OrdType: ${ordType ?? "1"} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '1' for Market, '2' for Limit, '3' for Stop)`,
|
|
635
|
-
`- Side: ${side} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '1' for Buy, '2' for Sell)`,
|
|
636
|
-
`- Symbol: ${symbol}`,
|
|
637
|
-
`- TimeInForce: ${timeInForce ?? "0"} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '0' for Day, '1' for Good Till Cancel, '2' for At Opening, '3' for Immediate or Cancel, '4' for Fill or Kill, '5' for Good Till Crossing, '6' for Good Till Date)`,
|
|
638
|
-
"",
|
|
639
|
-
'Note: For the OrdType parameter, always use the numeric/alphabetic value (e.g., "1" for Market, "2" for Limit, "3" for Stop) as defined in the FIX protocol, not the descriptive name.',
|
|
640
|
-
'Note: For the TimeInForce parameter, always use the numeric/alphabetic value (e.g., "0" for Day, "1" for Good Till Cancel, "2" for At Opening) as defined in the FIX protocol, not the descriptive name.',
|
|
641
|
-
"",
|
|
642
|
-
"IMPORTANT: All parameters must be set before sending the order. Missing or invalid parameters will result in a Reject message.",
|
|
643
|
-
"",
|
|
644
|
-
"IMPORTANT: The response will be either:",
|
|
645
|
-
"1. An Execution Report (MsgType=8) if the order was successfully placed",
|
|
646
|
-
"2. A Reject message (MsgType=3) if the order failed to execute (e.g., due to missing or invalid parameters)"
|
|
647
|
-
].join("\n")
|
|
648
|
-
}
|
|
994
|
+
type: "text",
|
|
995
|
+
text: `No price data available for ${symbol}`
|
|
649
996
|
}
|
|
650
997
|
]
|
|
651
998
|
};
|
|
652
999
|
}
|
|
653
|
-
|
|
654
|
-
|
|
1000
|
+
const width = 600;
|
|
1001
|
+
const height = 300;
|
|
1002
|
+
const padding = 40;
|
|
1003
|
+
const xScale = (width - 2 * padding) / (priceHistory.length - 1);
|
|
1004
|
+
const yMin = Math.min(...priceHistory.map((d) => d.price));
|
|
1005
|
+
const yMax = Math.max(...priceHistory.map((d) => d.price));
|
|
1006
|
+
const yScale = (height - 2 * padding) / (yMax - yMin);
|
|
1007
|
+
const points = priceHistory.map((d, i) => {
|
|
1008
|
+
const x = padding + i * xScale;
|
|
1009
|
+
const y = height - padding - (d.price - yMin) * yScale;
|
|
1010
|
+
return `${x},${y}`;
|
|
1011
|
+
}).join(" L ");
|
|
1012
|
+
const svg = `<?xml version="1.0" encoding="UTF-8"?>
|
|
1013
|
+
<svg width="${width}" height="${height}" xmlns="http://www.w3.org/2000/svg">
|
|
1014
|
+
<!-- Background -->
|
|
1015
|
+
<rect width="100%" height="100%" fill="#f8f9fa"/>
|
|
1016
|
+
|
|
1017
|
+
<!-- Grid lines -->
|
|
1018
|
+
<g stroke="#e9ecef" stroke-width="1">
|
|
1019
|
+
${Array.from({ length: 5 }, (_, i) => {
|
|
1020
|
+
const y = padding + (height - 2 * padding) * i / 4;
|
|
1021
|
+
return `<line x1="${padding}" y1="${y}" x2="${width - padding}" y2="${y}"/>`;
|
|
1022
|
+
}).join("\n")}
|
|
1023
|
+
</g>
|
|
1024
|
+
|
|
1025
|
+
<!-- Price line -->
|
|
1026
|
+
<path d="M ${points}"
|
|
1027
|
+
fill="none"
|
|
1028
|
+
stroke="#007bff"
|
|
1029
|
+
stroke-width="2"/>
|
|
1030
|
+
|
|
1031
|
+
<!-- Data points -->
|
|
1032
|
+
${priceHistory.map((d, i) => {
|
|
1033
|
+
const x = padding + i * xScale;
|
|
1034
|
+
const y = height - padding - (d.price - yMin) * yScale;
|
|
1035
|
+
return `<circle cx="${x}" cy="${y}" r="3" fill="#007bff"/>`;
|
|
1036
|
+
}).join("\n")}
|
|
1037
|
+
|
|
1038
|
+
<!-- Labels -->
|
|
1039
|
+
<g font-family="Arial" font-size="12" fill="#495057">
|
|
1040
|
+
${Array.from({ length: 5 }, (_, i) => {
|
|
1041
|
+
const x = padding + (width - 2 * padding) * i / 4;
|
|
1042
|
+
const index = Math.floor((priceHistory.length - 1) * i / 4);
|
|
1043
|
+
const timestamp = new Date(priceHistory[index].timestamp).toLocaleTimeString();
|
|
1044
|
+
return `<text x="${x + padding}" y="${height - padding + 20}" text-anchor="middle">${timestamp}</text>`;
|
|
1045
|
+
}).join("\n")}
|
|
1046
|
+
${Array.from({ length: 5 }, (_, i) => {
|
|
1047
|
+
const y = padding + (height - 2 * padding) * i / 4;
|
|
1048
|
+
const price = yMax - (yMax - yMin) * i / 4;
|
|
1049
|
+
return `<text x="${padding - 5}" y="${y + 4}" text-anchor="end">$${price.toFixed(2)}</text>`;
|
|
1050
|
+
}).join("\n")}
|
|
1051
|
+
</g>
|
|
1052
|
+
|
|
1053
|
+
<!-- Title -->
|
|
1054
|
+
<text x="${width / 2}" y="${padding / 2}"
|
|
1055
|
+
font-family="Arial" font-size="16" font-weight="bold"
|
|
1056
|
+
text-anchor="middle" fill="#212529">
|
|
1057
|
+
${symbol} - Price Chart (${priceHistory.length} points)
|
|
1058
|
+
</text>
|
|
1059
|
+
</svg>`;
|
|
1060
|
+
return {
|
|
1061
|
+
content: [
|
|
1062
|
+
{
|
|
1063
|
+
type: "text",
|
|
1064
|
+
text: svg
|
|
1065
|
+
}
|
|
1066
|
+
]
|
|
1067
|
+
};
|
|
1068
|
+
}
|
|
1069
|
+
);
|
|
1070
|
+
this.server.setRequestHandler(
|
|
1071
|
+
import_zod.z.object({
|
|
1072
|
+
method: import_zod.z.literal("stockPriceHistory"),
|
|
1073
|
+
params: symbolSchema
|
|
1074
|
+
}),
|
|
1075
|
+
async (request, extra) => {
|
|
1076
|
+
this.parser?.logger.log({
|
|
1077
|
+
level: "info",
|
|
1078
|
+
message: "MCP Server Resource called: stockPriceHistory"
|
|
1079
|
+
});
|
|
1080
|
+
const args = request.params;
|
|
1081
|
+
const symbol = args.symbol;
|
|
1082
|
+
const priceHistory = this.marketDataPrices.get(symbol) || [];
|
|
1083
|
+
if (priceHistory.length === 0) {
|
|
655
1084
|
return {
|
|
656
|
-
|
|
1085
|
+
content: [
|
|
657
1086
|
{
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
type: "text",
|
|
661
|
-
text: [
|
|
662
|
-
"Create a Market Data Request FIX message with the following parameters:",
|
|
663
|
-
`- MDUpdateType: ${mdUpdateType ?? "0"} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '0' for FullRefresh, '1' for IncrementalRefresh)`,
|
|
664
|
-
`- Symbol: ${symbol}`,
|
|
665
|
-
`- MDReqID: ${mdReqID}`,
|
|
666
|
-
`- SubscriptionRequestType: ${subscriptionRequestType ?? "0"} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '0' for Snapshot + Updates, '1' for Snapshot, '2' for Unsubscribe)`,
|
|
667
|
-
`- MDEntryType: ${mdEntryType ?? "0"} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '0' for Bid, '1' for Offer, '2' for Trade, '3' for Index Value, '4' for Opening Price)`,
|
|
668
|
-
"",
|
|
669
|
-
"Format the response as a JSON object with FIX tag numbers as keys and their corresponding values.",
|
|
670
|
-
"",
|
|
671
|
-
'Note: For the MDUpdateType parameter, always use the numeric/alphabetic value (e.g., "0" for FullRefresh, "1" for IncrementalRefresh) as defined in the FIX protocol, not the descriptive name.',
|
|
672
|
-
'Note: For the SubscriptionRequestType parameter, always use the numeric/alphabetic value (e.g., "0" for Snapshot + Updates, "1" for Snapshot, "2" for Unsubscribe) as defined in the FIX protocol, not the descriptive name.',
|
|
673
|
-
'Note: For the MDEntryType parameter, always use the numeric/alphabetic value (e.g., "0" for Bid, "1" for Offer, "2" for Trade, "3" for Index Value, "4" for Opening Price) as defined in the FIX protocol, not the descriptive name.'
|
|
674
|
-
].join("\n")
|
|
675
|
-
}
|
|
1087
|
+
type: "text",
|
|
1088
|
+
text: `No price data available for ${symbol}`
|
|
676
1089
|
}
|
|
677
1090
|
]
|
|
678
1091
|
};
|
|
679
1092
|
}
|
|
680
|
-
|
|
681
|
-
|
|
1093
|
+
return {
|
|
1094
|
+
content: [
|
|
1095
|
+
{
|
|
1096
|
+
type: "text",
|
|
1097
|
+
text: JSON.stringify(
|
|
1098
|
+
{
|
|
1099
|
+
symbol,
|
|
1100
|
+
count: priceHistory.length,
|
|
1101
|
+
prices: priceHistory.map((point) => ({
|
|
1102
|
+
timestamp: new Date(point.timestamp).toISOString(),
|
|
1103
|
+
price: point.price
|
|
1104
|
+
}))
|
|
1105
|
+
},
|
|
1106
|
+
null,
|
|
1107
|
+
2
|
|
1108
|
+
)
|
|
1109
|
+
}
|
|
1110
|
+
]
|
|
1111
|
+
};
|
|
682
1112
|
}
|
|
683
|
-
|
|
1113
|
+
);
|
|
684
1114
|
process.on("SIGINT", async () => {
|
|
685
1115
|
await this.server.close();
|
|
686
1116
|
process.exit(0);
|