fixparser-plugin-mcp 9.1.7-9d6b5ca3 → 9.1.7-a0e655a2
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 +600 -1223
- package/build/cjs/MCPLocal.js.map +4 -4
- package/build/cjs/MCPRemote.js +435 -1294
- package/build/cjs/MCPRemote.js.map +4 -4
- package/build/esm/MCPLocal.mjs +600 -1213
- package/build/esm/MCPLocal.mjs.map +4 -4
- package/build/esm/MCPRemote.mjs +444 -1284
- package/build/esm/MCPRemote.mjs.map +4 -4
- package/build-examples/cjs/example_mcp_local.js +46 -8
- package/build-examples/cjs/example_mcp_local.js.map +4 -4
- package/build-examples/esm/example_mcp_local.mjs +46 -8
- package/build-examples/esm/example_mcp_local.mjs.map +4 -4
- package/package.json +8 -9
- package/types/MCPLocal.d.ts +14 -0
- package/types/MCPRemote.d.ts +60 -0
- package/types/PluginOptions.d.ts +6 -0
- package/types/index.d.ts +3 -0
- package/build/cjs/index.js +0 -1593
- package/build/cjs/index.js.map +0 -7
- package/build/esm/index.mjs +0 -1555
- package/build/esm/index.mjs.map +0 -7
- package/build-examples/cjs/example_mcp_remote.js +0 -16
- package/build-examples/cjs/example_mcp_remote.js.map +0 -7
- package/build-examples/esm/example_mcp_remote.mjs +0 -16
- package/build-examples/esm/example_mcp_remote.mjs.map +0 -7
package/build/cjs/MCPLocal.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// src/MCPLocal.ts
|
|
@@ -33,1278 +23,665 @@ __export(MCPLocal_exports, {
|
|
|
33
23
|
MCPLocal: () => MCPLocal
|
|
34
24
|
});
|
|
35
25
|
module.exports = __toCommonJS(MCPLocal_exports);
|
|
36
|
-
var
|
|
26
|
+
var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
37
27
|
var import_stdio = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
28
|
+
var import_fixparser = require("fixparser");
|
|
38
29
|
var import_zod = require("zod");
|
|
39
|
-
|
|
40
|
-
// src/MCPBase.ts
|
|
41
|
-
var MCPBase = class {
|
|
42
|
-
/**
|
|
43
|
-
* Optional logger instance for diagnostics and output.
|
|
44
|
-
* @protected
|
|
45
|
-
*/
|
|
46
|
-
logger;
|
|
47
|
-
/**
|
|
48
|
-
* FIXParser instance, set during plugin register().
|
|
49
|
-
* @protected
|
|
50
|
-
*/
|
|
30
|
+
var MCPLocal = class {
|
|
51
31
|
parser;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
32
|
+
server = new import_mcp.McpServer(
|
|
33
|
+
{
|
|
34
|
+
name: "fixparser",
|
|
35
|
+
version: "1.0.0"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
capabilities: {
|
|
39
|
+
tools: {},
|
|
40
|
+
prompts: {},
|
|
41
|
+
resources: {}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
transport = new import_stdio.StdioServerTransport();
|
|
56
46
|
onReady = void 0;
|
|
57
|
-
/**
|
|
58
|
-
* Map to store verified orders before execution
|
|
59
|
-
* @protected
|
|
60
|
-
*/
|
|
61
|
-
verifiedOrders = /* @__PURE__ */ new Map();
|
|
62
|
-
/**
|
|
63
|
-
* Map to store pending market data requests
|
|
64
|
-
* @protected
|
|
65
|
-
*/
|
|
66
47
|
pendingRequests = /* @__PURE__ */ new Map();
|
|
67
|
-
|
|
68
|
-
* Map to store market data prices
|
|
69
|
-
* @protected
|
|
70
|
-
*/
|
|
71
|
-
marketDataPrices = /* @__PURE__ */ new Map();
|
|
72
|
-
/**
|
|
73
|
-
* Maximum number of price history entries to keep per symbol
|
|
74
|
-
* @protected
|
|
75
|
-
*/
|
|
76
|
-
MAX_PRICE_HISTORY = 1e5;
|
|
48
|
+
verifiedOrders = /* @__PURE__ */ new Map();
|
|
77
49
|
constructor({ logger, onReady }) {
|
|
78
|
-
this.
|
|
79
|
-
this.onReady = onReady;
|
|
50
|
+
if (onReady) this.onReady = onReady;
|
|
80
51
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
52
|
+
async register(parser) {
|
|
53
|
+
this.parser = parser;
|
|
54
|
+
this.parser.addOnMessageCallback((message) => {
|
|
55
|
+
const msgType = message.messageType;
|
|
56
|
+
if (msgType === import_fixparser.Messages.MarketDataSnapshotFullRefresh || msgType === import_fixparser.Messages.ExecutionReport || msgType === import_fixparser.Messages.Reject) {
|
|
57
|
+
let id;
|
|
58
|
+
if (msgType === import_fixparser.Messages.MarketDataSnapshotFullRefresh) {
|
|
59
|
+
const mdReqID = message.getField(import_fixparser.Fields.MDReqID);
|
|
60
|
+
if (mdReqID) id = String(mdReqID.value);
|
|
61
|
+
} else if (msgType === import_fixparser.Messages.ExecutionReport) {
|
|
62
|
+
const clOrdID = message.getField(import_fixparser.Fields.ClOrdID);
|
|
63
|
+
if (clOrdID) id = String(clOrdID.value);
|
|
64
|
+
} else if (msgType === import_fixparser.Messages.Reject) {
|
|
65
|
+
const refSeqNum = message.getField(import_fixparser.Fields.RefSeqNum);
|
|
66
|
+
if (refSeqNum) id = String(refSeqNum.value);
|
|
67
|
+
}
|
|
68
|
+
if (id) {
|
|
69
|
+
const callback = this.pendingRequests.get(id);
|
|
70
|
+
if (callback) {
|
|
71
|
+
callback(message);
|
|
72
|
+
this.pendingRequests.delete(id);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
this.addWorkflows();
|
|
78
|
+
await this.server.connect(this.transport);
|
|
79
|
+
if (this.onReady) {
|
|
80
|
+
this.onReady();
|
|
93
81
|
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
type: "object",
|
|
99
|
-
properties: {
|
|
100
|
-
fixString: { type: "string" }
|
|
101
|
-
},
|
|
102
|
-
required: ["fixString"]
|
|
82
|
+
}
|
|
83
|
+
addWorkflows() {
|
|
84
|
+
if (!this.parser) {
|
|
85
|
+
return;
|
|
103
86
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
description: "Verifies order parameters before execution. verifyOrder must be called before executeOrder.",
|
|
107
|
-
schema: {
|
|
108
|
-
type: "object",
|
|
109
|
-
properties: {
|
|
110
|
-
clOrdID: { type: "string" },
|
|
111
|
-
handlInst: {
|
|
112
|
-
type: "string",
|
|
113
|
-
enum: ["1", "2", "3"],
|
|
114
|
-
description: "Handling Instructions: 1=Automated Execution No Intervention, 2=Automated Execution Intervention OK, 3=Manual Order"
|
|
115
|
-
},
|
|
116
|
-
quantity: { type: "string" },
|
|
117
|
-
price: { type: "string" },
|
|
118
|
-
ordType: {
|
|
119
|
-
type: "string",
|
|
120
|
-
enum: [
|
|
121
|
-
"1",
|
|
122
|
-
"2",
|
|
123
|
-
"3",
|
|
124
|
-
"4",
|
|
125
|
-
"5",
|
|
126
|
-
"6",
|
|
127
|
-
"7",
|
|
128
|
-
"8",
|
|
129
|
-
"9",
|
|
130
|
-
"A",
|
|
131
|
-
"B",
|
|
132
|
-
"C",
|
|
133
|
-
"D",
|
|
134
|
-
"E",
|
|
135
|
-
"F",
|
|
136
|
-
"G",
|
|
137
|
-
"H",
|
|
138
|
-
"I",
|
|
139
|
-
"J",
|
|
140
|
-
"K",
|
|
141
|
-
"L",
|
|
142
|
-
"M",
|
|
143
|
-
"P",
|
|
144
|
-
"Q",
|
|
145
|
-
"R",
|
|
146
|
-
"S"
|
|
147
|
-
],
|
|
148
|
-
description: "Order Type: 1=Market, 2=Limit, 3=Stop, 4=StopLimit, 5=MarketOnClose, 6=WithOrWithout, 7=LimitOrBetter, 8=LimitWithOrWithout, 9=OnBasis, A=OnClose, B=LimitOnClose, C=ForexMarket, D=PreviouslyQuoted, E=PreviouslyIndicated, F=ForexLimit, G=ForexSwap, H=ForexPreviouslyQuoted, I=Funari, J=MarketIfTouched, K=MarketWithLeftOverAsLimit, L=PreviousFundValuationPoint, M=NextFundValuationPoint, P=Pegged, Q=CounterOrderSelection, R=StopOnBidOrOffer, S=StopLimitOnBidOrOffer"
|
|
149
|
-
},
|
|
150
|
-
side: {
|
|
151
|
-
type: "string",
|
|
152
|
-
enum: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H"],
|
|
153
|
-
description: "Side: 1=Buy, 2=Sell, 3=BuyMinus, 4=SellPlus, 5=SellShort, 6=SellShortExempt, 7=Undisclosed, 8=Cross, 9=CrossShort, A=CrossShortExempt, B=AsDefined, C=Opposite, D=Subscribe, E=Redeem, F=Lend, G=Borrow, H=SellUndisclosed"
|
|
154
|
-
},
|
|
155
|
-
symbol: { type: "string" },
|
|
156
|
-
timeInForce: {
|
|
157
|
-
type: "string",
|
|
158
|
-
enum: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C"],
|
|
159
|
-
description: "Time In Force: 0=Day, 1=GoodTillCancel, 2=AtTheOpening, 3=ImmediateOrCancel, 4=FillOrKill, 5=GoodTillCrossing, 6=GoodTillDate, 7=AtTheClose, 8=GoodThroughCrossing, 9=AtCrossing, A=GoodForTime, B=GoodForAuction, C=GoodForMonth"
|
|
160
|
-
}
|
|
161
|
-
},
|
|
162
|
-
required: ["clOrdID", "handlInst", "quantity", "price", "ordType", "side", "symbol", "timeInForce"]
|
|
87
|
+
if (!this.server) {
|
|
88
|
+
return;
|
|
163
89
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
properties: {
|
|
170
|
-
clOrdID: { type: "string" },
|
|
171
|
-
handlInst: {
|
|
172
|
-
type: "string",
|
|
173
|
-
enum: ["1", "2", "3"],
|
|
174
|
-
description: "Handling Instructions: 1=Automated Execution No Intervention, 2=Automated Execution Intervention OK, 3=Manual Order"
|
|
175
|
-
},
|
|
176
|
-
quantity: { type: "string" },
|
|
177
|
-
price: { type: "string" },
|
|
178
|
-
ordType: {
|
|
179
|
-
type: "string",
|
|
180
|
-
enum: [
|
|
181
|
-
"1",
|
|
182
|
-
"2",
|
|
183
|
-
"3",
|
|
184
|
-
"4",
|
|
185
|
-
"5",
|
|
186
|
-
"6",
|
|
187
|
-
"7",
|
|
188
|
-
"8",
|
|
189
|
-
"9",
|
|
190
|
-
"A",
|
|
191
|
-
"B",
|
|
192
|
-
"C",
|
|
193
|
-
"D",
|
|
194
|
-
"E",
|
|
195
|
-
"F",
|
|
196
|
-
"G",
|
|
197
|
-
"H",
|
|
198
|
-
"I",
|
|
199
|
-
"J",
|
|
200
|
-
"K",
|
|
201
|
-
"L",
|
|
202
|
-
"M",
|
|
203
|
-
"P",
|
|
204
|
-
"Q",
|
|
205
|
-
"R",
|
|
206
|
-
"S"
|
|
207
|
-
],
|
|
208
|
-
description: "Order Type: 1=Market, 2=Limit, 3=Stop, 4=StopLimit, 5=MarketOnClose, 6=WithOrWithout, 7=LimitOrBetter, 8=LimitWithOrWithout, 9=OnBasis, A=OnClose, B=LimitOnClose, C=ForexMarket, D=PreviouslyQuoted, E=PreviouslyIndicated, F=ForexLimit, G=ForexSwap, H=ForexPreviouslyQuoted, I=Funari, J=MarketIfTouched, K=MarketWithLeftOverAsLimit, L=PreviousFundValuationPoint, M=NextFundValuationPoint, P=Pegged, Q=CounterOrderSelection, R=StopOnBidOrOffer, S=StopLimitOnBidOrOffer"
|
|
209
|
-
},
|
|
210
|
-
side: {
|
|
211
|
-
type: "string",
|
|
212
|
-
enum: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H"],
|
|
213
|
-
description: "Side: 1=Buy, 2=Sell, 3=BuyMinus, 4=SellPlus, 5=SellShort, 6=SellShortExempt, 7=Undisclosed, 8=Cross, 9=CrossShort, A=CrossShortExempt, B=AsDefined, C=Opposite, D=Subscribe, E=Redeem, F=Lend, G=Borrow, H=SellUndisclosed"
|
|
214
|
-
},
|
|
215
|
-
symbol: { type: "string" },
|
|
216
|
-
timeInForce: {
|
|
217
|
-
type: "string",
|
|
218
|
-
enum: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C"],
|
|
219
|
-
description: "Time In Force: 0=Day, 1=GoodTillCancel, 2=AtTheOpening, 3=ImmediateOrCancel, 4=FillOrKill, 5=GoodTillCrossing, 6=GoodTillDate, 7=AtTheClose, 8=GoodThroughCrossing, 9=AtCrossing, A=GoodForTime, B=GoodForAuction, C=GoodForMonth"
|
|
220
|
-
}
|
|
90
|
+
this.server.tool(
|
|
91
|
+
"parse",
|
|
92
|
+
"Parses a FIX message and describes it in plain language",
|
|
93
|
+
{
|
|
94
|
+
fixString: import_zod.z.string().describe("FIX message string to parse")
|
|
221
95
|
},
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
type: "string",
|
|
239
|
-
enum: ["0", "1", "2"],
|
|
240
|
-
description: "Subscription Request Type: 0=Snapshot, 1=Snapshot + Updates, 2=Disable Previous Snapshot + Update Request"
|
|
241
|
-
},
|
|
242
|
-
mdEntryTypes: {
|
|
243
|
-
type: "array",
|
|
244
|
-
items: {
|
|
245
|
-
type: "string",
|
|
246
|
-
enum: [
|
|
247
|
-
"0",
|
|
248
|
-
"1",
|
|
249
|
-
"2",
|
|
250
|
-
"3",
|
|
251
|
-
"4",
|
|
252
|
-
"5",
|
|
253
|
-
"6",
|
|
254
|
-
"7",
|
|
255
|
-
"8",
|
|
256
|
-
"9",
|
|
257
|
-
"A",
|
|
258
|
-
"B",
|
|
259
|
-
"C",
|
|
260
|
-
"D",
|
|
261
|
-
"E",
|
|
262
|
-
"F",
|
|
263
|
-
"G",
|
|
264
|
-
"H",
|
|
265
|
-
"I",
|
|
266
|
-
"J",
|
|
267
|
-
"K",
|
|
268
|
-
"L",
|
|
269
|
-
"M",
|
|
270
|
-
"N",
|
|
271
|
-
"O",
|
|
272
|
-
"P",
|
|
273
|
-
"Q",
|
|
274
|
-
"R",
|
|
275
|
-
"S",
|
|
276
|
-
"T",
|
|
277
|
-
"U",
|
|
278
|
-
"V",
|
|
279
|
-
"W",
|
|
280
|
-
"X",
|
|
281
|
-
"Y",
|
|
282
|
-
"Z"
|
|
96
|
+
async (args) => {
|
|
97
|
+
try {
|
|
98
|
+
const parsedMessage = this.parser?.parse(args.fixString);
|
|
99
|
+
if (!parsedMessage || parsedMessage.length === 0) {
|
|
100
|
+
return {
|
|
101
|
+
content: [{ type: "text", text: "Error: Failed to parse FIX string" }],
|
|
102
|
+
isError: true
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
content: [
|
|
107
|
+
{
|
|
108
|
+
type: "text",
|
|
109
|
+
text: `${parsedMessage[0].description}
|
|
110
|
+
${parsedMessage[0].messageTypeDescription}`
|
|
111
|
+
}
|
|
283
112
|
]
|
|
284
|
-
}
|
|
285
|
-
|
|
113
|
+
};
|
|
114
|
+
} catch (error) {
|
|
115
|
+
return {
|
|
116
|
+
content: [
|
|
117
|
+
{
|
|
118
|
+
type: "text",
|
|
119
|
+
text: `Error: ${error instanceof Error ? error.message : "Failed to parse FIX string"}`
|
|
120
|
+
}
|
|
121
|
+
],
|
|
122
|
+
isError: true
|
|
123
|
+
};
|
|
286
124
|
}
|
|
125
|
+
}
|
|
126
|
+
);
|
|
127
|
+
this.server.tool(
|
|
128
|
+
"parseToJSON",
|
|
129
|
+
"Parses a FIX message into JSON",
|
|
130
|
+
{
|
|
131
|
+
fixString: import_zod.z.string().describe("FIX message string to parse")
|
|
287
132
|
},
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
133
|
+
async (args) => {
|
|
134
|
+
try {
|
|
135
|
+
const parsedMessage = this.parser?.parse(args.fixString);
|
|
136
|
+
if (!parsedMessage || parsedMessage.length === 0) {
|
|
137
|
+
return {
|
|
138
|
+
content: [{ type: "text", text: "Error: Failed to parse FIX string" }],
|
|
139
|
+
isError: true
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
content: [
|
|
144
|
+
{
|
|
145
|
+
type: "text",
|
|
146
|
+
text: `${parsedMessage[0].toFIXJSON()}`
|
|
147
|
+
}
|
|
148
|
+
]
|
|
149
|
+
};
|
|
150
|
+
} catch (error) {
|
|
151
|
+
return {
|
|
152
|
+
content: [
|
|
153
|
+
{
|
|
154
|
+
type: "text",
|
|
155
|
+
text: `Error: ${error instanceof Error ? error.message : "Failed to parse FIX string"}`
|
|
156
|
+
}
|
|
157
|
+
],
|
|
158
|
+
isError: true
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
);
|
|
163
|
+
this.server.tool(
|
|
164
|
+
"verifyOrder",
|
|
165
|
+
"Verifies all parameters for a New Order Single. This is the first step - verification only, no order is sent.",
|
|
166
|
+
{
|
|
167
|
+
clOrdID: import_zod.z.string().describe("Client Order ID"),
|
|
168
|
+
handlInst: import_zod.z.enum(["1", "2", "3"]).describe("Handling instruction (1=Manual, 2=Automated, 3=AutomatedNoIntervention)"),
|
|
169
|
+
quantity: import_zod.z.string().describe("Order quantity"),
|
|
170
|
+
price: import_zod.z.string().describe("Order price"),
|
|
171
|
+
ordType: import_zod.z.string().describe("Order type (1=Market, 2=Limit, 3=Stop)"),
|
|
172
|
+
side: import_zod.z.string().describe("Order side (1=Buy, 2=Sell, etc.)"),
|
|
173
|
+
symbol: import_zod.z.string().describe("Trading symbol"),
|
|
174
|
+
timeInForce: import_zod.z.string().describe("Time in force (0=Day, 1=Good Till Cancel, etc.)")
|
|
307
175
|
},
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
176
|
+
async (args) => {
|
|
177
|
+
try {
|
|
178
|
+
this.verifiedOrders.set(args.clOrdID, {
|
|
179
|
+
clOrdID: args.clOrdID,
|
|
180
|
+
handlInst: args.handlInst,
|
|
181
|
+
quantity: Number.parseFloat(args.quantity),
|
|
182
|
+
price: Number.parseFloat(args.price),
|
|
183
|
+
ordType: args.ordType,
|
|
184
|
+
side: args.side,
|
|
185
|
+
symbol: args.symbol,
|
|
186
|
+
timeInForce: args.timeInForce
|
|
187
|
+
});
|
|
188
|
+
return {
|
|
189
|
+
content: [
|
|
190
|
+
{
|
|
191
|
+
type: "text",
|
|
192
|
+
text: `VERIFICATION: All parameters valid. Ready to proceed with order execution.
|
|
193
|
+
|
|
194
|
+
Parameters verified:
|
|
195
|
+
- ClOrdID: ${args.clOrdID}
|
|
196
|
+
- HandlInst: ${args.handlInst}
|
|
197
|
+
- Quantity: ${args.quantity}
|
|
198
|
+
- Price: ${args.price}
|
|
199
|
+
- OrdType: ${args.ordType}
|
|
200
|
+
- Side: ${args.side}
|
|
201
|
+
- Symbol: ${args.symbol}
|
|
202
|
+
- TimeInForce: ${args.timeInForce}
|
|
312
203
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
});
|
|
329
|
-
});
|
|
330
|
-
const entryTypes = args.mdEntryTypes || [
|
|
331
|
-
import_fixparser.MDEntryType.Bid,
|
|
332
|
-
import_fixparser.MDEntryType.Offer,
|
|
333
|
-
import_fixparser.MDEntryType.Trade,
|
|
334
|
-
import_fixparser.MDEntryType.IndexValue,
|
|
335
|
-
import_fixparser.MDEntryType.OpeningPrice,
|
|
336
|
-
import_fixparser.MDEntryType.ClosingPrice,
|
|
337
|
-
import_fixparser.MDEntryType.SettlementPrice,
|
|
338
|
-
import_fixparser.MDEntryType.TradingSessionHighPrice,
|
|
339
|
-
import_fixparser.MDEntryType.TradingSessionLowPrice,
|
|
340
|
-
import_fixparser.MDEntryType.VWAP,
|
|
341
|
-
import_fixparser.MDEntryType.Imbalance,
|
|
342
|
-
import_fixparser.MDEntryType.TradeVolume,
|
|
343
|
-
import_fixparser.MDEntryType.OpenInterest,
|
|
344
|
-
import_fixparser.MDEntryType.CompositeUnderlyingPrice,
|
|
345
|
-
import_fixparser.MDEntryType.SimulatedSellPrice,
|
|
346
|
-
import_fixparser.MDEntryType.SimulatedBuyPrice,
|
|
347
|
-
import_fixparser.MDEntryType.MarginRate,
|
|
348
|
-
import_fixparser.MDEntryType.MidPrice,
|
|
349
|
-
import_fixparser.MDEntryType.EmptyBook,
|
|
350
|
-
import_fixparser.MDEntryType.SettleHighPrice,
|
|
351
|
-
import_fixparser.MDEntryType.SettleLowPrice,
|
|
352
|
-
import_fixparser.MDEntryType.PriorSettlePrice,
|
|
353
|
-
import_fixparser.MDEntryType.SessionHighBid,
|
|
354
|
-
import_fixparser.MDEntryType.SessionLowOffer,
|
|
355
|
-
import_fixparser.MDEntryType.EarlyPrices,
|
|
356
|
-
import_fixparser.MDEntryType.AuctionClearingPrice,
|
|
357
|
-
import_fixparser.MDEntryType.SwapValueFactor,
|
|
358
|
-
import_fixparser.MDEntryType.DailyValueAdjustmentForLongPositions,
|
|
359
|
-
import_fixparser.MDEntryType.CumulativeValueAdjustmentForLongPositions,
|
|
360
|
-
import_fixparser.MDEntryType.DailyValueAdjustmentForShortPositions,
|
|
361
|
-
import_fixparser.MDEntryType.CumulativeValueAdjustmentForShortPositions,
|
|
362
|
-
import_fixparser.MDEntryType.FixingPrice,
|
|
363
|
-
import_fixparser.MDEntryType.CashRate,
|
|
364
|
-
import_fixparser.MDEntryType.RecoveryRate,
|
|
365
|
-
import_fixparser.MDEntryType.RecoveryRateForLong,
|
|
366
|
-
import_fixparser.MDEntryType.RecoveryRateForShort,
|
|
367
|
-
import_fixparser.MDEntryType.MarketBid,
|
|
368
|
-
import_fixparser.MDEntryType.MarketOffer,
|
|
369
|
-
import_fixparser.MDEntryType.ShortSaleMinPrice,
|
|
370
|
-
import_fixparser.MDEntryType.PreviousClosingPrice,
|
|
371
|
-
import_fixparser.MDEntryType.ThresholdLimitPriceBanding,
|
|
372
|
-
import_fixparser.MDEntryType.DailyFinancingValue,
|
|
373
|
-
import_fixparser.MDEntryType.AccruedFinancingValue,
|
|
374
|
-
import_fixparser.MDEntryType.TWAP
|
|
375
|
-
];
|
|
376
|
-
const messageFields = [
|
|
377
|
-
new import_fixparser.Field(import_fixparser.Fields.MsgType, import_fixparser.Messages.MarketDataRequest),
|
|
378
|
-
new import_fixparser.Field(import_fixparser.Fields.SenderCompID, parser.sender),
|
|
379
|
-
new import_fixparser.Field(import_fixparser.Fields.MsgSeqNum, parser.getNextTargetMsgSeqNum()),
|
|
380
|
-
new import_fixparser.Field(import_fixparser.Fields.TargetCompID, parser.target),
|
|
381
|
-
new import_fixparser.Field(import_fixparser.Fields.SendingTime, parser.getTimestamp()),
|
|
382
|
-
new import_fixparser.Field(import_fixparser.Fields.MDReqID, args.mdReqID),
|
|
383
|
-
new import_fixparser.Field(import_fixparser.Fields.SubscriptionRequestType, args.subscriptionRequestType),
|
|
384
|
-
new import_fixparser.Field(import_fixparser.Fields.MarketDepth, 0),
|
|
385
|
-
new import_fixparser.Field(import_fixparser.Fields.MDUpdateType, args.mdUpdateType)
|
|
386
|
-
];
|
|
387
|
-
messageFields.push(new import_fixparser.Field(import_fixparser.Fields.NoRelatedSym, args.symbols.length));
|
|
388
|
-
args.symbols.forEach((symbol) => {
|
|
389
|
-
messageFields.push(new import_fixparser.Field(import_fixparser.Fields.Symbol, symbol));
|
|
390
|
-
});
|
|
391
|
-
messageFields.push(new import_fixparser.Field(import_fixparser.Fields.NoMDEntryTypes, entryTypes.length));
|
|
392
|
-
entryTypes.forEach((entryType) => {
|
|
393
|
-
messageFields.push(new import_fixparser.Field(import_fixparser.Fields.MDEntryType, entryType));
|
|
394
|
-
});
|
|
395
|
-
const mdr = parser.createMessage(...messageFields);
|
|
396
|
-
if (!parser.connected) {
|
|
397
|
-
parser.logger.log({
|
|
398
|
-
level: "error",
|
|
399
|
-
message: "Not connected. Cannot send market data request."
|
|
400
|
-
});
|
|
401
|
-
return {
|
|
402
|
-
content: [
|
|
403
|
-
{
|
|
404
|
-
type: "text",
|
|
405
|
-
text: "Error: Not connected. Ignoring message.",
|
|
406
|
-
uri: "marketDataRequest"
|
|
407
|
-
}
|
|
408
|
-
],
|
|
409
|
-
isError: true
|
|
410
|
-
};
|
|
204
|
+
To execute this order, call the executeOrder tool with these exact same parameters.`
|
|
205
|
+
}
|
|
206
|
+
]
|
|
207
|
+
};
|
|
208
|
+
} catch (error) {
|
|
209
|
+
return {
|
|
210
|
+
content: [
|
|
211
|
+
{
|
|
212
|
+
type: "text",
|
|
213
|
+
text: `Error: ${error instanceof Error ? error.message : "Failed to verify order parameters"}`
|
|
214
|
+
}
|
|
215
|
+
],
|
|
216
|
+
isError: true
|
|
217
|
+
};
|
|
218
|
+
}
|
|
411
219
|
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
220
|
+
);
|
|
221
|
+
this.server.tool(
|
|
222
|
+
"executeOrder",
|
|
223
|
+
"Executes a New Order Single after verification. This is the second step - only call after successful verification.",
|
|
224
|
+
{
|
|
225
|
+
clOrdID: import_zod.z.string().describe("Client Order ID"),
|
|
226
|
+
handlInst: import_zod.z.enum(["1", "2", "3"]).describe("Handling instruction (1=Manual, 2=Automated, 3=AutomatedNoIntervention)"),
|
|
227
|
+
quantity: import_zod.z.string().describe("Order quantity"),
|
|
228
|
+
price: import_zod.z.string().describe("Order price"),
|
|
229
|
+
ordType: import_zod.z.string().describe("Order type (1=Market, 2=Limit, 3=Stop)"),
|
|
230
|
+
side: import_zod.z.string().describe("Order side (1=Buy, 2=Sell, etc.)"),
|
|
231
|
+
symbol: import_zod.z.string().describe("Trading symbol"),
|
|
232
|
+
timeInForce: import_zod.z.string().describe("Time in force (0=Day, 1=Good Till Cancel, etc.)")
|
|
233
|
+
},
|
|
234
|
+
async (args) => {
|
|
235
|
+
try {
|
|
236
|
+
const verifiedOrder = this.verifiedOrders.get(args.clOrdID);
|
|
237
|
+
if (!verifiedOrder) {
|
|
238
|
+
return {
|
|
239
|
+
content: [
|
|
240
|
+
{
|
|
241
|
+
type: "text",
|
|
242
|
+
text: `Error: Order ${args.clOrdID} has not been verified. Please call verifyOrder first.`
|
|
243
|
+
}
|
|
244
|
+
],
|
|
245
|
+
isError: true
|
|
246
|
+
};
|
|
428
247
|
}
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
248
|
+
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) {
|
|
249
|
+
return {
|
|
250
|
+
content: [
|
|
251
|
+
{
|
|
252
|
+
type: "text",
|
|
253
|
+
text: "Error: Order parameters do not match the verified order. Please use the exact same parameters that were verified."
|
|
254
|
+
}
|
|
255
|
+
],
|
|
256
|
+
isError: true
|
|
257
|
+
};
|
|
438
258
|
}
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
const spreadData = priceHistory.map((point) => point.spread);
|
|
469
|
-
const volumeData = priceHistory.map((point) => point.volume);
|
|
470
|
-
const tradeData = priceHistory.map((point) => point.trade);
|
|
471
|
-
const vwapData = priceHistory.map((point) => point.vwap);
|
|
472
|
-
const twapData = priceHistory.map((point) => point.twap);
|
|
473
|
-
const config = {
|
|
474
|
-
type: "line",
|
|
475
|
-
data: {
|
|
476
|
-
labels,
|
|
477
|
-
datasets: [
|
|
478
|
-
{
|
|
479
|
-
label: "Bid",
|
|
480
|
-
data: bidData,
|
|
481
|
-
borderColor: "#28a745",
|
|
482
|
-
backgroundColor: "rgba(40, 167, 69, 0.1)",
|
|
483
|
-
fill: false,
|
|
484
|
-
tension: 0.4
|
|
485
|
-
},
|
|
486
|
-
{
|
|
487
|
-
label: "Offer",
|
|
488
|
-
data: offerData,
|
|
489
|
-
borderColor: "#dc3545",
|
|
490
|
-
backgroundColor: "rgba(220, 53, 69, 0.1)",
|
|
491
|
-
fill: false,
|
|
492
|
-
tension: 0.4
|
|
493
|
-
},
|
|
494
|
-
{
|
|
495
|
-
label: "Spread",
|
|
496
|
-
data: spreadData,
|
|
497
|
-
borderColor: "#6c757d",
|
|
498
|
-
backgroundColor: "rgba(108, 117, 125, 0.1)",
|
|
499
|
-
fill: false,
|
|
500
|
-
tension: 0.4
|
|
501
|
-
},
|
|
502
|
-
{
|
|
503
|
-
label: "Trade",
|
|
504
|
-
data: tradeData,
|
|
505
|
-
borderColor: "#ffc107",
|
|
506
|
-
backgroundColor: "rgba(255, 193, 7, 0.1)",
|
|
507
|
-
fill: false,
|
|
508
|
-
tension: 0.4
|
|
509
|
-
},
|
|
510
|
-
{
|
|
511
|
-
label: "VWAP",
|
|
512
|
-
data: vwapData,
|
|
513
|
-
borderColor: "#17a2b8",
|
|
514
|
-
backgroundColor: "rgba(23, 162, 184, 0.1)",
|
|
515
|
-
fill: false,
|
|
516
|
-
tension: 0.4
|
|
517
|
-
},
|
|
518
|
-
{
|
|
519
|
-
label: "TWAP",
|
|
520
|
-
data: twapData,
|
|
521
|
-
borderColor: "#6610f2",
|
|
522
|
-
backgroundColor: "rgba(102, 16, 242, 0.1)",
|
|
523
|
-
fill: false,
|
|
524
|
-
tension: 0.4
|
|
525
|
-
},
|
|
526
|
-
{
|
|
527
|
-
label: "Volume",
|
|
528
|
-
data: volumeData,
|
|
529
|
-
borderColor: "#007bff",
|
|
530
|
-
backgroundColor: "rgba(0, 123, 255, 0.1)",
|
|
531
|
-
fill: true,
|
|
532
|
-
tension: 0.4
|
|
533
|
-
}
|
|
534
|
-
]
|
|
535
|
-
},
|
|
536
|
-
options: {
|
|
537
|
-
responsive: true,
|
|
538
|
-
plugins: {
|
|
539
|
-
title: {
|
|
540
|
-
display: true,
|
|
541
|
-
text: `${symbol} Market Data`
|
|
542
|
-
}
|
|
543
|
-
},
|
|
544
|
-
scales: {
|
|
545
|
-
y: {
|
|
546
|
-
beginAtZero: false
|
|
547
|
-
}
|
|
259
|
+
const response = new Promise((resolve) => {
|
|
260
|
+
this.pendingRequests.set(args.clOrdID, resolve);
|
|
261
|
+
});
|
|
262
|
+
const order = this.parser?.createMessage(
|
|
263
|
+
new import_fixparser.Field(import_fixparser.Fields.MsgType, import_fixparser.Messages.NewOrderSingle),
|
|
264
|
+
new import_fixparser.Field(import_fixparser.Fields.MsgSeqNum, this.parser?.getNextTargetMsgSeqNum()),
|
|
265
|
+
new import_fixparser.Field(import_fixparser.Fields.SenderCompID, this.parser?.sender),
|
|
266
|
+
new import_fixparser.Field(import_fixparser.Fields.TargetCompID, this.parser?.target),
|
|
267
|
+
new import_fixparser.Field(import_fixparser.Fields.SendingTime, this.parser?.getTimestamp()),
|
|
268
|
+
new import_fixparser.Field(import_fixparser.Fields.ClOrdID, args.clOrdID),
|
|
269
|
+
new import_fixparser.Field(import_fixparser.Fields.Side, args.side),
|
|
270
|
+
new import_fixparser.Field(import_fixparser.Fields.Symbol, args.symbol),
|
|
271
|
+
new import_fixparser.Field(import_fixparser.Fields.OrderQty, Number.parseFloat(args.quantity)),
|
|
272
|
+
new import_fixparser.Field(import_fixparser.Fields.Price, Number.parseFloat(args.price)),
|
|
273
|
+
new import_fixparser.Field(import_fixparser.Fields.OrdType, args.ordType),
|
|
274
|
+
new import_fixparser.Field(import_fixparser.Fields.HandlInst, args.handlInst),
|
|
275
|
+
new import_fixparser.Field(import_fixparser.Fields.TimeInForce, args.timeInForce),
|
|
276
|
+
new import_fixparser.Field(import_fixparser.Fields.TransactTime, this.parser?.getTimestamp())
|
|
277
|
+
);
|
|
278
|
+
if (!this.parser?.connected) {
|
|
279
|
+
return {
|
|
280
|
+
content: [
|
|
281
|
+
{
|
|
282
|
+
type: "text",
|
|
283
|
+
text: "Error: Not connected. Ignoring message."
|
|
284
|
+
}
|
|
285
|
+
],
|
|
286
|
+
isError: true
|
|
287
|
+
};
|
|
548
288
|
}
|
|
289
|
+
this.parser?.send(order);
|
|
290
|
+
const fixData = await response;
|
|
291
|
+
this.verifiedOrders.delete(args.clOrdID);
|
|
292
|
+
return {
|
|
293
|
+
content: [
|
|
294
|
+
{
|
|
295
|
+
type: "text",
|
|
296
|
+
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())}`
|
|
297
|
+
}
|
|
298
|
+
]
|
|
299
|
+
};
|
|
300
|
+
} catch (error) {
|
|
301
|
+
return {
|
|
302
|
+
content: [
|
|
303
|
+
{
|
|
304
|
+
type: "text",
|
|
305
|
+
text: `Error: ${error instanceof Error ? error.message : "Failed to execute order"}`
|
|
306
|
+
}
|
|
307
|
+
],
|
|
308
|
+
isError: true
|
|
309
|
+
};
|
|
549
310
|
}
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
311
|
+
}
|
|
312
|
+
);
|
|
313
|
+
this.server.tool(
|
|
314
|
+
"marketDataRequest",
|
|
315
|
+
"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.",
|
|
316
|
+
{
|
|
317
|
+
mdUpdateType: import_zod.z.enum(["0", "1"]).describe("Market data update type (0=FullRefresh, 1=IncrementalRefresh)"),
|
|
318
|
+
symbol: import_zod.z.string().describe("Trading symbol"),
|
|
319
|
+
mdReqID: import_zod.z.string().describe("Market data request ID"),
|
|
320
|
+
subscriptionRequestType: import_zod.z.enum(["0", "1", "2"]).describe("Subscription request type (0=Snapshot + Updates, 1=Snapshot, 2=Unsubscribe)"),
|
|
321
|
+
mdEntryType: import_zod.z.string().describe("Market data entry type (0=Bid, 1=Offer, 2=Trade, etc.)")
|
|
322
|
+
},
|
|
323
|
+
async (args) => {
|
|
324
|
+
try {
|
|
325
|
+
const response = new Promise((resolve) => {
|
|
326
|
+
this.pendingRequests.set(args.mdReqID, resolve);
|
|
327
|
+
});
|
|
328
|
+
const marketDataRequest = this.parser?.createMessage(
|
|
329
|
+
new import_fixparser.Field(import_fixparser.Fields.MsgType, import_fixparser.Messages.MarketDataRequest),
|
|
330
|
+
new import_fixparser.Field(import_fixparser.Fields.SenderCompID, this.parser?.sender),
|
|
331
|
+
new import_fixparser.Field(import_fixparser.Fields.MsgSeqNum, this.parser?.getNextTargetMsgSeqNum()),
|
|
332
|
+
new import_fixparser.Field(import_fixparser.Fields.TargetCompID, this.parser?.target),
|
|
333
|
+
new import_fixparser.Field(import_fixparser.Fields.SendingTime, this.parser?.getTimestamp()),
|
|
334
|
+
new import_fixparser.Field(import_fixparser.Fields.MarketDepth, 0),
|
|
335
|
+
new import_fixparser.Field(import_fixparser.Fields.MDUpdateType, args.mdUpdateType),
|
|
336
|
+
new import_fixparser.Field(import_fixparser.Fields.NoRelatedSym, 1),
|
|
337
|
+
new import_fixparser.Field(import_fixparser.Fields.Symbol, args.symbol),
|
|
338
|
+
new import_fixparser.Field(import_fixparser.Fields.MDReqID, args.mdReqID),
|
|
339
|
+
new import_fixparser.Field(import_fixparser.Fields.SubscriptionRequestType, args.subscriptionRequestType),
|
|
340
|
+
new import_fixparser.Field(import_fixparser.Fields.NoMDEntryTypes, 1),
|
|
341
|
+
new import_fixparser.Field(import_fixparser.Fields.MDEntryType, args.mdEntryType)
|
|
342
|
+
);
|
|
343
|
+
if (!this.parser?.connected) {
|
|
344
|
+
return {
|
|
345
|
+
content: [
|
|
346
|
+
{
|
|
347
|
+
type: "text",
|
|
348
|
+
text: "Error: Not connected. Ignoring message."
|
|
349
|
+
}
|
|
350
|
+
],
|
|
351
|
+
isError: true
|
|
352
|
+
};
|
|
573
353
|
}
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
354
|
+
this.parser?.send(marketDataRequest);
|
|
355
|
+
const fixData = await response;
|
|
356
|
+
return {
|
|
357
|
+
content: [
|
|
358
|
+
{
|
|
359
|
+
type: "text",
|
|
360
|
+
text: `Market data for ${args.symbol}: ${JSON.stringify(fixData.toFIXJSON())}`
|
|
361
|
+
}
|
|
362
|
+
]
|
|
363
|
+
};
|
|
364
|
+
} catch (error) {
|
|
365
|
+
return {
|
|
366
|
+
content: [
|
|
367
|
+
{
|
|
368
|
+
type: "text",
|
|
369
|
+
text: `Error: ${error instanceof Error ? error.message : "Failed to request market data"}`
|
|
370
|
+
}
|
|
371
|
+
],
|
|
372
|
+
isError: true
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
);
|
|
377
|
+
this.server.prompt(
|
|
378
|
+
"parse",
|
|
379
|
+
"Parses a FIX message and describes it in plain language",
|
|
380
|
+
{
|
|
381
|
+
fixString: import_zod.z.string().describe("FIX message string to parse")
|
|
382
|
+
},
|
|
383
|
+
async (args) => {
|
|
586
384
|
return {
|
|
587
|
-
|
|
385
|
+
messages: [
|
|
588
386
|
{
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
387
|
+
role: "user",
|
|
388
|
+
content: {
|
|
389
|
+
type: "text",
|
|
390
|
+
text: `Please parse and explain this FIX message: ${args.fixString}`
|
|
391
|
+
}
|
|
592
392
|
}
|
|
593
393
|
]
|
|
594
394
|
};
|
|
595
395
|
}
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
data: priceHistory.map((point) => ({
|
|
605
|
-
timestamp: new Date(point.timestamp).toISOString(),
|
|
606
|
-
bid: point.bid,
|
|
607
|
-
offer: point.offer,
|
|
608
|
-
spread: point.spread,
|
|
609
|
-
volume: point.volume,
|
|
610
|
-
trade: point.trade,
|
|
611
|
-
indexValue: point.indexValue,
|
|
612
|
-
openingPrice: point.openingPrice,
|
|
613
|
-
closingPrice: point.closingPrice,
|
|
614
|
-
settlementPrice: point.settlementPrice,
|
|
615
|
-
tradingSessionHighPrice: point.tradingSessionHighPrice,
|
|
616
|
-
tradingSessionLowPrice: point.tradingSessionLowPrice,
|
|
617
|
-
vwap: point.vwap,
|
|
618
|
-
imbalance: point.imbalance,
|
|
619
|
-
openInterest: point.openInterest,
|
|
620
|
-
compositeUnderlyingPrice: point.compositeUnderlyingPrice,
|
|
621
|
-
simulatedSellPrice: point.simulatedSellPrice,
|
|
622
|
-
simulatedBuyPrice: point.simulatedBuyPrice,
|
|
623
|
-
marginRate: point.marginRate,
|
|
624
|
-
midPrice: point.midPrice,
|
|
625
|
-
emptyBook: point.emptyBook,
|
|
626
|
-
settleHighPrice: point.settleHighPrice,
|
|
627
|
-
settleLowPrice: point.settleLowPrice,
|
|
628
|
-
priorSettlePrice: point.priorSettlePrice,
|
|
629
|
-
sessionHighBid: point.sessionHighBid,
|
|
630
|
-
sessionLowOffer: point.sessionLowOffer,
|
|
631
|
-
earlyPrices: point.earlyPrices,
|
|
632
|
-
auctionClearingPrice: point.auctionClearingPrice,
|
|
633
|
-
swapValueFactor: point.swapValueFactor,
|
|
634
|
-
dailyValueAdjustmentForLongPositions: point.dailyValueAdjustmentForLongPositions,
|
|
635
|
-
cumulativeValueAdjustmentForLongPositions: point.cumulativeValueAdjustmentForLongPositions,
|
|
636
|
-
dailyValueAdjustmentForShortPositions: point.dailyValueAdjustmentForShortPositions,
|
|
637
|
-
cumulativeValueAdjustmentForShortPositions: point.cumulativeValueAdjustmentForShortPositions,
|
|
638
|
-
fixingPrice: point.fixingPrice,
|
|
639
|
-
cashRate: point.cashRate,
|
|
640
|
-
recoveryRate: point.recoveryRate,
|
|
641
|
-
recoveryRateForLong: point.recoveryRateForLong,
|
|
642
|
-
recoveryRateForShort: point.recoveryRateForShort,
|
|
643
|
-
marketBid: point.marketBid,
|
|
644
|
-
marketOffer: point.marketOffer,
|
|
645
|
-
shortSaleMinPrice: point.shortSaleMinPrice,
|
|
646
|
-
previousClosingPrice: point.previousClosingPrice,
|
|
647
|
-
thresholdLimitPriceBanding: point.thresholdLimitPriceBanding,
|
|
648
|
-
dailyFinancingValue: point.dailyFinancingValue,
|
|
649
|
-
accruedFinancingValue: point.accruedFinancingValue,
|
|
650
|
-
twap: point.twap
|
|
651
|
-
}))
|
|
652
|
-
},
|
|
653
|
-
null,
|
|
654
|
-
2
|
|
655
|
-
),
|
|
656
|
-
uri: "getStockPriceHistory"
|
|
657
|
-
}
|
|
658
|
-
]
|
|
659
|
-
};
|
|
660
|
-
} catch (error) {
|
|
661
|
-
return {
|
|
662
|
-
content: [
|
|
663
|
-
{
|
|
664
|
-
type: "text",
|
|
665
|
-
text: `Error: ${error instanceof Error ? error.message : "Failed to get price history"}`,
|
|
666
|
-
uri: "getStockPriceHistory"
|
|
667
|
-
}
|
|
668
|
-
],
|
|
669
|
-
isError: true
|
|
670
|
-
};
|
|
671
|
-
}
|
|
672
|
-
};
|
|
673
|
-
};
|
|
674
|
-
|
|
675
|
-
// src/tools/order.ts
|
|
676
|
-
var import_fixparser2 = require("fixparser");
|
|
677
|
-
var ordTypeNames = {
|
|
678
|
-
"1": "Market",
|
|
679
|
-
"2": "Limit",
|
|
680
|
-
"3": "Stop",
|
|
681
|
-
"4": "StopLimit",
|
|
682
|
-
"5": "MarketOnClose",
|
|
683
|
-
"6": "WithOrWithout",
|
|
684
|
-
"7": "LimitOrBetter",
|
|
685
|
-
"8": "LimitWithOrWithout",
|
|
686
|
-
"9": "OnBasis",
|
|
687
|
-
A: "OnClose",
|
|
688
|
-
B: "LimitOnClose",
|
|
689
|
-
C: "ForexMarket",
|
|
690
|
-
D: "PreviouslyQuoted",
|
|
691
|
-
E: "PreviouslyIndicated",
|
|
692
|
-
F: "ForexLimit",
|
|
693
|
-
G: "ForexSwap",
|
|
694
|
-
H: "ForexPreviouslyQuoted",
|
|
695
|
-
I: "Funari",
|
|
696
|
-
J: "MarketIfTouched",
|
|
697
|
-
K: "MarketWithLeftOverAsLimit",
|
|
698
|
-
L: "PreviousFundValuationPoint",
|
|
699
|
-
M: "NextFundValuationPoint",
|
|
700
|
-
P: "Pegged",
|
|
701
|
-
Q: "CounterOrderSelection",
|
|
702
|
-
R: "StopOnBidOrOffer",
|
|
703
|
-
S: "StopLimitOnBidOrOffer"
|
|
704
|
-
};
|
|
705
|
-
var sideNames = {
|
|
706
|
-
"1": "Buy",
|
|
707
|
-
"2": "Sell",
|
|
708
|
-
"3": "BuyMinus",
|
|
709
|
-
"4": "SellPlus",
|
|
710
|
-
"5": "SellShort",
|
|
711
|
-
"6": "SellShortExempt",
|
|
712
|
-
"7": "Undisclosed",
|
|
713
|
-
"8": "Cross",
|
|
714
|
-
"9": "CrossShort",
|
|
715
|
-
A: "CrossShortExempt",
|
|
716
|
-
B: "AsDefined",
|
|
717
|
-
C: "Opposite",
|
|
718
|
-
D: "Subscribe",
|
|
719
|
-
E: "Redeem",
|
|
720
|
-
F: "Lend",
|
|
721
|
-
G: "Borrow",
|
|
722
|
-
H: "SellUndisclosed"
|
|
723
|
-
};
|
|
724
|
-
var timeInForceNames = {
|
|
725
|
-
"0": "Day",
|
|
726
|
-
"1": "GoodTillCancel",
|
|
727
|
-
"2": "AtTheOpening",
|
|
728
|
-
"3": "ImmediateOrCancel",
|
|
729
|
-
"4": "FillOrKill",
|
|
730
|
-
"5": "GoodTillCrossing",
|
|
731
|
-
"6": "GoodTillDate",
|
|
732
|
-
"7": "AtTheClose",
|
|
733
|
-
"8": "GoodThroughCrossing",
|
|
734
|
-
"9": "AtCrossing",
|
|
735
|
-
A: "GoodForTime",
|
|
736
|
-
B: "GoodForAuction",
|
|
737
|
-
C: "GoodForMonth"
|
|
738
|
-
};
|
|
739
|
-
var handlInstNames = {
|
|
740
|
-
"1": "AutomatedExecutionNoIntervention",
|
|
741
|
-
"2": "AutomatedExecutionInterventionOK",
|
|
742
|
-
"3": "ManualOrder"
|
|
743
|
-
};
|
|
744
|
-
var createVerifyOrderHandler = (parser, verifiedOrders) => {
|
|
745
|
-
return async (args) => {
|
|
746
|
-
try {
|
|
747
|
-
verifiedOrders.set(args.clOrdID, {
|
|
748
|
-
clOrdID: args.clOrdID,
|
|
749
|
-
handlInst: args.handlInst,
|
|
750
|
-
quantity: Number.parseFloat(String(args.quantity)),
|
|
751
|
-
price: Number.parseFloat(String(args.price)),
|
|
752
|
-
ordType: args.ordType,
|
|
753
|
-
side: args.side,
|
|
754
|
-
symbol: args.symbol,
|
|
755
|
-
timeInForce: args.timeInForce
|
|
756
|
-
});
|
|
757
|
-
return {
|
|
758
|
-
content: [
|
|
759
|
-
{
|
|
760
|
-
type: "text",
|
|
761
|
-
text: `VERIFICATION: All parameters valid. Ready to proceed with order execution.
|
|
762
|
-
|
|
763
|
-
Parameters verified:
|
|
764
|
-
- ClOrdID: ${args.clOrdID}
|
|
765
|
-
- HandlInst: ${args.handlInst} (${handlInstNames[args.handlInst]})
|
|
766
|
-
- Quantity: ${args.quantity}
|
|
767
|
-
- Price: ${args.price}
|
|
768
|
-
- OrdType: ${args.ordType} (${ordTypeNames[args.ordType]})
|
|
769
|
-
- Side: ${args.side} (${sideNames[args.side]})
|
|
770
|
-
- Symbol: ${args.symbol}
|
|
771
|
-
- TimeInForce: ${args.timeInForce} (${timeInForceNames[args.timeInForce]})
|
|
772
|
-
|
|
773
|
-
To execute this order, call the executeOrder tool with these exact same parameters. Important: The user has to explicitly confirm before executeOrder is called!`,
|
|
774
|
-
uri: "verifyOrder"
|
|
775
|
-
}
|
|
776
|
-
]
|
|
777
|
-
};
|
|
778
|
-
} catch (error) {
|
|
779
|
-
return {
|
|
780
|
-
content: [
|
|
781
|
-
{
|
|
782
|
-
type: "text",
|
|
783
|
-
text: `Error: ${error instanceof Error ? error.message : "Failed to verify order parameters"}`,
|
|
784
|
-
uri: "verifyOrder"
|
|
785
|
-
}
|
|
786
|
-
],
|
|
787
|
-
isError: true
|
|
788
|
-
};
|
|
789
|
-
}
|
|
790
|
-
};
|
|
791
|
-
};
|
|
792
|
-
var createExecuteOrderHandler = (parser, verifiedOrders, pendingRequests) => {
|
|
793
|
-
return async (args) => {
|
|
794
|
-
try {
|
|
795
|
-
const verifiedOrder = verifiedOrders.get(args.clOrdID);
|
|
796
|
-
if (!verifiedOrder) {
|
|
396
|
+
);
|
|
397
|
+
this.server.prompt(
|
|
398
|
+
"parseToJSON",
|
|
399
|
+
"Parses a FIX message into JSON",
|
|
400
|
+
{
|
|
401
|
+
fixString: import_zod.z.string().describe("FIX message string to parse")
|
|
402
|
+
},
|
|
403
|
+
async (args) => {
|
|
797
404
|
return {
|
|
798
|
-
|
|
405
|
+
messages: [
|
|
799
406
|
{
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
407
|
+
role: "user",
|
|
408
|
+
content: {
|
|
409
|
+
type: "text",
|
|
410
|
+
text: `Please parse the FIX message to JSON: ${args.fixString}`
|
|
411
|
+
}
|
|
803
412
|
}
|
|
804
|
-
]
|
|
805
|
-
isError: true
|
|
413
|
+
]
|
|
806
414
|
};
|
|
807
415
|
}
|
|
808
|
-
|
|
416
|
+
);
|
|
417
|
+
this.server.prompt(
|
|
418
|
+
"verifyOrder",
|
|
419
|
+
"Verifies all parameters for a New Order Single. This is the first step - verification only, no order is sent.",
|
|
420
|
+
{
|
|
421
|
+
clOrdID: import_zod.z.string().describe("Client Order ID"),
|
|
422
|
+
handlInst: import_zod.z.enum(["1", "2", "3"]).describe("Handling instruction (1=Manual, 2=Automated, 3=AutomatedNoIntervention)"),
|
|
423
|
+
quantity: import_zod.z.string().describe("Order quantity"),
|
|
424
|
+
price: import_zod.z.string().describe("Order price"),
|
|
425
|
+
ordType: import_zod.z.string().describe("Order type (1=Market, 2=Limit, 3=Stop)"),
|
|
426
|
+
side: import_zod.z.string().describe("Order side (1=Buy, 2=Sell, etc.)"),
|
|
427
|
+
symbol: import_zod.z.string().describe("Trading symbol"),
|
|
428
|
+
timeInForce: import_zod.z.string().describe("Time in force (0=Day, 1=Good Till Cancel, etc.)")
|
|
429
|
+
},
|
|
430
|
+
async (args) => {
|
|
809
431
|
return {
|
|
810
|
-
|
|
432
|
+
messages: [
|
|
811
433
|
{
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
434
|
+
role: "user",
|
|
435
|
+
content: {
|
|
436
|
+
type: "text",
|
|
437
|
+
text: [
|
|
438
|
+
"You are an AI assistant that helps users verify FIX New Order Single parameters.",
|
|
439
|
+
"This is STEP 1 of 2 - VERIFICATION ONLY. No order will be sent at this stage.",
|
|
440
|
+
"",
|
|
441
|
+
"You must verify that all required fields are provided and valid:",
|
|
442
|
+
"- ClOrdID (Client Order ID)",
|
|
443
|
+
"- HandlInst (1=Manual, 2=Automated, 3=AutomatedNoIntervention)",
|
|
444
|
+
"- Quantity (Order quantity)",
|
|
445
|
+
"- Price (Order price)",
|
|
446
|
+
"- OrdType (1=Market, 2=Limit, 3=Stop)",
|
|
447
|
+
"- 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)",
|
|
448
|
+
"- Symbol (Trading symbol)",
|
|
449
|
+
"- TimeInForce (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)",
|
|
450
|
+
"",
|
|
451
|
+
"Current parameters to verify:",
|
|
452
|
+
`- ClOrdID: ${args.clOrdID}`,
|
|
453
|
+
`- HandlInst: ${args.handlInst}`,
|
|
454
|
+
`- Quantity: ${args.quantity}`,
|
|
455
|
+
`- Price: ${args.price}`,
|
|
456
|
+
`- OrdType: ${args.ordType}`,
|
|
457
|
+
`- Side: ${args.side}`,
|
|
458
|
+
`- Symbol: ${args.symbol}`,
|
|
459
|
+
`- TimeInForce: ${args.timeInForce}`,
|
|
460
|
+
"",
|
|
461
|
+
"If all parameters are valid, respond with:",
|
|
462
|
+
"`VERIFICATION: All parameters valid. Ready to proceed.`",
|
|
463
|
+
"",
|
|
464
|
+
"Otherwise, list the missing or invalid ones.",
|
|
465
|
+
"",
|
|
466
|
+
"IMPORTANT: This is only verification. To actually send the order, the user must call the executeOrder tool with the same parameters."
|
|
467
|
+
].join("\n")
|
|
468
|
+
}
|
|
815
469
|
}
|
|
816
|
-
]
|
|
817
|
-
isError: true
|
|
470
|
+
]
|
|
818
471
|
};
|
|
819
472
|
}
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
new import_fixparser2.Field(import_fixparser2.Fields.HandlInst, args.handlInst),
|
|
836
|
-
new import_fixparser2.Field(import_fixparser2.Fields.TimeInForce, args.timeInForce),
|
|
837
|
-
new import_fixparser2.Field(import_fixparser2.Fields.TransactTime, parser.getTimestamp())
|
|
838
|
-
);
|
|
839
|
-
if (!parser.connected) {
|
|
473
|
+
);
|
|
474
|
+
this.server.prompt(
|
|
475
|
+
"executeOrder",
|
|
476
|
+
"Executes a New Order Single after verification. This is the second step - only call after successful verification.",
|
|
477
|
+
{
|
|
478
|
+
clOrdID: import_zod.z.string().describe("Client Order ID"),
|
|
479
|
+
handlInst: import_zod.z.enum(["1", "2", "3"]).describe("Handling instruction (1=Manual, 2=Automated, 3=AutomatedNoIntervention)"),
|
|
480
|
+
quantity: import_zod.z.string().describe("Order quantity"),
|
|
481
|
+
price: import_zod.z.string().describe("Order price"),
|
|
482
|
+
ordType: import_zod.z.string().describe("Order type (1=Market, 2=Limit, 3=Stop)"),
|
|
483
|
+
side: import_zod.z.string().describe("Order side (1=Buy, 2=Sell, etc.)"),
|
|
484
|
+
symbol: import_zod.z.string().describe("Trading symbol"),
|
|
485
|
+
timeInForce: import_zod.z.string().describe("Time in force (0=Day, 1=Good Till Cancel, etc.)")
|
|
486
|
+
},
|
|
487
|
+
async (args) => {
|
|
840
488
|
return {
|
|
841
|
-
|
|
489
|
+
messages: [
|
|
842
490
|
{
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
491
|
+
role: "user",
|
|
492
|
+
content: {
|
|
493
|
+
type: "text",
|
|
494
|
+
text: [
|
|
495
|
+
"You are an AI assistant that helps users execute FIX New Order Single messages.",
|
|
496
|
+
"This is STEP 2 of 2 - EXECUTION. This will send the order to the market.",
|
|
497
|
+
"",
|
|
498
|
+
"IMPORTANT: This tool should only be called after successful verification of all parameters.",
|
|
499
|
+
"",
|
|
500
|
+
"Parameters to execute:",
|
|
501
|
+
`- ClOrdID: ${args.clOrdID}`,
|
|
502
|
+
`- HandlInst: ${args.handlInst}`,
|
|
503
|
+
`- Quantity: ${args.quantity}`,
|
|
504
|
+
`- Price: ${args.price}`,
|
|
505
|
+
`- OrdType: ${args.ordType}`,
|
|
506
|
+
`- Side: ${args.side}`,
|
|
507
|
+
`- Symbol: ${args.symbol}`,
|
|
508
|
+
`- TimeInForce: ${args.timeInForce}`,
|
|
509
|
+
"",
|
|
510
|
+
"IMPORTANT: The response will be either:",
|
|
511
|
+
"1. An Execution Report (MsgType=8) if the order was successfully placed",
|
|
512
|
+
"2. A Reject message (MsgType=3) if the order failed to execute (e.g., due to missing or invalid parameters)"
|
|
513
|
+
].join("\n")
|
|
514
|
+
}
|
|
846
515
|
}
|
|
847
|
-
]
|
|
848
|
-
isError: true
|
|
516
|
+
]
|
|
849
517
|
};
|
|
850
518
|
}
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
} catch (error) {
|
|
864
|
-
return {
|
|
865
|
-
content: [
|
|
866
|
-
{
|
|
867
|
-
type: "text",
|
|
868
|
-
text: `Error: ${error instanceof Error ? error.message : "Failed to execute order"}`,
|
|
869
|
-
uri: "executeOrder"
|
|
870
|
-
}
|
|
871
|
-
],
|
|
872
|
-
isError: true
|
|
873
|
-
};
|
|
874
|
-
}
|
|
875
|
-
};
|
|
876
|
-
};
|
|
877
|
-
|
|
878
|
-
// src/tools/parse.ts
|
|
879
|
-
var createParseHandler = (parser) => {
|
|
880
|
-
return async (args) => {
|
|
881
|
-
try {
|
|
882
|
-
const parsedMessage = parser.parse(args.fixString);
|
|
883
|
-
if (!parsedMessage || parsedMessage.length === 0) {
|
|
519
|
+
);
|
|
520
|
+
this.server.prompt(
|
|
521
|
+
"marketDataRequest",
|
|
522
|
+
"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.",
|
|
523
|
+
{
|
|
524
|
+
mdUpdateType: import_zod.z.enum(["0", "1"]).describe("Market data update type (0=FullRefresh, 1=IncrementalRefresh)"),
|
|
525
|
+
symbol: import_zod.z.string().describe("Trading symbol"),
|
|
526
|
+
mdReqID: import_zod.z.string().describe("Market data request ID"),
|
|
527
|
+
subscriptionRequestType: import_zod.z.enum(["0", "1", "2"]).describe("Subscription request type (0=Snapshot + Updates, 1=Snapshot, 2=Unsubscribe)"),
|
|
528
|
+
mdEntryType: import_zod.z.string().describe("Market data entry type (0=Bid, 1=Offer, 2=Trade, etc.)")
|
|
529
|
+
},
|
|
530
|
+
async (args) => {
|
|
884
531
|
return {
|
|
885
|
-
|
|
532
|
+
messages: [
|
|
886
533
|
{
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
534
|
+
role: "user",
|
|
535
|
+
content: {
|
|
536
|
+
type: "text",
|
|
537
|
+
text: [
|
|
538
|
+
"You are an AI assistant that helps users create FIX Market Data Request messages.",
|
|
539
|
+
"You must **first verify** that all required fields are provided:",
|
|
540
|
+
"- MDUpdateType (0=FullRefresh, 1=IncrementalRefresh)",
|
|
541
|
+
"- Symbol (Trading symbol)",
|
|
542
|
+
"- MDReqID (Market data request ID)",
|
|
543
|
+
"- SubscriptionRequestType (0=Snapshot + Updates, 1=Snapshot, 2=Unsubscribe)",
|
|
544
|
+
"- MDEntryType (0=Bid, 1=Offer, 2=Trade, 3=Index Value, 4=Opening Price)",
|
|
545
|
+
"",
|
|
546
|
+
"Only when all fields are present and valid, respond with:",
|
|
547
|
+
"`VERIFICATION: All parameters valid. Ready to proceed.`",
|
|
548
|
+
"",
|
|
549
|
+
"Otherwise, list the missing or invalid ones.",
|
|
550
|
+
"",
|
|
551
|
+
"Do not create the FIX message until verification is complete.",
|
|
552
|
+
"",
|
|
553
|
+
"Current parameters:",
|
|
554
|
+
`- MDUpdateType: ${args.mdUpdateType}`,
|
|
555
|
+
`- Symbol: ${args.symbol}`,
|
|
556
|
+
`- MDReqID: ${args.mdReqID}`,
|
|
557
|
+
`- SubscriptionRequestType: ${args.subscriptionRequestType}`,
|
|
558
|
+
`- MDEntryType: ${args.mdEntryType}`
|
|
559
|
+
].join("\n")
|
|
560
|
+
}
|
|
890
561
|
}
|
|
891
|
-
]
|
|
892
|
-
isError: true
|
|
562
|
+
]
|
|
893
563
|
};
|
|
894
564
|
}
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
uri: "parse"
|
|
902
|
-
}
|
|
903
|
-
]
|
|
904
|
-
};
|
|
905
|
-
} catch (error) {
|
|
906
|
-
return {
|
|
907
|
-
content: [
|
|
908
|
-
{
|
|
909
|
-
type: "text",
|
|
910
|
-
text: `Error: ${error instanceof Error ? error.message : "Failed to parse FIX string"}`,
|
|
911
|
-
uri: "parse"
|
|
912
|
-
}
|
|
913
|
-
],
|
|
914
|
-
isError: true
|
|
915
|
-
};
|
|
916
|
-
}
|
|
917
|
-
};
|
|
918
|
-
};
|
|
919
|
-
|
|
920
|
-
// src/tools/parseToJSON.ts
|
|
921
|
-
var createParseToJSONHandler = (parser) => {
|
|
922
|
-
return async (args) => {
|
|
923
|
-
try {
|
|
924
|
-
const parsedMessage = parser.parse(args.fixString);
|
|
925
|
-
if (!parsedMessage || parsedMessage.length === 0) {
|
|
565
|
+
);
|
|
566
|
+
this.server.resource(
|
|
567
|
+
"greeting-resource",
|
|
568
|
+
"https://example.com/greetings/default",
|
|
569
|
+
{ mimeType: "text/plain" },
|
|
570
|
+
async () => {
|
|
926
571
|
return {
|
|
927
|
-
|
|
572
|
+
contents: [
|
|
928
573
|
{
|
|
929
|
-
|
|
930
|
-
text: "
|
|
931
|
-
uri: "parseToJSON"
|
|
574
|
+
uri: "https://example.com/greetings/default",
|
|
575
|
+
text: "Hello, world!"
|
|
932
576
|
}
|
|
933
|
-
]
|
|
934
|
-
isError: true
|
|
577
|
+
]
|
|
935
578
|
};
|
|
936
579
|
}
|
|
937
|
-
|
|
938
|
-
|
|
580
|
+
);
|
|
581
|
+
this.server.resource(
|
|
582
|
+
"greeting",
|
|
583
|
+
new import_mcp.ResourceTemplate("greeting://{name}", { list: void 0 }),
|
|
584
|
+
async (uri, { name }) => ({
|
|
585
|
+
contents: [
|
|
939
586
|
{
|
|
940
|
-
|
|
941
|
-
text:
|
|
942
|
-
uri: "parseToJSON"
|
|
587
|
+
uri: uri.href,
|
|
588
|
+
text: `Hello, ${name}!`
|
|
943
589
|
}
|
|
944
590
|
]
|
|
945
|
-
}
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
591
|
+
})
|
|
592
|
+
);
|
|
593
|
+
this.server.resource(
|
|
594
|
+
"echo",
|
|
595
|
+
new import_mcp.ResourceTemplate("echo://{message}", { list: void 0 }),
|
|
596
|
+
async (uri, { message }) => ({
|
|
597
|
+
contents: [
|
|
949
598
|
{
|
|
950
|
-
|
|
951
|
-
text: `
|
|
952
|
-
uri: "parseToJSON"
|
|
599
|
+
uri: uri.href,
|
|
600
|
+
text: `Resource echo: ${message}`
|
|
953
601
|
}
|
|
954
|
-
]
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
}
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
}
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
};
|
|
1031
|
-
for (const entry of entries) {
|
|
1032
|
-
const entryType = entry.MDEntryType;
|
|
1033
|
-
const price = entry.MDEntryPx ? Number.parseFloat(entry.MDEntryPx) : 0;
|
|
1034
|
-
const size = entry.MDEntrySize ? Number.parseFloat(entry.MDEntrySize) : 0;
|
|
1035
|
-
const enumValue = getEnumValue(import_fixparser3.MDEntryType, entryType);
|
|
1036
|
-
switch (enumValue) {
|
|
1037
|
-
case import_fixparser3.MDEntryType.Bid:
|
|
1038
|
-
data.bid = price;
|
|
1039
|
-
break;
|
|
1040
|
-
case import_fixparser3.MDEntryType.Offer:
|
|
1041
|
-
data.offer = price;
|
|
1042
|
-
break;
|
|
1043
|
-
case import_fixparser3.MDEntryType.Trade:
|
|
1044
|
-
data.trade = price;
|
|
1045
|
-
break;
|
|
1046
|
-
case import_fixparser3.MDEntryType.IndexValue:
|
|
1047
|
-
data.indexValue = price;
|
|
1048
|
-
break;
|
|
1049
|
-
case import_fixparser3.MDEntryType.OpeningPrice:
|
|
1050
|
-
data.openingPrice = price;
|
|
1051
|
-
break;
|
|
1052
|
-
case import_fixparser3.MDEntryType.ClosingPrice:
|
|
1053
|
-
data.closingPrice = price;
|
|
1054
|
-
break;
|
|
1055
|
-
case import_fixparser3.MDEntryType.SettlementPrice:
|
|
1056
|
-
data.settlementPrice = price;
|
|
1057
|
-
break;
|
|
1058
|
-
case import_fixparser3.MDEntryType.TradingSessionHighPrice:
|
|
1059
|
-
data.tradingSessionHighPrice = price;
|
|
1060
|
-
break;
|
|
1061
|
-
case import_fixparser3.MDEntryType.TradingSessionLowPrice:
|
|
1062
|
-
data.tradingSessionLowPrice = price;
|
|
1063
|
-
break;
|
|
1064
|
-
case import_fixparser3.MDEntryType.VWAP:
|
|
1065
|
-
data.vwap = price;
|
|
1066
|
-
break;
|
|
1067
|
-
case import_fixparser3.MDEntryType.Imbalance:
|
|
1068
|
-
data.imbalance = size;
|
|
1069
|
-
break;
|
|
1070
|
-
case import_fixparser3.MDEntryType.TradeVolume:
|
|
1071
|
-
data.volume = size;
|
|
1072
|
-
break;
|
|
1073
|
-
case import_fixparser3.MDEntryType.OpenInterest:
|
|
1074
|
-
data.openInterest = size;
|
|
1075
|
-
break;
|
|
1076
|
-
case import_fixparser3.MDEntryType.CompositeUnderlyingPrice:
|
|
1077
|
-
data.compositeUnderlyingPrice = price;
|
|
1078
|
-
break;
|
|
1079
|
-
case import_fixparser3.MDEntryType.SimulatedSellPrice:
|
|
1080
|
-
data.simulatedSellPrice = price;
|
|
1081
|
-
break;
|
|
1082
|
-
case import_fixparser3.MDEntryType.SimulatedBuyPrice:
|
|
1083
|
-
data.simulatedBuyPrice = price;
|
|
1084
|
-
break;
|
|
1085
|
-
case import_fixparser3.MDEntryType.MarginRate:
|
|
1086
|
-
data.marginRate = price;
|
|
1087
|
-
break;
|
|
1088
|
-
case import_fixparser3.MDEntryType.MidPrice:
|
|
1089
|
-
data.midPrice = price;
|
|
1090
|
-
break;
|
|
1091
|
-
case import_fixparser3.MDEntryType.EmptyBook:
|
|
1092
|
-
data.emptyBook = 1;
|
|
1093
|
-
break;
|
|
1094
|
-
case import_fixparser3.MDEntryType.SettleHighPrice:
|
|
1095
|
-
data.settleHighPrice = price;
|
|
1096
|
-
break;
|
|
1097
|
-
case import_fixparser3.MDEntryType.SettleLowPrice:
|
|
1098
|
-
data.settleLowPrice = price;
|
|
1099
|
-
break;
|
|
1100
|
-
case import_fixparser3.MDEntryType.PriorSettlePrice:
|
|
1101
|
-
data.priorSettlePrice = price;
|
|
1102
|
-
break;
|
|
1103
|
-
case import_fixparser3.MDEntryType.SessionHighBid:
|
|
1104
|
-
data.sessionHighBid = price;
|
|
1105
|
-
break;
|
|
1106
|
-
case import_fixparser3.MDEntryType.SessionLowOffer:
|
|
1107
|
-
data.sessionLowOffer = price;
|
|
1108
|
-
break;
|
|
1109
|
-
case import_fixparser3.MDEntryType.EarlyPrices:
|
|
1110
|
-
data.earlyPrices = price;
|
|
1111
|
-
break;
|
|
1112
|
-
case import_fixparser3.MDEntryType.AuctionClearingPrice:
|
|
1113
|
-
data.auctionClearingPrice = price;
|
|
1114
|
-
break;
|
|
1115
|
-
case import_fixparser3.MDEntryType.SwapValueFactor:
|
|
1116
|
-
data.swapValueFactor = price;
|
|
1117
|
-
break;
|
|
1118
|
-
case import_fixparser3.MDEntryType.DailyValueAdjustmentForLongPositions:
|
|
1119
|
-
data.dailyValueAdjustmentForLongPositions = price;
|
|
1120
|
-
break;
|
|
1121
|
-
case import_fixparser3.MDEntryType.CumulativeValueAdjustmentForLongPositions:
|
|
1122
|
-
data.cumulativeValueAdjustmentForLongPositions = price;
|
|
1123
|
-
break;
|
|
1124
|
-
case import_fixparser3.MDEntryType.DailyValueAdjustmentForShortPositions:
|
|
1125
|
-
data.dailyValueAdjustmentForShortPositions = price;
|
|
1126
|
-
break;
|
|
1127
|
-
case import_fixparser3.MDEntryType.CumulativeValueAdjustmentForShortPositions:
|
|
1128
|
-
data.cumulativeValueAdjustmentForShortPositions = price;
|
|
1129
|
-
break;
|
|
1130
|
-
case import_fixparser3.MDEntryType.FixingPrice:
|
|
1131
|
-
data.fixingPrice = price;
|
|
1132
|
-
break;
|
|
1133
|
-
case import_fixparser3.MDEntryType.CashRate:
|
|
1134
|
-
data.cashRate = price;
|
|
1135
|
-
break;
|
|
1136
|
-
case import_fixparser3.MDEntryType.RecoveryRate:
|
|
1137
|
-
data.recoveryRate = price;
|
|
1138
|
-
break;
|
|
1139
|
-
case import_fixparser3.MDEntryType.RecoveryRateForLong:
|
|
1140
|
-
data.recoveryRateForLong = price;
|
|
1141
|
-
break;
|
|
1142
|
-
case import_fixparser3.MDEntryType.RecoveryRateForShort:
|
|
1143
|
-
data.recoveryRateForShort = price;
|
|
1144
|
-
break;
|
|
1145
|
-
case import_fixparser3.MDEntryType.MarketBid:
|
|
1146
|
-
data.marketBid = price;
|
|
1147
|
-
break;
|
|
1148
|
-
case import_fixparser3.MDEntryType.MarketOffer:
|
|
1149
|
-
data.marketOffer = price;
|
|
1150
|
-
break;
|
|
1151
|
-
case import_fixparser3.MDEntryType.ShortSaleMinPrice:
|
|
1152
|
-
data.shortSaleMinPrice = price;
|
|
1153
|
-
break;
|
|
1154
|
-
case import_fixparser3.MDEntryType.PreviousClosingPrice:
|
|
1155
|
-
data.previousClosingPrice = price;
|
|
1156
|
-
break;
|
|
1157
|
-
case import_fixparser3.MDEntryType.ThresholdLimitPriceBanding:
|
|
1158
|
-
data.thresholdLimitPriceBanding = price;
|
|
1159
|
-
break;
|
|
1160
|
-
case import_fixparser3.MDEntryType.DailyFinancingValue:
|
|
1161
|
-
data.dailyFinancingValue = price;
|
|
1162
|
-
break;
|
|
1163
|
-
case import_fixparser3.MDEntryType.AccruedFinancingValue:
|
|
1164
|
-
data.accruedFinancingValue = price;
|
|
1165
|
-
break;
|
|
1166
|
-
case import_fixparser3.MDEntryType.TWAP:
|
|
1167
|
-
data.twap = price;
|
|
1168
|
-
break;
|
|
1169
|
-
}
|
|
1170
|
-
}
|
|
1171
|
-
data.spread = data.offer - data.bid;
|
|
1172
|
-
if (!marketDataPrices.has(symbol)) {
|
|
1173
|
-
marketDataPrices.set(symbol, []);
|
|
1174
|
-
}
|
|
1175
|
-
const prices = marketDataPrices.get(symbol);
|
|
1176
|
-
prices.push(data);
|
|
1177
|
-
if (prices.length > maxPriceHistory) {
|
|
1178
|
-
prices.splice(0, prices.length - maxPriceHistory);
|
|
1179
|
-
}
|
|
1180
|
-
onPriceUpdate?.(symbol, data);
|
|
1181
|
-
const mdReqID = message.getField(import_fixparser3.Fields.MDReqID)?.value;
|
|
1182
|
-
if (mdReqID) {
|
|
1183
|
-
const callback = pendingRequests.get(mdReqID);
|
|
1184
|
-
if (callback) {
|
|
1185
|
-
callback(message);
|
|
1186
|
-
pendingRequests.delete(mdReqID);
|
|
1187
|
-
}
|
|
1188
|
-
}
|
|
1189
|
-
} else if (msgType === import_fixparser3.Messages.ExecutionReport) {
|
|
1190
|
-
const reqId = message.getField(import_fixparser3.Fields.ClOrdID)?.value;
|
|
1191
|
-
const callback = pendingRequests.get(reqId);
|
|
1192
|
-
if (callback) {
|
|
1193
|
-
callback(message);
|
|
1194
|
-
pendingRequests.delete(reqId);
|
|
1195
|
-
}
|
|
1196
|
-
}
|
|
1197
|
-
}
|
|
1198
|
-
|
|
1199
|
-
// src/MCPLocal.ts
|
|
1200
|
-
var MCPLocal = class extends MCPBase {
|
|
1201
|
-
/**
|
|
1202
|
-
* Map to store verified orders before execution
|
|
1203
|
-
* @private
|
|
1204
|
-
*/
|
|
1205
|
-
verifiedOrders = /* @__PURE__ */ new Map();
|
|
1206
|
-
/**
|
|
1207
|
-
* Map to store pending requests and their callbacks
|
|
1208
|
-
* @private
|
|
1209
|
-
*/
|
|
1210
|
-
pendingRequests = /* @__PURE__ */ new Map();
|
|
1211
|
-
/**
|
|
1212
|
-
* Map to store market data prices for each symbol
|
|
1213
|
-
* @private
|
|
1214
|
-
*/
|
|
1215
|
-
marketDataPrices = /* @__PURE__ */ new Map();
|
|
1216
|
-
/**
|
|
1217
|
-
* Maximum number of price history entries to keep per symbol
|
|
1218
|
-
* @private
|
|
1219
|
-
*/
|
|
1220
|
-
MAX_PRICE_HISTORY = 1e5;
|
|
1221
|
-
server = new import_server.Server(
|
|
1222
|
-
{
|
|
1223
|
-
name: "fixparser",
|
|
1224
|
-
version: "1.0.0"
|
|
1225
|
-
},
|
|
1226
|
-
{
|
|
1227
|
-
capabilities: {
|
|
1228
|
-
tools: Object.entries(toolSchemas).reduce(
|
|
1229
|
-
(acc, [name, { description, schema }]) => {
|
|
1230
|
-
acc[name] = {
|
|
1231
|
-
description,
|
|
1232
|
-
parameters: schema
|
|
1233
|
-
};
|
|
1234
|
-
return acc;
|
|
1235
|
-
},
|
|
1236
|
-
{}
|
|
1237
|
-
)
|
|
1238
|
-
}
|
|
1239
|
-
}
|
|
1240
|
-
);
|
|
1241
|
-
transport = new import_stdio.StdioServerTransport();
|
|
1242
|
-
constructor({ logger, onReady }) {
|
|
1243
|
-
super({ logger, onReady });
|
|
1244
|
-
}
|
|
1245
|
-
async register(parser) {
|
|
1246
|
-
this.parser = parser;
|
|
1247
|
-
this.parser.addOnMessageCallback((message) => {
|
|
1248
|
-
handleMessage(message, this.parser, this.pendingRequests, this.marketDataPrices, this.MAX_PRICE_HISTORY);
|
|
1249
|
-
});
|
|
1250
|
-
this.addWorkflows();
|
|
1251
|
-
await this.server.connect(this.transport);
|
|
1252
|
-
if (this.onReady) {
|
|
1253
|
-
this.onReady();
|
|
1254
|
-
}
|
|
1255
|
-
}
|
|
1256
|
-
addWorkflows() {
|
|
1257
|
-
if (!this.parser) {
|
|
1258
|
-
return;
|
|
1259
|
-
}
|
|
1260
|
-
if (!this.server) {
|
|
1261
|
-
return;
|
|
1262
|
-
}
|
|
1263
|
-
this.server.setRequestHandler(import_zod.z.object({ method: import_zod.z.literal("tools/list") }), async () => {
|
|
1264
|
-
return {
|
|
1265
|
-
tools: Object.entries(toolSchemas).map(([name, { description, schema }]) => ({
|
|
1266
|
-
name,
|
|
1267
|
-
description,
|
|
1268
|
-
inputSchema: schema
|
|
1269
|
-
}))
|
|
1270
|
-
};
|
|
1271
|
-
});
|
|
1272
|
-
this.server.setRequestHandler(
|
|
1273
|
-
import_zod.z.object({
|
|
1274
|
-
method: import_zod.z.literal("tools/call"),
|
|
1275
|
-
params: import_zod.z.object({
|
|
1276
|
-
name: import_zod.z.string(),
|
|
1277
|
-
arguments: import_zod.z.any(),
|
|
1278
|
-
_meta: import_zod.z.object({
|
|
1279
|
-
progressToken: import_zod.z.number()
|
|
1280
|
-
}).optional()
|
|
1281
|
-
})
|
|
1282
|
-
}),
|
|
1283
|
-
async (request) => {
|
|
1284
|
-
const { name, arguments: args } = request.params;
|
|
1285
|
-
const toolHandlers = createToolHandlers(
|
|
1286
|
-
this.parser,
|
|
1287
|
-
this.verifiedOrders,
|
|
1288
|
-
this.pendingRequests,
|
|
1289
|
-
this.marketDataPrices
|
|
1290
|
-
);
|
|
1291
|
-
const handler = toolHandlers[name];
|
|
1292
|
-
if (!handler) {
|
|
1293
|
-
return {
|
|
1294
|
-
content: [
|
|
1295
|
-
{
|
|
1296
|
-
type: "text",
|
|
1297
|
-
text: `Tool not found: ${name}`,
|
|
1298
|
-
uri: name
|
|
1299
|
-
}
|
|
1300
|
-
],
|
|
1301
|
-
isError: true
|
|
1302
|
-
};
|
|
1303
|
-
}
|
|
1304
|
-
const result = await handler(args);
|
|
602
|
+
]
|
|
603
|
+
})
|
|
604
|
+
);
|
|
605
|
+
this.server.resource(
|
|
606
|
+
"stockGraph",
|
|
607
|
+
new import_mcp.ResourceTemplate("stock://{symbol}", { list: void 0 }),
|
|
608
|
+
async (uri, variables) => {
|
|
609
|
+
const symbol = variables.symbol;
|
|
610
|
+
const data = [
|
|
611
|
+
{ time: "09:30", price: 150 },
|
|
612
|
+
{ time: "10:30", price: 152.5 },
|
|
613
|
+
{ time: "11:30", price: 151.75 },
|
|
614
|
+
{ time: "12:30", price: 153.25 },
|
|
615
|
+
{ time: "13:30", price: 154 },
|
|
616
|
+
{ time: "14:30", price: 153.5 },
|
|
617
|
+
{ time: "15:30", price: 155 },
|
|
618
|
+
{ time: "16:00", price: 154.75 }
|
|
619
|
+
];
|
|
620
|
+
const width = 600;
|
|
621
|
+
const height = 300;
|
|
622
|
+
const padding = 40;
|
|
623
|
+
const xScale = (width - 2 * padding) / (data.length - 1);
|
|
624
|
+
const yMin = Math.min(...data.map((d) => d.price));
|
|
625
|
+
const yMax = Math.max(...data.map((d) => d.price));
|
|
626
|
+
const yScale = (height - 2 * padding) / (yMax - yMin);
|
|
627
|
+
const points = data.map((d, i) => {
|
|
628
|
+
const x = padding + i * xScale;
|
|
629
|
+
const y = height - padding - (d.price - yMin) * yScale;
|
|
630
|
+
return `${x},${y}`;
|
|
631
|
+
}).join(" L ");
|
|
632
|
+
const svg = `<?xml version="1.0" encoding="UTF-8"?>
|
|
633
|
+
<svg width="${width}" height="${height}" xmlns="http://www.w3.org/2000/svg">
|
|
634
|
+
<!-- Background -->
|
|
635
|
+
<rect width="100%" height="100%" fill="#f8f9fa"/>
|
|
636
|
+
|
|
637
|
+
<!-- Grid lines -->
|
|
638
|
+
<g stroke="#e9ecef" stroke-width="1">
|
|
639
|
+
${Array.from({ length: 5 }, (_, i) => {
|
|
640
|
+
const y = padding + (height - 2 * padding) * i / 4;
|
|
641
|
+
return `<line x1="${padding}" y1="${y}" x2="${width - padding}" y2="${y}"/>`;
|
|
642
|
+
}).join("\n")}
|
|
643
|
+
</g>
|
|
644
|
+
|
|
645
|
+
<!-- Price line -->
|
|
646
|
+
<path d="M ${points}"
|
|
647
|
+
fill="none"
|
|
648
|
+
stroke="#007bff"
|
|
649
|
+
stroke-width="2"/>
|
|
650
|
+
|
|
651
|
+
<!-- Data points -->
|
|
652
|
+
${data.map((d, i) => {
|
|
653
|
+
const x = padding + i * xScale;
|
|
654
|
+
const y = height - padding - (d.price - yMin) * yScale;
|
|
655
|
+
return `<circle cx="${x}" cy="${y}" r="3" fill="#007bff"/>`;
|
|
656
|
+
}).join("\n")}
|
|
657
|
+
|
|
658
|
+
<!-- Labels -->
|
|
659
|
+
<g font-family="Arial" font-size="12" fill="#495057">
|
|
660
|
+
${data.map((d, i) => {
|
|
661
|
+
const x = padding + i * xScale;
|
|
662
|
+
return `<text x="${x}" y="${height - padding + 20}" text-anchor="middle">${d.time}</text>`;
|
|
663
|
+
}).join("\n")}
|
|
664
|
+
${Array.from({ length: 5 }, (_, i) => {
|
|
665
|
+
const y = padding + (height - 2 * padding) * i / 4;
|
|
666
|
+
const price = yMax - (yMax - yMin) * i / 4;
|
|
667
|
+
return `<text x="${padding - 5}" y="${y + 4}" text-anchor="end">$${price.toFixed(2)}</text>`;
|
|
668
|
+
}).join("\n")}
|
|
669
|
+
</g>
|
|
670
|
+
|
|
671
|
+
<!-- Title -->
|
|
672
|
+
<text x="${width / 2}" y="${padding / 2}"
|
|
673
|
+
font-family="Arial" font-size="16" font-weight="bold"
|
|
674
|
+
text-anchor="middle" fill="#212529">
|
|
675
|
+
${symbol} - 1 Day Price Chart
|
|
676
|
+
</text>
|
|
677
|
+
</svg>`;
|
|
1305
678
|
return {
|
|
1306
|
-
|
|
1307
|
-
|
|
679
|
+
contents: [
|
|
680
|
+
{
|
|
681
|
+
uri: uri.href,
|
|
682
|
+
text: svg
|
|
683
|
+
}
|
|
684
|
+
]
|
|
1308
685
|
};
|
|
1309
686
|
}
|
|
1310
687
|
);
|