gloomberb 0.19.4 → 0.19.6
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 +3 -1
- package/patches/@opentui%2Fcore@0.3.2.patch +86 -25
- package/src/api-client/equity-screener.ts +23 -0
- package/src/app/pane-runtime/index.tsx +2 -0
- package/src/app/pane-runtime/plugin-bindings.ts +10 -1
- package/src/app.tsx +63 -16
- package/src/cli/commands/command-utils.ts +4 -0
- package/src/cli/commands/market.ts +264 -33
- package/src/cli/commands/search.ts +22 -4
- package/src/cli/commands/ticker.ts +84 -39
- package/src/cli/currency-name-hint.ts +60 -0
- package/src/cli/glossary.ts +3 -3
- package/src/cli/history-rows.ts +18 -1
- package/src/cli/known-gaps.ts +25 -2
- package/src/cli/listing-arg.ts +12 -0
- package/src/cli/not-a-ticker.ts +5 -3
- package/src/cli/pane-functions/capabilities.ts +2 -0
- package/src/cli/pane-functions/catalog.ts +31 -5
- package/src/cli/pane-functions/function-help.ts +8 -5
- package/src/cli/pane-functions/headless.ts +11 -6
- package/src/cli/pane-functions/market-session.ts +6 -7
- package/src/cli/pane-functions/resolver.ts +75 -2
- package/src/cli/quote-answer.ts +9 -0
- package/src/cli/series-search.ts +4 -5
- package/src/cli/symbol-list.ts +54 -2
- package/src/cli/symbol-rows.ts +14 -2
- package/src/cli/ticker-resolution.ts +89 -20
- package/src/components/chart/composite/axis-overlays.tsx +60 -27
- package/src/components/chart/composite/composite-chart.tsx +118 -63
- package/src/components/chart/composite/cursor-source.ts +111 -0
- package/src/components/chart/composite/format.ts +168 -6
- package/src/components/chart/composite/legend.tsx +8 -4
- package/src/components/chart/composite/panel-bitmap.ts +28 -2
- package/src/components/chart/composite/panel-labels.ts +20 -1
- package/src/components/chart/composite/panel-surface.tsx +201 -92
- package/src/components/chart/composite/price-axis-labels.tsx +92 -46
- package/src/components/chart/composite/price-series.ts +31 -8
- package/src/components/chart/composite/scene.ts +154 -59
- package/src/components/chart/composite/series-axis-tags.tsx +4 -2
- package/src/components/chart/composite/time-axis.ts +30 -7
- package/src/components/chart/composite/time-scale.ts +211 -56
- package/src/components/chart/composite/types.ts +11 -1
- package/src/components/chart/composite/use-composite-chart-keyboard.ts +32 -12
- package/src/components/chart/curve/curve-surface.tsx +5 -2
- package/src/components/chart/curve/model.ts +4 -1
- package/src/components/chart/native/use-bitmap-metrics.ts +81 -0
- package/src/components/chart/static/series.ts +3 -0
- package/src/components/command-bar/commands/collection-list.ts +81 -0
- package/src/components/command-bar/commands/direct/index.ts +6 -0
- package/src/components/command-bar/commands/registry.ts +8 -0
- package/src/components/command-bar/layout-items/current-layout.ts +22 -1
- package/src/components/command-bar/layout-items/focused-pane.ts +22 -1
- package/src/components/command-bar/pane-templates/items.ts +19 -3
- package/src/components/command-bar/pane-templates/workflow.ts +5 -0
- package/src/components/command-bar/routes/root/results.ts +23 -3
- package/src/components/command-bar/routes/root/selection.ts +4 -2
- package/src/components/command-bar/routes/root/shortcut-feedback.ts +1 -1
- package/src/components/command-bar/routes/root/shortcut-items.ts +3 -4
- package/src/components/command-bar/routes/root/shortcuts.ts +58 -14
- package/src/components/command-bar/routes/root/ticker-first.ts +32 -0
- package/src/components/command-bar/surface/environment.ts +2 -0
- package/src/components/command-bar/view-model.ts +7 -0
- package/src/components/command-bar/workflow/ops.ts +2 -1
- package/src/components/command-bar/workflow/tickers.ts +20 -0
- package/src/components/layout/shell/active-drag.ts +38 -7
- package/src/components/layout/shell/drag/magnets.ts +106 -0
- package/src/components/layout/shell/menu.ts +15 -1
- package/src/components/layout/shell/pane/actions.ts +4 -0
- package/src/components/layout/shell/ticker-link-menu.ts +12 -3
- package/src/components/layout/status-bar.tsx +20 -0
- package/src/components/layout/window-controls.tsx +96 -35
- package/src/components/layout/window-fullscreen.ts +20 -0
- package/src/components/onboarding/onboarding-keyboard.ts +5 -1
- package/src/components/onboarding/onboarding-wizard.tsx +15 -4
- package/src/components/onboarding/portfolio-step/positions-panel.tsx +8 -5
- package/src/components/onboarding/use-onboarding-progress.ts +20 -1
- package/src/components/price-sparkline/view.tsx +14 -6
- package/src/components/quote-flash.ts +36 -32
- package/src/components/ticker/badge/index.tsx +8 -4
- package/src/components/ticker/badge/list.tsx +23 -7
- package/src/components/ui/column-grid.tsx +8 -2
- package/src/components/ui/data-table/opentui/model.ts +4 -1
- package/src/components/ui/tabs.tsx +5 -2
- package/src/core/state/app/layout.ts +18 -3
- package/src/core/state/app/state.ts +2 -0
- package/src/core/state/app/types.ts +5 -0
- package/src/data/config/layout.ts +3 -0
- package/src/data/config/store/normalize.ts +39 -4
- package/src/i18n/es.ts +10 -0
- package/src/i18n/ja.ts +10 -0
- package/src/i18n/ko.ts +10 -0
- package/src/i18n/zh-cn.ts +10 -0
- package/src/i18n/zh-tw.ts +10 -0
- package/src/layout/pane-manager/floating-placement.ts +7 -4
- package/src/layout/pane-manager/floating.ts +5 -2
- package/src/market-data/bond-funds.ts +19 -0
- package/src/market-data/coordinator/events.ts +17 -1
- package/src/market-data/frame-scheduler.ts +47 -10
- package/src/market-data/frame-wake.ts +74 -0
- package/src/market-data/futures-board.ts +7 -6
- package/src/market-data/futures-contract.ts +14 -3
- package/src/market-data/hooks.tsx +12 -3
- package/src/market-data/market/freshness.ts +18 -0
- package/src/market-data/market/status.ts +15 -2
- package/src/market-data/performance.ts +78 -9
- package/src/market-data/request-types.ts +6 -3
- package/src/plugins/builtin/alerts/cli.ts +2 -1
- package/src/plugins/builtin/analytics/risk-evidence.ts +1 -0
- package/src/plugins/builtin/attention/evidence.ts +1 -1
- package/src/plugins/builtin/awards/client.ts +1 -1
- package/src/plugins/builtin/awards/evidence.ts +1 -1
- package/src/plugins/builtin/awards/pane.tsx +2 -1
- package/src/plugins/builtin/bond-calculator/headless.ts +2 -1
- package/src/plugins/builtin/bond-calculator/index.tsx +1 -1
- package/src/plugins/builtin/bond-calculator/math.ts +1 -1
- package/src/plugins/builtin/bond-calculator/model.ts +14 -5
- package/src/plugins/builtin/bond-calculator/pane.tsx +1 -1
- package/src/plugins/builtin/broker-manager/footer.ts +3 -2
- package/src/plugins/builtin/broker-manager/index.tsx +2 -1
- package/src/plugins/builtin/broker-manager/keyboard.ts +2 -1
- package/src/plugins/builtin/buildout/cells.tsx +25 -45
- package/src/plugins/builtin/buildout/detail/company.tsx +3 -3
- package/src/plugins/builtin/buildout/detail/index.tsx +1 -1
- package/src/plugins/builtin/buildout/detail/intel.tsx +4 -7
- package/src/plugins/builtin/buildout/detail/site.tsx +4 -4
- package/src/plugins/builtin/buildout/detail/ui.tsx +39 -38
- package/src/plugins/builtin/buildout/format.ts +23 -1
- package/src/plugins/builtin/buildout/model/types.ts +1 -0
- package/src/plugins/builtin/buildout/pane/index.tsx +2 -8
- package/src/plugins/builtin/buildout/table-model.ts +12 -4
- package/src/plugins/builtin/catalysts/evidence.ts +1 -1
- package/src/plugins/builtin/catalysts/pane.tsx +2 -1
- package/src/plugins/builtin/cds/headless.ts +1 -0
- package/src/plugins/builtin/cds/index.tsx +1 -1
- package/src/plugins/builtin/chart-composer/headless.ts +40 -1
- package/src/plugins/builtin/cloud/plugin.tsx +2 -0
- package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +28 -3
- package/src/plugins/builtin/cloud-tweets/table.tsx +3 -2
- package/src/plugins/builtin/comment-letters/client.ts +2 -1
- package/src/plugins/builtin/company-kpis/client.ts +1 -1
- package/src/plugins/builtin/company-kpis/pane.tsx +2 -1
- package/src/plugins/builtin/company-kpis/screenshot-evidence.ts +3 -2
- package/src/plugins/builtin/correlation/headless.ts +3 -2
- package/src/plugins/builtin/cot/headless.ts +9 -3
- package/src/plugins/builtin/cot/model.ts +44 -3
- package/src/plugins/builtin/credit-documents/client.ts +1 -1
- package/src/plugins/builtin/credit-documents/evidence.ts +1 -1
- package/src/plugins/builtin/credit-documents/pane.tsx +2 -1
- package/src/plugins/builtin/crypto-board/pane.tsx +5 -4
- package/src/plugins/builtin/debt-maturities/headless.ts +11 -2
- package/src/plugins/builtin/debt-maturities/model.ts +66 -0
- package/src/plugins/builtin/debt-maturities/pane.tsx +23 -4
- package/src/plugins/builtin/earnings-calls/pane.tsx +1 -1
- package/src/plugins/builtin/earnings-ripple/index.tsx +6 -1
- package/src/plugins/builtin/earnings-ripple/pane.tsx +1 -1
- package/src/plugins/builtin/econ/calendar-model.ts +30 -6
- package/src/plugins/builtin/econ/fred-catalog.ts +5 -5
- package/src/plugins/builtin/econ/print-watch.ts +3 -1
- package/src/plugins/builtin/equity-screener/client.ts +1 -1
- package/src/plugins/builtin/equity-screener/criterion-editor.tsx +4 -16
- package/src/plugins/builtin/equity-screener/headless.ts +4 -2
- package/src/plugins/builtin/equity-screener/ideas.ts +67 -3
- package/src/plugins/builtin/equity-screener/model.ts +180 -12
- package/src/plugins/builtin/equity-screener/pane.tsx +52 -12
- package/src/plugins/builtin/equity-screener/screen-check.ts +7 -4
- package/src/plugins/builtin/equity-screener/watchlist.ts +33 -0
- package/src/plugins/builtin/futures/series.ts +16 -1
- package/src/plugins/builtin/futures-curve/client.ts +19 -0
- package/src/plugins/builtin/futures-curve/headless.ts +52 -13
- package/src/plugins/builtin/futures-curve/index.tsx +1 -1
- package/src/plugins/builtin/futures-curve/model.ts +77 -6
- package/src/plugins/builtin/futures-curve/pane.tsx +19 -3
- package/src/plugins/builtin/fx-matrix/headless.ts +4 -2
- package/src/plugins/builtin/fx-matrix/index.tsx +37 -3
- package/src/plugins/builtin/fx-matrix/pairs.ts +15 -0
- package/src/plugins/builtin/gpu/headless.ts +2 -1
- package/src/plugins/builtin/help/function-card.tsx +2 -1
- package/src/plugins/builtin/help/index.tsx +2 -1
- package/src/plugins/builtin/insider/display.ts +45 -6
- package/src/plugins/builtin/ipo-calendar/model.ts +2 -0
- package/src/plugins/builtin/iv-history/client.ts +2 -1
- package/src/plugins/builtin/iv-history/headless.ts +2 -1
- package/src/plugins/builtin/jobs/pages.ts +4 -4
- package/src/plugins/builtin/kelly-sizer/headless.ts +2 -1
- package/src/plugins/builtin/macro-day/client.ts +41 -0
- package/src/plugins/builtin/macro-day/headless.ts +19 -9
- package/src/plugins/builtin/macro-day/model.ts +3 -1
- package/src/plugins/builtin/market-heatmap/index.tsx +2 -1
- package/src/plugins/builtin/market-movers/index.tsx +4 -3
- package/src/plugins/builtin/members/client.ts +1 -1
- package/src/plugins/builtin/mna/distress/client.ts +1 -0
- package/src/plugins/builtin/mna/distress/headless.ts +1 -0
- package/src/plugins/builtin/mna/pane.tsx +4 -1
- package/src/plugins/builtin/options/market-reference.ts +1 -1
- package/src/plugins/builtin/options/open-interest-as-of.ts +3 -1
- package/src/plugins/builtin/options/view.tsx +2 -1
- package/src/plugins/builtin/options-calculator/evidence.ts +1 -1
- package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +1 -1
- package/src/plugins/builtin/options-scenario/csp-screen.ts +8 -4
- package/src/plugins/builtin/options-scenario/csp.ts +28 -9
- package/src/plugins/builtin/options-scenario/evidence.ts +5 -4
- package/src/plugins/builtin/options-scenario/pane.tsx +2 -1
- package/src/plugins/builtin/perps/client.ts +1 -1
- package/src/plugins/builtin/perps/pane.tsx +3 -1
- package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +17 -0
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +2 -1
- package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +4 -2
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +7 -3
- package/src/plugins/builtin/portfolio-list/use-throttled-memo.ts +10 -19
- package/src/plugins/builtin/rate-path/headless.ts +24 -10
- package/src/plugins/builtin/research/analyst-model.ts +1 -0
- package/src/plugins/builtin/research/equity-diagnostic-pane.tsx +2 -1
- package/src/plugins/builtin/research/event-model.ts +10 -3
- package/src/plugins/builtin/research/events-headless.ts +20 -2
- package/src/plugins/builtin/research/index.tsx +1 -0
- package/src/plugins/builtin/research/relative-valuation-currency.ts +1 -1
- package/src/plugins/builtin/research/relative-valuation-peers.ts +2 -1
- package/src/plugins/builtin/research-search/command-bar-search.ts +3 -1
- package/src/plugins/builtin/research-search/snippet.ts +1 -0
- package/src/plugins/builtin/revenue-breakdown/client.ts +3 -2
- package/src/plugins/builtin/seasonality/headless.ts +2 -1
- package/src/plugins/builtin/sec/command-bar-search.ts +3 -2
- package/src/plugins/builtin/sec/fund-facts.ts +17 -1
- package/src/plugins/builtin/sec/index.tsx +8 -5
- package/src/plugins/builtin/sec/row-summaries.ts +28 -12
- package/src/plugins/builtin/shared/members-menu.tsx +103 -38
- package/src/plugins/builtin/short-interest/publications-model.ts +22 -1
- package/src/plugins/builtin/short-interest/publications-pane.tsx +13 -4
- package/src/plugins/builtin/short-interest/watch-client.ts +2 -1
- package/src/plugins/builtin/short-interest/watch-model.ts +1 -1
- package/src/plugins/builtin/social-mentions/client.ts +2 -1
- package/src/plugins/builtin/supply-chain/client.ts +1 -1
- package/src/plugins/builtin/supply-chain/evidence.ts +1 -1
- package/src/plugins/builtin/supply-chain/graph-pane.tsx +2 -1
- package/src/plugins/builtin/supply-chain/pane.tsx +2 -1
- package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +1 -1
- package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +24 -4
- package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +1 -1
- package/src/plugins/builtin/time-sales/client.ts +1 -0
- package/src/plugins/builtin/time-sales/pane.tsx +3 -2
- package/src/plugins/builtin/trace-bonds/client.ts +7 -4
- package/src/plugins/builtin/trace-bonds/index.tsx +1 -1
- package/src/plugins/builtin/vol-surface/client.ts +2 -1
- package/src/plugins/builtin/volatility/client.ts +6 -1
- package/src/plugins/builtin/volatility/headless.ts +0 -1
- package/src/plugins/builtin/yield-curve/curves.ts +15 -0
- package/src/plugins/builtin/yield-curve/headless.ts +9 -2
- package/src/plugins/builtin/yield-curve/index.tsx +5 -8
- package/src/plugins/host-modules.ts +22 -3
- package/src/plugins/host-smoke.ts +6 -3
- package/src/portfolio/collection-name.ts +19 -0
- package/src/portfolio/column-values.ts +76 -10
- package/src/renderers/browser/http-proxy-transport.ts +78 -8
- package/src/renderers/cloudflare/http-proxy.ts +13 -2
- package/src/renderers/cloudflare/proxy-session.ts +47 -24
- package/src/renderers/cloudflare/worker.ts +15 -2
- package/src/renderers/desktop/geometry.ts +279 -0
- package/src/renderers/desktop/screen-setup.ts +246 -0
- package/src/renderers/desktop/sequential-window-host.ts +179 -0
- package/src/renderers/desktop/test-utils.ts +71 -0
- package/src/renderers/desktop/window-controller.ts +433 -0
- package/src/renderers/desktop/window-host.ts +70 -0
- package/src/renderers/desktop/window-layouts.ts +630 -0
- package/src/renderers/dom/data-frames.ts +15 -4
- package/src/renderers/dom/host/box.tsx +204 -176
- package/src/renderers/dom/host/style.ts +49 -20
- package/src/renderers/dom/host/text.tsx +3 -2
- package/src/renderers/electrobun/bun/application-menu/click.ts +1 -0
- package/src/renderers/electrobun/bun/application-menu/index.ts +4 -1
- package/src/renderers/electrobun/bun/desktop/backend-requests.ts +19 -8
- package/src/renderers/electrobun/bun/desktop/backend.ts +322 -19
- package/src/renderers/electrobun/bun/desktop/detached-windows.ts +83 -61
- package/src/renderers/electrobun/bun/desktop/host-requests.ts +29 -15
- package/src/renderers/electrobun/bun/desktop/initialization.ts +30 -11
- package/src/renderers/electrobun/bun/desktop/relaunch.ts +9 -1
- package/src/renderers/electrobun/bun/desktop/screen-setup-file.ts +55 -0
- package/src/renderers/electrobun/bun/desktop/state-broadcaster.ts +44 -8
- package/src/renderers/electrobun/bun/desktop/windows-script.ts +9 -6
- package/src/renderers/electrobun/bun/desktop/workspace/index.ts +298 -97
- package/src/renderers/electrobun/bun/desktop/workspace/requests.ts +44 -6
- package/src/renderers/electrobun/bun/index.ts +4 -97
- package/src/renderers/electrobun/bun/window/electrobun-window-host.ts +306 -0
- package/src/renderers/electrobun/bun/window/focus.ts +0 -25
- package/src/renderers/electrobun/bun/window/remembered-frame.ts +4 -82
- package/src/renderers/electrobun/bun/window/windows-native.ts +26 -1
- package/src/renderers/electrobun/shared/protocol.ts +50 -2
- package/src/renderers/electrobun/view/backend-rpc.ts +15 -0
- package/src/renderers/electrobun/view/desktop/window/bridge.ts +63 -3
- package/src/renderers/electrobun/view/main.tsx +13 -7
- package/src/renderers/electrobun/view/ui-host.tsx +7 -0
- package/src/renderers/electrobun/view/window-fullscreen.ts +10 -3
- package/src/series/fred-argument.ts +17 -0
- package/src/sources/provider-router/financial-routes.ts +7 -1
- package/src/sources/provider-router/index.ts +7 -1
- package/src/state/app/context/index.tsx +16 -2
- package/src/state/desktop-windows.ts +63 -0
- package/src/sync/other-window-tabs.ts +62 -0
- package/src/tickers/company-name-listing.ts +23 -3
- package/src/tickers/listing-fate.ts +147 -1
- package/src/tickers/terminal-codes.ts +5 -0
- package/src/time-series/price-units.ts +11 -0
- package/src/time-series/types.ts +6 -0
- package/src/types/config.ts +10 -1
- package/src/types/desktop-window.ts +71 -2
- package/src/types/financials.ts +4 -0
- package/src/types/headless.ts +19 -0
- package/src/types/plugin.ts +6 -0
- package/src/ui/host.tsx +2 -0
- package/src/ui/index.tsx +14 -13
- package/src/ui/same-props.ts +58 -0
- package/src/utils/cli-output.ts +33 -4
- package/src/utils/currency-names.ts +20 -0
- package/src/utils/currency-pair.ts +6 -0
- package/src/utils/exchange-rate-snapshot.ts +20 -2
- package/src/utils/format.ts +7 -2
- package/src/utils/futures-generic.ts +12 -0
- package/src/utils/fx-market-hours.ts +43 -0
- package/src/utils/http-proxy-upstream.ts +6 -2
- package/src/utils/plugin-proxy-hosts.json +0 -4
- package/src/utils/plugin-proxy-hosts.ts +22 -0
- package/src/utils/sec-filings.ts +7 -1
|
@@ -134,6 +134,7 @@ import {
|
|
|
134
134
|
historyBarStatusNote,
|
|
135
135
|
venueTradingDay,
|
|
136
136
|
historyCoverageWarning,
|
|
137
|
+
historyExportUnit,
|
|
137
138
|
historyFacts,
|
|
138
139
|
historyFlagNote,
|
|
139
140
|
historyWickNote,
|
|
@@ -155,7 +156,7 @@ import {
|
|
|
155
156
|
quotedPriceDivisor,
|
|
156
157
|
historyVolume,
|
|
157
158
|
historyVolumeBasis,
|
|
158
|
-
|
|
159
|
+
historyVolumeNote,
|
|
159
160
|
type HistoryRow,
|
|
160
161
|
type HistoryUnit,
|
|
161
162
|
type HistoryVolume,
|
|
@@ -250,12 +251,14 @@ import {
|
|
|
250
251
|
meantQuestion,
|
|
251
252
|
movedSymbolLine,
|
|
252
253
|
ListingArgError,
|
|
254
|
+
isNoProviderError,
|
|
253
255
|
requireCliListing,
|
|
254
256
|
resolveCliListing,
|
|
255
257
|
type CliListing,
|
|
256
258
|
type ListingIdentity,
|
|
257
259
|
} from "../listing-arg";
|
|
258
|
-
import {
|
|
260
|
+
import { currencyNameMiss, currencyNameStop } from "../currency-name-hint";
|
|
261
|
+
import { bareListingNote, listingFateNotes, loadNoQuoteLastTraded, noLongerTradingNote, noQuoteLastTraded, noQuoteLastTradeNote, SUCCESSOR_CHANGE_WAIT_MS, tradingListing, usVenueOf } from "../../tickers/listing-fate";
|
|
259
262
|
import { isYieldIndexSymbol } from "../../tickers/index-roots";
|
|
260
263
|
import {
|
|
261
264
|
analyzeTaxEquivalent, distributionBasis, loadTreasuryTenors, parseTaxRates, TAX_RATE_HELP_OPTIONS, taxEquivalentJson, type TaxRates,
|
|
@@ -386,10 +389,22 @@ type FinancialsCliData = TickerFinancials & {
|
|
|
386
389
|
providerId: string | null;
|
|
387
390
|
};
|
|
388
391
|
|
|
392
|
+
/**
|
|
393
|
+
* A range as typed, in any case and as other tools spell it: `1mo`, `1m` and
|
|
394
|
+
* `1 month` are 1M, `1wk` 1W, `5yr` 5Y, `max` ALL.
|
|
395
|
+
*/
|
|
396
|
+
export function readHistoryRange(value: string): HistoryRange | null {
|
|
397
|
+
const typed = value.trim().toUpperCase().replace(/\s+/g, "");
|
|
398
|
+
if (typed === "MAX") return "ALL";
|
|
399
|
+
const spelled = /^(\d+)(D|DAYS?|W|WKS?|WEEKS?|M|MOS?|MONTHS?|Y|YRS?|YEARS?)$/.exec(typed);
|
|
400
|
+
const range = (spelled ? `${spelled[1]}${spelled[2]![0]}` : typed) as HistoryRange;
|
|
401
|
+
return VALID_RANGES.has(range) ? range : null;
|
|
402
|
+
}
|
|
403
|
+
|
|
389
404
|
function parseRange(value: string | undefined, ctx: Parameters<CliCommandDef["execute"]>[1]): HistoryRange {
|
|
390
|
-
const range = (value ?? "1Y")
|
|
391
|
-
if (!
|
|
392
|
-
return range
|
|
405
|
+
const range = readHistoryRange(value ?? "1Y");
|
|
406
|
+
if (!range) ctx.fail(`Unknown range "${value}".`, `Use one of ${HISTORY_RANGES.join(", ")}.`);
|
|
407
|
+
return range!;
|
|
393
408
|
}
|
|
394
409
|
|
|
395
410
|
function parseNewsFeed(value: string | undefined): NewsQuery["feed"] | undefined {
|
|
@@ -454,7 +469,7 @@ async function readListedSymbols(
|
|
|
454
469
|
const QUOTE_CSV_SECTION = {
|
|
455
470
|
title: "CSV",
|
|
456
471
|
lines: [
|
|
457
|
-
"Last, Chg%, Prev Close and each extended print are plain numbers
|
|
472
|
+
"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.",
|
|
458
473
|
"A row with no figure says why in its status column, never NaN; a symbol with no quote is also named on standard error.",
|
|
459
474
|
],
|
|
460
475
|
};
|
|
@@ -594,6 +609,12 @@ const EXTENDED_CHANGE_EXPORT_COLUMNS = EXTENDED_SESSIONS.map((session) => ({
|
|
|
594
609
|
* Why an exported quote row's figures are empty, for its status column: the
|
|
595
610
|
* symbol's failure as the warning says it, or the figure it has no value for.
|
|
596
611
|
*/
|
|
612
|
+
/** A pair's rate unit for an export (`JPY per USD` for USDJPY=X) when its quote is in the counter currency; null otherwise. */
|
|
613
|
+
function pairExportUnit(symbol: string, currency: string): string | null {
|
|
614
|
+
const unit = historyUnit(symbol, { currency });
|
|
615
|
+
return unit.kind === "pair" && unit.currency === currency ? unit.unit : null;
|
|
616
|
+
}
|
|
617
|
+
|
|
597
618
|
function quoteExportStatus(row: QuoteRow): string {
|
|
598
619
|
if (row.rawPrice == null || !Number.isFinite(row.rawPrice)) return row.error || "Last: no price";
|
|
599
620
|
if (row.changePercent == null || !Number.isFinite(row.changePercent)) return "Chg%: no previous close";
|
|
@@ -1008,6 +1029,9 @@ async function runQuote(rawArgs: string[], ctx: Parameters<CliCommandDef["execut
|
|
|
1008
1029
|
const listed = file != null || args.includes("-");
|
|
1009
1030
|
const entries = normalizeSymbols(args);
|
|
1010
1031
|
if (entries.length === 0 && !listed) ctx.fail(usage);
|
|
1032
|
+
// A currency's name in words (`quote japanese yen`) is its pair, not a symbol a word.
|
|
1033
|
+
const currency = exchange || listed ? null : currencyNameStop(args, commandName);
|
|
1034
|
+
if (currency) ctx.fail(currency.message, currency.details);
|
|
1011
1035
|
// One quoted argument with spaces is a company's name, a pasted line of tickers, or a phrase to search for.
|
|
1012
1036
|
const phrase = exchange || listed ? null : quotedPhrase(args);
|
|
1013
1037
|
|
|
@@ -1071,6 +1095,13 @@ async function runQuote(rawArgs: string[], ctx: Parameters<CliCommandDef["execut
|
|
|
1071
1095
|
}));
|
|
1072
1096
|
const tickerChanges = symbolChanges.map(({ change }) => change);
|
|
1073
1097
|
const formerIssuers = symbolChanges.map(({ formerIssuer }) => formerIssuer);
|
|
1098
|
+
// A symbol with no quote whose bars stopped over a month ago says when it last traded, in place of why no quote
|
|
1099
|
+
// came: no longer listed on the service's record (FLAT, a retired ETN), else no trades since. Each costs a history
|
|
1100
|
+
// read, so a long list says only why.
|
|
1101
|
+
const lastTraded = await Promise.all(answers.map(({ result, listing }) => !result.quote && !isNetworkFailure(result.error)
|
|
1102
|
+
&& answers.length <= MAX_CHOICE_LOOKUPS ? loadNoQuoteLastTraded(listing.request, market.dataProvider, now) : null));
|
|
1103
|
+
const endedNotes = answers.map(({ listing }, index) => lastTraded[index] ? `${noQuoteLastTradeNote(listing.symbol, lastTraded[index]!)}.` : null);
|
|
1104
|
+
if (symbols.length === 1 && endedNotes[0]) ctx.fail(endedNotes[0], quoteChangeLine(tickerChanges[0], formerIssuers[0]) || undefined);
|
|
1074
1105
|
const failed = answers[0]?.failure;
|
|
1075
1106
|
if (symbols.length === 1 && failed) {
|
|
1076
1107
|
ctx.fail(failed.message, [quoteChangeLine(tickerChanges[0], formerIssuers[0]), failed.details].filter(Boolean).join("\n") || undefined);
|
|
@@ -1111,6 +1142,8 @@ async function runQuote(rawArgs: string[], ctx: Parameters<CliCommandDef["execut
|
|
|
1111
1142
|
...yieldIndexFields(result),
|
|
1112
1143
|
...tickerChanges[index] ? { tickerChange: tickerChanges[index] } : {},
|
|
1113
1144
|
...formerIssuers[index] ? { formerIssuer: formerIssuers[index] } : {},
|
|
1145
|
+
// The day it last traded, and whether the service's record says it no longer trades (else only old bars say it).
|
|
1146
|
+
...lastTraded[index] ? { lastTraded: lastTraded[index]!.date, noLongerListed: lastTraded[index]!.recorded } : {},
|
|
1114
1147
|
}));
|
|
1115
1148
|
const notes = [
|
|
1116
1149
|
...list?.notes ?? [],
|
|
@@ -1138,8 +1171,9 @@ async function runQuote(rawArgs: string[], ctx: Parameters<CliCommandDef["execut
|
|
|
1138
1171
|
const pair = listingDepositaryPair({ quote: row.quote });
|
|
1139
1172
|
return pair ? [`${row.target.symbol}: ${depositaryPairText(pair, isReceiptSide({ quote: row.quote }))}.`] : [];
|
|
1140
1173
|
}),
|
|
1174
|
+
...endedNotes.flatMap((note) => note ?? []),
|
|
1141
1175
|
// A cell shows only "unavailable", and an exported row only its status, so stderr names each failure; the JSON rows carry each reason.
|
|
1142
|
-
...ctx.cliOptions.format !== "json" ? quoteNotes(data) : [],
|
|
1176
|
+
...ctx.cliOptions.format !== "json" ? quoteNotes(data.filter((_row, index) => !endedNotes[index])) : [],
|
|
1143
1177
|
];
|
|
1144
1178
|
const columns = commandName === "compare" ? compareColumns() : quoteColumns();
|
|
1145
1179
|
const basisNotes = changeBasisNotes(data, now);
|
|
@@ -1163,7 +1197,9 @@ async function runQuote(rawArgs: string[], ctx: Parameters<CliCommandDef["execut
|
|
|
1163
1197
|
// An index row's Cur is blank, its level having no currency; the export names what it is in instead.
|
|
1164
1198
|
exportIdentity: (row) => ({
|
|
1165
1199
|
symbolOrSeries: row.symbol,
|
|
1166
|
-
|
|
1200
|
+
// A pair's rate is its quote currency per base: JPY per USD, as `history` and `fx` export it.
|
|
1201
|
+
currencyOrUnit: (row.currency && pairExportUnit(row.symbol, row.currency))
|
|
1202
|
+
|| row.currency || (row.yieldIndex ? "pct" : isIndexLevel(row.instrumentType) ? INDEX_POINTS_EXPORT_UNIT : null),
|
|
1167
1203
|
}),
|
|
1168
1204
|
// A row with no price or move says why in its status column, as the warnings do.
|
|
1169
1205
|
exportStatus: quoteExportStatus,
|
|
@@ -1414,7 +1450,7 @@ async function loadListingHistory(
|
|
|
1414
1450
|
const quoted = quoteAnswer.then((answer) => answer.quote);
|
|
1415
1451
|
const fate = lookups ? listingFateLoader(listing, market, quoted, { successor: true }) : null;
|
|
1416
1452
|
const request = { command: historyCommand(ask), noun: "history", ...(fate ? { fate } : {}) };
|
|
1417
|
-
const [
|
|
1453
|
+
const [answered, quote] = await Promise.all([
|
|
1418
1454
|
loadForListing(listing, market, ctx, load, (loaded) => loaded.points.length === 0, request)
|
|
1419
1455
|
.catch((error) => failHistory(error, listing.key, ctx)),
|
|
1420
1456
|
quoted,
|
|
@@ -1422,6 +1458,9 @@ async function loadListingHistory(
|
|
|
1422
1458
|
// A bare symbol several companies list is never served from the one the data service picked, in a range or a window:
|
|
1423
1459
|
// it asks for an exchange as `quote` does, and in a list that is the symbol's row alone.
|
|
1424
1460
|
await failUnchosenListing(listing, market, ctx, request, (await quoteAnswer).error);
|
|
1461
|
+
const loaded = quote || window ? answered : await stoppedUsListingHistory(listing, market, loadRange, context, answered);
|
|
1462
|
+
// With no quote and no bar in over a month, when the listing last traded is said first.
|
|
1463
|
+
const lastTraded = quote || window ? null : noQuoteLastTraded(loaded);
|
|
1425
1464
|
const { resolution } = loaded;
|
|
1426
1465
|
// While the session trades the day's bar is the quote's, whatever range the history was cut for (withSessionBar).
|
|
1427
1466
|
// A window that ended before today has no session in progress.
|
|
@@ -1461,11 +1500,13 @@ async function loadListingHistory(
|
|
|
1461
1500
|
const delayedTail = quote?.dataSource === "delayed" && !quote.delisting && (dayToDate || (intraday && sessionTrading));
|
|
1462
1501
|
// The source that served the bars, a broker or another source when Gloom Cloud could not.
|
|
1463
1502
|
const source = loaded.sourceName ? { source: loaded.sourceName } : {};
|
|
1503
|
+
// A coin's volume unit, or what an index's volume counts (a day's total, an intraday count).
|
|
1504
|
+
const volumeNote = historyVolumeNote(volume, interval, historyVolumeBasis(data));
|
|
1464
1505
|
// A window that closed before today is the history asked for: no later bar makes it stale.
|
|
1465
1506
|
const freshness = withSavedCopy(window && isPastPriceWindow(window) ? rowsFreshness(data, {
|
|
1466
1507
|
...source,
|
|
1467
1508
|
status: "not-a-feed", basis: `${interval ? BAR_INTERVAL_LABELS[interval] : "price"} bars, ${priceWindowText(window)}`, observedKey: "date", oldest: null,
|
|
1468
|
-
...(
|
|
1509
|
+
...(volumeNote ? { note: volumeNote } : {}),
|
|
1469
1510
|
}) : rowsFreshness(data, {
|
|
1470
1511
|
...source,
|
|
1471
1512
|
...barHistoryFreshness(intraday ? null : barResolutionFromDates(data.map((row) => row.date))),
|
|
@@ -1477,13 +1518,14 @@ async function loadListingHistory(
|
|
|
1477
1518
|
...(forming ? { periodToDate: forming.periodToDate } : closedDay ? { asOf: closedDay } : {}),
|
|
1478
1519
|
...(dayToDate ? { basis: "daily bars", ...(quote && Number.isFinite(quote.lastUpdated) ? { asOf: new Date(quote.lastUpdated).toISOString() } : {}) } : {}),
|
|
1479
1520
|
...(delayedTail ? { status: "delayed" as const, delayMinutes: CLOUD_QUOTE_DELAY_MINUTES } : {}),
|
|
1480
|
-
...(
|
|
1521
|
+
...(volumeNote || dayToDate ? { note: [volumeNote, dayToDate ? `the newest bar is ${DAY_SO_FAR_TEXT}` : null].filter(Boolean).join("; ") } : {}),
|
|
1481
1522
|
// The rows are drawn from the bars served, which say whether they are the saved copy.
|
|
1482
1523
|
}), loaded);
|
|
1483
1524
|
const gaps = historyGapNote(data, traded);
|
|
1484
1525
|
const coverage = window ? historyCoverageNotice(loaded.coverageStart, Date.parse(`${window.from}T00:00:00Z`), loaded.coverageNote)
|
|
1485
1526
|
: range === "YTD" ? null : historyCoverageWarning(range, loaded);
|
|
1486
1527
|
const notes = [
|
|
1528
|
+
...lastTraded ? [`${noQuoteLastTradeNote(listing.symbol, lastTraded)}.`] : [],
|
|
1487
1529
|
// A window the source has no bar in (a typo, a weekend, a listing that had not started) is said, not an empty table alone.
|
|
1488
1530
|
...data.length === 0 ? [emptyHistoryNote(listing.key, ask)] : [],
|
|
1489
1531
|
// FB's bars are the fund listed there now; META's from 2021 are from when it was FB.
|
|
@@ -1505,6 +1547,29 @@ async function loadListingHistory(
|
|
|
1505
1547
|
};
|
|
1506
1548
|
}
|
|
1507
1549
|
|
|
1550
|
+
/**
|
|
1551
|
+
* A bare symbol with no quote whose US listing stopped trading is that
|
|
1552
|
+
* listing's history: a source can answer the bare symbol with a listing
|
|
1553
|
+
* abroad that took it (STPP's bars from 2026 are a UCITS fund's, the iPath
|
|
1554
|
+
* steepener's ended in 2020). The bars as answered otherwise.
|
|
1555
|
+
*/
|
|
1556
|
+
async function stoppedUsListingHistory(
|
|
1557
|
+
listing: CliListing,
|
|
1558
|
+
market: MarketContext,
|
|
1559
|
+
range: TimeRange,
|
|
1560
|
+
context: { cacheMode: "refresh" | "default" },
|
|
1561
|
+
answered: PriceHistoryResult,
|
|
1562
|
+
): Promise<PriceHistoryResult> {
|
|
1563
|
+
if (listing.request.exchange || answered.delisting || !market.dataProvider.getPriceHistoryWithMetadata) return answered;
|
|
1564
|
+
const venue = await usVenueOf(listing.request.symbol, market.dataProvider);
|
|
1565
|
+
// Asked afresh: a copy saved for the bare symbol (the listing abroad's bars) can otherwise answer for the venue.
|
|
1566
|
+
const own = await market.dataProvider.getPriceHistoryWithMetadata(listing.request.symbol, venue, range, { ...context, cacheMode: "refresh" })
|
|
1567
|
+
.catch(logFailure("cli.commands-market", "Read a stopped US listing's history failed", null));
|
|
1568
|
+
const ended = own ? noQuoteLastTraded(own) : null;
|
|
1569
|
+
const newest = answered.points.at(-1)?.date;
|
|
1570
|
+
return own && ended && own.points.length > 0 && (!newest || new Date(newest).toISOString().slice(0, 10) > ended.date) ? own : answered;
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1508
1573
|
/**
|
|
1509
1574
|
* A continuous future's history is the front month's, not the contract its
|
|
1510
1575
|
* quote names now: NG=F's rows from before the roll are November's under a
|
|
@@ -1602,16 +1667,26 @@ async function runHistory(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
|
|
|
1602
1667
|
const window = historyWindowOption(args, rangeOption, ctx);
|
|
1603
1668
|
const ask: HistoryAsk = { range: parseRange(rangeOption, ctx), window };
|
|
1604
1669
|
const requestedExchange = takeOption(args, "--exchange");
|
|
1670
|
+
// One row a date and a close column a symbol, as a spreadsheet lays several series side by side.
|
|
1671
|
+
const wide = takeFlag(args, "--wide");
|
|
1605
1672
|
// A list from a file or standard input (`-`), or several symbols typed (AAPL MSFT, AAPL,MSFT), is one long table.
|
|
1606
1673
|
// One argument with spaces stays one, as before: it may be a company's name.
|
|
1607
1674
|
const file = args.some((arg) => arg === "--file" || arg.startsWith("--file=")) ? takeOption(args, "--file") ?? "" : undefined;
|
|
1608
|
-
|
|
1609
|
-
|
|
1675
|
+
// `history swiss franc` is the franc's pair, not SWISS (a Copenhagen listing) and FRANC.
|
|
1676
|
+
const currency = file != null || requestedExchange ? null : currencyNameStop(args, "history");
|
|
1677
|
+
if (currency) ctx.fail(currency.message, currency.details);
|
|
1678
|
+
if (wide || file != null || args.includes("-") || uniqueEntries(args).length > 1 || args.some((arg) => /[,;]/.test(arg))) {
|
|
1679
|
+
return runHistoryList(args, file, requestedExchange, ask, ctx, { wide });
|
|
1610
1680
|
}
|
|
1611
1681
|
const raw = requireOneArg(args, HISTORY_USAGE, "symbol", ctx);
|
|
1612
1682
|
await withMarketData(ctx, async (market) => {
|
|
1613
1683
|
const listing = await requireCliListing(raw, requestedExchange, market, ctx);
|
|
1614
|
-
const history = await loadListingHistory(listing, market, ctx, ask, { lookups: true })
|
|
1684
|
+
const history = await loadListingHistory(listing, market, ctx, ask, { lookups: true }).catch((error: unknown) => {
|
|
1685
|
+
// A word no source serves that names a currency (`history yen`) says which pair to ask for.
|
|
1686
|
+
const currency = !requestedExchange && isNoProviderError(error) ? currencyNameMiss(raw, "history") : null;
|
|
1687
|
+
if (currency) ctx.fail(currency.message, currency.details);
|
|
1688
|
+
throw error;
|
|
1689
|
+
});
|
|
1615
1690
|
const { identity, unit, data, interval, intraday, volume, freshness, notes } = history;
|
|
1616
1691
|
const price = historyPrice(history.decimals);
|
|
1617
1692
|
// A bar without volume in a history that reports it prints as missing.
|
|
@@ -1655,7 +1730,8 @@ async function runHistory(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
|
|
|
1655
1730
|
columns: historyExportColumns(data),
|
|
1656
1731
|
exportStatus: historyExportStatus,
|
|
1657
1732
|
// Every exported row says what it is a bar of, the currency a price is in and its bar size, so it survives head and concatenation.
|
|
1658
|
-
|
|
1733
|
+
// A pair's rate is in its quote currency per base: JPY per USD, as the JSON's unit and every other export say.
|
|
1734
|
+
exportIdentity: { symbolOrSeries: history.listing.key, currencyOrUnit: historyExportUnit(unit), interval },
|
|
1659
1735
|
});
|
|
1660
1736
|
});
|
|
1661
1737
|
}
|
|
@@ -1663,6 +1739,133 @@ async function runHistory(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
|
|
|
1663
1739
|
/** A symbol of a list: its bars, or why it has none. */
|
|
1664
1740
|
type ListedHistory = { symbol: string; history: ListingHistory } | { symbol: string; error: string };
|
|
1665
1741
|
|
|
1742
|
+
/** Minutes in an intraday bar size; null for daily and longer bars. */
|
|
1743
|
+
const INTRADAY_BAR_MINUTES: Partial<Record<NonNullable<HistoryRow["interval"]>, number>> = {
|
|
1744
|
+
"1m": 1, "5m": 5, "15m": 15, "30m": 30, "45m": 45, "1h": 60,
|
|
1745
|
+
};
|
|
1746
|
+
|
|
1747
|
+
/** The index of the latest of ascending `times` at or before `time`, or -1. */
|
|
1748
|
+
function latestAtOrBefore(times: readonly number[], time: number): number {
|
|
1749
|
+
let low = 0;
|
|
1750
|
+
let high = times.length - 1;
|
|
1751
|
+
let found = -1;
|
|
1752
|
+
while (low <= high) {
|
|
1753
|
+
const middle = (low + high) >> 1;
|
|
1754
|
+
if (times[middle]! <= time) {
|
|
1755
|
+
found = middle;
|
|
1756
|
+
low = middle + 1;
|
|
1757
|
+
} else high = middle - 1;
|
|
1758
|
+
}
|
|
1759
|
+
return found;
|
|
1760
|
+
}
|
|
1761
|
+
|
|
1762
|
+
/**
|
|
1763
|
+
* Where each symbol's intraday bars go in `--wide`. Bars are listed as they
|
|
1764
|
+
* come unless one symbol's bar starts inside another's (an hour stamped on
|
|
1765
|
+
* the half hour beside one stamped on the hour, 30m bars beside 1h ones):
|
|
1766
|
+
* then every bar is set under the bar it starts in of the coarsest symbol,
|
|
1767
|
+
* the one with most bars where several share that size, which keeps its own
|
|
1768
|
+
* stamps. A bar no such bar covers keeps its own. Null when nothing moves:
|
|
1769
|
+
* daily bars, and intraday ones stamped alike, as US stocks' hours all start
|
|
1770
|
+
* at :30.
|
|
1771
|
+
*/
|
|
1772
|
+
function wideBarSlots(histories: readonly ListingHistory[]): {
|
|
1773
|
+
anchor: number;
|
|
1774
|
+
slot: (series: number, row: number) => string;
|
|
1775
|
+
} | null {
|
|
1776
|
+
const minutes = histories.map((history) => history.interval ? INTRADAY_BAR_MINUTES[history.interval] : undefined);
|
|
1777
|
+
if (histories.length < 2 || minutes.some((value) => value == null)) return null;
|
|
1778
|
+
const times = histories.map((history) => history.data.map((row) => Date.parse(row.date)));
|
|
1779
|
+
if (times.some((series) => series.some((time) => !Number.isFinite(time)))) return null;
|
|
1780
|
+
const inside = (series: number, time: number) => {
|
|
1781
|
+
const at = latestAtOrBefore(times[series]!, time);
|
|
1782
|
+
return at >= 0 && times[series]![at]! < time && time < times[series]![at]! + minutes[series]! * 60_000;
|
|
1783
|
+
};
|
|
1784
|
+
// A live last bar can be stamped at the latest trade inside its slot, so only the others say where a symbol's bars start.
|
|
1785
|
+
const crossed = times.some((series, index) => series.slice(0, -1).some((time) =>
|
|
1786
|
+
times.some((_, other) => other !== index && inside(other, time))));
|
|
1787
|
+
if (!crossed) return null;
|
|
1788
|
+
const coarsest = Math.max(...minutes as number[]);
|
|
1789
|
+
const anchor = histories.reduce((best, history, index) => minutes[index] === coarsest
|
|
1790
|
+
&& (best < 0 || history.data.length > histories[best]!.data.length) ? index : best, -1);
|
|
1791
|
+
const size = coarsest * 60_000;
|
|
1792
|
+
return {
|
|
1793
|
+
anchor,
|
|
1794
|
+
slot: (series, row) => {
|
|
1795
|
+
const own = histories[series]!.data[row]!.date;
|
|
1796
|
+
if (series === anchor) return own;
|
|
1797
|
+
const time = times[series]![row]!;
|
|
1798
|
+
const at = latestAtOrBefore(times[anchor]!, time);
|
|
1799
|
+
return at >= 0 && time < times[anchor]![at]! + size ? histories[anchor]!.data[at]!.date : own;
|
|
1800
|
+
},
|
|
1801
|
+
};
|
|
1802
|
+
}
|
|
1803
|
+
|
|
1804
|
+
/** The symbols as a list: `A`, `A and B`, `A, B and C`. */
|
|
1805
|
+
function listedKeys(keys: readonly string[]): string {
|
|
1806
|
+
return keys.length < 2 ? keys.join("") : `${keys.slice(0, -1).join(", ")} and ${keys.at(-1)}`;
|
|
1807
|
+
}
|
|
1808
|
+
|
|
1809
|
+
/**
|
|
1810
|
+
* `history USDJPY=X USDCHF=X EURCHF=X --wide`: one row a date and one close
|
|
1811
|
+
* column a symbol, its unit in the header (`USDJPY=X close (JPY per USD)`),
|
|
1812
|
+
* as a spreadsheet sets several series side by side. A symbol with no bar on
|
|
1813
|
+
* a date (another market's holiday) leaves its cell blank. Intraday bars
|
|
1814
|
+
* that do not line up are set under the bar they start in (`wideBarSlots`):
|
|
1815
|
+
* where a symbol has several in one row, the row's close is the last one's,
|
|
1816
|
+
* the slot's close. `notes` names the symbols whose bars moved and those
|
|
1817
|
+
* whose bars were merged. `interval` is the bars' size when every symbol came
|
|
1818
|
+
* in one, else null.
|
|
1819
|
+
*/
|
|
1820
|
+
function wideHistoryTable(served: readonly ListingHistory[]): {
|
|
1821
|
+
rows: Array<Record<string, string | number | null>>;
|
|
1822
|
+
columns: CliResultColumn[];
|
|
1823
|
+
interval: string | null;
|
|
1824
|
+
notes: string[];
|
|
1825
|
+
} {
|
|
1826
|
+
const histories = served.filter((history, index) => served.findIndex((other) => other.listing.key === history.listing.key) === index);
|
|
1827
|
+
const key = (history: ListingHistory) => `close:${history.listing.key}`;
|
|
1828
|
+
const slots = wideBarSlots(histories);
|
|
1829
|
+
const slotOf = histories.map((history, series) => history.data.map((row, index) => slots?.slot(series, index) ?? row.date));
|
|
1830
|
+
const closes = histories.map((history, series) => new Map(history.data.map((row, index) => [slotOf[series]![index]!, row.close] as const)));
|
|
1831
|
+
const dates = [...new Set(closes.flatMap((bySlot) => [...bySlot.keys()]))].sort();
|
|
1832
|
+
const rows = dates.map((date) => Object.fromEntries([
|
|
1833
|
+
["date", date],
|
|
1834
|
+
...histories.map((history, index) => [key(history), closes[index]!.get(date) ?? null] as const),
|
|
1835
|
+
]));
|
|
1836
|
+
const intervals = new Set(histories.map((history) => history.interval));
|
|
1837
|
+
const notes: string[] = [];
|
|
1838
|
+
if (slots) {
|
|
1839
|
+
const anchor = histories[slots.anchor]!;
|
|
1840
|
+
const under = `under the ${anchor.listing.key} ${anchor.interval} bar they start in`;
|
|
1841
|
+
const moved: string[] = [];
|
|
1842
|
+
histories.forEach((history, series) => {
|
|
1843
|
+
const rowsOf = new Set(slotOf[series]);
|
|
1844
|
+
if (rowsOf.size < history.data.length) {
|
|
1845
|
+
notes.push(`${history.listing.key}'s ${history.interval} bars are merged ${under}, ${history.data.length} bars into ${rowsOf.size} rows: a row's close is its last bar's.`);
|
|
1846
|
+
// The last bar can be stamped at the latest trade inside its slot; the others say where a symbol's bars start.
|
|
1847
|
+
} else if (history.data.slice(0, -1).some((row, index) => slotOf[series]![index] !== row.date)) moved.push(history.listing.key);
|
|
1848
|
+
});
|
|
1849
|
+
if (moved.length) notes.unshift(`${listedKeys(moved)} bars are listed ${under}.`);
|
|
1850
|
+
}
|
|
1851
|
+
return {
|
|
1852
|
+
rows,
|
|
1853
|
+
columns: [
|
|
1854
|
+
{ key: "date", header: histories.some((history) => history.intraday) ? "Time" : "Date" },
|
|
1855
|
+
...histories.map((history): CliResultColumn => {
|
|
1856
|
+
const unit = historyExportUnit(history.unit);
|
|
1857
|
+
const price = historyPrice(history.decimals);
|
|
1858
|
+
return {
|
|
1859
|
+
key: key(history), header: `${history.listing.key} close${unit ? ` (${unit})` : ""}`, align: "right",
|
|
1860
|
+
format: (value) => value == null ? "" : price(value),
|
|
1861
|
+
};
|
|
1862
|
+
}),
|
|
1863
|
+
],
|
|
1864
|
+
interval: intervals.size === 1 ? [...intervals][0] ?? null : null,
|
|
1865
|
+
notes,
|
|
1866
|
+
};
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1666
1869
|
/**
|
|
1667
1870
|
* `history --file holdings.txt` (or several symbols, or `-` for standard
|
|
1668
1871
|
* input): every symbol's bars in one long table, `HISTORY_LIST_CONCURRENCY`
|
|
@@ -1675,6 +1878,7 @@ async function runHistoryList(
|
|
|
1675
1878
|
exchange: string | undefined,
|
|
1676
1879
|
ask: HistoryAsk,
|
|
1677
1880
|
ctx: Parameters<CliCommandDef["execute"]>[1],
|
|
1881
|
+
{ wide = false }: { wide?: boolean } = {},
|
|
1678
1882
|
) {
|
|
1679
1883
|
const usage = `Usage: gloom ${HISTORY_USAGE}`;
|
|
1680
1884
|
await withMarketData(ctx, async (market) => {
|
|
@@ -1723,6 +1927,40 @@ async function runHistoryList(
|
|
|
1723
1927
|
// reads it there): the list ends "couldn't refresh; saved copy from <time>" for the oldest copy among its symbols.
|
|
1724
1928
|
const savedAt = served.flatMap((history) => history.freshness?.savedAt ?? []).sort()[0];
|
|
1725
1929
|
const freshness = listFreshness && savedAt && !listFreshness.savedAt ? { ...listFreshness, savedAt } : listFreshness;
|
|
1930
|
+
const symbolsMetadata = listed.map((entry) => "history" in entry ? {
|
|
1931
|
+
...listingMetadata(entry.history.identity),
|
|
1932
|
+
currency: entry.history.unit.currency,
|
|
1933
|
+
unit: entry.history.unit.unit,
|
|
1934
|
+
interval: entry.history.interval,
|
|
1935
|
+
firstDate: entry.history.data[0]?.date ?? null,
|
|
1936
|
+
lastDate: entry.history.data.at(-1)?.date ?? null,
|
|
1937
|
+
bars: entry.history.data.length,
|
|
1938
|
+
asOf: entry.history.freshness?.asOf ?? null,
|
|
1939
|
+
} : { symbol: entry.symbol, error: entry.error });
|
|
1940
|
+
if (wide) {
|
|
1941
|
+
const table = wideHistoryTable(served);
|
|
1942
|
+
notes.push(...table.notes);
|
|
1943
|
+
ctx.printResult({
|
|
1944
|
+
data: table.rows,
|
|
1945
|
+
metadata: {
|
|
1946
|
+
range: ask.window ? null : ask.range,
|
|
1947
|
+
requestedRange: ask.window ? null : ask.range,
|
|
1948
|
+
...(ask.window ? { requestedWindow: ask.window } : {}),
|
|
1949
|
+
symbols: symbolsMetadata,
|
|
1950
|
+
},
|
|
1951
|
+
...(notes.length > 0 ? { warnings: notes } : {}),
|
|
1952
|
+
...(served.length === 0 ? { failure: { code: "cli_error", message: `No history for ${symbols.join(", ")}.` } } : {}),
|
|
1953
|
+
freshness,
|
|
1954
|
+
...(freshness ? {} : { exportFreshness: rowsFreshness([], { status: "not-a-feed", basis: "price bars" }) }),
|
|
1955
|
+
}, {
|
|
1956
|
+
dateKey: "date",
|
|
1957
|
+
columns: table.columns,
|
|
1958
|
+
// The unit is in each close column's header; a row of several symbols has no one symbol or unit to name.
|
|
1959
|
+
exportIdentity: { symbolOrSeries: null, currencyOrUnit: null, interval: table.interval },
|
|
1960
|
+
});
|
|
1961
|
+
if (served.length === 0) process.exitCode = CLI_EXIT_CODES.error;
|
|
1962
|
+
return;
|
|
1963
|
+
}
|
|
1726
1964
|
const decimals = (row: Record<string, unknown>) => bySymbol.get(String(row.symbol))?.decimals ?? 2;
|
|
1727
1965
|
const intraday = served.some((history) => history.intraday);
|
|
1728
1966
|
const textColumns = historyTextColumns(intraday, (value, row) => historyPrice(decimals(row))(value)).map((column) => column.key !== "volume" ? column
|
|
@@ -1737,16 +1975,7 @@ async function runHistoryList(
|
|
|
1737
1975
|
requestedRange: ask.window ? null : ask.range,
|
|
1738
1976
|
...(ask.window ? { requestedWindow: ask.window } : {}),
|
|
1739
1977
|
// Each symbol as a single `history` describes it, or the reason it has no bars.
|
|
1740
|
-
symbols:
|
|
1741
|
-
...listingMetadata(entry.history.identity),
|
|
1742
|
-
currency: entry.history.unit.currency,
|
|
1743
|
-
unit: entry.history.unit.unit,
|
|
1744
|
-
interval: entry.history.interval,
|
|
1745
|
-
firstDate: entry.history.data[0]?.date ?? null,
|
|
1746
|
-
lastDate: entry.history.data.at(-1)?.date ?? null,
|
|
1747
|
-
bars: entry.history.data.length,
|
|
1748
|
-
asOf: entry.history.freshness?.asOf ?? null,
|
|
1749
|
-
} : { symbol: entry.symbol, error: entry.error }),
|
|
1978
|
+
symbols: symbolsMetadata,
|
|
1750
1979
|
},
|
|
1751
1980
|
...(notes.length > 0 ? { warnings: notes } : {}),
|
|
1752
1981
|
...(served.length === 0 ? { failure: { code: "cli_error", message: `No history for ${symbols.join(", ")}.` } } : {}),
|
|
@@ -1765,7 +1994,7 @@ async function runHistoryList(
|
|
|
1765
1994
|
const history = bySymbol.get(String(row.symbol));
|
|
1766
1995
|
return {
|
|
1767
1996
|
symbolOrSeries: String(row.symbol),
|
|
1768
|
-
currencyOrUnit: history ? history.unit
|
|
1997
|
+
currencyOrUnit: history ? historyExportUnit(history.unit) : null,
|
|
1769
1998
|
interval: history?.interval ?? null,
|
|
1770
1999
|
// A symbol with no bars has no as-of of its own.
|
|
1771
2000
|
asOf: history ? history.freshness?.asOf ?? undefined : null,
|
|
@@ -3052,7 +3281,7 @@ async function runFxOnDate(
|
|
|
3052
3281
|
warnings: warnings.length > 0 ? warnings : undefined,
|
|
3053
3282
|
}, {
|
|
3054
3283
|
text: () => amount == null ? describeFxRate(request, rate) : `${describeFxConversion(request, amount, rate)}\n${describeFxRate(request, rate)}`,
|
|
3055
|
-
exportIdentity: { symbolOrSeries: pair, currencyOrUnit: baseCurrency
|
|
3284
|
+
exportIdentity: { symbolOrSeries: pair, currencyOrUnit: `${baseCurrency} per ${currency}`, interval: "1day" },
|
|
3056
3285
|
columns: [
|
|
3057
3286
|
{ key: "currency", header: "Currency" },
|
|
3058
3287
|
{ key: "baseCurrency", header: "Base" },
|
|
@@ -3180,7 +3409,7 @@ async function runFx(rawArgs: string[], ctx: Parameters<CliCommandDef["execute"]
|
|
|
3180
3409
|
`${baseCurrency} rate: ${describeShortRate(quote.rate)}`,
|
|
3181
3410
|
`Covered interest parity: ${formatFxRate(rate)} × ${growth(quote.rate)} / ${growth(base.rate)}; each rate earns simple interest over the ${tenor.days} days, standing in for a ${tenor.label} term rate.`,
|
|
3182
3411
|
].join("\n"),
|
|
3183
|
-
exportIdentity: { symbolOrSeries: pair, currencyOrUnit: baseCurrency
|
|
3412
|
+
exportIdentity: { symbolOrSeries: pair, currencyOrUnit: `${baseCurrency} per ${currency}`, interval: `forward ${tenor.label}` },
|
|
3184
3413
|
columns: [
|
|
3185
3414
|
{ key: "pair", header: "Pair" },
|
|
3186
3415
|
{ key: "tenor", header: "Tenor" },
|
|
@@ -3216,8 +3445,8 @@ async function runFx(rawArgs: string[], ctx: Parameters<CliCommandDef["execute"]
|
|
|
3216
3445
|
rateText,
|
|
3217
3446
|
...peso ? pesoDollarRateLines(peso) : [],
|
|
3218
3447
|
].join("\n"),
|
|
3219
|
-
// The rate is the base currency's price of one unit of the other, at the latest quote of each leg.
|
|
3220
|
-
exportIdentity: { symbolOrSeries: pair, currencyOrUnit: baseCurrency
|
|
3448
|
+
// The rate is the base currency's price of one unit of the other, at the latest quote of each leg: USD per ZAR.
|
|
3449
|
+
exportIdentity: { symbolOrSeries: pair, currencyOrUnit: `${baseCurrency} per ${currency}`, interval: "spot" },
|
|
3221
3450
|
columns: [
|
|
3222
3451
|
{ key: "currency", header: "Currency" },
|
|
3223
3452
|
{ key: "baseCurrency", header: "Base" },
|
|
@@ -3347,6 +3576,7 @@ export const marketDataCliCommands: BuiltinCliCommandDef[] = [
|
|
|
3347
3576
|
{ flags: "--from <year|date>, --start <year|date>", description: `${PRICE_WINDOW_FROM_HELP}. Up to five years come in daily bars, up to twenty weekly, longer monthly` },
|
|
3348
3577
|
{ flags: "--to <year|date>, --end <year|date>", description: PRICE_WINDOW_TO_HELP },
|
|
3349
3578
|
{ flags: "--file <path>", description: "Read the symbols from a text or CSV file, one per line (- reads standard input), and write every symbol's bars in one table" },
|
|
3579
|
+
{ flags: "--wide", description: "One row per date and one close column per symbol, its unit in the header, in place of one long table" },
|
|
3350
3580
|
EXCHANGE_OPTION,
|
|
3351
3581
|
],
|
|
3352
3582
|
sections: [{
|
|
@@ -3360,14 +3590,15 @@ export const marketDataCliCommands: BuiltinCliCommandDef[] = [
|
|
|
3360
3590
|
}, {
|
|
3361
3591
|
title: "CSV",
|
|
3362
3592
|
lines: [
|
|
3363
|
-
"Every --csv has one header, whatever the symbol, range or market state: Date, Open, High, Low, Close, Volume, Flag, Partial, Filled, Unsettled, Volume unit, Volume note, Venue volume, Volume venue, Volume basis, status, then symbol_or_series, currency_or_unit, interval, source and as_of. Prices are plain numbers in the
|
|
3593
|
+
"Every --csv has one header, whatever the symbol, range or market state: Date, Open, High, Low, Close, Volume, Flag, Partial, Filled, Unsettled, Volume unit, Volume note, Venue volume, Volume venue, Volume basis, status, then symbol_or_series, currency_or_unit, interval, source and as_of. Prices are plain numbers in the unit currency_or_unit names: the currency, a pair's quote currency per base (JPY per USD for USDJPY=X) or index points. Partial, Filled and Unsettled are true or false, and status says why a row has no prices.",
|
|
3364
3594
|
"A continuous future whose bars name their contracts (NG=F) adds Contract, Roll and Thin before status: the contract per bar, and true or false for the bar it rolled at and a bar that traded far below those around it.",
|
|
3365
3595
|
],
|
|
3366
3596
|
}, {
|
|
3367
3597
|
title: "Several symbols",
|
|
3368
3598
|
lines: [
|
|
3369
|
-
`history AAPL MSFT 000660.KS, or --file with one symbol a line (- reads standard input), writes every symbol's bars in one long table, ${HISTORY_LIST_CONCURRENCY} symbols loading at once. Each row names its symbol, its
|
|
3599
|
+
`history AAPL MSFT 000660.KS, or --file with one symbol a line (- reads standard input), writes every symbol's bars in one long table, ${HISTORY_LIST_CONCURRENCY} symbols loading at once. Each row names its symbol, its unit and the as-of of that symbol's bars in symbol_or_series, currency_or_unit and as_of.`,
|
|
3370
3600
|
"A symbol with no history is one row with its reason in status, and a warning names it; the command fails only when no symbol has any. --tail 5 keeps each symbol's newest five bars.",
|
|
3601
|
+
"--wide sets the symbols side by side instead: one row per date, one close column per symbol headed with its unit (USDJPY=X close (JPY per USD)), a blank where a symbol has no bar that day. history USDJPY=X USDCHF=X EURCHF=X --csv --wide is a spreadsheet of the three closes; --tail 5 keeps the newest five dates.",
|
|
3371
3602
|
],
|
|
3372
3603
|
}, {
|
|
3373
3604
|
title: "Long history",
|
|
@@ -3645,7 +3876,7 @@ export const marketDataCliCommands: BuiltinCliCommandDef[] = [
|
|
|
3645
3876
|
}, {
|
|
3646
3877
|
title: "Amounts",
|
|
3647
3878
|
lines: [
|
|
3648
|
-
"An amount in front converts it from the first currency to the second: fx 1234.5 EUR/USD, or fx 1234,5 EUR USD. It takes either decimal mark (1.234,5 and 1,234.5 are 1234.5) and reads as an amount of the first currency: 1
|
|
3879
|
+
"An amount in front converts it from the first currency to the second: fx 1234.5 EUR/USD, or fx 1234,5 EUR USD. It takes either decimal mark (1.234,5 and 1,234.5 are 1234.5) and reads as an amount of the first currency: 1.234 EUR is thousands, a third decimal being below a cent, while in a currency with three decimals (KWD) fx asks which. A comma before exactly three digits (fx 1,234 EUR) could be either, so fx asks which: type 1234 or 1.2340. An amount and one currency converts to USD. The answer gives the converted amount, then the rate it used, dated by the source line; --json adds amount and converted.",
|
|
3649
3880
|
],
|
|
3650
3881
|
}, {
|
|
3651
3882
|
title: "A past day",
|
|
@@ -21,8 +21,8 @@ import {
|
|
|
21
21
|
type TickerSearchCandidate,
|
|
22
22
|
} from "../../tickers/search";
|
|
23
23
|
import { initMarketData, withMarketData } from "../context";
|
|
24
|
-
import { listingChangeLine, loadListingFate } from "../../tickers/listing-fate";
|
|
25
|
-
import { formatMarketPriceWithCurrency, quoteFormatOptions } from "../../market-data/market/format";
|
|
24
|
+
import { listingChangeLine, loadListingFate, loadNoQuoteEnding, noLongerListedNote, noQuoteLastTradeNote, type NoQuoteEnding } from "../../tickers/listing-fate";
|
|
25
|
+
import { formatMarketPriceWithCurrency, quoteFormatOptions, withCurrencyMinorDigits } from "../../market-data/market/format";
|
|
26
26
|
import { formerIssuerLine, startTickerChangeLookup, type TickerChangeLookup } from "../../tickers/ticker-changes";
|
|
27
27
|
import { fail, failRetryable, failWithError, isCliFailure, unreachableError } from "../errors";
|
|
28
28
|
import { isProviderBusy, SEARCH_BUSY_CODE, SEARCH_BUSY_MESSAGE } from "../../sources/provider-errors";
|
|
@@ -180,9 +180,25 @@ async function searchFate(
|
|
|
180
180
|
quote: Quote | null,
|
|
181
181
|
dataProvider: DataProvider,
|
|
182
182
|
changes: TickerChangeLookup,
|
|
183
|
+
/** The symbol's last bars when it has no quote (loadNoQuoteEnding), read beside the search. */
|
|
184
|
+
noQuoteEnding: Promise<NoQuoteEnding | null> = Promise.resolve(null),
|
|
183
185
|
): Promise<SearchFate> {
|
|
184
186
|
const fate = await loadListingFate({ symbol }, dataProvider, { quote, changes });
|
|
185
187
|
const unlisted = !candidates.some((candidate) => candidate.symbol.toUpperCase() === symbol);
|
|
188
|
+
// No quote at all (a retired ETN): a listed row the service marks ended says when, and one search no longer lists is
|
|
189
|
+
// listed with its last day and close, from its US line's last bars, when the service's record says it ended. Bars
|
|
190
|
+
// alone that stopped over a month ago say only that it has not traded since.
|
|
191
|
+
if (!quote) {
|
|
192
|
+
const ended = candidates.find((candidate) => candidate.symbol.toUpperCase() === symbol && candidate.result?.delisting)?.result?.delisting;
|
|
193
|
+
if (ended) return { stopped: null, notes: [`${noLongerListedNote(symbol, ended.lastTradeDate)}.`] };
|
|
194
|
+
const ending = unlisted ? await noQuoteEnding : null;
|
|
195
|
+
if (ending && !ending.recorded) return { stopped: null, notes: [`${noQuoteLastTradeNote(symbol, ending)}.`] };
|
|
196
|
+
if (ending) {
|
|
197
|
+
const note = noLongerListedNote(symbol, ending.date);
|
|
198
|
+
return { stopped: { symbol, name: fate.change?.issuer || null, lastTraded: ending.date,
|
|
199
|
+
lastPrice: ending.lastClose == null ? "—" : formatMarketPriceWithCurrency(ending.lastClose, "USD", withCurrencyMinorDigits({}, "USD")), note }, notes: [] };
|
|
200
|
+
}
|
|
201
|
+
}
|
|
186
202
|
const stopped = unlisted && quote && fate.endedOn && fate.note
|
|
187
203
|
? {
|
|
188
204
|
symbol,
|
|
@@ -541,7 +557,7 @@ export function buildSearchReport({
|
|
|
541
557
|
if (bank) lines.push("", wrapToTerminal(centralBankLine(bank)));
|
|
542
558
|
const setting = commandPointer(query);
|
|
543
559
|
if (setting) lines.push("", wrapToTerminal(setting));
|
|
544
|
-
const charted = renderSeriesMatches(query, series, SEARCH_SERIES_LIMIT, cliTerminalWidth() ?? 100
|
|
560
|
+
const charted = renderSeriesMatches(query, series, SEARCH_SERIES_LIMIT, cliTerminalWidth() ?? 100);
|
|
545
561
|
// A query that names the data ("carbon", "day-ahead") lists its series first; words that happen to
|
|
546
562
|
// be in a series name ("apple") list them after the tickers.
|
|
547
563
|
const seriesFirst = series.some((match) => match.exact);
|
|
@@ -667,13 +683,15 @@ export async function search(query: string, dependencies: SearchCommandDependenc
|
|
|
667
683
|
const savedExchange = tickers.find((ticker) => ticker.metadata.ticker.toUpperCase() === symbol)?.metadata.exchange ?? "";
|
|
668
684
|
const quote = bare ? loadSearchedQuote(symbol, savedExchange, dataProvider) : null;
|
|
669
685
|
const changes = bare ? startTickerChangeLookup(dataProvider, symbol) : null;
|
|
686
|
+
// With no quote, its US line's last bars, to list a retired symbol (STPP) with its last day.
|
|
687
|
+
const ending = quote?.then((quoted) => quoted ? null : loadNoQuoteEnding({ symbol }, dataProvider));
|
|
670
688
|
const candidates = await searchCandidatesForCli({
|
|
671
689
|
query: index?.symbol ?? trimmedQuery,
|
|
672
690
|
tickers,
|
|
673
691
|
dataProvider,
|
|
674
692
|
...quote ? { quote } : {},
|
|
675
693
|
}).catch((error: unknown) => failTickerLookup(error, trimmedQuery, !dependencies.printResult));
|
|
676
|
-
const fate = quote && changes ? await searchFate(symbol, candidates, await quote, dataProvider, changes) : NO_SEARCH_FATE;
|
|
694
|
+
const fate = quote && changes ? await searchFate(symbol, candidates, await quote, dataProvider, changes, ending) : NO_SEARCH_FATE;
|
|
677
695
|
|
|
678
696
|
const series = findCatalogSeries(dependencies.plugins ?? [], trimmedQuery, "names");
|
|
679
697
|
const bank = searchedCentralBank(trimmedQuery);
|