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
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { DataTableColumn } from "../../../components";
|
|
2
|
+
import { dropColumnsToFit } from "../../../components/ui/table-layout";
|
|
3
|
+
import { displayWidth } from "../../../utils/format";
|
|
2
4
|
import { compareSortValues, type SortDirection } from "../../../utils/sort-values";
|
|
3
5
|
import { AUCTION_HISTORY_ALL, AUCTION_HISTORY_DAYS, AUCTION_HISTORY_START, type AuctionHistoryWindow } from "./client";
|
|
4
6
|
import type { TreasuryAuction } from "./types";
|
|
@@ -20,9 +22,10 @@ const AUCTION_HISTORY_LABELS: Record<string, { label: string; phrase: string }>
|
|
|
20
22
|
[AUCTION_HISTORY_ALL]: { label: `All, since ${AUCTION_HISTORY_START.slice(0, 4)}`, phrase: `every auction since ${AUCTION_HISTORY_START}` },
|
|
21
23
|
};
|
|
22
24
|
|
|
23
|
-
/** The window as the settings menu names it: "120 days", "5 years". */
|
|
25
|
+
/** The window as the settings menu names it: "120 days", "5 years"; the default says so. */
|
|
24
26
|
export function auctionHistoryLabel(window: AuctionHistoryWindow): string {
|
|
25
|
-
|
|
27
|
+
const label = AUCTION_HISTORY_LABELS[window]?.label ?? `${window} days`;
|
|
28
|
+
return window === AUCTION_HISTORY_DAYS ? `${label} (default)` : label;
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
/** The window inside a sentence: "the last 120 days", "the last 5 years". */
|
|
@@ -48,7 +51,18 @@ export function auctionHistoryWindow(settings: Record<string, unknown> | undefin
|
|
|
48
51
|
export const AUCTION_SEARCH_FIELDS = "type, benchmark (10Y), term, CUSIP, or date (YYYY-MM-DD)";
|
|
49
52
|
|
|
50
53
|
export type AuctionColumnId =
|
|
51
|
-
| "date" | "type" | "term" | "rate" | "stopOut" | "btc" | "indirect" | "direct" | "dealer" | "size"
|
|
54
|
+
| "date" | "type" | "term" | "rate" | "stopOut" | "btc" | "indirect" | "direct" | "dealer" | "size" | "cusip"
|
|
55
|
+
| "btcPctl" | "indirectPctl" | "dealerPctl" | "after1d" | "after5d" | "after20d";
|
|
56
|
+
|
|
57
|
+
/** What the after view adds to a row: its percentiles and the yield's moves after it (after.ts). */
|
|
58
|
+
export interface AuctionAfterFigures {
|
|
59
|
+
btcPercentile: number | null;
|
|
60
|
+
indirectPercentile: number | null;
|
|
61
|
+
dealerPercentile: number | null;
|
|
62
|
+
after1d: number | null;
|
|
63
|
+
after5d: number | null;
|
|
64
|
+
after20d: number | null;
|
|
65
|
+
}
|
|
52
66
|
|
|
53
67
|
export interface AuctionColumn extends DataTableColumn {
|
|
54
68
|
id: AuctionColumnId;
|
|
@@ -75,8 +89,39 @@ export const AUCTION_SORT_COLUMN_IDS: readonly AuctionColumnId[] = [
|
|
|
75
89
|
"direct",
|
|
76
90
|
"dealer",
|
|
77
91
|
"size",
|
|
92
|
+
"cusip",
|
|
93
|
+
];
|
|
94
|
+
|
|
95
|
+
/** The after view's columns, in the order [ and ] step through them. */
|
|
96
|
+
export const AUCTION_AFTER_SORT_COLUMN_IDS: readonly AuctionColumnId[] = [
|
|
97
|
+
"date", "type", "term", "rate", "btc", "btcPctl", "indirectPctl", "dealerPctl", "after1d", "after5d", "after20d", "cusip",
|
|
78
98
|
];
|
|
79
99
|
|
|
100
|
+
/** `--sort` as typed, and the column it sorts. */
|
|
101
|
+
export const AUCTION_SORT_NAMES: ReadonlyArray<{ value: string; column: AuctionColumnId; aliases?: string[] }> = [
|
|
102
|
+
{ value: "date", column: "date" },
|
|
103
|
+
{ value: "type", column: "type" },
|
|
104
|
+
{ value: "term", column: "term" },
|
|
105
|
+
{ value: "rate", column: "rate", aliases: ["yield"] },
|
|
106
|
+
{ value: "vs-median", column: "stopOut", aliases: ["vs-med", "vs-average", "vs-avg", "stop-out", "stopout"] },
|
|
107
|
+
{ value: "btc", column: "btc", aliases: ["b/c", "bid-to-cover", "bc"] },
|
|
108
|
+
{ value: "indirect", column: "indirect" },
|
|
109
|
+
{ value: "direct", column: "direct" },
|
|
110
|
+
{ value: "dealer", column: "dealer" },
|
|
111
|
+
{ value: "size", column: "size" },
|
|
112
|
+
{ value: "cusip", column: "cusip" },
|
|
113
|
+
{ value: "btc-pctl", column: "btcPctl", aliases: ["btc-percentile", "bc-pctl"] },
|
|
114
|
+
{ value: "indirect-pctl", column: "indirectPctl", aliases: ["indirect-percentile"] },
|
|
115
|
+
{ value: "dealer-pctl", column: "dealerPctl", aliases: ["dealer-percentile"] },
|
|
116
|
+
{ value: "1d", column: "after1d", aliases: ["after-1d", "+1d"] },
|
|
117
|
+
{ value: "5d", column: "after5d", aliases: ["after-5d", "+5d"] },
|
|
118
|
+
{ value: "20d", column: "after20d", aliases: ["after-20d", "+20d"] },
|
|
119
|
+
];
|
|
120
|
+
|
|
121
|
+
/** The after view's columns are its own; the results view's sort by its own. */
|
|
122
|
+
export const isAfterColumn = (column: AuctionColumnId) =>
|
|
123
|
+
column === "btcPctl" || column === "indirectPctl" || column === "dealerPctl" || column === "after1d" || column === "after5d" || column === "after20d";
|
|
124
|
+
|
|
80
125
|
export type AuctionFilter = "all" | "bill" | "note" | "bond";
|
|
81
126
|
|
|
82
127
|
export const AUCTION_FILTERS: ReadonlyArray<{ value: AuctionFilter; label: string }> = [
|
|
@@ -133,7 +178,7 @@ interface Benchmark {
|
|
|
133
178
|
* at auction is what the market calls the auction, so a 5-year auction that
|
|
134
179
|
* reopens an older 7-year note is still the 5Y.
|
|
135
180
|
*/
|
|
136
|
-
function auctionBenchmark(term: string): Benchmark | null {
|
|
181
|
+
export function auctionBenchmark(term: string): Benchmark | null {
|
|
137
182
|
const parts = termParts(term);
|
|
138
183
|
if (!parts) return null;
|
|
139
184
|
if (parts.year) {
|
|
@@ -245,16 +290,45 @@ export function dealerPct(auction: TreasuryAuction): number | null {
|
|
|
245
290
|
}
|
|
246
291
|
|
|
247
292
|
/**
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
|
|
252
|
-
|
|
293
|
+
* Treasury has sold every note, bond and bill at a single price since November
|
|
294
|
+
* 1998, and publishes the median accepted bid in its average/median field.
|
|
295
|
+
* Before, most auctions were multiple-price and the field is the average.
|
|
296
|
+
*/
|
|
297
|
+
const SINGLE_PRICE_FROM = "1998-11-01";
|
|
298
|
+
|
|
299
|
+
/** Whether an auction's average/median figure is the median (single-price) rather than the average. */
|
|
300
|
+
export const publishesMedian = (auction: Pick<TreasuryAuction, "auctionDate">) => auction.auctionDate >= SINGLE_PRICE_FROM;
|
|
301
|
+
|
|
302
|
+
/** The detail's name for the stop-out spread: against the median, or the average before November 1998. */
|
|
303
|
+
export const stopOutLabel = (auction: TreasuryAuction) => publishesMedian(auction) ? "Stop-out vs median" : "Stop-out vs average";
|
|
304
|
+
|
|
305
|
+
/** The detail's name for the middle figure itself: "Median yield", "Average discount rate". */
|
|
306
|
+
export function middleRateLabel(auction: TreasuryAuction, rate: "yield" | "discount rate"): string {
|
|
307
|
+
return `${publishesMedian(auction) ? "Median" : "Average"} ${rate}`;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* The stop-out column's heading for a list: VS MED when every row is from
|
|
312
|
+
* November 1998 on, VS AVG when every row is older, both when it spans the change.
|
|
313
|
+
*/
|
|
314
|
+
export function stopOutColumnLabel(auctions: readonly TreasuryAuction[], style: "pane" | "report"): string {
|
|
315
|
+
const median = auctions.some(publishesMedian);
|
|
316
|
+
const average = auctions.some((auction) => !publishesMedian(auction));
|
|
317
|
+
const which = median && average ? ["AVG/MED", "average/median"] : average ? ["AVG", "average"] : ["MED", "median"];
|
|
318
|
+
return style === "pane" ? `VS ${which[0]}` : `Stop-out vs ${which[1]} (bp)`;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* The stop-out (high yield) minus the median yield Treasury publishes for the
|
|
323
|
+
* same auction (the average before November 1998: publishesMedian), in basis
|
|
324
|
+
* points; a wider gap means the last dollars had to clear well above where
|
|
325
|
+
* most of the auction priced. Bills compare discount rates, which is how they
|
|
326
|
+
* trade. FRNs and auctions missing either leg are null.
|
|
253
327
|
*
|
|
254
328
|
* This is not a tail: a tail is the stop-out against the 1 pm when-issued
|
|
255
329
|
* yield, which the source does not carry.
|
|
256
330
|
*/
|
|
257
|
-
export function
|
|
331
|
+
export function stopOutVsAvgBp(auction: TreasuryAuction): number | null {
|
|
258
332
|
if (auction.secType === "FRN") return null;
|
|
259
333
|
const bill = FILTER_TYPES.bill.has(auction.secType);
|
|
260
334
|
const high = bill ? auction.highDiscountRate : auction.highYield;
|
|
@@ -276,7 +350,16 @@ export function rateValue(auction: TreasuryAuction): number | null {
|
|
|
276
350
|
/** Treasury's name for the rate rateValue reports; a bill's High Rate is its discount rate. */
|
|
277
351
|
export function rateLabel(auction: TreasuryAuction): string {
|
|
278
352
|
if (auction.secType === "FRN") return "High discount margin";
|
|
279
|
-
return
|
|
353
|
+
return isBill(auction) ? "Investment rate" : "High yield";
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/** A bill or cash management bill: its headline rate is the investment rate, and it trades on its discount rate. */
|
|
357
|
+
export const isBill = (auction: TreasuryAuction) => FILTER_TYPES.bill.has(auction.secType);
|
|
358
|
+
|
|
359
|
+
/** The rate column's heading: a board of bills says its rate is the investment rate Treasury states beside the discount rate. */
|
|
360
|
+
export function rateColumnLabel(auctions: readonly TreasuryAuction[], style: "pane" | "report"): string {
|
|
361
|
+
const bills = auctions.length > 0 && auctions.every(isBill);
|
|
362
|
+
return style === "pane" ? bills ? "INV RATE" : "RATE" : bills ? "Investment rate" : "Rate";
|
|
280
363
|
}
|
|
281
364
|
|
|
282
365
|
/**
|
|
@@ -293,9 +376,14 @@ export function formatAuctionRate(auction: TreasuryAuction, value: number | null
|
|
|
293
376
|
return auction.secType === "FRN" ? `${(value * 100).toFixed(1)}bp` : `${value.toFixed(3)}%`;
|
|
294
377
|
}
|
|
295
378
|
|
|
296
|
-
/**
|
|
379
|
+
/**
|
|
380
|
+
* Announced auctions appear in the feed days before any results are published.
|
|
381
|
+
* An early bill whose investment rate was blanked (inClearingOrder) still has
|
|
382
|
+
* its discount rates, so it is a result, not an announcement.
|
|
383
|
+
*/
|
|
297
384
|
export function isPendingAuction(auction: TreasuryAuction): boolean {
|
|
298
|
-
return rateValue(auction) == null && auction.bidToCoverRatio == null
|
|
385
|
+
return rateValue(auction) == null && auction.bidToCoverRatio == null
|
|
386
|
+
&& auction.highDiscountRate == null && auction.avgMedDiscountRate == null && auction.avgMedYield == null;
|
|
299
387
|
}
|
|
300
388
|
|
|
301
389
|
/**
|
|
@@ -329,7 +417,7 @@ export function auctionSize(auction: TreasuryAuction): number | null {
|
|
|
329
417
|
return auction.offeringAmount ?? auction.totalAccepted;
|
|
330
418
|
}
|
|
331
419
|
|
|
332
|
-
function sortValue(auction: TreasuryAuction, columnId: AuctionColumnId): number | string | null {
|
|
420
|
+
function sortValue(auction: TreasuryAuction, columnId: AuctionColumnId, after?: AuctionAfterFigures): number | string | null {
|
|
333
421
|
switch (columnId) {
|
|
334
422
|
case "date": return auctionDateValue(auction.auctionDate);
|
|
335
423
|
case "type": return auction.secType;
|
|
@@ -338,24 +426,32 @@ function sortValue(auction: TreasuryAuction, columnId: AuctionColumnId): number
|
|
|
338
426
|
return days === Number.MAX_SAFE_INTEGER ? null : days;
|
|
339
427
|
}
|
|
340
428
|
case "rate": return rateValue(auction);
|
|
341
|
-
case "stopOut": return
|
|
429
|
+
case "stopOut": return stopOutVsAvgBp(auction);
|
|
342
430
|
case "btc": return auction.bidToCoverRatio;
|
|
343
431
|
case "indirect": return indirectPct(auction);
|
|
344
432
|
case "direct": return directPct(auction);
|
|
345
433
|
case "dealer": return dealerPct(auction);
|
|
346
434
|
case "size": return auctionSize(auction);
|
|
435
|
+
case "cusip": return auction.cusip;
|
|
436
|
+
case "btcPctl": return after?.btcPercentile ?? null;
|
|
437
|
+
case "indirectPctl": return after?.indirectPercentile ?? null;
|
|
438
|
+
case "dealerPctl": return after?.dealerPercentile ?? null;
|
|
439
|
+
case "after1d": return after?.after1d ?? null;
|
|
440
|
+
case "after5d": return after?.after5d ?? null;
|
|
441
|
+
case "after20d": return after?.after20d ?? null;
|
|
347
442
|
}
|
|
348
443
|
}
|
|
349
444
|
|
|
350
445
|
export function visibleAuctions(
|
|
351
446
|
auctions: readonly TreasuryAuction[],
|
|
352
|
-
options: { filter: AuctionFilter; query: string; sort: AuctionSortPreference },
|
|
447
|
+
options: { filter: AuctionFilter; query: string; sort: AuctionSortPreference; after?: ReadonlyMap<string, AuctionAfterFigures>; from?: string },
|
|
353
448
|
): TreasuryAuction[] {
|
|
354
449
|
return auctions
|
|
355
|
-
.filter((auction) => matchesFilter(auction, options.filter) && matchesAuctionQuery(auction, options.query)
|
|
450
|
+
.filter((auction) => matchesFilter(auction, options.filter) && matchesAuctionQuery(auction, options.query)
|
|
451
|
+
&& (!options.from || auction.auctionDate >= options.from))
|
|
356
452
|
.sort((left, right) => {
|
|
357
|
-
const leftValue = sortValue(left, options.sort.columnId);
|
|
358
|
-
const rightValue = sortValue(right, options.sort.columnId);
|
|
453
|
+
const leftValue = sortValue(left, options.sort.columnId, options.after?.get(left.id));
|
|
454
|
+
const rightValue = sortValue(right, options.sort.columnId, options.after?.get(right.id));
|
|
359
455
|
const comparison = compareSortValues(
|
|
360
456
|
typeof leftValue === "string" ? leftValue.toLowerCase() : leftValue,
|
|
361
457
|
typeof rightValue === "string" ? rightValue.toLowerCase() : rightValue,
|
|
@@ -369,7 +465,7 @@ export function visibleAuctions(
|
|
|
369
465
|
|
|
370
466
|
/** Text columns read best ascending; every metric reads best highest-first. */
|
|
371
467
|
export function firstAuctionSortDirection(columnId: AuctionColumnId): SortDirection {
|
|
372
|
-
return columnId === "type" || columnId === "term" ? "asc" : "desc";
|
|
468
|
+
return columnId === "type" || columnId === "term" || columnId === "cusip" ? "asc" : "desc";
|
|
373
469
|
}
|
|
374
470
|
|
|
375
471
|
/**
|
|
@@ -382,21 +478,153 @@ export function auctionDatesShowYear(window: AuctionHistoryWindow): boolean {
|
|
|
382
478
|
|
|
383
479
|
/**
|
|
384
480
|
* Widths are the data's own; the table widens a column to its label plus the
|
|
385
|
-
* sort arrow.
|
|
386
|
-
*
|
|
387
|
-
*
|
|
481
|
+
* sort arrow. TERM is as wide as the longest term listed, and the CUSIP closes
|
|
482
|
+
* the row where the pane has room for it, taking what width is left; a pane
|
|
483
|
+
* too narrow for the rest scrolls sideways instead of clipping a figure.
|
|
388
484
|
*/
|
|
389
|
-
export function buildAuctionColumns(
|
|
390
|
-
|
|
485
|
+
export function buildAuctionColumns(options: {
|
|
486
|
+
showYear?: boolean;
|
|
487
|
+
view?: "results" | "after";
|
|
488
|
+
rows?: readonly TreasuryAuction[];
|
|
489
|
+
/** The table's width; without one every column is listed. */
|
|
490
|
+
width?: number;
|
|
491
|
+
} = {}): AuctionColumn[] {
|
|
492
|
+
const { showYear = false, view = "results", rows = [], width } = options;
|
|
493
|
+
const term = Math.max(6, ...rows.map((auction) => displayWidth(auction.securityTerm)));
|
|
494
|
+
const lead: AuctionColumn[] = [
|
|
391
495
|
{ id: "date", label: "DATE", width: showYear ? 10 : 6, align: "left" },
|
|
392
496
|
{ id: "type", label: "TYPE", width: 6, align: "left" },
|
|
393
|
-
{ id: "term", label: "TERM", width:
|
|
394
|
-
{ id: "rate", label: "
|
|
395
|
-
|
|
497
|
+
{ id: "term", label: "TERM", width: term, align: "left" },
|
|
498
|
+
{ id: "rate", label: rateColumnLabel(rows, "pane"), width: 7, align: "right" },
|
|
499
|
+
];
|
|
500
|
+
const figures: AuctionColumn[] = view === "after" ? [
|
|
501
|
+
{ id: "btc", label: "B/C", width: 5, align: "right" },
|
|
502
|
+
{ id: "btcPctl", label: "B/C PCTL", width: 4, align: "right", title: "Bid-to-cover percentile against the tenor's last 24 auctions" },
|
|
503
|
+
{ id: "indirectPctl", label: "IND PCTL", width: 4, align: "right", title: "Indirect share percentile against the tenor's last 24 auctions" },
|
|
504
|
+
{ id: "dealerPctl", label: "DLR PCTL", width: 4, align: "right", title: "Dealer share percentile against the tenor's last 24 auctions" },
|
|
505
|
+
{ id: "after1d", label: "+1D BP", width: 5, align: "right", title: "Treasury yield change one session after the auction, bp" },
|
|
506
|
+
{ id: "after5d", label: "+5D BP", width: 5, align: "right", title: "Treasury yield change five sessions after the auction, bp" },
|
|
507
|
+
{ id: "after20d", label: "+20D BP", width: 5, align: "right", title: "Treasury yield change twenty sessions after the auction, bp" },
|
|
508
|
+
] : [
|
|
509
|
+
{ id: "stopOut", label: stopOutColumnLabel(rows, "pane"), width: 7, align: "right", title: "Stop-out vs median yield (average before November 1998), bp" },
|
|
396
510
|
{ id: "btc", label: "B/C", width: 5, align: "right" },
|
|
397
511
|
{ id: "indirect", label: "INDIRECT", width: 8, align: "right" },
|
|
398
512
|
{ id: "direct", label: "DIRECT", width: 6, align: "right" },
|
|
399
513
|
{ id: "dealer", label: "DEALER", width: 6, align: "right" },
|
|
400
514
|
{ id: "size", label: "SIZE", width: 7, align: "right" },
|
|
401
515
|
];
|
|
516
|
+
const columns: AuctionColumn[] = [...lead, ...figures, { id: "cusip", label: "CUSIP", width: 9, align: "left", flexGrow: 1 }];
|
|
517
|
+
if (width == null) return columns;
|
|
518
|
+
const shown = dropColumnsToFit(columns, width, ["cusip"]);
|
|
519
|
+
// Without the CUSIP nothing grows: the figures keep their places at the left.
|
|
520
|
+
return shown.length === columns.length ? shown : shown.map((column) => ({ ...column, flexGrow: undefined }));
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* What `AUCT 10Y --history-days 3650` asks of the pane, typed in the command
|
|
525
|
+
* bar as it is to `fn AUCT`: the search, and the window, group, view and sort
|
|
526
|
+
* given as flags (`--history-days`, `--historyDays` or `--history`;
|
|
527
|
+
* `--filter`, `--view`, `--sort`), each as `--flag value` or `--flag=value`.
|
|
528
|
+
* A flag whose value is not one of its own is left out.
|
|
529
|
+
*/
|
|
530
|
+
function parseAuctionCommandArg(arg: string | undefined): {
|
|
531
|
+
search: string;
|
|
532
|
+
historyDays?: AuctionHistoryWindow;
|
|
533
|
+
filter?: AuctionFilter;
|
|
534
|
+
view?: "results" | "after";
|
|
535
|
+
/** The sort's name as `--sort` takes it: "btc-pctl". */
|
|
536
|
+
sort?: string;
|
|
537
|
+
} {
|
|
538
|
+
const tokens = (arg ?? "").trim().split(/\s+/).filter(Boolean);
|
|
539
|
+
const words: string[] = [];
|
|
540
|
+
const parsed: ReturnType<typeof parseAuctionCommandArg> = { search: "" };
|
|
541
|
+
for (let index = 0; index < tokens.length; index++) {
|
|
542
|
+
const token = tokens[index]!;
|
|
543
|
+
const flag = /^--([a-z-]+)(?:=(.*))?$/i.exec(token);
|
|
544
|
+
if (!flag) {
|
|
545
|
+
words.push(token);
|
|
546
|
+
continue;
|
|
547
|
+
}
|
|
548
|
+
const name = flag[1]!.toLowerCase().replace(/-/g, "");
|
|
549
|
+
const value = (flag[2] ?? tokens[++index] ?? "").toLowerCase();
|
|
550
|
+
if (name === "historydays" || name === "history") {
|
|
551
|
+
const window = auctionHistoryWindow({ historyDays: value });
|
|
552
|
+
if (value === AUCTION_HISTORY_ALL || String(window) === value) parsed.historyDays = window;
|
|
553
|
+
} else if (name === "filter") {
|
|
554
|
+
const filter = AUCTION_FILTERS.find((entry) => entry.value === value)?.value;
|
|
555
|
+
if (filter) parsed.filter = filter;
|
|
556
|
+
} else if (name === "view") {
|
|
557
|
+
if (value === "results" || value === "after") parsed.view = value;
|
|
558
|
+
} else if (name === "sort") {
|
|
559
|
+
const sort = auctionSortColumn(value);
|
|
560
|
+
const name = sort && AUCTION_SORT_NAMES.find((entry) => entry.column === sort)?.value;
|
|
561
|
+
if (name) parsed.sort = name;
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
parsed.search = words.join(" ");
|
|
565
|
+
return parsed;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
/**
|
|
569
|
+
* What `AUCT <arg>` asks of the pane: the search and every view key, defaults
|
|
570
|
+
* included, since an open pane merges a command's params into its own; a plain
|
|
571
|
+
* `AUCT 10Y` after `AUCT 7Y --view after --sort 5d --filter note` opens on
|
|
572
|
+
* results, newest first, all types. A window is a setting, sent when named.
|
|
573
|
+
*/
|
|
574
|
+
export function auctionCommandRequest(arg: string | undefined): {
|
|
575
|
+
params: Record<string, string>;
|
|
576
|
+
settings: Record<string, string> | null;
|
|
577
|
+
} {
|
|
578
|
+
const { search, historyDays, filter, view, sort } = parseAuctionCommandArg(arg);
|
|
579
|
+
return {
|
|
580
|
+
params: { search, auctionView: view ?? "results", auctionSort: sort ?? "date", auctionFilter: filter ?? "all" },
|
|
581
|
+
settings: historyDays != null ? { historyDays: String(historyDays) } : null,
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
/** The column `--sort` names, by its name or an alias; null for anything else. */
|
|
586
|
+
export function auctionSortColumn(value: string): AuctionColumnId | null {
|
|
587
|
+
const name = value.trim().toLowerCase();
|
|
588
|
+
return AUCTION_SORT_NAMES.find((entry) => entry.value === name || entry.aliases?.includes(name))?.column ?? null;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
/** A query for a market AUCT does not cover: another country's government paper. */
|
|
592
|
+
const NON_US_PAPER = /\b(jgb|jgbs|gilt|gilts|bund|bunds|bobl|schatz|oat|oats|btp|btps|bono|bonos|acgb|cgb|cgbs|ktb|ktbs|sgs|btf|euro|eur|gbp|jpy|uk|japan|japanese|german|germany|france|french|italy|italian|spain|canada|canadian|australia|australian|china|chinese|korea|singapore|india|indian|brazil|mexico)\b/i;
|
|
593
|
+
|
|
594
|
+
/** Whether a search names another market's government paper, which AUCT does not list. */
|
|
595
|
+
export function namesOtherMarket(query: string): boolean {
|
|
596
|
+
return NON_US_PAPER.test(query.trim());
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
/** A whole CUSIP: nine letters and digits with a digit. */
|
|
600
|
+
const isWholeCusip = (query: string) => /^[a-z0-9]{9}$/i.test(query.trim()) && /\d/.test(query);
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* Whether a longer window could list more rows for this search: not with
|
|
604
|
+
* every auction already read, not for another market's paper, not for a
|
|
605
|
+
* CUSIP whose first auction is listed (its reopenings come after it), and not
|
|
606
|
+
* for a date inside the window.
|
|
607
|
+
*/
|
|
608
|
+
export function widerWindowCouldAdd(query: string, rows: readonly TreasuryAuction[], window: AuctionHistoryWindow, now = Date.now()): boolean {
|
|
609
|
+
if (window === AUCTION_HISTORY_ALL) return false;
|
|
610
|
+
const text = query.trim();
|
|
611
|
+
if (!text) return true;
|
|
612
|
+
if (namesOtherMarket(text)) return false;
|
|
613
|
+
const from = new Date(now - window * 86_400_000).toISOString().slice(0, 10);
|
|
614
|
+
const date = /\b(\d{4})(?:-(\d{2}))?(?:-(\d{2}))?\b/.exec(text);
|
|
615
|
+
if (date && !parseBenchmarkQuery(text.toLowerCase())) {
|
|
616
|
+
// The latest day the search can mean: a year's last day, a month's last day, the day itself.
|
|
617
|
+
const latest = date[3] ? date[0] : date[2] ? `${date[1]}-${date[2]}-31` : `${date[1]}-12-31`;
|
|
618
|
+
return latest < from;
|
|
619
|
+
}
|
|
620
|
+
if (isWholeCusip(text)) {
|
|
621
|
+
// A note or bond reopening's term has a month part (9-Year 10-Month); its first auction's is whole (10-Year).
|
|
622
|
+
// A bill's term is whole either way: a 13-week bill can reopen a 26-week CUSIP, so a bill is never known first.
|
|
623
|
+
const first = rows.some((auction) => {
|
|
624
|
+
const parts = termParts(auction.securityTerm);
|
|
625
|
+
return !isBill(auction) && !!parts && Object.keys(parts).length === 1;
|
|
626
|
+
});
|
|
627
|
+
return !first;
|
|
628
|
+
}
|
|
629
|
+
return true;
|
|
402
630
|
}
|