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