@gloom-sh/terminal 0.20.10 → 0.20.12
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 +2 -1
- package/patches/@opentui%2Fcore@0.3.2.patch +16 -0
- package/src/api-client/awards.ts +16 -0
- package/src/api-client/central-bank-rates.ts +5 -0
- package/src/api-client/data.ts +55 -2
- package/src/api-client/index.ts +18 -1
- package/src/api-client/request.ts +86 -3
- package/src/api-client/socket-connection.ts +366 -0
- package/src/api-client/socket-features.ts +75 -0
- package/src/api-client/socket-frames.ts +161 -0
- package/src/api-client/socket-listeners.ts +207 -0
- package/src/api-client/socket-quotes.ts +332 -0
- package/src/api-client/socket.ts +168 -983
- package/src/api-client/supply-chain-graph.ts +4 -2
- package/src/api-client/supply-chain.ts +8 -0
- package/src/api-client/types/econ.ts +10 -7
- package/src/api-client/types/filings-and-calls.ts +8 -0
- package/src/app/global-shortcuts.ts +2 -1
- package/src/app/keybindings/actions.ts +19 -0
- package/src/app/pane-runtime/index.tsx +18 -3
- package/src/app/pane-runtime/layout-placement.ts +63 -0
- package/src/app/pane-runtime/ticker-open-runtime.ts +10 -2
- package/src/brokers/signed-in/adapter.ts +19 -5
- package/src/brokers/signed-in/client.ts +13 -1
- package/src/brokers/signed-in/sign-in-dialog.tsx +33 -9
- package/src/capabilities/chart-series.ts +4 -1
- package/src/cli/board-coins.ts +10 -1
- package/src/cli/commands/crypto-hints.ts +3 -2
- package/src/cli/commands/fred-series.ts +0 -54
- package/src/cli/commands/market.ts +209 -31
- package/src/cli/commands/overview.ts +47 -14
- package/src/cli/commands/search.ts +37 -8
- package/src/cli/commands/ticker.ts +15 -4
- package/src/cli/desktop-pane-shot.ts +27 -2
- package/src/cli/fx-quote-rate.ts +1 -1
- package/src/cli/glossary.ts +14 -5
- package/src/cli/history-catalog-series.ts +85 -0
- package/src/cli/index.ts +1 -1
- package/src/cli/list-progress.ts +45 -0
- package/src/cli/listing-arg.ts +71 -7
- package/src/cli/name-entries.ts +8 -4
- package/src/cli/not-a-ticker.ts +2 -2
- package/src/cli/pane-functions/freshness.ts +50 -3
- package/src/cli/pane-functions/index.ts +7 -4
- package/src/cli/pane-functions/market-session.ts +66 -14
- package/src/cli/pane-functions/options.ts +5 -0
- package/src/cli/pane-functions/resolver.ts +9 -2
- package/src/cli/pane-functions/screenshot-assessment.ts +28 -3
- package/src/cli/pane-functions/screenshot-types.ts +6 -0
- package/src/cli/quote-answer.ts +49 -10
- package/src/cli/quote-list-reads.ts +87 -0
- package/src/cli/report-tables.ts +70 -13
- package/src/cli/result.ts +24 -2
- package/src/cli/symbol-list.ts +31 -4
- package/src/cli/terminal-code-hints.ts +83 -0
- package/src/cli/ticker-resolution.ts +2 -1
- package/src/cli/treasury-yields.ts +5 -0
- package/src/components/chart/native/kitty/manager.ts +2 -0
- package/src/components/chart/native/surface/manager.ts +211 -11
- package/src/components/command-bar/action-runtime.ts +2 -0
- package/src/components/command-bar/panel/index.tsx +2 -13
- package/src/components/command-bar/panel/layout.ts +1 -7
- package/src/components/command-bar/panel/runtime.ts +0 -1
- package/src/components/command-bar/panel/types.ts +0 -2
- package/src/components/command-bar/routing/launch-request.ts +2 -1
- package/src/components/command-bar/routing/navigation-state.ts +4 -2
- package/src/components/command-bar/workflow/types.ts +6 -0
- package/src/components/data-table/column-menu.tsx +89 -0
- package/src/components/data-table/sort-menu.tsx +9 -2
- package/src/components/data-table/view.tsx +33 -6
- package/src/components/form-modal/content.tsx +10 -0
- package/src/components/index.ts +1 -1
- package/src/components/layout/detached-pane-shell.tsx +3 -0
- package/src/components/layout/double-escape-close.ts +34 -3
- package/src/components/layout/floating-pane.tsx +10 -4
- package/src/components/layout/pane/cycle-order.ts +66 -2
- package/src/components/layout/pane/footer/index.tsx +25 -11
- package/src/components/layout/pane/footer/model.ts +62 -20
- package/src/components/layout/pane/header.tsx +140 -31
- package/src/components/layout/pane/sidebar.tsx +138 -20
- package/src/components/layout/pane/status-footer.ts +3 -1
- package/src/components/layout/shell/active-drag.ts +18 -13
- package/src/components/layout/shell/drag/magnets.ts +34 -18
- package/src/components/layout/shell/drag/runtime.ts +5 -0
- package/src/components/layout/shell/index.tsx +25 -0
- package/src/components/layout/shell/menu.ts +9 -0
- package/src/components/layout/shell/pane/actions.ts +36 -0
- package/src/components/layout/shell/pane/management-shortcuts.ts +27 -3
- package/src/components/layout/shell/pane-occlusion.ts +40 -0
- package/src/components/layout/shell/shortcuts.ts +17 -1
- package/src/components/layout/shell/terminal-pointer-runtime.ts +39 -6
- package/src/components/layout/shell/window-mode/index.ts +5 -16
- package/src/components/layout/shell/window-mode/overlays.tsx +3 -1
- package/src/components/market-board/index.tsx +14 -5
- package/src/components/metric-treemap/index.tsx +3 -1
- package/src/components/ticker/list-table-view.tsx +5 -0
- package/src/components/ui/button.tsx +48 -4
- package/src/components/ui/data-table/column-order.ts +180 -0
- package/src/components/ui/data-table/index.tsx +12 -1
- package/src/components/ui/data-table/opentui/index.tsx +291 -32
- package/src/components/ui/data-table/opentui/model.ts +43 -4
- package/src/components/ui/data-table/types.ts +56 -0
- package/src/components/ui/data-table/use-column-order.ts +135 -0
- package/src/components/ui/index.ts +1 -1
- package/src/components/ui/inline-quick-add.tsx +19 -3
- package/src/components/ui/list-view.tsx +11 -5
- package/src/components/ui/query-bar.tsx +16 -1
- package/src/components/ui/selection-fill.ts +39 -0
- package/src/components/ui/table-layout.ts +120 -0
- package/src/core/state/app/layout-reducer.ts +2 -1
- package/src/core/state/app/pane-choices.ts +68 -0
- package/src/core/state/app/state.ts +14 -6
- package/src/core/state/app/types.ts +8 -0
- package/src/docs/snapshot.json +3 -2
- package/src/i18n/es.ts +2 -0
- package/src/i18n/ja.ts +2 -0
- package/src/i18n/ko.ts +2 -0
- package/src/i18n/zh-cn.ts +2 -0
- package/src/i18n/zh-tw.ts +2 -0
- package/src/layout/pane-manager/dock-tree.ts +19 -0
- package/src/layout/pane-manager/index.ts +3 -0
- package/src/market-data/coordinator/index.ts +4 -3
- package/src/market-data/coordinator/quotes.ts +12 -4
- package/src/market-data/market/freshness.ts +33 -0
- package/src/market-data/market/status.ts +5 -1
- package/src/market-data/quotes/contributions.ts +10 -0
- package/src/market-data/quotes/freshness.ts +31 -0
- package/src/market-data/quotes/live-valuation.ts +32 -5
- package/src/market-data/quotes/regular-session-valuation.ts +1 -1
- package/src/market-data/quotes/resolution.ts +4 -0
- package/src/market-data/quotes/time.ts +0 -14
- package/src/plugins/builtin/account-management/index.tsx +1 -0
- package/src/plugins/builtin/awards/detail.tsx +12 -4
- package/src/plugins/builtin/awards/headless.ts +29 -8
- package/src/plugins/builtin/awards/model.ts +36 -2
- package/src/plugins/builtin/awards/pane.tsx +7 -4
- package/src/plugins/builtin/broker-manager/detail.tsx +5 -3
- package/src/plugins/builtin/broker-manager/index.tsx +7 -6
- package/src/plugins/builtin/broker-manager/model.ts +15 -6
- package/src/plugins/builtin/broker-manager/pane-actions.tsx +11 -4
- package/src/plugins/builtin/broker-manager/sign-in-end.ts +50 -19
- package/src/plugins/builtin/broker-manager/table.ts +10 -4
- package/src/plugins/builtin/broker-trading/index.tsx +1 -1
- package/src/plugins/builtin/central-bank-rates/headless.ts +6 -6
- package/src/plugins/builtin/central-bank-rates/index.tsx +1 -1
- package/src/plugins/builtin/central-bank-rates/model.ts +21 -3
- package/src/plugins/builtin/central-bank-rates/pane.tsx +15 -5
- package/src/plugins/builtin/chart-composer/headless.ts +5 -1
- package/src/plugins/builtin/chart-composer/pane.tsx +1 -0
- package/src/plugins/builtin/chat/content/handle-prompt.tsx +4 -0
- package/src/plugins/builtin/chat/controller/realtime.ts +17 -1
- package/src/plugins/builtin/chat/message/terminal.tsx +4 -1
- package/src/plugins/builtin/chat/sidebar.tsx +35 -19
- package/src/plugins/builtin/cloud/askg/pane.tsx +4 -0
- package/src/plugins/builtin/cloud/askg/tool-timeline.tsx +2 -0
- package/src/plugins/builtin/cloud/plugin.tsx +1 -0
- package/src/plugins/builtin/cloud/team/module.tsx +1 -0
- package/src/plugins/builtin/cloud/thesis/detail.tsx +9 -4
- package/src/plugins/builtin/commodity-balances/pane.tsx +13 -5
- package/src/plugins/builtin/company-kpis/model.ts +3 -3
- package/src/plugins/builtin/connections/index.ts +1 -0
- package/src/plugins/builtin/credit-boards/cdx-pane.tsx +9 -5
- package/src/plugins/builtin/credit-boards/client.ts +5 -0
- package/src/plugins/builtin/credit-boards/headless.ts +1 -6
- package/src/plugins/builtin/credit-boards/model.ts +0 -6
- package/src/plugins/builtin/credit-boards/series.ts +19 -8
- package/src/plugins/builtin/credit-boards/sovr-pane.tsx +9 -5
- package/src/plugins/builtin/crypto-etf-flows/headless.ts +23 -13
- package/src/plugins/builtin/crypto-etf-flows/pane.tsx +8 -3
- package/src/plugins/builtin/debt-maturities/headless.ts +16 -7
- package/src/plugins/builtin/debt-maturities/model.ts +9 -15
- package/src/plugins/builtin/debt-maturities/pane.tsx +9 -10
- package/src/plugins/builtin/earnings/board-model.ts +33 -4
- package/src/plugins/builtin/earnings/board.tsx +15 -3
- package/src/plugins/builtin/earnings/calendar.tsx +10 -6
- package/src/plugins/builtin/earnings/client.ts +0 -9
- package/src/plugins/builtin/earnings/headless.ts +10 -7
- package/src/plugins/builtin/earnings/history.tsx +21 -14
- package/src/plugins/builtin/earnings-calls/data.ts +24 -4
- package/src/plugins/builtin/earnings-calls/format.ts +23 -5
- package/src/plugins/builtin/earnings-calls/headless.ts +23 -3
- package/src/plugins/builtin/earnings-calls/index.tsx +1 -0
- package/src/plugins/builtin/earnings-calls/model.ts +11 -1
- package/src/plugins/builtin/earnings-calls/pane.tsx +2 -5
- package/src/plugins/builtin/econ/calendar-model.ts +27 -0
- package/src/plugins/builtin/econ/fred-catalog.ts +3 -0
- package/src/plugins/builtin/econ/index.tsx +9 -2
- package/src/plugins/builtin/econ-statistics/headless.ts +3 -1
- package/src/plugins/builtin/econ-statistics/index.tsx +1 -1
- package/src/plugins/builtin/equity-screener/live.ts +74 -18
- package/src/plugins/builtin/equity-screener/model.ts +19 -4
- package/src/plugins/builtin/equity-screener/pane.tsx +19 -14
- package/src/plugins/builtin/equity-screener/refresh-anchor.ts +45 -0
- package/src/plugins/builtin/equity-screener/results.ts +22 -2
- package/src/plugins/builtin/equity-screener/screen-check.ts +9 -3
- package/src/plugins/builtin/fear-greed/headless.ts +16 -13
- package/src/plugins/builtin/fear-greed/pane.tsx +12 -4
- package/src/plugins/builtin/filing-events/index.tsx +1 -0
- package/src/plugins/builtin/futures/index.tsx +15 -1
- package/src/plugins/builtin/futures/table.tsx +1 -1
- package/src/plugins/builtin/fx-matrix/index.tsx +32 -19
- package/src/plugins/builtin/holders/pane.tsx +30 -20
- package/src/plugins/builtin/insider/table.tsx +10 -7
- package/src/plugins/builtin/insider/tickers.tsx +1 -1
- package/src/plugins/builtin/iv-history/events.ts +5 -0
- package/src/plugins/builtin/iv-history/headless.ts +15 -9
- package/src/plugins/builtin/jobs/index.tsx +1 -0
- package/src/plugins/builtin/kelly-sizer/sections.tsx +2 -0
- package/src/plugins/builtin/macro-day/headless.ts +15 -6
- package/src/plugins/builtin/macro-day/model.ts +1 -1
- package/src/plugins/builtin/macro-day/releases.ts +25 -16
- package/src/plugins/builtin/market-movers/index.tsx +20 -8
- package/src/plugins/builtin/market-movers/model.ts +5 -0
- package/src/plugins/builtin/market-movers/session-body.tsx +2 -1
- package/src/plugins/builtin/money-markets/headless.ts +12 -2
- package/src/plugins/builtin/money-markets/pane.tsx +10 -1
- package/src/plugins/builtin/options/view.tsx +3 -0
- package/src/plugins/builtin/options-positioning/pane.tsx +1 -1
- package/src/plugins/builtin/options-scenario/pane.tsx +2 -1
- package/src/plugins/builtin/perps/cascade-tabs.tsx +2 -1
- package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +4 -31
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +19 -1
- package/src/plugins/builtin/portfolio-list/quick-add/index.tsx +22 -8
- package/src/plugins/builtin/portfolio-list/summary/index.tsx +6 -8
- package/src/plugins/builtin/portfolio-list/table.tsx +15 -1
- package/src/plugins/builtin/rate-path/pane.tsx +2 -0
- package/src/plugins/builtin/realized-vol/headless.ts +28 -2
- package/src/plugins/builtin/revenue-breakdown/pane.tsx +2 -0
- package/src/plugins/builtin/reverse-dcf/pane.tsx +2 -1
- package/src/plugins/builtin/risk-factors/index.tsx +1 -0
- package/src/plugins/builtin/seasonality/pane.tsx +2 -1
- package/src/plugins/builtin/shared/source-footer.ts +70 -0
- package/src/plugins/builtin/short-interest/publications-pane.tsx +5 -1
- package/src/plugins/builtin/short-volume/pane.tsx +5 -1
- package/src/plugins/builtin/social-mentions/outliers.tsx +10 -1
- package/src/plugins/builtin/social-mentions/pane.tsx +7 -0
- package/src/plugins/builtin/supply-chain/client.ts +3 -1
- package/src/plugins/builtin/supply-chain/flow.tsx +25 -8
- package/src/plugins/builtin/supply-chain/graph-client.ts +1 -1
- package/src/plugins/builtin/supply-chain/graph-evidence.ts +1 -1
- package/src/plugins/builtin/supply-chain/graph-model.ts +12 -1
- package/src/plugins/builtin/supply-chain/graph-pane.tsx +9 -8
- package/src/plugins/builtin/supply-chain/graph.tsx +12 -6
- package/src/plugins/builtin/supply-chain/headless.ts +13 -7
- package/src/plugins/builtin/supply-chain/model.ts +68 -11
- package/src/plugins/builtin/supply-chain/pane.tsx +9 -6
- package/src/plugins/builtin/supply-chain/row-evidence.tsx +5 -5
- package/src/plugins/builtin/thirteenf/pane.tsx +2 -0
- package/src/plugins/builtin/ticker-detail/financials/model.ts +28 -6
- package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +26 -9
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +58 -35
- package/src/plugins/builtin/ticker-detail/overview/components.tsx +14 -1
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +2 -0
- package/src/plugins/builtin/ticker-detail/pane.tsx +48 -24
- package/src/plugins/builtin/ticker-detail/quote-footer.ts +5 -0
- package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +6 -3
- package/src/plugins/builtin/treasury-auctions/after.ts +50 -23
- package/src/plugins/builtin/treasury-auctions/cache.ts +23 -5
- package/src/plugins/builtin/treasury-auctions/headless.ts +226 -37
- package/src/plugins/builtin/treasury-auctions/hk-headless.ts +11 -5
- package/src/plugins/builtin/treasury-auctions/hk-view.tsx +27 -25
- package/src/plugins/builtin/treasury-auctions/hk.ts +60 -8
- package/src/plugins/builtin/treasury-auctions/index.tsx +3 -0
- package/src/plugins/builtin/treasury-auctions/keys.ts +27 -0
- package/src/plugins/builtin/treasury-auctions/like.ts +137 -0
- package/src/plugins/builtin/treasury-auctions/model.ts +100 -22
- package/src/plugins/builtin/treasury-auctions/pane.tsx +39 -11
- package/src/plugins/builtin/vol-surface/heat-grid.tsx +6 -3
- package/src/plugins/builtin/vol-surface/pane.tsx +7 -3
- package/src/plugins/builtin/world-indices/index.tsx +5 -1
- package/src/plugins/builtin/yield-curve/index.tsx +2 -1
- package/src/plugins/runtime/index.tsx +1 -0
- package/src/plugins/runtime/state.ts +20 -0
- package/src/portfolio/column-values.ts +8 -2
- package/src/public/__snapshots__/public-api.test.ts.snap +5 -0
- package/src/public/react.ts +7 -0
- package/src/react/auto-refresh.ts +29 -0
- package/src/renderers/browser/deeplink-bridge.ts +24 -3
- package/src/renderers/dom/data-table/column-drag.ts +147 -0
- package/src/renderers/dom/data-table/index.tsx +22 -0
- package/src/renderers/dom/data-table/row.tsx +27 -5
- package/src/renderers/dom/desktop/query-bar.tsx +229 -60
- package/src/renderers/dom/host/overflow-fade-px.ts +2 -0
- package/src/renderers/dom/host/overflow-fade.ts +1 -2
- package/src/renderers/dom/styles.css +47 -5
- package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +2 -1
- package/src/renderers/opentui/chart-surface.tsx +1 -0
- package/src/renderers/opentui/frame-hits.ts +33 -0
- package/src/renderers/opentui/host.tsx +2 -0
- package/src/renderers/opentui/native-surface.ts +14 -21
- package/src/renderers/opentui/test-utils.tsx +3 -0
- package/src/series/types.ts +2 -0
- package/src/sources/gloomberb-cloud/fred-attribution.ts +86 -0
- package/src/sources/gloomberb-cloud/index.ts +25 -1
- package/src/sources/gloomberb-cloud/normalizers.ts +22 -3
- package/src/sources/provider-errors.ts +64 -1
- package/src/sources/provider-router/batches.ts +19 -0
- package/src/sources/provider-router/index.ts +7 -1
- package/src/state/app/context/index.tsx +46 -1
- package/src/state/pane-unsent-work.ts +47 -0
- package/src/test-support/app-store.ts +24 -1
- package/src/test-support/shell-pane-keys.tsx +5 -0
- package/src/test-support/telemetry-guard.ts +83 -0
- package/src/test-support/test-env.ts +12 -0
- package/src/theme/colors.ts +17 -1
- package/src/theme/ui-tokens.ts +50 -1
- package/src/tickers/listing-venues.ts +11 -1
- package/src/tickers/search/japanese-names.json +1 -0
- package/src/tickers/search/japanese-names.ts +152 -0
- package/src/tickers/terminal-codes.ts +55 -6
- package/src/time-series/base-series.ts +3 -0
- package/src/time-series/live-quotes.ts +3 -9
- package/src/types/data-provider.ts +6 -0
- package/src/types/financials.ts +11 -0
- package/src/types/plugin-contributions.ts +7 -0
- package/src/types/plugin-panes.ts +7 -0
- package/src/ui/host.tsx +24 -0
- package/src/ui/pointer-drag.ts +11 -2
- package/src/utils/double-escape-close.ts +42 -0
- package/src/utils/fundamentals.ts +14 -3
- package/src/utils/fx-status.ts +30 -7
- package/src/utils/network-failure.ts +23 -0
- package/src/utils/share-multiples.cases.json +780 -2
- package/src/utils/share-multiples.ts +154 -24
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { seriesMoves, type MoveHorizon } from "../../plugins/builtin/shared/move-rank";
|
|
2
|
-
import { seriesNotOnFred } from "../../sources/gloomberb-cloud/fred-series";
|
|
3
2
|
import { ICE_SPREAD_SERIES } from "../../time-series/ice-credit";
|
|
4
3
|
import { toBasisPoints } from "../../utils/basis-points";
|
|
5
|
-
import { parseReportTime } from "../../utils/utc-time";
|
|
6
4
|
|
|
7
5
|
/** Where `fred` starts when `--start` is not given. */
|
|
8
6
|
export const DEFAULT_FRED_START = "2021-01-01";
|
|
@@ -115,58 +113,6 @@ export function basisPointsCell(value: unknown): string {
|
|
|
115
113
|
return String(rounded === 0 ? 0 : rounded);
|
|
116
114
|
}
|
|
117
115
|
|
|
118
|
-
/**
|
|
119
|
-
* When FRED last updated a series, its `last_updated` (`2026-10-09 08:08:04-05`),
|
|
120
|
-
* as an ISO instant in UTC: the publication time an export cites. Only when
|
|
121
|
-
* that update covers the newest observation shown (`observationEnd` reaches
|
|
122
|
-
* it): metadata from before it says nothing about when it was published.
|
|
123
|
-
* Null when it does not, or when FRED's metadata does not say.
|
|
124
|
-
*/
|
|
125
|
-
export function fredPublicationTime(
|
|
126
|
-
info: { lastUpdated?: string | null; observationEnd?: string | null } | null | undefined,
|
|
127
|
-
newestDate: string | null | undefined,
|
|
128
|
-
): string | null {
|
|
129
|
-
if (newestDate && !(info?.observationEnd && info.observationEnd >= newestDate)) return null;
|
|
130
|
-
const iso = (info?.lastUpdated ?? "").trim().replace(/^(\d{4}-\d{2}-\d{2}) /, "$1T").replace(/([+-]\d{2})$/, "$1:00");
|
|
131
|
-
const time = parseReportTime(iso);
|
|
132
|
-
return time && !time.dateOnly ? new Date(time.time).toISOString() : null;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/** Where a FRED report's figures come from, as its source line names them. */
|
|
136
|
-
export interface FredProvenance {
|
|
137
|
-
source: string;
|
|
138
|
-
publisher?: string;
|
|
139
|
-
publishedAt?: string;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Where the newest of these observations comes from: FRED, unless Gloom
|
|
144
|
-
* Cloud carried a value FRED does not list yet and named its publisher. Then
|
|
145
|
-
* the source line names that publisher and when it published, so a reader
|
|
146
|
-
* looking for the figure in FRED's own data knows it is not there yet:
|
|
147
|
-
* `U.S. Treasury via FRED, published 2026-10-09`. Null for FRED's own.
|
|
148
|
-
*/
|
|
149
|
-
export function fredProvenance(
|
|
150
|
-
observations: ReadonlyArray<{ date: string; publisher?: string; publishedAt?: string }>,
|
|
151
|
-
seriesId?: string,
|
|
152
|
-
): FredProvenance | null {
|
|
153
|
-
const ahead = observations.filter((observation) => observation.publisher?.trim());
|
|
154
|
-
if (ahead.length === 0) return null;
|
|
155
|
-
const publishers = [...new Set(ahead.map((observation) => observation.publisher!.trim()))];
|
|
156
|
-
const times = ahead.flatMap((observation) => {
|
|
157
|
-
const time = parseReportTime(observation.publishedAt);
|
|
158
|
-
return time ? [new Date(time.time).toISOString()] : [];
|
|
159
|
-
}).sort();
|
|
160
|
-
const publishedAt = times.at(-1);
|
|
161
|
-
const publisher = publishers.join(" and ");
|
|
162
|
-
return {
|
|
163
|
-
// A series FRED does not carry names whose publication it is read from instead (TurkStat via the CBRT).
|
|
164
|
-
source: `${publisher} via ${(seriesId ? seriesNotOnFred(seriesId)?.via : null) ?? "FRED"}${publishedAt ? `, published ${publishedAt.slice(0, 10)}` : ""}`,
|
|
165
|
-
publisher,
|
|
166
|
-
...(publishedAt ? { publishedAt } : {}),
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
|
|
170
116
|
/**
|
|
171
117
|
* Series FRED itself publishes late, with what a reader should know under the
|
|
172
118
|
* table. Add a series here when its newest FRED observation is not the newest
|
|
@@ -63,7 +63,10 @@ import {
|
|
|
63
63
|
} from "../../plugins/builtin/research/analyst-model";
|
|
64
64
|
import { hasAnalystCoverage, loadAnalystResearch, noAnalystCoverageText } from "../../plugins/builtin/research/client";
|
|
65
65
|
import { getPublishedUsEquityCalendarYears, getPublishedUsEquitySession } from "../../market-data/published-us-sessions";
|
|
66
|
-
import {
|
|
66
|
+
import {
|
|
67
|
+
awaitingFirstDelayedPrint, dailyCloseSessionLabel, dailyCloseText, isQuoteStaleForCurrentSession, noPrintsTodayText, nominalPriceText,
|
|
68
|
+
nominalSessionLabel,
|
|
69
|
+
} from "../../market-data/quotes/freshness";
|
|
67
70
|
import {
|
|
68
71
|
coinOptionsAlternativesText, isCoinWithoutOptions, isOptionsUnavailableError, listedOptionsAlternative, optionsUnavailableTitle,
|
|
69
72
|
} from "../../market-data/options-alternatives";
|
|
@@ -194,6 +197,7 @@ import {
|
|
|
194
197
|
symbolListNotes,
|
|
195
198
|
type HistoryListRow,
|
|
196
199
|
} from "../history-export";
|
|
200
|
+
import { catalogSeriesId, loadCatalogSeriesHistory, type CatalogSeriesHistory } from "../history-catalog-series";
|
|
197
201
|
import { fail, failWithError, isCliFailure, NO_DATA_CODE } from "../errors";
|
|
198
202
|
import { createConcurrencyLimiter, mapWithConcurrency } from "../../utils/concurrency";
|
|
199
203
|
import { CLOSE_COPIED_FLAG, MISSING_VOLUME_TEXT } from "../../utils/price-history-integrity";
|
|
@@ -310,12 +314,12 @@ import { isUnservedWithoutReason, notATickerSymbol, providerMissReason } from ".
|
|
|
310
314
|
import { isNetworkFailure } from "../../utils/network-failure";
|
|
311
315
|
import { withSavedCopy, type ReportFreshness } from "../pane-functions/freshness";
|
|
312
316
|
import { isNotATickerMessage } from "../not-a-ticker";
|
|
313
|
-
import {
|
|
317
|
+
import { useKnownCoins } from "../board-coins";
|
|
314
318
|
import { suggestUsTicker, type ListingSuggestion } from "../listing-suggestion";
|
|
315
|
-
import { quotedPhrase, splitSymbolArgs, uniqueSecuritySymbols } from "../symbol-args";
|
|
319
|
+
import { quotedPhrase, splitSymbolArgs, symbolInputKey, uniqueSecuritySymbols } from "../symbol-args";
|
|
316
320
|
import { isCompanyNameInput } from "../../tickers/company-name-listing";
|
|
317
321
|
import { readNameEntries, readPhraseArgument } from "../name-entries";
|
|
318
|
-
import { readSymbolList, SymbolListError } from "../symbol-list";
|
|
322
|
+
import { readSymbolList, SymbolListError, type TypedForm } from "../symbol-list";
|
|
319
323
|
import { notASymbolError } from "../symbol-cells";
|
|
320
324
|
import { cliPerpetualContract, perpetualContractStats, type PerpetualContractPayload } from "../perpetual-contract";
|
|
321
325
|
import { isSubMinuteInterval, knownGapMessage, subMinuteDataMessage } from "../known-gaps";
|
|
@@ -331,7 +335,9 @@ import {
|
|
|
331
335
|
import { noSecReportsNotice, nonUsSecListingVenue, secFilingItemCodes } from "../../utils/sec";
|
|
332
336
|
import type { MarketContext } from "../types";
|
|
333
337
|
import { windowRows } from "../row-window";
|
|
334
|
-
import { answerQuote, errorMessage, notUsTickerSentence, withJoinedCompanyNames } from "../quote-answer";
|
|
338
|
+
import { answerQuote, errorMessage, indexFormRead, notUsTickerSentence, withJoinedCompanyNames, type QuoteAnswer } from "../quote-answer";
|
|
339
|
+
import { QUOTE_PROGRESS_MIN_SYMBOLS, quotesWithRetries } from "../quote-list-reads";
|
|
340
|
+
import { listProgressNotice } from "../list-progress";
|
|
335
341
|
import { crossRate, describeFxConversion, describeFxLegs, describeFxRate, formatFxAmount, formatFxRate, FX_USAGE, fxSideCode, fxSubUnit, fxUnitRate, parseFxArgs, type FxQuotedFigure, type FxRequest } from "../fx-pair";
|
|
336
342
|
import {
|
|
337
343
|
describeCarrySides,
|
|
@@ -429,6 +435,10 @@ type QuoteCliRecord = Omit<QuoteBatchResult, "error"> & {
|
|
|
429
435
|
formerIssuer?: FormerIssuer;
|
|
430
436
|
/** A bare symbol read on a listing abroad that is one slip from a US ticker: the US ticker it was most likely typed for. */
|
|
431
437
|
usSuggestion?: ListingSuggestion;
|
|
438
|
+
/** A list's entry the row is for, as typed (`USDJPY Curncy`, `USDJPY`). */
|
|
439
|
+
input?: string;
|
|
440
|
+
/** The entry of an earlier row of the list that is the same listing, which this row repeats. */
|
|
441
|
+
duplicateOf?: string;
|
|
432
442
|
};
|
|
433
443
|
type FinancialsCliData = TickerFinancials & {
|
|
434
444
|
symbol: string;
|
|
@@ -465,10 +475,26 @@ function rangeTypedAsSymbol(entry: string): HistoryRange | null {
|
|
|
465
475
|
|
|
466
476
|
function parseRange(value: string | undefined, ctx: Parameters<CliCommandDef["execute"]>[1]): HistoryRange {
|
|
467
477
|
const range = readHistoryRange(value ?? "1Y");
|
|
478
|
+
// A date (2026/08/01, 2026-08-01, 2026) is where bars start, which --from takes; --range is a span back from now.
|
|
479
|
+
const from = range ? null : rangeTypedAsDate(value ?? "");
|
|
480
|
+
if (from) {
|
|
481
|
+
ctx.fail(`--range takes a span back from now, such as 3M or 1Y; ${value} is a date.`,
|
|
482
|
+
`For the bars from ${from}: --from ${from}${from.length > 4 ? "" : " (a year alone is from its first day)"}, with --to for an end.`);
|
|
483
|
+
}
|
|
468
484
|
if (!range) ctx.fail(`Unknown range "${value}".`, `Use one of ${HISTORY_RANGES.join(", ")}, or ${HISTORY_RANGE_ALIASES}.`);
|
|
469
485
|
return range!;
|
|
470
486
|
}
|
|
471
487
|
|
|
488
|
+
/** A date typed for --range, as --from takes it (2026-08-01 for 2026/08/01 or 2026.08.01, a year as is); null for anything else. */
|
|
489
|
+
function rangeTypedAsDate(value: string): string | null {
|
|
490
|
+
const typed = value.trim();
|
|
491
|
+
if (/^(?:19|20)\d{2}$/.test(typed)) return typed;
|
|
492
|
+
const date = /^((?:19|20)\d{2})[-/.](\d{1,2})[-/.](\d{1,2})$/.exec(typed);
|
|
493
|
+
if (!date) return null;
|
|
494
|
+
const iso = `${date[1]}-${date[2]!.padStart(2, "0")}-${date[3]!.padStart(2, "0")}`;
|
|
495
|
+
return Number.isNaN(Date.parse(`${iso}T00:00:00Z`)) ? null : iso;
|
|
496
|
+
}
|
|
497
|
+
|
|
472
498
|
function parseNewsFeed(value: string | undefined): NewsQuery["feed"] | undefined {
|
|
473
499
|
return value && VALID_NEWS_FEEDS.has(value as NewsFeed) ? value as NewsQuery["feed"] : undefined;
|
|
474
500
|
}
|
|
@@ -488,7 +514,9 @@ function normalizeSymbols(args: string[]): string[] {
|
|
|
488
514
|
* (`Aeon`) too: it may be a company's name as much as a ticker (`titleCaseCompanyName`).
|
|
489
515
|
*/
|
|
490
516
|
function uniqueEntries(entries: readonly string[]): string[] {
|
|
491
|
-
|
|
517
|
+
// A catalog series' id keeps the case its source names it in (CAP:bond-yield:jp-10y).
|
|
518
|
+
return uniqueSecuritySymbols(entries.map((entry) => catalogSeriesId(entry)
|
|
519
|
+
?? (isCompanyNameInput(entry) || isTitleCaseWord(entry) ? entry : entry.toUpperCase())));
|
|
492
520
|
}
|
|
493
521
|
|
|
494
522
|
/**
|
|
@@ -513,17 +541,18 @@ async function readListedSymbols(
|
|
|
513
541
|
market: MarketContext,
|
|
514
542
|
ctx: Parameters<CliCommandDef["execute"]>[1],
|
|
515
543
|
usage: string,
|
|
516
|
-
): Promise<{ symbols: string[]; notes: string[] }> {
|
|
544
|
+
): Promise<{ symbols: string[]; notes: string[]; typedForms: TypedForm[] }> {
|
|
517
545
|
try {
|
|
546
|
+
const typedForms: TypedForm[] = [];
|
|
518
547
|
const list = await readSymbolList({
|
|
519
|
-
args, file, stdinPiped: false, readEntries: (entries) => readNameEntries(entries, market.dataProvider),
|
|
548
|
+
args, file, stdinPiped: false, readEntries: (entries) => readNameEntries(entries, market.dataProvider), typedForms,
|
|
520
549
|
});
|
|
521
550
|
// Only numbers, or nothing: the message says what was left out (`Ignored 1.899, a number, not a symbol.`).
|
|
522
551
|
if (list.symbols.length === 0) {
|
|
523
552
|
const where = file && file !== "-" ? file : args.includes("-") ? "standard input" : "what was given";
|
|
524
553
|
ctx.fail([`No symbols in ${where}.`, ...list.notes].join(" "), usage);
|
|
525
554
|
}
|
|
526
|
-
return { symbols: uniqueEntries(list.symbols), notes: list.notes };
|
|
555
|
+
return { symbols: uniqueEntries(list.symbols), notes: list.notes, typedForms };
|
|
527
556
|
} catch (error) {
|
|
528
557
|
if (error instanceof SymbolListError) ctx.fail(error.message, usage);
|
|
529
558
|
throw error;
|
|
@@ -536,6 +565,7 @@ const QUOTE_CSV_SECTION = {
|
|
|
536
565
|
lines: [
|
|
537
566
|
"Last, Chg%, Prev Close and each extended print are plain numbers. Cur is the currency; currency_or_unit is the unit: the currency, a pair's quote currency per base (JPY per USD for USDJPY=X), index points or pct for a yield. A pre-market, after-hours or overnight print's move is in Pre-Market Chg%, After Hours Chg% or Overnight Chg%, and compare's day range in Day Low and Day High, after the columns the export already had.",
|
|
538
567
|
"A row with no figure says why in its status column, never NaN; a symbol with no quote is also named on standard error.",
|
|
568
|
+
"A list from --file or standard input has a row for every line, in its order, one that names no listing with its reason in status; its export adds input, the line as typed, and duplicate_of, the input of an earlier row that is the same listing.",
|
|
539
569
|
],
|
|
540
570
|
};
|
|
541
571
|
|
|
@@ -613,8 +643,8 @@ const CHANGE_BASIS_EXPORT_COLUMNS = [
|
|
|
613
643
|
* low and high) are already in the table's own cells.
|
|
614
644
|
*/
|
|
615
645
|
function quoteTextColumns<Column extends { key: string }>(columns: Column[]): Array<Column | typeof CHANGE_BASIS_COLUMN> {
|
|
616
|
-
const exported = new Set([...CHANGE_BASIS_EXPORT_COLUMNS, ...EXTENDED_CHANGE_EXPORT_COLUMNS, ...DAY_RANGE_EXPORT_COLUMNS, CHANGE_BP_EXPORT_COLUMN
|
|
617
|
-
.map((column) => column.key));
|
|
646
|
+
const exported = new Set([...CHANGE_BASIS_EXPORT_COLUMNS, ...EXTENDED_CHANGE_EXPORT_COLUMNS, ...DAY_RANGE_EXPORT_COLUMNS, CHANGE_BP_EXPORT_COLUMN,
|
|
647
|
+
...LIST_INPUT_EXPORT_COLUMNS].map((column) => column.key));
|
|
618
648
|
const kept = columns.filter((column) => !exported.has(column.key));
|
|
619
649
|
const at = kept.findIndex((column) => column.key === "changePercent") + 1;
|
|
620
650
|
return [...kept.slice(0, at), CHANGE_BASIS_COLUMN, ...kept.slice(at)];
|
|
@@ -748,6 +778,16 @@ const CHANGE_BP_EXPORT_COLUMN = {
|
|
|
748
778
|
key: "changeBasisPoints", header: "Chg bp", value: (row: QuoteRow) => row.yieldIndex ? row.changeBasisPoints : null,
|
|
749
779
|
};
|
|
750
780
|
|
|
781
|
+
/**
|
|
782
|
+
* A list's export names each row's entry as typed, so a row finds its line of the sheet again when several lines
|
|
783
|
+
* read as one listing (`USDJPY Curncy`, `USDJPY`, `usdjpy`, `USD/JPY` are all USDJPY=X), and marks a row
|
|
784
|
+
* that repeats an earlier row's listing with that row's entry. After the columns an export already had.
|
|
785
|
+
*/
|
|
786
|
+
const LIST_INPUT_EXPORT_COLUMNS = [
|
|
787
|
+
{ key: "input", header: "input", value: (row: QuoteRow) => row.input || null },
|
|
788
|
+
{ key: "duplicateOf", header: "duplicate_of", value: (row: QuoteRow) => row.duplicateOf || null },
|
|
789
|
+
];
|
|
790
|
+
|
|
751
791
|
/** The day's low and high as numbers, after the columns an export already had. */
|
|
752
792
|
const DAY_RANGE_EXPORT_COLUMNS = [
|
|
753
793
|
{ key: "dayLow", header: "Day Low", value: (row: QuoteRow) => exportFigure(row.rawDayLow) },
|
|
@@ -940,12 +980,16 @@ function quoteRows(results: QuoteCliRecord[], now = Date.now()) {
|
|
|
940
980
|
feed: quoteFeedState(quote, now),
|
|
941
981
|
// When the price Last shows was observed: in a pre-market nothing has traded in, the close it stands at.
|
|
942
982
|
updatedAt: quote?.lastUpdated ? new Date(quoteHeadlineTime(quote)).toISOString() : "",
|
|
983
|
+
input: result.input ?? "",
|
|
984
|
+
duplicateOf: result.duplicateOf ?? "",
|
|
943
985
|
error: result.error ?? "",
|
|
944
986
|
// Last, so a row read by position keeps every field where it was.
|
|
945
987
|
changeBasis: predates ? "" : basisLabel(result, now),
|
|
946
988
|
changeBasisNote: changeBasisNote(rowChangeBasis(result), now) ?? "",
|
|
947
989
|
// A price nothing traded at names the venue session it is the nominal close of; the quote keeps its last trade.
|
|
948
990
|
...quote?.nominalPrice ? { nominalLabel: nominalSessionLabel(quote) ?? undefined } : {},
|
|
991
|
+
// A price with no live quote behind it, the close of the latest daily bar, names that session.
|
|
992
|
+
...quote?.dailyClose ? { nominalLabel: dailyCloseSessionLabel(quote) ?? undefined } : {},
|
|
949
993
|
};
|
|
950
994
|
});
|
|
951
995
|
}
|
|
@@ -1179,6 +1223,11 @@ async function runQuote(rawArgs: string[], ctx: Parameters<CliCommandDef["execut
|
|
|
1179
1223
|
const symbols = read?.kind === "name" ? [read.name]
|
|
1180
1224
|
: read?.kind === "symbols" ? uniqueEntries(read.symbols)
|
|
1181
1225
|
: list!.symbols;
|
|
1226
|
+
// A long paste says how far it has got on stderr ("Quoted 120/307 symbols."), so it never looks stuck.
|
|
1227
|
+
const progress = symbols.length > QUOTE_PROGRESS_MIN_SYMBOLS
|
|
1228
|
+
? listProgressNotice(ctx, (settled, total, told) => told || settled > 0 ? `Quoted ${settled}/${total} symbols.` : `Quoting ${total} symbols.`)
|
|
1229
|
+
: null;
|
|
1230
|
+
progress?.(0, symbols.length);
|
|
1182
1231
|
// What cannot be a symbol (N/A, $$$, a price alone) is never looked up; one line names it.
|
|
1183
1232
|
const refused = symbols.flatMap((symbol) => notASymbolError(symbol) ?? []);
|
|
1184
1233
|
if (refused.length === symbols.length) {
|
|
@@ -1210,16 +1259,38 @@ async function runQuote(rawArgs: string[], ctx: Parameters<CliCommandDef["execut
|
|
|
1210
1259
|
// So is whether a symbol changed (FB is now META), for the same lists.
|
|
1211
1260
|
const changes = new Map(listings.length > MAX_CHOICE_LOOKUPS ? []
|
|
1212
1261
|
: listings.map((listing) => [listing, startTickerChangeLookup(market.dataProvider, listing.symbol, listing.exchange)] as const));
|
|
1262
|
+
// And the index form of a symbol no venue lists (GSPC, ^GSPC): its answer, when the symbol is no ticker, is waiting on it.
|
|
1263
|
+
const indexForms = new Map(listings.length > MAX_CHOICE_LOOKUPS ? []
|
|
1264
|
+
: listings.map((listing) => [listing, indexFormRead(listing, market, venues.get(listing) ?? null)] as const));
|
|
1213
1265
|
// The service's quote of the moment, not each form's local copy from whenever it was last asked for:
|
|
1214
1266
|
// BRK.B saved on NYSE, BRK-B and BRK.B:NYSE print one quote. A local copy answers only offline.
|
|
1215
1267
|
// Each row prints what its move is from (Chg Basis).
|
|
1216
|
-
|
|
1268
|
+
// A row of a list that failed for a reason that says nothing of its symbol (a busy moment, the request limit) is
|
|
1269
|
+
// asked for again before it is given a status.
|
|
1270
|
+
const ask = (asked: QuoteSubscriptionTarget[]) => market.dataProvider.getQuotesBatch(asked, { forceRefresh: ctx.cliOptions.refresh, revalidate: true, datesChangeBasis: true });
|
|
1217
1271
|
const listingOf = (result: QuoteBatchResult, index: number) => listings[targets.indexOf(result.target)] ?? listings[index]!;
|
|
1218
1272
|
const request = { command: commandName, noun: "quote" };
|
|
1219
|
-
|
|
1273
|
+
// Entries no listing was read for are settled already; each row is read as soon as its ask comes back final, and
|
|
1274
|
+
// counts once it has been, so a long list's progress moves as each batch is answered.
|
|
1275
|
+
let settled = symbols.length - targets.length;
|
|
1276
|
+
const answering = new Map<QuoteBatchResult, Promise<QuoteAnswer>>();
|
|
1277
|
+
const answer = (result: QuoteBatchResult, index: number) => {
|
|
1220
1278
|
const listing = listingOf(result, index);
|
|
1221
|
-
|
|
1222
|
-
|
|
1279
|
+
const answered = answerQuote(result, listing, market, request, ctx.cliOptions.refresh, venues.get(listing) ?? null, { datesChangeBasis: true, indexForm: indexForms.get(listing) ?? null })
|
|
1280
|
+
.then((done) => { progress?.(++settled, symbols.length); return done; });
|
|
1281
|
+
answered.catch(() => {
|
|
1282
|
+
// Intentional ignore: awaited with the others below, where its failure fails the command.
|
|
1283
|
+
});
|
|
1284
|
+
return answered;
|
|
1285
|
+
};
|
|
1286
|
+
const results = targets.length > 1
|
|
1287
|
+
? await quotesWithRetries(targets, ask, {
|
|
1288
|
+
onRetry: quoteRetryNotice(ctx),
|
|
1289
|
+
onSettled: (final) => { for (const { result, index } of final) answering.set(result, answer(result, index)); },
|
|
1290
|
+
})
|
|
1291
|
+
: await ask(targets);
|
|
1292
|
+
const quoted = await Promise.all(results.map((result, index) => answering.get(result) ?? answer(result, index)));
|
|
1293
|
+
progress?.(symbols.length, symbols.length);
|
|
1223
1294
|
// "MTN Group" typed apart is MTN Group, one row, where "Group" alone would read as UnitedHealth Group.
|
|
1224
1295
|
const { answers, asked } = listed ? { answers: quoted, asked: results.map(listingOf) }
|
|
1225
1296
|
: await withJoinedCompanyNames(quoted, results.map(listingOf), market, request, ctx.cliOptions.refresh, true);
|
|
@@ -1233,12 +1304,17 @@ async function runQuote(rawArgs: string[], ctx: Parameters<CliCommandDef["execut
|
|
|
1233
1304
|
return { change: describeTickerChange(listing.symbol, payload, current), formerIssuer: describeFormerIssuer(listing.symbol, payload, current) };
|
|
1234
1305
|
}));
|
|
1235
1306
|
const tickerChanges = symbolChanges.map(({ change }) => change);
|
|
1307
|
+
// A list's rows name the entry each is for, and mark one that is the same listing as an earlier row.
|
|
1308
|
+
const listInputs = listed && symbols.length > 1 ? quoteListInputs(asked, resolvedListings) : null;
|
|
1236
1309
|
const formerIssuers = symbolChanges.map(({ formerIssuer }) => formerIssuer);
|
|
1237
1310
|
// A symbol with no quote whose bars stopped over a month ago says when it last traded, in place of why no quote
|
|
1238
1311
|
// came: no longer listed on the service's record (FLAT, a retired ETN), else no trades since. Each costs a history
|
|
1239
1312
|
// read, so a long list says only why. A quote the service did not answer is asked after too: a dead listing's
|
|
1240
1313
|
// quote can fail where its history still says when it stopped (FRC), and an unreachable service fails it at once.
|
|
1314
|
+
// The service's "not a ticker" for a bare symbol says no listing anywhere carries it, so no bars or search row
|
|
1315
|
+
// would say it stopped: a symbol it knows from before answers its last quote or no data, never that.
|
|
1241
1316
|
const lastTraded = await Promise.all(answers.map(async ({ result, listing }) => !result.quote && answers.length <= MAX_CHOICE_LOOKUPS
|
|
1317
|
+
&& (listing.exchange || !isNotATickerMessage(errorMessage(result.error)))
|
|
1242
1318
|
? await loadNoQuoteLastTraded(listing.request, market.dataProvider, now) ?? await searchedDelisting(listing, market)
|
|
1243
1319
|
: null));
|
|
1244
1320
|
const endedNotes = answers.map(({ listing }, index) => lastTraded[index] ? `${noQuoteLastTradeNote(listing.symbol, lastTraded[index]!)}.` : null);
|
|
@@ -1302,6 +1378,7 @@ async function runQuote(rawArgs: string[], ctx: Parameters<CliCommandDef["execut
|
|
|
1302
1378
|
...formerIssuers[index] ? { formerIssuer: formerIssuers[index] } : {},
|
|
1303
1379
|
// The day it last traded, and whether the service's record says it no longer trades (else only old bars say it).
|
|
1304
1380
|
...lastTraded[index] ? { lastTraded: lastTraded[index]!.date, noLongerListed: lastTraded[index]!.recorded } : {},
|
|
1381
|
+
...listInputs ? listInputs[index]! : {},
|
|
1305
1382
|
}));
|
|
1306
1383
|
const notes = [
|
|
1307
1384
|
...list?.notes ?? [],
|
|
@@ -1322,7 +1399,7 @@ async function runQuote(rawArgs: string[], ctx: Parameters<CliCommandDef["execut
|
|
|
1322
1399
|
const ended = stopped && liveCompanies[index] ? `${stopped}. ${liveCompanies[index]}` : stopped;
|
|
1323
1400
|
// Open by its venue's calendar, before the delayed feed's first print: Last is the previous close until then.
|
|
1324
1401
|
const awaiting = ended ? null : awaitingFirstDelayedPrint(row.quote, now);
|
|
1325
|
-
const quiet = ended || awaiting ? null : nominalPriceText(row.quote) ?? noPrintsTodayText(row.quote, now);
|
|
1402
|
+
const quiet = ended || awaiting ? null : nominalPriceText(row.quote) ?? dailyCloseText(row.quote) ?? noPrintsTodayText(row.quote, now);
|
|
1326
1403
|
const waiting = awaiting && row.quote
|
|
1327
1404
|
? `${label}: open since ${utcClock(awaiting.open)} UTC; Last is the previous close until the first delayed print, about ${utcClock(awaiting.expected)} UTC`
|
|
1328
1405
|
: null;
|
|
@@ -1352,7 +1429,13 @@ async function runQuote(rawArgs: string[], ctx: Parameters<CliCommandDef["execut
|
|
|
1352
1429
|
...ctx.cliOptions.format !== "json" ? quoteNotes(data.filter((_row, index) => !endedNotes[index])) : [],
|
|
1353
1430
|
];
|
|
1354
1431
|
const holdsYield = data.some((row) => isYieldIndexSymbol(row.target.symbol));
|
|
1355
|
-
const columns = [...commandName === "compare" ? compareColumns() : quoteColumns(), ...holdsYield ? [CHANGE_BP_EXPORT_COLUMN] : []
|
|
1432
|
+
const columns = [...commandName === "compare" ? compareColumns() : quoteColumns(), ...holdsYield ? [CHANGE_BP_EXPORT_COLUMN] : [],
|
|
1433
|
+
...listInputs ? LIST_INPUT_EXPORT_COLUMNS : []];
|
|
1434
|
+
// An export of a list read from a file or standard input has a row for every line, in its order: one no listing was
|
|
1435
|
+
// read for says why in its status, as its line on stderr does. The table keeps a row per listing.
|
|
1436
|
+
const rows = listInputs && ctx.cliOptions.format !== "text"
|
|
1437
|
+
? listRows([...data, ...unread.map(unreadRow)], symbols, list?.typedForms ?? [])
|
|
1438
|
+
: data;
|
|
1356
1439
|
const basisNotes = changeBasisNotes(data, now);
|
|
1357
1440
|
const midNotes = extendedMidNotes(data);
|
|
1358
1441
|
// Another listing a row's code names (00700 on TWSE is 700.HK on HKEX) is said under the table, not as a warning on the row.
|
|
@@ -1361,11 +1444,12 @@ async function runQuote(rawArgs: string[], ctx: Parameters<CliCommandDef["execut
|
|
|
1361
1444
|
const footnotes = [...basisNotes, ...listingNotes];
|
|
1362
1445
|
// JSON has no table to put them under: they stay with its warnings.
|
|
1363
1446
|
const warnings = [...notes, ...ctx.cliOptions.format === "json" ? listingNotes : []];
|
|
1364
|
-
|
|
1447
|
+
// The hint for a word that is a coin's name comes from the coins this build knows: the board is a read after the rest.
|
|
1448
|
+
if (ctx.cliOptions.format !== "json") useKnownCoins();
|
|
1365
1449
|
// Only yield indices: their change is in bp, so the text header drops the percent sign (CSV keeps the percent it holds).
|
|
1366
1450
|
const yieldsOnly = data.length > 0 && data.every((row) => isYieldIndexSymbol(row.target.symbol));
|
|
1367
1451
|
ctx.printResult({
|
|
1368
|
-
data,
|
|
1452
|
+
data: rows,
|
|
1369
1453
|
warnings: warnings.length > 0 ? warnings : undefined,
|
|
1370
1454
|
// A Cboe yield index stops at its 15:00 ET close, before the Treasury's curve is taken: the line says so, so its
|
|
1371
1455
|
// close does not read as a contradiction of DGS10 or GC for the same day.
|
|
@@ -1402,6 +1486,59 @@ async function runQuote(rawArgs: string[], ctx: Parameters<CliCommandDef["execut
|
|
|
1402
1486
|
});
|
|
1403
1487
|
}
|
|
1404
1488
|
|
|
1489
|
+
/** Each row's entry of the list, as the list was read. */
|
|
1490
|
+
function quoteListInputs(
|
|
1491
|
+
asked: readonly CliListing[],
|
|
1492
|
+
resolved: ReadonlyArray<{ symbol: string; listing?: CliListing }>,
|
|
1493
|
+
): Array<{ input: string }> {
|
|
1494
|
+
const entryOf = new Map(resolved.flatMap((entry) => entry.listing ? [[entry.listing, entry.symbol] as const] : []));
|
|
1495
|
+
return asked.map((listing) => ({ input: entryOf.get(listing) ?? listing.typed ?? listing.symbol }));
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1498
|
+
/** The row of a list's entry no listing was read for (`GTJPY10Y Govt`), its reason in the status column. */
|
|
1499
|
+
function unreadRow({ symbol, error }: { symbol: string; error: ListingArgError }): QuoteCliRecord & { listing: ReturnType<typeof listingMetadata> } {
|
|
1500
|
+
return { target: { symbol }, listing: { symbol, exchange: null, name: null }, quote: null, error: error.message, input: symbol };
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
type ListRow = Pick<QuoteCliRecord, "input" | "duplicateOf" | "quote"> & { listing: { symbol: string; exchange: string | null } };
|
|
1504
|
+
|
|
1505
|
+
/**
|
|
1506
|
+
* A list's rows, one for each line of its text as typed where several were read as one entry (`USDJPY` and
|
|
1507
|
+
* `usdjpy` are both USDJPY), in the order of the lines, else of the entries; a row that is the same listing as an
|
|
1508
|
+
* earlier row names that row's entry in `duplicateOf`.
|
|
1509
|
+
*/
|
|
1510
|
+
function listRows<Row extends ListRow>(rows: readonly Row[], entries: readonly string[], forms: readonly TypedForm[]): Row[] {
|
|
1511
|
+
// An entry read from no line of its own (a name read as its words) goes after the line before it.
|
|
1512
|
+
let last = -1;
|
|
1513
|
+
const entryAt = new Map(entries.map((entry, index) => {
|
|
1514
|
+
const at = forms.findIndex((form) => form.key === symbolInputKey(entry));
|
|
1515
|
+
if (at >= 0) last = at;
|
|
1516
|
+
return [entry, { at: at >= 0 ? at : last + 0.5, index }] as const;
|
|
1517
|
+
}));
|
|
1518
|
+
const placed = rows.flatMap((row, index) => {
|
|
1519
|
+
const typed = forms.flatMap((form, at) => form.key === symbolInputKey(row.input ?? "") ? [{ form, at }] : []);
|
|
1520
|
+
const place = entryAt.get(row.input ?? "") ?? { at: forms.length, index: entries.length + index };
|
|
1521
|
+
return typed.length > 1 || (typed.length === 1 && typed[0]!.form.typed !== row.input)
|
|
1522
|
+
? typed.map(({ form, at }) => ({ row: { ...row, input: form.typed }, at, index: place.index }))
|
|
1523
|
+
: [{ row, ...place }];
|
|
1524
|
+
}).sort((a, b) => a.at - b.at || a.index - b.index);
|
|
1525
|
+
const first = new Map<string, string>();
|
|
1526
|
+
return placed.map(({ row }) => {
|
|
1527
|
+
const key = `${(row.quote?.symbol || row.listing.symbol).toUpperCase()}:${row.listing.exchange ?? ""}`;
|
|
1528
|
+
const earlier = first.get(key);
|
|
1529
|
+
if (earlier === undefined) first.set(key, row.input ?? "");
|
|
1530
|
+
return earlier === undefined ? row : { ...row, duplicateOf: earlier };
|
|
1531
|
+
});
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
/** The line a list's quote prints before asking again for the rows that failed for the moment. */
|
|
1535
|
+
function quoteRetryNotice(ctx: Parameters<CliCommandDef["execute"]>[1]): (count: number, waitMs: number) => void {
|
|
1536
|
+
return (count, waitMs) => {
|
|
1537
|
+
if (ctx.cliOptions.quiet) return;
|
|
1538
|
+
console.error(cliStyles.muted(`Gloom Cloud did not answer for ${count} symbol${count === 1 ? "" : "s"}; asking again in ${Math.round(waitMs / 1000)} s.`));
|
|
1539
|
+
};
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1405
1542
|
/** The entries refused before any lookup, named as written: `$$$, N/A`, split by semicolons when one has a comma. */
|
|
1406
1543
|
function refusedList(refused: ReadonlyArray<{ input: string }>): string {
|
|
1407
1544
|
const inputs = refused.map((error) => error.input.trim());
|
|
@@ -1418,6 +1555,8 @@ function refusedLine(refused: ReadonlyArray<{ input: string }>): string {
|
|
|
1418
1555
|
* after it a reason of several sentences: `Not quoted: iron ore. Iron ore: no live price (...). ...`.
|
|
1419
1556
|
*/
|
|
1420
1557
|
function unreadLine({ symbol, error }: { symbol: string; error: ListingArgError }): string {
|
|
1558
|
+
// A reason that names the line itself ("GTJPY10Y Govt is Bloomberg's code for a government bond...") says it once.
|
|
1559
|
+
if (error.message.startsWith(`${symbol} `) || error.message.startsWith(`${symbol}:`)) return error.message;
|
|
1421
1560
|
const reason = error.message.replace(/\.$/, "");
|
|
1422
1561
|
return reason.includes(". ") ? `Not quoted: ${symbol}. ${reason}.` : `Not quoted: ${symbol} (${reason}).`;
|
|
1423
1562
|
}
|
|
@@ -1681,6 +1820,27 @@ interface ListingHistory {
|
|
|
1681
1820
|
mostTraded: boolean;
|
|
1682
1821
|
/** `--currency`: what the prices were converted from and into, and the daily FX series read. */
|
|
1683
1822
|
fx?: HistoryConversion;
|
|
1823
|
+
/** A catalog series (`CAP:bond-yield:jp-10y`) read beside listings: its values are in `close`, and are no price. */
|
|
1824
|
+
catalogSeries?: true;
|
|
1825
|
+
}
|
|
1826
|
+
|
|
1827
|
+
/**
|
|
1828
|
+
* A catalog series' values as a list's history, each date's value its close:
|
|
1829
|
+
* dated, in the unit the catalog names (`%` as pct), with its name.
|
|
1830
|
+
*/
|
|
1831
|
+
function catalogListingHistory(series: CatalogSeriesHistory): ListingHistory {
|
|
1832
|
+
const unit = series.unit === "%" ? "pct" : series.unit;
|
|
1833
|
+
const decimals = Math.min(6, Math.max(2, ...series.points.map(({ value }) => (String(value).split(".")[1] ?? "").length)));
|
|
1834
|
+
return {
|
|
1835
|
+
listing: { symbol: series.id, exchange: "", key: series.id, saved: null, request: { symbol: series.id, exchange: "" } },
|
|
1836
|
+
identity: { symbol: series.id, exchange: "", name: series.label },
|
|
1837
|
+
unit: { kind: "unknown", currency: null, unit },
|
|
1838
|
+
data: series.points.map(({ date, value }) => ({
|
|
1839
|
+
date, open: null, high: null, low: null, close: value, volume: null, currency: null, unit, interval: "1d", flag: null,
|
|
1840
|
+
})),
|
|
1841
|
+
resolution: "1d", interval: "1d", decimals, intraday: false, volume: null, freshness: undefined,
|
|
1842
|
+
notes: series.notes, mostTraded: false, catalogSeries: true,
|
|
1843
|
+
};
|
|
1684
1844
|
}
|
|
1685
1845
|
|
|
1686
1846
|
/** A history's prices converted into another currency at each bar's daily FX close (`convertListingHistory`). */
|
|
@@ -2198,7 +2358,9 @@ async function runHistory(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
|
|
|
2198
2358
|
const words = args.filter((arg, index) => !arg.startsWith("-") && !(index > 0 && args[index - 1]!.startsWith("--") && !args[index - 1]!.includes("=")));
|
|
2199
2359
|
const barSize = file == null ? words.find((arg) => !/\s/.test(arg.trim()) && barSizeTypedAsSymbol(arg)) : undefined;
|
|
2200
2360
|
if (barSize) failHistoryBarSize(barSize, words, ctx);
|
|
2201
|
-
|
|
2361
|
+
// A catalog series (CAP:bond-yield:jp-10y) is read as a list's is, alone too.
|
|
2362
|
+
if (wide || file != null || args.includes("-") || uniqueEntries(args).length > 1 || args.some((arg) => /[,;]/.test(arg))
|
|
2363
|
+
|| args.some((arg) => catalogSeriesId(arg) != null)) {
|
|
2202
2364
|
// `history CC=F 1mo` asks for a month of cocoa, not for cocoa and 1MO: it says which option reads it.
|
|
2203
2365
|
const typedRange = rangeOption == null && !window ? args.find((arg) => rangeTypedAsSymbol(arg)) : undefined;
|
|
2204
2366
|
if (typedRange) {
|
|
@@ -2451,9 +2613,10 @@ function listedKeys(keys: readonly string[]): string {
|
|
|
2451
2613
|
* where a symbol has several in one row, the row's close is the last one's,
|
|
2452
2614
|
* the slot's close. `notes` names the symbols whose bars moved and those
|
|
2453
2615
|
* whose bars were merged. `interval` is the bars' size when every symbol came
|
|
2454
|
-
* in one, else null.
|
|
2616
|
+
* in one, else null. Columns go in `order`, the keys as the list asked for
|
|
2617
|
+
* them, a column that served nothing (`failed`) in its place, empty.
|
|
2455
2618
|
*/
|
|
2456
|
-
function wideHistoryTable(served: readonly ListingHistory[]): {
|
|
2619
|
+
function wideHistoryTable(served: readonly ListingHistory[], failed: readonly string[] = [], order: readonly string[] = []): {
|
|
2457
2620
|
rows: Array<Record<string, string | number | null>>;
|
|
2458
2621
|
columns: CliResultColumn[];
|
|
2459
2622
|
interval: string | null;
|
|
@@ -2484,18 +2647,25 @@ function wideHistoryTable(served: readonly ListingHistory[]): {
|
|
|
2484
2647
|
});
|
|
2485
2648
|
if (moved.length) notes.unshift(`${listedKeys(moved)} bars are listed ${under}.`);
|
|
2486
2649
|
}
|
|
2650
|
+
const columns = new Map<string, CliResultColumn>(histories.map((history) => {
|
|
2651
|
+
const unit = historyExportUnit(history.unit);
|
|
2652
|
+
const price = historyPrice(history.decimals);
|
|
2653
|
+
// A catalog series' value is no close: its column is the series, in its unit.
|
|
2654
|
+
return [history.listing.key, {
|
|
2655
|
+
key: key(history), header: `${history.listing.key}${history.catalogSeries ? "" : " close"}${unit ? ` (${unit})` : ""}`, align: "right",
|
|
2656
|
+
format: (value) => value == null ? "" : price(value),
|
|
2657
|
+
}];
|
|
2658
|
+
}));
|
|
2659
|
+
// A column asked for that served nothing stays, empty: its reason is in the notes.
|
|
2660
|
+
for (const symbol of failed) {
|
|
2661
|
+
if (!columns.has(symbol)) columns.set(symbol, { key: `close:${symbol}`, header: catalogSeriesId(symbol) ? symbol : `${symbol} close`, align: "right", format: () => "" });
|
|
2662
|
+
}
|
|
2663
|
+
const ordered = [...new Set([...order.filter((symbol) => columns.has(symbol)), ...columns.keys()])];
|
|
2487
2664
|
return {
|
|
2488
2665
|
rows,
|
|
2489
2666
|
columns: [
|
|
2490
2667
|
{ key: "date", header: histories.some((history) => history.intraday) ? "Time" : "Date" },
|
|
2491
|
-
...
|
|
2492
|
-
const unit = historyExportUnit(history.unit);
|
|
2493
|
-
const price = historyPrice(history.decimals);
|
|
2494
|
-
return {
|
|
2495
|
-
key: key(history), header: `${history.listing.key} close${unit ? ` (${unit})` : ""}`, align: "right",
|
|
2496
|
-
format: (value) => value == null ? "" : price(value),
|
|
2497
|
-
};
|
|
2498
|
-
}),
|
|
2668
|
+
...ordered.map((symbol) => columns.get(symbol)!),
|
|
2499
2669
|
],
|
|
2500
2670
|
interval: intervals.size === 1 ? [...intervals][0] ?? null : null,
|
|
2501
2671
|
notes,
|
|
@@ -2528,6 +2698,8 @@ async function runHistoryList(
|
|
|
2528
2698
|
// from a file or standard input, or past the lookups, is tickers: no word in it costs a quote to read as a name.
|
|
2529
2699
|
const typedList = file === undefined && !args.includes("-") && !exchange;
|
|
2530
2700
|
const read = await mapWithConcurrency(symbols, HISTORY_LIST_CONCURRENCY, async (symbol) => {
|
|
2701
|
+
// A catalog series is no listing: it is read as a series below.
|
|
2702
|
+
if (catalogSeriesId(symbol)) return { typed: symbol, listing: null, error: null };
|
|
2531
2703
|
try {
|
|
2532
2704
|
const listing = await resolveCliListing(symbol, exchange, market, { ownExchangeWins: true, companyWord: lookups && typedList });
|
|
2533
2705
|
return { typed: symbol, listing };
|
|
@@ -2539,6 +2711,9 @@ async function runHistoryList(
|
|
|
2539
2711
|
const listed = await mapWithConcurrency(entries, HISTORY_LIST_CONCURRENCY, async (entry): Promise<ListedHistory> => {
|
|
2540
2712
|
const symbol = entry.typed;
|
|
2541
2713
|
try {
|
|
2714
|
+
// A catalog series (CAP:bond-yield:jp-10y, FRED:DGS10) is read as `fn G` charts it, dated and in its unit.
|
|
2715
|
+
const seriesId = catalogSeriesId(symbol);
|
|
2716
|
+
if (seriesId) return { symbol: seriesId, history: catalogListingHistory(await loadCatalogSeriesHistory(seriesId, market, ctx.plugins, ask)) };
|
|
2542
2717
|
if (!("joined" in entry) && !entry.listing) throw entry.error;
|
|
2543
2718
|
const listing = "joined" in entry ? await resolveNamedListing(entry.joined, market) : entry.listing!;
|
|
2544
2719
|
const loaded = await loadListingHistory(listing, market, ctx, ask, { lookups });
|
|
@@ -2595,7 +2770,10 @@ async function runHistoryList(
|
|
|
2595
2770
|
asOf: entry.history.freshness?.asOf ?? null,
|
|
2596
2771
|
} : { symbol: entry.symbol, error: entry.error });
|
|
2597
2772
|
if (wide) {
|
|
2598
|
-
|
|
2773
|
+
// A column that served nothing keeps its place, empty, its reason said in the notes.
|
|
2774
|
+
const failed = listed.flatMap((entry) => "error" in entry ? [entry.symbol]
|
|
2775
|
+
: entry.history.data.length === 0 ? [entry.history.listing.key] : []);
|
|
2776
|
+
const table = wideHistoryTable(served, failed, listed.map((entry) => "history" in entry ? entry.history.listing.key : entry.symbol));
|
|
2599
2777
|
notes.push(...table.notes);
|
|
2600
2778
|
ctx.printResult({
|
|
2601
2779
|
data: table.rows,
|