@forgecharts/sdk 1.3.12 → 1.3.13

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.
@@ -26089,6 +26089,161 @@ function RightToolbar({
26089
26089
  }
26090
26090
  );
26091
26091
  }
26092
+
26093
+ // src/react/agent/contractUtils.ts
26094
+ var MONTH_CODE_MAP = {
26095
+ F: "January",
26096
+ G: "February",
26097
+ H: "March",
26098
+ J: "April",
26099
+ K: "May",
26100
+ M: "June",
26101
+ N: "July",
26102
+ Q: "August",
26103
+ U: "September",
26104
+ V: "October",
26105
+ X: "November",
26106
+ Z: "December"
26107
+ };
26108
+ var PRODUCTS = {
26109
+ // CME Equity Index
26110
+ ES: { exchange: "CME", months: ["H", "M", "U", "Z"] },
26111
+ MES: { exchange: "CME", months: ["H", "M", "U", "Z"] },
26112
+ NQ: { exchange: "CME", months: ["H", "M", "U", "Z"] },
26113
+ MNQ: { exchange: "CME", months: ["H", "M", "U", "Z"] },
26114
+ RTY: { exchange: "CME", months: ["H", "M", "U", "Z"] },
26115
+ M2K: { exchange: "CME", months: ["H", "M", "U", "Z"] },
26116
+ NKD: { exchange: "CME", months: ["H", "M", "U", "Z"] },
26117
+ // CBOT Equity Index
26118
+ YM: { exchange: "CBOT", months: ["H", "M", "U", "Z"] },
26119
+ MYM: { exchange: "CBOT", months: ["H", "M", "U", "Z"] },
26120
+ // CME FX
26121
+ "6E": { exchange: "CME", months: ["H", "M", "U", "Z"] },
26122
+ "6B": { exchange: "CME", months: ["H", "M", "U", "Z"] },
26123
+ "6J": { exchange: "CME", months: ["H", "M", "U", "Z"] },
26124
+ "6A": { exchange: "CME", months: ["H", "M", "U", "Z"] },
26125
+ "6C": { exchange: "CME", months: ["H", "M", "U", "Z"] },
26126
+ // NYMEX Energy
26127
+ CL: { exchange: "NYMEX", months: ["F", "G", "H", "J", "K", "M", "N", "Q", "U", "V", "X", "Z"] },
26128
+ QM: { exchange: "NYMEX", months: ["F", "G", "H", "J", "K", "M", "N", "Q", "U", "V", "X", "Z"] },
26129
+ MCL: { exchange: "NYMEX", months: ["F", "G", "H", "J", "K", "M", "N", "Q", "U", "V", "X", "Z"] },
26130
+ NG: { exchange: "NYMEX", months: ["F", "G", "H", "J", "K", "M", "N", "Q", "U", "V", "X", "Z"] },
26131
+ HO: { exchange: "NYMEX", months: ["F", "G", "H", "J", "K", "M", "N", "Q", "U", "V", "X", "Z"] },
26132
+ RB: { exchange: "NYMEX", months: ["F", "G", "H", "J", "K", "M", "N", "Q", "U", "V", "X", "Z"] },
26133
+ // COMEX Metals
26134
+ GC: { exchange: "COMEX", months: ["G", "J", "M", "Q", "V", "Z"] },
26135
+ MGC: { exchange: "COMEX", months: ["G", "J", "M", "Q", "V", "Z"] },
26136
+ SI: { exchange: "COMEX", months: ["H", "K", "N", "U", "Z"] },
26137
+ HG: { exchange: "COMEX", months: ["H", "K", "N", "U", "Z"] },
26138
+ // CBOT Grains
26139
+ ZC: { exchange: "CBOT", months: ["H", "K", "N", "U", "Z"] },
26140
+ ZS: { exchange: "CBOT", months: ["F", "H", "K", "N", "Q", "U", "X"] },
26141
+ ZW: { exchange: "CBOT", months: ["H", "K", "N", "U", "Z"] },
26142
+ // CBOT Interest Rates
26143
+ ZB: { exchange: "CBOT", months: ["H", "M", "U", "Z"] },
26144
+ ZN: { exchange: "CBOT", months: ["H", "M", "U", "Z"] },
26145
+ ZF: { exchange: "CBOT", months: ["H", "M", "U", "Z"] },
26146
+ ZT: { exchange: "CBOT", months: ["H", "M", "U", "Z"] }
26147
+ };
26148
+ var MC_INDEX = {
26149
+ F: 0,
26150
+ G: 1,
26151
+ H: 2,
26152
+ J: 3,
26153
+ K: 4,
26154
+ M: 5,
26155
+ N: 6,
26156
+ Q: 7,
26157
+ U: 8,
26158
+ V: 9,
26159
+ X: 10,
26160
+ Z: 11
26161
+ };
26162
+ function parseContractInfo(symbol) {
26163
+ let input = symbol.trim().toUpperCase();
26164
+ let exchangeHint;
26165
+ if (input.includes(":")) {
26166
+ const colon = input.indexOf(":");
26167
+ exchangeHint = input.slice(0, colon);
26168
+ input = input.slice(colon + 1);
26169
+ }
26170
+ const contMatch = input.match(/^([A-Z0-9]+?)(\d+)!$/);
26171
+ if (contMatch) {
26172
+ const product = contMatch[1];
26173
+ const info = PRODUCTS[product];
26174
+ if (!info) return null;
26175
+ const exchange = exchangeHint ?? info.exchange;
26176
+ const front = _guessFrontMonth(product, info.months);
26177
+ return {
26178
+ isContinuous: true,
26179
+ product,
26180
+ exchange,
26181
+ frontMonthContract: `${exchange}:${front}`,
26182
+ continuousSymbol: `${exchange}:${product}1!`,
26183
+ availableMonths: info.months
26184
+ };
26185
+ }
26186
+ const specificMatch = input.match(/^([A-Z0-9]+?)([FGHJKMNQUVXZ])(\d{1,4})$/);
26187
+ if (specificMatch) {
26188
+ const product = specificMatch[1];
26189
+ const info = PRODUCTS[product];
26190
+ if (!info) return null;
26191
+ const exchange = exchangeHint ?? info.exchange;
26192
+ const front = _guessFrontMonth(product, info.months);
26193
+ return {
26194
+ isContinuous: false,
26195
+ product,
26196
+ exchange,
26197
+ frontMonthContract: `${exchange}:${front}`,
26198
+ continuousSymbol: `${exchange}:${product}1!`,
26199
+ availableMonths: info.months
26200
+ };
26201
+ }
26202
+ if (PRODUCTS[input]) {
26203
+ const info = PRODUCTS[input];
26204
+ const exchange = exchangeHint ?? info.exchange;
26205
+ const front = _guessFrontMonth(input, info.months);
26206
+ return {
26207
+ isContinuous: false,
26208
+ product: input,
26209
+ exchange,
26210
+ frontMonthContract: `${exchange}:${front}`,
26211
+ continuousSymbol: `${exchange}:${input}1!`,
26212
+ availableMonths: info.months
26213
+ };
26214
+ }
26215
+ return null;
26216
+ }
26217
+ function getUpcomingContracts(product, exchange, months, count = 6) {
26218
+ const now = /* @__PURE__ */ new Date();
26219
+ const currentMonth = now.getMonth();
26220
+ const currentYear = now.getFullYear();
26221
+ const contracts = [];
26222
+ for (let yearOffset = 0; yearOffset <= 2 && contracts.length < count; yearOffset++) {
26223
+ const year = currentYear + yearOffset;
26224
+ for (const mc of months) {
26225
+ if (contracts.length >= count) break;
26226
+ const monthIdx = MC_INDEX[mc];
26227
+ if (monthIdx === void 0) continue;
26228
+ if (year === currentYear && monthIdx < currentMonth) continue;
26229
+ contracts.push(`${exchange}:${product}${mc}${year}`);
26230
+ }
26231
+ }
26232
+ return contracts;
26233
+ }
26234
+ function _guessFrontMonth(product, months) {
26235
+ const now = /* @__PURE__ */ new Date();
26236
+ const currentMonth = now.getMonth();
26237
+ const currentYear = now.getFullYear();
26238
+ for (const mc of months) {
26239
+ const monthIdx = MC_INDEX[mc];
26240
+ if (monthIdx === void 0) continue;
26241
+ if (monthIdx >= currentMonth) {
26242
+ return `${product}${mc}${currentYear}`;
26243
+ }
26244
+ }
26245
+ return `${product}${months[0]}${currentYear + 1}`;
26246
+ }
26092
26247
  var TIMEZONE_OPTIONS = [
26093
26248
  { label: "UTC", value: "UTC" },
26094
26249
  { label: "Exchange", value: "exchange" },
@@ -26252,7 +26407,8 @@ var CRYPTO_EXCHANGES = /* @__PURE__ */ new Set([
26252
26407
  ]);
26253
26408
  function symbolSupportsSession(symbol) {
26254
26409
  const exchange = symbol.includes(":") ? symbol.split(":")[0].toUpperCase() : "";
26255
- return exchange !== "" && !CRYPTO_EXCHANGES.has(exchange);
26410
+ if (exchange !== "") return !CRYPTO_EXCHANGES.has(exchange);
26411
+ return parseContractInfo(symbol) !== null;
26256
26412
  }
26257
26413
  function useClockTime(timezone) {
26258
26414
  const [time, setTime] = useState(() => _formatClock(timezone));
@@ -32319,161 +32475,6 @@ function AssistantPanel({ onClose, chartContext }) {
32319
32475
  ] });
