gloomberb 0.20.1 → 0.20.2
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/README.md +16 -26
- package/README.zh-CN.md +21 -65
- package/package.json +1 -1
- package/src/account/auth-model.ts +20 -1
- package/src/account/upgrade-dialog.tsx +8 -4
- package/src/api-client/askg.ts +7 -1
- package/src/api-client/auth.ts +27 -0
- package/src/api-client/catalysts.ts +2 -0
- package/src/api-client/company-kpis.ts +2 -1
- package/src/api-client/cot.ts +14 -2
- package/src/api-client/data.ts +3 -2
- package/src/api-client/earnings.ts +46 -3
- package/src/api-client/futures-curve.ts +17 -0
- package/src/api-client/index.ts +4 -1
- package/src/api-client/one-tap-reasons.ts +42 -0
- package/src/api-client/perps.ts +2 -1
- package/src/api-client/request.ts +3 -1
- package/src/api-client/research-activity.ts +16 -3
- package/src/api-client/types/filings-and-calls.ts +3 -0
- package/src/api-client/types/search.ts +3 -0
- package/src/app/keybindings/chord.ts +153 -9
- package/src/app/keybindings/index.ts +1 -1
- package/src/app/keybindings/labels.ts +49 -6
- package/src/app/runtime/desktop-deeplink.ts +73 -8
- package/src/app.tsx +7 -1
- package/src/architecture/core-builtin-allowlist.json +1 -2
- package/src/architecture/pane-tabs-allowlist.json +2 -1
- package/src/architecture/shortcut-labels-allowlist.json +11 -0
- package/src/architecture/ui-literals-allowlist.json +8 -8
- package/src/brokers/broker-portfolio-sync.ts +1 -1
- package/src/cli/bank-section.ts +26 -12
- package/src/cli/commands/market.ts +266 -75
- package/src/cli/commands/ticker.ts +12 -7
- package/src/cli/desktop-pane-shot-browser.ts +47 -31
- package/src/cli/desktop-pane-shot.ts +15 -0
- package/src/cli/entry.ts +5 -0
- package/src/cli/export-source.ts +7 -1
- package/src/cli/freshness.ts +0 -16
- package/src/cli/fx-pair.ts +64 -12
- package/src/cli/fx-quote-rate.ts +144 -0
- package/src/cli/glossary.ts +5 -0
- package/src/cli/history-back-adjust.ts +122 -0
- package/src/cli/history-rows.ts +114 -10
- package/src/cli/index.ts +4 -1
- package/src/cli/known-gaps.ts +45 -3
- package/src/cli/listing-arg.ts +48 -4
- package/src/cli/name-entries.ts +25 -5
- package/src/cli/pane-functions/catalog.ts +12 -2
- package/src/cli/pane-functions/dom.ts +4 -2
- package/src/cli/pane-functions/headless.ts +8 -5
- package/src/cli/pane-functions/index.ts +3 -0
- package/src/cli/pane-functions/resolver.ts +4 -1
- package/src/cli/pane-functions/screenshot-assessment.ts +15 -3
- package/src/cli/pane-functions/screenshot-payload.ts +130 -66
- package/src/cli/pane-functions/screenshot-render.ts +14 -2
- package/src/cli/pane-functions/screenshot-types.ts +4 -0
- package/src/cli/symbol-rows.ts +22 -2
- package/src/cli/ticker-resolution.ts +74 -17
- package/src/components/chart/composite/axis-overlays.tsx +13 -3
- package/src/components/chart/composite/composite-chart.tsx +8 -1
- package/src/components/chart/composite/format.ts +16 -1
- package/src/components/chart/composite/legend.tsx +4 -3
- package/src/components/chart/composite/panel-labels.ts +2 -1
- package/src/components/chart/composite/panel-surface.tsx +33 -4
- package/src/components/chart/composite/time-scale.ts +1 -1
- package/src/components/chart/composite/toolbar.tsx +8 -4
- package/src/components/chart/composite/types.ts +17 -1
- package/src/components/chart/composite/use-composite-chart-keyboard.ts +15 -5
- package/src/components/chart/composite/use-composite-viewport.ts +31 -8
- package/src/components/chart/static/scatter-chart-surface.tsx +25 -9
- package/src/components/chart-table/axis.ts +11 -0
- package/src/components/command-bar/assist/inventory.ts +3 -2
- package/src/components/command-bar/commands/collection-list.ts +3 -2
- package/src/components/command-bar/panel/layout.ts +8 -1
- package/src/components/command-bar/panel/prompt-width.ts +34 -0
- package/src/components/command-bar/panel/state.ts +4 -0
- package/src/components/command-bar/routes/root/search-providers.ts +3 -2
- package/src/components/command-bar/routes/root/search-report.ts +2 -2
- package/src/components/command-bar/workflow/ticker-listing-picker.ts +1 -0
- package/src/components/company-logo.tsx +2 -2
- package/src/components/data-table/view.tsx +11 -2
- package/src/components/feed-data-table/stack-view.tsx +20 -6
- package/src/components/feedback-dialog.tsx +3 -1
- package/src/components/form-modal/field-row.tsx +1 -1
- package/src/components/form-modal/routes.ts +1 -0
- package/src/components/index.ts +1 -1
- package/src/components/layout/header.tsx +12 -3
- package/src/components/layout/market-summary.ts +2 -1
- package/src/components/layout/pane/footer/index.tsx +9 -5
- package/src/components/layout/pane/footer/model.ts +26 -10
- package/src/components/layout/pane/footer/registration.tsx +60 -1
- package/src/components/layout/pane/header-tabs.tsx +17 -3
- package/src/components/layout/pane/header.tsx +5 -2
- package/src/components/layout/pane/pane-tabs.tsx +57 -3
- package/src/components/layout/shell/active-drag.ts +38 -30
- package/src/components/layout/shell/drag/index.ts +51 -21
- package/src/components/layout/shell/menu.ts +3 -5
- package/src/components/layout/shell/pane/actions.ts +4 -1
- package/src/components/layout/shell/pane/ask.ts +5 -2
- package/src/components/layout/status-bar.tsx +59 -54
- package/src/components/markdown-text.tsx +35 -10
- package/src/components/onboarding/first-run-workspace.ts +25 -23
- package/src/components/onboarding/onboarding-keyboard.ts +6 -1
- package/src/components/onboarding/onboarding-wizard.tsx +12 -2
- package/src/components/onboarding/portfolio-step/positions-panel.tsx +3 -3
- package/src/components/onboarding/use-onboarding-broker-form.ts +2 -1
- package/src/components/onboarding/use-onboarding-progress.ts +11 -4
- package/src/components/onboarding/use-onboarding-upgrade.ts +3 -2
- package/src/components/onboarding/wizard-positions.ts +8 -1
- package/src/components/pane-notice-seen.ts +125 -0
- package/src/components/pane-settings-dialog/field-dialogs.tsx +2 -1
- package/src/components/pane-settings-dialog.tsx +7 -6
- package/src/components/sign-in-code-panel.tsx +3 -2
- package/src/components/speedometer-gauge/terminal.tsx +30 -9
- package/src/components/ticker/list-table-view.tsx +39 -3
- package/src/components/ui/confirm-dialog.tsx +2 -1
- package/src/components/ui/data-table/index.tsx +4 -2
- package/src/components/ui/data-table/opentui/index.tsx +15 -5
- package/src/components/ui/data-table/types.ts +8 -0
- package/src/components/ui/external-link.tsx +4 -1
- package/src/components/ui/field-grid.tsx +1 -1
- package/src/components/ui/index.ts +2 -0
- package/src/components/ui/inline-quick-add.tsx +5 -0
- package/src/components/ui/multi-select/dialog.tsx +10 -9
- package/src/components/ui/pane-link-chip.tsx +354 -0
- package/src/components/ui/query-bar.tsx +22 -13
- package/src/components/ui/ratio-bar.tsx +24 -1
- package/src/components/ui/select-button.tsx +2 -1
- package/src/components/ui/shortcut-hint.tsx +6 -3
- package/src/components/ui/table-layout.ts +81 -0
- package/src/components/ui/tabs.tsx +45 -6
- package/src/components/use-pane-notice-footer.tsx +12 -4
- package/src/core/app-service-ports.ts +1 -1
- package/src/data/plugin-state-store.ts +44 -8
- package/src/docs/snapshot.json +53 -32
- package/src/i18n/es.ts +25 -6
- package/src/i18n/ja.ts +25 -5
- package/src/i18n/ko.ts +25 -5
- package/src/i18n/zh-cn.ts +25 -5
- package/src/i18n/zh-tw.ts +25 -5
- package/src/layout/pane-manager/gridlock-inference.ts +2 -1
- package/src/layout/pane-manager/gridlock.ts +47 -2
- package/src/layout-marketplace/api.ts +1 -0
- package/src/layout-marketplace/gallery.tsx +4 -3
- package/src/layout-marketplace/linked.ts +6 -4
- package/src/layout-marketplace/model.ts +3 -2
- package/src/market-data/futures-contract.ts +77 -31
- package/src/market-data/fx-closes.ts +5 -2
- package/src/market-data/hooks.tsx +23 -0
- package/src/market-data/market/change-basis.ts +72 -14
- package/src/market-data/market/format.ts +19 -11
- package/src/market-data/market/globex-day.ts +73 -0
- package/src/market-data/market/index-level.ts +10 -1
- package/src/market-data/quotes/intraday-bar.ts +1 -1
- package/src/market-data/quotes/session-split.ts +28 -0
- package/src/plugins/builtin/account-management/pane.tsx +1 -1
- package/src/plugins/builtin/analytics/account-returns.ts +1 -1
- package/src/plugins/builtin/analytics/index.tsx +10 -3
- package/src/plugins/builtin/analytics/pane-model.ts +1 -1
- package/src/plugins/builtin/analytics/risk-client.ts +4 -1
- package/src/plugins/builtin/analytics/risk-episodes.ts +422 -0
- package/src/plugins/builtin/analytics/risk-fx.ts +1 -1
- package/src/plugins/builtin/analytics/risk-headless.ts +28 -10
- package/src/plugins/builtin/analytics/risk-math.ts +1 -1
- package/src/plugins/builtin/analytics/risk-model.ts +115 -26
- package/src/plugins/builtin/analytics/risk-pane.tsx +201 -23
- package/src/plugins/builtin/analytics/sharpe-cadence.ts +1 -1
- package/src/plugins/builtin/backtest/format.ts +14 -0
- package/src/plugins/builtin/backtest/pane.tsx +3 -3
- package/src/plugins/builtin/backtest/report.ts +5 -3
- package/src/plugins/builtin/broker-manager/add-request.ts +10 -1
- package/src/plugins/builtin/broker-trading/pane.tsx +20 -2
- package/src/plugins/builtin/buildout/company/flow.tsx +5 -5
- package/src/plugins/builtin/buildout/company/model.ts +14 -2
- package/src/plugins/builtin/catalysts/detail.tsx +2 -2
- package/src/plugins/builtin/catalysts/model.ts +7 -2
- package/src/plugins/builtin/catalysts/pane.tsx +2 -2
- package/src/plugins/builtin/chat/message/pane-chip.tsx +36 -208
- package/src/plugins/builtin/cloud/askg/answer-follow-ups.tsx +61 -0
- package/src/plugins/builtin/cloud/askg/answer-sources.tsx +102 -0
- package/src/plugins/builtin/cloud/askg/controller.ts +7 -1
- package/src/plugins/builtin/cloud/askg/host.ts +57 -0
- package/src/plugins/builtin/cloud/askg/model.ts +45 -5
- package/src/plugins/builtin/cloud/askg/pane.tsx +304 -25
- package/src/plugins/builtin/cloud/askg/protocol.ts +26 -1
- package/src/plugins/builtin/cloud/askg/sources.ts +466 -0
- package/src/plugins/builtin/cloud/one-tap/controller.ts +309 -0
- package/src/plugins/builtin/cloud/one-tap/google-identity.ts +142 -0
- package/src/plugins/builtin/cloud/one-tap/one-tap-prompt.tsx +101 -0
- package/src/plugins/builtin/cloud/plugin.tsx +7 -1
- package/src/plugins/builtin/company-kpis/client.ts +4 -3
- package/src/plugins/builtin/company-kpis/model.ts +34 -3
- package/src/plugins/builtin/correlation/index.tsx +39 -167
- package/src/plugins/builtin/correlation/matrix/grid.tsx +285 -0
- package/src/plugins/builtin/correlation/relationship/pane.tsx +6 -7
- package/src/plugins/builtin/correlation/relationship/view-model.ts +14 -5
- package/src/plugins/builtin/cot/client.ts +8 -3
- package/src/plugins/builtin/cot/headless.ts +65 -12
- package/src/plugins/builtin/cot/pane.tsx +11 -5
- package/src/plugins/builtin/earnings/client.ts +40 -6
- package/src/plugins/builtin/earnings/fiscal-quarter.ts +54 -0
- package/src/plugins/builtin/earnings/headless.ts +47 -11
- package/src/plugins/builtin/earnings/history-model.ts +136 -24
- package/src/plugins/builtin/earnings/history-table.ts +42 -10
- package/src/plugins/builtin/earnings/history.tsx +23 -8
- package/src/plugins/builtin/earnings-ripple/client.ts +5 -2
- package/src/plugins/builtin/earnings-ripple/headless.ts +8 -3
- package/src/plugins/builtin/earnings-ripple/model.ts +21 -0
- package/src/plugins/builtin/earnings-ripple/pane.tsx +2 -3
- package/src/plugins/builtin/econ/index.tsx +5 -4
- package/src/plugins/builtin/econ-statistics/stats.ts +13 -5
- package/src/plugins/builtin/equity-screener/headless.ts +2 -1
- package/src/plugins/builtin/filing-events/feed.ts +56 -18
- package/src/plugins/builtin/filing-events/pane.tsx +8 -2
- package/src/plugins/builtin/futures/index.tsx +32 -10
- package/src/plugins/builtin/futures/model.ts +93 -6
- package/src/plugins/builtin/futures/returns.ts +29 -7
- package/src/plugins/builtin/futures/table.tsx +59 -17
- package/src/plugins/builtin/futures/use-front-returns.ts +32 -6
- package/src/plugins/builtin/futures-curve/client.ts +12 -2
- package/src/plugins/builtin/futures-curve/headless.ts +58 -17
- package/src/plugins/builtin/futures-curve/model.ts +111 -15
- package/src/plugins/builtin/futures-curve/pane.tsx +11 -6
- package/src/plugins/builtin/fx-matrix/amount.ts +132 -0
- package/src/plugins/builtin/fx-matrix/headless.ts +53 -13
- package/src/plugins/builtin/fx-matrix/index.tsx +205 -42
- package/src/plugins/builtin/fx-matrix/pairs.ts +10 -8
- package/src/plugins/builtin/fx-matrix/settings.ts +22 -1
- package/src/plugins/builtin/help/index.tsx +68 -61
- package/src/plugins/builtin/holders/format.ts +7 -2
- package/src/plugins/builtin/holders/pane.tsx +11 -3
- package/src/plugins/builtin/holders/report-header.ts +5 -4
- package/src/plugins/builtin/holders/report-rows.ts +4 -1
- package/src/plugins/builtin/holders/treemap.tsx +5 -3
- package/src/plugins/builtin/insider/signals-model.ts +4 -5
- package/src/plugins/builtin/ipo-calendar/headless.ts +18 -7
- package/src/plugins/builtin/ipo-calendar/listing-ipo.ts +3 -1
- package/src/plugins/builtin/ipo-calendar/model.ts +28 -8
- package/src/plugins/builtin/ipo-calendar/pane.tsx +2 -1
- package/src/plugins/builtin/kelly-sizer/headless.ts +4 -0
- package/src/plugins/builtin/perps/headless.ts +73 -17
- package/src/plugins/builtin/perps/index.tsx +3 -1
- package/src/plugins/builtin/perps/model.ts +1 -1
- package/src/plugins/builtin/perps/pane.tsx +2 -0
- package/src/plugins/builtin/portfolio-list/cell-version.ts +1 -0
- package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +20 -1
- package/src/plugins/builtin/portfolio-list/cli/import-positions.ts +260 -0
- package/src/plugins/builtin/portfolio-list/cli/period-report.ts +154 -0
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +64 -22
- package/src/plugins/builtin/portfolio-list/cli/render.ts +18 -7
- package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +5 -3
- package/src/plugins/builtin/portfolio-list/grid.tsx +56 -12
- package/src/plugins/builtin/portfolio-list/headless.ts +128 -0
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +42 -4
- package/src/plugins/builtin/portfolio-list/pane/period-pnl.ts +124 -0
- package/src/plugins/builtin/portfolio-list/period-pnl.ts +179 -0
- package/src/plugins/builtin/portfolio-list/positions-import/dialog.tsx +445 -0
- package/src/plugins/builtin/portfolio-list/positions-import/index.tsx +255 -0
- package/src/plugins/builtin/portfolio-list/positions-import/lookup.ts +78 -0
- package/src/plugins/builtin/portfolio-list/positions-import/read-file.ts +32 -0
- package/src/plugins/builtin/portfolio-list/quick-add/index.tsx +186 -50
- package/src/plugins/builtin/portfolio-list/quick-add/resolution.ts +118 -4
- package/src/plugins/builtin/portfolio-list/settings.ts +25 -0
- package/src/plugins/builtin/portfolio-list/summary/index.tsx +16 -1
- package/src/plugins/builtin/portfolio-list/summary/totals.ts +7 -5
- package/src/plugins/builtin/portfolio-list/table.tsx +105 -6
- package/src/plugins/builtin/power/headless.ts +47 -9
- package/src/plugins/builtin/research/relative-valuation-model.ts +8 -3
- package/src/plugins/builtin/research-search/article.ts +12 -2
- package/src/plugins/builtin/research-search/data.ts +5 -2
- package/src/plugins/builtin/research-search/document-view.tsx +1 -1
- package/src/plugins/builtin/research-search/model.ts +47 -3
- package/src/plugins/builtin/research-search/pane.tsx +3 -2
- package/src/plugins/builtin/reverse-dcf/model.ts +7 -4
- package/src/plugins/builtin/risk-factors/headless.ts +3 -2
- package/src/plugins/builtin/risk-factors/pane.tsx +5 -3
- package/src/plugins/builtin/scanner/flow-model.ts +17 -13
- package/src/plugins/builtin/scanner/flow-pane.tsx +8 -9
- package/src/plugins/builtin/scanner/flow-session.ts +2 -9
- package/src/plugins/builtin/sec/filing-display.tsx +0 -5
- package/src/plugins/builtin/sec/forms.ts +19 -0
- package/src/plugins/builtin/sec/headless.ts +7 -11
- package/src/plugins/builtin/sec/index.tsx +11 -3
- package/src/plugins/builtin/shared/earnings-calendar.ts +6 -3
- package/src/plugins/builtin/shared/earnings-report.ts +1 -1
- package/src/plugins/builtin/shared/fx-rate-freshness.ts +0 -35
- package/src/plugins/builtin/shared/use-quote-board.ts +42 -27
- package/src/plugins/builtin/supply-chain/graph-model.ts +7 -1
- package/src/plugins/builtin/supply-chain/headless.ts +20 -10
- package/src/plugins/builtin/supply-chain/model.ts +117 -20
- package/src/plugins/builtin/supply-chain/pane.tsx +22 -15
- package/src/plugins/builtin/supply-chain/row-evidence.tsx +1 -1
- package/src/plugins/builtin/ticker-detail/data-panes/returns-chart-model.ts +69 -0
- package/src/plugins/builtin/ticker-detail/data-panes/returns-chart.tsx +118 -0
- package/src/plugins/builtin/ticker-detail/data-panes/returns-model.ts +1 -1
- package/src/plugins/builtin/ticker-detail/data-panes/returns-pane.tsx +103 -40
- package/src/plugins/builtin/ticker-detail/headless-schema.ts +10 -1
- package/src/plugins/builtin/ticker-detail/headless.ts +8 -1
- package/src/plugins/builtin/ticker-detail/overview/components.tsx +2 -1
- package/src/plugins/builtin/ticker-detail/overview/model.ts +4 -2
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +11 -8
- package/src/plugins/builtin/ticker-detail/pane.tsx +95 -20
- package/src/plugins/builtin/ticker-detail/research-groups.ts +89 -0
- package/src/plugins/builtin/ticker-detail/settings.ts +4 -3
- package/src/plugins/builtin/volatility/charts.tsx +2 -2
- package/src/plugins/host-resolver.ts +3 -2
- package/src/portfolio/column-values.ts +42 -8
- package/src/portfolio/futures-positions.ts +10 -2
- package/src/portfolio/mutations.ts +4 -3
- package/src/portfolio/period-pnl.ts +119 -0
- package/src/portfolio/positions-import/describe.ts +89 -0
- package/src/portfolio/positions-import/parse.ts +682 -0
- package/src/portfolio/positions-import/plan.ts +295 -0
- package/src/{plugins/builtin/analytics/metrics.ts → portfolio/return-metrics.ts} +24 -11
- package/src/public/__snapshots__/public-api.test.ts.snap +1 -0
- package/src/react/jsx-dev-fallback.ts +62 -0
- package/src/renderers/browser/cloud-transport.ts +1 -1
- package/src/renderers/browser/config-host.ts +3 -1
- package/src/renderers/browser/deeplink-bridge.ts +8 -1
- package/src/renderers/browser/http-proxy-transport.ts +9 -2
- package/src/renderers/browser/main.tsx +2 -1
- package/src/renderers/browser/research-entry.ts +12 -0
- package/src/renderers/cloudflare/http-proxy.ts +8 -2
- package/src/renderers/cloudflare/proxy-session.ts +1 -0
- package/src/renderers/cloudflare/worker.ts +12 -3
- package/src/renderers/dom/desktop/audio-player.tsx +2 -2
- package/src/renderers/dom/desktop/controls.tsx +1 -1
- package/src/renderers/dom/desktop/dialog-actions.tsx +10 -24
- package/src/renderers/dom/desktop/icons.tsx +4 -2
- package/src/renderers/dom/desktop/query-bar.tsx +23 -19
- package/src/renderers/dom/dom-host-providers.tsx +7 -2
- package/src/renderers/dom/host/box.tsx +2 -2
- package/src/renderers/dom/host/input.tsx +13 -0
- package/src/renderers/dom/key-event.ts +1 -0
- package/src/renderers/dom/styles.css +3 -0
- package/src/renderers/electrobun/bun/context-menu/click.ts +1 -0
- package/src/renderers/electrobun/bun/desktop/backend.ts +1 -0
- package/src/renderers/electrobun/bun/desktop/capability-bridge.ts +5 -4
- package/src/renderers/electrobun/bun/desktop/host-requests.ts +5 -4
- package/src/renderers/electrobun/bun/desktop/http-fetch.ts +1 -0
- package/src/renderers/electrobun/bun/desktop/http-stream.ts +1 -1
- package/src/renderers/electrobun/bun/desktop/initialization.ts +3 -1
- package/src/renderers/electrobun/bun/desktop/install-records.ts +4 -1
- package/src/renderers/electrobun/bun/desktop/installer-folder.ts +5 -2
- package/src/renderers/electrobun/bun/desktop/macos-objc.ts +3 -1
- package/src/renderers/electrobun/bun/desktop/screen-setup-file.ts +9 -4
- package/src/renderers/electrobun/bun/desktop/update.ts +27 -13
- package/src/renderers/electrobun/bun/desktop/windows-script.ts +6 -2
- package/src/renderers/electrobun/bun/window/attention.ts +1 -0
- package/src/renderers/electrobun/bun/window/boot-frame.ts +1 -0
- package/src/renderers/electrobun/bun/window/create.ts +1 -0
- package/src/renderers/electrobun/bun/window/electrobun-window-host.ts +13 -8
- package/src/renderers/electrobun/bun/window/native-min-size.ts +1 -1
- package/src/renderers/electrobun/bun/window/remembered-frame.ts +1 -0
- package/src/renderers/electrobun/bun/window/windows-native.ts +3 -1
- package/src/renderers/electrobun/bun/window/windows-quit.ts +3 -1
- package/src/renderers/electrobun/view/app-badge-host.ts +2 -1
- package/src/renderers/electrobun/view/capability-subscription.ts +2 -1
- package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +7 -10
- package/src/renderers/electrobun/view/cli-pane-shot-mutations.ts +36 -0
- package/src/renderers/electrobun/view/http-fetch.ts +2 -1
- package/src/renderers/electrobun/view/main.tsx +9 -4
- package/src/renderers/electrobun/view/remote/capability-invoker.ts +6 -3
- package/src/renderers/electrobun/view/remote/persistence.ts +63 -27
- package/src/renderers/electrobun/view/rpc-timeout.ts +1 -0
- package/src/renderers/electrobun/view/ui-host.tsx +3 -2
- package/src/renderers/electrobun/view/window-fullscreen.ts +3 -1
- package/src/renderers/opentui/browser-open.ts +2 -1
- package/src/renderers/opentui/dialog-host.tsx +1 -1
- package/src/renderers/opentui/interaction-performance.ts +3 -1
- package/src/renderers/opentui/start.tsx +2 -1
- package/src/renderers/opentui/terminal-media.ts +11 -6
- package/src/renderers/opentui/ui-host.tsx +5 -8
- package/src/shares/open.ts +22 -1
- package/src/shares/pane.ts +2 -1
- package/src/sources/gloomberb-cloud/normalizers.ts +3 -0
- package/src/sync/analytics-payload.ts +194 -0
- package/src/sync/baseline.ts +19 -9
- package/src/sync/broker-identity.ts +171 -0
- package/src/sync/broker-instances.ts +137 -0
- package/src/sync/collections-contributor.ts +173 -0
- package/src/sync/config-contributor.ts +100 -0
- package/src/sync/config-merge.ts +229 -0
- package/src/sync/controller.ts +139 -28
- package/src/sync/core-contributors.ts +8 -1583
- package/src/sync/history-memo.ts +32 -0
- package/src/sync/layout-merge.ts +259 -0
- package/src/sync/sanitize.ts +114 -0
- package/src/sync/ticker-merge.ts +208 -0
- package/src/sync/ticker-payload.ts +81 -0
- package/src/sync/types.ts +15 -1
- package/src/telemetry/attention-setting.ts +1 -1
- package/src/telemetry/usage-counts.ts +16 -0
- package/src/test-support/preload.ts +5 -0
- package/src/theme/color-utils.ts +10 -0
- package/src/theme/font-scale.ts +34 -3
- package/src/theme/series-colors.ts +44 -0
- package/src/theme/themes.ts +2 -1
- package/src/tickers/batched-lookups.ts +263 -6
- package/src/tickers/company-name-listing.ts +44 -2
- package/src/tickers/company-name.ts +7 -2
- package/src/tickers/search/upsert.ts +16 -1
- package/src/time-series/base-series.ts +18 -4
- package/src/time-series/studies/indicators.ts +3 -1
- package/src/time-series/studies/resolve.ts +1 -1
- package/src/time-series/types.ts +6 -0
- package/src/types/financials.ts +18 -0
- package/src/types/headless.ts +11 -0
- package/src/ui/host.tsx +26 -3
- package/src/ui/index.tsx +1 -0
- package/src/utils/concurrency.ts +6 -0
- package/src/utils/currency-pair.ts +56 -4
- package/src/utils/datetime-format.ts +11 -0
- package/src/utils/decimal-comma.ts +9 -6
- package/src/utils/exchanges.ts +32 -0
- package/src/utils/fundamentals.ts +41 -0
- package/src/utils/markdown.ts +4 -2
- package/src/utils/pasted-lines.ts +14 -0
- package/src/utils/price-window.ts +2 -1
- package/src/utils/sec-filings.ts +17 -0
- package/src/utils/sec.ts +4 -23
- package/src/utils/shortcut-labels.ts +6 -30
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { logFailure } from "../../utils/log-failure";
|
|
2
|
+
import { normalizeTickerSymbol } from "../../tickers/search/ranking";
|
|
2
3
|
import type { CliCommandDef } from "../../types/plugin";
|
|
3
4
|
import { TIME_RANGES, type TimeRange } from "../../time-series/range";
|
|
4
5
|
import { CHART_RESOLUTION_STEP_MS } from "../../time-series/resolution";
|
|
5
6
|
import { yearToDateStartIndex } from "../../market-data/market/year-to-date";
|
|
6
|
-
import type { EarningsEvent, QuoteBatchResult, QuoteSubscriptionTarget, SecFilingItem } from "../../types/data-provider";
|
|
7
|
+
import type { EarningsEvent, MarketDataRequestContext, QuoteBatchResult, QuoteSubscriptionTarget, SecFilingItem } from "../../types/data-provider";
|
|
7
8
|
import { companyDataNotes, type CompanyFrom } from "../../types/company-from";
|
|
8
9
|
import type { NewsArticle, NewsFeed, NewsQuery } from "../../news/types";
|
|
9
10
|
import { newsSummaryLine } from "../../news/news-model";
|
|
@@ -13,12 +14,13 @@ import type {
|
|
|
13
14
|
CorporateActionsData,
|
|
14
15
|
HolderData,
|
|
15
16
|
OptionsChain,
|
|
17
|
+
PricePoint,
|
|
16
18
|
Quote,
|
|
17
19
|
TickerFinancials,
|
|
18
20
|
} from "../../types/financials";
|
|
19
21
|
import { currencyPriceMinDigits, formatMarketPrice, formatMarketPriceWithCurrency, nearParCoinPriceDigits, penceFigure, quoteFormatOptions, withCurrencyMinorDigits } from "../../market-data/market/format";
|
|
20
22
|
import { INDEX_POINTS_EXPORT_UNIT, isIndexLevel, reportedQuoteVolume } from "../../market-data/market/index-level";
|
|
21
|
-
import { changeBasisJson, changeBasisLabel, changeBasisNote, printPredatesChangeBasis, quoteChangeBasis, quotePreviousCloseDate, quoteSettleText } from "../../market-data/market/change-basis";
|
|
23
|
+
import { changeBasisJson, changeBasisLabel, changeBasisNote, futuresQuoteFromSettle, printPredatesChangeBasis, quoteChangeBasis, quotePreviousCloseDate, quoteSettleText } from "../../market-data/market/change-basis";
|
|
22
24
|
import {
|
|
23
25
|
EXTENDED_SESSION_LABELS,
|
|
24
26
|
getExtendedSessionDisplay,
|
|
@@ -73,7 +75,7 @@ import { latestFinancialPeriod } from "../../utils/latest-financial-period";
|
|
|
73
75
|
import type { FuturesContractTermsPayload } from "../../api-client/futures-curve";
|
|
74
76
|
import { currencyCodeLabel } from "../../utils/currency-units";
|
|
75
77
|
import {
|
|
76
|
-
futuresContractLines, futuresPricePer, futuresRollLines, isFuturesInstrument, loadUsdPerMmbtu, usdPerMmbtuText, type UsdPerMmbtu,
|
|
78
|
+
futuresContractLines, futuresPricePer, futuresRollLines, isFuturesInstrument, loadFuturesPriceUnit, loadUsdPerMmbtu, usdPerMmbtuText, type UsdPerMmbtu,
|
|
77
79
|
} from "../../market-data/futures-contract";
|
|
78
80
|
import {
|
|
79
81
|
chainHasExpiry,
|
|
@@ -125,6 +127,8 @@ import {
|
|
|
125
127
|
type CliReportTables,
|
|
126
128
|
} from "../report-tables";
|
|
127
129
|
import { historyCoverageNotice } from "../../sources/history-coverage";
|
|
130
|
+
import { fetchHistoryResult } from "../../sources/history-result";
|
|
131
|
+
import { settleWithin } from "../../utils/async-deadline";
|
|
128
132
|
import { maxDrawdownText } from "../../utils/max-drawdown";
|
|
129
133
|
import { isPastPriceWindow, loadPriceWindowHistory, PRICE_WINDOW_FROM_HELP, PRICE_WINDOW_TO_HELP, priceWindowText, readPriceWindow, type PriceWindow } from "../../utils/price-window";
|
|
130
134
|
import {
|
|
@@ -144,6 +148,7 @@ import {
|
|
|
144
148
|
historyGapNote,
|
|
145
149
|
historyJumpNote,
|
|
146
150
|
historyUnbrokenFrom,
|
|
151
|
+
dailyRebuildSpans,
|
|
147
152
|
historyAllRangeYears,
|
|
148
153
|
historyIntervalsByRange,
|
|
149
154
|
historyMissingVolumeNote,
|
|
@@ -151,16 +156,20 @@ import {
|
|
|
151
156
|
historyNotes,
|
|
152
157
|
historyReportsVolume,
|
|
153
158
|
historyPriceDecimals,
|
|
159
|
+
historyRolls,
|
|
154
160
|
historyRows,
|
|
155
161
|
historyUnit,
|
|
156
162
|
quotedPriceDivisor,
|
|
163
|
+
withDailyRebuiltBars,
|
|
157
164
|
historyVolume,
|
|
158
165
|
historyVolumeBasis,
|
|
159
166
|
historyVolumeNote,
|
|
167
|
+
type HistoryRoll,
|
|
160
168
|
type HistoryRow,
|
|
161
169
|
type HistoryUnit,
|
|
162
170
|
type HistoryVolume,
|
|
163
171
|
} from "../history-rows";
|
|
172
|
+
import { backAdjustHistory, contractCloses, stitchedRollsNote, type BackAdjustMethod, type StitchedRoll } from "../history-back-adjust";
|
|
164
173
|
import {
|
|
165
174
|
historyExportColumns,
|
|
166
175
|
historyExportStatus,
|
|
@@ -170,7 +179,7 @@ import {
|
|
|
170
179
|
type HistoryListRow,
|
|
171
180
|
} from "../history-export";
|
|
172
181
|
import { fail, isCliFailure, NO_DATA_CODE } from "../errors";
|
|
173
|
-
import { mapWithConcurrency } from "../../utils/concurrency";
|
|
182
|
+
import { createConcurrencyLimiter, mapWithConcurrency } from "../../utils/concurrency";
|
|
174
183
|
import { MISSING_VOLUME_TEXT } from "../../utils/price-history-integrity";
|
|
175
184
|
import { CRYPTO_BOARD_HINT, quoteNotes } from "./crypto-hints";
|
|
176
185
|
import { bareFuturesCode, futuresBoardContract } from "../../market-data/futures-board";
|
|
@@ -196,12 +205,13 @@ import {
|
|
|
196
205
|
searchNewsStories,
|
|
197
206
|
wordMeansMore,
|
|
198
207
|
} from "./news-search";
|
|
199
|
-
import { formatUtcTime } from "../../utils/utc-time";
|
|
208
|
+
import { formatUtcDayTime, formatUtcTime } from "../../utils/utc-time";
|
|
200
209
|
import { DAY_SO_FAR_TEXT, withSessionBar } from "../../time-series/session-bar";
|
|
201
210
|
import { isFiniteNumber } from "../../utils/guards";
|
|
202
211
|
import { exportedFundamentals } from "../../utils/price-earnings";
|
|
203
|
-
import {
|
|
204
|
-
import {
|
|
212
|
+
import { withBankEnterpriseValue } from "../../utils/fundamentals";
|
|
213
|
+
import { fundamentalsFreshness, quotesFreshness, rowsFreshness, valuationFreshness } from "../freshness";
|
|
214
|
+
import { fxPairListing, fxQuoteRateObservation, readFxQuoteRate } from "../fx-quote-rate";
|
|
205
215
|
import { quoteBarNotes } from "../../market-data/quotes/intraday-bar";
|
|
206
216
|
import { cedearRatioText, depositaryPairText, isReceiptSide, listingCedearRatio, listingDepositaryPair } from "../../market-data/depositary-pair";
|
|
207
217
|
import { isPesoDollarPair, loadPesoDollarRates, pesoDollarRateLines, pesoDollarRatesJson } from "../peso-dollar-rates";
|
|
@@ -259,7 +269,7 @@ import {
|
|
|
259
269
|
} from "../listing-arg";
|
|
260
270
|
import { currencyNameMiss, currencyNameStop } from "../currency-name-hint";
|
|
261
271
|
import { liveCompanyQuestion } from "../company-name-hint";
|
|
262
|
-
import { bareListingNote, listingFateNotes, loadNoQuoteLastTraded, noLongerTradingNote, noQuoteLastTraded, noQuoteLastTradeNote, SUCCESSOR_CHANGE_WAIT_MS, tradingListing, usVenueOf } from "../../tickers/listing-fate";
|
|
272
|
+
import { bareListingNote, listingFateNotes, loadNoQuoteLastTraded, noLongerTradingNote, noQuoteLastTraded, noQuoteLastTradeNote, SUCCESSOR_CHANGE_WAIT_MS, tradingListing, usVenueOf, type NoQuoteLastTrade } from "../../tickers/listing-fate";
|
|
263
273
|
import { isYieldIndexSymbol } from "../../tickers/index-roots";
|
|
264
274
|
import {
|
|
265
275
|
analyzeTaxEquivalent, distributionBasis, loadTreasuryTenors, parseTaxRates, TAX_RATE_HELP_OPTIONS, taxEquivalentJson, type TaxRates,
|
|
@@ -291,7 +301,7 @@ import { noSecReportsNotice, nonUsSecListingVenue, secFilingItemCodes } from "..
|
|
|
291
301
|
import type { MarketContext } from "../types";
|
|
292
302
|
import { windowRows } from "../row-window";
|
|
293
303
|
import { answerQuote, errorMessage, notUsTickerSentence } from "../quote-answer";
|
|
294
|
-
import { crossRate, describeFxConversion, describeFxRate, formatFxRate, FX_USAGE,
|
|
304
|
+
import { crossRate, describeFxConversion, describeFxLegs, describeFxRate, formatFxRate, FX_USAGE, parseFxArgs, type FxQuotedFigure } from "../fx-pair";
|
|
295
305
|
import {
|
|
296
306
|
describeShortRate,
|
|
297
307
|
formatForwardPoints,
|
|
@@ -337,8 +347,8 @@ import {
|
|
|
337
347
|
loadIndexedHolders,
|
|
338
348
|
withIndexedHolders,
|
|
339
349
|
} from "../../plugins/builtin/holders/index-holders";
|
|
340
|
-
import {
|
|
341
|
-
import { currentReportItemsLabel } from "../../utils/sec-filings";
|
|
350
|
+
import { loadShownSecFilings } from "../../plugins/builtin/sec/forms";
|
|
351
|
+
import { currentReportItemsLabel, hiddenFilingsMetadata, hiddenFilingsNote, type HiddenFilings } from "../../utils/sec-filings";
|
|
342
352
|
import { INSIDER_REPORT_FILINGS, loadParsedInsiderFilings } from "../../plugins/builtin/insider/client";
|
|
343
353
|
import { insiderEmptyNotice, loadHomeInsiderReportsNote } from "../../plugins/builtin/insider/issuer";
|
|
344
354
|
import { buildInsiderSummary } from "../../plugins/builtin/insider/model";
|
|
@@ -1095,9 +1105,11 @@ async function runQuote(rawArgs: string[], ctx: Parameters<CliCommandDef["execut
|
|
|
1095
1105
|
const formerIssuers = symbolChanges.map(({ formerIssuer }) => formerIssuer);
|
|
1096
1106
|
// A symbol with no quote whose bars stopped over a month ago says when it last traded, in place of why no quote
|
|
1097
1107
|
// came: no longer listed on the service's record (FLAT, a retired ETN), else no trades since. Each costs a history
|
|
1098
|
-
// read, so a long list says only why.
|
|
1099
|
-
|
|
1100
|
-
|
|
1108
|
+
// read, so a long list says only why. A quote the service did not answer is asked after too: a dead listing's
|
|
1109
|
+
// quote can fail where its history still says when it stopped (FRC), and an unreachable service fails it at once.
|
|
1110
|
+
const lastTraded = await Promise.all(answers.map(async ({ result, listing }) => !result.quote && answers.length <= MAX_CHOICE_LOOKUPS
|
|
1111
|
+
? await loadNoQuoteLastTraded(listing.request, market.dataProvider, now) ?? await searchedDelisting(listing, market)
|
|
1112
|
+
: null));
|
|
1101
1113
|
const endedNotes = answers.map(({ listing }, index) => lastTraded[index] ? `${noQuoteLastTradeNote(listing.symbol, lastTraded[index]!)}.` : null);
|
|
1102
1114
|
// A bare symbol whose listing stopped asks after the company by that name that still trades (DBS: D05 on SGX).
|
|
1103
1115
|
const liveCompanies = await Promise.all(answers.map(({ result, listing }) => result.quote && !listing.exchange
|
|
@@ -1112,6 +1124,14 @@ async function runQuote(rawArgs: string[], ctx: Parameters<CliCommandDef["execut
|
|
|
1112
1124
|
const contracts = await Promise.all(answers.map(({ result }) => commandName === "quote" && result.quote
|
|
1113
1125
|
? cliFuturesContract(result.quote.symbol || result.target.symbol, result.quote.instrumentType)
|
|
1114
1126
|
: null));
|
|
1127
|
+
// A future's move the source measured from something other than the session before's settlement of the same contract is measured from it, in the row and in every line.
|
|
1128
|
+
const sourceMoves = answers.map((answer, index) => {
|
|
1129
|
+
const sent = answer.result.quote;
|
|
1130
|
+
const quote = futuresQuoteFromSettle(sent, contracts[index]);
|
|
1131
|
+
if (!sent || quote === sent) return null;
|
|
1132
|
+
answers[index] = { ...answer, result: { ...answer.result, quote } };
|
|
1133
|
+
return { change: sent.change, changePercent: sent.changePercent, previousClose: sent.previousClose };
|
|
1134
|
+
});
|
|
1115
1135
|
// A contract that is not its root's front (NGF27, NG2) prints the front's own price beside it, read in one batch.
|
|
1116
1136
|
const fronts = await loadFuturesFrontQuotes(contracts, market.dataProvider);
|
|
1117
1137
|
// A per-MWh gas price (TTF) adds its dollars per MMBtu at the day's rate, to read beside Henry Hub.
|
|
@@ -1130,11 +1150,12 @@ async function runQuote(rawArgs: string[], ctx: Parameters<CliCommandDef["execut
|
|
|
1130
1150
|
const data = answers.map(({ result, listing, failure }, index) => ({
|
|
1131
1151
|
target: result.target,
|
|
1132
1152
|
listing: listingMetadata(listingIdentity(listing, result.quote)),
|
|
1133
|
-
// The figures the table shows, beside the quote as the source
|
|
1153
|
+
// The figures the table shows, beside the quote they come from: a future's move as the table measures it, and the source's own beside it when that differs.
|
|
1134
1154
|
...quoteSessionFields(result.quote),
|
|
1135
1155
|
// What `change` is measured from, with the label and holiday note the table shows.
|
|
1136
1156
|
changeBasis: changeBasisJson(quoteChangeBasis(result.quote, { terms: contracts[index] }), now),
|
|
1137
1157
|
quote: withPreviousCloseDate(result.quote),
|
|
1158
|
+
...sourceMoves[index] ? { sourceMove: sourceMoves[index] } : {},
|
|
1138
1159
|
...contracts[index] ? { futuresContract: contracts[index] } : {},
|
|
1139
1160
|
...fronts[index] ? { futuresFront: fronts[index] } : {},
|
|
1140
1161
|
...gasInUsd[index] ? { usdPerMmbtu: gasInUsd[index] } : {},
|
|
@@ -1427,6 +1448,43 @@ function historyCommand({ range, window }: HistoryAsk): string {
|
|
|
1427
1448
|
return window ? `history --from ${window.from}${isPastPriceWindow(window) ? ` --to ${window.to}` : ""}` : range === "1Y" ? "history" : `history --range ${range}`;
|
|
1428
1449
|
}
|
|
1429
1450
|
|
|
1451
|
+
/** How long `history` waits for a future's contract terms to name its unit before using the catalog's. */
|
|
1452
|
+
const HISTORY_PRICE_UNIT_WAIT_MS = 1_500;
|
|
1453
|
+
|
|
1454
|
+
/** How long `history` waits for the daily bars that rebuild contradictory monthly bars before printing them with blanks. */
|
|
1455
|
+
const MONTHLY_REBUILD_WAIT_MS = 8_000;
|
|
1456
|
+
/** Reads of daily bars in flight at once to rebuild them. */
|
|
1457
|
+
const MONTHLY_REBUILD_CONCURRENCY = 3;
|
|
1458
|
+
|
|
1459
|
+
/**
|
|
1460
|
+
* Monthly bars whose prices contradict each other, rebuilt from the daily
|
|
1461
|
+
* bars of the months they span (dailyRebuildSpans, withDailyRebuiltBars),
|
|
1462
|
+
* each day the one `venue` trades it on. Any other history, and months
|
|
1463
|
+
* whose daily bars fail or do not answer in time, come back as they are.
|
|
1464
|
+
*/
|
|
1465
|
+
async function withMonthlyBarsRebuilt(
|
|
1466
|
+
rows: HistoryRow[], market: MarketContext, symbol: string, exchange: string,
|
|
1467
|
+
context: MarketDataRequestContext, priceDivisor: number, venue: string,
|
|
1468
|
+
): Promise<HistoryRow[]> {
|
|
1469
|
+
const flagged = rows.filter((row) => row.interval === "1mo" && row.close != null && row.open == null && row.flag
|
|
1470
|
+
&& row.flag.split(",").some((code) => /^(high<|low>)/.test(code)));
|
|
1471
|
+
if (flagged.length === 0) return rows;
|
|
1472
|
+
// Neighbouring months share a read, a few reads at a time; what has come by the deadline is used, and no read starts after it.
|
|
1473
|
+
const spans = dailyRebuildSpans(flagged.map((row) => row.date.slice(0, 7)));
|
|
1474
|
+
const points: PricePoint[] = [];
|
|
1475
|
+
let reading = true;
|
|
1476
|
+
await settleWithin(mapWithConcurrency(spans, MONTHLY_REBUILD_CONCURRENCY, async ({ from, to }) => {
|
|
1477
|
+
if (!reading) return;
|
|
1478
|
+
const start = new Date(`${from}-01T00:00:00Z`);
|
|
1479
|
+
const end = new Date(Date.UTC(Number(to.slice(0, 4)), Number(to.slice(5, 7)), 0, 23, 59, 59));
|
|
1480
|
+
const result = await fetchHistoryResult(market.dataProvider, symbol, exchange, { kind: "detail", start, end, interval: "1d" }, context)
|
|
1481
|
+
.catch(logFailure("cli.commands-market", "Daily bars to rebuild a monthly bar failed", null));
|
|
1482
|
+
if (reading && result?.points) points.push(...result.points);
|
|
1483
|
+
}), MONTHLY_REBUILD_WAIT_MS);
|
|
1484
|
+
reading = false;
|
|
1485
|
+
return points.length ? withDailyRebuiltBars(rows, points, priceDivisor, venue) : rows;
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1430
1488
|
/**
|
|
1431
1489
|
* One listing's bars, dated and checked as `history` prints them. Without
|
|
1432
1490
|
* `lookups` it does not look up the other venues of a bare symbol or whether
|
|
@@ -1450,6 +1508,8 @@ async function loadListingHistory(
|
|
|
1450
1508
|
? market.dataProvider.getPriceHistoryWithMetadata(symbol, exchange, loadRange, context)
|
|
1451
1509
|
: market.dataProvider.getPriceHistory(symbol, exchange, loadRange, context).then((points): PriceHistoryResult => ({ points, resolution: null }));
|
|
1452
1510
|
const quoteAnswer = loadListingQuoteAnswer(market.dataProvider, listing);
|
|
1511
|
+
// A future's prices are in its contract's unit (US cents / bushel), as FUT and G spell it; asked beside the bars.
|
|
1512
|
+
const priceUnit = isFuturesInstrument(symbol, null) ? settleWithin(loadFuturesPriceUnit(symbol), HISTORY_PRICE_UNIT_WAIT_MS) : Promise.resolve(null);
|
|
1453
1513
|
const quoted = quoteAnswer.then((answer) => answer.quote);
|
|
1454
1514
|
const fate = lookups ? listingFateLoader(listing, market, quoted, { successor: true }) : null;
|
|
1455
1515
|
const request = { command: historyCommand(ask), noun: "history", ...(fate ? { fate } : {}) };
|
|
@@ -1473,7 +1533,7 @@ async function loadListingHistory(
|
|
|
1473
1533
|
const identity = listingIdentity(listing, quote);
|
|
1474
1534
|
// Without a quote currency, the listing metadata research reads (as `ticker` does) may still state it.
|
|
1475
1535
|
const listed = quote?.currency ? quote : await market.dataProvider.getQuoteMetadata?.(symbol, exchange).catch(logFailure("cli.commands-market", "Read quote metadata for history failed", null));
|
|
1476
|
-
const unit = historyUnit(listing.key, listed ?? quote);
|
|
1536
|
+
const unit = historyUnit(listing.key, listed ?? quote, await priceUnit);
|
|
1477
1537
|
const traded = {
|
|
1478
1538
|
listing: listing.key, exchange: quote?.listingExchangeName || exchange || undefined, instrumentType: quote?.instrumentType,
|
|
1479
1539
|
};
|
|
@@ -1483,7 +1543,10 @@ async function loadListingHistory(
|
|
|
1483
1543
|
const pair = quote?.instrumentType === "CURRENCY" || isCurrencyPairListing(symbol, exchange);
|
|
1484
1544
|
// A London line's bars were priced in pence: cleaned there, and printed to the pence decimals `quote` shows.
|
|
1485
1545
|
const priceDivisor = quotedPriceDivisor(quote);
|
|
1486
|
-
const
|
|
1546
|
+
const barRows = historyRows(pair ? points.map(({ volume: _volume, ...point }) => point) : points, resolution, unit.currency, unit.unit, volume, priceDivisor);
|
|
1547
|
+
// A monthly bar whose prices contradict each other keeps its close; its open, high and low come from the daily bars.
|
|
1548
|
+
const rows = await withMonthlyBarsRebuilt(barRows, market, symbol, exchange, context, priceDivisor,
|
|
1549
|
+
quote?.listingExchangeName || exchange || "");
|
|
1487
1550
|
// Bars stop arriving on the listing's own trading days, not New York's.
|
|
1488
1551
|
const venue = quote?.listingExchangeName || exchange || undefined;
|
|
1489
1552
|
const served = range === "YTD" && !window ? rows.slice(Math.max(0, yearToDateStartIndex(rows.map((row) => row.date), rows[0]?.interval, venue))) : rows;
|
|
@@ -1668,10 +1731,14 @@ async function runHistory(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
|
|
|
1668
1731
|
const rangeOption = takeOption(args, "--range");
|
|
1669
1732
|
// --from 2007 --to 2009: those years' bars, daily up to five years, in place of a range ending now.
|
|
1670
1733
|
const window = historyWindowOption(args, rangeOption, ctx);
|
|
1671
|
-
const
|
|
1734
|
+
const range = parseRange(rangeOption, ctx);
|
|
1672
1735
|
const requestedExchange = takeOption(args, "--exchange");
|
|
1673
1736
|
// One row a date and a close column a symbol, as a spreadsheet lays several series side by side.
|
|
1674
1737
|
const wide = takeFlag(args, "--wide");
|
|
1738
|
+
// A continuous future stitched across its rolls, by difference unless `ratio` follows.
|
|
1739
|
+
const backAdjust = takeBackAdjust(args, ctx);
|
|
1740
|
+
// Stitching reads daily bars: five years, which come weekly as a range, are read as the window from five years back, which comes daily.
|
|
1741
|
+
const ask: HistoryAsk = { range, window: window ?? (backAdjust && range === "5Y" ? yearsBackWindow(5) : null) };
|
|
1675
1742
|
// A list from a file or standard input (`-`), or several symbols typed (AAPL MSFT, AAPL,MSFT), is one long table.
|
|
1676
1743
|
// One argument with spaces stays one, as before: it may be a company's name.
|
|
1677
1744
|
const file = args.some((arg) => arg === "--file" || arg.startsWith("--file=")) ? takeOption(args, "--file") ?? "" : undefined;
|
|
@@ -1679,6 +1746,7 @@ async function runHistory(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
|
|
|
1679
1746
|
const currency = file != null || requestedExchange ? null : currencyNameStop(args, "history");
|
|
1680
1747
|
if (currency) ctx.fail(currency.message, currency.details);
|
|
1681
1748
|
if (wide || file != null || args.includes("-") || uniqueEntries(args).length > 1 || args.some((arg) => /[,;]/.test(arg))) {
|
|
1749
|
+
if (backAdjust) ctx.fail("--back-adjust stitches one continuous future, such as ES=F.", `Usage: gloom ${HISTORY_USAGE}`);
|
|
1682
1750
|
return runHistoryList(args, file, requestedExchange, ask, ctx, { wide });
|
|
1683
1751
|
}
|
|
1684
1752
|
const raw = requireOneArg(args, HISTORY_USAGE, "symbol", ctx);
|
|
@@ -1690,7 +1758,11 @@ async function runHistory(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
|
|
|
1690
1758
|
if (currency) ctx.fail(currency.message, currency.details);
|
|
1691
1759
|
throw error;
|
|
1692
1760
|
});
|
|
1693
|
-
const { identity, unit,
|
|
1761
|
+
const { identity, unit, interval, intraday, volume, freshness } = history;
|
|
1762
|
+
// Raw stays the default; --back-adjust stitches the contracts at the rolls the warning names, and lists them.
|
|
1763
|
+
const stitched = backAdjust ? await backAdjustListingHistory(history, backAdjust, market, ctx) : null;
|
|
1764
|
+
const data = stitched?.rows ?? history.data;
|
|
1765
|
+
const notes = stitched ? [stitched.note, ...history.notes] : history.notes;
|
|
1694
1766
|
const price = historyPrice(history.decimals);
|
|
1695
1767
|
// A bar without volume in a history that reports it prints as missing.
|
|
1696
1768
|
const missingVolume = historyReportsVolume(data) ? MISSING_VOLUME_TEXT : "";
|
|
@@ -1719,6 +1791,7 @@ async function runHistory(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
|
|
|
1719
1791
|
maxDrawdown: drawdown && contractDrawdown?.contract ? { ...drawdown, contract: contractDrawdown.contract } : drawdown,
|
|
1720
1792
|
asOf: freshness?.asOf ?? null,
|
|
1721
1793
|
...(volume ? { volumeUnit: volume.unit, volumePeriod: interval === "1d" ? "UTC day" : interval } : {}),
|
|
1794
|
+
...(stitched ? { backAdjust: { method: backAdjust, rolls: stitched.rolls, ...(stitched.unstitched.length > 0 ? { unstitched: stitched.unstitched } : {}) } } : {}),
|
|
1722
1795
|
},
|
|
1723
1796
|
...(notes.length > 0 ? { warnings: notes } : {}),
|
|
1724
1797
|
freshness,
|
|
@@ -1739,6 +1812,84 @@ async function runHistory(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
|
|
|
1739
1812
|
});
|
|
1740
1813
|
}
|
|
1741
1814
|
|
|
1815
|
+
/** The window from `years` back to today. */
|
|
1816
|
+
function yearsBackWindow(years: number): PriceWindow | null {
|
|
1817
|
+
const from = new Date();
|
|
1818
|
+
from.setUTCFullYear(from.getUTCFullYear() - years);
|
|
1819
|
+
return readPriceWindow(from.toISOString().slice(0, 10), undefined);
|
|
1820
|
+
}
|
|
1821
|
+
|
|
1822
|
+
/** `--back-adjust` and the method after it (`ratio` or `difference`, the default); null without it. */
|
|
1823
|
+
function takeBackAdjust(args: string[], ctx: Parameters<CliCommandDef["execute"]>[1]): BackAdjustMethod | null {
|
|
1824
|
+
const methods = new Set(["difference", "ratio"]);
|
|
1825
|
+
const equals = args.findIndex((arg) => arg.startsWith("--back-adjust="));
|
|
1826
|
+
if (equals >= 0) {
|
|
1827
|
+
const value = args.splice(equals, 1)[0]!.slice("--back-adjust=".length).toLowerCase();
|
|
1828
|
+
if (!methods.has(value)) ctx.fail(`--back-adjust is by difference or ratio, not "${value}".`, `Usage: gloom ${HISTORY_USAGE}`);
|
|
1829
|
+
return value as BackAdjustMethod;
|
|
1830
|
+
}
|
|
1831
|
+
const index = args.indexOf("--back-adjust");
|
|
1832
|
+
if (index < 0) return null;
|
|
1833
|
+
const next = args[index + 1]?.toLowerCase();
|
|
1834
|
+
const method = next && methods.has(next) ? next as BackAdjustMethod : "difference";
|
|
1835
|
+
args.splice(index, next && methods.has(next) ? 2 : 1);
|
|
1836
|
+
return method;
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1839
|
+
/** Contract reads a back-adjusted history makes at once. */
|
|
1840
|
+
const BACK_ADJUST_READ_LIMIT = 4;
|
|
1841
|
+
/** How far before a roll a contract's bars must reach for its close: past a long holiday weekend. */
|
|
1842
|
+
const ROLL_READ_DAYS = 10;
|
|
1843
|
+
/** The ranges a contract's bars are read over, each with the days it spans at least. */
|
|
1844
|
+
const BACK_ADJUST_READ_RANGES: ReadonlyArray<readonly [TimeRange, number]> = [["1M", 28], ["3M", 89], ["6M", 181], ["1Y", 365], ["5Y", 1826]];
|
|
1845
|
+
|
|
1846
|
+
/**
|
|
1847
|
+
* A continuous future's daily bars back-adjusted at its rolls
|
|
1848
|
+
* (backAdjustHistory): each outgoing and incoming contract's bars read
|
|
1849
|
+
* around its roll, the stitched rolls and the warning that lists them. Fails
|
|
1850
|
+
* for a symbol that is not a continuous future whose bars name their
|
|
1851
|
+
* contracts, for bars coarser than daily, and when a roll cannot be priced.
|
|
1852
|
+
*/
|
|
1853
|
+
async function backAdjustListingHistory(
|
|
1854
|
+
history: ListingHistory,
|
|
1855
|
+
method: BackAdjustMethod,
|
|
1856
|
+
market: MarketContext,
|
|
1857
|
+
ctx: Parameters<CliCommandDef["execute"]>[1],
|
|
1858
|
+
): Promise<{ rows: HistoryRow[]; rolls: StitchedRoll[]; unstitched: HistoryRoll[]; note: string }> {
|
|
1859
|
+
const symbol = history.listing.symbol;
|
|
1860
|
+
const board = futuresBoardContract(symbol);
|
|
1861
|
+
if (!/=F$/i.test(symbol) || !board || !history.data.some((row) => row.contract)) {
|
|
1862
|
+
ctx.fail(`--back-adjust stitches a continuous future's contracts, such as ES=F; ${history.listing.key} is not one whose bars name them.`);
|
|
1863
|
+
}
|
|
1864
|
+
if (history.interval !== "1d") {
|
|
1865
|
+
ctx.fail("--back-adjust stitches daily bars: ask for --range 5Y or less, or a --from window of up to five years.", `Usage: gloom ${HISTORY_USAGE}`);
|
|
1866
|
+
}
|
|
1867
|
+
const rolls = historyRolls(history.data);
|
|
1868
|
+
// Each contract's daily bars over the shortest range that reaches back past its earliest roll.
|
|
1869
|
+
const oldest = new Map<string, number>();
|
|
1870
|
+
for (const roll of rolls) {
|
|
1871
|
+
for (const contract of [roll.from, roll.to]) {
|
|
1872
|
+
const at = Date.parse(`${roll.date.slice(0, 10)}T00:00:00Z`) - ROLL_READ_DAYS * 86_400_000;
|
|
1873
|
+
oldest.set(contract, Math.min(oldest.get(contract) ?? at, at));
|
|
1874
|
+
}
|
|
1875
|
+
}
|
|
1876
|
+
const context = { cacheMode: ctx.cliOptions.refresh ? "refresh" as const : "default" as const };
|
|
1877
|
+
// A few contracts at a time: five years of rolls is forty-odd contracts.
|
|
1878
|
+
const read = createConcurrencyLimiter(BACK_ADJUST_READ_LIMIT);
|
|
1879
|
+
const loaded = await Promise.all([...oldest].map(([contract, from]) => read(() => {
|
|
1880
|
+
const range = BACK_ADJUST_READ_RANGES.find(([, days]) => Date.now() - days * 86_400_000 <= from)?.[0] ?? "5Y";
|
|
1881
|
+
return market.dataProvider.getPriceHistory(`${contract}.${board!.venue}`, "", range, context)
|
|
1882
|
+
.then((points) => ({ contract, closes: contractCloses(points) }))
|
|
1883
|
+
.catch(logFailure("cli.commands-market", "Read a futures contract's bars to back-adjust failed", { contract, closes: new Map<string, number>() }));
|
|
1884
|
+
})));
|
|
1885
|
+
const closes = new Map(loaded.map(({ contract, closes: read }) => [contract, read]));
|
|
1886
|
+
// A contract the source has no bars of leaves its rolls as traded, named in the warning, and the rest are stitched.
|
|
1887
|
+
const unserved = new Set(loaded.flatMap(({ contract, closes: read }) => read.size === 0 ? [contract] : []));
|
|
1888
|
+
const stitched = backAdjustHistory(history.data, method, (contract) => closes.get(contract));
|
|
1889
|
+
const named = history.data.findIndex((row) => row.contract);
|
|
1890
|
+
return { ...stitched, note: stitchedRollsNote(symbol, method, stitched.rolls, named > 0 ? history.data[named]!.date : null, stitched.unstitched, unserved) };
|
|
1891
|
+
}
|
|
1892
|
+
|
|
1742
1893
|
/** A symbol of a list: its bars, or why it has none. */
|
|
1743
1894
|
type ListedHistory = { symbol: string; history: ListingHistory } | { symbol: string; error: string };
|
|
1744
1895
|
|
|
@@ -2137,7 +2288,9 @@ async function runFinancials(rawArgs: string[], ctx: Parameters<CliCommandDef["e
|
|
|
2137
2288
|
marketCap: capitalization?.value ?? null,
|
|
2138
2289
|
marketCapCurrency: capitalization?.currency ?? null,
|
|
2139
2290
|
} : {},
|
|
2140
|
-
|
|
2291
|
+
// A bank's EV and EV/revenue are null with why: n/m for banks.
|
|
2292
|
+
fundamentals: priced.fundamentals && exportedDividendFundamentals(
|
|
2293
|
+
exportedFundamentals(withBankEnterpriseValue(priced.fundamentals, priced.profile))!, report.distributions),
|
|
2141
2294
|
// A bond fund's sponsor figures; fundamentals.dividendYield is then its distribution yield, not its SEC yield.
|
|
2142
2295
|
...bond ? { bondFund: bond } : {},
|
|
2143
2296
|
...view === "fundamentals" ? { statementFilings, bank: bank.bank, ...bank.note ? { bankNote: bank.note } : {} } : {},
|
|
@@ -2364,8 +2517,12 @@ async function runNews(rawArgs: string[], ctx: Parameters<CliCommandDef["execute
|
|
|
2364
2517
|
// to its future: the stories that mention the word are the news.
|
|
2365
2518
|
const word = commodity ?? (unfiled ? newsFallbackText(args[0]!) : null);
|
|
2366
2519
|
const futuresCode = !!word && !!bareFuturesCode(word) && isFuturesInstrument(listing!.symbol, quote?.instrumentType);
|
|
2520
|
+
// A word typed as a word ("corn", not CORN) that a ticker answers to but no story is filed under: the stories
|
|
2521
|
+
// that mention the word, said to be that (Teucrium Corn Fund had none on 5 Nov 2026; corn's market had plenty).
|
|
2522
|
+
const typedWord = !!word && /^[A-Za-z]{3,}$/.test(word) && /[a-z]/.test(word);
|
|
2367
2523
|
const reason = commodity ? `the commodity ${future!.symbol} trades`
|
|
2368
|
-
: !resolved ? "no ticker by that name" : futuresCode ? "a futures code, not a ticker"
|
|
2524
|
+
: !resolved ? "no ticker by that name" : futuresCode ? "a futures code, not a ticker"
|
|
2525
|
+
: typedWord ? `no stories filed under ${listing!.symbol}${identity?.name ? ` (${identity.name})` : ""}` : null;
|
|
2369
2526
|
const emptyMessage = (searched: boolean) => listing && identity
|
|
2370
2527
|
? newsEmptyMessage(searched && word ? word : listing.symbol, listingTitle(identity), quote, resolved, searched)
|
|
2371
2528
|
: undefined;
|
|
@@ -2467,7 +2624,10 @@ async function runFilings(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
|
|
|
2467
2624
|
const count = parsePositiveInt(takeOption(args, "--count"), ctx.cliOptions.tail ?? ctx.cliOptions.limit ?? 15, "Count", ctx);
|
|
2468
2625
|
const exchangeOption = takeOption(args, "--exchange");
|
|
2469
2626
|
const form = takeOption(args, "--form")?.trim() || null;
|
|
2470
|
-
|
|
2627
|
+
// As in fn SEC: a bank's pricing supplements and a trust's other funds stay out unless --all, and the list
|
|
2628
|
+
// says how many it left out.
|
|
2629
|
+
const all = takeFlag(args, "--all");
|
|
2630
|
+
const raw = requireOneArg(args, "filings <symbol> [--count <n>] [--form <form>] [--all]", "symbol", ctx);
|
|
2471
2631
|
await withMarketData(ctx, async (market) => {
|
|
2472
2632
|
// NST.AX is NST:ASX, as quote, valuation and the pane functions read it: the SEC is asked by venue.
|
|
2473
2633
|
const listing = await requireCliListing(raw, exchangeOption, market, ctx, { venueSuffix: true });
|
|
@@ -2481,15 +2641,19 @@ async function runFilings(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
|
|
|
2481
2641
|
const pageLine = page ? `${page.name}: ${page.url}` : null;
|
|
2482
2642
|
try {
|
|
2483
2643
|
const context = identity?.name ? { listingName: identity.name } : undefined;
|
|
2644
|
+
const load = (rows: number) => market.dataProvider.getSecFilings(symbol, rows, exchange, context);
|
|
2645
|
+
let hidden: HiddenFilings | null = null;
|
|
2484
2646
|
const [filings, quote] = await Promise.all([
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2647
|
+
// What fn SEC shows: a form filter searches every filing listed for the issuer; without one, what fn SEC
|
|
2648
|
+
// leaves out by default stays out unless --all.
|
|
2649
|
+
loadForListing(listing, market, ctx, () => loadShownSecFilings(load, count, { form, all }).then((shown) => {
|
|
2650
|
+
hidden = shown.hidden;
|
|
2651
|
+
return shown.filings;
|
|
2652
|
+
}),
|
|
2490
2653
|
(found) => found.length === 0),
|
|
2491
2654
|
quotePromise,
|
|
2492
2655
|
]);
|
|
2656
|
+
const hiddenNote = hidden ? hiddenFilingsNote(hidden) : null;
|
|
2493
2657
|
const resolved = identity ?? listingIdentity(listing, quote);
|
|
2494
2658
|
const choice = await listingChoiceNotes(listing, market, quote, venues);
|
|
2495
2659
|
// A company on ASX that files nothing with the SEC lists its ASX announcements instead.
|
|
@@ -2502,6 +2666,7 @@ async function runFilings(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
|
|
|
2502
2666
|
metadata: {
|
|
2503
2667
|
...listingMetadata(resolved), ...(form ? { form } : {}),
|
|
2504
2668
|
...(page ? { announcementsPage: page.url } : {}),
|
|
2669
|
+
...hiddenFilingsMetadata(hidden),
|
|
2505
2670
|
},
|
|
2506
2671
|
freshness: rowsFreshness(filingRows(filings), SEC_FILING_ROWS),
|
|
2507
2672
|
...(choice.length > 0 ? { warnings: choice } : {}),
|
|
@@ -2515,7 +2680,7 @@ async function runFilings(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
|
|
|
2515
2680
|
empty: [form ? `No ${form} filings found for ${listingTitle(resolved)}.`
|
|
2516
2681
|
: identity ? noSecReportsNotice(resolved)
|
|
2517
2682
|
: `No SEC filings found for ${listingTitle(resolved)}.`, pageLine].filter(Boolean).join("\n"),
|
|
2518
|
-
...filingsFootnote(pageLine, filings[0]?.companyFrom),
|
|
2683
|
+
...filingsFootnote(pageLine, filings[0]?.companyFrom, hiddenNote),
|
|
2519
2684
|
});
|
|
2520
2685
|
} catch (error) {
|
|
2521
2686
|
if (!(error instanceof SecRegistrantMismatchError)) throw error;
|
|
@@ -2534,12 +2699,29 @@ async function runFilings(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
|
|
|
2534
2699
|
}
|
|
2535
2700
|
|
|
2536
2701
|
/**
|
|
2537
|
-
*
|
|
2538
|
-
*
|
|
2539
|
-
*
|
|
2702
|
+
* A bare symbol's own row that search marks as delisted (FRC: inactive, last
|
|
2703
|
+
* traded 2023-04-28), the service's record of it, for a symbol whose quote
|
|
2704
|
+
* and bars said nothing: "FRC last traded 2023-04-28; no longer listed".
|
|
2540
2705
|
*/
|
|
2541
|
-
function
|
|
2542
|
-
|
|
2706
|
+
async function searchedDelisting(listing: CliListing, market: MarketContext): Promise<NoQuoteLastTrade | null> {
|
|
2707
|
+
if (listing.exchange || !market.dataProvider.search || !/^[A-Z][A-Z0-9.-]{0,9}$/.test(listing.symbol)) return null;
|
|
2708
|
+
const rows = await market.dataProvider.search(listing.symbol).catch(logFailure("cli.market", "Search a delisted symbol failed", []));
|
|
2709
|
+
const row = rows.find((result) => result.delisting && normalizeTickerSymbol(result.symbol) === listing.symbol);
|
|
2710
|
+
return row?.delisting ? { date: row.delisting.lastTradeDate, recorded: true } : null;
|
|
2711
|
+
}
|
|
2712
|
+
|
|
2713
|
+
/**
|
|
2714
|
+
* The lines `filings` prints under its rows and CSV writes as notes: how
|
|
2715
|
+
* many pricing supplements it left out, an ASX listing's announcements page,
|
|
2716
|
+
* and whose filings a foreign line shows when they are its company's home
|
|
2717
|
+
* line's.
|
|
2718
|
+
*/
|
|
2719
|
+
function filingsFootnote(
|
|
2720
|
+
pageLine: string | null | undefined,
|
|
2721
|
+
companyFrom: CompanyFrom | undefined,
|
|
2722
|
+
hiddenNote: string | null = null,
|
|
2723
|
+
): { footnote?: string; exportNotes?: string[] } {
|
|
2724
|
+
const lines = [...(hiddenNote ? [hiddenNote] : []), ...(pageLine ? [pageLine] : []), ...companyDataNotes(companyFrom)];
|
|
2543
2725
|
return lines.length ? { footnote: lines.join("\n"), exportNotes: lines } : {};
|
|
2544
2726
|
}
|
|
2545
2727
|
|
|
@@ -3262,7 +3444,15 @@ async function runFxOnDate(
|
|
|
3262
3444
|
}
|
|
3263
3445
|
}
|
|
3264
3446
|
const from = legs.get(currency), into = legs.get(baseCurrency);
|
|
3447
|
+
// Converted at the closes as sent, never at a rounded rate; the line names each close it used.
|
|
3265
3448
|
const rate = currency === baseCurrency ? 1 : crossRate(from?.rate, into?.rate);
|
|
3449
|
+
const closes: FxQuotedFigure[] = codes.flatMap((code) => {
|
|
3450
|
+
const leg = dailyFxLeg(code), close = legs.get(code)?.close;
|
|
3451
|
+
return leg && close != null ? [{ pair: leg.invert ? `USD/${code}` : `${code}/USD`, figure: close }] : [];
|
|
3452
|
+
});
|
|
3453
|
+
const rateLine = closes.length > 1
|
|
3454
|
+
? `${describeFxRate(request, rate)} · ${describeFxLegs(closes)}`
|
|
3455
|
+
: describeFxRate(request, rate, closes[0]);
|
|
3266
3456
|
// A cross is as old as its older close; a weekend or holiday reads the trading day before it.
|
|
3267
3457
|
const closeDate = [...legs.values()].map((leg) => leg.date).sort()[0]!;
|
|
3268
3458
|
const converted = amount == null ? null : amount * rate;
|
|
@@ -3283,7 +3473,7 @@ async function runFxOnDate(
|
|
|
3283
3473
|
freshness: rowsFreshness([], { status: "not-a-feed", basis: "daily FX close", asOf: closeDate }),
|
|
3284
3474
|
warnings: warnings.length > 0 ? warnings : undefined,
|
|
3285
3475
|
}, {
|
|
3286
|
-
text: () => amount == null ?
|
|
3476
|
+
text: () => amount == null ? rateLine : `${describeFxConversion(request, amount, rate)}\n${rateLine}`,
|
|
3287
3477
|
exportIdentity: { symbolOrSeries: pair, currencyOrUnit: `${baseCurrency} per ${currency}`, interval: "1day" },
|
|
3288
3478
|
columns: [
|
|
3289
3479
|
{ key: "currency", header: "Currency" },
|
|
@@ -3334,49 +3524,43 @@ async function runFx(rawArgs: string[], ctx: Parameters<CliCommandDef["execute"]
|
|
|
3334
3524
|
(payload) => ({ payload }),
|
|
3335
3525
|
(error: unknown) => ({ error: unavailableOnServer(error, "Forwards are not available from Gloom Cloud yet: it serves no short rates.") }),
|
|
3336
3526
|
) : null;
|
|
3337
|
-
|
|
3338
|
-
const
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
const legs = await Promise.all(codes.map(load));
|
|
3347
|
-
const missing = codes.filter((_code, index) => !isUsableRate(legs[index]?.value));
|
|
3348
|
-
if (missing.length > 0) {
|
|
3349
|
-
// A reason the data service gave for the first missing leg says more than the generic line.
|
|
3350
|
-
const reason = missing.map((code) => reasons.get(code)).find(Boolean);
|
|
3527
|
+
// The pair's own quote, as `quote` and the FX board read it; a pair with none is crossed through the dollar.
|
|
3528
|
+
const now = Date.now();
|
|
3529
|
+
const read = await readFxQuoteRate(currency, baseCurrency, (targets, options) => market.dataProvider.getQuotesBatch(targets, options),
|
|
3530
|
+
{ forceRefresh: ctx.cliOptions.refresh, now });
|
|
3531
|
+
if (read && "missing" in read) {
|
|
3532
|
+
// A reason the data service gave for a missing quote (spot gold is not quoted) says more than the generic line;
|
|
3533
|
+
// a symbol that names nothing (USDXYZ=X) or a source with nothing to say (No quote provider available) does not.
|
|
3534
|
+
const reason = read.errors.map((error) => providerMissReason(error)
|
|
3535
|
+
?? (typeof error === "string" && !/^(?:Not a ticker|No quote provider)\b|unavailable/i.test(error) ? error : undefined)).find(Boolean);
|
|
3351
3536
|
if (reason) ctx.fail(reason);
|
|
3352
3537
|
ctx.fail(
|
|
3353
|
-
`Exchange rate unavailable for ${missing.join(" and ")}.`,
|
|
3354
|
-
|
|
3538
|
+
`Exchange rate unavailable for ${read.missing.join(" and ")}.`,
|
|
3539
|
+
`No quote came back for ${fxPairListing(currency, baseCurrency).symbol}${currency !== "USD" && baseCurrency !== "USD" ? " or the dollar pairs it crosses from" : ""}. Check the ISO code.`,
|
|
3355
3540
|
);
|
|
3356
3541
|
}
|
|
3357
|
-
const
|
|
3358
|
-
// A
|
|
3359
|
-
|
|
3360
|
-
const
|
|
3361
|
-
const
|
|
3542
|
+
const quoted = read && !("missing" in read) ? read : null;
|
|
3543
|
+
// A conversion uses the quote as sent (or the cross of the dollar pairs as sent), never a rounded rate,
|
|
3544
|
+
// and the rate line prints each figure it used.
|
|
3545
|
+
const rate = quoted ? quoted.rate : 1;
|
|
3546
|
+
const observation = quoted ? fxQuoteRateObservation(quoted, now) : null;
|
|
3547
|
+
const asOf = observation && Number.isFinite(observation.updatedAt) ? new Date(observation.updatedAt).toISOString() : null;
|
|
3548
|
+
// A rate older than its feed's delay is stale, as `quote` says of the same quote.
|
|
3549
|
+
const stale = observation?.stale === true;
|
|
3362
3550
|
const converted = amount == null ? null : amount * rate;
|
|
3363
|
-
const row = {
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
// A rate that is its pair's bar says which bar, and a stale one why it stands.
|
|
3377
|
-
const timings = new Map([...loaded].map(([code, leg]) => [code, leg.timing]));
|
|
3378
|
-
// --refresh read every leg again: one that is still stale says the data service has no newer rate.
|
|
3379
|
-
const rateNotes = [...fxRateNotes(timings), ...ctx.cliOptions.refresh ? refreshedFxRateNotes(timings) : []];
|
|
3551
|
+
const row = {
|
|
3552
|
+
currency, baseCurrency, rate, asOf, stale, pair, inverse: 1 / rate,
|
|
3553
|
+
...(quoted ? { quotes: quoted.quotes.map(({ symbol }) => symbol), ...(quoted.viaUsd ? { via: "USD" } : {}) } : {}),
|
|
3554
|
+
...(amount == null ? {} : { amount, converted }),
|
|
3555
|
+
};
|
|
3556
|
+
// The closing line is the quote's own, as `quote` prints it: its time, and stale once older than the feed's delay.
|
|
3557
|
+
const freshness = observation ? rowsFreshness([observation], undefined, undefined, now) : undefined;
|
|
3558
|
+
// A rate that is its pair's bar says which bar, and a stale one why it stands; --refresh says when it found nothing newer.
|
|
3559
|
+
const rateNotes = (quoted?.quotes ?? []).flatMap(({ symbol, quote }) => [
|
|
3560
|
+
...quoteBarNotes(symbol, quote, now),
|
|
3561
|
+
...ctx.cliOptions.refresh && !quote.staleReason && isQuoteStaleForCurrentSession(quote, now)
|
|
3562
|
+
? [`${symbol}: --refresh found no newer quote than ${formatUtcDayTime({ time: quote.lastUpdated, dateOnly: false }, now)} UTC.`] : [],
|
|
3563
|
+
]);
|
|
3380
3564
|
if (tenor && shortRates && !("error" in tenor)) {
|
|
3381
3565
|
const read = await shortRates;
|
|
3382
3566
|
if ("error" in read) throw read.error;
|
|
@@ -3440,7 +3624,12 @@ async function runFx(rawArgs: string[], ctx: Parameters<CliCommandDef["execute"]
|
|
|
3440
3624
|
? await loadPesoDollarRates((targets) => market.dataProvider.getQuotesBatch(targets, { forceRefresh: ctx.cliOptions.refresh }))
|
|
3441
3625
|
: null;
|
|
3442
3626
|
if (peso && peso.missing.length > 0) warnings.push(`No price for ${peso.missing.join(", ")}, so the rates from ${peso.missing.length === 1 ? "it are" : "them are"} left out.`);
|
|
3443
|
-
|
|
3627
|
+
// A cross says so, naming the dollar pairs it is read from: the pair has no quote of its own.
|
|
3628
|
+
const rateText = [
|
|
3629
|
+
describeFxRate(request, rate, quoted && !quoted.viaUsd ? quoted.quotes[0] : undefined),
|
|
3630
|
+
...quoted?.viaUsd ? [describeFxLegs(quoted.quotes)] : [],
|
|
3631
|
+
...peso ? [`${peso.spotKind} rate`] : [],
|
|
3632
|
+
].join(" · ");
|
|
3444
3633
|
ctx.printResult({ data: [peso ? { ...row, ...pesoDollarRatesJson(peso) } : row], freshness, warnings: warnings.length > 0 ? warnings : undefined }, {
|
|
3445
3634
|
// The conversion, then the rate it used; the source line under it dates that rate.
|
|
3446
3635
|
text: () => [
|
|
@@ -3580,6 +3769,7 @@ export const marketDataCliCommands: BuiltinCliCommandDef[] = [
|
|
|
3580
3769
|
{ flags: "--to <year|date>, --end <year|date>", description: PRICE_WINDOW_TO_HELP },
|
|
3581
3770
|
{ 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" },
|
|
3582
3771
|
{ flags: "--wide", description: "One row per date and one close column per symbol, its unit in the header, in place of one long table" },
|
|
3772
|
+
{ flags: "--back-adjust [ratio]", description: "A continuous future (ES=F) stitched into one series at the rolls its bars name: every price before a roll moved by the gap between the two contracts that day (by difference, or scaled by their ratio with ratio), the rolls listed in a warning and in --json metadata.backAdjust. Daily bars, --range 5Y included; a roll whose contracts the source serves no bars of is left as traded and named. Raw front-month prices are the default" },
|
|
3583
3773
|
EXCHANGE_OPTION,
|
|
3584
3774
|
],
|
|
3585
3775
|
sections: [{
|
|
@@ -3828,10 +4018,11 @@ export const marketDataCliCommands: BuiltinCliCommandDef[] = [
|
|
|
3828
4018
|
description: "Fetch recent SEC filings; a listing abroad gets its exchange's announcements page, and ASX's list",
|
|
3829
4019
|
help: {
|
|
3830
4020
|
group: CLI_COMMAND_GROUPS.companyData,
|
|
3831
|
-
usage: ["filings <symbol> [--count <n>] [--form <form>]"],
|
|
4021
|
+
usage: ["filings <symbol> [--count <n>] [--form <form>] [--all]"],
|
|
3832
4022
|
options: [
|
|
3833
4023
|
{ flags: "--count <n>", description: "Number of filings (default 15)" },
|
|
3834
4024
|
{ flags: "--form <form>", description: "Only this form and its amendments, such as 10-K or 13D" },
|
|
4025
|
+
{ flags: "--all", description: "Also list what fn SEC leaves out by default: the pricing supplements and term sheets (424B2, FWP) a bank files for each structured note, and a fund trust's filings for its other funds" },
|
|
3835
4026
|
EXCHANGE_OPTION,
|
|
3836
4027
|
],
|
|
3837
4028
|
examples: ["filings AAPL", "filings BHP:ASX", "filings NST.AX", "filings AAPL --count 40 --json", "filings CAR --form 13G"],
|
|
@@ -3879,7 +4070,7 @@ export const marketDataCliCommands: BuiltinCliCommandDef[] = [
|
|
|
3879
4070
|
}, {
|
|
3880
4071
|
title: "Amounts",
|
|
3881
4072
|
lines: [
|
|
3882
|
-
"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
|
|
4073
|
+
"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; 1.5 and 1,5 are 1.5). A lone comma or dot before exactly three digits (fx 1,234 EUR, fx 1.234 EUR) could be thousands or a decimal, 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.",
|
|
3883
4074
|
],
|
|
3884
4075
|
}, {
|
|
3885
4076
|
title: "A past day",
|