fixparser-plugin-mcp 9.1.7-f34f63d7 → 9.1.7-f3af791d
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 +844 -1654
- package/build/cjs/MCPLocal.js.map +4 -4
- package/build/esm/MCPLocal.mjs +834 -1667
- package/build/esm/MCPLocal.mjs.map +4 -4
- package/build-examples/cjs/example_mcp_local.js +14 -5
- package/build-examples/cjs/example_mcp_local.js.map +4 -4
- package/build-examples/esm/example_mcp_local.mjs +14 -5
- package/build-examples/esm/example_mcp_local.mjs.map +4 -4
- package/package.json +12 -11
- package/types/MCPLocal.d.ts +3 -1
- package/types/schemas/index.d.ts +32 -0
- package/types/schemas/schemas.d.ts +168 -0
- package/types/tools/index.d.ts +17 -0
- package/types/tools/marketData.d.ts +40 -0
- package/types/tools/order.d.ts +11 -0
- package/types/tools/parse.d.ts +5 -0
- package/types/tools/parseToJSON.d.ts +5 -0
package/build/cjs/MCPLocal.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
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
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/MCPLocal.ts
|
|
@@ -25,1269 +35,768 @@ __export(MCPLocal_exports, {
|
|
|
25
35
|
module.exports = __toCommonJS(MCPLocal_exports);
|
|
26
36
|
var import_server = require("@modelcontextprotocol/sdk/server/index.js");
|
|
27
37
|
var import_stdio = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
28
|
-
var
|
|
29
|
-
var import_zod5 = require("zod");
|
|
30
|
-
|
|
31
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/Options.js
|
|
32
|
-
var ignoreOverride = Symbol("Let zodToJsonSchema decide on which parser to use");
|
|
33
|
-
var defaultOptions = {
|
|
34
|
-
name: void 0,
|
|
35
|
-
$refStrategy: "root",
|
|
36
|
-
basePath: ["#"],
|
|
37
|
-
effectStrategy: "input",
|
|
38
|
-
pipeStrategy: "all",
|
|
39
|
-
dateStrategy: "format:date-time",
|
|
40
|
-
mapStrategy: "entries",
|
|
41
|
-
removeAdditionalStrategy: "passthrough",
|
|
42
|
-
allowedAdditionalProperties: true,
|
|
43
|
-
rejectedAdditionalProperties: false,
|
|
44
|
-
definitionPath: "definitions",
|
|
45
|
-
target: "jsonSchema7",
|
|
46
|
-
strictUnions: false,
|
|
47
|
-
definitions: {},
|
|
48
|
-
errorMessages: false,
|
|
49
|
-
markdownDescription: false,
|
|
50
|
-
patternStrategy: "escape",
|
|
51
|
-
applyRegexFlags: false,
|
|
52
|
-
emailStrategy: "format:email",
|
|
53
|
-
base64Strategy: "contentEncoding:base64",
|
|
54
|
-
nameStrategy: "ref"
|
|
55
|
-
};
|
|
56
|
-
var getDefaultOptions = (options) => typeof options === "string" ? {
|
|
57
|
-
...defaultOptions,
|
|
58
|
-
name: options
|
|
59
|
-
} : {
|
|
60
|
-
...defaultOptions,
|
|
61
|
-
...options
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/Refs.js
|
|
65
|
-
var getRefs = (options) => {
|
|
66
|
-
const _options = getDefaultOptions(options);
|
|
67
|
-
const currentPath = _options.name !== void 0 ? [..._options.basePath, _options.definitionPath, _options.name] : _options.basePath;
|
|
68
|
-
return {
|
|
69
|
-
..._options,
|
|
70
|
-
currentPath,
|
|
71
|
-
propertyPath: void 0,
|
|
72
|
-
seen: new Map(Object.entries(_options.definitions).map(([name, def]) => [
|
|
73
|
-
def._def,
|
|
74
|
-
{
|
|
75
|
-
def: def._def,
|
|
76
|
-
path: [..._options.basePath, _options.definitionPath, name],
|
|
77
|
-
// Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
|
|
78
|
-
jsonSchema: void 0
|
|
79
|
-
}
|
|
80
|
-
]))
|
|
81
|
-
};
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/errorMessages.js
|
|
85
|
-
function addErrorMessage(res, key, errorMessage, refs) {
|
|
86
|
-
if (!refs?.errorMessages)
|
|
87
|
-
return;
|
|
88
|
-
if (errorMessage) {
|
|
89
|
-
res.errorMessage = {
|
|
90
|
-
...res.errorMessage,
|
|
91
|
-
[key]: errorMessage
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
function setResponseValueAndErrors(res, key, value, errorMessage, refs) {
|
|
96
|
-
res[key] = value;
|
|
97
|
-
addErrorMessage(res, key, errorMessage, refs);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/selectParser.js
|
|
101
|
-
var import_zod4 = require("zod");
|
|
102
|
-
|
|
103
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/any.js
|
|
104
|
-
function parseAnyDef() {
|
|
105
|
-
return {};
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/array.js
|
|
38
|
+
var import_fixparser3 = require("fixparser");
|
|
109
39
|
var import_zod = require("zod");
|
|
110
|
-
function parseArrayDef(def, refs) {
|
|
111
|
-
const res = {
|
|
112
|
-
type: "array"
|
|
113
|
-
};
|
|
114
|
-
if (def.type?._def && def.type?._def?.typeName !== import_zod.ZodFirstPartyTypeKind.ZodAny) {
|
|
115
|
-
res.items = parseDef(def.type._def, {
|
|
116
|
-
...refs,
|
|
117
|
-
currentPath: [...refs.currentPath, "items"]
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
if (def.minLength) {
|
|
121
|
-
setResponseValueAndErrors(res, "minItems", def.minLength.value, def.minLength.message, refs);
|
|
122
|
-
}
|
|
123
|
-
if (def.maxLength) {
|
|
124
|
-
setResponseValueAndErrors(res, "maxItems", def.maxLength.value, def.maxLength.message, refs);
|
|
125
|
-
}
|
|
126
|
-
if (def.exactLength) {
|
|
127
|
-
setResponseValueAndErrors(res, "minItems", def.exactLength.value, def.exactLength.message, refs);
|
|
128
|
-
setResponseValueAndErrors(res, "maxItems", def.exactLength.value, def.exactLength.message, refs);
|
|
129
|
-
}
|
|
130
|
-
return res;
|
|
131
|
-
}
|
|
132
40
|
|
|
133
|
-
//
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
41
|
+
// src/schemas/schemas.ts
|
|
42
|
+
var toolSchemas = {
|
|
43
|
+
parse: {
|
|
44
|
+
description: "Parses a FIX message and describes it in plain language",
|
|
45
|
+
schema: {
|
|
46
|
+
type: "object",
|
|
47
|
+
properties: {
|
|
48
|
+
fixString: { type: "string" }
|
|
49
|
+
},
|
|
50
|
+
required: ["fixString"]
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
parseToJSON: {
|
|
54
|
+
description: "Parses a FIX message into JSON",
|
|
55
|
+
schema: {
|
|
56
|
+
type: "object",
|
|
57
|
+
properties: {
|
|
58
|
+
fixString: { type: "string" }
|
|
59
|
+
},
|
|
60
|
+
required: ["fixString"]
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
verifyOrder: {
|
|
64
|
+
description: "Verifies order parameters before execution. verifyOrder must be called before executeOrder.",
|
|
65
|
+
schema: {
|
|
66
|
+
type: "object",
|
|
67
|
+
properties: {
|
|
68
|
+
clOrdID: { type: "string" },
|
|
69
|
+
handlInst: {
|
|
70
|
+
type: "string",
|
|
71
|
+
enum: ["1", "2", "3"],
|
|
72
|
+
description: "Handling Instructions: 1=Automated Execution No Intervention, 2=Automated Execution Intervention OK, 3=Manual Order"
|
|
73
|
+
},
|
|
74
|
+
quantity: { type: "string" },
|
|
75
|
+
price: { type: "string" },
|
|
76
|
+
ordType: {
|
|
77
|
+
type: "string",
|
|
78
|
+
enum: [
|
|
79
|
+
"1",
|
|
80
|
+
"2",
|
|
81
|
+
"3",
|
|
82
|
+
"4",
|
|
83
|
+
"5",
|
|
84
|
+
"6",
|
|
85
|
+
"7",
|
|
86
|
+
"8",
|
|
87
|
+
"9",
|
|
88
|
+
"A",
|
|
89
|
+
"B",
|
|
90
|
+
"C",
|
|
91
|
+
"D",
|
|
92
|
+
"E",
|
|
93
|
+
"F",
|
|
94
|
+
"G",
|
|
95
|
+
"H",
|
|
96
|
+
"I",
|
|
97
|
+
"J",
|
|
98
|
+
"K",
|
|
99
|
+
"L",
|
|
100
|
+
"M",
|
|
101
|
+
"P",
|
|
102
|
+
"Q",
|
|
103
|
+
"R",
|
|
104
|
+
"S"
|
|
105
|
+
],
|
|
106
|
+
description: "Order Type: 1=Market, 2=Limit, 3=Stop, 4=StopLimit, 5=MarketOnClose, 6=WithOrWithout, 7=LimitOrBetter, 8=LimitWithOrWithout, 9=OnBasis, A=OnClose, B=LimitOnClose, C=ForexMarket, D=PreviouslyQuoted, E=PreviouslyIndicated, F=ForexLimit, G=ForexSwap, H=ForexPreviouslyQuoted, I=Funari, J=MarketIfTouched, K=MarketWithLeftOverAsLimit, L=PreviousFundValuationPoint, M=NextFundValuationPoint, P=Pegged, Q=CounterOrderSelection, R=StopOnBidOrOffer, S=StopLimitOnBidOrOffer"
|
|
107
|
+
},
|
|
108
|
+
side: {
|
|
109
|
+
type: "string",
|
|
110
|
+
enum: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H"],
|
|
111
|
+
description: "Side: 1=Buy, 2=Sell, 3=BuyMinus, 4=SellPlus, 5=SellShort, 6=SellShortExempt, 7=Undisclosed, 8=Cross, 9=CrossShort, A=CrossShortExempt, B=AsDefined, C=Opposite, D=Subscribe, E=Redeem, F=Lend, G=Borrow, H=SellUndisclosed"
|
|
112
|
+
},
|
|
113
|
+
symbol: { type: "string" },
|
|
114
|
+
timeInForce: {
|
|
115
|
+
type: "string",
|
|
116
|
+
enum: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C"],
|
|
117
|
+
description: "Time In Force: 0=Day, 1=GoodTillCancel, 2=AtTheOpening, 3=ImmediateOrCancel, 4=FillOrKill, 5=GoodTillCrossing, 6=GoodTillDate, 7=AtTheClose, 8=GoodThroughCrossing, 9=AtCrossing, A=GoodForTime, B=GoodForAuction, C=GoodForMonth"
|
|
155
118
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
119
|
+
},
|
|
120
|
+
required: ["clOrdID", "handlInst", "quantity", "price", "ordType", "side", "symbol", "timeInForce"]
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
executeOrder: {
|
|
124
|
+
description: "Executes a verified order. verifyOrder must be called before executeOrder. user has to explicitly allow executeOrder.",
|
|
125
|
+
schema: {
|
|
126
|
+
type: "object",
|
|
127
|
+
properties: {
|
|
128
|
+
clOrdID: { type: "string" },
|
|
129
|
+
handlInst: {
|
|
130
|
+
type: "string",
|
|
131
|
+
enum: ["1", "2", "3"],
|
|
132
|
+
description: "Handling Instructions: 1=Automated Execution No Intervention, 2=Automated Execution Intervention OK, 3=Manual Order"
|
|
133
|
+
},
|
|
134
|
+
quantity: { type: "string" },
|
|
135
|
+
price: { type: "string" },
|
|
136
|
+
ordType: {
|
|
137
|
+
type: "string",
|
|
138
|
+
enum: [
|
|
139
|
+
"1",
|
|
140
|
+
"2",
|
|
141
|
+
"3",
|
|
142
|
+
"4",
|
|
143
|
+
"5",
|
|
144
|
+
"6",
|
|
145
|
+
"7",
|
|
146
|
+
"8",
|
|
147
|
+
"9",
|
|
148
|
+
"A",
|
|
149
|
+
"B",
|
|
150
|
+
"C",
|
|
151
|
+
"D",
|
|
152
|
+
"E",
|
|
153
|
+
"F",
|
|
154
|
+
"G",
|
|
155
|
+
"H",
|
|
156
|
+
"I",
|
|
157
|
+
"J",
|
|
158
|
+
"K",
|
|
159
|
+
"L",
|
|
160
|
+
"M",
|
|
161
|
+
"P",
|
|
162
|
+
"Q",
|
|
163
|
+
"R",
|
|
164
|
+
"S"
|
|
165
|
+
],
|
|
166
|
+
description: "Order Type: 1=Market, 2=Limit, 3=Stop, 4=StopLimit, 5=MarketOnClose, 6=WithOrWithout, 7=LimitOrBetter, 8=LimitWithOrWithout, 9=OnBasis, A=OnClose, B=LimitOnClose, C=ForexMarket, D=PreviouslyQuoted, E=PreviouslyIndicated, F=ForexLimit, G=ForexSwap, H=ForexPreviouslyQuoted, I=Funari, J=MarketIfTouched, K=MarketWithLeftOverAsLimit, L=PreviousFundValuationPoint, M=NextFundValuationPoint, P=Pegged, Q=CounterOrderSelection, R=StopOnBidOrOffer, S=StopLimitOnBidOrOffer"
|
|
167
|
+
},
|
|
168
|
+
side: {
|
|
169
|
+
type: "string",
|
|
170
|
+
enum: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H"],
|
|
171
|
+
description: "Side: 1=Buy, 2=Sell, 3=BuyMinus, 4=SellPlus, 5=SellShort, 6=SellShortExempt, 7=Undisclosed, 8=Cross, 9=CrossShort, A=CrossShortExempt, B=AsDefined, C=Opposite, D=Subscribe, E=Redeem, F=Lend, G=Borrow, H=SellUndisclosed"
|
|
172
|
+
},
|
|
173
|
+
symbol: { type: "string" },
|
|
174
|
+
timeInForce: {
|
|
175
|
+
type: "string",
|
|
176
|
+
enum: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C"],
|
|
177
|
+
description: "Time In Force: 0=Day, 1=GoodTillCancel, 2=AtTheOpening, 3=ImmediateOrCancel, 4=FillOrKill, 5=GoodTillCrossing, 6=GoodTillDate, 7=AtTheClose, 8=GoodThroughCrossing, 9=AtCrossing, A=GoodForTime, B=GoodForAuction, C=GoodForMonth"
|
|
169
178
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
179
|
+
},
|
|
180
|
+
required: ["clOrdID", "handlInst", "quantity", "price", "ordType", "side", "symbol", "timeInForce"]
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
marketDataRequest: {
|
|
184
|
+
description: "Requests market data for specified symbols",
|
|
185
|
+
schema: {
|
|
186
|
+
type: "object",
|
|
187
|
+
properties: {
|
|
188
|
+
mdUpdateType: {
|
|
189
|
+
type: "string",
|
|
190
|
+
enum: ["0", "1"],
|
|
191
|
+
description: "Market Data Update Type: 0=Full Refresh, 1=Incremental Refresh"
|
|
192
|
+
},
|
|
193
|
+
symbols: { type: "array", items: { type: "string" } },
|
|
194
|
+
mdReqID: { type: "string" },
|
|
195
|
+
subscriptionRequestType: {
|
|
196
|
+
type: "string",
|
|
197
|
+
enum: ["0", "1", "2"],
|
|
198
|
+
description: "Subscription Request Type: 0=Snapshot, 1=Snapshot + Updates, 2=Disable Previous Snapshot + Update Request"
|
|
199
|
+
},
|
|
200
|
+
mdEntryTypes: {
|
|
201
|
+
type: "array",
|
|
202
|
+
items: {
|
|
203
|
+
type: "string",
|
|
204
|
+
enum: [
|
|
205
|
+
"0",
|
|
206
|
+
"1",
|
|
207
|
+
"2",
|
|
208
|
+
"3",
|
|
209
|
+
"4",
|
|
210
|
+
"5",
|
|
211
|
+
"6",
|
|
212
|
+
"7",
|
|
213
|
+
"8",
|
|
214
|
+
"9",
|
|
215
|
+
"A",
|
|
216
|
+
"B",
|
|
217
|
+
"C",
|
|
218
|
+
"D",
|
|
219
|
+
"E",
|
|
220
|
+
"F",
|
|
221
|
+
"G",
|
|
222
|
+
"H",
|
|
223
|
+
"I",
|
|
224
|
+
"J",
|
|
225
|
+
"K",
|
|
226
|
+
"L",
|
|
227
|
+
"M",
|
|
228
|
+
"N",
|
|
229
|
+
"O",
|
|
230
|
+
"P",
|
|
231
|
+
"Q",
|
|
232
|
+
"R",
|
|
233
|
+
"S",
|
|
234
|
+
"T",
|
|
235
|
+
"U",
|
|
236
|
+
"V",
|
|
237
|
+
"W",
|
|
238
|
+
"X",
|
|
239
|
+
"Y",
|
|
240
|
+
"Z"
|
|
241
|
+
]
|
|
242
|
+
},
|
|
243
|
+
description: "Market Data Entry Types: 0=Bid, 1=Offer, 2=Trade, 3=Index Value, 4=Opening Price, 5=Closing Price, 6=Settlement Price, 7=High Price, 8=Low Price, 9=Trade Volume, A=Open Interest, B=Simulated Sell Price, C=Simulated Buy Price, D=Empty Book, E=Session High Bid, F=Session Low Offer, G=Fixing Price, H=Electronic Volume, I=Threshold Limits and Price Band Variation, J=Clearing Price, K=Open Interest Change, L=Last Trade Price, M=Last Trade Volume, N=Last Trade Time, O=Last Trade Tick, P=Last Trade Exchange, Q=Last Trade ID, R=Last Trade Side, S=Last Trade Price Change, T=Last Trade Price Change Percent, U=Last Trade Price Change Basis Points, V=Last Trade Price Change Points, W=Last Trade Price Change Ticks, X=Last Trade Price Change Ticks Percent, Y=Last Trade Price Change Ticks Basis Points, Z=Last Trade Price Change Ticks Points"
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
required: ["mdUpdateType", "symbols", "mdReqID", "subscriptionRequestType"]
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
getStockGraph: {
|
|
250
|
+
description: "Generates a price chart for a given symbol",
|
|
251
|
+
schema: {
|
|
252
|
+
type: "object",
|
|
253
|
+
properties: {
|
|
254
|
+
symbol: { type: "string" }
|
|
255
|
+
},
|
|
256
|
+
required: ["symbol"]
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
getStockPriceHistory: {
|
|
260
|
+
description: "Returns price history for a given symbol",
|
|
261
|
+
schema: {
|
|
262
|
+
type: "object",
|
|
263
|
+
properties: {
|
|
264
|
+
symbol: { type: "string" }
|
|
265
|
+
},
|
|
266
|
+
required: ["symbol"]
|
|
174
267
|
}
|
|
175
268
|
}
|
|
176
|
-
return res;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js
|
|
180
|
-
function parseBooleanDef() {
|
|
181
|
-
return {
|
|
182
|
-
type: "boolean"
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/branded.js
|
|
187
|
-
function parseBrandedDef(_def, refs) {
|
|
188
|
-
return parseDef(_def.type._def, refs);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/catch.js
|
|
192
|
-
var parseCatchDef = (def, refs) => {
|
|
193
|
-
return parseDef(def.innerType._def, refs);
|
|
194
269
|
};
|
|
195
270
|
|
|
196
|
-
//
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
271
|
+
// src/tools/marketData.ts
|
|
272
|
+
var import_fixparser = require("fixparser");
|
|
273
|
+
var import_quickchart_js = __toESM(require("quickchart-js"), 1);
|
|
274
|
+
var createMarketDataRequestHandler = (parser, pendingRequests) => {
|
|
275
|
+
return async (args) => {
|
|
276
|
+
try {
|
|
277
|
+
const response = new Promise((resolve) => {
|
|
278
|
+
pendingRequests.set(args.mdReqID, resolve);
|
|
279
|
+
});
|
|
280
|
+
const entryTypes = args.mdEntryTypes || [import_fixparser.MDEntryType.Bid, import_fixparser.MDEntryType.Offer, import_fixparser.MDEntryType.TradeVolume];
|
|
281
|
+
const messageFields = [
|
|
282
|
+
new import_fixparser.Field(import_fixparser.Fields.MsgType, import_fixparser.Messages.MarketDataRequest),
|
|
283
|
+
new import_fixparser.Field(import_fixparser.Fields.SenderCompID, parser.sender),
|
|
284
|
+
new import_fixparser.Field(import_fixparser.Fields.MsgSeqNum, parser.getNextTargetMsgSeqNum()),
|
|
285
|
+
new import_fixparser.Field(import_fixparser.Fields.TargetCompID, parser.target),
|
|
286
|
+
new import_fixparser.Field(import_fixparser.Fields.SendingTime, parser.getTimestamp()),
|
|
287
|
+
new import_fixparser.Field(import_fixparser.Fields.MDReqID, args.mdReqID),
|
|
288
|
+
new import_fixparser.Field(import_fixparser.Fields.SubscriptionRequestType, args.subscriptionRequestType),
|
|
289
|
+
new import_fixparser.Field(import_fixparser.Fields.MarketDepth, 0),
|
|
290
|
+
new import_fixparser.Field(import_fixparser.Fields.MDUpdateType, args.mdUpdateType)
|
|
291
|
+
];
|
|
292
|
+
messageFields.push(new import_fixparser.Field(import_fixparser.Fields.NoRelatedSym, args.symbols.length));
|
|
293
|
+
args.symbols.forEach((symbol) => {
|
|
294
|
+
messageFields.push(new import_fixparser.Field(import_fixparser.Fields.Symbol, symbol));
|
|
295
|
+
});
|
|
296
|
+
messageFields.push(new import_fixparser.Field(import_fixparser.Fields.NoMDEntryTypes, entryTypes.length));
|
|
297
|
+
entryTypes.forEach((entryType) => {
|
|
298
|
+
messageFields.push(new import_fixparser.Field(import_fixparser.Fields.MDEntryType, entryType));
|
|
299
|
+
});
|
|
300
|
+
const mdr = parser.createMessage(...messageFields);
|
|
301
|
+
if (!parser.connected) {
|
|
302
|
+
return {
|
|
303
|
+
content: [
|
|
304
|
+
{
|
|
305
|
+
type: "text",
|
|
306
|
+
text: "Error: Not connected. Ignoring message.",
|
|
307
|
+
uri: "marketDataRequest"
|
|
308
|
+
}
|
|
309
|
+
],
|
|
310
|
+
isError: true
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
parser.send(mdr);
|
|
314
|
+
const fixData = await response;
|
|
207
315
|
return {
|
|
208
|
-
|
|
209
|
-
|
|
316
|
+
content: [
|
|
317
|
+
{
|
|
318
|
+
type: "text",
|
|
319
|
+
text: `Market data for ${args.symbols.join(", ")}: ${JSON.stringify(fixData.toFIXJSON())}`,
|
|
320
|
+
uri: "marketDataRequest"
|
|
321
|
+
}
|
|
322
|
+
]
|
|
210
323
|
};
|
|
211
|
-
|
|
324
|
+
} catch (error) {
|
|
212
325
|
return {
|
|
213
|
-
|
|
214
|
-
|
|
326
|
+
content: [
|
|
327
|
+
{
|
|
328
|
+
type: "text",
|
|
329
|
+
text: `Error: ${error instanceof Error ? error.message : "Failed to request market data"}`,
|
|
330
|
+
uri: "marketDataRequest"
|
|
331
|
+
}
|
|
332
|
+
],
|
|
333
|
+
isError: true
|
|
215
334
|
};
|
|
216
|
-
case "integer":
|
|
217
|
-
return integerDateParser(def, refs);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
var integerDateParser = (def, refs) => {
|
|
221
|
-
const res = {
|
|
222
|
-
type: "integer",
|
|
223
|
-
format: "unix-time"
|
|
224
|
-
};
|
|
225
|
-
if (refs.target === "openApi3") {
|
|
226
|
-
return res;
|
|
227
|
-
}
|
|
228
|
-
for (const check of def.checks) {
|
|
229
|
-
switch (check.kind) {
|
|
230
|
-
case "min":
|
|
231
|
-
setResponseValueAndErrors(
|
|
232
|
-
res,
|
|
233
|
-
"minimum",
|
|
234
|
-
check.value,
|
|
235
|
-
// This is in milliseconds
|
|
236
|
-
check.message,
|
|
237
|
-
refs
|
|
238
|
-
);
|
|
239
|
-
break;
|
|
240
|
-
case "max":
|
|
241
|
-
setResponseValueAndErrors(
|
|
242
|
-
res,
|
|
243
|
-
"maximum",
|
|
244
|
-
check.value,
|
|
245
|
-
// This is in milliseconds
|
|
246
|
-
check.message,
|
|
247
|
-
refs
|
|
248
|
-
);
|
|
249
|
-
break;
|
|
250
335
|
}
|
|
251
|
-
}
|
|
252
|
-
return res;
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/default.js
|
|
256
|
-
function parseDefaultDef(_def, refs) {
|
|
257
|
-
return {
|
|
258
|
-
...parseDef(_def.innerType._def, refs),
|
|
259
|
-
default: _def.defaultValue()
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/effects.js
|
|
264
|
-
function parseEffectsDef(_def, refs) {
|
|
265
|
-
return refs.effectStrategy === "input" ? parseDef(_def.schema._def, refs) : {};
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/enum.js
|
|
269
|
-
function parseEnumDef(def) {
|
|
270
|
-
return {
|
|
271
|
-
type: "string",
|
|
272
|
-
enum: Array.from(def.values)
|
|
273
336
|
};
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js
|
|
277
|
-
var isJsonSchema7AllOfType = (type) => {
|
|
278
|
-
if ("type" in type && type.type === "string")
|
|
279
|
-
return false;
|
|
280
|
-
return "allOf" in type;
|
|
281
337
|
};
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
mergedAllOf.push(...schema.allOf);
|
|
298
|
-
if (schema.unevaluatedProperties === void 0) {
|
|
299
|
-
unevaluatedProperties = void 0;
|
|
300
|
-
}
|
|
301
|
-
} else {
|
|
302
|
-
let nestedSchema = schema;
|
|
303
|
-
if ("additionalProperties" in schema && schema.additionalProperties === false) {
|
|
304
|
-
const { additionalProperties, ...rest } = schema;
|
|
305
|
-
nestedSchema = rest;
|
|
306
|
-
} else {
|
|
307
|
-
unevaluatedProperties = void 0;
|
|
338
|
+
var createGetStockGraphHandler = (marketDataPrices) => {
|
|
339
|
+
return async (args) => {
|
|
340
|
+
try {
|
|
341
|
+
const symbol = args.symbol;
|
|
342
|
+
const priceHistory = marketDataPrices.get(symbol) || [];
|
|
343
|
+
if (priceHistory.length === 0) {
|
|
344
|
+
return {
|
|
345
|
+
content: [
|
|
346
|
+
{
|
|
347
|
+
type: "text",
|
|
348
|
+
text: `No price data available for ${symbol}`,
|
|
349
|
+
uri: "getStockGraph"
|
|
350
|
+
}
|
|
351
|
+
]
|
|
352
|
+
};
|
|
308
353
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
|
|
354
|
-
/**
|
|
355
|
-
* Constructed a valid Unicode RegExp
|
|
356
|
-
*
|
|
357
|
-
* Lazily instantiate since this type of regex isn't supported
|
|
358
|
-
* in all envs (e.g. React Native).
|
|
359
|
-
*
|
|
360
|
-
* See:
|
|
361
|
-
* https://github.com/colinhacks/zod/issues/2433
|
|
362
|
-
* Fix in Zod:
|
|
363
|
-
* https://github.com/colinhacks/zod/commit/9340fd51e48576a75adc919bff65dbc4a5d4c99b
|
|
364
|
-
*/
|
|
365
|
-
emoji: () => {
|
|
366
|
-
if (emojiRegex === void 0) {
|
|
367
|
-
emojiRegex = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u");
|
|
368
|
-
}
|
|
369
|
-
return emojiRegex;
|
|
370
|
-
},
|
|
371
|
-
/**
|
|
372
|
-
* Unused
|
|
373
|
-
*/
|
|
374
|
-
uuid: /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,
|
|
375
|
-
/**
|
|
376
|
-
* Unused
|
|
377
|
-
*/
|
|
378
|
-
ipv4: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,
|
|
379
|
-
ipv4Cidr: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,
|
|
380
|
-
/**
|
|
381
|
-
* Unused
|
|
382
|
-
*/
|
|
383
|
-
ipv6: /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,
|
|
384
|
-
ipv6Cidr: /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,
|
|
385
|
-
base64: /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,
|
|
386
|
-
base64url: /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,
|
|
387
|
-
nanoid: /^[a-zA-Z0-9_-]{21}$/,
|
|
388
|
-
jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
|
|
389
|
-
};
|
|
390
|
-
function parseStringDef(def, refs) {
|
|
391
|
-
const res = {
|
|
392
|
-
type: "string"
|
|
393
|
-
};
|
|
394
|
-
if (def.checks) {
|
|
395
|
-
for (const check of def.checks) {
|
|
396
|
-
switch (check.kind) {
|
|
397
|
-
case "min":
|
|
398
|
-
setResponseValueAndErrors(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
|
|
399
|
-
break;
|
|
400
|
-
case "max":
|
|
401
|
-
setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
|
|
402
|
-
break;
|
|
403
|
-
case "email":
|
|
404
|
-
switch (refs.emailStrategy) {
|
|
405
|
-
case "format:email":
|
|
406
|
-
addFormat(res, "email", check.message, refs);
|
|
407
|
-
break;
|
|
408
|
-
case "format:idn-email":
|
|
409
|
-
addFormat(res, "idn-email", check.message, refs);
|
|
410
|
-
break;
|
|
411
|
-
case "pattern:zod":
|
|
412
|
-
addPattern(res, zodPatterns.email, check.message, refs);
|
|
413
|
-
break;
|
|
414
|
-
}
|
|
415
|
-
break;
|
|
416
|
-
case "url":
|
|
417
|
-
addFormat(res, "uri", check.message, refs);
|
|
418
|
-
break;
|
|
419
|
-
case "uuid":
|
|
420
|
-
addFormat(res, "uuid", check.message, refs);
|
|
421
|
-
break;
|
|
422
|
-
case "regex":
|
|
423
|
-
addPattern(res, check.regex, check.message, refs);
|
|
424
|
-
break;
|
|
425
|
-
case "cuid":
|
|
426
|
-
addPattern(res, zodPatterns.cuid, check.message, refs);
|
|
427
|
-
break;
|
|
428
|
-
case "cuid2":
|
|
429
|
-
addPattern(res, zodPatterns.cuid2, check.message, refs);
|
|
430
|
-
break;
|
|
431
|
-
case "startsWith":
|
|
432
|
-
addPattern(res, RegExp(`^${escapeLiteralCheckValue(check.value, refs)}`), check.message, refs);
|
|
433
|
-
break;
|
|
434
|
-
case "endsWith":
|
|
435
|
-
addPattern(res, RegExp(`${escapeLiteralCheckValue(check.value, refs)}$`), check.message, refs);
|
|
436
|
-
break;
|
|
437
|
-
case "datetime":
|
|
438
|
-
addFormat(res, "date-time", check.message, refs);
|
|
439
|
-
break;
|
|
440
|
-
case "date":
|
|
441
|
-
addFormat(res, "date", check.message, refs);
|
|
442
|
-
break;
|
|
443
|
-
case "time":
|
|
444
|
-
addFormat(res, "time", check.message, refs);
|
|
445
|
-
break;
|
|
446
|
-
case "duration":
|
|
447
|
-
addFormat(res, "duration", check.message, refs);
|
|
448
|
-
break;
|
|
449
|
-
case "length":
|
|
450
|
-
setResponseValueAndErrors(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
|
|
451
|
-
setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
|
|
452
|
-
break;
|
|
453
|
-
case "includes": {
|
|
454
|
-
addPattern(res, RegExp(escapeLiteralCheckValue(check.value, refs)), check.message, refs);
|
|
455
|
-
break;
|
|
456
|
-
}
|
|
457
|
-
case "ip": {
|
|
458
|
-
if (check.version !== "v6") {
|
|
459
|
-
addFormat(res, "ipv4", check.message, refs);
|
|
460
|
-
}
|
|
461
|
-
if (check.version !== "v4") {
|
|
462
|
-
addFormat(res, "ipv6", check.message, refs);
|
|
463
|
-
}
|
|
464
|
-
break;
|
|
465
|
-
}
|
|
466
|
-
case "base64url":
|
|
467
|
-
addPattern(res, zodPatterns.base64url, check.message, refs);
|
|
468
|
-
break;
|
|
469
|
-
case "jwt":
|
|
470
|
-
addPattern(res, zodPatterns.jwt, check.message, refs);
|
|
471
|
-
break;
|
|
472
|
-
case "cidr": {
|
|
473
|
-
if (check.version !== "v6") {
|
|
474
|
-
addPattern(res, zodPatterns.ipv4Cidr, check.message, refs);
|
|
475
|
-
}
|
|
476
|
-
if (check.version !== "v4") {
|
|
477
|
-
addPattern(res, zodPatterns.ipv6Cidr, check.message, refs);
|
|
478
|
-
}
|
|
479
|
-
break;
|
|
480
|
-
}
|
|
481
|
-
case "emoji":
|
|
482
|
-
addPattern(res, zodPatterns.emoji(), check.message, refs);
|
|
483
|
-
break;
|
|
484
|
-
case "ulid": {
|
|
485
|
-
addPattern(res, zodPatterns.ulid, check.message, refs);
|
|
486
|
-
break;
|
|
487
|
-
}
|
|
488
|
-
case "base64": {
|
|
489
|
-
switch (refs.base64Strategy) {
|
|
490
|
-
case "format:binary": {
|
|
491
|
-
addFormat(res, "binary", check.message, refs);
|
|
492
|
-
break;
|
|
354
|
+
const chart = new import_quickchart_js.default();
|
|
355
|
+
chart.setWidth(600);
|
|
356
|
+
chart.setHeight(300);
|
|
357
|
+
const labels = priceHistory.map((point) => new Date(point.timestamp).toLocaleTimeString());
|
|
358
|
+
const bidData = priceHistory.map((point) => point.bid);
|
|
359
|
+
const offerData = priceHistory.map((point) => point.offer);
|
|
360
|
+
const spreadData = priceHistory.map((point) => point.spread);
|
|
361
|
+
const volumeData = priceHistory.map((point) => point.volume);
|
|
362
|
+
const config = {
|
|
363
|
+
type: "line",
|
|
364
|
+
data: {
|
|
365
|
+
labels,
|
|
366
|
+
datasets: [
|
|
367
|
+
{
|
|
368
|
+
label: "Bid",
|
|
369
|
+
data: bidData,
|
|
370
|
+
borderColor: "#28a745",
|
|
371
|
+
backgroundColor: "rgba(40, 167, 69, 0.1)",
|
|
372
|
+
fill: false,
|
|
373
|
+
tension: 0.4
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
label: "Offer",
|
|
377
|
+
data: offerData,
|
|
378
|
+
borderColor: "#dc3545",
|
|
379
|
+
backgroundColor: "rgba(220, 53, 69, 0.1)",
|
|
380
|
+
fill: false,
|
|
381
|
+
tension: 0.4
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
label: "Spread",
|
|
385
|
+
data: spreadData,
|
|
386
|
+
borderColor: "#6c757d",
|
|
387
|
+
backgroundColor: "rgba(108, 117, 125, 0.1)",
|
|
388
|
+
fill: false,
|
|
389
|
+
tension: 0.4
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
label: "Volume",
|
|
393
|
+
data: volumeData,
|
|
394
|
+
borderColor: "#007bff",
|
|
395
|
+
backgroundColor: "rgba(0, 123, 255, 0.1)",
|
|
396
|
+
fill: true,
|
|
397
|
+
tension: 0.4
|
|
493
398
|
}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
399
|
+
]
|
|
400
|
+
},
|
|
401
|
+
options: {
|
|
402
|
+
responsive: true,
|
|
403
|
+
plugins: {
|
|
404
|
+
title: {
|
|
405
|
+
display: true,
|
|
406
|
+
text: `${symbol} Market Data`
|
|
497
407
|
}
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
408
|
+
},
|
|
409
|
+
scales: {
|
|
410
|
+
y: {
|
|
411
|
+
beginAtZero: false
|
|
501
412
|
}
|
|
502
413
|
}
|
|
503
|
-
break;
|
|
504
|
-
}
|
|
505
|
-
case "nanoid": {
|
|
506
|
-
addPattern(res, zodPatterns.nanoid, check.message, refs);
|
|
507
414
|
}
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
var ALPHA_NUMERIC = new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
|
|
524
|
-
function escapeNonAlphaNumeric(source) {
|
|
525
|
-
let result = "";
|
|
526
|
-
for (let i = 0; i < source.length; i++) {
|
|
527
|
-
if (!ALPHA_NUMERIC.has(source[i])) {
|
|
528
|
-
result += "\\";
|
|
529
|
-
}
|
|
530
|
-
result += source[i];
|
|
531
|
-
}
|
|
532
|
-
return result;
|
|
533
|
-
}
|
|
534
|
-
function addFormat(schema, value, message, refs) {
|
|
535
|
-
if (schema.format || schema.anyOf?.some((x) => x.format)) {
|
|
536
|
-
if (!schema.anyOf) {
|
|
537
|
-
schema.anyOf = [];
|
|
538
|
-
}
|
|
539
|
-
if (schema.format) {
|
|
540
|
-
schema.anyOf.push({
|
|
541
|
-
format: schema.format,
|
|
542
|
-
...schema.errorMessage && refs.errorMessages && {
|
|
543
|
-
errorMessage: { format: schema.errorMessage.format }
|
|
544
|
-
}
|
|
545
|
-
});
|
|
546
|
-
delete schema.format;
|
|
547
|
-
if (schema.errorMessage) {
|
|
548
|
-
delete schema.errorMessage.format;
|
|
549
|
-
if (Object.keys(schema.errorMessage).length === 0) {
|
|
550
|
-
delete schema.errorMessage;
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
schema.anyOf.push({
|
|
555
|
-
format: value,
|
|
556
|
-
...message && refs.errorMessages && { errorMessage: { format: message } }
|
|
557
|
-
});
|
|
558
|
-
} else {
|
|
559
|
-
setResponseValueAndErrors(schema, "format", value, message, refs);
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
function addPattern(schema, regex, message, refs) {
|
|
563
|
-
if (schema.pattern || schema.allOf?.some((x) => x.pattern)) {
|
|
564
|
-
if (!schema.allOf) {
|
|
565
|
-
schema.allOf = [];
|
|
566
|
-
}
|
|
567
|
-
if (schema.pattern) {
|
|
568
|
-
schema.allOf.push({
|
|
569
|
-
pattern: schema.pattern,
|
|
570
|
-
...schema.errorMessage && refs.errorMessages && {
|
|
571
|
-
errorMessage: { pattern: schema.errorMessage.pattern }
|
|
572
|
-
}
|
|
573
|
-
});
|
|
574
|
-
delete schema.pattern;
|
|
575
|
-
if (schema.errorMessage) {
|
|
576
|
-
delete schema.errorMessage.pattern;
|
|
577
|
-
if (Object.keys(schema.errorMessage).length === 0) {
|
|
578
|
-
delete schema.errorMessage;
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
schema.allOf.push({
|
|
583
|
-
pattern: stringifyRegExpWithFlags(regex, refs),
|
|
584
|
-
...message && refs.errorMessages && { errorMessage: { pattern: message } }
|
|
585
|
-
});
|
|
586
|
-
} else {
|
|
587
|
-
setResponseValueAndErrors(schema, "pattern", stringifyRegExpWithFlags(regex, refs), message, refs);
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
function stringifyRegExpWithFlags(regex, refs) {
|
|
591
|
-
if (!refs.applyRegexFlags || !regex.flags) {
|
|
592
|
-
return regex.source;
|
|
593
|
-
}
|
|
594
|
-
const flags = {
|
|
595
|
-
i: regex.flags.includes("i"),
|
|
596
|
-
m: regex.flags.includes("m"),
|
|
597
|
-
s: regex.flags.includes("s")
|
|
598
|
-
// `.` matches newlines
|
|
599
|
-
};
|
|
600
|
-
const source = flags.i ? regex.source.toLowerCase() : regex.source;
|
|
601
|
-
let pattern = "";
|
|
602
|
-
let isEscaped = false;
|
|
603
|
-
let inCharGroup = false;
|
|
604
|
-
let inCharRange = false;
|
|
605
|
-
for (let i = 0; i < source.length; i++) {
|
|
606
|
-
if (isEscaped) {
|
|
607
|
-
pattern += source[i];
|
|
608
|
-
isEscaped = false;
|
|
609
|
-
continue;
|
|
610
|
-
}
|
|
611
|
-
if (flags.i) {
|
|
612
|
-
if (inCharGroup) {
|
|
613
|
-
if (source[i].match(/[a-z]/)) {
|
|
614
|
-
if (inCharRange) {
|
|
615
|
-
pattern += source[i];
|
|
616
|
-
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
617
|
-
inCharRange = false;
|
|
618
|
-
} else if (source[i + 1] === "-" && source[i + 2]?.match(/[a-z]/)) {
|
|
619
|
-
pattern += source[i];
|
|
620
|
-
inCharRange = true;
|
|
621
|
-
} else {
|
|
622
|
-
pattern += `${source[i]}${source[i].toUpperCase()}`;
|
|
415
|
+
};
|
|
416
|
+
chart.setConfig(config);
|
|
417
|
+
const imageBuffer = await chart.toBinary();
|
|
418
|
+
const base64Image = imageBuffer.toString("base64");
|
|
419
|
+
return {
|
|
420
|
+
content: [
|
|
421
|
+
{
|
|
422
|
+
type: "image",
|
|
423
|
+
image: {
|
|
424
|
+
source: {
|
|
425
|
+
data: base64Image
|
|
426
|
+
}
|
|
427
|
+
},
|
|
428
|
+
uri: "getStockGraph",
|
|
429
|
+
mimeType: "image/png"
|
|
623
430
|
}
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
]
|
|
635
|
-
|
|
636
|
-
}
|
|
637
|
-
pattern += `($|(?=[\r
|
|
638
|
-
]))`;
|
|
639
|
-
continue;
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
if (flags.s && source[i] === ".") {
|
|
643
|
-
pattern += inCharGroup ? `${source[i]}\r
|
|
644
|
-
` : `[${source[i]}\r
|
|
645
|
-
]`;
|
|
646
|
-
continue;
|
|
647
|
-
}
|
|
648
|
-
pattern += source[i];
|
|
649
|
-
if (source[i] === "\\") {
|
|
650
|
-
isEscaped = true;
|
|
651
|
-
} else if (inCharGroup && source[i] === "]") {
|
|
652
|
-
inCharGroup = false;
|
|
653
|
-
} else if (!inCharGroup && source[i] === "[") {
|
|
654
|
-
inCharGroup = true;
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
try {
|
|
658
|
-
new RegExp(pattern);
|
|
659
|
-
} catch {
|
|
660
|
-
console.warn(`Could not convert regex pattern at ${refs.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`);
|
|
661
|
-
return regex.source;
|
|
662
|
-
}
|
|
663
|
-
return pattern;
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/record.js
|
|
667
|
-
function parseRecordDef(def, refs) {
|
|
668
|
-
if (refs.target === "openAi") {
|
|
669
|
-
console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");
|
|
670
|
-
}
|
|
671
|
-
if (refs.target === "openApi3" && def.keyType?._def.typeName === import_zod2.ZodFirstPartyTypeKind.ZodEnum) {
|
|
672
|
-
return {
|
|
673
|
-
type: "object",
|
|
674
|
-
required: def.keyType._def.values,
|
|
675
|
-
properties: def.keyType._def.values.reduce((acc, key) => ({
|
|
676
|
-
...acc,
|
|
677
|
-
[key]: parseDef(def.valueType._def, {
|
|
678
|
-
...refs,
|
|
679
|
-
currentPath: [...refs.currentPath, "properties", key]
|
|
680
|
-
}) ?? {}
|
|
681
|
-
}), {}),
|
|
682
|
-
additionalProperties: refs.rejectedAdditionalProperties
|
|
683
|
-
};
|
|
684
|
-
}
|
|
685
|
-
const schema = {
|
|
686
|
-
type: "object",
|
|
687
|
-
additionalProperties: parseDef(def.valueType._def, {
|
|
688
|
-
...refs,
|
|
689
|
-
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
690
|
-
}) ?? refs.allowedAdditionalProperties
|
|
691
|
-
};
|
|
692
|
-
if (refs.target === "openApi3") {
|
|
693
|
-
return schema;
|
|
694
|
-
}
|
|
695
|
-
if (def.keyType?._def.typeName === import_zod2.ZodFirstPartyTypeKind.ZodString && def.keyType._def.checks?.length) {
|
|
696
|
-
const { type, ...keyType } = parseStringDef(def.keyType._def, refs);
|
|
697
|
-
return {
|
|
698
|
-
...schema,
|
|
699
|
-
propertyNames: keyType
|
|
700
|
-
};
|
|
701
|
-
} else if (def.keyType?._def.typeName === import_zod2.ZodFirstPartyTypeKind.ZodEnum) {
|
|
702
|
-
return {
|
|
703
|
-
...schema,
|
|
704
|
-
propertyNames: {
|
|
705
|
-
enum: def.keyType._def.values
|
|
706
|
-
}
|
|
707
|
-
};
|
|
708
|
-
} else if (def.keyType?._def.typeName === import_zod2.ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === import_zod2.ZodFirstPartyTypeKind.ZodString && def.keyType._def.type._def.checks?.length) {
|
|
709
|
-
const { type, ...keyType } = parseBrandedDef(def.keyType._def, refs);
|
|
710
|
-
return {
|
|
711
|
-
...schema,
|
|
712
|
-
propertyNames: keyType
|
|
713
|
-
};
|
|
714
|
-
}
|
|
715
|
-
return schema;
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/map.js
|
|
719
|
-
function parseMapDef(def, refs) {
|
|
720
|
-
if (refs.mapStrategy === "record") {
|
|
721
|
-
return parseRecordDef(def, refs);
|
|
722
|
-
}
|
|
723
|
-
const keys = parseDef(def.keyType._def, {
|
|
724
|
-
...refs,
|
|
725
|
-
currentPath: [...refs.currentPath, "items", "items", "0"]
|
|
726
|
-
}) || {};
|
|
727
|
-
const values = parseDef(def.valueType._def, {
|
|
728
|
-
...refs,
|
|
729
|
-
currentPath: [...refs.currentPath, "items", "items", "1"]
|
|
730
|
-
}) || {};
|
|
731
|
-
return {
|
|
732
|
-
type: "array",
|
|
733
|
-
maxItems: 125,
|
|
734
|
-
items: {
|
|
735
|
-
type: "array",
|
|
736
|
-
items: [keys, values],
|
|
737
|
-
minItems: 2,
|
|
738
|
-
maxItems: 2
|
|
431
|
+
]
|
|
432
|
+
};
|
|
433
|
+
} catch (error) {
|
|
434
|
+
return {
|
|
435
|
+
content: [
|
|
436
|
+
{
|
|
437
|
+
type: "text",
|
|
438
|
+
text: `Error: ${error instanceof Error ? error.message : "Failed to generate chart"}`,
|
|
439
|
+
uri: "getStockGraph"
|
|
440
|
+
}
|
|
441
|
+
],
|
|
442
|
+
isError: true
|
|
443
|
+
};
|
|
739
444
|
}
|
|
740
445
|
};
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js
|
|
744
|
-
function parseNativeEnumDef(def) {
|
|
745
|
-
const object = def.values;
|
|
746
|
-
const actualKeys = Object.keys(def.values).filter((key) => {
|
|
747
|
-
return typeof object[object[key]] !== "number";
|
|
748
|
-
});
|
|
749
|
-
const actualValues = actualKeys.map((key) => object[key]);
|
|
750
|
-
const parsedTypes = Array.from(new Set(actualValues.map((values) => typeof values)));
|
|
751
|
-
return {
|
|
752
|
-
type: parsedTypes.length === 1 ? parsedTypes[0] === "string" ? "string" : "number" : ["string", "number"],
|
|
753
|
-
enum: actualValues
|
|
754
|
-
};
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/never.js
|
|
758
|
-
function parseNeverDef() {
|
|
759
|
-
return {
|
|
760
|
-
not: {}
|
|
761
|
-
};
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/null.js
|
|
765
|
-
function parseNullDef(refs) {
|
|
766
|
-
return refs.target === "openApi3" ? {
|
|
767
|
-
enum: ["null"],
|
|
768
|
-
nullable: true
|
|
769
|
-
} : {
|
|
770
|
-
type: "null"
|
|
771
|
-
};
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/union.js
|
|
775
|
-
var primitiveMappings = {
|
|
776
|
-
ZodString: "string",
|
|
777
|
-
ZodNumber: "number",
|
|
778
|
-
ZodBigInt: "integer",
|
|
779
|
-
ZodBoolean: "boolean",
|
|
780
|
-
ZodNull: "null"
|
|
781
446
|
};
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
switch (type) {
|
|
798
|
-
case "string":
|
|
799
|
-
case "number":
|
|
800
|
-
case "boolean":
|
|
801
|
-
return [...acc, type];
|
|
802
|
-
case "bigint":
|
|
803
|
-
return [...acc, "integer"];
|
|
804
|
-
case "object":
|
|
805
|
-
if (x._def.value === null)
|
|
806
|
-
return [...acc, "null"];
|
|
807
|
-
case "symbol":
|
|
808
|
-
case "undefined":
|
|
809
|
-
case "function":
|
|
810
|
-
default:
|
|
811
|
-
return acc;
|
|
447
|
+
var createGetStockPriceHistoryHandler = (marketDataPrices) => {
|
|
448
|
+
return async (args) => {
|
|
449
|
+
try {
|
|
450
|
+
const symbol = args.symbol;
|
|
451
|
+
const priceHistory = marketDataPrices.get(symbol) || [];
|
|
452
|
+
if (priceHistory.length === 0) {
|
|
453
|
+
return {
|
|
454
|
+
content: [
|
|
455
|
+
{
|
|
456
|
+
type: "text",
|
|
457
|
+
text: `No price data available for ${symbol}`,
|
|
458
|
+
uri: "getStockPriceHistory"
|
|
459
|
+
}
|
|
460
|
+
]
|
|
461
|
+
};
|
|
812
462
|
}
|
|
813
|
-
}, []);
|
|
814
|
-
if (types.length === options.length) {
|
|
815
|
-
const uniqueTypes = types.filter((x, i, a) => a.indexOf(x) === i);
|
|
816
463
|
return {
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
464
|
+
content: [
|
|
465
|
+
{
|
|
466
|
+
type: "text",
|
|
467
|
+
text: JSON.stringify(
|
|
468
|
+
{
|
|
469
|
+
symbol,
|
|
470
|
+
count: priceHistory.length,
|
|
471
|
+
data: priceHistory.map((point) => ({
|
|
472
|
+
timestamp: new Date(point.timestamp).toISOString(),
|
|
473
|
+
bid: point.bid,
|
|
474
|
+
offer: point.offer,
|
|
475
|
+
spread: point.spread,
|
|
476
|
+
volume: point.volume
|
|
477
|
+
}))
|
|
478
|
+
},
|
|
479
|
+
null,
|
|
480
|
+
2
|
|
481
|
+
),
|
|
482
|
+
uri: "getStockPriceHistory"
|
|
483
|
+
}
|
|
484
|
+
]
|
|
821
485
|
};
|
|
822
|
-
}
|
|
823
|
-
} else if (options.every((x) => x._def.typeName === "ZodEnum")) {
|
|
824
|
-
return {
|
|
825
|
-
type: "string",
|
|
826
|
-
enum: options.reduce((acc, x) => [
|
|
827
|
-
...acc,
|
|
828
|
-
...x._def.values.filter((x2) => !acc.includes(x2))
|
|
829
|
-
], [])
|
|
830
|
-
};
|
|
831
|
-
}
|
|
832
|
-
return asAnyOf(def, refs);
|
|
833
|
-
}
|
|
834
|
-
var asAnyOf = (def, refs) => {
|
|
835
|
-
const anyOf = (def.options instanceof Map ? Array.from(def.options.values()) : def.options).map((x, i) => parseDef(x._def, {
|
|
836
|
-
...refs,
|
|
837
|
-
currentPath: [...refs.currentPath, "anyOf", `${i}`]
|
|
838
|
-
})).filter((x) => !!x && (!refs.strictUnions || typeof x === "object" && Object.keys(x).length > 0));
|
|
839
|
-
return anyOf.length ? { anyOf } : void 0;
|
|
840
|
-
};
|
|
841
|
-
|
|
842
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js
|
|
843
|
-
function parseNullableDef(def, refs) {
|
|
844
|
-
if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(def.innerType._def.typeName) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
|
|
845
|
-
if (refs.target === "openApi3") {
|
|
486
|
+
} catch (error) {
|
|
846
487
|
return {
|
|
847
|
-
|
|
848
|
-
|
|
488
|
+
content: [
|
|
489
|
+
{
|
|
490
|
+
type: "text",
|
|
491
|
+
text: `Error: ${error instanceof Error ? error.message : "Failed to get stock price history"}`,
|
|
492
|
+
uri: "getStockPriceHistory"
|
|
493
|
+
}
|
|
494
|
+
],
|
|
495
|
+
isError: true
|
|
849
496
|
};
|
|
850
497
|
}
|
|
851
|
-
return {
|
|
852
|
-
type: [
|
|
853
|
-
primitiveMappings[def.innerType._def.typeName],
|
|
854
|
-
"null"
|
|
855
|
-
]
|
|
856
|
-
};
|
|
857
|
-
}
|
|
858
|
-
if (refs.target === "openApi3") {
|
|
859
|
-
const base2 = parseDef(def.innerType._def, {
|
|
860
|
-
...refs,
|
|
861
|
-
currentPath: [...refs.currentPath]
|
|
862
|
-
});
|
|
863
|
-
if (base2 && "$ref" in base2)
|
|
864
|
-
return { allOf: [base2], nullable: true };
|
|
865
|
-
return base2 && { ...base2, nullable: true };
|
|
866
|
-
}
|
|
867
|
-
const base = parseDef(def.innerType._def, {
|
|
868
|
-
...refs,
|
|
869
|
-
currentPath: [...refs.currentPath, "anyOf", "0"]
|
|
870
|
-
});
|
|
871
|
-
return base && { anyOf: [base, { type: "null" }] };
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/number.js
|
|
875
|
-
function parseNumberDef(def, refs) {
|
|
876
|
-
const res = {
|
|
877
|
-
type: "number"
|
|
878
498
|
};
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
// src/tools/order.ts
|
|
502
|
+
var import_fixparser2 = require("fixparser");
|
|
503
|
+
var ordTypeNames = {
|
|
504
|
+
"1": "Market",
|
|
505
|
+
"2": "Limit",
|
|
506
|
+
"3": "Stop",
|
|
507
|
+
"4": "StopLimit",
|
|
508
|
+
"5": "MarketOnClose",
|
|
509
|
+
"6": "WithOrWithout",
|
|
510
|
+
"7": "LimitOrBetter",
|
|
511
|
+
"8": "LimitWithOrWithout",
|
|
512
|
+
"9": "OnBasis",
|
|
513
|
+
A: "OnClose",
|
|
514
|
+
B: "LimitOnClose",
|
|
515
|
+
C: "ForexMarket",
|
|
516
|
+
D: "PreviouslyQuoted",
|
|
517
|
+
E: "PreviouslyIndicated",
|
|
518
|
+
F: "ForexLimit",
|
|
519
|
+
G: "ForexSwap",
|
|
520
|
+
H: "ForexPreviouslyQuoted",
|
|
521
|
+
I: "Funari",
|
|
522
|
+
J: "MarketIfTouched",
|
|
523
|
+
K: "MarketWithLeftOverAsLimit",
|
|
524
|
+
L: "PreviousFundValuationPoint",
|
|
525
|
+
M: "NextFundValuationPoint",
|
|
526
|
+
P: "Pegged",
|
|
527
|
+
Q: "CounterOrderSelection",
|
|
528
|
+
R: "StopOnBidOrOffer",
|
|
529
|
+
S: "StopLimitOnBidOrOffer"
|
|
530
|
+
};
|
|
531
|
+
var sideNames = {
|
|
532
|
+
"1": "Buy",
|
|
533
|
+
"2": "Sell",
|
|
534
|
+
"3": "BuyMinus",
|
|
535
|
+
"4": "SellPlus",
|
|
536
|
+
"5": "SellShort",
|
|
537
|
+
"6": "SellShortExempt",
|
|
538
|
+
"7": "Undisclosed",
|
|
539
|
+
"8": "Cross",
|
|
540
|
+
"9": "CrossShort",
|
|
541
|
+
A: "CrossShortExempt",
|
|
542
|
+
B: "AsDefined",
|
|
543
|
+
C: "Opposite",
|
|
544
|
+
D: "Subscribe",
|
|
545
|
+
E: "Redeem",
|
|
546
|
+
F: "Lend",
|
|
547
|
+
G: "Borrow",
|
|
548
|
+
H: "SellUndisclosed"
|
|
549
|
+
};
|
|
550
|
+
var timeInForceNames = {
|
|
551
|
+
"0": "Day",
|
|
552
|
+
"1": "GoodTillCancel",
|
|
553
|
+
"2": "AtTheOpening",
|
|
554
|
+
"3": "ImmediateOrCancel",
|
|
555
|
+
"4": "FillOrKill",
|
|
556
|
+
"5": "GoodTillCrossing",
|
|
557
|
+
"6": "GoodTillDate",
|
|
558
|
+
"7": "AtTheClose",
|
|
559
|
+
"8": "GoodThroughCrossing",
|
|
560
|
+
"9": "AtCrossing",
|
|
561
|
+
A: "GoodForTime",
|
|
562
|
+
B: "GoodForAuction",
|
|
563
|
+
C: "GoodForMonth"
|
|
564
|
+
};
|
|
565
|
+
var handlInstNames = {
|
|
566
|
+
"1": "AutomatedExecutionNoIntervention",
|
|
567
|
+
"2": "AutomatedExecutionInterventionOK",
|
|
568
|
+
"3": "ManualOrder"
|
|
569
|
+
};
|
|
570
|
+
var createVerifyOrderHandler = (parser, verifiedOrders) => {
|
|
571
|
+
return async (args) => {
|
|
572
|
+
try {
|
|
573
|
+
verifiedOrders.set(args.clOrdID, {
|
|
574
|
+
clOrdID: args.clOrdID,
|
|
575
|
+
handlInst: args.handlInst,
|
|
576
|
+
quantity: Number.parseFloat(String(args.quantity)),
|
|
577
|
+
price: Number.parseFloat(String(args.price)),
|
|
578
|
+
ordType: args.ordType,
|
|
579
|
+
side: args.side,
|
|
580
|
+
symbol: args.symbol,
|
|
581
|
+
timeInForce: args.timeInForce
|
|
582
|
+
});
|
|
583
|
+
return {
|
|
584
|
+
content: [
|
|
585
|
+
{
|
|
586
|
+
type: "text",
|
|
587
|
+
text: `VERIFICATION: All parameters valid. Ready to proceed with order execution.
|
|
588
|
+
|
|
589
|
+
Parameters verified:
|
|
590
|
+
- ClOrdID: ${args.clOrdID}
|
|
591
|
+
- HandlInst: ${args.handlInst} (${handlInstNames[args.handlInst]})
|
|
592
|
+
- Quantity: ${args.quantity}
|
|
593
|
+
- Price: ${args.price}
|
|
594
|
+
- OrdType: ${args.ordType} (${ordTypeNames[args.ordType]})
|
|
595
|
+
- Side: ${args.side} (${sideNames[args.side]})
|
|
596
|
+
- Symbol: ${args.symbol}
|
|
597
|
+
- TimeInForce: ${args.timeInForce} (${timeInForceNames[args.timeInForce]})
|
|
598
|
+
|
|
599
|
+
To execute this order, call the executeOrder tool with these exact same parameters.`,
|
|
600
|
+
uri: "verifyOrder"
|
|
907
601
|
}
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
602
|
+
]
|
|
603
|
+
};
|
|
604
|
+
} catch (error) {
|
|
605
|
+
return {
|
|
606
|
+
content: [
|
|
607
|
+
{
|
|
608
|
+
type: "text",
|
|
609
|
+
text: `Error: ${error instanceof Error ? error.message : "Failed to verify order parameters"}`,
|
|
610
|
+
uri: "verifyOrder"
|
|
911
611
|
}
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
case "multipleOf":
|
|
916
|
-
setResponseValueAndErrors(res, "multipleOf", check.value, check.message, refs);
|
|
917
|
-
break;
|
|
612
|
+
],
|
|
613
|
+
isError: true
|
|
614
|
+
};
|
|
918
615
|
}
|
|
919
|
-
}
|
|
920
|
-
return res;
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/object.js
|
|
924
|
-
var import_zod3 = require("zod");
|
|
925
|
-
function parseObjectDef(def, refs) {
|
|
926
|
-
const forceOptionalIntoNullable = refs.target === "openAi";
|
|
927
|
-
const result = {
|
|
928
|
-
type: "object",
|
|
929
|
-
properties: {}
|
|
930
616
|
};
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
617
|
+
};
|
|
618
|
+
var createExecuteOrderHandler = (parser, verifiedOrders, pendingRequests) => {
|
|
619
|
+
return async (args) => {
|
|
620
|
+
try {
|
|
621
|
+
const verifiedOrder = verifiedOrders.get(args.clOrdID);
|
|
622
|
+
if (!verifiedOrder) {
|
|
623
|
+
return {
|
|
624
|
+
content: [
|
|
625
|
+
{
|
|
626
|
+
type: "text",
|
|
627
|
+
text: `Error: Order ${args.clOrdID} has not been verified. Please call verifyOrder first.`,
|
|
628
|
+
uri: "executeOrder"
|
|
629
|
+
}
|
|
630
|
+
],
|
|
631
|
+
isError: true
|
|
632
|
+
};
|
|
942
633
|
}
|
|
943
|
-
if (
|
|
944
|
-
|
|
634
|
+
if (verifiedOrder.handlInst !== args.handlInst || verifiedOrder.quantity !== Number.parseFloat(String(args.quantity)) || verifiedOrder.price !== Number.parseFloat(String(args.price)) || verifiedOrder.ordType !== args.ordType || verifiedOrder.side !== args.side || verifiedOrder.symbol !== args.symbol || verifiedOrder.timeInForce !== args.timeInForce) {
|
|
635
|
+
return {
|
|
636
|
+
content: [
|
|
637
|
+
{
|
|
638
|
+
type: "text",
|
|
639
|
+
text: "Error: Order parameters do not match the verified order. Please use the exact same parameters that were verified.",
|
|
640
|
+
uri: "executeOrder"
|
|
641
|
+
}
|
|
642
|
+
],
|
|
643
|
+
isError: true
|
|
644
|
+
};
|
|
945
645
|
}
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
646
|
+
const response = new Promise((resolve) => {
|
|
647
|
+
pendingRequests.set(args.clOrdID, resolve);
|
|
648
|
+
});
|
|
649
|
+
const order = parser.createMessage(
|
|
650
|
+
new import_fixparser2.Field(import_fixparser2.Fields.MsgType, import_fixparser2.Messages.NewOrderSingle),
|
|
651
|
+
new import_fixparser2.Field(import_fixparser2.Fields.MsgSeqNum, parser.getNextTargetMsgSeqNum()),
|
|
652
|
+
new import_fixparser2.Field(import_fixparser2.Fields.SenderCompID, parser.sender),
|
|
653
|
+
new import_fixparser2.Field(import_fixparser2.Fields.TargetCompID, parser.target),
|
|
654
|
+
new import_fixparser2.Field(import_fixparser2.Fields.SendingTime, parser.getTimestamp()),
|
|
655
|
+
new import_fixparser2.Field(import_fixparser2.Fields.ClOrdID, args.clOrdID),
|
|
656
|
+
new import_fixparser2.Field(import_fixparser2.Fields.Side, args.side),
|
|
657
|
+
new import_fixparser2.Field(import_fixparser2.Fields.Symbol, args.symbol),
|
|
658
|
+
new import_fixparser2.Field(import_fixparser2.Fields.OrderQty, Number.parseFloat(String(args.quantity))),
|
|
659
|
+
new import_fixparser2.Field(import_fixparser2.Fields.Price, Number.parseFloat(String(args.price))),
|
|
660
|
+
new import_fixparser2.Field(import_fixparser2.Fields.OrdType, args.ordType),
|
|
661
|
+
new import_fixparser2.Field(import_fixparser2.Fields.HandlInst, args.handlInst),
|
|
662
|
+
new import_fixparser2.Field(import_fixparser2.Fields.TimeInForce, args.timeInForce),
|
|
663
|
+
new import_fixparser2.Field(import_fixparser2.Fields.TransactTime, parser.getTimestamp())
|
|
664
|
+
);
|
|
665
|
+
if (!parser.connected) {
|
|
666
|
+
return {
|
|
667
|
+
content: [
|
|
668
|
+
{
|
|
669
|
+
type: "text",
|
|
670
|
+
text: "Error: Not connected. Ignoring message.",
|
|
671
|
+
uri: "executeOrder"
|
|
672
|
+
}
|
|
673
|
+
],
|
|
674
|
+
isError: true
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
parser.send(order);
|
|
678
|
+
const fixData = await response;
|
|
679
|
+
verifiedOrders.delete(args.clOrdID);
|
|
680
|
+
return {
|
|
681
|
+
content: [
|
|
682
|
+
{
|
|
683
|
+
type: "text",
|
|
684
|
+
text: fixData.messageType === import_fixparser2.Messages.Reject ? `Reject message for order ${args.clOrdID}: ${JSON.stringify(fixData.toFIXJSON())}` : `Execution Report for order ${args.clOrdID}: ${JSON.stringify(fixData.toFIXJSON())}`,
|
|
685
|
+
uri: "executeOrder"
|
|
686
|
+
}
|
|
687
|
+
]
|
|
688
|
+
};
|
|
689
|
+
} catch (error) {
|
|
690
|
+
return {
|
|
691
|
+
content: [
|
|
692
|
+
{
|
|
693
|
+
type: "text",
|
|
694
|
+
text: `Error: ${error instanceof Error ? error.message : "Failed to execute order"}`,
|
|
695
|
+
uri: "executeOrder"
|
|
696
|
+
}
|
|
697
|
+
],
|
|
698
|
+
isError: true
|
|
699
|
+
};
|
|
959
700
|
}
|
|
960
|
-
}
|
|
961
|
-
if (required.length) {
|
|
962
|
-
result.required = required;
|
|
963
|
-
}
|
|
964
|
-
const additionalProperties = decideAdditionalProperties(def, refs);
|
|
965
|
-
if (additionalProperties !== void 0) {
|
|
966
|
-
result.additionalProperties = additionalProperties;
|
|
967
|
-
}
|
|
968
|
-
return result;
|
|
969
|
-
}
|
|
970
|
-
function decideAdditionalProperties(def, refs) {
|
|
971
|
-
if (def.catchall._def.typeName !== "ZodNever") {
|
|
972
|
-
return parseDef(def.catchall._def, {
|
|
973
|
-
...refs,
|
|
974
|
-
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
975
|
-
});
|
|
976
|
-
}
|
|
977
|
-
switch (def.unknownKeys) {
|
|
978
|
-
case "passthrough":
|
|
979
|
-
return refs.allowedAdditionalProperties;
|
|
980
|
-
case "strict":
|
|
981
|
-
return refs.rejectedAdditionalProperties;
|
|
982
|
-
case "strip":
|
|
983
|
-
return refs.removeAdditionalStrategy === "strict" ? refs.allowedAdditionalProperties : refs.rejectedAdditionalProperties;
|
|
984
|
-
}
|
|
985
|
-
}
|
|
986
|
-
function safeIsOptional(schema) {
|
|
987
|
-
try {
|
|
988
|
-
return schema.isOptional();
|
|
989
|
-
} catch {
|
|
990
|
-
return true;
|
|
991
|
-
}
|
|
992
|
-
}
|
|
993
|
-
|
|
994
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/optional.js
|
|
995
|
-
var parseOptionalDef = (def, refs) => {
|
|
996
|
-
if (refs.currentPath.toString() === refs.propertyPath?.toString()) {
|
|
997
|
-
return parseDef(def.innerType._def, refs);
|
|
998
|
-
}
|
|
999
|
-
const innerSchema = parseDef(def.innerType._def, {
|
|
1000
|
-
...refs,
|
|
1001
|
-
currentPath: [...refs.currentPath, "anyOf", "1"]
|
|
1002
|
-
});
|
|
1003
|
-
return innerSchema ? {
|
|
1004
|
-
anyOf: [
|
|
1005
|
-
{
|
|
1006
|
-
not: {}
|
|
1007
|
-
},
|
|
1008
|
-
innerSchema
|
|
1009
|
-
]
|
|
1010
|
-
} : {};
|
|
1011
|
-
};
|
|
1012
|
-
|
|
1013
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js
|
|
1014
|
-
var parsePipelineDef = (def, refs) => {
|
|
1015
|
-
if (refs.pipeStrategy === "input") {
|
|
1016
|
-
return parseDef(def.in._def, refs);
|
|
1017
|
-
} else if (refs.pipeStrategy === "output") {
|
|
1018
|
-
return parseDef(def.out._def, refs);
|
|
1019
|
-
}
|
|
1020
|
-
const a = parseDef(def.in._def, {
|
|
1021
|
-
...refs,
|
|
1022
|
-
currentPath: [...refs.currentPath, "allOf", "0"]
|
|
1023
|
-
});
|
|
1024
|
-
const b = parseDef(def.out._def, {
|
|
1025
|
-
...refs,
|
|
1026
|
-
currentPath: [...refs.currentPath, "allOf", a ? "1" : "0"]
|
|
1027
|
-
});
|
|
1028
|
-
return {
|
|
1029
|
-
allOf: [a, b].filter((x) => x !== void 0)
|
|
1030
|
-
};
|
|
1031
|
-
};
|
|
1032
|
-
|
|
1033
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/promise.js
|
|
1034
|
-
function parsePromiseDef(def, refs) {
|
|
1035
|
-
return parseDef(def.type._def, refs);
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/set.js
|
|
1039
|
-
function parseSetDef(def, refs) {
|
|
1040
|
-
const items = parseDef(def.valueType._def, {
|
|
1041
|
-
...refs,
|
|
1042
|
-
currentPath: [...refs.currentPath, "items"]
|
|
1043
|
-
});
|
|
1044
|
-
const schema = {
|
|
1045
|
-
type: "array",
|
|
1046
|
-
uniqueItems: true,
|
|
1047
|
-
items
|
|
1048
|
-
};
|
|
1049
|
-
if (def.minSize) {
|
|
1050
|
-
setResponseValueAndErrors(schema, "minItems", def.minSize.value, def.minSize.message, refs);
|
|
1051
|
-
}
|
|
1052
|
-
if (def.maxSize) {
|
|
1053
|
-
setResponseValueAndErrors(schema, "maxItems", def.maxSize.value, def.maxSize.message, refs);
|
|
1054
|
-
}
|
|
1055
|
-
return schema;
|
|
1056
|
-
}
|
|
1057
|
-
|
|
1058
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js
|
|
1059
|
-
function parseTupleDef(def, refs) {
|
|
1060
|
-
if (def.rest) {
|
|
1061
|
-
return {
|
|
1062
|
-
type: "array",
|
|
1063
|
-
minItems: def.items.length,
|
|
1064
|
-
items: def.items.map((x, i) => parseDef(x._def, {
|
|
1065
|
-
...refs,
|
|
1066
|
-
currentPath: [...refs.currentPath, "items", `${i}`]
|
|
1067
|
-
})).reduce((acc, x) => x === void 0 ? acc : [...acc, x], []),
|
|
1068
|
-
additionalItems: parseDef(def.rest._def, {
|
|
1069
|
-
...refs,
|
|
1070
|
-
currentPath: [...refs.currentPath, "additionalItems"]
|
|
1071
|
-
})
|
|
1072
|
-
};
|
|
1073
|
-
} else {
|
|
1074
|
-
return {
|
|
1075
|
-
type: "array",
|
|
1076
|
-
minItems: def.items.length,
|
|
1077
|
-
maxItems: def.items.length,
|
|
1078
|
-
items: def.items.map((x, i) => parseDef(x._def, {
|
|
1079
|
-
...refs,
|
|
1080
|
-
currentPath: [...refs.currentPath, "items", `${i}`]
|
|
1081
|
-
})).reduce((acc, x) => x === void 0 ? acc : [...acc, x], [])
|
|
1082
|
-
};
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
|
-
|
|
1086
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js
|
|
1087
|
-
function parseUndefinedDef() {
|
|
1088
|
-
return {
|
|
1089
|
-
not: {}
|
|
1090
701
|
};
|
|
1091
|
-
}
|
|
1092
|
-
|
|
1093
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js
|
|
1094
|
-
function parseUnknownDef() {
|
|
1095
|
-
return {};
|
|
1096
|
-
}
|
|
1097
|
-
|
|
1098
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js
|
|
1099
|
-
var parseReadonlyDef = (def, refs) => {
|
|
1100
|
-
return parseDef(def.innerType._def, refs);
|
|
1101
702
|
};
|
|
1102
703
|
|
|
1103
|
-
//
|
|
1104
|
-
var
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
return parseUndefinedDef();
|
|
1120
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodNull:
|
|
1121
|
-
return parseNullDef(refs);
|
|
1122
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodArray:
|
|
1123
|
-
return parseArrayDef(def, refs);
|
|
1124
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodUnion:
|
|
1125
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:
|
|
1126
|
-
return parseUnionDef(def, refs);
|
|
1127
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodIntersection:
|
|
1128
|
-
return parseIntersectionDef(def, refs);
|
|
1129
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodTuple:
|
|
1130
|
-
return parseTupleDef(def, refs);
|
|
1131
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodRecord:
|
|
1132
|
-
return parseRecordDef(def, refs);
|
|
1133
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodLiteral:
|
|
1134
|
-
return parseLiteralDef(def, refs);
|
|
1135
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodEnum:
|
|
1136
|
-
return parseEnumDef(def);
|
|
1137
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodNativeEnum:
|
|
1138
|
-
return parseNativeEnumDef(def);
|
|
1139
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodNullable:
|
|
1140
|
-
return parseNullableDef(def, refs);
|
|
1141
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodOptional:
|
|
1142
|
-
return parseOptionalDef(def, refs);
|
|
1143
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodMap:
|
|
1144
|
-
return parseMapDef(def, refs);
|
|
1145
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodSet:
|
|
1146
|
-
return parseSetDef(def, refs);
|
|
1147
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodLazy:
|
|
1148
|
-
return () => def.getter()._def;
|
|
1149
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodPromise:
|
|
1150
|
-
return parsePromiseDef(def, refs);
|
|
1151
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodNaN:
|
|
1152
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodNever:
|
|
1153
|
-
return parseNeverDef();
|
|
1154
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodEffects:
|
|
1155
|
-
return parseEffectsDef(def, refs);
|
|
1156
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodAny:
|
|
1157
|
-
return parseAnyDef();
|
|
1158
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodUnknown:
|
|
1159
|
-
return parseUnknownDef();
|
|
1160
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodDefault:
|
|
1161
|
-
return parseDefaultDef(def, refs);
|
|
1162
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodBranded:
|
|
1163
|
-
return parseBrandedDef(def, refs);
|
|
1164
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodReadonly:
|
|
1165
|
-
return parseReadonlyDef(def, refs);
|
|
1166
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodCatch:
|
|
1167
|
-
return parseCatchDef(def, refs);
|
|
1168
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodPipeline:
|
|
1169
|
-
return parsePipelineDef(def, refs);
|
|
1170
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodFunction:
|
|
1171
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodVoid:
|
|
1172
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodSymbol:
|
|
1173
|
-
return void 0;
|
|
1174
|
-
default:
|
|
1175
|
-
return /* @__PURE__ */ ((_) => void 0)(typeName);
|
|
1176
|
-
}
|
|
1177
|
-
};
|
|
1178
|
-
|
|
1179
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parseDef.js
|
|
1180
|
-
function parseDef(def, refs, forceResolution = false) {
|
|
1181
|
-
const seenItem = refs.seen.get(def);
|
|
1182
|
-
if (refs.override) {
|
|
1183
|
-
const overrideResult = refs.override?.(def, refs, seenItem, forceResolution);
|
|
1184
|
-
if (overrideResult !== ignoreOverride) {
|
|
1185
|
-
return overrideResult;
|
|
1186
|
-
}
|
|
1187
|
-
}
|
|
1188
|
-
if (seenItem && !forceResolution) {
|
|
1189
|
-
const seenSchema = get$ref(seenItem, refs);
|
|
1190
|
-
if (seenSchema !== void 0) {
|
|
1191
|
-
return seenSchema;
|
|
1192
|
-
}
|
|
1193
|
-
}
|
|
1194
|
-
const newItem = { def, path: refs.currentPath, jsonSchema: void 0 };
|
|
1195
|
-
refs.seen.set(def, newItem);
|
|
1196
|
-
const jsonSchemaOrGetter = selectParser(def, def.typeName, refs);
|
|
1197
|
-
const jsonSchema = typeof jsonSchemaOrGetter === "function" ? parseDef(jsonSchemaOrGetter(), refs) : jsonSchemaOrGetter;
|
|
1198
|
-
if (jsonSchema) {
|
|
1199
|
-
addMeta(def, refs, jsonSchema);
|
|
1200
|
-
}
|
|
1201
|
-
if (refs.postProcess) {
|
|
1202
|
-
const postProcessResult = refs.postProcess(jsonSchema, def, refs);
|
|
1203
|
-
newItem.jsonSchema = jsonSchema;
|
|
1204
|
-
return postProcessResult;
|
|
1205
|
-
}
|
|
1206
|
-
newItem.jsonSchema = jsonSchema;
|
|
1207
|
-
return jsonSchema;
|
|
1208
|
-
}
|
|
1209
|
-
var get$ref = (item, refs) => {
|
|
1210
|
-
switch (refs.$refStrategy) {
|
|
1211
|
-
case "root":
|
|
1212
|
-
return { $ref: item.path.join("/") };
|
|
1213
|
-
case "relative":
|
|
1214
|
-
return { $ref: getRelativePath(refs.currentPath, item.path) };
|
|
1215
|
-
case "none":
|
|
1216
|
-
case "seen": {
|
|
1217
|
-
if (item.path.length < refs.currentPath.length && item.path.every((value, index) => refs.currentPath[index] === value)) {
|
|
1218
|
-
console.warn(`Recursive reference detected at ${refs.currentPath.join("/")}! Defaulting to any`);
|
|
1219
|
-
return {};
|
|
704
|
+
// src/tools/parse.ts
|
|
705
|
+
var createParseHandler = (parser) => {
|
|
706
|
+
return async (args) => {
|
|
707
|
+
try {
|
|
708
|
+
const parsedMessage = parser.parse(args.fixString);
|
|
709
|
+
if (!parsedMessage || parsedMessage.length === 0) {
|
|
710
|
+
return {
|
|
711
|
+
content: [
|
|
712
|
+
{
|
|
713
|
+
type: "text",
|
|
714
|
+
text: "Error: Failed to parse FIX string",
|
|
715
|
+
uri: "parse"
|
|
716
|
+
}
|
|
717
|
+
],
|
|
718
|
+
isError: true
|
|
719
|
+
};
|
|
1220
720
|
}
|
|
1221
|
-
return
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
721
|
+
return {
|
|
722
|
+
content: [
|
|
723
|
+
{
|
|
724
|
+
type: "text",
|
|
725
|
+
text: `${parsedMessage[0].description}
|
|
726
|
+
${parsedMessage[0].messageTypeDescription}`,
|
|
727
|
+
uri: "parse"
|
|
728
|
+
}
|
|
729
|
+
]
|
|
730
|
+
};
|
|
731
|
+
} catch (error) {
|
|
732
|
+
return {
|
|
733
|
+
content: [
|
|
734
|
+
{
|
|
735
|
+
type: "text",
|
|
736
|
+
text: `Error: ${error instanceof Error ? error.message : "Failed to parse FIX string"}`,
|
|
737
|
+
uri: "parse"
|
|
738
|
+
}
|
|
739
|
+
],
|
|
740
|
+
isError: true
|
|
741
|
+
};
|
|
1238
742
|
}
|
|
1239
|
-
}
|
|
1240
|
-
return jsonSchema;
|
|
743
|
+
};
|
|
1241
744
|
};
|
|
1242
745
|
|
|
1243
|
-
//
|
|
1244
|
-
var
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
746
|
+
// src/tools/parseToJSON.ts
|
|
747
|
+
var createParseToJSONHandler = (parser) => {
|
|
748
|
+
return async (args) => {
|
|
749
|
+
try {
|
|
750
|
+
const parsedMessage = parser.parse(args.fixString);
|
|
751
|
+
if (!parsedMessage || parsedMessage.length === 0) {
|
|
752
|
+
return {
|
|
753
|
+
content: [
|
|
754
|
+
{
|
|
755
|
+
type: "text",
|
|
756
|
+
text: "Error: Failed to parse FIX string",
|
|
757
|
+
uri: "parseToJSON"
|
|
758
|
+
}
|
|
759
|
+
],
|
|
760
|
+
isError: true
|
|
761
|
+
};
|
|
762
|
+
}
|
|
763
|
+
return {
|
|
764
|
+
content: [
|
|
765
|
+
{
|
|
766
|
+
type: "text",
|
|
767
|
+
text: `${parsedMessage[0].toFIXJSON()}`,
|
|
768
|
+
uri: "parseToJSON"
|
|
769
|
+
}
|
|
770
|
+
]
|
|
771
|
+
};
|
|
772
|
+
} catch (error) {
|
|
773
|
+
return {
|
|
774
|
+
content: [
|
|
775
|
+
{
|
|
776
|
+
type: "text",
|
|
777
|
+
text: `Error: ${error instanceof Error ? error.message : "Failed to parse FIX string"}`,
|
|
778
|
+
uri: "parseToJSON"
|
|
779
|
+
}
|
|
780
|
+
],
|
|
781
|
+
isError: true
|
|
782
|
+
};
|
|
1274
783
|
}
|
|
1275
784
|
};
|
|
1276
|
-
if (refs.target === "jsonSchema7") {
|
|
1277
|
-
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
1278
|
-
} else if (refs.target === "jsonSchema2019-09" || refs.target === "openAi") {
|
|
1279
|
-
combined.$schema = "https://json-schema.org/draft/2019-09/schema#";
|
|
1280
|
-
}
|
|
1281
|
-
if (refs.target === "openAi" && ("anyOf" in combined || "oneOf" in combined || "allOf" in combined || "type" in combined && Array.isArray(combined.type))) {
|
|
1282
|
-
console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.");
|
|
1283
|
-
}
|
|
1284
|
-
return combined;
|
|
1285
785
|
};
|
|
1286
786
|
|
|
787
|
+
// src/tools/index.ts
|
|
788
|
+
var createToolHandlers = (parser, verifiedOrders, pendingRequests, marketDataPrices) => ({
|
|
789
|
+
parse: createParseHandler(parser),
|
|
790
|
+
parseToJSON: createParseToJSONHandler(parser),
|
|
791
|
+
verifyOrder: createVerifyOrderHandler(parser, verifiedOrders),
|
|
792
|
+
executeOrder: createExecuteOrderHandler(parser, verifiedOrders, pendingRequests),
|
|
793
|
+
marketDataRequest: createMarketDataRequestHandler(parser, pendingRequests),
|
|
794
|
+
getStockGraph: createGetStockGraphHandler(marketDataPrices),
|
|
795
|
+
getStockPriceHistory: createGetStockPriceHistoryHandler(marketDataPrices)
|
|
796
|
+
});
|
|
797
|
+
|
|
1287
798
|
// src/MCPLocal.ts
|
|
1288
|
-
var import_fixparser = require("fixparser");
|
|
1289
799
|
var MCPLocal = class {
|
|
1290
|
-
logger;
|
|
1291
800
|
parser;
|
|
1292
801
|
server = new import_server.Server(
|
|
1293
802
|
{
|
|
@@ -1295,39 +804,106 @@ var MCPLocal = class {
|
|
|
1295
804
|
version: "1.0.0"
|
|
1296
805
|
},
|
|
1297
806
|
{
|
|
1298
|
-
capabilities: {
|
|
807
|
+
capabilities: {
|
|
808
|
+
tools: Object.entries(toolSchemas).reduce(
|
|
809
|
+
(acc, [name, { description, schema }]) => {
|
|
810
|
+
acc[name] = {
|
|
811
|
+
description,
|
|
812
|
+
parameters: schema
|
|
813
|
+
};
|
|
814
|
+
return acc;
|
|
815
|
+
},
|
|
816
|
+
{}
|
|
817
|
+
)
|
|
818
|
+
}
|
|
1299
819
|
}
|
|
1300
820
|
);
|
|
1301
821
|
transport = new import_stdio.StdioServerTransport();
|
|
1302
822
|
onReady = void 0;
|
|
1303
823
|
pendingRequests = /* @__PURE__ */ new Map();
|
|
824
|
+
verifiedOrders = /* @__PURE__ */ new Map();
|
|
825
|
+
marketDataPrices = /* @__PURE__ */ new Map();
|
|
826
|
+
MAX_PRICE_HISTORY = 1e5;
|
|
827
|
+
// Maximum number of price points to store per symbol
|
|
1304
828
|
constructor({ logger, onReady }) {
|
|
1305
|
-
if (logger) this.logger = logger;
|
|
1306
829
|
if (onReady) this.onReady = onReady;
|
|
1307
830
|
}
|
|
1308
831
|
async register(parser) {
|
|
1309
832
|
this.parser = parser;
|
|
1310
833
|
this.parser.addOnMessageCallback((message) => {
|
|
1311
|
-
this.logger
|
|
834
|
+
this.parser?.logger.log({
|
|
1312
835
|
level: "info",
|
|
1313
|
-
message: `
|
|
836
|
+
message: `MCP Server received message: ${message.messageType}: ${message.description}`
|
|
1314
837
|
});
|
|
1315
838
|
const msgType = message.messageType;
|
|
1316
|
-
if (msgType ===
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
839
|
+
if (msgType === import_fixparser3.Messages.MarketDataSnapshotFullRefresh || msgType === import_fixparser3.Messages.ExecutionReport || msgType === import_fixparser3.Messages.Reject || msgType === import_fixparser3.Messages.MarketDataIncrementalRefresh) {
|
|
840
|
+
this.parser?.logger.log({
|
|
841
|
+
level: "info",
|
|
842
|
+
message: `MCP Server handling message type: ${msgType}`
|
|
843
|
+
});
|
|
844
|
+
let id;
|
|
845
|
+
if (msgType === import_fixparser3.Messages.MarketDataIncrementalRefresh || msgType === import_fixparser3.Messages.MarketDataSnapshotFullRefresh) {
|
|
846
|
+
const symbol = message.getField(import_fixparser3.Fields.Symbol);
|
|
847
|
+
const entryType = message.getField(import_fixparser3.Fields.MDEntryType);
|
|
848
|
+
const price = message.getField(import_fixparser3.Fields.MDEntryPx);
|
|
849
|
+
const size = message.getField(import_fixparser3.Fields.MDEntrySize);
|
|
850
|
+
const timestamp = message.getField(import_fixparser3.Fields.MDEntryTime)?.value || Date.now();
|
|
851
|
+
if (symbol?.value && price?.value) {
|
|
852
|
+
const symbolStr = String(symbol.value);
|
|
853
|
+
const priceNum = Number(price.value);
|
|
854
|
+
const sizeNum = size?.value ? Number(size.value) : 0;
|
|
855
|
+
const priceHistory = this.marketDataPrices.get(symbolStr) || [];
|
|
856
|
+
const lastEntry = priceHistory[priceHistory.length - 1] || {
|
|
857
|
+
timestamp: 0,
|
|
858
|
+
bid: 0,
|
|
859
|
+
offer: 0,
|
|
860
|
+
spread: 0,
|
|
861
|
+
volume: 0
|
|
862
|
+
};
|
|
863
|
+
const newEntry = {
|
|
864
|
+
timestamp: Number(timestamp),
|
|
865
|
+
bid: entryType?.value === import_fixparser3.MDEntryType.Bid ? priceNum : lastEntry.bid,
|
|
866
|
+
offer: entryType?.value === import_fixparser3.MDEntryType.Offer ? priceNum : lastEntry.offer,
|
|
867
|
+
spread: entryType?.value === import_fixparser3.MDEntryType.Offer ? priceNum - lastEntry.bid : entryType?.value === import_fixparser3.MDEntryType.Bid ? lastEntry.offer - priceNum : lastEntry.spread,
|
|
868
|
+
volume: entryType?.value === import_fixparser3.MDEntryType.TradeVolume ? sizeNum : lastEntry.volume
|
|
869
|
+
};
|
|
870
|
+
priceHistory.push(newEntry);
|
|
871
|
+
if (priceHistory.length > this.MAX_PRICE_HISTORY) {
|
|
872
|
+
priceHistory.shift();
|
|
1325
873
|
}
|
|
874
|
+
this.marketDataPrices.set(symbolStr, priceHistory);
|
|
875
|
+
this.parser?.logger.log({
|
|
876
|
+
level: "info",
|
|
877
|
+
message: `MCP Server added ${symbol}: ${JSON.stringify(newEntry)}`
|
|
878
|
+
});
|
|
879
|
+
this.server.notification({
|
|
880
|
+
method: "priceUpdate",
|
|
881
|
+
params: {
|
|
882
|
+
symbol: symbolStr,
|
|
883
|
+
...newEntry
|
|
884
|
+
}
|
|
885
|
+
});
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
if (msgType === import_fixparser3.Messages.MarketDataSnapshotFullRefresh) {
|
|
889
|
+
const mdReqID = message.getField(import_fixparser3.Fields.MDReqID);
|
|
890
|
+
if (mdReqID) id = String(mdReqID.value);
|
|
891
|
+
} else if (msgType === import_fixparser3.Messages.ExecutionReport) {
|
|
892
|
+
const clOrdID = message.getField(import_fixparser3.Fields.ClOrdID);
|
|
893
|
+
if (clOrdID) id = String(clOrdID.value);
|
|
894
|
+
} else if (msgType === import_fixparser3.Messages.Reject) {
|
|
895
|
+
const refSeqNum = message.getField(import_fixparser3.Fields.RefSeqNum);
|
|
896
|
+
if (refSeqNum) id = String(refSeqNum.value);
|
|
897
|
+
}
|
|
898
|
+
if (id) {
|
|
899
|
+
const callback = this.pendingRequests.get(id);
|
|
900
|
+
if (callback) {
|
|
901
|
+
callback(message);
|
|
902
|
+
this.pendingRequests.delete(id);
|
|
1326
903
|
}
|
|
1327
904
|
}
|
|
1328
905
|
}
|
|
1329
906
|
});
|
|
1330
|
-
this.logger = parser.logger;
|
|
1331
907
|
this.addWorkflows();
|
|
1332
908
|
await this.server.connect(this.transport);
|
|
1333
909
|
if (this.onReady) {
|
|
@@ -1336,448 +912,62 @@ var MCPLocal = class {
|
|
|
1336
912
|
}
|
|
1337
913
|
addWorkflows() {
|
|
1338
914
|
if (!this.parser) {
|
|
1339
|
-
this.logger?.log({
|
|
1340
|
-
level: "error",
|
|
1341
|
-
message: "FIXParser (MCP): -- FIXParser instance not initialized. Ignoring setup of workflows..."
|
|
1342
|
-
});
|
|
1343
915
|
return;
|
|
1344
916
|
}
|
|
1345
917
|
if (!this.server) {
|
|
1346
|
-
this.logger?.log({
|
|
1347
|
-
level: "error",
|
|
1348
|
-
message: "FIXParser (MCP): -- MCP Server not initialized. Ignoring setup of workflows..."
|
|
1349
|
-
});
|
|
1350
918
|
return;
|
|
1351
919
|
}
|
|
1352
|
-
this.server.setRequestHandler(
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
{
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
clOrdID: import_zod5.z.string().describe("Client Order ID"),
|
|
1386
|
-
handlInst: import_zod5.z.enum(["1", "2", "3"]).default(import_fixparser.HandlInst.AutomatedExecutionNoIntervention).optional().describe("Handling instruction"),
|
|
1387
|
-
quantity: import_zod5.z.number().describe("Order quantity"),
|
|
1388
|
-
price: import_zod5.z.number().describe("Order price"),
|
|
1389
|
-
ordType: import_zod5.z.enum([
|
|
1390
|
-
"1",
|
|
1391
|
-
"2",
|
|
1392
|
-
"3",
|
|
1393
|
-
"4",
|
|
1394
|
-
"5",
|
|
1395
|
-
"6",
|
|
1396
|
-
"7",
|
|
1397
|
-
"8",
|
|
1398
|
-
"9",
|
|
1399
|
-
"A",
|
|
1400
|
-
"B",
|
|
1401
|
-
"C",
|
|
1402
|
-
"D",
|
|
1403
|
-
"E",
|
|
1404
|
-
"F",
|
|
1405
|
-
"G",
|
|
1406
|
-
"H",
|
|
1407
|
-
"I",
|
|
1408
|
-
"J",
|
|
1409
|
-
"K",
|
|
1410
|
-
"L",
|
|
1411
|
-
"M",
|
|
1412
|
-
"P",
|
|
1413
|
-
"Q",
|
|
1414
|
-
"R",
|
|
1415
|
-
"S"
|
|
1416
|
-
]).default("1").optional().describe("Order type"),
|
|
1417
|
-
side: import_zod5.z.enum([
|
|
1418
|
-
"1",
|
|
1419
|
-
"2",
|
|
1420
|
-
"3",
|
|
1421
|
-
"4",
|
|
1422
|
-
"5",
|
|
1423
|
-
"6",
|
|
1424
|
-
"7",
|
|
1425
|
-
"8",
|
|
1426
|
-
"9",
|
|
1427
|
-
"A",
|
|
1428
|
-
"B",
|
|
1429
|
-
"C",
|
|
1430
|
-
"D",
|
|
1431
|
-
"E",
|
|
1432
|
-
"F",
|
|
1433
|
-
"G",
|
|
1434
|
-
"H"
|
|
1435
|
-
]).describe("Order side (1=Buy, 2=Sell)"),
|
|
1436
|
-
symbol: import_zod5.z.string().describe("Trading symbol"),
|
|
1437
|
-
timeInForce: import_zod5.z.enum(["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C"]).default(import_fixparser.TimeInForce.Day).optional().describe("Time in force")
|
|
1438
|
-
}),
|
|
1439
|
-
{ name: "NewOrderSingleInput" }
|
|
1440
|
-
)
|
|
1441
|
-
},
|
|
1442
|
-
{
|
|
1443
|
-
name: "marketDataRequest",
|
|
1444
|
-
description: "Sends a request for Market Data with the given symbol",
|
|
1445
|
-
inputSchema: zodToJsonSchema(
|
|
1446
|
-
import_zod5.z.object({
|
|
1447
|
-
mdUpdateType: import_zod5.z.enum(["0", "1"]).default("0").optional().describe("Market data update type"),
|
|
1448
|
-
symbol: import_zod5.z.string().describe("Trading symbol"),
|
|
1449
|
-
mdReqID: import_zod5.z.string().describe("Market data request ID"),
|
|
1450
|
-
subscriptionRequestType: import_zod5.z.enum(["0", "1", "2"]).default(import_fixparser.SubscriptionRequestType.SnapshotAndUpdates).optional().describe("Subscription request type"),
|
|
1451
|
-
mdEntryType: import_zod5.z.enum([
|
|
1452
|
-
"0",
|
|
1453
|
-
"1",
|
|
1454
|
-
"2",
|
|
1455
|
-
"3",
|
|
1456
|
-
"4",
|
|
1457
|
-
"5",
|
|
1458
|
-
"6",
|
|
1459
|
-
"7",
|
|
1460
|
-
"8",
|
|
1461
|
-
"9",
|
|
1462
|
-
"A",
|
|
1463
|
-
"B",
|
|
1464
|
-
"C",
|
|
1465
|
-
"D",
|
|
1466
|
-
"E",
|
|
1467
|
-
"F",
|
|
1468
|
-
"G",
|
|
1469
|
-
"H",
|
|
1470
|
-
"J",
|
|
1471
|
-
"K",
|
|
1472
|
-
"L",
|
|
1473
|
-
"M",
|
|
1474
|
-
"N",
|
|
1475
|
-
"O",
|
|
1476
|
-
"P",
|
|
1477
|
-
"Q",
|
|
1478
|
-
"S",
|
|
1479
|
-
"R",
|
|
1480
|
-
"T",
|
|
1481
|
-
"U",
|
|
1482
|
-
"V",
|
|
1483
|
-
"W",
|
|
1484
|
-
"X",
|
|
1485
|
-
"Y",
|
|
1486
|
-
"Z",
|
|
1487
|
-
"a",
|
|
1488
|
-
"b",
|
|
1489
|
-
"c",
|
|
1490
|
-
"d",
|
|
1491
|
-
"e",
|
|
1492
|
-
"g",
|
|
1493
|
-
"h",
|
|
1494
|
-
"i",
|
|
1495
|
-
"t"
|
|
1496
|
-
]).default(import_fixparser.MDEntryType.Bid).optional().describe("Market data entry type")
|
|
1497
|
-
}),
|
|
1498
|
-
{ name: "MarketDataRequestInput" }
|
|
1499
|
-
)
|
|
1500
|
-
}
|
|
1501
|
-
]
|
|
1502
|
-
};
|
|
1503
|
-
});
|
|
1504
|
-
this.server.setRequestHandler(import_types.CallToolRequestSchema, async (request) => {
|
|
1505
|
-
const { name, arguments: args } = request.params;
|
|
1506
|
-
switch (name) {
|
|
1507
|
-
case "parse": {
|
|
1508
|
-
const { fixString } = import_zod5.z.object({
|
|
1509
|
-
fixString: import_zod5.z.string().describe("FIX message string to parse")
|
|
1510
|
-
}).parse(args || {});
|
|
1511
|
-
try {
|
|
1512
|
-
const parsedMessage = this.parser?.parse(fixString);
|
|
1513
|
-
if (!parsedMessage || parsedMessage.length === 0) {
|
|
1514
|
-
return {
|
|
1515
|
-
isError: true,
|
|
1516
|
-
content: [{ type: "text", text: "Error: Failed to parse FIX string" }]
|
|
1517
|
-
};
|
|
1518
|
-
}
|
|
1519
|
-
return {
|
|
1520
|
-
content: [
|
|
1521
|
-
{
|
|
1522
|
-
type: "text",
|
|
1523
|
-
text: `Parsed FIX message: ${fixString} (placeholder implementation)`
|
|
1524
|
-
}
|
|
1525
|
-
]
|
|
1526
|
-
};
|
|
1527
|
-
} catch (error) {
|
|
1528
|
-
return {
|
|
1529
|
-
isError: true,
|
|
1530
|
-
content: [
|
|
1531
|
-
{
|
|
1532
|
-
type: "text",
|
|
1533
|
-
text: "Error: Failed to parse FIX string"
|
|
1534
|
-
}
|
|
1535
|
-
]
|
|
1536
|
-
};
|
|
1537
|
-
}
|
|
1538
|
-
}
|
|
1539
|
-
case "parseToJSON": {
|
|
1540
|
-
const { fixString } = import_zod5.z.object({
|
|
1541
|
-
fixString: import_zod5.z.string().describe("FIX message string to parse")
|
|
1542
|
-
}).parse(args || {});
|
|
1543
|
-
try {
|
|
1544
|
-
const parsedMessage = this.parser?.parse(fixString);
|
|
1545
|
-
if (!parsedMessage || parsedMessage.length === 0) {
|
|
1546
|
-
return {
|
|
1547
|
-
isError: true,
|
|
1548
|
-
content: [{ type: "text", text: "Error: Failed to parse FIX string" }]
|
|
1549
|
-
};
|
|
1550
|
-
}
|
|
1551
|
-
return {
|
|
1552
|
-
content: [
|
|
1553
|
-
{
|
|
1554
|
-
type: "text",
|
|
1555
|
-
text: JSON.stringify({ fixString, parsed: "placeholder" })
|
|
1556
|
-
}
|
|
1557
|
-
]
|
|
1558
|
-
};
|
|
1559
|
-
} catch (error) {
|
|
1560
|
-
return {
|
|
1561
|
-
isError: true,
|
|
1562
|
-
content: [
|
|
1563
|
-
{
|
|
1564
|
-
type: "text",
|
|
1565
|
-
text: "Error: Failed to parse FIX string"
|
|
1566
|
-
}
|
|
1567
|
-
]
|
|
1568
|
-
};
|
|
1569
|
-
}
|
|
1570
|
-
}
|
|
1571
|
-
case "newOrderSingle": {
|
|
1572
|
-
const { clOrdID, handlInst, quantity, price, ordType, side, symbol, timeInForce } = import_zod5.z.object({
|
|
1573
|
-
clOrdID: import_zod5.z.string().describe("Client Order ID"),
|
|
1574
|
-
handlInst: import_zod5.z.enum(["1", "2", "3"]).default(import_fixparser.HandlInst.AutomatedExecutionNoIntervention).optional().describe("Handling instruction"),
|
|
1575
|
-
quantity: import_zod5.z.number().describe("Order quantity"),
|
|
1576
|
-
price: import_zod5.z.number().describe("Order price"),
|
|
1577
|
-
ordType: import_zod5.z.enum([
|
|
1578
|
-
"1",
|
|
1579
|
-
"2",
|
|
1580
|
-
"3",
|
|
1581
|
-
"4",
|
|
1582
|
-
"5",
|
|
1583
|
-
"6",
|
|
1584
|
-
"7",
|
|
1585
|
-
"8",
|
|
1586
|
-
"9",
|
|
1587
|
-
"A",
|
|
1588
|
-
"B",
|
|
1589
|
-
"C",
|
|
1590
|
-
"D",
|
|
1591
|
-
"E",
|
|
1592
|
-
"F",
|
|
1593
|
-
"G",
|
|
1594
|
-
"H",
|
|
1595
|
-
"I",
|
|
1596
|
-
"J",
|
|
1597
|
-
"K",
|
|
1598
|
-
"L",
|
|
1599
|
-
"M",
|
|
1600
|
-
"P",
|
|
1601
|
-
"Q",
|
|
1602
|
-
"R",
|
|
1603
|
-
"S"
|
|
1604
|
-
]).default(import_fixparser.OrdType.Market).optional().describe("Order type"),
|
|
1605
|
-
side: import_zod5.z.enum([
|
|
1606
|
-
"1",
|
|
1607
|
-
"2",
|
|
1608
|
-
"3",
|
|
1609
|
-
"4",
|
|
1610
|
-
"5",
|
|
1611
|
-
"6",
|
|
1612
|
-
"7",
|
|
1613
|
-
"8",
|
|
1614
|
-
"9",
|
|
1615
|
-
"A",
|
|
1616
|
-
"B",
|
|
1617
|
-
"C",
|
|
1618
|
-
"D",
|
|
1619
|
-
"E",
|
|
1620
|
-
"F",
|
|
1621
|
-
"G",
|
|
1622
|
-
"H"
|
|
1623
|
-
]).describe("Order side (1=Buy, 2=Sell)"),
|
|
1624
|
-
symbol: import_zod5.z.string().describe("Trading symbol"),
|
|
1625
|
-
timeInForce: import_zod5.z.enum(["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C"]).default(import_fixparser.TimeInForce.Day).optional().describe("Time in force")
|
|
1626
|
-
}).parse(args || {});
|
|
1627
|
-
const response = new Promise((resolve) => {
|
|
1628
|
-
this.pendingRequests.set(clOrdID, resolve);
|
|
1629
|
-
});
|
|
1630
|
-
const order = this.parser?.createMessage(
|
|
1631
|
-
new import_fixparser.Field(import_fixparser.Fields.MsgType, import_fixparser.Messages.NewOrderSingle),
|
|
1632
|
-
new import_fixparser.Field(import_fixparser.Fields.MsgSeqNum, this.parser?.getNextTargetMsgSeqNum()),
|
|
1633
|
-
new import_fixparser.Field(import_fixparser.Fields.SenderCompID, this.parser?.sender),
|
|
1634
|
-
new import_fixparser.Field(import_fixparser.Fields.TargetCompID, this.parser?.target),
|
|
1635
|
-
new import_fixparser.Field(import_fixparser.Fields.SendingTime, this.parser?.getTimestamp()),
|
|
1636
|
-
new import_fixparser.Field(import_fixparser.Fields.ClOrdID, clOrdID),
|
|
1637
|
-
new import_fixparser.Field(import_fixparser.Fields.Side, side),
|
|
1638
|
-
new import_fixparser.Field(import_fixparser.Fields.Symbol, symbol),
|
|
1639
|
-
new import_fixparser.Field(import_fixparser.Fields.OrderQty, quantity),
|
|
1640
|
-
new import_fixparser.Field(import_fixparser.Fields.Price, price),
|
|
1641
|
-
new import_fixparser.Field(import_fixparser.Fields.OrdType, ordType),
|
|
1642
|
-
new import_fixparser.Field(import_fixparser.Fields.HandlInst, handlInst),
|
|
1643
|
-
new import_fixparser.Field(import_fixparser.Fields.TimeInForce, timeInForce),
|
|
1644
|
-
new import_fixparser.Field(import_fixparser.Fields.TransactTime, this.parser?.getTimestamp())
|
|
1645
|
-
);
|
|
1646
|
-
if (!this.parser?.connected) {
|
|
1647
|
-
this.logger?.log({
|
|
1648
|
-
level: "error",
|
|
1649
|
-
message: "FIXParser (MCP): -- Not connected. Ignoring message."
|
|
1650
|
-
});
|
|
1651
|
-
return {
|
|
1652
|
-
isError: true,
|
|
1653
|
-
content: [
|
|
1654
|
-
{
|
|
1655
|
-
type: "text",
|
|
1656
|
-
text: "Error: Not connected. Ignoring message."
|
|
1657
|
-
}
|
|
1658
|
-
]
|
|
1659
|
-
};
|
|
1660
|
-
}
|
|
1661
|
-
this.parser?.send(order);
|
|
1662
|
-
this.logger?.log({
|
|
1663
|
-
level: "info",
|
|
1664
|
-
message: `FIXParser (MCP): (${this.parser?.protocol?.toUpperCase()}): >> sent ${order?.description}`
|
|
1665
|
-
});
|
|
1666
|
-
const fixData = await response;
|
|
1667
|
-
return {
|
|
1668
|
-
content: [
|
|
1669
|
-
{
|
|
1670
|
-
type: "text",
|
|
1671
|
-
text: `Execution Report for order ${clOrdID}: ${JSON.stringify(fixData.toFIXJSON())}`
|
|
1672
|
-
}
|
|
1673
|
-
]
|
|
1674
|
-
};
|
|
1675
|
-
}
|
|
1676
|
-
case "marketDataRequest": {
|
|
1677
|
-
const { mdUpdateType, symbol, mdReqID, subscriptionRequestType, mdEntryType } = import_zod5.z.object({
|
|
1678
|
-
mdUpdateType: import_zod5.z.enum(["0", "1"]).default("0").optional().describe("Market data update type"),
|
|
1679
|
-
symbol: import_zod5.z.string().describe("Trading symbol"),
|
|
1680
|
-
mdReqID: import_zod5.z.string().describe("Market data request ID"),
|
|
1681
|
-
subscriptionRequestType: import_zod5.z.enum(["0", "1", "2"]).default(import_fixparser.SubscriptionRequestType.SnapshotAndUpdates).optional().describe("Subscription request type"),
|
|
1682
|
-
mdEntryType: import_zod5.z.enum([
|
|
1683
|
-
"0",
|
|
1684
|
-
"1",
|
|
1685
|
-
"2",
|
|
1686
|
-
"3",
|
|
1687
|
-
"4",
|
|
1688
|
-
"5",
|
|
1689
|
-
"6",
|
|
1690
|
-
"7",
|
|
1691
|
-
"8",
|
|
1692
|
-
"9",
|
|
1693
|
-
"A",
|
|
1694
|
-
"B",
|
|
1695
|
-
"C",
|
|
1696
|
-
"D",
|
|
1697
|
-
"E",
|
|
1698
|
-
"F",
|
|
1699
|
-
"G",
|
|
1700
|
-
"H",
|
|
1701
|
-
"J",
|
|
1702
|
-
"K",
|
|
1703
|
-
"L",
|
|
1704
|
-
"M",
|
|
1705
|
-
"N",
|
|
1706
|
-
"O",
|
|
1707
|
-
"P",
|
|
1708
|
-
"Q",
|
|
1709
|
-
"S",
|
|
1710
|
-
"R",
|
|
1711
|
-
"T",
|
|
1712
|
-
"U",
|
|
1713
|
-
"V",
|
|
1714
|
-
"W",
|
|
1715
|
-
"X",
|
|
1716
|
-
"Y",
|
|
1717
|
-
"Z",
|
|
1718
|
-
"a",
|
|
1719
|
-
"b",
|
|
1720
|
-
"c",
|
|
1721
|
-
"d",
|
|
1722
|
-
"e",
|
|
1723
|
-
"g",
|
|
1724
|
-
"h",
|
|
1725
|
-
"i",
|
|
1726
|
-
"t"
|
|
1727
|
-
]).default(import_fixparser.MDEntryType.Bid).optional().describe("Market data entry type")
|
|
1728
|
-
}).parse(args || {});
|
|
1729
|
-
const response = new Promise((resolve) => {
|
|
1730
|
-
this.pendingRequests.set(mdReqID, resolve);
|
|
1731
|
-
});
|
|
1732
|
-
const marketDataRequest = this.parser?.createMessage(
|
|
1733
|
-
new import_fixparser.Field(import_fixparser.Fields.MsgType, import_fixparser.Messages.MarketDataRequest),
|
|
1734
|
-
new import_fixparser.Field(import_fixparser.Fields.SenderCompID, this.parser?.sender),
|
|
1735
|
-
new import_fixparser.Field(import_fixparser.Fields.MsgSeqNum, this.parser?.getNextTargetMsgSeqNum()),
|
|
1736
|
-
new import_fixparser.Field(import_fixparser.Fields.TargetCompID, this.parser?.target),
|
|
1737
|
-
new import_fixparser.Field(import_fixparser.Fields.SendingTime, this.parser?.getTimestamp()),
|
|
1738
|
-
new import_fixparser.Field(import_fixparser.Fields.MarketDepth, 0),
|
|
1739
|
-
new import_fixparser.Field(import_fixparser.Fields.MDUpdateType, mdUpdateType),
|
|
1740
|
-
new import_fixparser.Field(import_fixparser.Fields.NoRelatedSym, 1),
|
|
1741
|
-
new import_fixparser.Field(import_fixparser.Fields.Symbol, symbol),
|
|
1742
|
-
new import_fixparser.Field(import_fixparser.Fields.MDReqID, mdReqID),
|
|
1743
|
-
new import_fixparser.Field(import_fixparser.Fields.SubscriptionRequestType, subscriptionRequestType),
|
|
1744
|
-
new import_fixparser.Field(import_fixparser.Fields.NoMDEntryTypes, 1),
|
|
1745
|
-
new import_fixparser.Field(import_fixparser.Fields.MDEntryType, mdEntryType)
|
|
1746
|
-
);
|
|
1747
|
-
if (!this.parser?.connected) {
|
|
1748
|
-
this.logger?.log({
|
|
1749
|
-
level: "error",
|
|
1750
|
-
message: "FIXParser (MCP): -- Not connected. Ignoring message."
|
|
1751
|
-
});
|
|
1752
|
-
return {
|
|
1753
|
-
isError: true,
|
|
1754
|
-
content: [
|
|
1755
|
-
{
|
|
1756
|
-
type: "text",
|
|
1757
|
-
text: "Error: Not connected. Ignoring message."
|
|
1758
|
-
}
|
|
1759
|
-
]
|
|
1760
|
-
};
|
|
1761
|
-
}
|
|
1762
|
-
this.parser?.send(marketDataRequest);
|
|
1763
|
-
this.logger?.log({
|
|
1764
|
-
level: "info",
|
|
1765
|
-
message: `FIXParser (MCP): (${this.parser?.protocol?.toUpperCase()}): >> sent ${marketDataRequest?.description}`
|
|
1766
|
-
});
|
|
1767
|
-
const fixData = await response;
|
|
920
|
+
this.server.setRequestHandler(
|
|
921
|
+
import_zod.z.object({ method: import_zod.z.literal("tools/list") }),
|
|
922
|
+
async (request, extra) => {
|
|
923
|
+
return {
|
|
924
|
+
tools: Object.entries(toolSchemas).map(([name, { description, schema }]) => ({
|
|
925
|
+
name,
|
|
926
|
+
description,
|
|
927
|
+
inputSchema: schema
|
|
928
|
+
}))
|
|
929
|
+
};
|
|
930
|
+
}
|
|
931
|
+
);
|
|
932
|
+
this.server.setRequestHandler(
|
|
933
|
+
import_zod.z.object({
|
|
934
|
+
method: import_zod.z.literal("tools/call"),
|
|
935
|
+
params: import_zod.z.object({
|
|
936
|
+
name: import_zod.z.string(),
|
|
937
|
+
arguments: import_zod.z.any(),
|
|
938
|
+
_meta: import_zod.z.object({
|
|
939
|
+
progressToken: import_zod.z.number()
|
|
940
|
+
}).optional()
|
|
941
|
+
})
|
|
942
|
+
}),
|
|
943
|
+
async (request, extra) => {
|
|
944
|
+
const { name, arguments: args } = request.params;
|
|
945
|
+
const toolHandlers = createToolHandlers(
|
|
946
|
+
this.parser,
|
|
947
|
+
this.verifiedOrders,
|
|
948
|
+
this.pendingRequests,
|
|
949
|
+
this.marketDataPrices
|
|
950
|
+
);
|
|
951
|
+
const handler = toolHandlers[name];
|
|
952
|
+
if (!handler) {
|
|
1768
953
|
return {
|
|
1769
954
|
content: [
|
|
1770
955
|
{
|
|
1771
956
|
type: "text",
|
|
1772
|
-
text: `
|
|
957
|
+
text: `Tool not found: ${name}`,
|
|
958
|
+
uri: name
|
|
1773
959
|
}
|
|
1774
|
-
]
|
|
960
|
+
],
|
|
961
|
+
isError: true
|
|
1775
962
|
};
|
|
1776
963
|
}
|
|
1777
|
-
|
|
1778
|
-
|
|
964
|
+
const result = await handler(args);
|
|
965
|
+
return {
|
|
966
|
+
content: result.content,
|
|
967
|
+
isError: result.isError
|
|
968
|
+
};
|
|
1779
969
|
}
|
|
1780
|
-
|
|
970
|
+
);
|
|
1781
971
|
process.on("SIGINT", async () => {
|
|
1782
972
|
await this.server.close();
|
|
1783
973
|
process.exit(0);
|