32320
32476
  }
32321
32477
 
32322
- // src/react/agent/contractUtils.ts
32323
- var MONTH_CODE_MAP = {
32324
- F: "January",
32325
- G: "February",
32326
- H: "March",
32327
- J: "April",
32328
- K: "May",
32329
- M: "June",
32330
- N: "July",
32331
- Q: "August",
32332
- U: "September",
32333
- V: "October",
32334
- X: "November",
32335
- Z: "December"
32336
- };
32337
- var PRODUCTS = {
32338
- // CME Equity Index
32339
- ES: { exchange: "CME", months: ["H", "M", "U", "Z"] },
32340
- MES: { exchange: "CME", months: ["H", "M", "U", "Z"] },
32341
- NQ: { exchange: "CME", months: ["H", "M", "U", "Z"] },
32342
- MNQ: { exchange: "CME", months: ["H", "M", "U", "Z"] },
32343
- RTY: { exchange: "CME", months: ["H", "M", "U", "Z"] },
32344
- M2K: { exchange: "CME", months: ["H", "M", "U", "Z"] },
32345
- NKD: { exchange: "CME", months: ["H", "M", "U", "Z"] },
32346
- // CBOT Equity Index
32347
- YM: { exchange: "CBOT", months: ["H", "M", "U", "Z"] },
32348
- MYM: { exchange: "CBOT", months: ["H", "M", "U", "Z"] },
32349
- // CME FX
32350
- "6E": { exchange: "CME", months: ["H", "M", "U", "Z"] },
32351
- "6B": { exchange: "CME", months: ["H", "M", "U", "Z"] },
32352
- "6J": { exchange: "CME", months: ["H", "M", "U", "Z"] },
32353
- "6A": { exchange: "CME", months: ["H", "M", "U", "Z"] },
32354
- "6C": { exchange: "CME", months: ["H", "M", "U", "Z"] },
32355
- // NYMEX Energy
32356
- CL: { exchange: "NYMEX", months: ["F", "G", "H", "J", "K", "M", "N", "Q", "U", "V", "X", "Z"] },
32357
- QM: { exchange: "NYMEX", months: ["F", "G", "H", "J", "K", "M", "N", "Q", "U", "V", "X", "Z"] },
32358
- MCL: { exchange: "NYMEX", months: ["F", "G", "H", "J", "K", "M", "N", "Q", "U", "V", "X", "Z"] },
32359
- NG: { exchange: "NYMEX", months: ["F", "G", "H", "J", "K", "M", "N", "Q", "U", "V", "X", "Z"] },
32360
- HO: { exchange: "NYMEX", months: ["F", "G", "H", "J", "K", "M", "N", "Q", "U", "V", "X", "Z"] },
32361
- RB: { exchange: "NYMEX", months: ["F", "G", "H", "J", "K", "M", "N", "Q", "U", "V", "X", "Z"] },
32362
- // COMEX Metals
32363
- GC: { exchange: "COMEX", months: ["G", "J", "M", "Q", "V", "Z"] },
32364
- MGC: { exchange: "COMEX", months: ["G", "J", "M", "Q", "V", "Z"] },
32365
- SI: { exchange: "COMEX", months: ["H", "K", "N", "U", "Z"] },
32366
- HG: { exchange: "COMEX", months: ["H", "K", "N", "U", "Z"] },
32367
- // CBOT Grains
32368
- ZC: { exchange: "CBOT", months: ["H", "K", "N", "U", "Z"] },
32369
- ZS: { exchange: "CBOT", months: ["F", "H", "K", "N", "Q", "U", "X"] },
32370
- ZW: { exchange: "CBOT", months: ["H", "K", "N", "U", "Z"] },
32371
- // CBOT Interest Rates
32372
- ZB: { exchange: "CBOT", months: ["H", "M", "U", "Z"] },
32373
- ZN: { exchange: "CBOT", months: ["H", "M", "U", "Z"] },
32374
- ZF: { exchange: "CBOT", months: ["H", "M", "U", "Z"] },
32375
- ZT: { exchange: "CBOT", months: ["H", "M", "U", "Z"] }
32376
- };
32377
- var MC_INDEX = {
32378
- F: 0,
32379
- G: 1,
32380
- H: 2,
32381
- J: 3,
32382
- K: 4,
32383
- M: 5,
32384
- N: 6,
32385
- Q: 7,
32386
- U: 8,
32387
- V: 9,
32388
- X: 10,
32389
- Z: 11
32390
- };
32391
- function parseContractInfo(symbol) {
32392
- let input = symbol.trim().toUpperCase();
32393
- let exchangeHint;
32394
- if (input.includes(":")) {
32395
- const colon = input.indexOf(":");
32396
- exchangeHint = input.slice(0, colon);
32397
- input = input.slice(colon + 1);
32398
- }
32399
- const contMatch = input.match(/^([A-Z0-9]+?)(\d+)!$/);
32400
- if (contMatch) {
32401
- const product = contMatch[1];
32402
- const info = PRODUCTS[product];
32403
- if (!info) return null;
32404
- const exchange = exchangeHint ?? info.exchange;
32405
- const front = _guessFrontMonth(product, info.months);
32406
- return {
32407
- isContinuous: true,
32408
- product,
32409
- exchange,
32410
- frontMonthContract: `${exchange}:${front}`,
32411
- continuousSymbol: `${exchange}:${product}1!`,
32412
- availableMonths: info.months
32413
- };
32414
- }
32415
- const specificMatch = input.match(/^([A-Z0-9]+?)([FGHJKMNQUVXZ])(\d{1,4})$/);
32416
- if (specificMatch) {
32417
- const product = specificMatch[1];
32418
- const info = PRODUCTS[product];
32419
- if (!info) return null;
32420
- const exchange = exchangeHint ?? info.exchange;
32421
- const front = _guessFrontMonth(product, info.months);
32422
- return {
32423
- isContinuous: false,
32424
- product,
32425
- exchange,
32426
- frontMonthContract: `${exchange}:${front}`,
32427
- continuousSymbol: `${exchange}:${product}1!`,
32428
- availableMonths: info.months
32429
- };
32430
- }
32431
- if (PRODUCTS[input]) {
32432
- const info = PRODUCTS[input];
32433
- const exchange = exchangeHint ?? info.exchange;
32434
- const front = _guessFrontMonth(input, info.months);
32435
- return {
32436
- isContinuous: false,
32437
- product: input,
32438
- exchange,
32439
- frontMonthContract: `${exchange}:${front}`,
32440
- continuousSymbol: `${exchange}:${input}1!`,
32441
- availableMonths: info.months
32442
- };
32443
- }
32444
- return null;
32445
- }
32446
- function getUpcomingContracts(product, exchange, months, count = 6) {
32447
- const now = /* @__PURE__ */ new Date();
32448
- const currentMonth = now.getMonth();
32449
- const currentYear = now.getFullYear();
32450
- const contracts = [];
32451
- for (let yearOffset = 0; yearOffset <= 2 && contracts.length < count; yearOffset++) {
32452
- const year = currentYear + yearOffset;
32453
- for (const mc of months) {
32454
- if (contracts.length >= count) break;
32455
- const monthIdx = MC_INDEX[mc];
32456
- if (monthIdx === void 0) continue;
32457
- if (year === currentYear && monthIdx < currentMonth) continue;
32458
- contracts.push(`${exchange}:${product}${mc}${year}`);
32459
- }
32460
- }
32461
- return contracts;
32462
- }
32463
- function _guessFrontMonth(product, months) {
32464
- const now = /* @__PURE__ */ new Date();
32465
- const currentMonth = now.getMonth();
32466
- const currentYear = now.getFullYear();
32467
- for (const mc of months) {
32468
- const monthIdx = MC_INDEX[mc];
32469
- if (monthIdx === void 0) continue;
32470
- if (monthIdx >= currentMonth) {
32471
- return `${product}${mc}${currentYear}`;
32472
- }
32473
- }
32474
- return `${product}${months[0]}${currentYear + 1}`;
32475
- }
32476
-
32477
32478
  // src/react/agent/CommandDispatcher.ts
32478
32479
  var CommandDispatcher = class {
32479
32480
  constructor(chart) {