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