fixparser-plugin-mcp 9.1.7-620b3399 → 9.1.7-63c797c5
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 +35 -367
- package/build/cjs/MCPLocal.js.map +2 -2
- package/build/cjs/MCPRemote.js +176 -435
- package/build/cjs/MCPRemote.js.map +2 -2
- package/build/cjs/index.js +177 -436
- package/build/cjs/index.js.map +2 -2
- package/build/esm/MCPLocal.mjs +35 -367
- package/build/esm/MCPLocal.mjs.map +2 -2
- package/build/esm/MCPRemote.mjs +176 -435
- package/build/esm/MCPRemote.mjs.map +2 -2
- package/build/esm/index.mjs +177 -436
- package/build/esm/index.mjs.map +2 -2
- package/build-examples/cjs/example_mcp_local.js +16 -0
- package/build-examples/cjs/example_mcp_local.js.map +7 -0
- 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 +16 -0
- package/build-examples/esm/example_mcp_local.mjs.map +7 -0
- package/build-examples/esm/example_mcp_remote.mjs +16 -0
- package/build-examples/esm/example_mcp_remote.mjs.map +7 -0
- package/package.json +1 -1
- package/types/MCPBase.d.ts +49 -0
- package/types/MCPLocal.d.ts +40 -0
- package/types/MCPRemote.d.ts +66 -0
- package/types/PluginOptions.d.ts +6 -0
- package/types/index.d.ts +3 -0
- package/types/schemas/index.d.ts +15 -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 +12 -0
- package/types/tools/parse.d.ts +5 -0
- package/types/tools/parseToJSON.d.ts +5 -0
- package/types/utils/messageHandler.d.ts +18 -0
package/build/cjs/MCPLocal.js
CHANGED
|
@@ -163,7 +163,7 @@ var toolSchemas = {
|
|
|
163
163
|
}
|
|
164
164
|
},
|
|
165
165
|
executeOrder: {
|
|
166
|
-
description: "Executes a verified order. verifyOrder must be called before executeOrder.",
|
|
166
|
+
description: "Executes a verified order. verifyOrder must be called before executeOrder. user has to explicitly allow executeOrder.",
|
|
167
167
|
schema: {
|
|
168
168
|
type: "object",
|
|
169
169
|
properties: {
|
|
@@ -316,63 +316,10 @@ var import_quickchart_js = __toESM(require("quickchart-js"), 1);
|
|
|
316
316
|
var createMarketDataRequestHandler = (parser, pendingRequests) => {
|
|
317
317
|
return async (args) => {
|
|
318
318
|
try {
|
|
319
|
-
parser.logger.log({
|
|
320
|
-
level: "info",
|
|
321
|
-
message: `Sending market data request for symbols: ${args.symbols.join(", ")}`
|
|
322
|
-
});
|
|
323
319
|
const response = new Promise((resolve) => {
|
|
324
320
|
pendingRequests.set(args.mdReqID, resolve);
|
|
325
|
-
parser.logger.log({
|
|
326
|
-
level: "info",
|
|
327
|
-
message: `Registered callback for market data request ID: ${args.mdReqID}`
|
|
328
|
-
});
|
|
329
321
|
});
|
|
330
|
-
const entryTypes = args.mdEntryTypes || [
|
|
331
|
-
import_fixparser.MDEntryType.Bid,
|
|
332
|
-
import_fixparser.MDEntryType.Offer,
|
|
333
|
-
import_fixparser.MDEntryType.Trade,
|
|
334
|
-
import_fixparser.MDEntryType.IndexValue,
|
|
335
|
-
import_fixparser.MDEntryType.OpeningPrice,
|
|
336
|
-
import_fixparser.MDEntryType.ClosingPrice,
|
|
337
|
-
import_fixparser.MDEntryType.SettlementPrice,
|
|
338
|
-
import_fixparser.MDEntryType.TradingSessionHighPrice,
|
|
339
|
-
import_fixparser.MDEntryType.TradingSessionLowPrice,
|
|
340
|
-
import_fixparser.MDEntryType.VWAP,
|
|
341
|
-
import_fixparser.MDEntryType.Imbalance,
|
|
342
|
-
import_fixparser.MDEntryType.TradeVolume,
|
|
343
|
-
import_fixparser.MDEntryType.OpenInterest,
|
|
344
|
-
import_fixparser.MDEntryType.CompositeUnderlyingPrice,
|
|
345
|
-
import_fixparser.MDEntryType.SimulatedSellPrice,
|
|
346
|
-
import_fixparser.MDEntryType.SimulatedBuyPrice,
|
|
347
|
-
import_fixparser.MDEntryType.MarginRate,
|
|
348
|
-
import_fixparser.MDEntryType.MidPrice,
|
|
349
|
-
import_fixparser.MDEntryType.EmptyBook,
|
|
350
|
-
import_fixparser.MDEntryType.SettleHighPrice,
|
|
351
|
-
import_fixparser.MDEntryType.SettleLowPrice,
|
|
352
|
-
import_fixparser.MDEntryType.PriorSettlePrice,
|
|
353
|
-
import_fixparser.MDEntryType.SessionHighBid,
|
|
354
|
-
import_fixparser.MDEntryType.SessionLowOffer,
|
|
355
|
-
import_fixparser.MDEntryType.EarlyPrices,
|
|
356
|
-
import_fixparser.MDEntryType.AuctionClearingPrice,
|
|
357
|
-
import_fixparser.MDEntryType.SwapValueFactor,
|
|
358
|
-
import_fixparser.MDEntryType.DailyValueAdjustmentForLongPositions,
|
|
359
|
-
import_fixparser.MDEntryType.CumulativeValueAdjustmentForLongPositions,
|
|
360
|
-
import_fixparser.MDEntryType.DailyValueAdjustmentForShortPositions,
|
|
361
|
-
import_fixparser.MDEntryType.CumulativeValueAdjustmentForShortPositions,
|
|
362
|
-
import_fixparser.MDEntryType.FixingPrice,
|
|
363
|
-
import_fixparser.MDEntryType.CashRate,
|
|
364
|
-
import_fixparser.MDEntryType.RecoveryRate,
|
|
365
|
-
import_fixparser.MDEntryType.RecoveryRateForLong,
|
|
366
|
-
import_fixparser.MDEntryType.RecoveryRateForShort,
|
|
367
|
-
import_fixparser.MDEntryType.MarketBid,
|
|
368
|
-
import_fixparser.MDEntryType.MarketOffer,
|
|
369
|
-
import_fixparser.MDEntryType.ShortSaleMinPrice,
|
|
370
|
-
import_fixparser.MDEntryType.PreviousClosingPrice,
|
|
371
|
-
import_fixparser.MDEntryType.ThresholdLimitPriceBanding,
|
|
372
|
-
import_fixparser.MDEntryType.DailyFinancingValue,
|
|
373
|
-
import_fixparser.MDEntryType.AccruedFinancingValue,
|
|
374
|
-
import_fixparser.MDEntryType.TWAP
|
|
375
|
-
];
|
|
322
|
+
const entryTypes = args.mdEntryTypes || [import_fixparser.MDEntryType.Bid, import_fixparser.MDEntryType.Offer, import_fixparser.MDEntryType.TradeVolume];
|
|
376
323
|
const messageFields = [
|
|
377
324
|
new import_fixparser.Field(import_fixparser.Fields.MsgType, import_fixparser.Messages.MarketDataRequest),
|
|
378
325
|
new import_fixparser.Field(import_fixparser.Fields.SenderCompID, parser.sender),
|
|
@@ -394,10 +341,6 @@ var createMarketDataRequestHandler = (parser, pendingRequests) => {
|
|
|
394
341
|
});
|
|
395
342
|
const mdr = parser.createMessage(...messageFields);
|
|
396
343
|
if (!parser.connected) {
|
|
397
|
-
parser.logger.log({
|
|
398
|
-
level: "error",
|
|
399
|
-
message: "Not connected. Cannot send market data request."
|
|
400
|
-
});
|
|
401
344
|
return {
|
|
402
345
|
content: [
|
|
403
346
|
{
|
|
@@ -409,16 +352,8 @@ var createMarketDataRequestHandler = (parser, pendingRequests) => {
|
|
|
409
352
|
isError: true
|
|
410
353
|
};
|
|
411
354
|
}
|
|
412
|
-
parser.logger.log({
|
|
413
|
-
level: "info",
|
|
414
|
-
message: `Sending market data request message: ${JSON.stringify(mdr?.toFIXJSON())}`
|
|
415
|
-
});
|
|
416
355
|
parser.send(mdr);
|
|
417
356
|
const fixData = await response;
|
|
418
|
-
parser.logger.log({
|
|
419
|
-
level: "info",
|
|
420
|
-
message: `Received market data response for request ID: ${args.mdReqID}`
|
|
421
|
-
});
|
|
422
357
|
return {
|
|
423
358
|
content: [
|
|
424
359
|
{
|
|
@@ -467,9 +402,6 @@ var createGetStockGraphHandler = (marketDataPrices) => {
|
|
|
467
402
|
const offerData = priceHistory.map((point) => point.offer);
|
|
468
403
|
const spreadData = priceHistory.map((point) => point.spread);
|
|
469
404
|
const volumeData = priceHistory.map((point) => point.volume);
|
|
470
|
-
const tradeData = priceHistory.map((point) => point.trade);
|
|
471
|
-
const vwapData = priceHistory.map((point) => point.vwap);
|
|
472
|
-
const twapData = priceHistory.map((point) => point.twap);
|
|
473
405
|
const config = {
|
|
474
406
|
type: "line",
|
|
475
407
|
data: {
|
|
@@ -499,30 +431,6 @@ var createGetStockGraphHandler = (marketDataPrices) => {
|
|
|
499
431
|
fill: false,
|
|
500
432
|
tension: 0.4
|
|
501
433
|
},
|
|
502
|
-
{
|
|
503
|
-
label: "Trade",
|
|
504
|
-
data: tradeData,
|
|
505
|
-
borderColor: "#ffc107",
|
|
506
|
-
backgroundColor: "rgba(255, 193, 7, 0.1)",
|
|
507
|
-
fill: false,
|
|
508
|
-
tension: 0.4
|
|
509
|
-
},
|
|
510
|
-
{
|
|
511
|
-
label: "VWAP",
|
|
512
|
-
data: vwapData,
|
|
513
|
-
borderColor: "#17a2b8",
|
|
514
|
-
backgroundColor: "rgba(23, 162, 184, 0.1)",
|
|
515
|
-
fill: false,
|
|
516
|
-
tension: 0.4
|
|
517
|
-
},
|
|
518
|
-
{
|
|
519
|
-
label: "TWAP",
|
|
520
|
-
data: twapData,
|
|
521
|
-
borderColor: "#6610f2",
|
|
522
|
-
backgroundColor: "rgba(102, 16, 242, 0.1)",
|
|
523
|
-
fill: false,
|
|
524
|
-
tension: 0.4
|
|
525
|
-
},
|
|
526
434
|
{
|
|
527
435
|
label: "Volume",
|
|
528
436
|
data: volumeData,
|
|
@@ -568,7 +476,7 @@ var createGetStockGraphHandler = (marketDataPrices) => {
|
|
|
568
476
|
content: [
|
|
569
477
|
{
|
|
570
478
|
type: "text",
|
|
571
|
-
text: `Error: ${error instanceof Error ? error.message : "Failed to generate
|
|
479
|
+
text: `Error: ${error instanceof Error ? error.message : "Failed to generate chart"}`,
|
|
572
480
|
uri: "getStockGraph"
|
|
573
481
|
}
|
|
574
482
|
],
|
|
@@ -606,48 +514,7 @@ var createGetStockPriceHistoryHandler = (marketDataPrices) => {
|
|
|
606
514
|
bid: point.bid,
|
|
607
515
|
offer: point.offer,
|
|
608
516
|
spread: point.spread,
|
|
609
|
-
volume: point.volume
|
|
610
|
-
trade: point.trade,
|
|
611
|
-
indexValue: point.indexValue,
|
|
612
|
-
openingPrice: point.openingPrice,
|
|
613
|
-
closingPrice: point.closingPrice,
|
|
614
|
-
settlementPrice: point.settlementPrice,
|
|
615
|
-
tradingSessionHighPrice: point.tradingSessionHighPrice,
|
|
616
|
-
tradingSessionLowPrice: point.tradingSessionLowPrice,
|
|
617
|
-
vwap: point.vwap,
|
|
618
|
-
imbalance: point.imbalance,
|
|
619
|
-
openInterest: point.openInterest,
|
|
620
|
-
compositeUnderlyingPrice: point.compositeUnderlyingPrice,
|
|
621
|
-
simulatedSellPrice: point.simulatedSellPrice,
|
|
622
|
-
simulatedBuyPrice: point.simulatedBuyPrice,
|
|
623
|
-
marginRate: point.marginRate,
|
|
624
|
-
midPrice: point.midPrice,
|
|
625
|
-
emptyBook: point.emptyBook,
|
|
626
|
-
settleHighPrice: point.settleHighPrice,
|
|
627
|
-
settleLowPrice: point.settleLowPrice,
|
|
628
|
-
priorSettlePrice: point.priorSettlePrice,
|
|
629
|
-
sessionHighBid: point.sessionHighBid,
|
|
630
|
-
sessionLowOffer: point.sessionLowOffer,
|
|
631
|
-
earlyPrices: point.earlyPrices,
|
|
632
|
-
auctionClearingPrice: point.auctionClearingPrice,
|
|
633
|
-
swapValueFactor: point.swapValueFactor,
|
|
634
|
-
dailyValueAdjustmentForLongPositions: point.dailyValueAdjustmentForLongPositions,
|
|
635
|
-
cumulativeValueAdjustmentForLongPositions: point.cumulativeValueAdjustmentForLongPositions,
|
|
636
|
-
dailyValueAdjustmentForShortPositions: point.dailyValueAdjustmentForShortPositions,
|
|
637
|
-
cumulativeValueAdjustmentForShortPositions: point.cumulativeValueAdjustmentForShortPositions,
|
|
638
|
-
fixingPrice: point.fixingPrice,
|
|
639
|
-
cashRate: point.cashRate,
|
|
640
|
-
recoveryRate: point.recoveryRate,
|
|
641
|
-
recoveryRateForLong: point.recoveryRateForLong,
|
|
642
|
-
recoveryRateForShort: point.recoveryRateForShort,
|
|
643
|
-
marketBid: point.marketBid,
|
|
644
|
-
marketOffer: point.marketOffer,
|
|
645
|
-
shortSaleMinPrice: point.shortSaleMinPrice,
|
|
646
|
-
previousClosingPrice: point.previousClosingPrice,
|
|
647
|
-
thresholdLimitPriceBanding: point.thresholdLimitPriceBanding,
|
|
648
|
-
dailyFinancingValue: point.dailyFinancingValue,
|
|
649
|
-
accruedFinancingValue: point.accruedFinancingValue,
|
|
650
|
-
twap: point.twap
|
|
517
|
+
volume: point.volume
|
|
651
518
|
}))
|
|
652
519
|
},
|
|
653
520
|
null,
|
|
@@ -662,7 +529,7 @@ var createGetStockPriceHistoryHandler = (marketDataPrices) => {
|
|
|
662
529
|
content: [
|
|
663
530
|
{
|
|
664
531
|
type: "text",
|
|
665
|
-
text: `Error: ${error instanceof Error ? error.message : "Failed to get price history"}`,
|
|
532
|
+
text: `Error: ${error instanceof Error ? error.message : "Failed to get stock price history"}`,
|
|
666
533
|
uri: "getStockPriceHistory"
|
|
667
534
|
}
|
|
668
535
|
],
|
|
@@ -770,7 +637,7 @@ Parameters verified:
|
|
|
770
637
|
- Symbol: ${args.symbol}
|
|
771
638
|
- TimeInForce: ${args.timeInForce} (${timeInForceNames[args.timeInForce]})
|
|
772
639
|
|
|
773
|
-
To execute this order, call the executeOrder tool with these exact same parameters
|
|
640
|
+
To execute this order, call the executeOrder tool with these exact same parameters.`,
|
|
774
641
|
uri: "verifyOrder"
|
|
775
642
|
}
|
|
776
643
|
]
|
|
@@ -977,245 +844,46 @@ function handleMessage(message, parser, pendingRequests, marketDataPrices, maxPr
|
|
|
977
844
|
message: `MCP Server received message: ${message.messageType}: ${message.description}`
|
|
978
845
|
});
|
|
979
846
|
const msgType = message.messageType;
|
|
980
|
-
if (msgType === import_fixparser3.Messages.MarketDataSnapshotFullRefresh
|
|
847
|
+
if (msgType === import_fixparser3.Messages.MarketDataSnapshotFullRefresh) {
|
|
981
848
|
const symbol = message.getField(import_fixparser3.Fields.Symbol)?.value;
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
const
|
|
987
|
-
const
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
openingPrice: 0,
|
|
1001
|
-
closingPrice: 0,
|
|
1002
|
-
settlementPrice: 0,
|
|
1003
|
-
tradingSessionHighPrice: 0,
|
|
1004
|
-
tradingSessionLowPrice: 0,
|
|
1005
|
-
vwap: 0,
|
|
1006
|
-
imbalance: 0,
|
|
1007
|
-
openInterest: 0,
|
|
1008
|
-
compositeUnderlyingPrice: 0,
|
|
1009
|
-
simulatedSellPrice: 0,
|
|
1010
|
-
simulatedBuyPrice: 0,
|
|
1011
|
-
marginRate: 0,
|
|
1012
|
-
midPrice: 0,
|
|
1013
|
-
emptyBook: 0,
|
|
1014
|
-
settleHighPrice: 0,
|
|
1015
|
-
settleLowPrice: 0,
|
|
1016
|
-
priorSettlePrice: 0,
|
|
1017
|
-
sessionHighBid: 0,
|
|
1018
|
-
sessionLowOffer: 0,
|
|
1019
|
-
earlyPrices: 0,
|
|
1020
|
-
auctionClearingPrice: 0,
|
|
1021
|
-
swapValueFactor: 0,
|
|
1022
|
-
dailyValueAdjustmentForLongPositions: 0,
|
|
1023
|
-
cumulativeValueAdjustmentForLongPositions: 0,
|
|
1024
|
-
dailyValueAdjustmentForShortPositions: 0,
|
|
1025
|
-
cumulativeValueAdjustmentForShortPositions: 0,
|
|
1026
|
-
fixingPrice: 0,
|
|
1027
|
-
cashRate: 0,
|
|
1028
|
-
recoveryRate: 0,
|
|
1029
|
-
recoveryRateForLong: 0,
|
|
1030
|
-
recoveryRateForShort: 0,
|
|
1031
|
-
marketBid: 0,
|
|
1032
|
-
marketOffer: 0,
|
|
1033
|
-
shortSaleMinPrice: 0,
|
|
1034
|
-
previousClosingPrice: 0,
|
|
1035
|
-
thresholdLimitPriceBanding: 0,
|
|
1036
|
-
dailyFinancingValue: 0,
|
|
1037
|
-
accruedFinancingValue: 0,
|
|
1038
|
-
twap: 0
|
|
1039
|
-
};
|
|
1040
|
-
for (const entry of entries) {
|
|
1041
|
-
const entryType = entry.MDEntryType;
|
|
1042
|
-
const price = entry.MDEntryPx ? Number.parseFloat(entry.MDEntryPx) : 0;
|
|
1043
|
-
const size = entry.MDEntrySize ? Number.parseFloat(entry.MDEntrySize) : 0;
|
|
1044
|
-
if (entryType === import_fixparser3.MDEntryType.Bid || entryType === import_fixparser3.MDEntryType.Offer || entryType === import_fixparser3.MDEntryType.TradeVolume) {
|
|
1045
|
-
parser.logger.log({
|
|
1046
|
-
level: "info",
|
|
1047
|
-
message: `Market Data Entry - Type: ${entryType}, Price: ${price}, Size: ${size}`
|
|
1048
|
-
});
|
|
1049
|
-
}
|
|
1050
|
-
switch (entryType) {
|
|
1051
|
-
case import_fixparser3.MDEntryType.Bid:
|
|
1052
|
-
data.bid = price;
|
|
1053
|
-
break;
|
|
1054
|
-
case import_fixparser3.MDEntryType.Offer:
|
|
1055
|
-
data.offer = price;
|
|
1056
|
-
break;
|
|
1057
|
-
case import_fixparser3.MDEntryType.Trade:
|
|
1058
|
-
data.trade = price;
|
|
1059
|
-
break;
|
|
1060
|
-
case import_fixparser3.MDEntryType.IndexValue:
|
|
1061
|
-
data.indexValue = price;
|
|
1062
|
-
break;
|
|
1063
|
-
case import_fixparser3.MDEntryType.OpeningPrice:
|
|
1064
|
-
data.openingPrice = price;
|
|
1065
|
-
break;
|
|
1066
|
-
case import_fixparser3.MDEntryType.ClosingPrice:
|
|
1067
|
-
data.closingPrice = price;
|
|
1068
|
-
break;
|
|
1069
|
-
case import_fixparser3.MDEntryType.SettlementPrice:
|
|
1070
|
-
data.settlementPrice = price;
|
|
1071
|
-
break;
|
|
1072
|
-
case import_fixparser3.MDEntryType.TradingSessionHighPrice:
|
|
1073
|
-
data.tradingSessionHighPrice = price;
|
|
1074
|
-
break;
|
|
1075
|
-
case import_fixparser3.MDEntryType.TradingSessionLowPrice:
|
|
1076
|
-
data.tradingSessionLowPrice = price;
|
|
1077
|
-
break;
|
|
1078
|
-
case import_fixparser3.MDEntryType.VWAP:
|
|
1079
|
-
data.vwap = price;
|
|
1080
|
-
break;
|
|
1081
|
-
case import_fixparser3.MDEntryType.Imbalance:
|
|
1082
|
-
data.imbalance = size;
|
|
1083
|
-
break;
|
|
1084
|
-
case import_fixparser3.MDEntryType.TradeVolume:
|
|
1085
|
-
data.volume = size;
|
|
1086
|
-
break;
|
|
1087
|
-
case import_fixparser3.MDEntryType.OpenInterest:
|
|
1088
|
-
data.openInterest = size;
|
|
1089
|
-
break;
|
|
1090
|
-
case import_fixparser3.MDEntryType.CompositeUnderlyingPrice:
|
|
1091
|
-
data.compositeUnderlyingPrice = price;
|
|
1092
|
-
break;
|
|
1093
|
-
case import_fixparser3.MDEntryType.SimulatedSellPrice:
|
|
1094
|
-
data.simulatedSellPrice = price;
|
|
1095
|
-
break;
|
|
1096
|
-
case import_fixparser3.MDEntryType.SimulatedBuyPrice:
|
|
1097
|
-
data.simulatedBuyPrice = price;
|
|
1098
|
-
break;
|
|
1099
|
-
case import_fixparser3.MDEntryType.MarginRate:
|
|
1100
|
-
data.marginRate = price;
|
|
1101
|
-
break;
|
|
1102
|
-
case import_fixparser3.MDEntryType.MidPrice:
|
|
1103
|
-
data.midPrice = price;
|
|
1104
|
-
break;
|
|
1105
|
-
case import_fixparser3.MDEntryType.EmptyBook:
|
|
1106
|
-
data.emptyBook = 1;
|
|
1107
|
-
break;
|
|
1108
|
-
case import_fixparser3.MDEntryType.SettleHighPrice:
|
|
1109
|
-
data.settleHighPrice = price;
|
|
1110
|
-
break;
|
|
1111
|
-
case import_fixparser3.MDEntryType.SettleLowPrice:
|
|
1112
|
-
data.settleLowPrice = price;
|
|
1113
|
-
break;
|
|
1114
|
-
case import_fixparser3.MDEntryType.PriorSettlePrice:
|
|
1115
|
-
data.priorSettlePrice = price;
|
|
1116
|
-
break;
|
|
1117
|
-
case import_fixparser3.MDEntryType.SessionHighBid:
|
|
1118
|
-
data.sessionHighBid = price;
|
|
1119
|
-
break;
|
|
1120
|
-
case import_fixparser3.MDEntryType.SessionLowOffer:
|
|
1121
|
-
data.sessionLowOffer = price;
|
|
1122
|
-
break;
|
|
1123
|
-
case import_fixparser3.MDEntryType.EarlyPrices:
|
|
1124
|
-
data.earlyPrices = price;
|
|
1125
|
-
break;
|
|
1126
|
-
case import_fixparser3.MDEntryType.AuctionClearingPrice:
|
|
1127
|
-
data.auctionClearingPrice = price;
|
|
1128
|
-
break;
|
|
1129
|
-
case import_fixparser3.MDEntryType.SwapValueFactor:
|
|
1130
|
-
data.swapValueFactor = price;
|
|
1131
|
-
break;
|
|
1132
|
-
case import_fixparser3.MDEntryType.DailyValueAdjustmentForLongPositions:
|
|
1133
|
-
data.dailyValueAdjustmentForLongPositions = price;
|
|
1134
|
-
break;
|
|
1135
|
-
case import_fixparser3.MDEntryType.CumulativeValueAdjustmentForLongPositions:
|
|
1136
|
-
data.cumulativeValueAdjustmentForLongPositions = price;
|
|
1137
|
-
break;
|
|
1138
|
-
case import_fixparser3.MDEntryType.DailyValueAdjustmentForShortPositions:
|
|
1139
|
-
data.dailyValueAdjustmentForShortPositions = price;
|
|
1140
|
-
break;
|
|
1141
|
-
case import_fixparser3.MDEntryType.CumulativeValueAdjustmentForShortPositions:
|
|
1142
|
-
data.cumulativeValueAdjustmentForShortPositions = price;
|
|
1143
|
-
break;
|
|
1144
|
-
case import_fixparser3.MDEntryType.FixingPrice:
|
|
1145
|
-
data.fixingPrice = price;
|
|
1146
|
-
break;
|
|
1147
|
-
case import_fixparser3.MDEntryType.CashRate:
|
|
1148
|
-
data.cashRate = price;
|
|
1149
|
-
break;
|
|
1150
|
-
case import_fixparser3.MDEntryType.RecoveryRate:
|
|
1151
|
-
data.recoveryRate = price;
|
|
1152
|
-
break;
|
|
1153
|
-
case import_fixparser3.MDEntryType.RecoveryRateForLong:
|
|
1154
|
-
data.recoveryRateForLong = price;
|
|
1155
|
-
break;
|
|
1156
|
-
case import_fixparser3.MDEntryType.RecoveryRateForShort:
|
|
1157
|
-
data.recoveryRateForShort = price;
|
|
1158
|
-
break;
|
|
1159
|
-
case import_fixparser3.MDEntryType.MarketBid:
|
|
1160
|
-
data.marketBid = price;
|
|
1161
|
-
break;
|
|
1162
|
-
case import_fixparser3.MDEntryType.MarketOffer:
|
|
1163
|
-
data.marketOffer = price;
|
|
1164
|
-
break;
|
|
1165
|
-
case import_fixparser3.MDEntryType.ShortSaleMinPrice:
|
|
1166
|
-
data.shortSaleMinPrice = price;
|
|
1167
|
-
break;
|
|
1168
|
-
case import_fixparser3.MDEntryType.PreviousClosingPrice:
|
|
1169
|
-
data.previousClosingPrice = price;
|
|
1170
|
-
break;
|
|
1171
|
-
case import_fixparser3.MDEntryType.ThresholdLimitPriceBanding:
|
|
1172
|
-
data.thresholdLimitPriceBanding = price;
|
|
1173
|
-
break;
|
|
1174
|
-
case import_fixparser3.MDEntryType.DailyFinancingValue:
|
|
1175
|
-
data.dailyFinancingValue = price;
|
|
1176
|
-
break;
|
|
1177
|
-
case import_fixparser3.MDEntryType.AccruedFinancingValue:
|
|
1178
|
-
data.accruedFinancingValue = price;
|
|
1179
|
-
break;
|
|
1180
|
-
case import_fixparser3.MDEntryType.TWAP:
|
|
1181
|
-
data.twap = price;
|
|
1182
|
-
break;
|
|
849
|
+
const entries = message.getField(import_fixparser3.Fields.NoMDEntries)?.value;
|
|
850
|
+
let bid = 0;
|
|
851
|
+
let offer = 0;
|
|
852
|
+
let volume = 0;
|
|
853
|
+
const entryTypes = message.getFields(import_fixparser3.Fields.MDEntryType);
|
|
854
|
+
const entryPrices = message.getFields(import_fixparser3.Fields.MDEntryPx);
|
|
855
|
+
const entrySizes = message.getFields(import_fixparser3.Fields.MDEntrySize);
|
|
856
|
+
if (entryTypes && entryPrices && entrySizes) {
|
|
857
|
+
for (let i = 0; i < entries; i++) {
|
|
858
|
+
const entryType = entryTypes[i]?.value;
|
|
859
|
+
const entryPrice = Number.parseFloat(entryPrices[i]?.value);
|
|
860
|
+
const entrySize = Number.parseFloat(entrySizes[i]?.value);
|
|
861
|
+
if (entryType === import_fixparser3.MDEntryType.Bid) {
|
|
862
|
+
bid = entryPrice;
|
|
863
|
+
} else if (entryType === import_fixparser3.MDEntryType.Offer) {
|
|
864
|
+
offer = entryPrice;
|
|
865
|
+
}
|
|
866
|
+
volume += entrySize;
|
|
1183
867
|
}
|
|
1184
868
|
}
|
|
1185
|
-
|
|
869
|
+
const spread = offer - bid;
|
|
870
|
+
const timestamp = Date.now();
|
|
871
|
+
const data = {
|
|
872
|
+
timestamp,
|
|
873
|
+
bid,
|
|
874
|
+
offer,
|
|
875
|
+
spread,
|
|
876
|
+
volume
|
|
877
|
+
};
|
|
1186
878
|
if (!marketDataPrices.has(symbol)) {
|
|
1187
|
-
parser.logger.log({
|
|
1188
|
-
level: "info",
|
|
1189
|
-
message: `Creating new price history array for symbol: ${symbol}`
|
|
1190
|
-
});
|
|
1191
879
|
marketDataPrices.set(symbol, []);
|
|
1192
880
|
}
|
|
1193
881
|
const prices = marketDataPrices.get(symbol);
|
|
1194
882
|
prices.push(data);
|
|
1195
|
-
parser.logger.log({
|
|
1196
|
-
level: "info",
|
|
1197
|
-
message: `Updated price history for ${symbol}. Current size: ${prices.length}`
|
|
1198
|
-
});
|
|
1199
883
|
if (prices.length > maxPriceHistory) {
|
|
1200
884
|
prices.splice(0, prices.length - maxPriceHistory);
|
|
1201
|
-
parser.logger.log({
|
|
1202
|
-
level: "info",
|
|
1203
|
-
message: `Trimmed price history for ${symbol} to ${maxPriceHistory} entries`
|
|
1204
|
-
});
|
|
1205
885
|
}
|
|
1206
886
|
onPriceUpdate?.(symbol, data);
|
|
1207
|
-
const mdReqID = message.getField(import_fixparser3.Fields.MDReqID)?.value;
|
|
1208
|
-
if (mdReqID) {
|
|
1209
|
-
const callback = pendingRequests.get(mdReqID);
|
|
1210
|
-
if (callback) {
|
|
1211
|
-
callback(message);
|
|
1212
|
-
pendingRequests.delete(mdReqID);
|
|
1213
|
-
parser.logger.log({
|
|
1214
|
-
level: "info",
|
|
1215
|
-
message: `Resolved market data request for ID: ${mdReqID}`
|
|
1216
|
-
});
|
|
1217
|
-
}
|
|
1218
|
-
}
|
|
1219
887
|
} else if (msgType === import_fixparser3.Messages.ExecutionReport) {
|
|
1220
888
|
const reqId = message.getField(import_fixparser3.Fields.ClOrdID)?.value;
|
|
1221
889
|
const callback = pendingRequests.get(reqId);
|
|
@@ -1244,7 +912,7 @@ var MCPLocal = class extends MCPBase {
|
|
|
1244
912
|
*/
|
|
1245
913
|
marketDataPrices = /* @__PURE__ */ new Map();
|
|
1246
914
|
/**
|
|
1247
|
-
* Maximum number of price
|
|
915
|
+
* Maximum number of price points to store per symbol
|
|
1248
916
|
* @private
|
|
1249
917
|
*/
|
|
1250
918
|
MAX_PRICE_HISTORY = 1e5;
|