gloomberb 0.20.3 → 0.20.5
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 +2 -0
- package/bin/gloom +9 -0
- package/bin/without-bun.cjs +98 -0
- package/package.json +3 -1
- package/src/account/auth-dialog.tsx +17 -0
- package/src/api-client/data.ts +144 -35
- package/src/api-client/fx-interventions.ts +64 -0
- package/src/api-client/index.ts +1 -0
- package/src/api-client/release-summaries.ts +21 -0
- package/src/api-client/types/econ.ts +12 -0
- package/src/api-client/yield-curves.ts +1 -1
- package/src/app/global-shortcuts.ts +4 -1
- package/src/app/keybindings/actions.ts +8 -2
- package/src/app/keybindings/config.ts +2 -1
- package/src/app/keybindings/index.ts +1 -0
- package/src/app/keybindings/labels.ts +6 -1
- package/src/app/keybindings/resolve.ts +23 -4
- package/src/app/keybindings/terminal-keys.ts +35 -0
- package/src/app/pane-runtime/index.tsx +2 -2
- package/src/app/pane-runtime/ticker-open-runtime.ts +274 -67
- package/src/architecture/ui-literals-allowlist.json +1 -1
- package/src/capabilities/chart-series.ts +27 -1
- package/src/cli/commands/keybindings.ts +5 -5
- package/src/cli/commands/market.ts +154 -21
- package/src/cli/commands/news-search.ts +60 -10
- package/src/cli/commands/overview.ts +16 -1
- package/src/cli/commands/plugins.ts +27 -5
- package/src/cli/commands/remote.ts +16 -17
- package/src/cli/commands/system.ts +20 -4
- package/src/cli/commands/ticker.ts +60 -19
- package/src/cli/fx-forward.ts +25 -7
- package/src/cli/glossary.ts +19 -5
- package/src/cli/history-rows.ts +5 -3
- package/src/cli/index.ts +8 -8
- package/src/cli/known-gaps.ts +27 -1
- package/src/cli/listing-arg.ts +11 -1
- package/src/cli/name-entries.ts +5 -1
- package/src/cli/not-a-ticker.ts +4 -0
- package/src/cli/pane-functions/function-help.ts +5 -5
- package/src/cli/report-tables.ts +18 -6
- package/src/cli/result.ts +15 -7
- package/src/cli/types.ts +2 -0
- package/src/components/chart/composite/axis-overlays.tsx +22 -0
- package/src/components/chart/composite/composite-chart.tsx +54 -13
- package/src/components/chart/composite/event-captions.ts +109 -0
- package/src/components/chart/composite/event-guides.ts +74 -0
- package/src/components/chart/composite/rasterizer.ts +2 -0
- package/src/components/chart/composite/text-renderer.ts +2 -0
- package/src/components/chart/composite/types.ts +31 -0
- package/src/components/command-bar/layout-items/focused-pane.ts +5 -5
- package/src/components/command-bar/pane-settings.ts +2 -2
- package/src/components/command-bar/routes/root/provider-search.ts +5 -4
- package/src/components/command-bar/routes/root/results.ts +6 -2
- package/src/components/command-bar/routes/ticker-search/results.ts +51 -0
- package/src/components/command-bar/routes/ticker-search/route.ts +3 -2
- package/src/components/input-search-bar.tsx +9 -2
- package/src/components/layout/detached-pane-shell.tsx +1 -1
- package/src/components/layout/floating-pane.tsx +5 -1
- package/src/components/layout/pane/footer/index.tsx +21 -14
- package/src/components/layout/pane/footer/model.ts +6 -0
- package/src/components/layout/pane/header.tsx +2 -0
- package/src/components/layout/shell/action-menu-overlay.tsx +10 -5
- package/src/components/layout/shell/active-drag.ts +149 -105
- package/src/components/layout/shell/drag/drop-zones.ts +162 -0
- package/src/components/layout/shell/drag/index.ts +47 -218
- package/src/components/layout/shell/drag/live.ts +10 -3
- package/src/components/layout/shell/drag/overlays.tsx +182 -5
- package/src/components/layout/shell/drag/runtime.ts +29 -6
- package/src/components/layout/shell/drag/shared-edges.ts +156 -0
- package/src/components/layout/shell/index.tsx +11 -6
- package/src/components/layout/shell/menu.ts +11 -2
- package/src/components/layout/shell/native/pointer-runtime.ts +25 -0
- package/src/components/layout/shell/native/window-state.ts +2 -2
- package/src/components/layout/shell/pane/capture.ts +4 -1
- package/src/components/layout/shell/pane/layers.tsx +71 -7
- package/src/components/layout/shell/terminal-pointer-runtime.ts +18 -9
- package/src/components/layout/shell/window-mode/index.ts +8 -10
- package/src/components/layout/status-bar.tsx +6 -1
- package/src/components/layout/window-edit/mode.ts +39 -7
- package/src/components/layout/window-edit/presentation.ts +1 -1
- package/src/components/onboarding/first-run-workspace.ts +44 -2
- package/src/components/onboarding/onboarding-frame.tsx +11 -2
- package/src/components/onboarding/onboarding-keyboard.ts +20 -0
- package/src/components/onboarding/onboarding-wizard.tsx +16 -11
- package/src/components/onboarding/portfolio-step/positions-panel.tsx +62 -1
- package/src/components/onboarding/use-onboarding-progress.ts +12 -4
- package/src/components/pane-settings-dialog/desktop.tsx +2 -2
- package/src/components/pane-settings-dialog/tui.tsx +2 -2
- package/src/components/pane-settings-dialog/value.ts +6 -0
- package/src/components/pane-settings-dialog.tsx +3 -3
- package/src/components/reader/detail-reader.tsx +4 -0
- package/src/components/ui/button.tsx +2 -0
- package/src/components/ui/choice-dialog.tsx +1 -0
- package/src/components/ui/data-table/index.tsx +4 -3
- package/src/components/ui/index.ts +1 -1
- package/src/components/ui/list-view.tsx +7 -12
- package/src/components/ui/loading.tsx +10 -3
- package/src/components/ui/menu.tsx +6 -2
- package/src/components/ui/page-stack-view.tsx +3 -0
- package/src/components/ui/pane-link-chip.tsx +269 -54
- package/src/components/ui/query-bar.tsx +2 -1
- package/src/components/ui/quote.ts +14 -1
- package/src/components/ui/tabs.tsx +97 -19
- package/src/core/state/app/layout-reducer.ts +7 -0
- package/src/core/state/app/layout.ts +44 -7
- package/src/core/state/app/state.ts +1 -1
- package/src/core/state/app/types.ts +22 -2
- package/src/data/config/layout.ts +5 -2
- package/src/docs/snapshot.json +54 -13
- package/src/i18n/es.ts +9 -8
- package/src/i18n/ja.ts +9 -8
- package/src/i18n/ko.ts +9 -8
- package/src/i18n/zh-cn.ts +9 -8
- package/src/i18n/zh-tw.ts +9 -8
- package/src/layout/pane-manager/floating-actions.ts +17 -0
- package/src/layout/pane-manager/floating-stack.ts +187 -0
- package/src/layout/pane-manager/floating.ts +4 -2
- package/src/layout/pane-manager/gridlock.ts +5 -1
- package/src/layout/pane-manager/index.ts +11 -0
- package/src/layout/pane-manager/layout-state.ts +10 -3
- package/src/market-data/depositary-pair.ts +5 -3
- package/src/market-data/futures-board.ts +46 -1
- package/src/market-data/futures-contract.ts +12 -3
- package/src/market-data/fx-interventions.ts +270 -0
- package/src/market-data/market/dated-previous-close.ts +94 -15
- package/src/market-data/market/status.ts +17 -1
- package/src/news/news-model.ts +44 -2
- package/src/plugins/builtin/alerts/cli.ts +4 -4
- package/src/plugins/builtin/alerts/format.ts +1 -2
- package/src/plugins/builtin/alerts/headless.ts +1 -2
- package/src/plugins/builtin/alerts/move-checks.ts +12 -6
- package/src/plugins/builtin/alerts/move.ts +30 -9
- package/src/plugins/builtin/alerts/pane.tsx +0 -2
- package/src/plugins/builtin/alerts/storage.ts +4 -2
- package/src/plugins/builtin/alerts/types.ts +12 -0
- package/src/plugins/builtin/analytics/risk-client.ts +10 -4
- package/src/plugins/builtin/analytics/risk-episodes.ts +5 -4
- package/src/plugins/builtin/analytics/risk-headless.ts +4 -2
- package/src/plugins/builtin/analytics/risk-sectors.ts +91 -0
- package/src/plugins/builtin/awards/index.tsx +1 -1
- package/src/plugins/builtin/buildout/index.tsx +1 -0
- package/src/plugins/builtin/catalysts/index.tsx +2 -2
- package/src/plugins/builtin/cds/headless.ts +4 -0
- package/src/plugins/builtin/changelog/index.tsx +292 -101
- package/src/plugins/builtin/changelog/versions.ts +293 -0
- package/src/plugins/builtin/chart-composer/headless.ts +2 -1
- package/src/plugins/builtin/chart-composer/index.tsx +1 -0
- package/src/plugins/builtin/chart-composer/intervention-events.ts +105 -0
- package/src/plugins/builtin/chart-composer/pane.tsx +21 -7
- package/src/plugins/builtin/chat/content/composer.tsx +5 -4
- package/src/plugins/builtin/chat/content/index.tsx +12 -2
- package/src/plugins/builtin/chat/content/layout-metrics.ts +3 -3
- package/src/plugins/builtin/chat/content/open-targets.ts +3 -3
- package/src/plugins/builtin/chat/layout.ts +5 -2
- package/src/plugins/builtin/chat/message/pane-chip.tsx +61 -40
- package/src/plugins/builtin/chat/message/render-state.ts +2 -5
- package/src/plugins/builtin/chat/message/terminal.tsx +13 -15
- package/src/plugins/builtin/chat/pane-links/previews.ts +51 -5
- package/src/plugins/builtin/chat/pane-links/share-card.ts +36 -0
- package/src/plugins/builtin/cloud/askg/attached-pane.tsx +10 -5
- package/src/plugins/builtin/cloud/askg/controller.ts +141 -5
- package/src/plugins/builtin/cloud/askg/executor.ts +113 -4
- package/src/plugins/builtin/cloud/askg/manifest.ts +28 -13
- package/src/plugins/builtin/cloud/askg/model.ts +14 -4
- package/src/plugins/builtin/cloud/askg/pane.tsx +70 -46
- package/src/plugins/builtin/cloud/askg/tool-display.ts +1 -0
- package/src/plugins/builtin/cloud/askg/turn-parts.tsx +70 -0
- package/src/plugins/builtin/cloud/terminal-relay/engine.ts +50 -130
- package/src/plugins/builtin/cloud/terminal-relay/policy.ts +327 -7
- package/src/plugins/builtin/cloud/terminal-relay/prompts.tsx +2 -1
- package/src/plugins/builtin/cloud/terminal-relay/redact.ts +52 -9
- package/src/plugins/builtin/commodities-energy/index.tsx +1 -3
- package/src/plugins/builtin/commodities-energy/view-state.ts +3 -0
- package/src/plugins/builtin/commodity-balances/index.tsx +1 -0
- package/src/plugins/builtin/company-attention/index.tsx +1 -1
- package/src/plugins/builtin/company-kpis/headless.ts +3 -1
- package/src/plugins/builtin/company-kpis/index.tsx +2 -2
- package/src/plugins/builtin/cot/headless.ts +14 -2
- package/src/plugins/builtin/cot/index.tsx +1 -1
- package/src/plugins/builtin/cpi/index.tsx +1 -1
- package/src/plugins/builtin/crypto-board/index.tsx +1 -0
- package/src/plugins/builtin/dividend-yield/index.tsx +1 -0
- package/src/plugins/builtin/doe/index.tsx +1 -1
- package/src/plugins/builtin/earnings/index.tsx +2 -2
- package/src/plugins/builtin/earnings-calls/headless.ts +5 -1
- package/src/plugins/builtin/earnings-calls/index.tsx +1 -0
- package/src/plugins/builtin/econ/calendar-model.ts +74 -1
- package/src/plugins/builtin/econ/fred-catalog.ts +3 -1
- package/src/plugins/builtin/econ/index.tsx +1 -0
- package/src/plugins/builtin/econ-statistics/index.tsx +1 -0
- package/src/plugins/builtin/econ-statistics/pane.tsx +6 -0
- package/src/plugins/builtin/estimate-revisions/index.tsx +1 -0
- package/src/plugins/builtin/executives/index.tsx +1 -0
- package/src/plugins/builtin/filing-events/index.tsx +1 -0
- package/src/plugins/builtin/fixed-income/index.tsx +1 -0
- package/src/plugins/builtin/futures/index.tsx +25 -4
- package/src/plugins/builtin/futures/model.ts +28 -32
- package/src/plugins/builtin/futures/series.ts +4 -3
- package/src/plugins/builtin/futures/table.tsx +16 -9
- package/src/plugins/builtin/futures/use-board-terms.ts +3 -3
- package/src/plugins/builtin/futures-curve/headless.ts +3 -3
- package/src/plugins/builtin/futures-curve/index.tsx +1 -1
- package/src/plugins/builtin/futures-curve/model.ts +18 -0
- package/src/plugins/builtin/gpu/index.tsx +1 -1
- package/src/plugins/builtin/help/functions-table.tsx +1 -1
- package/src/plugins/builtin/help/index.tsx +14 -4
- package/src/plugins/builtin/help/keybindings-editor.tsx +19 -5
- package/src/plugins/builtin/holders/index.tsx +1 -0
- package/src/plugins/builtin/holders/report-header.ts +2 -2
- package/src/plugins/builtin/insider/index.tsx +1 -0
- package/src/plugins/builtin/iv-history/index.tsx +1 -1
- package/src/plugins/builtin/jobs/index.tsx +1 -0
- package/src/plugins/builtin/layout-manager/index.tsx +8 -8
- package/src/plugins/builtin/macro-day/headless.ts +27 -8
- package/src/plugins/builtin/macro-day/index.tsx +1 -1
- package/src/plugins/builtin/macro-day/model.ts +19 -3
- package/src/plugins/builtin/macro-day/pane.tsx +14 -9
- package/src/plugins/builtin/macro-day/releases.ts +25 -7
- package/src/plugins/builtin/market-valuation/index.tsx +1 -0
- package/src/plugins/builtin/market-valuation/pane.tsx +8 -0
- package/src/plugins/builtin/members/index.tsx +1 -1
- package/src/plugins/builtin/mna/index.tsx +1 -0
- package/src/plugins/builtin/news/headless.ts +2 -2
- package/src/plugins/builtin/news/index.tsx +4 -3
- package/src/plugins/builtin/news/wire/index.tsx +5 -1
- package/src/plugins/builtin/news/wire/news/detail-view.tsx +4 -0
- package/src/plugins/builtin/news/wire/news/list-search.ts +5 -2
- package/src/plugins/builtin/options/index.tsx +1 -0
- package/src/plugins/builtin/options-positioning/index.tsx +1 -0
- package/src/plugins/builtin/pe-band/index.tsx +1 -1
- package/src/plugins/builtin/perps/markets-section.tsx +5 -2
- package/src/plugins/builtin/plugin-marketplace/pane.tsx +11 -11
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +25 -0
- package/src/plugins/builtin/portfolio-list/headless.ts +15 -6
- package/src/plugins/builtin/portfolio-list/summary/index.tsx +3 -1
- package/src/plugins/builtin/power/index.tsx +1 -1
- package/src/plugins/builtin/realized-vol/index.tsx +1 -1
- package/src/plugins/builtin/research/event-model.ts +9 -1
- package/src/plugins/builtin/research/event-sources.ts +22 -0
- package/src/plugins/builtin/research/headless.ts +11 -5
- package/src/plugins/builtin/research/index.tsx +4 -0
- package/src/plugins/builtin/research-search/index.tsx +1 -0
- package/src/plugins/builtin/research-search/pane.tsx +8 -0
- package/src/plugins/builtin/revenue-breakdown/index.tsx +1 -0
- package/src/plugins/builtin/reverse-dcf/index.tsx +1 -1
- package/src/plugins/builtin/risk-factors/index.tsx +1 -0
- package/src/plugins/builtin/scanner/headless.ts +52 -13
- package/src/plugins/builtin/seasonality/index.tsx +1 -1
- package/src/plugins/builtin/sec/index.tsx +1 -0
- package/src/plugins/builtin/series-inventory.ts +1 -1
- package/src/plugins/builtin/shared/cloud-upgrade.ts +27 -3
- package/src/plugins/builtin/shared/scanner-capture.ts +11 -3
- package/src/plugins/builtin/shared/series-list-detail.tsx +5 -0
- package/src/plugins/builtin/short-interest/index.tsx +1 -0
- package/src/plugins/builtin/social-mentions/index.tsx +1 -1
- package/src/plugins/builtin/supply-chain/index.tsx +1 -0
- package/src/plugins/builtin/thirteenf/data.ts +43 -10
- package/src/plugins/builtin/thirteenf/headless.ts +55 -11
- package/src/plugins/builtin/thirteenf/model.ts +25 -9
- package/src/plugins/builtin/thirteenf/report-notes.ts +27 -6
- package/src/plugins/builtin/thirteenf/types.ts +2 -0
- package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +1 -1
- package/src/plugins/builtin/ticker-detail/financials/model.ts +12 -0
- package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +3 -3
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +5 -5
- package/src/plugins/builtin/ticker-detail/headless.ts +18 -13
- package/src/plugins/builtin/ticker-detail/index.tsx +4 -0
- package/src/plugins/builtin/ticker-detail/overview/components.tsx +54 -5
- package/src/plugins/builtin/ticker-detail/overview/model.ts +6 -4
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +34 -17
- package/src/plugins/builtin/ticker-detail/pane.tsx +7 -2
- package/src/plugins/builtin/time-sales/client.ts +9 -11
- package/src/plugins/builtin/time-sales/index.tsx +1 -1
- package/src/plugins/builtin/treasury-auctions/after.ts +267 -0
- package/src/plugins/builtin/treasury-auctions/cache.ts +18 -3
- package/src/plugins/builtin/treasury-auctions/client.ts +33 -2
- package/src/plugins/builtin/treasury-auctions/headless.ts +109 -19
- package/src/plugins/builtin/treasury-auctions/index.tsx +14 -4
- package/src/plugins/builtin/treasury-auctions/model.ts +256 -28
- package/src/plugins/builtin/treasury-auctions/pane.tsx +139 -28
- package/src/plugins/builtin/treasury-auctions/treasury-direct.ts +5 -2
- package/src/plugins/builtin/treasury-auctions/types.ts +7 -1
- package/src/plugins/builtin/vol-surface/index.tsx +1 -1
- package/src/plugins/builtin/world-venue-map/index.ts +1 -0
- package/src/plugins/builtin/yield-curve/curves.ts +10 -4
- package/src/plugins/builtin/yield-curve/headless.ts +6 -2
- package/src/plugins/builtin/yield-curve/index.tsx +3 -3
- package/src/plugins/builtin/yield-curve/series.ts +10 -0
- package/src/plugins/builtin/yield-curve/world.ts +3 -1
- package/src/plugins/installer.ts +45 -0
- package/src/portfolio/column-values.ts +2 -1
- package/src/public/__snapshots__/public-api.test.ts.snap +4 -0
- package/src/public/remote.ts +7 -1
- package/src/remote/client.ts +191 -11
- package/src/remote/controller-utils.ts +13 -1
- package/src/remote/controller.ts +88 -26
- package/src/remote/endpoint.ts +24 -0
- package/src/remote/form.ts +59 -4
- package/src/remote/resources.ts +56 -19
- package/src/remote/schema.ts +22 -9
- package/src/remote/secrets.ts +12 -0
- package/src/remote/semantic-helpers.ts +29 -1
- package/src/remote/semantic-tree.tsx +44 -15
- package/src/remote/server.ts +2 -1
- package/src/remote/surface.tsx +192 -0
- package/src/remote/types.ts +5 -0
- package/src/renderers/cloudflare/worker.ts +16 -1
- package/src/renderers/dom/styles.css +40 -6
- package/src/renderers/opentui/host.tsx +6 -0
- package/src/renderers/share/layout-view.tsx +1 -1
- package/src/series/standalone.ts +2 -2
- package/src/shares/api.ts +21 -4
- package/src/shares/item.ts +73 -0
- package/src/shares/pane-item.ts +205 -0
- package/src/shares/pane.ts +4 -0
- package/src/shares/payload.ts +9 -5
- package/src/sources/gloomberb-cloud/news.ts +37 -12
- package/src/state/opening-ticker-panes.ts +47 -0
- package/src/test-support/cli-context.ts +2 -0
- package/src/test-support/preload.ts +4 -1
- package/src/tickers/instrument-kind.ts +23 -3
- package/src/tickers/renamed-listings.ts +105 -0
- package/src/tickers/search/index.ts +103 -16
- package/src/time-series/resolve.ts +2 -2
- package/src/types/config.ts +5 -0
- package/src/types/context-menu.ts +2 -0
- package/src/types/financials.ts +1 -0
- package/src/types/plugin-commands.ts +140 -0
- package/src/types/plugin-context.ts +125 -0
- package/src/types/plugin-contributions.ts +55 -0
- package/src/types/plugin-definition.ts +234 -0
- package/src/types/plugin-notifications.ts +38 -0
- package/src/types/plugin-pane-settings.ts +116 -0
- package/src/types/plugin-pane-templates.ts +160 -0
- package/src/types/plugin-panes.ts +243 -0
- package/src/types/plugin-reports.ts +35 -0
- package/src/types/plugin-shared.ts +14 -0
- package/src/types/plugin-state.ts +71 -0
- package/src/types/plugin.ts +14 -1169
- package/src/ui/index.tsx +14 -3
- package/src/updater/github-releases.ts +23 -0
- package/src/utils/central-banks.ts +86 -1
- package/src/utils/cli-output.ts +22 -9
- package/src/utils/datetime-format.ts +12 -3
- package/src/utils/depositary-receipt.ts +28 -3
- package/src/utils/fundamentals.ts +14 -0
- package/src/utils/max-drawdown.ts +97 -16
- package/src/utils/untrusted-text.ts +29 -0
|
@@ -129,7 +129,11 @@ import {
|
|
|
129
129
|
import { historyCoverageNotice } from "../../sources/history-coverage";
|
|
130
130
|
import { fetchHistoryResult } from "../../sources/history-result";
|
|
131
131
|
import { settleWithin } from "../../utils/async-deadline";
|
|
132
|
-
import {
|
|
132
|
+
import type { FxInterventionsPayload } from "../../api-client/fx-interventions";
|
|
133
|
+
import {
|
|
134
|
+
fxInterventionLatestNote, fxInterventionPair, fxInterventionWindowNote, loadFxInterventions, type FxInterventionPair,
|
|
135
|
+
} from "../../market-data/fx-interventions";
|
|
136
|
+
import { maxDrawdownText, maxRunUp, maxRunUpText } from "../../utils/max-drawdown";
|
|
133
137
|
import { isPastPriceWindow, loadPriceWindowHistory, PRICE_WINDOW_FROM_HELP, PRICE_WINDOW_TO_HELP, priceWindowText, readPriceWindow, type PriceWindow } from "../../utils/price-window";
|
|
134
138
|
import {
|
|
135
139
|
BAR_INTERVAL_LABELS,
|
|
@@ -185,11 +189,11 @@ import { CRYPTO_BOARD_HINT, quoteNotes } from "./crypto-hints";
|
|
|
185
189
|
import { bareFuturesCode, futuresBoardContract, futuresContractByWord } from "../../market-data/futures-board";
|
|
186
190
|
import { commodityNamedIn, commoditySearchName } from "../../market-data/commodity-names";
|
|
187
191
|
import { newsEmptyMessage } from "./news-hints";
|
|
192
|
+
import { centralBankInNews, centralBankShortNamed } from "../../utils/central-banks";
|
|
188
193
|
import {
|
|
189
194
|
closestStoriesReason,
|
|
190
195
|
commodityNewsRoute,
|
|
191
196
|
commonWordCandidate,
|
|
192
|
-
METALS_NEWS_TOPIC,
|
|
193
197
|
metalCodeNewsRoute,
|
|
194
198
|
type MetalNewsRoute,
|
|
195
199
|
metalNewsHeading,
|
|
@@ -198,7 +202,10 @@ import {
|
|
|
198
202
|
newsSearchHeading,
|
|
199
203
|
newsSearchText,
|
|
200
204
|
newsSearchTextProblem,
|
|
205
|
+
newestFirst,
|
|
201
206
|
noMetalStoriesMessage,
|
|
207
|
+
searchCentralBankStories,
|
|
208
|
+
centralBankNewsReason,
|
|
202
209
|
noStoriesMessage,
|
|
203
210
|
quotedSearchCommand,
|
|
204
211
|
searchClosestNewsStories,
|
|
@@ -307,8 +314,8 @@ import { answerQuote, errorMessage, notUsTickerSentence } from "../quote-answer"
|
|
|
307
314
|
import { crossRate, describeFxConversion, describeFxLegs, describeFxRate, formatFxRate, FX_USAGE, parseFxArgs, type FxQuotedFigure } from "../fx-pair";
|
|
308
315
|
import {
|
|
309
316
|
describeShortRate,
|
|
317
|
+
shortRateGrowthText,
|
|
310
318
|
formatForwardPoints,
|
|
311
|
-
formatRatePercent,
|
|
312
319
|
formatSignedPercent,
|
|
313
320
|
IMPLIED_FORWARD_LABEL,
|
|
314
321
|
impliedForward,
|
|
@@ -418,6 +425,16 @@ export function readHistoryRange(value: string): HistoryRange | null {
|
|
|
418
425
|
return VALID_RANGES.has(range) ? range : null;
|
|
419
426
|
}
|
|
420
427
|
|
|
428
|
+
/**
|
|
429
|
+
* The range a symbol's place holds, typed as a count and a unit (`1mo`, `3m`,
|
|
430
|
+
* `5 days`), or null. `history CC=F 1mo` loaded 1MO, a Milan listing, beside
|
|
431
|
+
* cocoa. A bare word stays a symbol: ALL and MAX are listings, and YTD only
|
|
432
|
+
* means a range after --range.
|
|
433
|
+
*/
|
|
434
|
+
function rangeTypedAsSymbol(entry: string): HistoryRange | null {
|
|
435
|
+
return /^\s*\d+\s*[a-z]+\s*$/i.test(entry) ? readHistoryRange(entry) : null;
|
|
436
|
+
}
|
|
437
|
+
|
|
421
438
|
function parseRange(value: string | undefined, ctx: Parameters<CliCommandDef["execute"]>[1]): HistoryRange {
|
|
422
439
|
const range = readHistoryRange(value ?? "1Y");
|
|
423
440
|
if (!range) ctx.fail(`Unknown range "${value}".`, `Use one of ${HISTORY_RANGES.join(", ")}.`);
|
|
@@ -1297,9 +1314,13 @@ function refusedLine(refused: ReadonlyArray<{ input: string }>): string {
|
|
|
1297
1314
|
return `Not ${refused.length === 1 ? "a symbol" : "symbols"}, not quoted: ${refusedList(refused)}.`;
|
|
1298
1315
|
}
|
|
1299
1316
|
|
|
1300
|
-
/**
|
|
1317
|
+
/**
|
|
1318
|
+
* A symbol of a list that names no listing: `Not quoted: EQT:NYSE:US (Unknown exchange US for EQT:NYSE).`, or
|
|
1319
|
+
* after it a reason of several sentences: `Not quoted: iron ore. Iron ore: no live price (...). ...`.
|
|
1320
|
+
*/
|
|
1301
1321
|
function unreadLine({ symbol, error }: { symbol: string; error: ListingArgError }): string {
|
|
1302
|
-
|
|
1322
|
+
const reason = error.message.replace(/\.$/, "");
|
|
1323
|
+
return reason.includes(". ") ? `Not quoted: ${symbol}. ${reason}.` : `Not quoted: ${symbol} (${reason}).`;
|
|
1303
1324
|
}
|
|
1304
1325
|
|
|
1305
1326
|
/**
|
|
@@ -1497,6 +1518,35 @@ function historyCommand({ range, window }: HistoryAsk): string {
|
|
|
1497
1518
|
|
|
1498
1519
|
/** How long `history` waits for a future's contract terms to name its unit before using the catalog's. */
|
|
1499
1520
|
const HISTORY_PRICE_UNIT_WAIT_MS = 1_500;
|
|
1521
|
+
/** How long a yen pair's answer waits for Japan's intervention record, read beside it; the note is left out after. */
|
|
1522
|
+
const INTERVENTION_NOTE_WAIT_MS = 3_000;
|
|
1523
|
+
|
|
1524
|
+
/** Japan's intervention record for a yen pair, read beside its rate or bars; null for any other pair, or none in time. */
|
|
1525
|
+
function loadInterventionsFor(pair: FxInterventionPair | null, market: MarketContext): Promise<FxInterventionsPayload | null> {
|
|
1526
|
+
return pair ? settleWithin((market.fxInterventions ?? (() => loadFxInterventions()))(), INTERVENTION_NOTE_WAIT_MS) : Promise.resolve(null);
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
/** The last day a bar's period covers: a weekly bar's Sunday, a monthly bar's month end, else its own day. */
|
|
1530
|
+
function barPeriodEnd(date: string, interval: string | null | undefined): string {
|
|
1531
|
+
const start = Date.parse(`${date}T00:00:00Z`);
|
|
1532
|
+
if (interval === "1wk") return new Date(start + 6 * 86_400_000).toISOString().slice(0, 10);
|
|
1533
|
+
if (interval !== "1mo") return date;
|
|
1534
|
+
const day = new Date(start);
|
|
1535
|
+
return new Date(Date.UTC(day.getUTCFullYear(), day.getUTCMonth() + 1, 0)).toISOString().slice(0, 10);
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
/** The interventions from the first bar shown to the end of the last one's period. */
|
|
1539
|
+
async function interventionWindowNote(
|
|
1540
|
+
record: Promise<FxInterventionsPayload | null>,
|
|
1541
|
+
pair: FxInterventionPair | null,
|
|
1542
|
+
rows: readonly { date: string; interval?: string | null }[],
|
|
1543
|
+
): Promise<string | null> {
|
|
1544
|
+
const first = rows[0]?.date.slice(0, 10), lastRow = rows.at(-1);
|
|
1545
|
+
const last = lastRow ? barPeriodEnd(lastRow.date.slice(0, 10), lastRow.interval) : undefined;
|
|
1546
|
+
if (!pair || !first || !last) return null;
|
|
1547
|
+
const payload = await record;
|
|
1548
|
+
return payload ? fxInterventionWindowNote(payload, pair, first, last) : null;
|
|
1549
|
+
}
|
|
1500
1550
|
|
|
1501
1551
|
/** How long `history` waits for the daily bars that rebuild contradictory monthly bars before printing them with blanks. */
|
|
1502
1552
|
const MONTHLY_REBUILD_WAIT_MS = 8_000;
|
|
@@ -1558,6 +1608,9 @@ async function loadListingHistory(
|
|
|
1558
1608
|
// A future's prices are in its contract's unit (US cents / bushel), as FUT and G spell it; asked beside the bars.
|
|
1559
1609
|
const priceUnit = isFuturesInstrument(symbol, null) ? settleWithin(loadFuturesPriceUnit(symbol), HISTORY_PRICE_UNIT_WAIT_MS) : Promise.resolve(null);
|
|
1560
1610
|
const quoted = quoteAnswer.then((answer) => answer.quote);
|
|
1611
|
+
// USDJPY=X's bars name Japan's interventions they span.
|
|
1612
|
+
const interventionPair = fxInterventionPair(symbol, exchange);
|
|
1613
|
+
const interventions = loadInterventionsFor(interventionPair, market);
|
|
1561
1614
|
const fate = lookups ? listingFateLoader(listing, market, quoted, { successor: true }) : null;
|
|
1562
1615
|
const request = { command: historyCommand(ask), noun: "history", ...(fate ? { fate } : {}) };
|
|
1563
1616
|
const [answered, quote] = await Promise.all([
|
|
@@ -1660,6 +1713,7 @@ async function loadListingHistory(
|
|
|
1660
1713
|
// NG=F's rows are November's to the 23rd and December's from the 26th: each roll named, and thin bars said.
|
|
1661
1714
|
historyRollNote(listing.symbol, data) ?? [], historyThinNote(data) ?? [],
|
|
1662
1715
|
historyBarStatusNote(forming ? served : data, { tradingDay: venueTradingDay(venue, Date.now()) }) ?? [],
|
|
1716
|
+
await interventionWindowNote(interventions, interventionPair, data) ?? [],
|
|
1663
1717
|
].flat();
|
|
1664
1718
|
return {
|
|
1665
1719
|
listing, identity, unit, data, resolution, interval, intraday, volume, freshness, notes,
|
|
@@ -1800,6 +1854,19 @@ async function runHistory(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
|
|
|
1800
1854
|
const currency = file != null || requestedExchange ? null : currencyNameStop(args, "history");
|
|
1801
1855
|
if (currency) ctx.fail(currency.message, currency.details);
|
|
1802
1856
|
if (wide || file != null || args.includes("-") || uniqueEntries(args).length > 1 || args.some((arg) => /[,;]/.test(arg))) {
|
|
1857
|
+
// `history CC=F 1mo` asks for a month of cocoa, not for cocoa and 1MO: it says which option reads it.
|
|
1858
|
+
const typedRange = rangeOption == null && !window ? args.find((arg) => rangeTypedAsSymbol(arg)) : undefined;
|
|
1859
|
+
if (typedRange) {
|
|
1860
|
+
// The command as typed with the range moved to --range: its other options (--wide, --exchange) and the output
|
|
1861
|
+
// flags read before the command (--csv, --limit) stay.
|
|
1862
|
+
const range = rangeTypedAsSymbol(typedRange)!;
|
|
1863
|
+
const at = rawArgs.indexOf(typedRange);
|
|
1864
|
+
const { format, limit, tail } = ctx.cliOptions;
|
|
1865
|
+
const words = [...rawArgs.filter((_arg, index) => index !== at), "--range", range,
|
|
1866
|
+
...format === "text" ? [] : [`--${format}`], ...limit == null ? [] : ["--limit", String(limit)], ...tail == null ? [] : ["--tail", String(tail)]];
|
|
1867
|
+
const shell = (arg: string) => /[\s"'$`\\!&|;<>()*?#~]/.test(arg) ? `"${arg.replace(/(["\\$`])/g, "\\$1")}"` : arg;
|
|
1868
|
+
ctx.fail(`"${typedRange}" reads as a range, not a symbol: give it as --range ${range}.`, `gloom history ${words.map(shell).join(" ")}`);
|
|
1869
|
+
}
|
|
1803
1870
|
if (backAdjust) ctx.fail("--back-adjust stitches one continuous future, such as ES=F.", `Usage: gloom ${HISTORY_USAGE}`);
|
|
1804
1871
|
return runHistoryList(args, file, requestedExchange, ask, ctx, { wide });
|
|
1805
1872
|
}
|
|
@@ -1824,8 +1891,13 @@ async function runHistory(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
|
|
|
1824
1891
|
: { ...column, format: historyVolumeCell(() => missingVolume) });
|
|
1825
1892
|
// The largest fall from a close to a later one in the bars shown, said under the heading: within one contract
|
|
1826
1893
|
// of a continuous future, never from one month's close to another's across a roll.
|
|
1827
|
-
|
|
1894
|
+
// A yield (^TNX) falls and rises by its level, in bp, and its largest rise is said too.
|
|
1895
|
+
const yieldUnits = isYieldIndexSymbol(history.listing.symbol);
|
|
1896
|
+
const contractDrawdown = historyContractDrawdown(data, yieldUnits ? "yield" : "return");
|
|
1828
1897
|
const drawdown = contractDrawdown?.drawdown ?? null;
|
|
1898
|
+
const runUp = yieldUnits ? maxRunUp(data) : null;
|
|
1899
|
+
const moveText = interval ? { basis: `${BAR_INTERVAL_LABELS[interval]} closes${contractDrawdown?.contract ? `, ${contractDrawdown.contract}` : ""}`, price,
|
|
1900
|
+
date: (text: string) => intraday ? formatUtcTime(text) : text.slice(0, 10) } : null;
|
|
1829
1901
|
ctx.printResult({
|
|
1830
1902
|
data,
|
|
1831
1903
|
metadata: {
|
|
@@ -1843,6 +1915,7 @@ async function runHistory(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
|
|
|
1843
1915
|
unbrokenFrom: historyUnbrokenFrom(data) ?? data[0]?.date ?? null,
|
|
1844
1916
|
bars: data.length,
|
|
1845
1917
|
maxDrawdown: drawdown && contractDrawdown?.contract ? { ...drawdown, contract: contractDrawdown.contract } : drawdown,
|
|
1918
|
+
...(runUp ? { maxRunUp: runUp } : {}),
|
|
1846
1919
|
asOf: freshness?.asOf ?? null,
|
|
1847
1920
|
...(volume ? { volumeUnit: volume.unit, volumePeriod: interval === "1d" ? "UTC day" : interval } : {}),
|
|
1848
1921
|
...(stitched ? { backAdjust: { method: backAdjust, rolls: stitched.rolls, ...(stitched.unstitched.length > 0 ? { unstitched: stitched.unstitched } : {}) } } : {}),
|
|
@@ -1851,9 +1924,8 @@ async function runHistory(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
|
|
|
1851
1924
|
freshness,
|
|
1852
1925
|
}, {
|
|
1853
1926
|
heading: [listingHeading(frontMonthIdentity(identity, history.listing.symbol, data)), cliStyles.muted(historyFacts(unit, data).join(" · ")),
|
|
1854
|
-
...drawdown &&
|
|
1855
|
-
|
|
1856
|
-
date: (text) => intraday ? formatUtcTime(text) : text.slice(0, 10) }))] : []].join("\n"),
|
|
1927
|
+
...drawdown && moveText ? [cliStyles.muted(maxDrawdownText(drawdown, moveText))] : [],
|
|
1928
|
+
...runUp && moveText ? [cliStyles.muted(maxRunUpText(runUp, moveText))] : []].join("\n"),
|
|
1857
1929
|
dateKey: "date",
|
|
1858
1930
|
textColumns: [...textColumns, HISTORY_FLAG_TEXT_COLUMN],
|
|
1859
1931
|
// One header whatever the market is doing, for one symbol as for a list (historyExportColumns).
|
|
@@ -2441,7 +2513,7 @@ const newsRowNote = (row: Record<string, unknown>) => typeof row.summary === "st
|
|
|
2441
2513
|
async function printNewsSearch(
|
|
2442
2514
|
text: string,
|
|
2443
2515
|
articles: NewsArticle[],
|
|
2444
|
-
{ reason, empty, commodity = true, failure, ticker = null, closest = false }: {
|
|
2516
|
+
{ reason, empty, commodity = true, failure, ticker = null, closest = false, listing }: {
|
|
2445
2517
|
reason?: string;
|
|
2446
2518
|
empty?: string;
|
|
2447
2519
|
commodity?: boolean;
|
|
@@ -2450,6 +2522,8 @@ async function printNewsSearch(
|
|
|
2450
2522
|
ticker?: string | null;
|
|
2451
2523
|
/** No story has every word: these are the ones with the most. */
|
|
2452
2524
|
closest?: boolean;
|
|
2525
|
+
/** The listing the typed word also names, and how to read its news: a bank's short name ahead of a listing abroad. */
|
|
2526
|
+
listing?: { key: string; note: string };
|
|
2453
2527
|
},
|
|
2454
2528
|
ctx: Parameters<CliCommandDef["execute"]>[1],
|
|
2455
2529
|
) {
|
|
@@ -2460,7 +2534,8 @@ async function printNewsSearch(
|
|
|
2460
2534
|
ctx.printResult({
|
|
2461
2535
|
data: articles,
|
|
2462
2536
|
...(searched ? {} : { warnings: [`Searching stories for "${text}" failed: ${failure}`] }),
|
|
2463
|
-
metadata: { ticker, search: text, feed: null, ...(closestReason ? { match: "closest" } : {}), ...(route ? { futuresNews: route.command } : {})
|
|
2537
|
+
metadata: { ticker, search: text, feed: null, ...(closestReason ? { match: "closest" } : {}), ...(route ? { futuresNews: route.command } : {}),
|
|
2538
|
+
...(listing ? { listing: listing.key } : {}) },
|
|
2464
2539
|
freshness: rowsFreshness(newsRows(articles), cloudNewsFreshness(await cloudRealtimeAccess())),
|
|
2465
2540
|
}, {
|
|
2466
2541
|
heading: newsSearchHeading(text, [reason, closestReason].filter(Boolean).join(" · ") || undefined),
|
|
@@ -2468,6 +2543,7 @@ async function printNewsSearch(
|
|
|
2468
2543
|
columns: NEWS_COLUMNS,
|
|
2469
2544
|
rowNote: newsRowNote,
|
|
2470
2545
|
empty: named ? noStoriesMessage(text, route) : empty ?? (searched ? noStoriesMessage(text, null) : "No stories to show."),
|
|
2546
|
+
...(listing ? { footnote: listing.note } : {}),
|
|
2471
2547
|
});
|
|
2472
2548
|
}
|
|
2473
2549
|
|
|
@@ -2490,8 +2566,8 @@ async function tickerOfWord(word: string, market: MarketContext): Promise<{ symb
|
|
|
2490
2566
|
* name is in capitals, whose company news `news GOLD` keeps.
|
|
2491
2567
|
*/
|
|
2492
2568
|
async function printMetalNews(route: MetalNewsRoute, limit: number, ctx: Parameters<CliCommandDef["execute"]>[1], market?: MarketContext) {
|
|
2493
|
-
const search = searchNewsStories(route.metal, limit, [
|
|
2494
|
-
logFailure("cli.commands-market",
|
|
2569
|
+
const search = searchNewsStories(route.metal, limit, [route.topic]).then((found) => ({ found, failure: undefined }), (error: unknown) => {
|
|
2570
|
+
logFailure("cli.commands-market", `Search ${route.topic} news failed`)(error);
|
|
2495
2571
|
return { found: [] as NewsArticle[], failure: errorMessage(error) ?? "no answer" };
|
|
2496
2572
|
});
|
|
2497
2573
|
const word = route.word;
|
|
@@ -2503,8 +2579,8 @@ async function printMetalNews(route: MetalNewsRoute, limit: number, ctx: Paramet
|
|
|
2503
2579
|
const companyNews = ticker ? `gloom news ${ticker.symbol}` : null;
|
|
2504
2580
|
ctx.printResult({
|
|
2505
2581
|
data: found,
|
|
2506
|
-
...(failure === undefined ? {} : { warnings: [`Searching
|
|
2507
|
-
metadata: { ticker: null, search: route.metal, topics: [
|
|
2582
|
+
...(failure === undefined ? {} : { warnings: [`Searching ${route.label.toLowerCase()} stories for "${route.metal}" failed: ${failure}`] }),
|
|
2583
|
+
metadata: { ticker: null, search: route.metal, topics: [route.topic], feed: null, ...(companyNews ? { companyNews } : {}) },
|
|
2508
2584
|
freshness: rowsFreshness(newsRows(found), cloudNewsFreshness(await cloudRealtimeAccess())),
|
|
2509
2585
|
}, {
|
|
2510
2586
|
heading: metalNewsHeading(route),
|
|
@@ -2527,6 +2603,12 @@ async function runNews(rawArgs: string[], ctx: Parameters<CliCommandDef["execute
|
|
|
2527
2603
|
if (exchangeOption || feed) ctx.fail(`${exchangeOption ? "--exchange" : "--feed"} goes with a symbol, not with text to search stories for.`, "Usage: gloom news <query>");
|
|
2528
2604
|
const problem = newsSearchTextProblem(text);
|
|
2529
2605
|
if (problem) ctx.fail(problem);
|
|
2606
|
+
// "copom selic", "Bank of Mexico": the bank's latest decision stories, under every name it is reported by.
|
|
2607
|
+
const bank = centralBankInNews(text);
|
|
2608
|
+
if (bank) {
|
|
2609
|
+
await printNewsSearch(text, await searchCentralBankStories(bank, limit, text), { reason: centralBankNewsReason(bank), commodity: false }, ctx);
|
|
2610
|
+
return;
|
|
2611
|
+
}
|
|
2530
2612
|
const answer = await searchClosestNewsStories(text, limit);
|
|
2531
2613
|
await printNewsSearch(text, answer.found, { closest: answer.closest }, ctx);
|
|
2532
2614
|
return;
|
|
@@ -2541,6 +2623,28 @@ async function runNews(rawArgs: string[], ctx: Parameters<CliCommandDef["execute
|
|
|
2541
2623
|
await withMarketData(ctx, async (market) => {
|
|
2542
2624
|
const listing = args[0] ? await requireCliListing(args[0], exchangeOption, market, ctx) : null;
|
|
2543
2625
|
const quoteLoad = listing ? loadListingQuote(market.dataProvider, listing) : Promise.resolve(null);
|
|
2626
|
+
// A bank's short name typed on its own (ECB, FED, RBI) is the bank's stories ahead of a listing outside the US
|
|
2627
|
+
// that trades under it (ECB S.A. on the WSE, "No news" on 7 Nov 2026), which its venue still reaches (ECB:WSE).
|
|
2628
|
+
// A US listing (RBA, RB Global) keeps the name.
|
|
2629
|
+
const shortBank = listing && !listing.exchange && !feed && args.length === 1 ? centralBankShortNamed(args[0]!) : null;
|
|
2630
|
+
if (shortBank) {
|
|
2631
|
+
const quote = await quoteLoad;
|
|
2632
|
+
const identity = listingIdentity(listing!, quote);
|
|
2633
|
+
if (!isUsListingExchange(identity.exchange)) {
|
|
2634
|
+
const resolved = quote !== null || identity.name != null;
|
|
2635
|
+
const key = identity.exchange ? `${listing!.symbol}:${identity.exchange}` : null;
|
|
2636
|
+
const typed = args[0]!.trim();
|
|
2637
|
+
const stories = await searchCentralBankStories(shortBank, limit, typed).then((found) => ({ found, failure: undefined }), (error: unknown) => {
|
|
2638
|
+
logFailure("cli.commands-market", "Search a central bank's stories failed")(error);
|
|
2639
|
+
return { found: [], failure: errorMessage(error) ?? "no answer" };
|
|
2640
|
+
});
|
|
2641
|
+
await printNewsSearch(typed, stories.found, {
|
|
2642
|
+
reason: centralBankNewsReason(shortBank), commodity: false, failure: stories.failure,
|
|
2643
|
+
...(resolved && key ? { listing: { key, note: `${typed} is also ${identity.name ?? listing!.symbol} (${identity.exchange}): gloom news ${key}` } } : {}),
|
|
2644
|
+
}, ctx);
|
|
2645
|
+
return;
|
|
2646
|
+
}
|
|
2647
|
+
}
|
|
2544
2648
|
// A coin pair's feed searches for the coin when no story is filed under the pair, by the name its quote gives.
|
|
2545
2649
|
const coin = !!listing && !feed && isRoundTheClockCoin(listing.request.symbol, listing.request.exchange);
|
|
2546
2650
|
const loadNews = async () => market.dataProvider.getNews({
|
|
@@ -2557,6 +2661,14 @@ async function runNews(rawArgs: string[], ctx: Parameters<CliCommandDef["execute
|
|
|
2557
2661
|
quoteLoad,
|
|
2558
2662
|
]);
|
|
2559
2663
|
const searchedFor = listing ? articles[0]?.searchedFor : undefined;
|
|
2664
|
+
// A future's feed already searched its commodity's stories when none are filed under it (the pane reads the same
|
|
2665
|
+
// way): they print as they did when this command searched them, newest first under "the commodity KC=F trades".
|
|
2666
|
+
const searchedFuture = listing && searchedFor && !listing.exchange && !feed && isFuturesInstrument(listing.symbol, quote?.instrumentType)
|
|
2667
|
+
? futuresBoardContract(listing.symbol) ?? bareFuturesCode(args[0]) : null;
|
|
2668
|
+
if (searchedFuture && commoditySearchName(searchedFuture) === searchedFor) {
|
|
2669
|
+
await printNewsSearch(searchedFor, newestFirst(articles), { reason: `the commodity ${searchedFuture.symbol} trades`, commodity: false }, ctx);
|
|
2670
|
+
return;
|
|
2671
|
+
}
|
|
2560
2672
|
if (listing && searchedFor) {
|
|
2561
2673
|
await printNewsSearch(searchedFor, articles, { reason: `no stories filed under ${listing.symbol}`, ticker: listing.key }, ctx);
|
|
2562
2674
|
return;
|
|
@@ -2589,13 +2701,16 @@ async function runNews(rawArgs: string[], ctx: Parameters<CliCommandDef["execute
|
|
|
2589
2701
|
return;
|
|
2590
2702
|
}
|
|
2591
2703
|
if (word && reason) {
|
|
2704
|
+
// A central bank's name no ticker answers to ("banxico") is its decision stories, under every name it goes by.
|
|
2705
|
+
const bank = !resolved && !commodity ? centralBankInNews(word) : null;
|
|
2592
2706
|
// The lookup that found no ticker already answered; a search that fails leaves that answer.
|
|
2593
|
-
const search = await searchNewsStories(word, limit).then((found) => ({ found, failure: undefined }), (error: unknown) => {
|
|
2707
|
+
const search = await (bank ? searchCentralBankStories(bank, limit, word) : searchNewsStories(word, limit)).then((found) => ({ found, failure: undefined }), (error: unknown) => {
|
|
2594
2708
|
logFailure("cli.commands-market", "Search news stories failed")(error);
|
|
2595
2709
|
return { found: [], failure: errorMessage(error) ?? "no answer" };
|
|
2596
2710
|
});
|
|
2597
2711
|
const searched = search.failure === undefined;
|
|
2598
|
-
await printNewsSearch(word, search.found, { reason
|
|
2712
|
+
await printNewsSearch(word, search.found, { reason: bank ? `${reason}; ${centralBankNewsReason(bank)}` : reason,
|
|
2713
|
+
empty: emptyMessage(searched && !commodity), commodity: !commodity, failure: search.failure }, ctx);
|
|
2599
2714
|
return;
|
|
2600
2715
|
}
|
|
2601
2716
|
const empty = emptyMessage(false);
|
|
@@ -3567,7 +3682,14 @@ async function runFxOnDate(
|
|
|
3567
3682
|
async function runFx(rawArgs: string[], ctx: Parameters<CliCommandDef["execute"]>[1]) {
|
|
3568
3683
|
const args = [...rawArgs];
|
|
3569
3684
|
const dateOption = takeOption(args, "--date");
|
|
3685
|
+
const forwardAsked = args.some((arg) => arg === "--forward" || arg.startsWith("--forward="));
|
|
3570
3686
|
const forwardOption = takeOption(args, "--forward");
|
|
3687
|
+
// `fx USD/BRL --forward` and `fx --forward USD/BRL` name no tenor: say what --forward takes, never print spot alone
|
|
3688
|
+
// or the bare usage line.
|
|
3689
|
+
if (forwardAsked && (!forwardOption?.trim() || (args.length === 0 && !/^\s*\d/.test(forwardOption)))) {
|
|
3690
|
+
const pair = args.length ? args.join(" ") : forwardOption?.trim() || "<base>/<quote>";
|
|
3691
|
+
ctx.fail("--forward takes a tenor: 30d, 2w, 3m, up to 1y.", `For the 3-month forward: gloom fx ${pair} --forward 3m`);
|
|
3692
|
+
}
|
|
3571
3693
|
if (args.length === 0) ctx.fail(`Usage: gloom ${FX_USAGE}`);
|
|
3572
3694
|
// A forward is implied from today's spot and the latest short rates, which are all Gloom Cloud serves.
|
|
3573
3695
|
if (dateOption != null && forwardOption != null) {
|
|
@@ -3596,6 +3718,10 @@ async function runFx(rawArgs: string[], ctx: Parameters<CliCommandDef["execute"]
|
|
|
3596
3718
|
(payload) => ({ payload }),
|
|
3597
3719
|
(error: unknown) => ({ error: unavailableOnServer(error, "Forwards are not available from Gloom Cloud yet: it serves no short rates.") }),
|
|
3598
3720
|
) : null;
|
|
3721
|
+
// A yen pair's rate names Japan's latest intervention in it; a conversion is about the amount, not the pair.
|
|
3722
|
+
const interventionPair = amount == null && !tenor && currency !== baseCurrency && (currency === "JPY" || baseCurrency === "JPY")
|
|
3723
|
+
? { base: currency, quote: baseCurrency } : null;
|
|
3724
|
+
const interventions = loadInterventionsFor(interventionPair, market);
|
|
3599
3725
|
// The pair's own quote, as `quote` and the FX board read it; a pair with none is crossed through the dollar.
|
|
3600
3726
|
const now = Date.now();
|
|
3601
3727
|
const read = await readFxQuoteRate(currency, baseCurrency, (targets, options) => market.dataProvider.getQuotesBatch(targets, options),
|
|
@@ -3649,7 +3775,8 @@ async function runFx(rawArgs: string[], ctx: Parameters<CliCommandDef["execute"]
|
|
|
3649
3775
|
const forwardDate = new Date(Math.floor(Date.now() / 86_400_000) * 86_400_000 + tenor.days * 86_400_000).toISOString().slice(0, 10);
|
|
3650
3776
|
const rateFields = (short: typeof base.rate) => ({
|
|
3651
3777
|
currency: short.currency, name: short.name, tenor: short.tenor, value: short.value, asOf: short.asOf,
|
|
3652
|
-
dayCountBasis: short.dayCountBasis,
|
|
3778
|
+
dayCountBasis: short.dayCountBasis, ...(short.compounding ? { compounding: short.compounding } : {}),
|
|
3779
|
+
publisher: short.publisher, sourceUrl: short.sourceUrl, stale: short.stale,
|
|
3653
3780
|
...(short.attribution ? { attribution: short.attribution } : {}),
|
|
3654
3781
|
});
|
|
3655
3782
|
// A publisher's licence asks for its attribution wherever its rate is shown (MAS's SORA).
|
|
@@ -3662,7 +3789,8 @@ async function runFx(rawArgs: string[], ctx: Parameters<CliCommandDef["execute"]
|
|
|
3662
3789
|
points: implied.points, pointSize: implied.pointSize, premiumPercent: implied.premiumPercent, annualizedPercent: implied.annualizedPercent,
|
|
3663
3790
|
baseRate: rateFields(base.rate), quoteRate: rateFields(quote.rate), method: "covered interest parity", label: IMPLIED_FORWARD_LABEL,
|
|
3664
3791
|
};
|
|
3665
|
-
const growth = (short: typeof base.rate) =>
|
|
3792
|
+
const growth = (short: typeof base.rate) => shortRateGrowthText(short, tenor.days);
|
|
3793
|
+
const compounded = [base.rate, quote.rate].filter((short) => short.compounding === "business-252").map((short) => short.name);
|
|
3666
3794
|
// A currency typed as its name (yen) says which code it was read as, as the spot answer does.
|
|
3667
3795
|
const forwardWarnings = [...request.readAs ?? [], ...rateNotes, ...staleRates];
|
|
3668
3796
|
return ctx.printResult({ data: [forwardRow], freshness, ...(forwardWarnings.length > 0 ? { warnings: forwardWarnings } : {}) }, {
|
|
@@ -3671,7 +3799,9 @@ async function runFx(rawArgs: string[], ctx: Parameters<CliCommandDef["execute"]
|
|
|
3671
3799
|
`Spot ${formatFxRate(rate)} · forward points ${formatForwardPoints(implied.points)} (pips of ${implied.pointSize}) · ${implied.premiumPercent >= 0 ? "premium" : "discount"} ${formatSignedPercent(implied.premiumPercent)} over ${tenor.days} days to ${forwardDate}, ${formatSignedPercent(implied.annualizedPercent, 2)} a year (×360/${tenor.days})`,
|
|
3672
3800
|
`${currency} rate: ${describeShortRate(base.rate)}`,
|
|
3673
3801
|
`${baseCurrency} rate: ${describeShortRate(quote.rate)}`,
|
|
3674
|
-
`Covered interest parity: ${formatFxRate(rate)} × ${growth(quote.rate)} / ${growth(base.rate)};
|
|
3802
|
+
`Covered interest parity: ${formatFxRate(rate)} × ${growth(quote.rate)} / ${growth(base.rate)}; ${compounded.length > 0
|
|
3803
|
+
? `${compounded.join(" and ")} compounds over business days (252 a year, taken as 252/365 of the ${tenor.days} days), the other rate earns simple interest`
|
|
3804
|
+
: `each rate earns simple interest over the ${tenor.days} days`}, standing in for a ${tenor.label} term rate.`,
|
|
3675
3805
|
...attributions,
|
|
3676
3806
|
].join("\n"),
|
|
3677
3807
|
exportIdentity: { symbolOrSeries: pair, currencyOrUnit: `${baseCurrency} per ${currency}`, interval: `forward ${tenor.label}` },
|
|
@@ -3697,6 +3827,9 @@ async function runFx(rawArgs: string[], ctx: Parameters<CliCommandDef["execute"]
|
|
|
3697
3827
|
: [],
|
|
3698
3828
|
...rateNotes,
|
|
3699
3829
|
];
|
|
3830
|
+
const record = await interventions;
|
|
3831
|
+
const interventionNote = record && interventionPair ? fxInterventionLatestNote(record, interventionPair) : null;
|
|
3832
|
+
if (interventionNote) warnings.push(interventionNote);
|
|
3700
3833
|
// The peso's dollar rate is the official one; the market rates Buenos Aires prices imply follow it, each with its inputs.
|
|
3701
3834
|
const peso = isPesoDollarPair(currency, baseCurrency)
|
|
3702
3835
|
? await loadPesoDollarRates((targets) => market.dataProvider.getQuotesBatch(targets, { forceRefresh: ctx.cliOptions.refresh }))
|
|
@@ -3859,7 +3992,7 @@ export const marketDataCliCommands: BuiltinCliCommandDef[] = [
|
|
|
3859
3992
|
`Each range comes in one bar size: ${historyIntervalsByRange()}. The line under the heading, and the --json metadata, give the currency, the bar size actually served, the first and last bar and the bar count. A warning says when the bars are coarser, or start later, than the range asked for, and for a coin, which trades every day, names each day it has no bar for.`,
|
|
3860
3993
|
"A bar whose prices contradict each other (high below the open or close, or low above them) is left blank and flagged, such as high<open, with the count in a warning. A low under half the open and close, or a high over twice them, is left blank alone and flagged low<close/2 or high>2*open. --json rows carry currency, unit, interval and flag.",
|
|
3861
3994
|
"A break in the series flags the bar after it, which keeps its prices: gap after more than three months with no bar (weeks for weekly, daily and intraday bars), jump when the close is over 100 times the one before or under a hundredth of it. A warning names each break, and the heading says the date the series runs unbroken from.",
|
|
3862
|
-
"The heading's last line is the max drawdown of the bars shown: the largest fall from a close to a later close, with the peak and the trough, their dates, and the date a close got back to the peak, if one did (maxDrawdown in --json).",
|
|
3995
|
+
"The heading's last line is the max drawdown of the bars shown: the largest fall from a close to a later close, with the peak and the trough, their dates, and the date a close got back to the peak, if one did (maxDrawdown in --json). A yield (^TNX) reads it in bp, with its max run-up beside it: the largest rise from a close to a later close, found on its own (maxRunUp).",
|
|
3863
3996
|
],
|
|
3864
3997
|
}, {
|
|
3865
3998
|
title: "CSV",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { apiClient } from "../../api-client";
|
|
2
2
|
import type { NewsArticle } from "../../news/types";
|
|
3
|
-
import { mapCloudNewsArticle } from "../../sources/gloomberb-cloud/news";
|
|
3
|
+
import { ENERGY_NEWS_TOPIC, mapCloudNewsArticle, METALS_NEWS_TOPIC } from "../../sources/gloomberb-cloud/news";
|
|
4
|
+
import { centralBankNewsQueries, centralBankNewsTopic, storyNamesCentralBank, type CentralBank } from "../../utils/central-banks";
|
|
4
5
|
import { cliStyles } from "../../utils/cli-output";
|
|
5
6
|
import { logFailure } from "../../utils/log-failure";
|
|
6
7
|
import { commodityNamedIn, commoditySearchName, isCommodityName } from "../../market-data/commodity-names";
|
|
@@ -77,7 +78,7 @@ export function newsFallbackText(symbol: string): string | null {
|
|
|
77
78
|
* the list is then read by date, which its help promises. A story with no
|
|
78
79
|
* date goes last; equal dates keep the service's order.
|
|
79
80
|
*/
|
|
80
|
-
function newestFirst(articles: readonly NewsArticle[]): NewsArticle[] {
|
|
81
|
+
export function newestFirst(articles: readonly NewsArticle[]): NewsArticle[] {
|
|
81
82
|
const time = (article: NewsArticle) => {
|
|
82
83
|
const at = new Date(article.publishedAt as Date | string | number).getTime();
|
|
83
84
|
return Number.isFinite(at) ? at : -Infinity;
|
|
@@ -123,20 +124,30 @@ export function closestStoriesReason(text: string): string {
|
|
|
123
124
|
return `no story has every word of "${text}"; the closest, most words first`;
|
|
124
125
|
}
|
|
125
126
|
|
|
126
|
-
/** The NI code of the metal markets: prices, futures, bullion and the trusts that hold it, not a miner's releases. */
|
|
127
|
-
export const METALS_NEWS_TOPIC = "metals";
|
|
128
127
|
|
|
129
128
|
/** A metal's market news, for what `news` was given: its name, its future, or its board code. */
|
|
130
129
|
export interface MetalNewsRoute {
|
|
131
|
-
/** The metal the stories are searched for, in METALS: "gold". */
|
|
130
|
+
/** The metal the stories are searched for, in METALS: "gold"; for oil, in ENERGY. */
|
|
132
131
|
metal: string;
|
|
133
132
|
contract: FuturesContract;
|
|
134
133
|
/** Why what was typed reads as the metal, under the heading; null for the metal's own name. */
|
|
135
134
|
reason: string | null;
|
|
136
135
|
/** The name as typed, which in capitals may be a ticker too ("gold", GOLD for Gold.com Inc.). */
|
|
137
136
|
word: string | null;
|
|
137
|
+
/** The market's stories the search is kept to: METALS, or ENERGY for oil. */
|
|
138
|
+
topic: string;
|
|
139
|
+
/** What the heading calls those stories: "Metals", "Energy". */
|
|
140
|
+
label: string;
|
|
138
141
|
}
|
|
139
142
|
|
|
143
|
+
/**
|
|
144
|
+
* The words that are the oil market, searched in its energy stories as a
|
|
145
|
+
* metal's name is in METALS: "oil" otherwise found Oil India's stories under
|
|
146
|
+
* the iPath ETN that trades as OIL, and stories that name oil are mostly
|
|
147
|
+
* companies'. Brent, gas and the rest keep their futures route.
|
|
148
|
+
*/
|
|
149
|
+
const ENERGY_MARKET_WORDS: ReadonlySet<string> = new Set(["oil", "crude"]);
|
|
150
|
+
|
|
140
151
|
/**
|
|
141
152
|
* A metal's market news for a metal's future (GC=F, SI=F, HG=F, PL=F, PA=F,
|
|
142
153
|
* ALI=F) or its name typed as a word (gold, Silver, copper): news filed under
|
|
@@ -150,30 +161,69 @@ export function metalNewsRoute(typed: string): MetalNewsRoute | null {
|
|
|
150
161
|
if (/=F$/i.test(text)) {
|
|
151
162
|
const contract = futuresBoardContract(text);
|
|
152
163
|
const metal = contract?.sector === "metals" ? commoditySearchName(contract) : null;
|
|
153
|
-
return contract && metal ? { metal, contract, reason: `the commodity ${contract.symbol} trades`, word: null } : null;
|
|
164
|
+
return contract && metal ? { metal, contract, reason: `the commodity ${contract.symbol} trades`, word: null, ...METALS_MARKET } : null;
|
|
154
165
|
}
|
|
155
166
|
if (!/^\p{L}{3,}$/u.test(text) || !/\p{Ll}/u.test(text)) return null;
|
|
156
167
|
// One word of letters: the metal's names are one word each (gold, aluminium).
|
|
157
168
|
const contract = commodityNamedIn(text);
|
|
158
|
-
|
|
169
|
+
if (contract?.sector === "metals") return { metal: text.toLowerCase(), contract, reason: null, word: text, ...METALS_MARKET };
|
|
170
|
+
return contract?.sector === "energy" && ENERGY_MARKET_WORDS.has(text.toLowerCase())
|
|
171
|
+
? { metal: text.toLowerCase(), contract, reason: null, word: text, ...ENERGY_MARKET } : null;
|
|
159
172
|
}
|
|
160
173
|
|
|
174
|
+
const METALS_MARKET = { topic: METALS_NEWS_TOPIC, label: "Metals" } as const;
|
|
175
|
+
const ENERGY_MARKET = { topic: ENERGY_NEWS_TOPIC, label: "Energy" } as const;
|
|
176
|
+
|
|
161
177
|
/** A metal's market news for its board code typed bare (GC, SI, HG) where no listing answers to it. */
|
|
162
178
|
export function metalCodeNewsRoute(typed: string): MetalNewsRoute | null {
|
|
163
179
|
const code = typed.trim().toUpperCase();
|
|
164
180
|
const contract = /^[A-Z]{2,3}$/.test(code) ? futuresBoardContract(code) : null;
|
|
165
181
|
const metal = contract?.sector === "metals" ? commoditySearchName(contract) : null;
|
|
166
|
-
return contract && metal ? { metal, contract, reason: `${code} is the futures board's code for ${contract.name}`, word: null } : null;
|
|
182
|
+
return contract && metal ? { metal, contract, reason: `${code} is the futures board's code for ${contract.name}`, word: null, ...METALS_MARKET } : null;
|
|
167
183
|
}
|
|
168
184
|
|
|
169
185
|
/** The line above a metal's market news: "Metals news matching "gold"", with why what was typed reads as the metal. */
|
|
170
186
|
export function metalNewsHeading(route: MetalNewsRoute): string {
|
|
171
|
-
return `${cliStyles.bold(
|
|
187
|
+
return `${cliStyles.bold(`${route.label} news matching "${route.metal}"`)}${route.reason ? cliStyles.muted(` · ${route.reason}`) : ""}`;
|
|
172
188
|
}
|
|
173
189
|
|
|
174
190
|
/** What a metal's market news says when no story is tagged METALS: every story that names it is one search away. */
|
|
175
191
|
export function noMetalStoriesMessage(route: MetalNewsRoute): string {
|
|
176
|
-
return `No
|
|
192
|
+
return `No ${route.label.toLowerCase()} stories match "${route.metal}". For every story that mentions it, try: ${quotedSearchCommand(route.metal)}`;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* A central bank's latest decision stories, for its name or the committee and
|
|
197
|
+
* rate its decisions go by (`centralBankInNews`): the text as typed and every
|
|
198
|
+
* name it is reported under (`centralBankNewsQueries`), each with what else
|
|
199
|
+
* the text asks (`centralBankNewsTopic`: "rate cut" of "fed rate cut"),
|
|
200
|
+
* searched at once, newest first, and only the stories that name the bank.
|
|
201
|
+
* "banxico" alone found May's cut, not November's, reported as the Bank of
|
|
202
|
+
* Mexico's. Fails only when every search failed.
|
|
203
|
+
*/
|
|
204
|
+
export async function searchCentralBankStories(bank: CentralBank, limit: number, typed = ""): Promise<NewsArticle[]> {
|
|
205
|
+
const topic = centralBankNewsTopic(bank, typed);
|
|
206
|
+
const queries = new Map<string, string>();
|
|
207
|
+
for (const query of [typed.trim(), ...centralBankNewsQueries(bank).map((name) => topic ? `${name} ${topic}` : name)]) {
|
|
208
|
+
if (query && !queries.has(query.toLowerCase())) queries.set(query.toLowerCase(), query);
|
|
209
|
+
}
|
|
210
|
+
const answers = await Promise.allSettled([...queries.values()].map((query) => searchNewsStories(query, limit)));
|
|
211
|
+
const found = answers.flatMap((answer) => answer.status === "fulfilled" ? answer.value : []);
|
|
212
|
+
const failed = answers.find((answer): answer is PromiseRejectedResult => answer.status === "rejected");
|
|
213
|
+
if (failed && answers.every((answer) => answer.status === "rejected")) throw failed.reason;
|
|
214
|
+
const seen = new Set<string>();
|
|
215
|
+
const unique = found.filter((article) => {
|
|
216
|
+
const key = article.id || article.url;
|
|
217
|
+
if (seen.has(key) || !storyNamesCentralBank(bank, `${article.title} ${article.summary ?? ""}`)) return false;
|
|
218
|
+
seen.add(key);
|
|
219
|
+
return true;
|
|
220
|
+
});
|
|
221
|
+
return newestFirst(unique).slice(0, limit);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** What the heading says of a central bank's stories: "the Bank of Mexico's stories, under each name it is reported by". */
|
|
225
|
+
export function centralBankNewsReason(bank: CentralBank): string {
|
|
226
|
+
return `the ${bank.name}'s stories, under each name it is reported by`;
|
|
177
227
|
}
|
|
178
228
|
|
|
179
229
|
/** The futures news route a search offers when no story matches it: `gloom news KC=F` for "arabica". */
|
|
@@ -44,6 +44,7 @@ import {
|
|
|
44
44
|
eventCountry,
|
|
45
45
|
matchesCountry,
|
|
46
46
|
matchesEventSearch,
|
|
47
|
+
policyDecisionsNamed,
|
|
47
48
|
matchesImpact,
|
|
48
49
|
NO_CONSENSUS_NOTE,
|
|
49
50
|
noScheduledReleasesMessage,
|
|
@@ -409,6 +410,19 @@ function econEmptyMessage(from: string | null, listedThrough: string | null, sto
|
|
|
409
410
|
: `No matching events${range} through ${listedThrough}.`;
|
|
410
411
|
}
|
|
411
412
|
|
|
413
|
+
/**
|
|
414
|
+
* What an empty search for a bank's own names could mean: `selic` is the
|
|
415
|
+
* Copom's decision, none of which falls in the window, and CBR has the rate
|
|
416
|
+
* and its next decision. Only a bank of the countries asked for; null for
|
|
417
|
+
* any other search.
|
|
418
|
+
*/
|
|
419
|
+
function policyDecisionHint(search: string, countries: string): string | null {
|
|
420
|
+
const named = policyDecisionsNamed(search, countries);
|
|
421
|
+
if (named.length === 0) return null;
|
|
422
|
+
const events = named.map(({ country, event }) => `${event} (${country})`).join(", ");
|
|
423
|
+
return `"${search}" is the ${events}; none falls in this window. The rate and its next decision: gloom fn CBR.`;
|
|
424
|
+
}
|
|
425
|
+
|
|
412
426
|
/**
|
|
413
427
|
* A date option, read as an ISO date; null when it was not given. `expand`
|
|
414
428
|
* reads a shorthand as a full date first, and `form` is how the message names
|
|
@@ -592,7 +606,8 @@ async function runEcon(args: string[], ctx: Parameters<CliCommandDef["execute"]>
|
|
|
592
606
|
}, {
|
|
593
607
|
dateKey: "date",
|
|
594
608
|
defaultLimit: 50,
|
|
595
|
-
empty: allUnscheduled ? noScheduledReleasesMessage(unscheduled)
|
|
609
|
+
empty: allUnscheduled ? noScheduledReleasesMessage(unscheduled)
|
|
610
|
+
: [econEmptyMessage(from, listedThrough, listedAfter != null), search == null ? null : policyDecisionHint(search, country)].filter(Boolean).join(" "),
|
|
596
611
|
...(footnote ? { footnote } : {}),
|
|
597
612
|
// What the text says under the table, a script reads in the CSV's closing lines.
|
|
598
613
|
exportNotes: notes,
|