tradeblocks-mcp 4.4.0 → 4.5.1

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.
Files changed (93) hide show
  1. package/README.md +31 -0
  2. package/dist/{chunk-ENXBPJ7Y.js → chunk-7F73I2XO.js} +59 -25
  3. package/dist/{chunk-ENXBPJ7Y.js.map → chunk-7F73I2XO.js.map} +1 -1
  4. package/dist/{chunk-CZNPQ574.js → chunk-VRAB46QT.js} +721 -602
  5. package/dist/chunk-VRAB46QT.js.map +1 -0
  6. package/dist/{chunk-35RVWZGT.js → chunk-VZIHINEU.js} +41 -3
  7. package/dist/chunk-VZIHINEU.js.map +1 -0
  8. package/dist/{chunk-5WRI5ZAA.js → chunk-YLJ4XMA6.js} +6 -2
  9. package/dist/{daily-log-processor-ZFTGQDOD.js → daily-log-processor-MDGQSXZF.js} +2 -2
  10. package/dist/{daily-logs-store-FZRIGYUX.js → daily-logs-store-JHUAAI5N.js} +2 -2
  11. package/dist/{daily-logs-store-MEZ5S3BR.js → daily-logs-store-VYEAQ3QA.js} +3 -3
  12. package/dist/market/provenance/index.d.ts +2 -1
  13. package/dist/market/provenance/index.js +15 -2
  14. package/dist/market/provenance/index.js.map +1 -1
  15. package/dist/{proto-V23GIZG2.js → proto-MNJ2RLM2.js} +2 -2
  16. package/dist/{sync-P6QUZFSF.js → sync-KL55HZQ6.js} +4 -4
  17. package/dist/test-exports.js +280 -550
  18. package/dist/test-exports.js.map +1 -1
  19. package/dist/{trade-processor-VJ3XUDTH.js → trade-processor-YBTG2WIA.js} +2 -2
  20. package/dist/{trades-store-PNLPRYRJ.js → trades-store-SZOQIYA4.js} +2 -2
  21. package/dist/{trades-store-3TOLBL2W.js → trades-store-XEOP35HD.js} +3 -3
  22. package/package.json +3 -3
  23. package/server/{chunk-PDSUY2X2.js → chunk-7GMTUEFR.js} +59 -25
  24. package/server/{chunk-PDSUY2X2.js.map → chunk-7GMTUEFR.js.map} +1 -1
  25. package/server/{chunk-5JTQEV7P.js → chunk-Q5DMZ2WG.js} +752 -633
  26. package/server/chunk-Q5DMZ2WG.js.map +1 -0
  27. package/server/{chunk-UT3JLF3M.js → chunk-YUBKEMYJ.js} +6 -2
  28. package/server/cli.d.ts +1 -1
  29. package/server/cli.js +1 -1
  30. package/server/{config-DK7KOMNL.js → config-IDH2S2DC.js} +2 -2
  31. package/server/{daily-log-processor-NXSUFX32.js → daily-log-processor-EKMBPCH5.js} +2 -2
  32. package/server/{daily-logs-store-LRVO7COL.js → daily-logs-store-TJUXTZG4.js} +3 -3
  33. package/server/index.d.ts +7 -8
  34. package/server/index.js +647 -659
  35. package/server/index.js.map +1 -1
  36. package/server/{proto-YZ4TLX2N.js → proto-L4NZHBZE.js} +2 -2
  37. package/server/{setup-4EJSSDL4.js → setup-QCRLIAAQ.js} +2 -2
  38. package/server/{sync-336543PJ.js → sync-WXQANQUJ.js} +4 -4
  39. package/server/{trade-processor-NYDJ3VMH.js → trade-processor-F3UOCOMW.js} +2 -2
  40. package/server/{trades-store-MXUZLSF5.js → trades-store-B54RYREL.js} +3 -3
  41. package/src/db/connection.ts +12 -8
  42. package/src/db/dataset-schemas.ts +5 -2
  43. package/src/db/legacy-option-migration.ts +99 -0
  44. package/src/db/market-datasets.ts +32 -2
  45. package/src/db/market-schemas.ts +5 -6
  46. package/src/db/market-views.ts +25 -6
  47. package/src/db/parquet-writer.ts +11 -4
  48. package/src/index.ts +5 -1
  49. package/src/market/stores/chain-store.ts +3 -4
  50. package/src/market/stores/index.ts +11 -25
  51. package/src/market/stores/parquet-chain-store.ts +20 -1
  52. package/src/market/stores/quote-store.ts +1 -2
  53. package/src/market/stores/types.ts +2 -3
  54. package/src/test-exports.ts +6 -4
  55. package/src/tools/analysis.ts +5 -3
  56. package/src/tools/batch-exit-analysis.ts +3 -3
  57. package/src/tools/blocks/analysis.ts +1 -1
  58. package/src/tools/blocks/similarity.ts +1 -1
  59. package/src/tools/exit-analysis.ts +2 -11
  60. package/src/tools/market-fetch.ts +1 -1
  61. package/src/tools/profile-analysis.ts +11 -6
  62. package/src/tools/replay.ts +91 -48
  63. package/src/tools/reports/fields.ts +1 -1
  64. package/src/tools/reports/helpers.ts +2 -1
  65. package/src/tools/reports/predictive.ts +145 -13
  66. package/src/tools/shared/field-analysis.ts +39 -25
  67. package/src/tools/shared/filter-objective.ts +10 -3
  68. package/src/utils/filter-curve.ts +264 -55
  69. package/src/utils/trade-analysis-fields.ts +8 -2
  70. package/src/utils/trade-replay.ts +101 -0
  71. package/dist/chunk-35RVWZGT.js.map +0 -1
  72. package/dist/chunk-CZNPQ574.js.map +0 -1
  73. package/server/chunk-5JTQEV7P.js.map +0 -1
  74. package/src/market/stores/duckdb-chain-store.ts +0 -90
  75. package/src/market/stores/duckdb-quote-store.ts +0 -386
  76. /package/dist/{chunk-5WRI5ZAA.js.map → chunk-YLJ4XMA6.js.map} +0 -0
  77. /package/dist/{daily-log-processor-ZFTGQDOD.js.map → daily-log-processor-MDGQSXZF.js.map} +0 -0
  78. /package/dist/{daily-logs-store-FZRIGYUX.js.map → daily-logs-store-JHUAAI5N.js.map} +0 -0
  79. /package/dist/{daily-logs-store-MEZ5S3BR.js.map → daily-logs-store-VYEAQ3QA.js.map} +0 -0
  80. /package/dist/{proto-V23GIZG2.js.map → proto-MNJ2RLM2.js.map} +0 -0
  81. /package/dist/{sync-P6QUZFSF.js.map → sync-KL55HZQ6.js.map} +0 -0
  82. /package/dist/{trade-processor-VJ3XUDTH.js.map → trade-processor-YBTG2WIA.js.map} +0 -0
  83. /package/dist/{trades-store-3TOLBL2W.js.map → trades-store-SZOQIYA4.js.map} +0 -0
  84. /package/dist/{trades-store-PNLPRYRJ.js.map → trades-store-XEOP35HD.js.map} +0 -0
  85. /package/server/{chunk-UT3JLF3M.js.map → chunk-YUBKEMYJ.js.map} +0 -0
  86. /package/server/{config-DK7KOMNL.js.map → config-IDH2S2DC.js.map} +0 -0
  87. /package/server/{daily-log-processor-NXSUFX32.js.map → daily-log-processor-EKMBPCH5.js.map} +0 -0
  88. /package/server/{daily-logs-store-LRVO7COL.js.map → daily-logs-store-TJUXTZG4.js.map} +0 -0
  89. /package/server/{proto-YZ4TLX2N.js.map → proto-L4NZHBZE.js.map} +0 -0
  90. /package/server/{setup-4EJSSDL4.js.map → setup-QCRLIAAQ.js.map} +0 -0
  91. /package/server/{sync-336543PJ.js.map → sync-WXQANQUJ.js.map} +0 -0
  92. /package/server/{trade-processor-NYDJ3VMH.js.map → trade-processor-F3UOCOMW.js.map} +0 -0
  93. /package/server/{trades-store-MXUZLSF5.js.map → trades-store-B54RYREL.js.map} +0 -0
