gloomberb 0.20.4 → 0.20.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/README.zh-CN.md +1 -1
- package/bin/gloom +9 -0
- package/bin/without-bun.cjs +98 -0
- package/package.json +4 -1
- package/src/api-client/data.ts +148 -37
- package/src/api-client/hk-tenders.ts +59 -0
- package/src/api-client/index.ts +1 -0
- package/src/api-client/types/econ.ts +30 -0
- package/src/api-client/yield-curves.ts +1 -1
- package/src/app/global-shortcuts.ts +4 -1
- package/src/app/keybindings/actions.ts +6 -0
- 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 +68 -40
- package/src/app.tsx +18 -13
- package/src/architecture/floating-promise-allowlist.json +313 -0
- 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 +238 -57
- package/src/cli/commands/news-search.ts +81 -14
- package/src/cli/commands/overview.ts +27 -6
- package/src/cli/commands/remote.ts +16 -17
- package/src/cli/commands/system.ts +1 -1
- package/src/cli/commands/ticker.ts +3 -1
- package/src/cli/early-command.ts +2 -0
- package/src/cli/errors.ts +10 -1
- package/src/cli/fx-forward.ts +89 -7
- package/src/cli/fx-pair.ts +1 -1
- package/src/cli/fx-quote-rate.ts +23 -0
- package/src/cli/glossary.ts +19 -5
- package/src/cli/help.ts +1 -0
- package/src/cli/history-rows.ts +5 -3
- package/src/cli/index-roots.ts +5 -4
- package/src/cli/index.ts +40 -3
- package/src/cli/known-gaps.ts +38 -9
- package/src/cli/listing-arg.ts +17 -5
- package/src/cli/name-entries.ts +5 -1
- package/src/cli/not-a-ticker.ts +4 -0
- package/src/cli/options.ts +52 -3
- package/src/cli/output-file.ts +5 -3
- package/src/cli/pane-functions/catalog.ts +15 -0
- package/src/cli/pane-functions/function-help.ts +4 -4
- package/src/cli/pane-functions/headless.ts +9 -4
- package/src/cli/pane-functions/index.ts +6 -4
- package/src/cli/pane-functions/resolver.ts +2 -2
- package/src/cli/result.ts +21 -2
- package/src/cli/spreadsheet-hint.ts +7 -3
- package/src/cli/treasury-yields.ts +5 -3
- package/src/components/chart/composite/legend.tsx +40 -2
- package/src/components/command-bar/pane-settings.ts +2 -2
- package/src/components/command-bar/routes/root/results.ts +6 -2
- package/src/components/command-bar/workflow/tickers.ts +2 -2
- package/src/components/data-table/view.tsx +9 -2
- package/src/components/input-search-bar.tsx +9 -2
- package/src/components/layout/pane/header.tsx +2 -0
- package/src/components/layout/shell/pane/capture.ts +4 -1
- package/src/components/layout/status-bar.tsx +6 -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 +16 -0
- package/src/components/onboarding/onboarding-wizard.tsx +8 -8
- 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/data-table/opentui/index.tsx +11 -4
- package/src/components/ui/data-table/opentui/model.ts +8 -6
- package/src/components/ui/data-table/types.ts +6 -1
- package/src/components/ui/index.ts +1 -1
- 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/table-layout.ts +38 -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/docs/snapshot.json +30 -13
- package/src/market-data/depositary-pair.ts +5 -3
- package/src/market-data/market/change-basis.ts +9 -5
- package/src/market-data/market/dated-previous-close.ts +147 -17
- package/src/market-data/market/status.ts +17 -1
- package/src/market-data/quotes/contributions.ts +2 -0
- package/src/market-data/quotes/listing-enterprise-value.ts +50 -0
- package/src/plugins/builtin/alerts/metric-data.ts +15 -2
- 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/backtest/headless.ts +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/cds/model.ts +0 -6
- package/src/plugins/builtin/chart-composer/formula.ts +16 -3
- package/src/plugins/builtin/chart-composer/headless-schema.ts +2 -0
- package/src/plugins/builtin/chart-composer/headless.ts +4 -2
- package/src/plugins/builtin/chart-composer/index.tsx +1 -0
- package/src/plugins/builtin/chart-composer/presets.ts +1 -0
- 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/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/pane.tsx +55 -13
- package/src/plugins/builtin/cloud/askg/tool-display.ts +1 -0
- package/src/plugins/builtin/cloud/terminal-relay/redact.ts +5 -3
- 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/index.tsx +1 -1
- package/src/plugins/builtin/cpi/index.tsx +1 -1
- package/src/plugins/builtin/credit-boards/cdx-pane.tsx +20 -7
- package/src/plugins/builtin/credit-boards/client.ts +8 -0
- package/src/plugins/builtin/credit-boards/headless.ts +4 -1
- package/src/plugins/builtin/credit-boards/model.ts +58 -4
- package/src/plugins/builtin/credit-boards/series.ts +63 -6
- package/src/plugins/builtin/credit-boards/sovr-pane.tsx +3 -2
- package/src/plugins/builtin/credit-conditions/headless.ts +24 -6
- package/src/plugins/builtin/credit-conditions/index.tsx +1 -1
- package/src/plugins/builtin/credit-conditions/model.ts +12 -6
- package/src/plugins/builtin/credit-conditions/series.ts +2 -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-calls/headless.ts +5 -1
- package/src/plugins/builtin/earnings-calls/index.tsx +1 -0
- package/src/plugins/builtin/econ/calendar-model.ts +115 -8
- package/src/plugins/builtin/econ/calendar-source.ts +7 -1
- package/src/plugins/builtin/econ/fred-catalog.ts +3 -1
- package/src/plugins/builtin/econ/index.tsx +42 -8
- package/src/plugins/builtin/econ/types.ts +3 -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 +3 -0
- 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/fx-matrix/index.tsx +44 -14
- 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 +11 -1
- package/src/plugins/builtin/help/keybindings-editor.tsx +7 -3
- 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/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/index.tsx +1 -0
- 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/portfolio-list/cli/portfolio-command.ts +25 -0
- package/src/plugins/builtin/portfolio-list/cli/render.ts +20 -3
- package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +5 -1
- package/src/plugins/builtin/portfolio-list/headless.ts +15 -6
- package/src/plugins/builtin/power/index.tsx +1 -1
- package/src/plugins/builtin/realized-vol/index.tsx +1 -1
- package/src/plugins/builtin/research/headless-schema.ts +4 -3
- package/src/plugins/builtin/research/headless.ts +10 -4
- package/src/plugins/builtin/research/index.tsx +4 -0
- package/src/plugins/builtin/research/relative-valuation-columns.ts +145 -47
- package/src/plugins/builtin/research/relative-valuation-currency.ts +31 -0
- package/src/plugins/builtin/research/relative-valuation-headless.ts +25 -8
- package/src/plugins/builtin/research/relative-valuation-model.ts +40 -9
- package/src/plugins/builtin/research/relative-valuation-pane.tsx +3 -2
- package/src/plugins/builtin/research/relative-valuation-peers.ts +2 -2
- 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/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/api.ts +47 -4
- 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/data-panes/historical-prices.tsx +8 -7
- package/src/plugins/builtin/ticker-detail/data-panes/history-bars.ts +8 -5
- package/src/plugins/builtin/ticker-detail/financials/model.ts +18 -2
- package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +3 -3
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +6 -6
- package/src/plugins/builtin/ticker-detail/headless.ts +24 -17
- package/src/plugins/builtin/ticker-detail/index.tsx +4 -0
- package/src/plugins/builtin/ticker-detail/overview/model.ts +6 -4
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +6 -4
- 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 +54 -5
- package/src/plugins/builtin/treasury-auctions/client.ts +33 -2
- package/src/plugins/builtin/treasury-auctions/headless.ts +150 -22
- package/src/plugins/builtin/treasury-auctions/hk-headless.ts +126 -0
- package/src/plugins/builtin/treasury-auctions/hk-view.tsx +347 -0
- package/src/plugins/builtin/treasury-auctions/hk.ts +363 -0
- package/src/plugins/builtin/treasury-auctions/index.tsx +27 -4
- package/src/plugins/builtin/treasury-auctions/model.ts +264 -28
- package/src/plugins/builtin/treasury-auctions/pane.tsx +176 -41
- 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/portfolio/collection-name.ts +22 -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 +44 -18
- package/src/remote/schema.ts +21 -9
- package/src/remote/secrets.ts +12 -0
- package/src/remote/semantic-tree.tsx +14 -2
- package/src/remote/server.ts +2 -1
- package/src/remote/surface.tsx +192 -0
- package/src/remote/types.ts +5 -0
- package/src/renderers/dom/data-table/frozen-column.ts +3 -1
- package/src/renderers/dom/data-table/index.tsx +27 -9
- package/src/renderers/dom/data-table/row.tsx +2 -0
- package/src/renderers/electrobun/bun/desktop/backend.ts +27 -24
- package/src/renderers/electrobun/bun/desktop/detached-windows.ts +3 -3
- package/src/renderers/electrobun/bun/desktop/snapshot-commit.ts +77 -0
- package/src/renderers/electrobun/shared/protocol.ts +4 -0
- package/src/renderers/electrobun/view/backend-rpc.ts +3 -0
- package/src/renderers/electrobun/view/desktop/window/bridge.ts +3 -0
- package/src/renderers/opentui/host.tsx +6 -0
- 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 +2 -0
- package/src/sources/gloomberb-cloud/normalizers.ts +9 -5
- package/src/sources/provider-router/cache.ts +3 -1
- package/src/sync/controller.ts +17 -2
- package/src/sync/other-window-tabs.ts +32 -1
- package/src/sync/react.ts +4 -4
- package/src/tickers/renamed-listings.ts +105 -0
- package/src/tickers/search/index.ts +103 -16
- package/src/time-series/bar-spacing.ts +33 -0
- package/src/time-series/base-series.ts +21 -3
- package/src/time-series/chart-bounds.ts +31 -0
- package/src/time-series/field-catalog.ts +17 -0
- package/src/time-series/fundamentals.ts +143 -11
- package/src/time-series/ice-credit.ts +32 -6
- package/src/time-series/resolve.ts +11 -7
- package/src/time-series/session-bar.ts +78 -9
- package/src/time-series/studies/formula.ts +53 -10
- package/src/time-series/studies/pair.ts +18 -7
- package/src/time-series/studies/units.ts +49 -2
- package/src/time-series/types.ts +12 -0
- package/src/types/desktop-window.ts +2 -0
- package/src/types/financials.ts +7 -0
- package/src/types/headless.ts +8 -0
- package/src/types/plugin-pane-settings.ts +2 -0
- package/src/types/plugin-panes.ts +22 -0
- package/src/utils/central-banks.ts +86 -1
- package/src/utils/cli-output.ts +6 -3
- package/src/utils/datetime-format.ts +12 -3
- package/src/utils/depositary-receipt.ts +28 -3
- package/src/utils/ebitda.ts +128 -0
- package/src/utils/format.ts +1 -1
- package/src/utils/fundamentals.ts +14 -0
- package/src/utils/max-drawdown.ts +97 -16
- package/src/utils/shell-word.ts +13 -0
- package/src/utils/untrusted-text.ts +29 -0
|
@@ -2,29 +2,44 @@ import type {
|
|
|
2
2
|
HeadlessPaneDefinition,
|
|
3
3
|
HeadlessPaneLoadArgs,
|
|
4
4
|
} from "../../../types/plugin";
|
|
5
|
+
import type { HeadlessPaneColumn } from "../../../types/headless";
|
|
6
|
+
import {
|
|
7
|
+
afterLoadWindow, afterWindowStart, AUCTION_VIEWS, loadAuctionCurves, projectAuctionAfter, widerAfterWindow, type AuctionCurveRead, type AuctionView,
|
|
8
|
+
} from "./after";
|
|
5
9
|
import { formatCompact } from "../../../utils/format";
|
|
6
10
|
import { AUCTION_HISTORY_ALL, AUCTION_HISTORY_START, fetchTreasuryAuctions, type AuctionHistoryWindow } from "./client";
|
|
7
11
|
import { loadTreasuryAuctions, type TreasuryAuctionsResult } from "./cache";
|
|
8
12
|
import { unansweredRefreshError } from "../../../data/saved-copies";
|
|
9
13
|
import type { TreasuryAuction } from "./types";
|
|
14
|
+
import { AUCTION_MARKETS, auctionSearchMarket, isAuctionMarket, loadHkTenders, type HkTendersResult } from "./hk";
|
|
15
|
+
import { hkTendersReport } from "./hk-headless";
|
|
10
16
|
import { FIXED_INCOME_VIEW_STATE } from "../fixed-income/model";
|
|
11
17
|
import {
|
|
12
18
|
AUCTION_HISTORY_WINDOWS,
|
|
13
19
|
AUCTION_SEARCH_FIELDS,
|
|
20
|
+
AUCTION_SORT_NAMES,
|
|
14
21
|
auctionHistoryPhrase,
|
|
15
22
|
auctionHistoryWindow,
|
|
16
23
|
auctionSize,
|
|
24
|
+
auctionSortColumn,
|
|
17
25
|
dealerPct,
|
|
18
26
|
DEFAULT_AUCTION_SORT,
|
|
19
27
|
directPct,
|
|
28
|
+
firstAuctionSortDirection,
|
|
20
29
|
formatAuctionRate,
|
|
21
30
|
indirectPct,
|
|
31
|
+
isAfterColumn,
|
|
32
|
+
isBill,
|
|
22
33
|
isPendingAuction,
|
|
34
|
+
namesOtherMarket,
|
|
23
35
|
nextAuctionHistoryWindow,
|
|
36
|
+
rateColumnLabel,
|
|
24
37
|
rateQualifier,
|
|
25
38
|
rateValue,
|
|
26
|
-
|
|
39
|
+
stopOutColumnLabel,
|
|
40
|
+
stopOutVsAvgBp,
|
|
27
41
|
visibleAuctions,
|
|
42
|
+
widerWindowCouldAdd,
|
|
28
43
|
type AuctionFilter,
|
|
29
44
|
} from "./model";
|
|
30
45
|
|
|
@@ -40,7 +55,8 @@ const RESULTS_NOT_PUBLISHED = "results not published";
|
|
|
40
55
|
const pending = (row: Record<string, unknown>) => isPendingAuction(row as unknown as TreasuryAuction);
|
|
41
56
|
|
|
42
57
|
/** Why the stop-out column is not a tail; the docs page says the same at length. */
|
|
43
|
-
const STOP_OUT_NOTE = "Stop-out vs
|
|
58
|
+
const STOP_OUT_NOTE = "Stop-out vs median is the high yield minus the median yield, in bp (bills: discount rates); "
|
|
59
|
+
+ "before November 1998, when most auctions were multiple-price, Treasury published the average, so older rows read against the average. "
|
|
44
60
|
+ "A true tail, the stop-out against the 1 pm when-issued yield, needs the when-issued yield, which the source does not carry.";
|
|
45
61
|
|
|
46
62
|
const MISSING_METRICS_NOTE = "A blank B/C or bidder share is one the source does not have for that auction: "
|
|
@@ -61,7 +77,7 @@ const rateCell = (value: unknown, row: Record<string, unknown>) => {
|
|
|
61
77
|
return qualifier ? `${text} ${qualifier}` : text;
|
|
62
78
|
};
|
|
63
79
|
|
|
64
|
-
const
|
|
80
|
+
const LEAD_COLUMNS: HeadlessPaneColumn[] = [
|
|
65
81
|
{ key: "auctionDate", header: "Date" },
|
|
66
82
|
{ key: "secType", header: "Type" },
|
|
67
83
|
{ key: "securityTerm", header: "Term" },
|
|
@@ -74,7 +90,17 @@ const COLUMNS = [
|
|
|
74
90
|
),
|
|
75
91
|
textFormat: rateCell,
|
|
76
92
|
},
|
|
93
|
+
];
|
|
94
|
+
|
|
95
|
+
/** A bill's high discount rate, beside the investment rate its Rate is: the rate Treasury's announcement leads with. */
|
|
96
|
+
const DISCOUNT_RATE_COLUMN: HeadlessPaneColumn = {
|
|
97
|
+
key: "highDiscountRate", header: "Discount rate", align: "right" as const,
|
|
98
|
+
format: (value: unknown, row: Record<string, unknown>) => value == null ? pending(row) ? "" : "-" : `${Number(value).toFixed(3)}%`,
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const RESULT_COLUMNS: HeadlessPaneColumn[] = [
|
|
77
102
|
{
|
|
103
|
+
// Exports keep the name scripts read it by: the spread against the published average, or the median from November 1998.
|
|
78
104
|
key: "stopOutVsAvgBp", header: "Stop-out vs avg (bp)", align: "right" as const,
|
|
79
105
|
format: (value: unknown, row: Record<string, unknown>) => value == null ? pending(row) ? "" : "-" : Number(value).toFixed(1),
|
|
80
106
|
},
|
|
@@ -86,22 +112,63 @@ const COLUMNS = [
|
|
|
86
112
|
{ key: "cusip", header: "CUSIP" },
|
|
87
113
|
];
|
|
88
114
|
|
|
115
|
+
const percentile = (value: unknown) => value == null ? "" : String(value);
|
|
116
|
+
const bpMove = (value: unknown) => value == null ? "" : `${Number(value) > 0 ? "+" : ""}${Number(value).toFixed(0)}`;
|
|
117
|
+
|
|
118
|
+
/** The after view: each auction against its tenor's last 24, and the matching Treasury yield's moves after it. */
|
|
119
|
+
const AFTER_COLUMNS: HeadlessPaneColumn[] = [
|
|
120
|
+
{ key: "bidToCoverRatio", header: "B/C", align: "right" as const, format: (value: unknown) => value == null ? "" : Number(value).toFixed(2) },
|
|
121
|
+
{ key: "btcPercentile", header: "B/C pctl", align: "right" as const, format: percentile },
|
|
122
|
+
{ key: "indirectPercentile", header: "Indirect pctl", align: "right" as const, format: percentile },
|
|
123
|
+
{ key: "dealerPercentile", header: "Dealer pctl", align: "right" as const, format: percentile },
|
|
124
|
+
{ key: "cmt", header: "Yield", description: "The Treasury par yield the moves are read on: the auction's tenor, real for a TIPS." },
|
|
125
|
+
{ key: "after1d", header: "+1d (bp)", align: "right" as const, format: bpMove },
|
|
126
|
+
{ key: "after5d", header: "+5d (bp)", align: "right" as const, format: bpMove },
|
|
127
|
+
{ key: "after20d", header: "+20d (bp)", align: "right" as const, format: bpMove },
|
|
128
|
+
{ key: "cusip", header: "CUSIP" },
|
|
129
|
+
];
|
|
130
|
+
|
|
131
|
+
/** The columns a board lists: a bill board heads its rate as the investment rate and puts the discount rate beside it. */
|
|
132
|
+
function columnsFor(view: AuctionView, auctions: readonly TreasuryAuction[]): HeadlessPaneColumn[] {
|
|
133
|
+
const rate = { ...LEAD_COLUMNS[3]!, textHeader: rateColumnLabel(auctions, "report") };
|
|
134
|
+
const discount = auctions.some(isBill) ? [DISCOUNT_RATE_COLUMN] : [];
|
|
135
|
+
// The spread is against the median from November 1998 and the average before: the heading says which the rows hold.
|
|
136
|
+
const results = RESULT_COLUMNS.map((column) => column.key === "stopOutVsAvgBp" ? { ...column, textHeader: stopOutColumnLabel(auctions, "report") } : column);
|
|
137
|
+
return [...LEAD_COLUMNS.slice(0, 3), rate, ...discount, ...view === "after" ? AFTER_COLUMNS : results];
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const AFTER_NOTE = "Percentiles rank each auction against its tenor's previous 24 (at least 12); the moves are the Treasury par yield "
|
|
141
|
+
+ "of its tenor (real for TIPS) from the auction day's close, in bp. Treasury par yields start in 1990, real yields in 2003.";
|
|
142
|
+
|
|
89
143
|
interface TreasuryAuctionsHeadlessDependencies {
|
|
90
144
|
load(args: HeadlessPaneLoadArgs, window: AuctionHistoryWindow): Promise<TreasuryAuctionsResult>;
|
|
145
|
+
curves(shown: readonly TreasuryAuction[], from: string | null): Promise<AuctionCurveRead>;
|
|
146
|
+
hk?(window: AuctionHistoryWindow): Promise<HkTendersResult>;
|
|
91
147
|
}
|
|
92
148
|
|
|
93
149
|
const defaultDependencies: TreasuryAuctionsHeadlessDependencies = {
|
|
94
150
|
load: (_args, window) => loadTreasuryAuctions(false, fetchTreasuryAuctions, window),
|
|
151
|
+
curves: (shown, from) => loadAuctionCurves(shown, from),
|
|
152
|
+
hk: (window) => loadHkTenders(false, window),
|
|
95
153
|
};
|
|
96
154
|
|
|
97
|
-
/** An empty table says what was searched, in which window, and what the search understands. */
|
|
155
|
+
/** An empty table says what was searched, in which window, and what the search understands; another market's paper, what AUCT covers. */
|
|
98
156
|
function emptyNote(query: string, filter: AuctionFilter, historyDays: AuctionHistoryWindow): string {
|
|
157
|
+
if (namesOtherMarket(query)) {
|
|
158
|
+
return `AUCT covers US Treasury auctions and Hong Kong government paper tenders (--market hk); "${query.trim()}" is neither. Search by ${AUCTION_SEARCH_FIELDS}.`;
|
|
159
|
+
}
|
|
99
160
|
const searched = query.trim() ? `match "${query.trim()}"` : "found";
|
|
100
161
|
const group = filter === "all" ? "" : ` in the ${filter} group`;
|
|
101
162
|
return `No auctions ${searched}${group} in ${auctionHistoryPhrase(historyDays)}. Search by ${AUCTION_SEARCH_FIELDS}.`;
|
|
102
163
|
}
|
|
103
164
|
|
|
104
|
-
|
|
165
|
+
/** The market `--market` names; without it Hong Kong's when the search names its paper (`HK 10Y`, `EFB`), else the US. */
|
|
166
|
+
function marketOf(args: Pick<HeadlessPaneLoadArgs, "argument" | "options">) {
|
|
167
|
+
if (isAuctionMarket(args.options.market)) return args.options.market;
|
|
168
|
+
return auctionSearchMarket(typeof args.argument === "string" ? args.argument : "").market ?? "us";
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export function createTreasuryAuctionsHeadless(
|
|
105
172
|
dependencies: TreasuryAuctionsHeadlessDependencies = defaultDependencies,
|
|
106
173
|
): HeadlessPaneDefinition<"rows"> {
|
|
107
174
|
return {
|
|
@@ -110,7 +177,7 @@ function createTreasuryAuctionsHeadless(
|
|
|
110
177
|
argument: {
|
|
111
178
|
kind: "free-text",
|
|
112
179
|
placeholder: "search",
|
|
113
|
-
description: "Optional search: security type, benchmark (10Y), term, CUSIP, or auction date (YYYY-MM-DD).",
|
|
180
|
+
description: "Optional search: security type, benchmark (10Y), term, CUSIP, or auction date (YYYY-MM-DD). HK, EFB or HKGB lists Hong Kong's tenders.",
|
|
114
181
|
optional: true,
|
|
115
182
|
},
|
|
116
183
|
options: [
|
|
@@ -119,61 +186,122 @@ function createTreasuryAuctionsHeadless(
|
|
|
119
186
|
aliases: ["history"],
|
|
120
187
|
settingKey: "historyDays",
|
|
121
188
|
description: `Auction history window in days, up to 3650 (10 years), or all: every auction since ${AUCTION_HISTORY_START}.`,
|
|
189
|
+
example: "--history-days 3650",
|
|
122
190
|
type: "enum",
|
|
123
191
|
values: AUCTION_HISTORY_WINDOWS.map((days) => ({ value: String(days) })),
|
|
124
192
|
defaultValue: "120",
|
|
125
193
|
},
|
|
194
|
+
{
|
|
195
|
+
key: "market",
|
|
196
|
+
// No default: a search naming HK, EFB or RMB picks hk unless --market says otherwise.
|
|
197
|
+
description: "us (without it, unless the search names Hong Kong's paper): US Treasury auctions; hk: Hong Kong government paper tenders (EF Bills and Notes, HKSAR Government Bonds) from HKMA's Open API. A search naming HK, EFB, HKGB or RMB picks hk.",
|
|
198
|
+
type: "enum",
|
|
199
|
+
values: AUCTION_MARKETS.map((entry) => ({ value: entry.value })),
|
|
200
|
+
example: "--market hk",
|
|
201
|
+
pluginState: { pluginId: FIXED_INCOME_VIEW_STATE.treasuryAuctions, key: "market" },
|
|
202
|
+
},
|
|
126
203
|
{
|
|
127
204
|
key: "filter",
|
|
128
|
-
description: "Security type group.",
|
|
205
|
+
description: "Security type group (Hong Kong: bill is EF Bills, note EF Notes, bond Government Bonds).",
|
|
129
206
|
type: "enum",
|
|
130
207
|
values: [{ value: "all" }, { value: "bill" }, { value: "note" }, { value: "bond" }],
|
|
131
208
|
defaultValue: "all",
|
|
132
209
|
pluginState: { pluginId: FIXED_INCOME_VIEW_STATE.treasuryAuctions, key: "activeTab" },
|
|
133
210
|
},
|
|
211
|
+
{
|
|
212
|
+
key: "view",
|
|
213
|
+
description: "results: each auction's figures; after: its B/C, indirect and dealer percentiles against the tenor's last 24 auctions, and the matching Treasury yield's change 1, 5 and 20 sessions later (bp).",
|
|
214
|
+
type: "enum",
|
|
215
|
+
values: AUCTION_VIEWS.map((value) => ({ value })),
|
|
216
|
+
defaultValue: "results",
|
|
217
|
+
example: "--view after",
|
|
218
|
+
pluginState: { pluginId: FIXED_INCOME_VIEW_STATE.treasuryAuctions, key: "view" },
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
key: "sort",
|
|
222
|
+
description: "Row order, by a column: largest first for a figure, newest first for date, A to Z for type, term and CUSIP. An after-view column (btc-pctl, 1d...) shows the after view.",
|
|
223
|
+
type: "enum",
|
|
224
|
+
values: AUCTION_SORT_NAMES.map((entry) => ({ value: entry.value, ...(entry.aliases ? { aliases: entry.aliases } : {}) })),
|
|
225
|
+
example: "--sort btc-pctl",
|
|
226
|
+
pluginState: { pluginId: FIXED_INCOME_VIEW_STATE.treasuryAuctions, key: "sortColumn" },
|
|
227
|
+
},
|
|
134
228
|
],
|
|
135
|
-
columns:
|
|
229
|
+
columns: columnsFor("results", []),
|
|
230
|
+
// A search naming Hong Kong (`shot AUCT HK 10Y`) opens the pane on its market, as `fn` reads it.
|
|
231
|
+
shotState: (args) => marketOf(args) === "hk" ? { pluginState: { [FIXED_INCOME_VIEW_STATE.treasuryAuctions]: { market: "hk" } } } : {},
|
|
136
232
|
describe: (args) => {
|
|
137
233
|
const window = auctionHistoryWindow({ historyDays: args.options.historyDays });
|
|
138
|
-
|
|
234
|
+
const hk = marketOf(args) === "hk";
|
|
235
|
+
return `${hk ? "Hong Kong Tenders" : "Treasury Auctions"} | ${window === AUCTION_HISTORY_ALL ? "all" : `${window} days`} | ${String(args.options.filter)}`;
|
|
139
236
|
},
|
|
140
237
|
async load(args) {
|
|
141
238
|
const historyDays = auctionHistoryWindow({ historyDays: args.options.historyDays });
|
|
142
239
|
const filter = args.options.filter as AuctionFilter;
|
|
143
|
-
|
|
240
|
+
if (marketOf(args) === "hk") {
|
|
241
|
+
return {
|
|
242
|
+
...hkTendersReport(await (dependencies.hk ?? defaultDependencies.hk!)(historyDays), {
|
|
243
|
+
search: typeof args.argument === "string" ? args.argument : "",
|
|
244
|
+
filter,
|
|
245
|
+
window: historyDays,
|
|
246
|
+
view: args.options.view === "after" ? "after" : "results",
|
|
247
|
+
sort: typeof args.options.sort === "string" ? args.options.sort : null,
|
|
248
|
+
}),
|
|
249
|
+
appliedOptions: { market: "hk" },
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
const sortColumn = typeof args.options.sort === "string" ? auctionSortColumn(args.options.sort) : null;
|
|
253
|
+
// A sort by an after-view column is a request for that view.
|
|
254
|
+
const view: AuctionView = args.options.view === "after" || (sortColumn && isAfterColumn(sortColumn)) ? "after" : "results";
|
|
255
|
+
const sort = sortColumn ? { columnId: sortColumn, direction: firstAuctionSortDirection(sortColumn) } : DEFAULT_AUCTION_SORT;
|
|
144
256
|
const query = typeof args.argument === "string" ? args.argument : "";
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
});
|
|
150
|
-
|
|
257
|
+
const from = view === "after" ? afterWindowStart(historyDays) : undefined;
|
|
258
|
+
// The after view reads more than it lists, until each listed tenor has its 24 before the oldest row (or ALL).
|
|
259
|
+
let window = view === "after" ? afterLoadWindow(historyDays) : historyDays;
|
|
260
|
+
let result = await dependencies.load(args, window);
|
|
261
|
+
let listed = visibleAuctions(result.auctions, { filter, query, sort: DEFAULT_AUCTION_SORT, from });
|
|
262
|
+
for (let wider = view === "after" ? widerAfterWindow(listed, result.auctions, window) : null; wider;
|
|
263
|
+
wider = widerAfterWindow(listed, result.auctions, window)) {
|
|
264
|
+
window = wider;
|
|
265
|
+
result = await dependencies.load(args, window);
|
|
266
|
+
listed = visibleAuctions(result.auctions, { filter, query, sort: DEFAULT_AUCTION_SORT, from });
|
|
267
|
+
}
|
|
268
|
+
const curves = view === "after" ? await dependencies.curves(listed, from ?? null) : null;
|
|
269
|
+
const after = curves ? projectAuctionAfter(listed, result.auctions, curves.curves) : null;
|
|
270
|
+
const auctions = sortColumn ? visibleAuctions(listed, { filter: "all", query: "", sort, ...(after ? { after } : {}) }) : listed;
|
|
151
271
|
const notes = [
|
|
152
272
|
...(auctions.length === 0 ? [emptyNote(query, filter, historyDays)] : []),
|
|
153
|
-
//
|
|
154
|
-
...(
|
|
155
|
-
|
|
273
|
+
// Only where a longer window could list more: never past ALL, for another market, or for a CUSIP whose first auction is listed.
|
|
274
|
+
...(nextAuctionHistoryWindow(historyDays) && widerWindowCouldAdd(query, auctions, historyDays)
|
|
275
|
+
? [`Older auctions: use --history-days ${nextAuctionHistoryWindow(historyDays)}.`] : []),
|
|
276
|
+
...(auctions.length > 0 && view === "results" ? [STOP_OUT_NOTE] : []),
|
|
277
|
+
...(auctions.length > 0 && view === "after" ? [AFTER_NOTE] : []),
|
|
156
278
|
...(auctions.some(lacksMetrics) ? [MISSING_METRICS_NOTE] : []),
|
|
157
279
|
];
|
|
158
280
|
return {
|
|
159
|
-
complete: !result.refreshError,
|
|
281
|
+
complete: !result.refreshError && !curves?.errors.length,
|
|
160
282
|
// A saved copy answering the failed refresh ends the report by saying when it was saved instead.
|
|
161
|
-
errors: [unansweredRefreshError(result)].filter((error): error is string => !!error),
|
|
283
|
+
errors: [unansweredRefreshError(result), ...curves?.errors ?? []].filter((error): error is string => !!error),
|
|
162
284
|
notes,
|
|
285
|
+
columns: columnsFor(view, auctions),
|
|
163
286
|
rows: auctions.map((auction) => ({
|
|
164
287
|
...auction,
|
|
165
288
|
rate: rateValue(auction),
|
|
166
|
-
stopOutVsAvgBp:
|
|
289
|
+
stopOutVsAvgBp: stopOutVsAvgBp(auction),
|
|
167
290
|
indirectPercent: indirectPct(auction),
|
|
168
291
|
directPercent: directPct(auction),
|
|
169
292
|
dealerPercent: dealerPct(auction),
|
|
170
293
|
size: auctionSize(auction),
|
|
294
|
+
...(after ? after.get(auction.id) : {}),
|
|
171
295
|
})),
|
|
296
|
+
appliedOptions: { market: "us" },
|
|
172
297
|
metadata: {
|
|
173
298
|
fetchedAt: result.fetchedAt,
|
|
174
299
|
stale: result.stale,
|
|
300
|
+
market: "us",
|
|
175
301
|
historyDays,
|
|
176
302
|
filter,
|
|
303
|
+
view,
|
|
304
|
+
...(sortColumn ? { sort: args.options.sort } : {}),
|
|
177
305
|
},
|
|
178
306
|
};
|
|
179
307
|
},
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import type { HkTender } from "../../../api-client/hk-tenders";
|
|
2
|
+
import { unansweredRefreshError } from "../../../data/saved-copies";
|
|
3
|
+
import type { HeadlessPaneColumn, HeadlessPaneFreshness, HeadlessRowsResult } from "../../../types/headless";
|
|
4
|
+
import { AUCTION_HISTORY_ALL, type AuctionHistoryWindow } from "./client";
|
|
5
|
+
import {
|
|
6
|
+
DEFAULT_HK_SORT,
|
|
7
|
+
firstHkSortDirection,
|
|
8
|
+
formatHkAmount,
|
|
9
|
+
formatHkRate,
|
|
10
|
+
HK_SEARCH_FIELDS,
|
|
11
|
+
hkDateText,
|
|
12
|
+
hkRate,
|
|
13
|
+
hkSize,
|
|
14
|
+
hkSizeWorkedOut,
|
|
15
|
+
hkSortColumn,
|
|
16
|
+
hkTenderType,
|
|
17
|
+
hkWindowStart,
|
|
18
|
+
isSpread,
|
|
19
|
+
visibleHkTenders,
|
|
20
|
+
type HkTendersResult,
|
|
21
|
+
} from "./hk";
|
|
22
|
+
import { auctionHistoryPhrase, nextAuctionHistoryWindow, type AuctionFilter } from "./model";
|
|
23
|
+
|
|
24
|
+
const tender = (row: Record<string, unknown>) => row as unknown as HkTender;
|
|
25
|
+
const rate = (value: unknown, row: Record<string, unknown>) => formatHkRate(tender(row), value == null ? null : Number(value), "-");
|
|
26
|
+
/** The text says what a floating rate note's figure is, as a US FRN's does; the export keeps the number. */
|
|
27
|
+
const rateText = (value: unknown, row: Record<string, unknown>) => `${rate(value, row)}${value != null && isSpread(tender(row)) ? " spread" : ""}`;
|
|
28
|
+
|
|
29
|
+
const HK_COLUMNS: HeadlessPaneColumn[] = [
|
|
30
|
+
{ key: "date", header: "Date", description: "Issue day, the business day after the tender; a Government Bond's issue month, all HKMA's figures give." },
|
|
31
|
+
{ key: "type", header: "Type", description: "EFB: Exchange Fund Bills; EFN: Exchange Fund Notes; HKGB: Government Bond; FRN: its HONIA-indexed floating rate note." },
|
|
32
|
+
{ key: "term", header: "Term" },
|
|
33
|
+
{
|
|
34
|
+
key: "rate", header: "Rate", align: "right", format: rate, textFormat: rateText,
|
|
35
|
+
description: "Average accepted yield (an RMB bond's annualised); a floating rate note's spread over HONIA, in bp.",
|
|
36
|
+
},
|
|
37
|
+
{ key: "bidToCover", header: "B/C", align: "right", format: (value: unknown) => value == null ? "" : Number(value).toFixed(2) },
|
|
38
|
+
{
|
|
39
|
+
// Exports write the bare amount, each row's currency (HKD or CNH) beside it.
|
|
40
|
+
key: "size", header: "Size", align: "right", unitKey: "currency",
|
|
41
|
+
description: "A bond's amount allotted; EF paper's amount offered, worked out from its applications and over-subscription (≈).",
|
|
42
|
+
format: (value: unknown) => value == null ? "" : String(value),
|
|
43
|
+
textFormat: (value: unknown, row: Record<string, unknown>) =>
|
|
44
|
+
formatHkAmount(tender(row), value == null ? null : Number(value), "-", hkSizeWorkedOut(tender(row))),
|
|
45
|
+
},
|
|
46
|
+
{ key: "issue", header: "Issue", format: (value: unknown) => value == null ? "" : String(value) },
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
const HK_NOTE = "Hong Kong tenders are the Hong Kong Monetary Authority's tender figures from its Open API (Source: HKMA): "
|
|
50
|
+
+ "EF Bills and Notes and HKSAR institutional Government Bonds, dated by issue (a bond by its month). "
|
|
51
|
+
+ "EF paper's B/C is one plus HKMA's over-subscription, and its size the amount offered that implies (≈).";
|
|
52
|
+
|
|
53
|
+
const HK_FRESHNESS: HeadlessPaneFreshness = {
|
|
54
|
+
source: "HKMA", publisher: "Hong Kong Monetary Authority", status: "not-a-feed", basis: "monthly tender figures", observedKey: "date", oldest: null,
|
|
55
|
+
tradingDayMarket: "HK",
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/** An empty list says what was searched, in which window, and what the search understands. */
|
|
59
|
+
function emptyNote(search: string, filter: AuctionFilter, window: AuctionHistoryWindow): string {
|
|
60
|
+
const searched = search.trim() ? `match "${search.trim()}"` : "found";
|
|
61
|
+
const group = filter === "all" ? "" : ` in the ${filter} group`;
|
|
62
|
+
const phrase = window === AUCTION_HISTORY_ALL ? "every tender on record" : auctionHistoryPhrase(window);
|
|
63
|
+
return `No Hong Kong tenders ${searched}${group} in ${phrase}. Search by ${HK_SEARCH_FIELDS}.`;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* HKMA publishes these figures a month at a time, after the tenders: how far
|
|
69
|
+
* each paper's run, so a missing recent tender reads as not published yet.
|
|
70
|
+
*/
|
|
71
|
+
function hkRunsToNote(runsTo: HkTendersResult["runsTo"]): string | null {
|
|
72
|
+
const parts = [
|
|
73
|
+
runsTo.efb && `${hkDateText(runsTo.efb)} for EF Bills`,
|
|
74
|
+
runsTo.efn && `${hkDateText(runsTo.efn)} for EF Notes`,
|
|
75
|
+
runsTo.hkgb && `${hkDateText(runsTo.hkgb)} for Government Bonds`,
|
|
76
|
+
].filter(Boolean);
|
|
77
|
+
return parts.length ? `HKMA publishes its tender figures monthly; they run to ${parts.join(", ")}.` : null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** `fn AUCT --market hk` (or a search naming Hong Kong's paper): HKMA's tender figures, in the AUCT report's shape. */
|
|
81
|
+
export function hkTendersReport(
|
|
82
|
+
result: HkTendersResult,
|
|
83
|
+
options: { search: string; filter: AuctionFilter; window: AuctionHistoryWindow; view: "results" | "after"; sort: string | null },
|
|
84
|
+
): HeadlessRowsResult {
|
|
85
|
+
const { search, filter, window } = options;
|
|
86
|
+
const sortColumn = options.sort ? hkSortColumn(options.sort) : null;
|
|
87
|
+
const sort = sortColumn ? { columnId: sortColumn, direction: firstHkSortDirection(sortColumn) } : DEFAULT_HK_SORT;
|
|
88
|
+
const from = hkWindowStart(window);
|
|
89
|
+
const tenders = visibleHkTenders(result.tenders, { filter, query: search, sort, from });
|
|
90
|
+
const next = nextAuctionHistoryWindow(window);
|
|
91
|
+
// A wider window adds rows only where the record goes back past this one's start.
|
|
92
|
+
const widerAdds = !!next && !!from && !!result.firstTender && result.firstTender < from;
|
|
93
|
+
const runsTo = hkRunsToNote(result.runsTo);
|
|
94
|
+
const notes = [
|
|
95
|
+
...(tenders.length === 0 ? [emptyNote(search, filter, window)] : []),
|
|
96
|
+
...(widerAdds ? [`Older tenders: use --history-days ${next}.`] : []),
|
|
97
|
+
...(options.view === "after" ? ["The after view ranks US Treasury auctions; Hong Kong tenders list their results."] : []),
|
|
98
|
+
...(options.sort && !sortColumn ? [`--sort ${options.sort} is a US Treasury column; Hong Kong tenders are listed newest first.`] : []),
|
|
99
|
+
...(tenders.length > 0 ? [HK_NOTE] : []),
|
|
100
|
+
...(runsTo ? [runsTo] : []),
|
|
101
|
+
];
|
|
102
|
+
return {
|
|
103
|
+
complete: !result.refreshError && !result.truncated,
|
|
104
|
+
errors: [unansweredRefreshError(result)].filter((error): error is string => !!error),
|
|
105
|
+
notes,
|
|
106
|
+
columns: HK_COLUMNS,
|
|
107
|
+
rowUnitKey: "currency",
|
|
108
|
+
rows: tenders.map((entry) => ({
|
|
109
|
+
...entry,
|
|
110
|
+
type: hkTenderType(entry),
|
|
111
|
+
rate: hkRate(entry),
|
|
112
|
+
size: hkSize(entry),
|
|
113
|
+
})),
|
|
114
|
+
freshness: HK_FRESHNESS,
|
|
115
|
+
metadata: {
|
|
116
|
+
fetchedAt: result.fetchedAt,
|
|
117
|
+
stale: result.stale,
|
|
118
|
+
market: "hk",
|
|
119
|
+
historyDays: window,
|
|
120
|
+
filter,
|
|
121
|
+
runsTo: result.runsTo,
|
|
122
|
+
firstTender: result.firstTender,
|
|
123
|
+
...(sortColumn ? { sort: options.sort } : {}),
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
}
|