gloomberb 0.20.5 → 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 +1 -1
- package/README.zh-CN.md +1 -1
- package/package.json +2 -1
- package/src/api-client/data.ts +10 -2
- package/src/api-client/hk-tenders.ts +59 -0
- package/src/api-client/index.ts +1 -0
- package/src/api-client/types/econ.ts +20 -2
- package/src/app.tsx +18 -13
- package/src/architecture/floating-promise-allowlist.json +313 -0
- package/src/cli/commands/market.ts +164 -40
- package/src/cli/commands/news-search.ts +22 -7
- package/src/cli/commands/overview.ts +12 -6
- 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 +76 -12
- package/src/cli/fx-pair.ts +1 -1
- package/src/cli/fx-quote-rate.ts +23 -0
- package/src/cli/help.ts +1 -0
- package/src/cli/index-roots.ts +5 -4
- package/src/cli/index.ts +40 -3
- package/src/cli/known-gaps.ts +11 -8
- package/src/cli/listing-arg.ts +6 -4
- 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/workflow/tickers.ts +2 -2
- package/src/components/data-table/view.tsx +9 -2
- 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/table-layout.ts +38 -1
- package/src/docs/snapshot.json +3 -3
- package/src/market-data/market/change-basis.ts +9 -5
- package/src/market-data/market/dated-previous-close.ts +57 -6
- 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/backtest/headless.ts +1 -1
- 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 +2 -1
- package/src/plugins/builtin/chart-composer/presets.ts +1 -0
- package/src/plugins/builtin/cloud/askg/pane.tsx +55 -13
- 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/econ/calendar-model.ts +41 -7
- package/src/plugins/builtin/econ/calendar-source.ts +7 -1
- package/src/plugins/builtin/econ/index.tsx +41 -8
- package/src/plugins/builtin/econ/types.ts +3 -0
- package/src/plugins/builtin/fixed-income/index.tsx +2 -0
- package/src/plugins/builtin/fx-matrix/index.tsx +44 -14
- package/src/plugins/builtin/help/keybindings-editor.tsx +6 -2
- 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/research/headless-schema.ts +4 -3
- 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/thirteenf/api.ts +47 -4
- 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 +6 -2
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +1 -1
- package/src/plugins/builtin/ticker-detail/headless.ts +6 -4
- package/src/plugins/builtin/treasury-auctions/cache.ts +36 -2
- package/src/plugins/builtin/treasury-auctions/headless.ts +42 -4
- 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 +14 -1
- package/src/plugins/builtin/treasury-auctions/model.ts +16 -8
- package/src/plugins/builtin/treasury-auctions/pane.tsx +45 -21
- package/src/portfolio/collection-name.ts +22 -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/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/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 +9 -5
- 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 +6 -0
- package/src/types/headless.ts +8 -0
- package/src/utils/cli-output.ts +6 -3
- package/src/utils/ebitda.ts +128 -0
- package/src/utils/format.ts +1 -1
- package/src/utils/shell-word.ts +13 -0
|
@@ -2,7 +2,7 @@ import { BAR_INTERVAL_LABELS } from "../../../../cli/history-rows";
|
|
|
2
2
|
import { periodToDateText } from "../../../../cli/pane-functions/freshness";
|
|
3
3
|
import { barLastSession, barPeriodToDate, type BarPeriod, type BarPeriodToDate } from "../../../../market-data/market/bar-period";
|
|
4
4
|
import { isIntradayDailyBar } from "../../../../market-data/market/period-return";
|
|
5
|
-
import { barSizeFromGap, medianBarGap } from "../../../../time-series/bar-spacing";
|
|
5
|
+
import { barSizeFromGap, medianBarGap, requestedBarSize } from "../../../../time-series/bar-spacing";
|
|
6
6
|
import type { TimeRange } from "../../../../time-series/range";
|
|
7
7
|
import { CHART_RESOLUTION_STEP_MS, type ManualChartResolution } from "../../../../time-series/resolution";
|
|
8
8
|
|
|
@@ -23,13 +23,16 @@ const INTRADAY_BELOW_MS = 0.8 * CHART_RESOLUTION_STEP_MS["1d"];
|
|
|
23
23
|
/**
|
|
24
24
|
* The bar size of a history, read from the usual spacing of its bars
|
|
25
25
|
* (medianBarGap), as `history` reads it, so the gap a holiday leaves does not
|
|
26
|
-
* make daily bars weekly. Daily when there is no gap to read.
|
|
26
|
+
* make daily bars weekly. Daily when there is no gap to read. Daily or longer
|
|
27
|
+
* bars asked for in a size (`requested`, the range's) are that size unless
|
|
28
|
+
* the bars show otherwise (requestedBarSize).
|
|
27
29
|
*/
|
|
28
|
-
export function historyBarSize(times: readonly number[]): HistoryBarSize {
|
|
30
|
+
export function historyBarSize(times: readonly number[], requested?: ManualChartResolution | null): HistoryBarSize {
|
|
29
31
|
const gap = medianBarGap(times);
|
|
30
|
-
if (gap == null) return "1d";
|
|
32
|
+
if (gap == null) return requested ?? "1d";
|
|
31
33
|
if (gap < INTRADAY_BELOW_MS) return INTRADAY_SIZES.find((size) => CHART_RESOLUTION_STEP_MS[size] === gap) ?? "intraday";
|
|
32
|
-
|
|
34
|
+
// Daily or longer bars of a range are the size it asks for: a thin listing's daily bars a week apart are not weekly.
|
|
35
|
+
return requested && isDailyOrLongerBar(requested) ? requestedBarSize(times, requested) : barSizeFromGap(gap);
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
/** Whether a bar of this size covers a day or more, so its date is a day and not a time. */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { FinancialStatement, TickerFinancials } from "../../../../types/financials";
|
|
2
|
+
import { ebitdaLacksDepreciation } from "../../../../utils/ebitda";
|
|
2
3
|
import { fiscalPeriodLabel, ttmPeriodLabel } from "../../../../utils/fiscal-period";
|
|
3
4
|
import { formatPerShareNumber } from "../../../../utils/reported-money";
|
|
4
5
|
import { hasNonIncomeStatementGap } from "../../../../utils/statement-gaps";
|
|
@@ -193,8 +194,11 @@ function formatFinancialGrowth(growth: number): string {
|
|
|
193
194
|
|
|
194
195
|
export function formatFinancialValue(
|
|
195
196
|
value: number | undefined,
|
|
196
|
-
row: Pick<FinancialTableRow, "format" | "divisor"
|
|
197
|
+
row: Pick<FinancialTableRow, "format" | "divisor"> & { key?: string },
|
|
198
|
+
statement?: FinancialStatement,
|
|
197
199
|
): string {
|
|
200
|
+
// EBITDA is operating income plus D&A: a period that reports no D&A has none, and its cell says why.
|
|
201
|
+
if ((value == null || !Number.isFinite(value)) && row.key === "ebitda" && ebitdaLacksDepreciation(statement)) return "no D&A";
|
|
198
202
|
if (value == null || !Number.isFinite(value)) return "—";
|
|
199
203
|
if (row.format === "eps") return formatPerShareNumber(value);
|
|
200
204
|
if (row.format === "percent") return `${formatNumber(value * 100, 1)}%`;
|
|
@@ -641,7 +645,7 @@ export function buildFinancialTableModel(
|
|
|
641
645
|
|| !canCompareFinancialRow(row, statement, previous, comparisonCurrency)
|
|
642
646
|
? undefined : computeGrowth(value, previousValue);
|
|
643
647
|
return {
|
|
644
|
-
...formatFinancialCell(formatFinancialValue(value, row), growth),
|
|
648
|
+
...formatFinancialCell(formatFinancialValue(value, row, statement), growth),
|
|
645
649
|
value,
|
|
646
650
|
growth,
|
|
647
651
|
semanticGrowth: semanticGrowthValue(growth, row.growthDirection),
|
|
@@ -385,7 +385,7 @@ export function ResolvedFinancialsTab({
|
|
|
385
385
|
const growth = (row.kind === "metric" && !row.showGrowth)
|
|
386
386
|
|| !canCompareFinancialRow(row, column.statement, previous, comparisonCurrency)
|
|
387
387
|
? undefined : computeGrowth(value, previousValue);
|
|
388
|
-
const formattedValue = formatFinancialValue(value, row);
|
|
388
|
+
const formattedValue = formatFinancialValue(value, row, column.statement);
|
|
389
389
|
const cell = formatFinancialCell(formattedValue, growth);
|
|
390
390
|
const growthColorValue = semanticGrowthValue(growth, row.growthDirection);
|
|
391
391
|
|
|
@@ -48,10 +48,10 @@ import { formatUtcTime } from "../../../utils/utc-time";
|
|
|
48
48
|
import { closeMoves } from "../../../utils/max-drawdown";
|
|
49
49
|
import { isYieldIndexSymbol } from "../../../tickers/index-roots";
|
|
50
50
|
import { parsePublicTickerKey } from "../../../utils/exchanges";
|
|
51
|
-
import { isPastPriceWindow, loadPriceWindowHistory, priceWindowText, readPriceWindow, type PriceWindow } from "../../../utils/price-window";
|
|
51
|
+
import { isPastPriceWindow, loadPriceWindowHistory, priceWindowInterval, priceWindowText, readPriceWindow, type PriceWindow } from "../../../utils/price-window";
|
|
52
52
|
import { historyCoverageNotice } from "../../../sources/history-coverage";
|
|
53
53
|
import { getChartResolutionLabel, isIntradayResolution, RANGE_HISTORY_RESOLUTION, type ManualChartResolution } from "../../../time-series/resolution";
|
|
54
|
-
import { DAY_SO_FAR_TEXT, withSessionBar } from "../../../time-series/session-bar";
|
|
54
|
+
import { DAY_SO_FAR_TEXT, requestedSessionBarSize, withSessionBar } from "../../../time-series/session-bar";
|
|
55
55
|
import { buildReturnRows, closedMarketNote, isTodayReturnRow, returnBaseCloseDay, type ReturnRange } from "./data-panes/returns-model";
|
|
56
56
|
import { periodBaseText } from "../../../market-data/market/period-return";
|
|
57
57
|
import { loadReturnSeries } from "./data-panes/returns-history";
|
|
@@ -417,7 +417,9 @@ export const historicalPricesHeadless: HeadlessPaneDefinition<"rows"> = {
|
|
|
417
417
|
// The venue whose sessions say whether a day, week or month is still running: the key's, or for a bare symbol its quote's.
|
|
418
418
|
const venue = exchange || quote?.listingExchangeName || quote?.exchangeName || undefined;
|
|
419
419
|
const now = Date.now();
|
|
420
|
-
|
|
420
|
+
// The bars the range or window asks for: a thin listing's daily bars a week or two apart are still daily.
|
|
421
|
+
const requested = window ? priceWindowInterval(window) : RANGE_HISTORY_RESOLUTION[range];
|
|
422
|
+
const points = withSessionBar(loaded, quote, { now, venue, ...requestedSessionBarSize(loaded, requested) });
|
|
421
423
|
// Providers serve float32 prices (4013.39990234 for 4013.4): the rows hold the decimal each is, as `history` does,
|
|
422
424
|
// a London line's cleaned in the pence it was priced in.
|
|
423
425
|
const priceDivisor = quotedPriceDivisor(quote);
|
|
@@ -436,7 +438,7 @@ export const historicalPricesHeadless: HeadlessPaneDefinition<"rows"> = {
|
|
|
436
438
|
};
|
|
437
439
|
}).sort((left, right) => left.date.localeCompare(right.date));
|
|
438
440
|
const notice = priceHistoryIntegrityNotice(rows.filter((row) => row.integrity).length);
|
|
439
|
-
const size = historyBarSize(rows.map((row) => Date.parse(row.date)));
|
|
441
|
+
const size = historyBarSize(rows.map((row) => Date.parse(row.date)), requested);
|
|
440
442
|
// A weekly or monthly bar whose period runs on is dated by how far it runs, as `history` dates it.
|
|
441
443
|
const forming = formingHistoryBar(size, rows.at(-1)?.date, venue, now);
|
|
442
444
|
// A complete one is dated by the day its last session closed, the day its close is from.
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
AUCTION_ARCHIVE_PAGE_SIZE, AUCTION_HISTORY_ALL, AUCTION_HISTORY_DAYS, AUCTION_HISTORY_START, auctionArchiveBoundary,
|
|
7
7
|
auctionWindowQuery, fetchTreasuryAuctions, type AuctionHistoryWindow, type AuctionQuery,
|
|
8
8
|
} from "./client";
|
|
9
|
-
import { mergeAuctionSources } from "./model";
|
|
9
|
+
import { isPendingAuction, mergeAuctionSources } from "./model";
|
|
10
10
|
import { DIRECT_LOOKBACK_DAYS, fetchDirectAuctions } from "./treasury-direct";
|
|
11
11
|
import type { TreasuryAuction } from "./types";
|
|
12
12
|
|
|
@@ -127,9 +127,12 @@ async function loadRecentBoard(
|
|
|
127
127
|
direct: { days: number; load: DirectLoader } | null,
|
|
128
128
|
from: () => string,
|
|
129
129
|
): Promise<TreasuryAuctionsResult> {
|
|
130
|
+
const directKey = direct && `direct:${direct.days}`;
|
|
131
|
+
const unchanged = force ? null : savedRecentBoard(fiscalKey, directKey, from());
|
|
132
|
+
if (unchanged) return unchanged;
|
|
130
133
|
const [primary, supplement] = await Promise.all([
|
|
131
134
|
answer(cache.load(fiscalKey, walk(FISCAL_DATA, fiscal), { force })),
|
|
132
|
-
direct ? answer(directCache.load(
|
|
135
|
+
direct && directKey ? answer(directCache.load(directKey, walk(TREASURY_DIRECT, () => direct.load(direct.days)), { force })) : null,
|
|
133
136
|
]);
|
|
134
137
|
if ("failed" in primary && (!supplement || "failed" in supplement)) throw primary.failed;
|
|
135
138
|
|
|
@@ -147,6 +150,37 @@ async function loadRecentBoard(
|
|
|
147
150
|
};
|
|
148
151
|
}
|
|
149
152
|
|
|
153
|
+
/** A New York day (YYYY-MM-DD): an auction closes on it and its results come out that afternoon. */
|
|
154
|
+
const newYorkDay = new Intl.DateTimeFormat("en-CA", { timeZone: "America/New_York", year: "numeric", month: "2-digit", day: "2-digit" });
|
|
155
|
+
|
|
156
|
+
/** An announced auction whose day has come in the last week: its results may be out by now. */
|
|
157
|
+
function comeDue(auction: TreasuryAuction, today: string, weekAgo: string): boolean {
|
|
158
|
+
return isPendingAuction(auction) && auction.auctionDate <= today && auction.auctionDate >= weekAgo;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* A command's recent board as an earlier run saved both sources' copies, while
|
|
163
|
+
* they are within the hour the app refreshes them in and no auction they list
|
|
164
|
+
* has come due since: results in do not change, so asking again could add only
|
|
165
|
+
* an auction announced within that hour, which the app waits as long for. A
|
|
166
|
+
* command otherwise asks both sources again (saved-copy-persistence.ts), a
|
|
167
|
+
* second or more each run; an auction due today is asked for until its
|
|
168
|
+
* results are in. The app's own cache already answers from a fresh copy, and
|
|
169
|
+
* keeps the failure of a refresh, so only a run that has read nothing yet
|
|
170
|
+
* (a command) looks here.
|
|
171
|
+
*/
|
|
172
|
+
function savedRecentBoard(fiscalKey: string, directKey: string | null, from: string, now = Date.now()): TreasuryAuctionsResult | null {
|
|
173
|
+
if (cache.get(fiscalKey)) return null;
|
|
174
|
+
const fiscal = cache.get(fiscalKey, { allowExpired: true });
|
|
175
|
+
const direct = directKey ? directCache.get(directKey, { allowExpired: true }) : null;
|
|
176
|
+
if (!fiscal || fiscal.stale || (directKey && (!direct || direct.stale))) return null;
|
|
177
|
+
const auctions = mergeAuctionSources(fiscal.data, direct?.data ?? [], from);
|
|
178
|
+
const today = newYorkDay.format(now);
|
|
179
|
+
const weekAgo = newYorkDay.format(now - 7 * 86_400_000);
|
|
180
|
+
if (auctions.some((auction) => comeDue(auction, today, weekAgo))) return null;
|
|
181
|
+
return { auctions, fetchedAt: Math.min(fiscal.fetchedAt, direct?.fetchedAt ?? Infinity), stale: false };
|
|
182
|
+
}
|
|
183
|
+
|
|
150
184
|
export async function loadTreasuryAuctions(
|
|
151
185
|
force = false,
|
|
152
186
|
loader: AuctionLoader = fetchTreasuryAuctions,
|
|
@@ -11,6 +11,8 @@ import { AUCTION_HISTORY_ALL, AUCTION_HISTORY_START, fetchTreasuryAuctions, type
|
|
|
11
11
|
import { loadTreasuryAuctions, type TreasuryAuctionsResult } from "./cache";
|
|
12
12
|
import { unansweredRefreshError } from "../../../data/saved-copies";
|
|
13
13
|
import type { TreasuryAuction } from "./types";
|
|
14
|
+
import { AUCTION_MARKETS, auctionSearchMarket, isAuctionMarket, loadHkTenders, type HkTendersResult } from "./hk";
|
|
15
|
+
import { hkTendersReport } from "./hk-headless";
|
|
14
16
|
import { FIXED_INCOME_VIEW_STATE } from "../fixed-income/model";
|
|
15
17
|
import {
|
|
16
18
|
AUCTION_HISTORY_WINDOWS,
|
|
@@ -141,21 +143,31 @@ const AFTER_NOTE = "Percentiles rank each auction against its tenor's previous 2
|
|
|
141
143
|
interface TreasuryAuctionsHeadlessDependencies {
|
|
142
144
|
load(args: HeadlessPaneLoadArgs, window: AuctionHistoryWindow): Promise<TreasuryAuctionsResult>;
|
|
143
145
|
curves(shown: readonly TreasuryAuction[], from: string | null): Promise<AuctionCurveRead>;
|
|
146
|
+
hk?(window: AuctionHistoryWindow): Promise<HkTendersResult>;
|
|
144
147
|
}
|
|
145
148
|
|
|
146
149
|
const defaultDependencies: TreasuryAuctionsHeadlessDependencies = {
|
|
147
150
|
load: (_args, window) => loadTreasuryAuctions(false, fetchTreasuryAuctions, window),
|
|
148
151
|
curves: (shown, from) => loadAuctionCurves(shown, from),
|
|
152
|
+
hk: (window) => loadHkTenders(false, window),
|
|
149
153
|
};
|
|
150
154
|
|
|
151
155
|
/** An empty table says what was searched, in which window, and what the search understands; another market's paper, what AUCT covers. */
|
|
152
156
|
function emptyNote(query: string, filter: AuctionFilter, historyDays: AuctionHistoryWindow): string {
|
|
153
|
-
if (namesOtherMarket(query))
|
|
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
|
+
}
|
|
154
160
|
const searched = query.trim() ? `match "${query.trim()}"` : "found";
|
|
155
161
|
const group = filter === "all" ? "" : ` in the ${filter} group`;
|
|
156
162
|
return `No auctions ${searched}${group} in ${auctionHistoryPhrase(historyDays)}. Search by ${AUCTION_SEARCH_FIELDS}.`;
|
|
157
163
|
}
|
|
158
164
|
|
|
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
|
+
|
|
159
171
|
export function createTreasuryAuctionsHeadless(
|
|
160
172
|
dependencies: TreasuryAuctionsHeadlessDependencies = defaultDependencies,
|
|
161
173
|
): HeadlessPaneDefinition<"rows"> {
|
|
@@ -165,7 +177,7 @@ export function createTreasuryAuctionsHeadless(
|
|
|
165
177
|
argument: {
|
|
166
178
|
kind: "free-text",
|
|
167
179
|
placeholder: "search",
|
|
168
|
-
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.",
|
|
169
181
|
optional: true,
|
|
170
182
|
},
|
|
171
183
|
options: [
|
|
@@ -179,9 +191,18 @@ export function createTreasuryAuctionsHeadless(
|
|
|
179
191
|
values: AUCTION_HISTORY_WINDOWS.map((days) => ({ value: String(days) })),
|
|
180
192
|
defaultValue: "120",
|
|
181
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
|
+
},
|
|
182
203
|
{
|
|
183
204
|
key: "filter",
|
|
184
|
-
description: "Security type group.",
|
|
205
|
+
description: "Security type group (Hong Kong: bill is EF Bills, note EF Notes, bond Government Bonds).",
|
|
185
206
|
type: "enum",
|
|
186
207
|
values: [{ value: "all" }, { value: "bill" }, { value: "note" }, { value: "bond" }],
|
|
187
208
|
defaultValue: "all",
|
|
@@ -206,13 +227,28 @@ export function createTreasuryAuctionsHeadless(
|
|
|
206
227
|
},
|
|
207
228
|
],
|
|
208
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" } } } : {},
|
|
209
232
|
describe: (args) => {
|
|
210
233
|
const window = auctionHistoryWindow({ historyDays: args.options.historyDays });
|
|
211
|
-
|
|
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)}`;
|
|
212
236
|
},
|
|
213
237
|
async load(args) {
|
|
214
238
|
const historyDays = auctionHistoryWindow({ historyDays: args.options.historyDays });
|
|
215
239
|
const filter = args.options.filter as AuctionFilter;
|
|
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
|
+
}
|
|
216
252
|
const sortColumn = typeof args.options.sort === "string" ? auctionSortColumn(args.options.sort) : null;
|
|
217
253
|
// A sort by an after-view column is a request for that view.
|
|
218
254
|
const view: AuctionView = args.options.view === "after" || (sortColumn && isAfterColumn(sortColumn)) ? "after" : "results";
|
|
@@ -257,9 +293,11 @@ export function createTreasuryAuctionsHeadless(
|
|
|
257
293
|
size: auctionSize(auction),
|
|
258
294
|
...(after ? after.get(auction.id) : {}),
|
|
259
295
|
})),
|
|
296
|
+
appliedOptions: { market: "us" },
|
|
260
297
|
metadata: {
|
|
261
298
|
fetchedAt: result.fetchedAt,
|
|
262
299
|
stale: result.stale,
|
|
300
|
+
market: "us",
|
|
263
301
|
historyDays,
|
|
264
302
|
filter,
|
|
265
303
|
view,
|
|
@@ -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
|
+
}
|