@forgecharts/sdk 1.3.12 → 1.4.0

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.
@@ -22902,7 +22902,10 @@ var ChartCanvas = forwardRef(
22902
22902
  const order = chart.getTradingOverlayStore()?.getOrders().find((o) => o.id === orderId);
22903
22903
  const isBracketLeg = order?.role === "take_profit" || order?.role === "stop_loss";
22904
22904
  if (isBracketLeg) {
22905
- if (!canUseBracketOrders()) return;
22905
+ if (!canUseBracketOrders()) {
22906
+ console.warn("[ForgeCharts] TP/SL drag ignored \u2014 the `bracketOrders` feature is not enabled on the active license, so no bracket_adjust intent was dispatched.");
22907
+ return;
22908
+ }
22906
22909
  void bridge.onBracketAdjustIntent?.({
22907
22910
  type: "bracket_adjust",
22908
22911
  entryOrderId: order?.groupId ?? orderId,
@@ -22911,7 +22914,10 @@ var ChartCanvas = forwardRef(
22911
22914
  timestamp: Date.now()
22912
22915
  });
22913
22916
  } else {
22914
- if (!canUseDraggableOrders()) return;
22917
+ if (!canUseDraggableOrders()) {
22918
+ console.warn("[ForgeCharts] Order drag ignored \u2014 the `draggableOrders` feature is not enabled on the active license, so no modify intent was dispatched.");
22919
+ return;
22920
+ }
22915
22921
  void bridge.onModifyOrderIntent?.({
22916
22922
  type: "modify",
22917
22923
  orderId,
@@ -22927,7 +22933,11 @@ var ChartCanvas = forwardRef(
22927
22933
  return;
22928
22934
  }
22929
22935
  const bridge = tradingBridgeRef.current;
22930
- if (!bridge || !canUseBracketOrders()) return;
22936
+ if (!bridge) return;
22937
+ if (!canUseBracketOrders()) {
22938
+ console.warn("[ForgeCharts] TP/SL pill drag ignored \u2014 the `bracketOrders` feature is not enabled on the active license, so no bracket_adjust intent was dispatched.");
22939
+ return;
22940
+ }
22931
22941
  void bridge.onBracketAdjustIntent?.({
22932
22942
  type: "bracket_adjust",
22933
22943
  entryOrderId,
@@ -26314,6 +26324,161 @@ function RightToolbar({
26314
26324
  }
26315
26325
  );
26316
26326
  }
26327
+
26328
+ // src/react/agent/contractUtils.ts
26329
+ var MONTH_CODE_MAP = {
26330
+ F: "January",
26331
+ G: "February",
26332
+ H: "March",
26333
+ J: "April",
26334
+ K: "May",
26335
+ M: "June",
26336
+ N: "July",
26337
+ Q: "August",
26338
+ U: "September",
26339
+ V: "October",
26340
+ X: "November",
26341
+ Z: "December"
26342
+ };
26343
+ var PRODUCTS = {
26344
+ // CME Equity Index
26345
+ ES: { exchange: "CME", months: ["H", "M", "U", "Z"] },
26346
+ MES: { exchange: "CME", months: ["H", "M", "U", "Z"] },
26347
+ NQ: { exchange: "CME", months: ["H", "M", "U", "Z"] },
26348
+ MNQ: { exchange: "CME", months: ["H", "M", "U", "Z"] },
26349
+ RTY: { exchange: "CME", months: ["H", "M", "U", "Z"] },
26350
+ M2K: { exchange: "CME", months: ["H", "M", "U", "Z"] },
26351
+ NKD: { exchange: "CME", months: ["H", "M", "U", "Z"] },
26352
+ // CBOT Equity Index
26353
+ YM: { exchange: "CBOT", months: ["H", "M", "U", "Z"] },
26354
+ MYM: { exchange: "CBOT", months: ["H", "M", "U", "Z"] },
26355
+ // CME FX
26356
+ "6E": { exchange: "CME", months: ["H", "M", "U", "Z"] },
26357
+ "6B": { exchange: "CME", months: ["H", "M", "U", "Z"] },
26358
+ "6J": { exchange: "CME", months: ["H", "M", "U", "Z"] },
26359
+ "6A": { exchange: "CME", months: ["H", "M", "U", "Z"] },
26360
+ "6C": { exchange: "CME", months: ["H", "M", "U", "Z"] },
26361
+ // NYMEX Energy
26362
+ CL: { exchange: "NYMEX", months: ["F", "G", "H", "J", "K", "M", "N", "Q", "U", "V", "X", "Z"] },
26363
+ QM: { exchange: "NYMEX", months: ["F", "G", "H", "J", "K", "M", "N", "Q", "U", "V", "X", "Z"] },
26364
+ MCL: { exchange: "NYMEX", months: ["F", "G", "H", "J", "K", "M", "N", "Q", "U", "V", "X", "Z"] },
26365
+ NG: { exchange: "NYMEX", months: ["F", "G", "H", "J", "K", "M", "N", "Q", "U", "V", "X", "Z"] },
26366
+ HO: { exchange: "NYMEX", months: ["F", "G", "H", "J", "K", "M", "N", "Q", "U", "V", "X", "Z"] },
26367
+ RB: { exchange: "NYMEX", months: ["F", "G", "H", "J", "K", "M", "N", "Q", "U", "V", "X", "Z"] },
26368
+ // COMEX Metals
26369
+ GC: { exchange: "COMEX", months: ["G", "J", "M", "Q", "V", "Z"] },
26370
+ MGC: { exchange: "COMEX", months: ["G", "J", "M", "Q", "V", "Z"] },
26371
+ SI: { exchange: "COMEX", months: ["H", "K", "N", "U", "Z"] },
26372
+ HG: { exchange: "COMEX", months: ["H", "K", "N", "U", "Z"] },
26373
+ // CBOT Grains
26374
+ ZC: { exchange: "CBOT", months: ["H", "K", "N", "U", "Z"] },
26375
+ ZS: { exchange: "CBOT", months: ["F", "H", "K", "N", "Q", "U", "X"] },
26376
+ ZW: { exchange: "CBOT", months: ["H", "K", "N", "U", "Z"] },
26377
+ // CBOT Interest Rates
26378
+ ZB: { exchange: "CBOT", months: ["H", "M", "U", "Z"] },
26379
+ ZN: { exchange: "CBOT", months: ["H", "M", "U", "Z"] },
26380
+ ZF: { exchange: "CBOT", months: ["H", "M", "U", "Z"] },
26381
+ ZT: { exchange: "CBOT", months: ["H", "M", "U", "Z"] }
26382
+ };
26383
+ var MC_INDEX = {
26384
+ F: 0,
26385
+ G: 1,
26386
+ H: 2,
26387
+ J: 3,
26388
+ K: 4,
26389
+ M: 5,
26390
+ N: 6,
26391
+ Q: 7,
26392
+ U: 8,
26393
+ V: 9,
26394
+ X: 10,
26395
+ Z: 11
26396
+ };
26397
+ function parseContractInfo(symbol) {
26398
+ let input = symbol.trim().toUpperCase();
26399
+ let exchangeHint;
26400
+ if (input.includes(":")) {
26401
+ const colon = input.indexOf(":");
26402
+ exchangeHint = input.slice(0, colon);
26403
+ input = input.slice(colon + 1);
26404
+ }
26405
+ const contMatch = input.match(/^([A-Z0-9]+?)(\d+)!$/);
26406
+ if (contMatch) {
26407
+ const product = contMatch[1];
26408
+ const info = PRODUCTS[product];
26409
+ if (!info) return null;
26410
+ const exchange = exchangeHint ?? info.exchange;
26411
+ const front = _guessFrontMonth(product, info.months);
26412
+ return {
26413
+ isContinuous: true,
26414
+ product,
26415
+ exchange,
26416
+ frontMonthContract: `${exchange}:${front}`,
26417
+ continuousSymbol: `${exchange}:${product}1!`,
26418
+ availableMonths: info.months
26419
+ };
26420
+ }
26421
+ const specificMatch = input.match(/^([A-Z0-9]+?)([FGHJKMNQUVXZ])(\d{1,4})$/);
26422
+ if (specificMatch) {
26423
+ const product = specificMatch[1];
26424
+ const info = PRODUCTS[product];
26425
+ if (!info) return null;
26426
+ const exchange = exchangeHint ?? info.exchange;
26427
+ const front = _guessFrontMonth(product, info.months);
26428
+ return {
26429
+ isContinuous: false,
26430
+ product,
26431
+ exchange,
26432
+ frontMonthContract: `${exchange}:${front}`,
26433
+ continuousSymbol: `${exchange}:${product}1!`,
26434
+ availableMonths: info.months
26435
+ };
26436
+ }
26437
+ if (PRODUCTS[input]) {
26438
+ const info = PRODUCTS[input];
26439
+ const exchange = exchangeHint ?? info.exchange;
26440
+ const front = _guessFrontMonth(input, info.months);
26441
+ return {
26442
+ isContinuous: false,
26443
+ product: input,
26444
+ exchange,
26445
+ frontMonthContract: `${exchange}:${front}`,
26446
+ continuousSymbol: `${exchange}:${input}1!`,
26447
+ availableMonths: info.months
26448
+ };
26449
+ }
26450
+ return null;
26451
+ }
26452
+ function getUpcomingContracts(product, exchange, months, count = 6) {
26453
+ const now = /* @__PURE__ */ new Date();
26454
+ const currentMonth = now.getMonth();
26455
+ const currentYear = now.getFullYear();
26456
+ const contracts = [];
26457
+ for (let yearOffset = 0; yearOffset <= 2 && contracts.length < count; yearOffset++) {
26458
+ const year = currentYear + yearOffset;
26459
+ for (const mc of months) {
26460
+ if (contracts.length >= count) break;
26461
+ const monthIdx = MC_INDEX[mc];
26462
+ if (monthIdx === void 0) continue;
26463
+ if (year === currentYear && monthIdx < currentMonth) continue;
26464
+ contracts.push(`${exchange}:${product}${mc}${year}`);
26465
+ }
26466
+ }
26467
+ return contracts;
26468
+ }
26469
+ function _guessFrontMonth(product, months) {
26470
+ const now = /* @__PURE__ */ new Date();
26471
+ const currentMonth = now.getMonth();
26472
+ const currentYear = now.getFullYear();
26473
+ for (const mc of months) {
26474
+ const monthIdx = MC_INDEX[mc];
26475
+ if (monthIdx === void 0) continue;
26476
+ if (monthIdx >= currentMonth) {
26477
+ return `${product}${mc}${currentYear}`;
26478
+ }
26479
+ }
26480
+ return `${product}${months[0]}${currentYear + 1}`;
26481
+ }
26317
26482
  var TIMEZONE_OPTIONS = [
26318
26483
  { label: "UTC", value: "UTC" },
26319
26484
  { label: "Exchange", value: "exchange" },
@@ -26477,7 +26642,8 @@ var CRYPTO_EXCHANGES = /* @__PURE__ */ new Set([
26477
26642
  ]);
26478
26643
  function symbolSupportsSession(symbol) {
26479
26644
  const exchange = symbol.includes(":") ? symbol.split(":")[0].toUpperCase() : "";
26480
- return exchange !== "" && !CRYPTO_EXCHANGES.has(exchange);
26645
+ if (exchange !== "") return !CRYPTO_EXCHANGES.has(exchange);
26646
+ return parseContractInfo(symbol) !== null;
26481
26647
  }
26482
26648
  function useClockTime(timezone) {
26483
26649
  const [time, setTime] = useState(() => _formatClock(timezone));
@@ -32544,161 +32710,6 @@ function AssistantPanel({ onClose, chartContext }) {
32544
32710
  ] });
32545
32711
  }
32546
32712
 
32547
- // src/react/agent/contractUtils.ts
32548
- var MONTH_CODE_MAP = {
32549
- F: "January",
32550
- G: "February",
32551
- H: "March",
32552
- J: "April",
32553
- K: "May",
32554
- M: "June",
32555
- N: "July",
32556
- Q: "August",
32557
- U: "September",
32558
- V: "October",
32559
- X: "November",
32560
- Z: "December"
32561
- };
32562
- var PRODUCTS = {
32563
- // CME Equity Index
32564
- ES: { exchange: "CME", months: ["H", "M", "U", "Z"] },
32565
- MES: { exchange: "CME", months: ["H", "M", "U", "Z"] },
32566
- NQ: { exchange: "CME", months: ["H", "M", "U", "Z"] },
32567
- MNQ: { exchange: "CME", months: ["H", "M", "U", "Z"] },
32568
- RTY: { exchange: "CME", months: ["H", "M", "U", "Z"] },
32569
- M2K: { exchange: "CME", months: ["H", "M", "U", "Z"] },
32570
- NKD: { exchange: "CME", months: ["H", "M", "U", "Z"] },
32571
- // CBOT Equity Index
32572
- YM: { exchange: "CBOT", months: ["H", "M", "U", "Z"] },
32573
- MYM: { exchange: "CBOT", months: ["H", "M", "U", "Z"] },
32574
- // CME FX
32575
- "6E": { exchange: "CME", months: ["H", "M", "U", "Z"] },
32576
- "6B": { exchange: "CME", months: ["H", "M", "U", "Z"] },
32577
- "6J": { exchange: "CME", months: ["H", "M", "U", "Z"] },
32578
- "6A": { exchange: "CME", months: ["H", "M", "U", "Z"] },
32579
- "6C": { exchange: "CME", months: ["H", "M", "U", "Z"] },
32580
- // NYMEX Energy
32581
- CL: { exchange: "NYMEX", months: ["F", "G", "H", "J", "K", "M", "N", "Q", "U", "V", "X", "Z"] },
32582
- QM: { exchange: "NYMEX", months: ["F", "G", "H", "J", "K", "M", "N", "Q", "U", "V", "X", "Z"] },
32583
- MCL: { exchange: "NYMEX", months: ["F", "G", "H", "J", "K", "M", "N", "Q", "U", "V", "X", "Z"] },
32584
- NG: { exchange: "NYMEX", months: ["F", "G", "H", "J", "K", "M", "N", "Q", "U", "V", "X", "Z"] },
32585
- HO: { exchange: "NYMEX", months: ["F", "G", "H", "J", "K", "M", "N", "Q", "U", "V", "X", "Z"] },
32586
- RB: { exchange: "NYMEX", months: ["F", "G", "H", "J", "K", "M", "N", "Q", "U", "V", "X", "Z"] },
32587
- // COMEX Metals
32588
- GC: { exchange: "COMEX", months: ["G", "J", "M", "Q", "V", "Z"] },
32589
- MGC: { exchange: "COMEX", months: ["G", "J", "M", "Q", "V", "Z"] },
32590
- SI: { exchange: "COMEX", months: ["H", "K", "N", "U", "Z"] },
32591
- HG: { exchange: "COMEX", months: ["H", "K", "N", "U", "Z"] },
32592
- // CBOT Grains
32593
- ZC: { exchange: "CBOT", months: ["H", "K", "N", "U", "Z"] },
32594
- ZS: { exchange: "CBOT", months: ["F", "H", "K", "N", "Q", "U", "X"] },
32595
- ZW: { exchange: "CBOT", months: ["H", "K", "N", "U", "Z"] },
32596
- // CBOT Interest Rates
32597
- ZB: { exchange: "CBOT", months: ["H", "M", "U", "Z"] },
32598
- ZN: { exchange: "CBOT", months: ["H", "M", "U", "Z"] },
32599
- ZF: { exchange: "CBOT", months: ["H", "M", "U", "Z"] },
32600
- ZT: { exchange: "CBOT", months: ["H", "M", "U", "Z"] }
32601
- };
32602
- var MC_INDEX = {
32603
- F: 0,
32604
- G: 1,
32605
- H: 2,
32606
- J: 3,
32607
- K: 4,
32608
- M: 5,
32609
- N: 6,
32610
- Q: 7,
32611
- U: 8,
32612
- V: 9,
32613
- X: 10,
32614
- Z: 11
32615
- };
32616
- function parseContractInfo(symbol) {
32617
- let input = symbol.trim().toUpperCase();
32618
- let exchangeHint;
32619
- if (input.includes(":")) {
32620
- const colon = input.indexOf(":");
32621
- exchangeHint = input.slice(0, colon);
32622
- input = input.slice(colon + 1);
32623
- }
32624
- const contMatch = input.match(/^([A-Z0-9]+?)(\d+)!$/);
32625
- if (contMatch) {
32626
- const product = contMatch[1];
32627
- const info = PRODUCTS[product];
32628
- if (!info) return null;
32629
- const exchange = exchangeHint ?? info.exchange;
32630
- const front = _guessFrontMonth(product, info.months);
32631
- return {
32632
- isContinuous: true,
32633
- product,
32634
- exchange,
32635
- frontMonthContract: `${exchange}:${front}`,
32636
- continuousSymbol: `${exchange}:${product}1!`,
32637
- availableMonths: info.months
32638
- };
32639
- }
32640
- const specificMatch = input.match(/^([A-Z0-9]+?)([FGHJKMNQUVXZ])(\d{1,4})$/);
32641
- if (specificMatch) {
32642
- const product = specificMatch[1];
32643
- const info = PRODUCTS[product];
32644
- if (!info) return null;
32645
- const exchange = exchangeHint ?? info.exchange;
32646
- const front = _guessFrontMonth(product, info.months);
32647
- return {
32648
- isContinuous: false,
32649
- product,
32650
- exchange,
32651
- frontMonthContract: `${exchange}:${front}`,
32652
- continuousSymbol: `${exchange}:${product}1!`,
32653
- availableMonths: info.months
32654
- };
32655
- }
32656
- if (PRODUCTS[input]) {
32657
- const info = PRODUCTS[input];
32658
- const exchange = exchangeHint ?? info.exchange;
32659
- const front = _guessFrontMonth(input, info.months);
32660
- return {
32661
- isContinuous: false,
32662
- product: input,
32663
- exchange,
32664
- frontMonthContract: `${exchange}:${front}`,
32665
- continuousSymbol: `${exchange}:${input}1!`,
32666
- availableMonths: info.months
32667
- };
32668
- }
32669
- return null;
32670
- }
32671
- function getUpcomingContracts(product, exchange, months, count = 6) {
32672
- const now = /* @__PURE__ */ new Date();
32673
- const currentMonth = now.getMonth();
32674
- const currentYear = now.getFullYear();
32675
- const contracts = [];
32676
- for (let yearOffset = 0; yearOffset <= 2 && contracts.length < count; yearOffset++) {
32677
- const year = currentYear + yearOffset;
32678
- for (const mc of months) {
32679
- if (contracts.length >= count) break;
32680
- const monthIdx = MC_INDEX[mc];
32681
- if (monthIdx === void 0) continue;
32682
- if (year === currentYear && monthIdx < currentMonth) continue;
32683
- contracts.push(`${exchange}:${product}${mc}${year}`);
32684
- }
32685
- }
32686
- return contracts;
32687
- }
32688
- function _guessFrontMonth(product, months) {
32689
- const now = /* @__PURE__ */ new Date();
32690
- const currentMonth = now.getMonth();
32691
- const currentYear = now.getFullYear();
32692
- for (const mc of months) {
32693
- const monthIdx = MC_INDEX[mc];
32694
- if (monthIdx === void 0) continue;
32695
- if (monthIdx >= currentMonth) {
32696
- return `${product}${mc}${currentYear}`;
32697
- }
32698
- }
32699
- return `${product}${months[0]}${currentYear + 1}`;
32700
- }
32701
-
32702
32713
  // src/react/agent/CommandDispatcher.ts
32703
32714
  var CommandDispatcher = class {
32704
32715
  constructor(chart) {