@gloom-sh/terminal 0.20.18 → 0.20.19
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/package.json +1 -1
- package/src/api-client/cot.ts +5 -6
- package/src/api-client/data.ts +11 -1
- package/src/api-client/index.ts +1 -0
- package/src/api-client/request.ts +162 -40
- package/src/api-client/types/news.ts +45 -0
- package/src/api-client/types/world-venues.ts +9 -0
- package/src/app.tsx +4 -2
- package/src/architecture/floating-promise-allowlist.json +1 -1
- package/src/cli/commands/market.ts +53 -17
- package/src/cli/commands/ticker.ts +13 -6
- package/src/cli/context.ts +8 -0
- package/src/cli/desktop-pane-shot-browser.ts +3 -1
- package/src/cli/desktop-pane-shot-view.ts +0 -1
- package/src/cli/desktop-pane-shot.ts +204 -43
- package/src/cli/errors.ts +3 -9
- package/src/cli/exit-codes.ts +1 -1
- package/src/cli/glossary.ts +1 -1
- package/src/cli/help.ts +1 -1
- package/src/cli/history-rows.ts +2 -2
- package/src/cli/index.ts +1 -1
- package/src/cli/listing-arg.ts +87 -23
- package/src/cli/pane-functions/catalog-snapshot.json +17 -6
- package/src/cli/pane-functions/dom.ts +30 -2
- package/src/cli/pane-functions/freshness.ts +23 -4
- package/src/cli/pane-functions/function-help.ts +3 -3
- package/src/cli/pane-functions/headless.ts +9 -1
- package/src/cli/pane-functions/index.ts +77 -10
- package/src/cli/pane-functions/report-notices.ts +10 -0
- package/src/cli/pane-functions/resolver.ts +3 -2
- package/src/cli/pane-functions/screenshot-assessment.ts +10 -5
- package/src/cli/pane-functions/screenshot-data-evidence.ts +7 -15
- package/src/cli/pane-functions/screenshot-payload.ts +24 -10
- package/src/cli/pane-functions/screenshot-render.ts +21 -8
- package/src/cli/pane-functions/screenshot-types.ts +9 -0
- package/src/cli/quote-answer.ts +1 -1
- package/src/cli/result.ts +17 -0
- package/src/cli/scroll-truncation.ts +7 -2
- package/src/cli/ticker-resolution.ts +1 -1
- package/src/cli/unreachable.ts +21 -0
- package/src/components/chart/composite/drawing-store.ts +11 -7
- package/src/components/chart/composite/format.ts +1 -0
- package/src/components/chart/composite/legend.tsx +5 -2
- package/src/components/chart/composite/panel-surface/plot-gestures.ts +9 -2
- package/src/components/chart/composite/panel-surface.tsx +1 -1
- package/src/components/chart/composite/tools.ts +164 -39
- package/src/components/chart-table/header.tsx +2 -2
- package/src/components/chart-table/layout.ts +5 -6
- package/src/components/command-bar/routes/root/runtime.ts +11 -3
- package/src/components/command-bar/routes/ticker-search/results.ts +5 -0
- package/src/components/command-bar/selection-runtime.ts +29 -5
- package/src/components/command-bar/surface/index.tsx +4 -1
- package/src/components/command-bar/workflow/alert.ts +13 -5
- package/src/components/layout/pane/footer/model.ts +10 -2
- package/src/components/layout/pane/status-footer.ts +24 -0
- package/src/components/price-performance.tsx +26 -8
- package/src/components/reader/article-reader.tsx +12 -5
- package/src/components/ui/data-table/opentui/index.tsx +7 -0
- package/src/components/ui/table-layout.ts +32 -1
- package/src/market-data/ah-pair.ts +19 -0
- package/src/market-data/coordinator/entries.ts +6 -4
- package/src/market-data/coordinator/index.ts +14 -3
- package/src/market-data/futures-board.ts +36 -29
- package/src/market-data/futures-contract.ts +37 -1
- package/src/market-data/market/change-basis.ts +9 -0
- package/src/market-data/market/status.ts +40 -4
- package/src/market-data/performance.ts +127 -32
- package/src/market-data/quotes/time.ts +5 -2
- package/src/news/types.ts +28 -0
- package/src/notifications/app-badge.ts +2 -3
- package/src/notifications/app-notifier.ts +5 -0
- package/src/plugins/builtin/alerts/cli.ts +65 -18
- package/src/plugins/builtin/alerts/command.ts +39 -9
- package/src/plugins/builtin/alerts/event-rows.ts +9 -3
- package/src/plugins/builtin/alerts/events-pane.tsx +16 -10
- package/src/plugins/builtin/alerts/headless.ts +12 -6
- package/src/plugins/builtin/alerts/index.tsx +60 -8
- package/src/plugins/builtin/alerts/option-contract.ts +197 -0
- package/src/plugins/builtin/alerts/price.ts +30 -5
- package/src/plugins/builtin/alerts/pro-rules.ts +62 -0
- package/src/plugins/builtin/alerts/research-builder.ts +5 -10
- package/src/plugins/builtin/analytics/account-returns.ts +1 -1
- package/src/plugins/builtin/analytics/pane-model.ts +2 -2
- package/src/plugins/builtin/analytics/risk-client.ts +1 -1
- package/src/plugins/builtin/buildout/company/pane.tsx +4 -14
- package/src/plugins/builtin/catalysts/model.ts +2 -1
- package/src/plugins/builtin/chart-composer/chart-spec.ts +5 -0
- package/src/plugins/builtin/chart-composer/cli-options.ts +5 -3
- package/src/plugins/builtin/chart-composer/headless-schema.ts +14 -10
- package/src/plugins/builtin/chart-composer/headless.ts +2 -0
- package/src/plugins/builtin/chart-composer/index.tsx +17 -5
- package/src/plugins/builtin/chart-composer/pane.tsx +14 -4
- package/src/plugins/builtin/chart-composer/viewport-labels.ts +2 -17
- package/src/plugins/builtin/chat/controller/notifications.ts +1 -0
- package/src/plugins/builtin/chat/index.tsx +0 -1
- package/src/plugins/builtin/commodities-energy/index.tsx +1 -1
- package/src/plugins/builtin/company-kpis/headless.ts +1 -1
- package/src/plugins/builtin/company-kpis/model.ts +21 -9
- package/src/plugins/builtin/congress-trades/model.ts +9 -5
- package/src/plugins/builtin/cot/client.ts +2 -3
- package/src/plugins/builtin/cot/headless.ts +16 -16
- package/src/plugins/builtin/cot/index.tsx +6 -6
- package/src/plugins/builtin/cot/model.ts +25 -5
- package/src/plugins/builtin/cot/pane.tsx +11 -6
- package/src/plugins/builtin/cot/series.ts +11 -8
- package/src/plugins/builtin/cpi/model.ts +15 -4
- package/src/plugins/builtin/cpi/pane.tsx +29 -7
- package/src/plugins/builtin/doe/model.ts +30 -0
- package/src/plugins/builtin/doe/pane.tsx +8 -2
- package/src/plugins/builtin/earnings/board-table.ts +9 -4
- package/src/plugins/builtin/earnings/headless.ts +10 -3
- package/src/plugins/builtin/earnings/history-table.ts +4 -2
- package/src/plugins/builtin/earnings-calls/calendar.tsx +4 -3
- package/src/plugins/builtin/earnings-ripple/pane.tsx +2 -2
- package/src/plugins/builtin/econ/index.tsx +4 -2
- package/src/plugins/builtin/futures/model.ts +14 -1
- package/src/plugins/builtin/futures/series.ts +1 -8
- package/src/plugins/builtin/fx-matrix/index.tsx +2 -2
- package/src/plugins/builtin/insider/detail.tsx +36 -7
- package/src/plugins/builtin/insider/filing-stories.ts +110 -0
- package/src/plugins/builtin/insider/headless.ts +37 -2
- package/src/plugins/builtin/insider/index.tsx +79 -10
- package/src/plugins/builtin/insider/model.ts +43 -5
- package/src/plugins/builtin/ipo-calendar/client.ts +11 -1
- package/src/plugins/builtin/ipo-calendar/model.ts +3 -7
- package/src/plugins/builtin/jobs/headless.ts +2 -1
- package/src/plugins/builtin/jobs/model.ts +6 -0
- package/src/plugins/builtin/jobs/pane.tsx +8 -3
- package/src/plugins/builtin/news/wire/news/detail-view.tsx +118 -10
- package/src/plugins/builtin/news/wire/news/story-evidence.ts +178 -0
- package/src/plugins/builtin/options/analytics.ts +1 -1
- package/src/plugins/builtin/options/view.tsx +18 -11
- package/src/plugins/builtin/options-positioning/model.ts +11 -0
- package/src/plugins/builtin/options-positioning/pane.tsx +22 -1
- package/src/plugins/builtin/options-scenario/client.ts +49 -8
- package/src/plugins/builtin/options-scenario/headless.ts +7 -3
- package/src/plugins/builtin/options-scenario/model.ts +33 -2
- package/src/plugins/builtin/options-scenario/pane.tsx +3 -4
- package/src/plugins/builtin/perps/cascade.ts +4 -3
- package/src/plugins/builtin/perps/markets-section.tsx +5 -2
- package/src/plugins/builtin/perps/model.ts +4 -3
- package/src/plugins/builtin/portfolio-list/table.tsx +3 -2
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +29 -14
- package/src/plugins/builtin/research/event-model.ts +12 -6
- package/src/plugins/builtin/research-search/index.tsx +3 -1
- package/src/plugins/builtin/scanner/denied.tsx +16 -4
- package/src/plugins/builtin/scanner/flow-pane.tsx +1 -1
- package/src/plugins/builtin/scanner/hilo-pane.tsx +1 -1
- package/src/plugins/builtin/sec/filing-display.tsx +14 -2
- package/src/plugins/builtin/sec/headless.ts +42 -4
- package/src/plugins/builtin/sec/index.tsx +21 -1
- package/src/plugins/builtin/sectors/sector-model.ts +1 -1
- package/src/plugins/builtin/shared/earnings-report.ts +32 -3
- package/src/plugins/builtin/shared/options-pro-copy.ts +34 -0
- package/src/plugins/builtin/shared/statement-currency.ts +23 -0
- package/src/plugins/builtin/shared/ticker-surface.ts +1 -1
- package/src/plugins/builtin/supply-chain/pane.tsx +4 -3
- package/src/plugins/builtin/themes/headless.ts +4 -4
- package/src/plugins/builtin/themes/model.ts +11 -8
- package/src/plugins/builtin/themes/pane.tsx +2 -2
- package/src/plugins/builtin/ticker-detail/financials/model.ts +22 -32
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +7 -9
- package/src/plugins/builtin/ticker-detail/headless-schema.ts +2 -0
- package/src/plugins/builtin/ticker-detail/headless.ts +28 -12
- package/src/plugins/builtin/ticker-detail/overview/board-lot.ts +21 -0
- package/src/plugins/builtin/ticker-detail/overview/model.ts +11 -1
- package/src/plugins/builtin/ticker-detail/overview/pane.tsx +4 -0
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +61 -13
- package/src/plugins/builtin/volatility/pane.tsx +3 -3
- package/src/plugins/builtin/world-venue-map/headless.ts +4 -2
- package/src/plugins/builtin/world-venue-map/model.ts +6 -1
- package/src/plugins/builtin/world-venue-map/venue-header.tsx +5 -3
- package/src/plugins/catalog-browser.ts +10 -1
- package/src/renderers/browser/activity.ts +16 -0
- package/src/renderers/browser/app-badge-host.ts +14 -0
- package/src/renderers/browser/main.tsx +5 -0
- package/src/renderers/browser/notifications.ts +103 -0
- package/src/renderers/browser/ui-host.tsx +4 -0
- package/src/renderers/dom/data-table/index.tsx +27 -4
- package/src/renderers/electrobun/view/http-fetch.ts +3 -2
- package/src/sources/gloomberb-cloud/index.ts +8 -6
- package/src/sources/gloomberb-cloud/news.ts +35 -0
- package/src/sources/provider-errors.ts +34 -7
- package/src/sources/provider-router/history.ts +32 -6
- package/src/time-series/base-series.ts +39 -6
- package/src/time-series/chart-seed.ts +2 -2
- package/src/time-series/history-quality.ts +4 -1
- package/src/time-series/hooks.ts +2 -0
- package/src/time-series/price-comparison.ts +17 -23
- package/src/time-series/reporting.ts +1 -1
- package/src/time-series/resolution.ts +13 -0
- package/src/time-series/resolve-context.ts +6 -0
- package/src/time-series/resolve.ts +39 -2
- package/src/time-series/types.ts +2 -1
- package/src/types/financials.ts +9 -1
- package/src/types/headless.ts +1 -0
- package/src/types/issuer-listings.ts +2 -0
- package/src/types/plugin-notifications.ts +3 -0
- package/src/types/price-history.ts +6 -4
- package/src/ui/host.tsx +2 -0
- package/src/utils/exchange-announcements.ts +7 -2
- package/src/utils/fundamentals.ts +40 -0
- package/src/utils/network-failure.ts +2 -0
- package/src/utils/price-history-integrity.ts +9 -1
|
@@ -30,6 +30,8 @@ import {
|
|
|
30
30
|
import {
|
|
31
31
|
CHART_DRAWINGS_SETTING_KEY,
|
|
32
32
|
parseChartDrawings,
|
|
33
|
+
parseSharedChartDrawings,
|
|
34
|
+
shareableChartDrawings,
|
|
33
35
|
type ChartDrawing,
|
|
34
36
|
} from "../../../components/chart/composite/tools";
|
|
35
37
|
import {
|
|
@@ -191,10 +193,20 @@ function pinChartSpecListings(spec: ChartSpec, tickers: ReadonlyMap<string, Tick
|
|
|
191
193
|
return changed ? { ...spec, series } : spec;
|
|
192
194
|
}
|
|
193
195
|
|
|
196
|
+
/** The pane with only the drawings a link carries: the newest that fit, none this build cannot read. */
|
|
197
|
+
function withShareableDrawings(pane: PaneInstanceConfig): PaneInstanceConfig {
|
|
198
|
+
const saved = pane.settings?.[CHART_DRAWINGS_SETTING_KEY];
|
|
199
|
+
if (saved === undefined) return pane;
|
|
200
|
+
const { [CHART_DRAWINGS_SETTING_KEY]: _saved, ...settings } = pane.settings!;
|
|
201
|
+
const drawings = shareableChartDrawings(parseChartDrawings(saved));
|
|
202
|
+
return { ...pane, settings: drawings.length > 0 ? { ...settings, [CHART_DRAWINGS_SETTING_KEY]: drawings } : settings };
|
|
203
|
+
}
|
|
204
|
+
|
|
194
205
|
function prepareChartPaneForShare(
|
|
195
|
-
|
|
206
|
+
saved: PaneInstanceConfig,
|
|
196
207
|
{ tickers, pinnedTime }: { tickers: ReadonlyMap<string, TickerRecord>; pinnedTime?: number },
|
|
197
208
|
): PaneInstanceConfig {
|
|
209
|
+
const pane = withShareableDrawings(saved);
|
|
198
210
|
// A crosshair pinned in the sender's tab travels with the link, so it opens
|
|
199
211
|
// on that moment. A moment the pane still holds from a link it was opened
|
|
200
212
|
// from is never passed on, whatever else the pane holds.
|
|
@@ -333,7 +345,7 @@ const chartComposerTemplates: PaneTemplateDef[] = [
|
|
|
333
345
|
const sharedData = isRecord(options?.shareData) ? options.shareData : null;
|
|
334
346
|
const sharedSpec = parseChartSpec(sharedData?.chartSpec ?? options?.shareData);
|
|
335
347
|
if (sharedSpec) {
|
|
336
|
-
const drawings =
|
|
348
|
+
const drawings = parseSharedChartDrawings(sharedData?.chartDrawings) ?? [];
|
|
337
349
|
const viewport = parseChartInteractionViewport(sharedData?.chartInteractionViewport);
|
|
338
350
|
return instanceFor(sharedSpec, "G", {
|
|
339
351
|
...(drawings.length > 0 ? { drawings } : {}),
|
|
@@ -349,7 +361,7 @@ const chartComposerTemplates: PaneTemplateDef[] = [
|
|
|
349
361
|
if (!spec) return null;
|
|
350
362
|
if (spec.series.some((series) => series.source.kind === "security"
|
|
351
363
|
&& (series.source.instrument.instrument || series.source.instrument.brokerId || series.source.instrument.brokerInstanceId))) return null;
|
|
352
|
-
const drawings = parseChartDrawings(pane.settings?.[CHART_DRAWINGS_SETTING_KEY]);
|
|
364
|
+
const drawings = shareableChartDrawings(parseChartDrawings(pane.settings?.[CHART_DRAWINGS_SETTING_KEY]));
|
|
353
365
|
const viewport = parseChartInteractionViewport(
|
|
354
366
|
pane.settings?.[CHART_INTERACTION_VIEWPORT_SETTING_KEY],
|
|
355
367
|
);
|
|
@@ -370,8 +382,8 @@ const chartComposerTemplates: PaneTemplateDef[] = [
|
|
|
370
382
|
].includes(key))) return null;
|
|
371
383
|
const spec = parseChartSpec(data.chartSpec);
|
|
372
384
|
if (!spec) return null;
|
|
373
|
-
const drawings =
|
|
374
|
-
if (
|
|
385
|
+
const drawings = data.chartDrawings === undefined ? [] : parseSharedChartDrawings(data.chartDrawings);
|
|
386
|
+
if (!drawings) return null;
|
|
375
387
|
const viewport = data.chartInteractionViewport === undefined
|
|
376
388
|
? null
|
|
377
389
|
: parseChartInteractionViewport(data.chartInteractionViewport);
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
type MultiSelectRowAction,
|
|
21
21
|
} from "../../../components/ui";
|
|
22
22
|
import { CompositeChart } from "../../../components/chart/composite";
|
|
23
|
+
import { useCaptureDatesData } from "../../../components/layout/pane/capture-status";
|
|
23
24
|
import { savedCopyFooterInfo } from "../../../components/layout/pane/footer";
|
|
24
25
|
import { useChartViewReset, useChartViewResetListener } from "../../../components/chart/core/view-reset";
|
|
25
26
|
import { formatCompositeDatasetDate } from "../../../components/chart/composite/format";
|
|
@@ -64,6 +65,7 @@ import { getTimeSeriesField, isMarketFieldId } from "../../../time-series/field-
|
|
|
64
65
|
import { isDatasetChart, isOhlcSeriesStyle } from "../../../time-series/spec";
|
|
65
66
|
import { useThemeColors } from "../../../theme/theme-context";
|
|
66
67
|
import { comparisonLegCurrencies, priceComparisonSeriesIds } from "../../../time-series/price-comparison";
|
|
68
|
+
import { periodDayText } from "../../../market-data/market/period-return";
|
|
67
69
|
import { companyLegendLabels } from "./legend-names";
|
|
68
70
|
import { seriesMessageName, studyMessageName } from "../../../time-series/series-name";
|
|
69
71
|
import { CHART_COMPOSER_PANE_ID } from "../../../types/config";
|
|
@@ -120,7 +122,7 @@ import {
|
|
|
120
122
|
type PairStudySelection,
|
|
121
123
|
} from "./studies";
|
|
122
124
|
import { buildEmptyChartPreset, buildPriceChartPreset } from "./presets";
|
|
123
|
-
import type
|
|
125
|
+
import { comparisonPresetResolution, type ChartInteractionViewport } from "./chart-spec";
|
|
124
126
|
import {
|
|
125
127
|
CHART_FORMULA_OPTIONS,
|
|
126
128
|
CHART_BAR_SIZE_PRESETS,
|
|
@@ -962,14 +964,18 @@ function ChartComposerSurface({
|
|
|
962
964
|
/** The range the bar shows as selected; a fixed window or a period count leaves a range to pick. */
|
|
963
965
|
const rangeReselects = !spec.viewport.dateWindow && spec.viewport.maxPoints === undefined;
|
|
964
966
|
const setRange = useCallback((range: TimeRange) => {
|
|
967
|
+
const current = spec.viewport;
|
|
968
|
+
const changesSession = range === "1D" ? current.resolution === "1d"
|
|
969
|
+
: current.range === "1D" && current.resolution === "auto";
|
|
970
|
+
const resolution = changesSession && priceComparisonSeriesIds(spec) ? comparisonPresetResolution(range) : current.resolution;
|
|
965
971
|
// The range already showing: a view moved off it goes back to it, as `0` does.
|
|
966
|
-
if (rangeReselects && range ===
|
|
972
|
+
if (rangeReselects && range === current.range && resolution === current.resolution) {
|
|
967
973
|
resetChartView();
|
|
968
974
|
return;
|
|
969
975
|
}
|
|
970
976
|
setSpec({
|
|
971
977
|
...spec,
|
|
972
|
-
viewport: { ...
|
|
978
|
+
viewport: { ...current, range, resolution, dateWindow: undefined, maxPoints: undefined },
|
|
973
979
|
});
|
|
974
980
|
}, [rangeReselects, resetChartView, setSpec, spec]);
|
|
975
981
|
const setResolution = useCallback((next: ChartResolution) => {
|
|
@@ -1222,6 +1228,9 @@ function ChartComposerSurface({
|
|
|
1222
1228
|
: window.end;
|
|
1223
1229
|
return formatChartDateWindow({ ...window, end }, timeZone);
|
|
1224
1230
|
}, [spec.series, spec.viewport.dateWindow, viewport?.end]);
|
|
1231
|
+
const comparisonEnd = resolution.resolution === "1d" ? Object.values(resolution.priceComparison?.legs ?? {})[0] : undefined;
|
|
1232
|
+
const comparisonAsOf = comparisonEnd && `${periodDayText(comparisonEnd.endDay, new Date().getUTCFullYear())} ${comparisonEnd.intraday ? "partial" : "close"}`;
|
|
1233
|
+
const captureDatesData = useCaptureDatesData();
|
|
1225
1234
|
|
|
1226
1235
|
// A generic future (CL1) is a rolling series: its roll rule and adjustment are chart controls.
|
|
1227
1236
|
const generic = useMemo(() => chartFuturesGeneric(spec), [spec]);
|
|
@@ -1326,7 +1335,8 @@ function ChartComposerSurface({
|
|
|
1326
1335
|
options: resolutionOptions,
|
|
1327
1336
|
onChange: (value: string) => setResolution(value as ChartResolution),
|
|
1328
1337
|
} : undefined}
|
|
1329
|
-
|
|
1338
|
+
asOf={comparisonAsOf}
|
|
1339
|
+
meta={[dateWindowLabel, captureDatesData && comparisonAsOf].filter(Boolean).join(" · ") || undefined}
|
|
1330
1340
|
/>
|
|
1331
1341
|
<MultiSelectDialogButton
|
|
1332
1342
|
ref={indicatorsDialogRef}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ChartResolution } from "../../../components/chart/core/types";
|
|
2
|
-
import { chartBarSizeParts, isManualChartResolution, type ManualChartResolution } from "../../../time-series/resolution";
|
|
2
|
+
import { chartBarSizeName, chartBarSizeParts, isManualChartResolution, type ManualChartResolution } from "../../../time-series/resolution";
|
|
3
3
|
|
|
4
4
|
const RESOLUTION_LABELS: Record<ManualChartResolution | "auto", string> = {
|
|
5
5
|
auto: "Auto",
|
|
@@ -14,21 +14,8 @@ const RESOLUTION_LABELS: Record<ManualChartResolution | "auto", string> = {
|
|
|
14
14
|
"1mo": "M",
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
const RESOLUTION_NAMES: Record<ManualChartResolution, string> = {
|
|
18
|
-
"1m": "1-minute",
|
|
19
|
-
"5m": "5-minute",
|
|
20
|
-
"15m": "15-minute",
|
|
21
|
-
"30m": "30-minute",
|
|
22
|
-
"45m": "45-minute",
|
|
23
|
-
"1h": "hourly",
|
|
24
|
-
"1d": "daily",
|
|
25
|
-
"1wk": "weekly",
|
|
26
|
-
"1mo": "monthly",
|
|
27
|
-
};
|
|
28
|
-
|
|
29
17
|
// Months take MO beyond one (3MO), as 3M and 6M are ranges in the same bar.
|
|
30
18
|
const BUILT_UNIT_LABELS = { m: "m", h: "h", d: "D", wk: "W", mo: "MO" } as const;
|
|
31
|
-
const BUILT_UNIT_NAMES = { m: "minute", h: "hour", d: "day", wk: "week", mo: "month" } as const;
|
|
32
19
|
|
|
33
20
|
/**
|
|
34
21
|
* The one way chart intervals are labelled. Intraday reads in lowercase units
|
|
@@ -44,9 +31,7 @@ export function formatChartResolution(resolution: ChartResolution): string {
|
|
|
44
31
|
|
|
45
32
|
export function describeChartResolution(resolution: ChartResolution): string {
|
|
46
33
|
if (resolution === "auto") return "Choose an interval automatically for the active range.";
|
|
47
|
-
|
|
48
|
-
const parts = chartBarSizeParts(resolution);
|
|
49
|
-
return parts ? `Use ${parts.count}-${BUILT_UNIT_NAMES[parts.unit]} observations.` : `Use ${resolution} observations.`;
|
|
34
|
+
return `Use ${chartBarSizeName(resolution)} observations.`;
|
|
50
35
|
}
|
|
51
36
|
|
|
52
37
|
function calendarParts(date: Date, timeZone: string): { key: string; year: number; label: string } {
|
|
@@ -178,7 +178,6 @@ export const chatModule: PluginModule = {
|
|
|
178
178
|
chatController.attachPersistence(ctx.persistence, ctx.resume);
|
|
179
179
|
chatSidebarStore.attach(ctx.persistence);
|
|
180
180
|
chatHandlePromptStore.attach(ctx.persistence);
|
|
181
|
-
// The desktop app's Dock badge counts the people who wrote to you or tagged you, plus the missed notices; other hosts have no badge.
|
|
182
181
|
disposeUnreadBadge?.();
|
|
183
182
|
const badgeHost = getAppBadgeHost();
|
|
184
183
|
disposeUnreadBadge = badgeHost
|
|
@@ -57,7 +57,7 @@ const TAB_ELSEWHERE: Readonly<Record<string, string>> = {
|
|
|
57
57
|
const TAB_REPORT_OPTION: PaneReportOptionDef = {
|
|
58
58
|
key: "tab",
|
|
59
59
|
type: "enum",
|
|
60
|
-
description: "The board to open on: futures markets, EIA inventories,
|
|
60
|
+
description: "The board to open on: futures markets, EIA inventories, COT positioning or USDA crop balances.",
|
|
61
61
|
values: [{ value: "markets" }, { value: "inventories" }, { value: "positioning" }, { value: "crops" }],
|
|
62
62
|
example: "--tab inventories",
|
|
63
63
|
exampleWithoutArgument: true,
|
|
@@ -121,7 +121,7 @@ export function companyHeadless(mode: CompanyMode): HeadlessPaneDefinition<"bund
|
|
|
121
121
|
// A company with nothing on file says so once, as the pane does, rather than "not covered".
|
|
122
122
|
const nothingOnFile = datasetRows(data).length === 0 && data.lockedRows === 0 && !requested;
|
|
123
123
|
const { title, hint } = companyEmptyState(mode, symbol, { tab: "table", hasRows: !nothingOnFile }, "cli");
|
|
124
|
-
return { complete: !data.truncated, ...(nothingOnFile ? { empty:
|
|
124
|
+
return { complete: !data.truncated, ...(nothingOnFile ? { empty: [title, hint].filter(Boolean).join(" ") } : {}), errors: data.truncated ? [data.access === "preview" ? companyPreviewNote(data, mode === "guidance") : "Response limit reached; narrow the metric or date range"] : [],
|
|
125
125
|
...(notes.length ? { notes } : {}),
|
|
126
126
|
sections: "series" in data ? [
|
|
127
127
|
section("Latest KPIs", currentKpiSeries(data.series).map((series) => series.latest), { first: true }),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { GuidancePayload, KpiGuidance, KpiObservation, KpiSeries, KpiUnit, KpisPayload } from "../../../api-client/company-kpis";
|
|
2
2
|
import type { DataTableColumn } from "../../../components";
|
|
3
3
|
import { scalarPoint, staticSeries } from "../../../components/chart/static/series";
|
|
4
|
-
import { getTableWidth, tableColumnWidth } from "../../../components/ui/table-layout";
|
|
4
|
+
import { getTableWidth, markHiddenTableColumns, tableColumnWidth } from "../../../components/ui/table-layout";
|
|
5
5
|
import type { CompositeChartXAxis } from "../../../components/chart/composite/types";
|
|
6
6
|
import { MISSING_VALUE, formatCompact, formatNumber } from "../../../utils/format";
|
|
7
7
|
import { growthRate, isNotMeaningful, NOT_MEANINGFUL_TEXT, NOT_MEANINGFUL_TONE } from "../../../utils/growth";
|
|
@@ -132,11 +132,14 @@ export function allGuidance(data: GuidancePayload): KpiGuidance[] {
|
|
|
132
132
|
/**
|
|
133
133
|
* How far back the period just before is, for the kinds that repeat: in fiscal
|
|
134
134
|
* quarters, and in days between period ends (52- and 53-week calendars included).
|
|
135
|
+
* A year to date repeats a year later: the nine months to September against
|
|
136
|
+
* the nine months to September before, never against the same year's half.
|
|
135
137
|
*/
|
|
136
138
|
const PERIOD_STEP: Partial<Record<KpiObservation["period"]["kind"], { quarters: number; days: readonly [number, number] }>> = {
|
|
137
139
|
quarter: { quarters: 1, days: [80, 100] },
|
|
138
140
|
half: { quarters: 2, days: [170, 195] },
|
|
139
141
|
year: { quarters: 4, days: [350, 380] },
|
|
142
|
+
ytd: { quarters: 4, days: [350, 380] },
|
|
140
143
|
};
|
|
141
144
|
const DAY_MS = 86_400_000;
|
|
142
145
|
/**
|
|
@@ -145,6 +148,10 @@ const DAY_MS = 86_400_000;
|
|
|
145
148
|
* before it and a year against the year before, never against an older one
|
|
146
149
|
* when that period is missing: Tencent's Q2 2026 revenue over its Q3 2025 one
|
|
147
150
|
* read +6.19% as if quarter on quarter, where the quarter before gave +4%.
|
|
151
|
+
* A year to date is set against the same window a year earlier: nine months
|
|
152
|
+
* against the half of the same year read +52.73% for an insurer whose nine
|
|
153
|
+
* months grew 0.9%. A balance is set against the balance before it; a period
|
|
154
|
+
* of another kind ("other") against none, its window being unknown.
|
|
148
155
|
*/
|
|
149
156
|
export function observationChange(row: KpiObservation, observations: KpiObservation[]): { value: number | null; unit: string; notMeaningful?: true } {
|
|
150
157
|
const fiscalOrder = (item: KpiObservation) => item.period.fiscalYear !== null && (item.period.kind === "year" || item.period.fiscalQuarter !== null)
|
|
@@ -153,7 +160,7 @@ export function observationChange(row: KpiObservation, observations: KpiObservat
|
|
|
153
160
|
: fiscalOrder(other) !== null && fiscalOrder(row) !== null && fiscalOrder(other)! < fiscalOrder(row)!;
|
|
154
161
|
const step = PERIOD_STEP[row.period.kind];
|
|
155
162
|
const adjacent = (other: KpiObservation) => {
|
|
156
|
-
if (!step) return
|
|
163
|
+
if (!step) return row.period.kind === "instant";
|
|
157
164
|
if (other.period.end && row.period.end) {
|
|
158
165
|
const days = (Date.parse(row.period.end) - Date.parse(other.period.end)) / DAY_MS;
|
|
159
166
|
return days >= step.days[0] && days <= step.days[1];
|
|
@@ -161,8 +168,12 @@ export function observationChange(row: KpiObservation, observations: KpiObservat
|
|
|
161
168
|
const [from, to] = [fiscalOrder(other), fiscalOrder(row)];
|
|
162
169
|
return from !== null && to !== null && to - from === step.quarters;
|
|
163
170
|
};
|
|
171
|
+
// A year to date's prior is the same window a year earlier, as long by its dates when both state them.
|
|
172
|
+
const days = (item: KpiObservation) => item.period.start && item.period.end ? (Date.parse(item.period.end) - Date.parse(item.period.start)) / DAY_MS : null;
|
|
173
|
+
const sameWindow = (other: KpiObservation) => row.period.kind !== "ytd" || adjacent(other)
|
|
174
|
+
&& (days(row) === null || days(other) === null || Math.abs(days(row)! - days(other)!) <= 10);
|
|
164
175
|
const prior = observations.filter((other) => other.id !== row.id && other.current && !other.conflict && !other.contested && exactObservation(other) && other.seriesKey === row.seriesKey
|
|
165
|
-
&& other.period.kind === row.period.kind && previousPeriod(other)).sort((a, b) => periodOrder(b).localeCompare(periodOrder(a)))[0];
|
|
176
|
+
&& other.period.kind === row.period.kind && previousPeriod(other) && sameWindow(other)).sort((a, b) => periodOrder(b).localeCompare(periodOrder(a)))[0];
|
|
166
177
|
if (!prior || !adjacent(prior) || (row.conflict || row.contested) || !exactObservation(row)) return { value: null, unit: "" };
|
|
167
178
|
if (row.unit === "percent") return { value: row.value - prior.value, unit: "pp" };
|
|
168
179
|
if (row.unit === "basis_points") return { value: row.value - prior.value, unit: "bp" };
|
|
@@ -303,9 +314,9 @@ export function fitCompanyColumns(columns: readonly DataTableColumn[], width: nu
|
|
|
303
314
|
for (const drop of [null, ...(history ? ["change", "issued"] : ["issued", "change"]), "scope", "basis", "trend", "period", "outcome", "actual"]) {
|
|
304
315
|
if (drop) shown = shown.filter((column) => column.id !== drop);
|
|
305
316
|
const fitted = attempt(shown);
|
|
306
|
-
if (fitted) return fitted;
|
|
317
|
+
if (fitted) return markHiddenTableColumns(columns, fitted);
|
|
307
318
|
}
|
|
308
|
-
return narrow(shown);
|
|
319
|
+
return markHiddenTableColumns(columns, narrow(shown));
|
|
309
320
|
}
|
|
310
321
|
|
|
311
322
|
export function guidanceIssueNote(row: KpiGuidance, rows: readonly KpiGuidance[]): string | null {
|
|
@@ -314,7 +325,7 @@ export function guidanceIssueNote(row: KpiGuidance, rows: readonly KpiGuidance[]
|
|
|
314
325
|
}
|
|
315
326
|
|
|
316
327
|
/** Companies to point an empty pane at, one that has data and one for when the pane is for the first. */
|
|
317
|
-
const
|
|
328
|
+
const GUIDANCE_EXAMPLE_COMPANIES = ["WMT", "DAL"] as const;
|
|
318
329
|
|
|
319
330
|
/**
|
|
320
331
|
* What an empty table says. A company with nothing on file for the function reads as
|
|
@@ -323,10 +334,11 @@ const EXAMPLE_COMPANIES: Record<CompanyMode, readonly string[]> = { guidance: ["
|
|
|
323
334
|
*/
|
|
324
335
|
export function companyEmptyState(mode: CompanyMode, symbol: string, view: { tab: string; hasRows: boolean }, surface: "cli" | "pane" = "pane"): { title: string; hint?: string } {
|
|
325
336
|
if (view.hasRows) return { title: view.tab === "history" ? "Actuals have not been matched to these guidance periods yet." : "No disclosed observations for this selection yet." };
|
|
326
|
-
|
|
337
|
+
if (mode === "kpis") return { title: `No KPIs on file for ${symbol} yet.` };
|
|
338
|
+
const examples = GUIDANCE_EXAMPLE_COMPANIES;
|
|
327
339
|
const example = examples.find((candidate) => candidate !== symbol.trim().toUpperCase()) ?? examples[0]!;
|
|
328
|
-
const command =
|
|
329
|
-
return { title:
|
|
340
|
+
const command = `GUIDE ${example}`;
|
|
341
|
+
return { title: `Guidance for ${symbol} is not yet available.`, hint: `Try ${surface === "cli" ? `\`fn ${command}\`` : command}.` };
|
|
330
342
|
}
|
|
331
343
|
|
|
332
344
|
/** What a missing KPI means, as KPIS states it among its limitations and EQS beside a KPI column with gaps. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DataTableColumn } from "../../../components";
|
|
2
|
-
import { dropColumnsToFit, getTableWidth } from "../../../components/ui/table-layout";
|
|
2
|
+
import { dropColumnsToFit, getTableWidth, markHiddenTableColumns } from "../../../components/ui/table-layout";
|
|
3
3
|
import type { ShortDateOptions } from "../../../utils/datetime-format";
|
|
4
4
|
import { MISSING_VALUE, formatCompact } from "../../../utils/format";
|
|
5
5
|
import type { SortDirection } from "../../../utils/sort-values";
|
|
@@ -246,8 +246,10 @@ export function buildTradeColumns(width: number, tickerView = false): TradeColum
|
|
|
246
246
|
const fitted = getTableWidth(long) <= width ? long : dropColumnsToFit(tradeColumns(tickerView, 7, MEMBER_READABLE_WIDTH, null), width, TRADE_DROP_ORDER);
|
|
247
247
|
const shown = new Set(fitted.map((column) => column.id));
|
|
248
248
|
const dateWidth = fitted[0]!.width;
|
|
249
|
-
const layout = (memberWidth: number, assetWidth: number | null) =>
|
|
250
|
-
|
|
249
|
+
const layout = (memberWidth: number, assetWidth: number | null) => {
|
|
250
|
+
const all = tradeColumns(tickerView, dateWidth, memberWidth, assetWidth);
|
|
251
|
+
return markHiddenTableColumns(all, all.filter((column) => shown.has(column.id) || column.id === "asset"));
|
|
252
|
+
};
|
|
251
253
|
// What the other columns leave, as the table draws them, names the member and then the asset.
|
|
252
254
|
const flexWidth = Math.max(TRADE_MEMBER_MIN_WIDTH, MEMBER_READABLE_WIDTH + width - getTableWidth(fitted));
|
|
253
255
|
// Member names rarely pass 22 cells; the rest names the asset, which is the
|
|
@@ -276,7 +278,8 @@ export function buildMemberTradeColumns(width: number): TradeColumn[] {
|
|
|
276
278
|
const fitted = dropColumnsToFit(layout(MEMBER_TRADE_ASSET_MIN_WIDTH), width, MEMBER_TRADE_DROP_ORDER);
|
|
277
279
|
const shown = new Set(fitted.map((column) => column.id));
|
|
278
280
|
const assetWidth = Math.max(MEMBER_TRADE_ASSET_MIN_WIDTH, MEMBER_TRADE_ASSET_MIN_WIDTH + width - getTableWidth(fitted));
|
|
279
|
-
|
|
281
|
+
const all = layout(assetWidth);
|
|
282
|
+
return markHiddenTableColumns(all, all.filter((column) => shown.has(column.id)));
|
|
280
283
|
}
|
|
281
284
|
|
|
282
285
|
/**
|
|
@@ -304,7 +307,8 @@ export function buildMemberColumns(width: number): MemberColumn[] {
|
|
|
304
307
|
const fitted = dropColumnsToFit(layout(MEMBER_READABLE_WIDTH), width, MEMBER_DROP_ORDER);
|
|
305
308
|
const shown = new Set(fitted.map((column) => column.id));
|
|
306
309
|
const memberWidth = Math.max(MEMBER_READABLE_WIDTH, MEMBER_READABLE_WIDTH + width - getTableWidth(fitted));
|
|
307
|
-
|
|
310
|
+
const all = layout(memberWidth);
|
|
311
|
+
return markHiddenTableColumns(all, all.filter((column) => shown.has(column.id)));
|
|
308
312
|
}
|
|
309
313
|
|
|
310
314
|
export function sortedTrades(
|
|
@@ -16,7 +16,7 @@ const number = (value: unknown) => value === null || typeof value === "number" &
|
|
|
16
16
|
const count = (value: unknown) => value === null || typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
17
17
|
const code = (value: unknown) => typeof value === "string" && /^[0-9A-Z]{5}[0-9A-Z+]$/.test(value);
|
|
18
18
|
function base(data: CotPayloadBase, family: CotFamily, positions: CotPositions) {
|
|
19
|
-
if (!data ||
|
|
19
|
+
if (!data || !["CFTC", "ICE Futures Europe", "CFTC / ICE Futures Europe"].includes(data.source) || data.scope !== positions || data.reportFamily !== family
|
|
20
20
|
|| !Array.isArray(data.gaps) || !data.gaps.every((gap) => typeof gap === "string")
|
|
21
21
|
|| !Array.isArray(data.classes) || data.classes.some((row) => !COT_CLASSES[family].some((option) => option.value === row.id))
|
|
22
22
|
|| data.asOf !== null && !date(data.asOf) || !Number.isFinite(Date.parse(data.generatedAt))
|
|
@@ -71,9 +71,8 @@ export async function fetchCotBoard(family: CotFamily, traderClass: CotClass, cl
|
|
|
71
71
|
try { return validateCotBoard(await client.getCloudCotBoard(family, traderClass, positions), family, traderClass, positions); }
|
|
72
72
|
catch (error) { throw unavailable(error); }
|
|
73
73
|
}
|
|
74
|
-
// Futures-only boards keep the key they always had, so a cached board still opens.
|
|
75
74
|
const cotBoardKey = (family: CotFamily, traderClass: CotClass, positions: CotPositions) =>
|
|
76
|
-
positions === "combined" ?
|
|
75
|
+
`${family}:${traderClass}${positions === "combined" ? ":combined" : ""}${family === "disaggregated" ? ":ice" : ""}`;
|
|
77
76
|
const presentCotBoard = (payload: CotBoardPayload, stale: boolean, refreshError: string | null) => ({
|
|
78
77
|
...payload, gaps: [...payload.gaps, ...(refreshError ? [refreshError] : [])],
|
|
79
78
|
status: stale && payload.status === "available" ? "partial" as const : payload.status,
|
|
@@ -2,7 +2,7 @@ import { MISSING_VALUE } from "../../../utils/format";
|
|
|
2
2
|
import type { CotClass, CotClassSummary, CotContractPayload, CotFamily, CotHistoryPoint } from "../../../api-client/cot";
|
|
3
3
|
import type { HeadlessPaneColumn, HeadlessPaneDefinition } from "../../../types/plugin";
|
|
4
4
|
import { fetchCotBoard, fetchCotContract } from "./client";
|
|
5
|
-
import { COT_CLASSES, COT_FAMILIES, COT_MAJOR_CODES, COT_POSITIONS, COT_SCOPES, cotClass, cotContractCode, cotContractUnitText, cotFamily, cotInteger, cotMarketName, cotPositions, cotPositionsText, cotProxyFor, cotProxyNote, cotReleaseTime, cotRoot, cotScope, cotUnknownMarketMessage } from "./model";
|
|
5
|
+
import { COT_CLASSES, COT_FAMILIES, COT_MAJOR_CODES, COT_POSITIONS, COT_SCOPES, cotClass, cotContractCode, cotContractUnitText, cotDefaultFamily, cotFamily, cotInteger, cotMarketName, cotPositions, cotPositionsText, cotProxyFor, cotProxyNote, cotReleaseTime, cotRoot, cotScope, cotUnknownMarketMessage } from "./model";
|
|
6
6
|
import { COMMODITIES_VIEW_STATE } from "../commodities-energy/view-state";
|
|
7
7
|
import { REPORT_ROWS } from "../shared/headless-options";
|
|
8
8
|
import { DATE_OPTION_EXAMPLES, isoDateOption } from "../../../utils/calendar-date";
|
|
@@ -19,13 +19,13 @@ const rank = (value: unknown) => typeof value === "number" ? value.toFixed(0) :
|
|
|
19
19
|
* the app's copy of the schedule): one time for the text, CSV and JSON, the
|
|
20
20
|
* export's publication time and the metadata's `publishedAt` alike.
|
|
21
21
|
*/
|
|
22
|
-
function cotPublishedAt(data: Pick<CotContractPayload, "asOf" | "publishedAt">): string | null {
|
|
23
|
-
return data.publishedAt ?? cotReleaseTime(data.asOf);
|
|
22
|
+
function cotPublishedAt(data: Pick<CotContractPayload, "asOf" | "publishedAt" | "source">): string | null {
|
|
23
|
+
return data.publishedAt ?? (data.source === "CFTC" ? cotReleaseTime(data.asOf) : null);
|
|
24
24
|
}
|
|
25
|
-
/**
|
|
25
|
+
/** The CFTC's full publisher name for exports of its reports. */
|
|
26
26
|
const COT_PUBLISHER = "Commodity Futures Trading Commission (CFTC)";
|
|
27
|
-
function cotReleased(publishedAt: string | null) {
|
|
28
|
-
return { freshness: { publisher: COT_PUBLISHER, ...(publishedAt ? { publishedAt } : {}) } };
|
|
27
|
+
function cotReleased(publishedAt: string | null, source: CotContractPayload["source"]) {
|
|
28
|
+
return { freshness: { source, publisher: source === "CFTC" ? COT_PUBLISHER : source, ...(publishedAt ? { publishedAt } : {}) } };
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/** The pane's columns: percentiles as their rank value, net share of open interest to one decimal. */
|
|
@@ -104,15 +104,15 @@ function cotHistoryNote(data: CotContractPayload, since: string | null): string
|
|
|
104
104
|
const previous = data.reportFamily === "legacy" ? COT_CODES_BEFORE_1998[data.contract?.contractCode ?? ""] : undefined;
|
|
105
105
|
return previous
|
|
106
106
|
? `Reports under CFTC code ${data.contract!.contractCode} start ${data.historyStart}, when the CFTC began counting this market in contracts; its earlier reports are under its previous code ${previous}, in thousands of bushels, and are not joined to these. --since ${since} lists from ${data.historyStart}.`
|
|
107
|
-
: `The
|
|
107
|
+
: `The first report of this market in Gloom Cloud is ${data.historyStart}; --since ${since} lists from there.`;
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
export const cotHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
111
111
|
shape: "bundle",
|
|
112
112
|
// Tuesday positions published the Friday after; two weeks without a new report means one was missed.
|
|
113
|
-
freshness: { source: "
|
|
114
|
-
argument: { kind: "free-text", optional: true, placeholder: "code or name", description: "Futures root (KC), commodity name (coffee) or CFTC market code; omit for the extremes board." },
|
|
115
|
-
options: [{ key: "report", type: "enum", values: COT_FAMILIES.map(({ value }) => ({ value })),
|
|
113
|
+
freshness: { source: "Commitments of Traders", status: "not-a-feed", basis: "weekly report", maxAgeMinutes: 14 * 24 * 60 },
|
|
114
|
+
argument: { kind: "free-text", optional: true, placeholder: "code or name", description: "Futures root (KC), commodity name (coffee, Brent, gasoil) or CFTC/ICE market code; omit for the extremes board." },
|
|
115
|
+
options: [{ key: "report", type: "enum", values: COT_FAMILIES.map(({ value }) => ({ value })), description: "Report: legacy (default), disaggregated (default for ICE Europe markets), or tff (Traders in Financial Futures)." },
|
|
116
116
|
{ key: "traderClass", type: "enum", values: TRADER_CLASSES.map((value) => ({ value })), description: "Trader class for the extremes board; defaults by report family.",
|
|
117
117
|
pluginState: { pluginId: COMMODITIES_VIEW_STATE.cot, key: "class" } },
|
|
118
118
|
{ key: "positions", type: "enum", values: COT_POSITIONS.map(({ value }) => ({ value })), defaultValue: "futures-only", description: "Futures positions only, or futures and options combined, as in the pane.",
|
|
@@ -125,10 +125,10 @@ export const cotHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
|
125
125
|
// Weekly reports come newest first, so --tail asks for the same newest n as --limit.
|
|
126
126
|
{ key: "limit", type: "integer", aliases: ["tail", "weeks", "rows"], minimum: 1, maximum: 2000, shot: REPORT_ROWS,
|
|
127
127
|
description: "Newest weekly reports a market lists; every one by default." }],
|
|
128
|
-
discovery: { aliases: ["COT", "CFTC"], dataRequirements: ["Gloom Cloud CFTC history"], limitations: ["Positions aggregate all maturities; combined adds options, delta-adjusted.", "Legacy, disaggregated and TFF classes differ.", "Observation date is not publication date.", "Some markets have short or suppressed histories."] },
|
|
129
|
-
describe: "
|
|
128
|
+
discovery: { aliases: ["COT", "CFTC"], dataRequirements: ["Gloom Cloud CFTC and ICE Futures Europe history"], limitations: ["Positions aggregate all maturities; combined adds options, delta-adjusted.", "Legacy, disaggregated and TFF classes differ.", "Observation date is not publication date.", "Some markets have short or suppressed histories."] },
|
|
129
|
+
describe: "Commitments of Traders positioning",
|
|
130
130
|
async load(args, ctx) {
|
|
131
|
-
const family = cotFamily(args.options.report);
|
|
131
|
+
const family = cotFamily(args.options.report ?? cotDefaultFamily(cotContractCode(args.argument)));
|
|
132
132
|
const positions = cotPositions(args.options.positions);
|
|
133
133
|
if (args.argument) {
|
|
134
134
|
const code = cotContractCode(args.argument);
|
|
@@ -155,11 +155,11 @@ export const cotHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
|
155
155
|
columns: weeklyColumns,
|
|
156
156
|
// Each report's scheduled release, for an export read as of a past week; the text keeps to the positions.
|
|
157
157
|
textColumns: weeklyColumns.filter((column) => column.key !== "released"),
|
|
158
|
-
rows: weeks.map((row) => ({ reportDate: row.reportDate, released: row.publishedAt ?? cotReleaseTime(row.reportDate), openInterest: row.openInterest,
|
|
158
|
+
rows: weeks.map((row) => ({ reportDate: row.reportDate, released: row.publishedAt ?? (code.startsWith("ICE") ? null : cotReleaseTime(row.reportDate)), openInterest: row.openInterest,
|
|
159
159
|
...Object.fromEntries(row.positions.map((position) => [`${camelClass(position.id)}Net`, position.net])) })) }],
|
|
160
160
|
// "jet fuel" reads heating oil's positions, and says so.
|
|
161
161
|
...(proxy || historyNote ? { notes: [...(proxy ? [cotProxyNote(proxy)] : []), ...(historyNote ? [historyNote] : [])] } : {}),
|
|
162
|
-
errors: data.gaps, metadata: { ...data, publishedAt, complete: data.status === "available" }, ...cotReleased(publishedAt) };
|
|
162
|
+
errors: data.gaps, metadata: { ...data, publishedAt, complete: data.status === "available" }, ...cotReleased(publishedAt, data.source) };
|
|
163
163
|
}
|
|
164
164
|
const traderClass = cotClass(family, args.options.traderClass);
|
|
165
165
|
if (args.options.traderClass && traderClass !== args.options.traderClass) throw new Error("Trader class does not belong to this report family");
|
|
@@ -173,6 +173,6 @@ export const cotHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
|
173
173
|
...POSITION_COLUMNS.map((column) => column.key === "net" ? { ...column, textHeader: cotBoardNetHeader(family, traderClass) } : column),
|
|
174
174
|
{ key: "openInterest", header: "Open interest", align: "right", format: count }, { key: "reportDate", header: "As of" }],
|
|
175
175
|
rows: rows.map((row) => ({ contractCode: row.contractCode, root: cotRoot(row.contractCode) ?? row.contractCode, marketName: cotMarketName(row.marketName), reportDate: row.reportDate, openInterest: row.openInterest, ...cotPositionRow(row.position) })) }],
|
|
176
|
-
errors: data.gaps, metadata: { ...data, scope, publishedAt, complete: data.status === "available" }, ...cotReleased(publishedAt) };
|
|
176
|
+
errors: data.gaps, metadata: { ...data, scope, publishedAt, complete: data.status === "available" }, ...cotReleased(publishedAt, data.source) };
|
|
177
177
|
},
|
|
178
178
|
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import type { PluginModule } from "../plugin-module";
|
|
2
2
|
import { cotBoardCache } from "./client";
|
|
3
3
|
import { cotHeadless } from "./headless";
|
|
4
|
-
import { COT_ROOT_OPTIONS, cotContractCode, cotContractCodeForTicker, cotProxyFor, cotRoot, cotUnknownMarketMessage } from "./model";
|
|
4
|
+
import { COT_ROOT_OPTIONS, cotContractCode, cotContractCodeForTicker, cotDefaultFamily, cotProxyFor, cotRoot, cotUnknownMarketMessage } from "./model";
|
|
5
5
|
import { COT_SERIES } from "./series";
|
|
6
6
|
|
|
7
7
|
export const cotModule: PluginModule = {
|
|
8
8
|
series: COT_SERIES,
|
|
9
|
-
panes: [{ id: "cot", name: "
|
|
9
|
+
panes: [{ id: "cot", name: "Trader Positioning", icon: "P", shareItem: { argument: true }, get component(): typeof import("./pane").CotPane { const { CotPane } = require("./pane"); return CotPane; },
|
|
10
10
|
defaultPosition: "right", defaultMode: "floating", defaultFloatingSize: { width: 106, height: 30 },
|
|
11
11
|
tableExport: true, headless: cotHeadless }],
|
|
12
|
-
paneTemplates: [{ id: "cot-cot", paneId: "cot", label: "
|
|
12
|
+
paneTemplates: [{ id: "cot-cot", paneId: "cot", label: "Trader Positioning",
|
|
13
13
|
description: "Weekly futures positioning, changes, historical percentiles and cross-market extremes.",
|
|
14
|
-
keywords: ["cot", "cftc", "positioning", "commitments", "managed money", "net spec", "crude oil", "natural gas"],
|
|
14
|
+
keywords: ["cot", "cftc", "positioning", "commitments", "managed money", "net spec", "crude oil", "natural gas", "brent", "gasoil", "ICE Europe"],
|
|
15
15
|
shortcut: { prefix: "COT", aliases: ["CFTC"], argKind: "text" as const, argPlaceholder: "code or name", argOptional: true,
|
|
16
16
|
argOptions: () => COT_ROOT_OPTIONS }, headless: cotHeadless,
|
|
17
17
|
createInstance: (context, options) => {
|
|
@@ -20,8 +20,8 @@ export const cotModule: PluginModule = {
|
|
|
20
20
|
if (input && !code) throw new Error(cotUnknownMarketMessage(input));
|
|
21
21
|
// "jet fuel" opens heating oil, and the title says which market stands in.
|
|
22
22
|
const proxy = input ? cotProxyFor(input) : null;
|
|
23
|
-
return { title: code ? `COT ${cotRoot(code) ?? code}${proxy ? ` (${proxy.subject} proxy)` : ""}` : "
|
|
24
|
-
settings: { report: options?.values?.report ??
|
|
23
|
+
return { title: code ? `COT ${cotRoot(code) ?? code}${proxy ? ` (${proxy.subject} proxy)` : ""}` : "Trader Positioning", params: code ? { code, cotReport: String(options?.values?.report ?? cotDefaultFamily(code)) } : undefined,
|
|
24
|
+
settings: { report: options?.values?.report ?? cotDefaultFamily(code) }, placement: "floating" as const };
|
|
25
25
|
},
|
|
26
26
|
}],
|
|
27
27
|
setup(ctx) { cotBoardCache.attach(ctx.persistence); },
|
|
@@ -50,7 +50,23 @@ const ROOTS: Record<string, { code: string; exchange: string; priceSymbol: strin
|
|
|
50
50
|
XRP: { code: "176740", exchange: "CME", priceSymbol: null, name: "XRP", crypto: true },
|
|
51
51
|
};
|
|
52
52
|
/** The verified root aliases, labeled "ZQ 30-Day Fed Funds"; `cotContractCode` also takes every FUT board root the CFTC reports. */
|
|
53
|
-
|
|
53
|
+
const ICE_MARKETS = [
|
|
54
|
+
{ code: "ICE00B", root: "BRENT", name: "ICE Brent Crude", aliases: ["brent", "ice brent", "brent crude", "brent crude oil", "ice brent crude", "ice brent crude oil"], exchange: "NYM", priceSymbol: "BZ=F" },
|
|
55
|
+
{ code: "ICE00G", root: "GASOIL", name: "ICE Gasoil", aliases: ["gasoil", "gas oil", "ice gasoil", "ice gas oil", "low sulphur gasoil"], exchange: "ICEU", priceSymbol: null },
|
|
56
|
+
{ code: "ICEDBI", root: "ICE DUBAI", name: "ICE Dubai 1st Line", aliases: ["dubai", "ice dubai", "dubai 1st line", "ice dubai 1st line"], exchange: "ICEU", priceSymbol: null },
|
|
57
|
+
{ code: "ICE00C", root: "ICE COCOA", name: "ICE Cocoa", aliases: ["ice cocoa", "london cocoa"], exchange: "ICEU", priceSymbol: null },
|
|
58
|
+
{ code: "ICE0RC", root: "ROBUSTA", name: "ICE Robusta Coffee", aliases: ["robusta", "robusta coffee", "ice robusta", "ice robusta coffee", "rc", "ice rc"], exchange: "ICEU", priceSymbol: null },
|
|
59
|
+
{ code: "ICE00W", root: "WHITE SUGAR", name: "ICE White Sugar", aliases: ["white sugar", "ice white sugar"], exchange: "ICEU", priceSymbol: null },
|
|
60
|
+
{ code: "ICE00T", root: "ICE WHEAT", name: "ICE Wheat", aliases: ["ice wheat", "feed wheat", "uk wheat", "london wheat"], exchange: "ICEU", priceSymbol: null },
|
|
61
|
+
{ code: "067411", root: "ICE WTI", name: "ICE WTI Crude", aliases: ["ice wti", "ice wti crude", "ice wti crude oil"], exchange: "ICEU", priceSymbol: null },
|
|
62
|
+
] as const;
|
|
63
|
+
const iceMarket = (value: string) => {
|
|
64
|
+
const input = value.trim().toLowerCase().replace(/[\s_-]+/g, " ");
|
|
65
|
+
return ICE_MARKETS.find((market) => (market.aliases as readonly string[]).includes(input));
|
|
66
|
+
};
|
|
67
|
+
export const COT_ROOT_OPTIONS = [...Object.entries(ROOTS).map(([root, row]) => ({ value: root, label: root === row.name ? root : `${root} ${row.name}` })),
|
|
68
|
+
...ICE_MARKETS.map((market) => ({ value: market.aliases[0], label: market.name }))];
|
|
69
|
+
export function cotDefaultFamily(code: string | null): CotFamily { return code?.startsWith("ICE") ? "disaggregated" : "legacy"; }
|
|
54
70
|
/** The crypto roots named for a coin, which a coin pair (BTC-USD) can stand for. The micros have no pair. */
|
|
55
71
|
const COIN_PAIR_ROOTS: ReadonlySet<string> = new Set(["BTC", "ETH", "SOL", "XRP"]);
|
|
56
72
|
/**
|
|
@@ -119,6 +135,7 @@ function boardMarketCode(contract: FuturesContract): string | null {
|
|
|
119
135
|
* not appear; nothing is substituted. Everything else is one scope switch away.
|
|
120
136
|
*/
|
|
121
137
|
export const COT_MAJOR_CODES: ReadonlySet<string> = new Set([
|
|
138
|
+
...ICE_MARKETS.map((market) => market.code),
|
|
122
139
|
// Equity index and volatility
|
|
123
140
|
"13874A", "209742", "239742", "124603", "1170E1",
|
|
124
141
|
// Rates
|
|
@@ -172,6 +189,8 @@ function typedMarket(value: string): { board: FuturesContract } | { root: string
|
|
|
172
189
|
*/
|
|
173
190
|
export function cotContractCode(value: unknown): string | null {
|
|
174
191
|
if (typeof value !== "string") return null;
|
|
192
|
+
const ice = iceMarket(value);
|
|
193
|
+
if (ice) return ice.code;
|
|
175
194
|
const input = value.trim().toUpperCase().replace(/=F$/, "");
|
|
176
195
|
const alias = rootAlias(input) ?? currencyFuture(input);
|
|
177
196
|
if (alias) return alias;
|
|
@@ -219,9 +238,9 @@ const SUGGESTED_MARKETS: ReadonlyArray<readonly [string, string]> = [
|
|
|
219
238
|
*/
|
|
220
239
|
export function cotUnknownMarketMessage(value: unknown): string {
|
|
221
240
|
const market = typeof value === "string" ? typedMarket(value) : null;
|
|
222
|
-
if (market && "board" in market) return `${market.board.code} (${market.board.name}) is not reported in
|
|
241
|
+
if (market && "board" in market) return `${market.board.code} (${market.board.name}) is not reported in COT.`;
|
|
223
242
|
const known = SUGGESTED_MARKETS.map(([code, name]) => `${code} ${name}`).join(", ");
|
|
224
|
-
return `Unknown market "${String(value)}". Try a code or name such as ${known}, or a
|
|
243
|
+
return `Unknown market "${String(value)}". Try a code or name such as ${known}, Brent, gasoil, or a market code such as ${ROOTS.GC!.code} or ICE00B.`;
|
|
225
244
|
}
|
|
226
245
|
/**
|
|
227
246
|
* The code for the ticker under the cursor, when COT is opened without an
|
|
@@ -274,11 +293,12 @@ export function cotReleaseTime(reportDate: string | null | undefined): string |
|
|
|
274
293
|
|
|
275
294
|
/** The futures root a CFTC code belongs to, for titles readers recognize: a verified alias, else its FUT board root. */
|
|
276
295
|
export function cotRoot(code: string): string | null {
|
|
277
|
-
return
|
|
296
|
+
return ICE_MARKETS.find((market) => market.code === code)?.root
|
|
297
|
+
?? Object.entries(ROOTS).find(([, row]) => row.code === code)?.[0]
|
|
278
298
|
?? FUTURES_CONTRACTS.find((contract) => boardMarketCode(contract) === code)?.code
|
|
279
299
|
?? null;
|
|
280
300
|
}
|
|
281
|
-
export function cotPriceMapping(code: string) { return Object.values(ROOTS).find((row) => row.code === code) ?? PRICE_OVERLAYS[code] ?? null; }
|
|
301
|
+
export function cotPriceMapping(code: string) { return ICE_MARKETS.find((market) => market.code === code) ?? Object.values(ROOTS).find((row) => row.code === code) ?? PRICE_OVERLAYS[code] ?? null; }
|
|
282
302
|
export function cotClass(family: CotFamily, value: unknown): CotClass {
|
|
283
303
|
return COT_CLASSES[family].find((row) => row.value === value)?.value ?? COT_CLASSES[family][0]!.value;
|
|
284
304
|
}
|