package/README.md CHANGED
@@ -105,6 +105,12 @@ verification starts.
105
105
  The server's first npx launch may need network access to download TradeBlocks;
106
106
  setup does not install clients, Node/npm, or change system settings.
107
107
 
108
+ Option chains and minute quotes are always persisted as Parquet partitions under your data directory.
109
+ No storage setting or provider key is needed for local file imports.
110
+ `TRADEBLOCKS_PARQUET=true` is an optional switch for spot/enriched Parquet writes and
111
+ metadata/profile JSON storage, default off; setup does not add it.
112
+ See [storage and client configuration](../../docs/market-data.md#storage-and-configuration).
113
+
108
114
  For **Claude Code only**, the separate
109
115
  [tradeblocks-skills plugin](https://github.com/tradeblocks-org/tradeblocks-skills)
110
116
  is optional and is not installed by setup. Manual CSV import and core analysis
@@ -581,6 +587,31 @@ Field, objective and mode choices across separate requests are outside the Holm
581
587
  Monthly blocks retain within-month dependence, not cross-month dependence; block
582
588
  exchangeability is an assumption. See [the full contract](../../docs/mcp-tools.md#filter-curve-significance-and-stability).
583
589
 
590
+ In 4.5.0, `unit: "day"` aggregates entry-date P&L before scoring and month
591
+ permutation; win rate counts profitable days. A field varying within a day is
592
+ refused as `day_field_varies`, with the varying dates. Cheap request/work admission
593
+ precedes causal field resolution and counts the chosen unit conservatively before
594
+ coverage. Omitted `unit` retains trade-mode outputs.
595
+ Day mode also offers `sharpe` (daily dollar P&L, rf=0, sample std, √252),
596
+ `mar` (calendar-day CAGR / drawdown fraction of observed starting capital), and
597
+ `maxDrawdown` (dollar drawdown reduction; smaller is better). Filtered dates are
598
+ flat. Trade units refuse these objectives; MAR additionally refuses missing capital.
599
+ `objectiveMetadata` documents definitions and undefined cases. This dollar-P&L
600
+ Sharpe intentionally differs from the capital-based portfolio return Sharpe.
601
+ `groupBy: "regime.label"` adds chosen-threshold `perGroup` rows in either unit,
602
+ with the same covered baseline/kept/removed shape as `perYear`. Numeric groups use
603
+ `bins` or shared regime-analysis quartiles; categorical groups use values.
604
+ Missing values form an explicit uncovered group, small groups stay flagged,
605
+ and within-day varying groups refuse as `day_group_varies`. Group values honor
606
+ the same causal availability and optional freshness limit.
607
+
608
+ Missing groups use `group: null`, `groupValue: null`, `uncoveredGroup: true`, distinct
609
+ from a real `"uncovered"` category. Varchar market fields such as `Trend_Direction`
610
+ are now categorical for filter suggestions and regime analysis. Explicit-field
611
+ tools resolve only consumed fields without changing their timing or values. See the
612
+ [4.5.0 release notes](../../releases/v4.5.0.md) for the timings, MAR capital/window
613
+ policy and the under-90-day per-year/per-group `marUnstable` guard.
614
+
584
615
  `suggest_filters` defaults to `objective: "totalPl"`: only positive P&L improvements,
585
616
  ranked by P&L improvement with win-rate gain as tie-breaker. `objective: "winRate"`
586
617
  admits/ranks by win-rate gain with P&L tie-breaks. `minImprovementPct` (default 3
@@ -3767,7 +3767,20 @@ var TREASURY_RATES = {
3767
3767
  "2026-10-01": 4,
3768
3768
  "2026-10-02": 4.01,
3769
3769
  "2026-10-05": 4.05,
3770
- "2026-10-06": 4.04
3770
+ "2026-10-06": 4.04,
3771
+ "2026-10-07": 4.05,
3772
+ "2026-10-08": 4.05,
3773
+ "2026-10-09": 4.06,
3774
+ "2026-10-13": 4.09,
3775
+ "2026-10-14": 4.1,
3776
+ "2026-10-15": 4.1,
3777
+ "2026-10-16": 4.08,
3778
+ "2026-10-19": 4.1,
3779
+ "2026-10-20": 4.08,
3780
+ "2026-10-21": 4.07,
3781
+ "2026-10-22": 4.04,
3782
+ "2026-10-23": 4.04,
3783
+ "2026-10-26": 4.05
3771
3784
  };
3772
3785
 
3773
3786
  // ../lib/data/sofr-rates.ts
@@ -4960,7 +4973,20 @@ var SOFR_RATES = {
4960
4973
  "2026-10-02": 3.88,
4961
4974
  "2026-10-05": 3.89,
4962
4975
  "2026-10-06": 3.9,
4963
- "2026-10-07": 3.88
4976
+ "2026-10-07": 3.88,
4977
+ "2026-10-08": 3.87,
4978
+ "2026-10-09": 3.87,
4979
+ "2026-10-13": 3.89,
4980
+ "2026-10-14": 3.88,
4981
+ "2026-10-15": 3.89,
4982
+ "2026-10-16": 3.88,
4983
+ "2026-10-19": 3.87,
4984
+ "2026-10-20": 3.88,
4985
+ "2026-10-21": 3.88,
4986
+ "2026-10-22": 3.9,
4987
+ "2026-10-23": 3.92,
4988
+ "2026-10-26": 3.93,
4989
+ "2026-10-27": 3.95
4964
4990
  };
4965
4991
 
4966
4992
  // ../lib/utils/published-rates.ts
@@ -5331,16 +5357,21 @@ var MS_PER_DAY = 1e3 * 60 * 60 * 24;
5331
5357
  var XNYS_SESSION_CALENDAR_REVISION = "xnys-full-day-2022-2030-v1";
5332
5358
  var XNYS_SESSION_CALENDAR_SUPPORTED_FROM = "2022-01-01";
5333
5359
  var XNYS_SESSION_CALENDAR_SUPPORTED_THROUGH = "2030-12-31";
5360
+ var V1 = {
5361
+ revision: XNYS_SESSION_CALENDAR_REVISION,
5362
+ from: XNYS_SESSION_CALENDAR_SUPPORTED_FROM,
5363
+ through: XNYS_SESSION_CALENDAR_SUPPORTED_THROUGH
5364
+ };
5334
5365
  var ISO_DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
5335
5366
  var MS_PER_DAY2 = 24 * 60 * 60 * 1e3;
5336
- var SPECIAL_CLOSURES = /* @__PURE__ */ new Set(["2025-01-09"]);
5367
+ var SPECIAL_CLOSURES = /* @__PURE__ */ new Set(["2018-12-05", "2025-01-09"]);
5337
5368
  function isoDate(date) {
5338
5369
  return date.toISOString().slice(0, 10);
5339
5370
  }
5340
5371
  function utcDate(year, monthIndex, day) {
5341
5372
  return new Date(Date.UTC(year, monthIndex, day));
5342
5373
  }
5343
- function parseSupportedDate(value, label) {
5374
+ function parseSupportedDate(value, label, calendar) {
5344
5375
  if (!ISO_DATE_RE.test(value)) {
5345
5376
  throw new TypeError(
5346
5377
  `${label} must be an ISO calendar date (YYYY-MM-DD): ${JSON.stringify(value)}`
@@ -5350,9 +5381,9 @@ function parseSupportedDate(value, label) {
5350
5381
  if (!Number.isFinite(parsed.getTime()) || isoDate(parsed) !== value) {
5351
5382
  throw new TypeError(`${label} is not a real calendar date: ${JSON.stringify(value)}`);
5352
5383
  }
5353
- if (value < XNYS_SESSION_CALENDAR_SUPPORTED_FROM || value > XNYS_SESSION_CALENDAR_SUPPORTED_THROUGH) {
5384
+ if (value < calendar.from || value > calendar.through) {
5354
5385
  throw new RangeError(
5355
- `${label} ${JSON.stringify(value)} is outside XNYS calendar revision ${XNYS_SESSION_CALENDAR_REVISION} [${XNYS_SESSION_CALENDAR_SUPPORTED_FROM}, ${XNYS_SESSION_CALENDAR_SUPPORTED_THROUGH}]`
5386
+ `${label} ${JSON.stringify(value)} is outside XNYS calendar revision ${calendar.revision} [${calendar.from}, ${calendar.through}]`
5356
5387
  );
5357
5388
  }
5358
5389
  return parsed;
@@ -5411,7 +5442,7 @@ function holidayClosures(year) {
5411
5442
  add(nthWeekdayOfMonth(year, 1, 1, 3));
5412
5443
  add(addDays(easterSunday(year), -2));
5413
5444
  add(lastWeekdayOfMonth(year, 4, 1));
5414
- add(observedFixedHoliday(year, 5, 19));
5445
+ if (year >= 2022) add(observedFixedHoliday(year, 5, 19));
5415
5446
  add(observedFixedHoliday(year, 6, 4));
5416
5447
  add(nthWeekdayOfMonth(year, 8, 1, 1));
5417
5448
  add(nthWeekdayOfMonth(year, 10, 4, 4));
@@ -5430,15 +5461,18 @@ function closuresForYear(year) {
5430
5461
  }
5431
5462
  return closures;
5432
5463
  }
5433
- function isXnysSessionDate(value) {
5434
- const date = parseSupportedDate(value, "XNYS session date");
5464
+ function isSessionDate(value, calendar) {
5465
+ const date = parseSupportedDate(value, "XNYS session date", calendar);
5435
5466
  const weekday = date.getUTCDay();
5436
5467
  if (weekday === 0 || weekday === 6) return false;
5437
5468
  return !closuresForYear(date.getUTCFullYear()).has(value);
5438
5469
  }
5439
5470
  function enumerateXnysSessions(from, through) {
5440
- const first = parseSupportedDate(from, "XNYS session range from");
5441
- const last = parseSupportedDate(through, "XNYS session range through");
5471
+ return enumerateSessions(from, through, V1);
5472
+ }
5473
+ function enumerateSessions(from, through, calendar) {
5474
+ const first = parseSupportedDate(from, "XNYS session range from", calendar);
5475
+ const last = parseSupportedDate(through, "XNYS session range through", calendar);
5442
5476
  if (first.getTime() > last.getTime()) {
5443
5477
  throw new RangeError(
5444
5478
  `XNYS session range from ${JSON.stringify(from)} exceeds through ${JSON.stringify(through)}`
@@ -5447,7 +5481,7 @@ function enumerateXnysSessions(from, through) {
5447
5481
  const sessions = [];
5448
5482
  for (let cursor = first; cursor.getTime() <= last.getTime(); cursor = addDays(cursor, 1)) {
5449
5483
  const date = isoDate(cursor);
5450
- if (isXnysSessionDate(date)) sessions.push(date);
5484
+ if (isSessionDate(date, calendar)) sessions.push(date);
5451
5485
  }
5452
5486
  return Object.freeze(sessions);
5453
5487
  }
@@ -5553,12 +5587,12 @@ function combineDateAndTime(dateOpened, timeOpened) {
5553
5587
  const etOffset = getEasternTimeOffset(testDate);
5554
5588
  return new Date(utcDate2 - etOffset * 60 * 1e3);
5555
5589
  }
5590
+ var easternOffsetFormatter = new Intl.DateTimeFormat("en-US", {
5591
+ timeZone: "America/New_York",
5592
+ timeZoneName: "shortOffset"
5593
+ });
5556
5594
  function getEasternTimeOffset(date) {
5557
- const formatter = new Intl.DateTimeFormat("en-US", {
5558
- timeZone: "America/New_York",
5559
- timeZoneName: "shortOffset"
5560
- });
5561
- const parts = formatter.formatToParts(date);
5595
+ const parts = easternOffsetFormatter.formatToParts(date);
5562
5596
  const tzPart = parts.find((p) => p.type === "timeZoneName");
5563
5597
  if (tzPart) {
5564
5598
  const match = tzPart.value.match(/GMT([+-]\d+)/);
@@ -5568,14 +5602,14 @@ function getEasternTimeOffset(date) {
5568
5602
  }
5569
5603
  return -300;
5570
5604
  }
5605
+ var easternDateFormatter = new Intl.DateTimeFormat("en-CA", {
5606
+ timeZone: "America/New_York",
5607
+ year: "numeric",
5608
+ month: "2-digit",
5609
+ day: "2-digit"
5610
+ });
5571
5611
  function getDateOnly(date) {
5572
- const formatter = new Intl.DateTimeFormat("en-CA", {
5573
- timeZone: "America/New_York",
5574
- year: "numeric",
5575
- month: "2-digit",
5576
- day: "2-digit"
5577
- });
5578
- return formatter.format(date);
5612
+ return easternDateFormatter.format(date);
5579
5613
  }
5580
5614
 
5581
5615
  // ../lib/db/index.ts
@@ -6083,4 +6117,4 @@ export {
6083
6117
  searchTrades,
6084
6118
  getTradesPage
6085
6119
  };
6086
- //# sourceMappingURL=chunk-ENXBPJ7Y.js.map
6120
+ //# sourceMappingURL=chunk-7F73I2XO.js.map