@gloom-sh/terminal 0.20.11 → 0.20.12

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.
Files changed (242) hide show
  1. package/package.json +2 -1
  2. package/src/api-client/awards.ts +16 -0
  3. package/src/api-client/central-bank-rates.ts +5 -0
  4. package/src/api-client/data.ts +55 -2
  5. package/src/api-client/index.ts +18 -1
  6. package/src/api-client/request.ts +86 -3
  7. package/src/api-client/socket-connection.ts +12 -1
  8. package/src/api-client/socket.ts +21 -3
  9. package/src/api-client/supply-chain-graph.ts +4 -2
  10. package/src/api-client/supply-chain.ts +8 -0
  11. package/src/api-client/types/econ.ts +10 -7
  12. package/src/api-client/types/filings-and-calls.ts +8 -0
  13. package/src/app/global-shortcuts.ts +2 -1
  14. package/src/app/keybindings/actions.ts +19 -0
  15. package/src/app/pane-runtime/index.tsx +18 -3
  16. package/src/app/pane-runtime/layout-placement.ts +63 -0
  17. package/src/app/pane-runtime/ticker-open-runtime.ts +10 -2
  18. package/src/capabilities/chart-series.ts +4 -1
  19. package/src/cli/board-coins.ts +10 -1
  20. package/src/cli/commands/crypto-hints.ts +3 -2
  21. package/src/cli/commands/fred-series.ts +0 -54
  22. package/src/cli/commands/market.ts +209 -31
  23. package/src/cli/commands/overview.ts +47 -14
  24. package/src/cli/commands/search.ts +37 -8
  25. package/src/cli/commands/ticker.ts +15 -4
  26. package/src/cli/desktop-pane-shot.ts +27 -2
  27. package/src/cli/fx-quote-rate.ts +1 -1
  28. package/src/cli/glossary.ts +14 -5
  29. package/src/cli/history-catalog-series.ts +85 -0
  30. package/src/cli/index.ts +1 -1
  31. package/src/cli/list-progress.ts +45 -0
  32. package/src/cli/listing-arg.ts +71 -7
  33. package/src/cli/name-entries.ts +8 -4
  34. package/src/cli/not-a-ticker.ts +2 -2
  35. package/src/cli/pane-functions/freshness.ts +50 -3
  36. package/src/cli/pane-functions/index.ts +7 -4
  37. package/src/cli/pane-functions/market-session.ts +66 -14
  38. package/src/cli/pane-functions/options.ts +5 -0
  39. package/src/cli/pane-functions/resolver.ts +9 -2
  40. package/src/cli/pane-functions/screenshot-assessment.ts +28 -3
  41. package/src/cli/pane-functions/screenshot-types.ts +6 -0
  42. package/src/cli/quote-answer.ts +49 -10
  43. package/src/cli/quote-list-reads.ts +87 -0
  44. package/src/cli/report-tables.ts +70 -13
  45. package/src/cli/result.ts +24 -2
  46. package/src/cli/symbol-list.ts +31 -4
  47. package/src/cli/terminal-code-hints.ts +83 -0
  48. package/src/cli/ticker-resolution.ts +2 -1
  49. package/src/cli/treasury-yields.ts +5 -0
  50. package/src/components/command-bar/action-runtime.ts +2 -0
  51. package/src/components/command-bar/routing/launch-request.ts +2 -1
  52. package/src/components/command-bar/routing/navigation-state.ts +4 -2
  53. package/src/components/command-bar/workflow/types.ts +6 -0
  54. package/src/components/layout/detached-pane-shell.tsx +3 -0
  55. package/src/components/layout/double-escape-close.ts +34 -3
  56. package/src/components/layout/floating-pane.tsx +10 -4
  57. package/src/components/layout/pane/cycle-order.ts +66 -2
  58. package/src/components/layout/pane/header.tsx +140 -31
  59. package/src/components/layout/pane/sidebar.tsx +13 -5
  60. package/src/components/layout/pane/status-footer.ts +3 -1
  61. package/src/components/layout/shell/drag/runtime.ts +5 -0
  62. package/src/components/layout/shell/index.tsx +25 -0
  63. package/src/components/layout/shell/menu.ts +9 -0
  64. package/src/components/layout/shell/pane/actions.ts +36 -0
  65. package/src/components/layout/shell/pane/management-shortcuts.ts +27 -3
  66. package/src/components/layout/shell/pane-occlusion.ts +40 -0
  67. package/src/components/layout/shell/shortcuts.ts +17 -1
  68. package/src/components/layout/shell/terminal-pointer-runtime.ts +39 -6
  69. package/src/components/layout/shell/window-mode/index.ts +5 -16
  70. package/src/components/layout/shell/window-mode/overlays.tsx +3 -1
  71. package/src/components/market-board/index.tsx +14 -5
  72. package/src/components/metric-treemap/index.tsx +3 -1
  73. package/src/components/ui/button.tsx +48 -4
  74. package/src/components/ui/data-table/opentui/index.tsx +24 -9
  75. package/src/components/ui/data-table/types.ts +7 -0
  76. package/src/components/ui/inline-quick-add.tsx +19 -3
  77. package/src/components/ui/list-view.tsx +11 -5
  78. package/src/components/ui/query-bar.tsx +16 -1
  79. package/src/components/ui/selection-fill.ts +39 -0
  80. package/src/core/state/app/layout-reducer.ts +2 -1
  81. package/src/core/state/app/pane-choices.ts +68 -0
  82. package/src/core/state/app/state.ts +14 -6
  83. package/src/core/state/app/types.ts +8 -0
  84. package/src/layout/pane-manager/dock-tree.ts +19 -0
  85. package/src/layout/pane-manager/index.ts +3 -0
  86. package/src/market-data/market/freshness.ts +33 -0
  87. package/src/market-data/market/status.ts +5 -1
  88. package/src/market-data/quotes/contributions.ts +10 -0
  89. package/src/market-data/quotes/freshness.ts +19 -0
  90. package/src/market-data/quotes/live-valuation.ts +31 -4
  91. package/src/market-data/quotes/resolution.ts +4 -0
  92. package/src/market-data/quotes/time.ts +0 -14
  93. package/src/plugins/builtin/account-management/index.tsx +1 -0
  94. package/src/plugins/builtin/awards/detail.tsx +12 -4
  95. package/src/plugins/builtin/awards/headless.ts +29 -8
  96. package/src/plugins/builtin/awards/model.ts +36 -2
  97. package/src/plugins/builtin/awards/pane.tsx +7 -4
  98. package/src/plugins/builtin/broker-manager/index.tsx +1 -0
  99. package/src/plugins/builtin/broker-trading/index.tsx +1 -1
  100. package/src/plugins/builtin/central-bank-rates/headless.ts +6 -6
  101. package/src/plugins/builtin/central-bank-rates/index.tsx +1 -1
  102. package/src/plugins/builtin/central-bank-rates/model.ts +21 -3
  103. package/src/plugins/builtin/central-bank-rates/pane.tsx +15 -5
  104. package/src/plugins/builtin/chart-composer/headless.ts +5 -1
  105. package/src/plugins/builtin/chart-composer/pane.tsx +1 -0
  106. package/src/plugins/builtin/chat/content/handle-prompt.tsx +4 -0
  107. package/src/plugins/builtin/chat/controller/realtime.ts +17 -1
  108. package/src/plugins/builtin/chat/message/terminal.tsx +4 -1
  109. package/src/plugins/builtin/chat/sidebar.tsx +3 -4
  110. package/src/plugins/builtin/cloud/askg/pane.tsx +4 -0
  111. package/src/plugins/builtin/cloud/plugin.tsx +1 -0
  112. package/src/plugins/builtin/cloud/team/module.tsx +1 -0
  113. package/src/plugins/builtin/cloud/thesis/detail.tsx +9 -4
  114. package/src/plugins/builtin/commodity-balances/pane.tsx +13 -5
  115. package/src/plugins/builtin/company-kpis/model.ts +3 -3
  116. package/src/plugins/builtin/connections/index.ts +1 -0
  117. package/src/plugins/builtin/credit-boards/cdx-pane.tsx +9 -5
  118. package/src/plugins/builtin/credit-boards/client.ts +5 -0
  119. package/src/plugins/builtin/credit-boards/headless.ts +1 -6
  120. package/src/plugins/builtin/credit-boards/model.ts +0 -6
  121. package/src/plugins/builtin/credit-boards/series.ts +19 -8
  122. package/src/plugins/builtin/credit-boards/sovr-pane.tsx +9 -5
  123. package/src/plugins/builtin/crypto-etf-flows/headless.ts +23 -13
  124. package/src/plugins/builtin/crypto-etf-flows/pane.tsx +8 -3
  125. package/src/plugins/builtin/debt-maturities/headless.ts +16 -7
  126. package/src/plugins/builtin/debt-maturities/model.ts +9 -15
  127. package/src/plugins/builtin/debt-maturities/pane.tsx +9 -10
  128. package/src/plugins/builtin/earnings/board-model.ts +33 -4
  129. package/src/plugins/builtin/earnings/board.tsx +15 -3
  130. package/src/plugins/builtin/earnings/calendar.tsx +10 -6
  131. package/src/plugins/builtin/earnings/client.ts +0 -9
  132. package/src/plugins/builtin/earnings/headless.ts +10 -7
  133. package/src/plugins/builtin/earnings/history.tsx +21 -14
  134. package/src/plugins/builtin/earnings-calls/data.ts +24 -4
  135. package/src/plugins/builtin/earnings-calls/format.ts +23 -5
  136. package/src/plugins/builtin/earnings-calls/headless.ts +23 -3
  137. package/src/plugins/builtin/earnings-calls/index.tsx +1 -0
  138. package/src/plugins/builtin/earnings-calls/model.ts +11 -1
  139. package/src/plugins/builtin/earnings-calls/pane.tsx +2 -5
  140. package/src/plugins/builtin/econ/calendar-model.ts +27 -0
  141. package/src/plugins/builtin/econ/fred-catalog.ts +3 -0
  142. package/src/plugins/builtin/econ/index.tsx +9 -2
  143. package/src/plugins/builtin/econ-statistics/headless.ts +3 -1
  144. package/src/plugins/builtin/econ-statistics/index.tsx +1 -1
  145. package/src/plugins/builtin/fear-greed/headless.ts +16 -13
  146. package/src/plugins/builtin/fear-greed/pane.tsx +12 -4
  147. package/src/plugins/builtin/filing-events/index.tsx +1 -0
  148. package/src/plugins/builtin/fx-matrix/index.tsx +30 -19
  149. package/src/plugins/builtin/insider/table.tsx +10 -7
  150. package/src/plugins/builtin/insider/tickers.tsx +1 -1
  151. package/src/plugins/builtin/iv-history/headless.ts +9 -8
  152. package/src/plugins/builtin/jobs/index.tsx +1 -0
  153. package/src/plugins/builtin/macro-day/headless.ts +3 -3
  154. package/src/plugins/builtin/macro-day/model.ts +1 -1
  155. package/src/plugins/builtin/macro-day/releases.ts +25 -16
  156. package/src/plugins/builtin/market-movers/index.tsx +20 -8
  157. package/src/plugins/builtin/market-movers/model.ts +5 -0
  158. package/src/plugins/builtin/market-movers/session-body.tsx +2 -1
  159. package/src/plugins/builtin/money-markets/headless.ts +12 -2
  160. package/src/plugins/builtin/money-markets/pane.tsx +10 -1
  161. package/src/plugins/builtin/options/view.tsx +1 -0
  162. package/src/plugins/builtin/options-positioning/pane.tsx +1 -1
  163. package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +4 -31
  164. package/src/plugins/builtin/portfolio-list/pane/index.tsx +6 -1
  165. package/src/plugins/builtin/portfolio-list/quick-add/index.tsx +22 -8
  166. package/src/plugins/builtin/portfolio-list/summary/index.tsx +6 -8
  167. package/src/plugins/builtin/portfolio-list/table.tsx +10 -1
  168. package/src/plugins/builtin/realized-vol/headless.ts +28 -2
  169. package/src/plugins/builtin/risk-factors/index.tsx +1 -0
  170. package/src/plugins/builtin/shared/source-footer.ts +70 -0
  171. package/src/plugins/builtin/short-interest/publications-pane.tsx +5 -1
  172. package/src/plugins/builtin/short-volume/pane.tsx +5 -1
  173. package/src/plugins/builtin/social-mentions/outliers.tsx +10 -1
  174. package/src/plugins/builtin/social-mentions/pane.tsx +7 -0
  175. package/src/plugins/builtin/supply-chain/client.ts +3 -1
  176. package/src/plugins/builtin/supply-chain/flow.tsx +25 -8
  177. package/src/plugins/builtin/supply-chain/graph-client.ts +1 -1
  178. package/src/plugins/builtin/supply-chain/graph-evidence.ts +1 -1
  179. package/src/plugins/builtin/supply-chain/graph-model.ts +12 -1
  180. package/src/plugins/builtin/supply-chain/graph-pane.tsx +9 -8
  181. package/src/plugins/builtin/supply-chain/graph.tsx +12 -6
  182. package/src/plugins/builtin/supply-chain/headless.ts +13 -7
  183. package/src/plugins/builtin/supply-chain/model.ts +68 -11
  184. package/src/plugins/builtin/supply-chain/pane.tsx +9 -6
  185. package/src/plugins/builtin/supply-chain/row-evidence.tsx +5 -5
  186. package/src/plugins/builtin/ticker-detail/overview/components.tsx +14 -1
  187. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +2 -0
  188. package/src/plugins/builtin/ticker-detail/pane.tsx +48 -24
  189. package/src/plugins/builtin/ticker-detail/quote-footer.ts +5 -0
  190. package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +6 -3
  191. package/src/plugins/builtin/treasury-auctions/after.ts +50 -23
  192. package/src/plugins/builtin/treasury-auctions/cache.ts +23 -5
  193. package/src/plugins/builtin/treasury-auctions/headless.ts +226 -37
  194. package/src/plugins/builtin/treasury-auctions/hk-headless.ts +11 -5
  195. package/src/plugins/builtin/treasury-auctions/hk-view.tsx +27 -25
  196. package/src/plugins/builtin/treasury-auctions/hk.ts +60 -8
  197. package/src/plugins/builtin/treasury-auctions/index.tsx +3 -0
  198. package/src/plugins/builtin/treasury-auctions/keys.ts +27 -0
  199. package/src/plugins/builtin/treasury-auctions/like.ts +137 -0
  200. package/src/plugins/builtin/treasury-auctions/model.ts +100 -22
  201. package/src/plugins/builtin/treasury-auctions/pane.tsx +39 -11
  202. package/src/plugins/builtin/vol-surface/heat-grid.tsx +4 -2
  203. package/src/plugins/builtin/vol-surface/pane.tsx +5 -2
  204. package/src/plugins/runtime/index.tsx +1 -0
  205. package/src/plugins/runtime/state.ts +20 -0
  206. package/src/portfolio/column-values.ts +8 -2
  207. package/src/public/__snapshots__/public-api.test.ts.snap +5 -0
  208. package/src/public/react.ts +7 -0
  209. package/src/react/auto-refresh.ts +29 -0
  210. package/src/renderers/browser/deeplink-bridge.ts +24 -3
  211. package/src/renderers/dom/desktop/query-bar.tsx +229 -60
  212. package/src/renderers/dom/host/overflow-fade-px.ts +2 -0
  213. package/src/renderers/dom/host/overflow-fade.ts +1 -2
  214. package/src/renderers/dom/styles.css +25 -5
  215. package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +2 -1
  216. package/src/series/types.ts +2 -0
  217. package/src/sources/gloomberb-cloud/fred-attribution.ts +86 -0
  218. package/src/sources/gloomberb-cloud/index.ts +25 -1
  219. package/src/sources/gloomberb-cloud/normalizers.ts +22 -3
  220. package/src/sources/provider-errors.ts +64 -1
  221. package/src/sources/provider-router/batches.ts +19 -0
  222. package/src/sources/provider-router/index.ts +7 -1
  223. package/src/state/app/context/index.tsx +24 -1
  224. package/src/state/pane-unsent-work.ts +47 -0
  225. package/src/test-support/shell-pane-keys.tsx +5 -0
  226. package/src/test-support/telemetry-guard.ts +83 -0
  227. package/src/test-support/test-env.ts +12 -0
  228. package/src/theme/colors.ts +17 -1
  229. package/src/theme/ui-tokens.ts +50 -1
  230. package/src/tickers/listing-venues.ts +11 -1
  231. package/src/tickers/search/japanese-names.json +1 -0
  232. package/src/tickers/search/japanese-names.ts +152 -0
  233. package/src/tickers/terminal-codes.ts +55 -6
  234. package/src/time-series/base-series.ts +3 -0
  235. package/src/types/data-provider.ts +6 -0
  236. package/src/types/financials.ts +11 -0
  237. package/src/types/plugin-contributions.ts +7 -0
  238. package/src/types/plugin-panes.ts +7 -0
  239. package/src/ui/host.tsx +6 -0
  240. package/src/utils/double-escape-close.ts +42 -0
  241. package/src/utils/fx-status.ts +30 -7
  242. package/src/utils/network-failure.ts +23 -0
@@ -97,12 +97,54 @@ const termMonths = (term: string) => {
97
97
  return own ? Number(own[1]) * (own[2] === "Year" ? 12 : 1) : null;
98
98
  };
99
99
 
100
- /** "3M" is the 3-Month bill; "1Y" the 12-Month bill as well as a 1-Year note. */
100
+ /** A day as HKMA gives it, a bond's issue or maturity month (YYYY-MM) read as its middle. */
101
+ const dayOf = (date: string) => Date.parse(`${date.length === 7 ? `${date}-15` : date}T00:00:00Z`);
102
+
103
+ /**
104
+ * The months a re-opened Government Bond had left when it was tendered, to the
105
+ * nearest month: HKMA names a re-opening by its issue's tenor (10GB2601 is a
106
+ * 10-year bond), and the 2023-10-26 tender of it sold paper with about 2.2
107
+ * years left. Null for a new issue, EF paper, or a bond without its maturity.
108
+ */
109
+ function remainingMonths(tender: HkTender): number | null {
110
+ if (!tender.reopening || !tender.maturity) return null;
111
+ const days = (dayOf(tender.maturity) - dayOf(tender.date)) / 86_400_000;
112
+ return Number.isFinite(days) && days > 0 ? Math.max(1, Math.round(days / 30.4375)) : null;
113
+ }
114
+
115
+ /** Months as a US auction writes a term: 27 is 2-Year 3-Month, 24 is 2-Year, 9 is 9-Month. */
116
+ function monthsTerm(months: number): string {
117
+ const years = Math.floor(months / 12);
118
+ const rest = months % 12;
119
+ return [years ? `${years}-Year` : "", rest ? `${rest}-Month` : ""].filter(Boolean).join(" ");
120
+ }
121
+
122
+ /**
123
+ * The term a tender sold: a re-opening's what its issue had left (2-Year
124
+ * 3-Month of a 10-year bond), as a US reopening's 9-Year 10-Month reads;
125
+ * otherwise the tenor HKMA gives.
126
+ */
127
+ export function hkTenderTerm(tender: HkTender): string {
128
+ const left = remainingMonths(tender);
129
+ return left == null ? tender.term : monthsTerm(left);
130
+ }
131
+
132
+ /** The tender's term in months, a re-opening's what it had left. */
133
+ const tenderMonths = (tender: HkTender) => remainingMonths(tender) ?? termMonths(tender.term);
134
+
135
+ /**
136
+ * "3M" is the 3-Month bill; "1Y" the 12-Month bill as well as a 1-Year note.
137
+ * A re-opening answers to its issue's tenor (10Y for 10GB2601) and to the
138
+ * whole years its term left rounds up to (3Y for 2-Year 3-Month), as a US
139
+ * 9-Year 10-Month answers to 10Y.
140
+ */
101
141
  function matchesTenor(tender: HkTender, word: string): boolean | null {
102
142
  const tenor = TENOR.exec(word);
103
143
  if (!tenor) return null;
104
144
  const count = Number(tenor[1]);
105
- return termMonths(tender.term) === (tenor[2]![0] === "y" ? count * 12 : count);
145
+ const months = tenor[2]![0] === "y" ? count * 12 : count;
146
+ const left = remainingMonths(tender);
147
+ return termMonths(tender.term) === months || (left != null && tenor[2]![0] === "y" && Math.ceil(left / 12) === count);
106
148
  }
107
149
 
108
150
  function matchesWord(tender: HkTender, word: string): boolean {
@@ -113,7 +155,8 @@ function matchesWord(tender: HkTender, word: string): boolean {
113
155
  if (currency) return tender.currency === currency;
114
156
  const tenor = matchesTenor(tender, word);
115
157
  if (tenor != null) return tenor;
116
- return tender.date.startsWith(word) || !!tender.issue?.toLowerCase().includes(word) || tender.term.toLowerCase().includes(word);
158
+ return tender.date.startsWith(word) || !!tender.issue?.toLowerCase().includes(word) || tender.term.toLowerCase().includes(word)
159
+ || hkTenderTerm(tender).toLowerCase().includes(word);
117
160
  }
118
161
 
119
162
  /** Every word of the search names the tender (`10Y RMB`, `EFB 2026-10`); words that only pick the market are left out. */
@@ -174,11 +217,19 @@ const HK_SORT_NAMES: ReadonlyArray<{ names: readonly string[]; column: HkColumnI
174
217
  ];
175
218
 
176
219
  /** The column a sort name means for Hong Kong's tenders; null for a US-only one (`indirect`, `btc-pctl`). */
177
- export function hkSortColumn(name: string): HkColumnId | null {
178
- const value = name.trim().toLowerCase();
220
+ function hkSortColumn(name: string): HkColumnId | null {
221
+ const value = name.trim().toLowerCase().replace(/^-/, "");
179
222
  return HK_SORT_NAMES.find((entry) => entry.names.includes(value))?.column ?? null;
180
223
  }
181
224
 
225
+ /** A sort name as `--sort` and the pane keep it, `-` first for the other way round (`-btc`: lowest first); null for a US-only one. */
226
+ export function parseHkSort(name: string): HkSortPreference | null {
227
+ const columnId = hkSortColumn(name);
228
+ if (!columnId) return null;
229
+ const first = firstHkSortDirection(columnId);
230
+ return { columnId, direction: name.trim().startsWith("-") ? first === "asc" ? "desc" : "asc" : first };
231
+ }
232
+
182
233
  export const hkSortName = (column: HkColumnId) => HK_SORT_NAMES.find((entry) => entry.column === column)!.names[0]!;
183
234
 
184
235
  /** Text columns read best A to Z; every figure highest first. */
@@ -192,7 +243,7 @@ function hkSortValue(tender: HkTender, column: HkColumnId): number | string | nu
192
243
  switch (column) {
193
244
  case "date": return sortDay(tender.date);
194
245
  case "type": return hkTenderType(tender);
195
- case "term": return termMonths(tender.term);
246
+ case "term": return tenderMonths(tender);
196
247
  case "rate": return hkRate(tender);
197
248
  case "btc": return tender.bidToCover;
198
249
  case "size": return hkSize(tender);
@@ -244,7 +295,8 @@ export function buildHkColumns(options: { showYear?: boolean; rows?: readonly Hk
244
295
  const columns: HkColumn[] = [
245
296
  { id: "date", label: "DATE", width: showYear ? 10 : 6, align: "left", title: "Issue day (a Government Bond's issue month): the business day after the tender" },
246
297
  { id: "type", label: "TYPE", width: 6, align: "left" },
247
- { id: "term", label: "TERM", width: widest(7, (tender) => tender.term), align: "left" },
298
+ { id: "term", label: "TERM", width: widest(7, hkTenderTerm), align: "left",
299
+ title: "Term sold: a re-opening's is what its issue had left" },
248
300
  { id: "rate", label: "RATE", width: widest(6, (tender) => formatHkRate(tender, hkRate(tender), "—")), align: "right",
249
301
  title: "Average accepted yield; a floating rate note's spread over HONIA, bp" },
250
302
  { id: "btc", label: "B/C", width: 5, align: "right" },
@@ -270,7 +322,7 @@ function readsAsTender(tender: HkTender): boolean {
270
322
  }
271
323
 
272
324
  /** What the HK market lists, and how far HKMA's figures run. */
273
- export interface HkTendersBoard {
325
+ interface HkTendersBoard {
274
326
  tenders: HkTender[];
275
327
  /** The first issue Gloom Cloud's record holds: a wider window adds rows only past it. */
276
328
  firstTender: string | null;
@@ -85,6 +85,9 @@ export const treasuryAuctionsModule: PluginModule = {
85
85
  "indirect",
86
86
  "takedown",
87
87
  "tail",
88
+ "when issued",
89
+ "when-issued",
90
+ "wi",
88
91
  "stop-out",
89
92
  "stop out",
90
93
  "treasury auction",
@@ -0,0 +1,27 @@
1
+ import type { PaneHint } from "../../../components";
2
+ import type { AuctionView } from "./after";
3
+ import type { AuctionMarket } from "./hk";
4
+
5
+ /**
6
+ * The keys a market's table answers besides search and filter: `v` turns the
7
+ * US table between Results and After, `m` between the US and Hong Kong, and
8
+ * `[`/`]` step the sort column (the footer shows `[]`, the next one).
9
+ */
10
+ export function auctionViewHints(options: {
11
+ view?: AuctionView;
12
+ toggleView?: () => void;
13
+ market: AuctionMarket;
14
+ toggleMarket: () => void;
15
+ cycleSort: (step: 1 | -1) => void;
16
+ }): PaneHint[] {
17
+ const { view, toggleView, market, toggleMarket, cycleSort } = options;
18
+ return [
19
+ ...(view && toggleView ? [view === "after"
20
+ ? { id: "view", key: "v", label: " results", title: "Show Results", onPress: toggleView }
21
+ : { id: "view", key: "v", label: " after", title: "Show After", onPress: toggleView }] : []),
22
+ market === "hk"
23
+ ? { id: "market", key: "m", label: " US", title: "US Treasury Auctions", onPress: toggleMarket }
24
+ : { id: "market", key: "m", label: " HK", title: "Hong Kong Tenders", onPress: toggleMarket },
25
+ { id: "sort", key: "[]", label: "sort", title: "Next Sort Column", onPress: () => cycleSort(1) },
26
+ ];
27
+ }
@@ -0,0 +1,137 @@
1
+ import { auctionTenorKey, type AfterMove, type AuctionAfter, type AuctionPercentiles } from "./after";
2
+ import { auctionBenchmark, isPendingAuction } from "./model";
3
+ import type { TreasuryAuction } from "./types";
4
+
5
+ /**
6
+ * `fn AUCT 3Y --like 2026-11-09`: the earlier auctions of the same tenor
7
+ * that ranked most like one, and what the Treasury yield did after them.
8
+ *
9
+ * Likeness is read on the percentiles the after view shows (after.ts), which
10
+ * already put each auction against its own tenor's recent history: a 2.46
11
+ * bid-to-cover reads differently in 2008 and 2026, its percentile does not.
12
+ * The distance is the root mean square of the gaps between the two auctions'
13
+ * stop-out vs median, B/C and indirect percentiles, 0 for an auction that
14
+ * ranked the same on all three; only the ones the auction has count, and an
15
+ * earlier auction is compared only when it has them all.
16
+ */
17
+
18
+ /** How many of the closest earlier auctions `--like` lists. */
19
+ export const LIKE_LIMIT = 15;
20
+
21
+ type LikeDimension = "stopOutPercentile" | "btcPercentile" | "indirectPercentile";
22
+ const LIKE_DIMENSIONS: readonly LikeDimension[] = ["stopOutPercentile", "btcPercentile", "indirectPercentile"];
23
+
24
+ export interface AuctionAnalog {
25
+ auction: TreasuryAuction;
26
+ /** Root mean square of the percentile gaps, 0 to 100. */
27
+ distance: number;
28
+ }
29
+
30
+ export interface AuctionAnalogs {
31
+ /** The percentiles the distance reads: those the auction has. */
32
+ dimensions: LikeDimension[];
33
+ /** The closest first; ties keep the newest first. */
34
+ analogs: AuctionAnalog[];
35
+ }
36
+
37
+ /**
38
+ * The search that names an auction's tenor (`3Y`, `13W`, `10Y TIPS`), as
39
+ * `fn AUCT` takes it; null for a term with no benchmark.
40
+ */
41
+ function tenorSearch(auction: TreasuryAuction): string | null {
42
+ const benchmark = auctionBenchmark(auction.securityTerm);
43
+ if (!benchmark) return null;
44
+ const kind = auction.secType === "TIPS" || auction.secType === "FRN" ? ` ${auction.secType}` : "";
45
+ return `${benchmark.count}${benchmark.unit[0]!.toUpperCase()}${kind}`;
46
+ }
47
+
48
+ /**
49
+ * The completed auctions on `date` among `listed` (already narrowed by the
50
+ * search and group): one is the auction to compare with, several ask for a
51
+ * search that tells them apart, naming a tenor held that day (a note or bond's
52
+ * before a bill's), none says so.
53
+ */
54
+ export function likeTarget(listed: readonly TreasuryAuction[], date: string): { target: TreasuryAuction } | { error: string } {
55
+ const held = listed.filter((auction) => auction.auctionDate === date);
56
+ const completed = held.filter((auction) => !isPendingAuction(auction));
57
+ if (completed.length === 1) return { target: completed[0]! };
58
+ if (completed.length > 1) {
59
+ const named = completed.map((auction) => `${auction.securityTerm} ${auction.secType}`).join(", ");
60
+ const example = [...completed.filter((auction) => auction.secType !== "Bill" && auction.secType !== "CMB"), ...completed]
61
+ .map(tenorSearch).find((search) => search != null);
62
+ return { error: `${date} held ${completed.length} auctions (${named}): search for one${example ? `, as in fn AUCT ${example} --like ${date}` : " by its term"}.` };
63
+ }
64
+ if (held.length > 0) return { error: `The ${held[0]!.securityTerm} ${held[0]!.secType.toLowerCase()} auction of ${date} has no results yet.` };
65
+ return { error: `No auction on ${date} matches the search: --like takes the date an auction was held, as in fn AUCT 3Y --like 2026-11-09.` };
66
+ }
67
+
68
+ /**
69
+ * The earlier auctions of the target's tenor in `history` closest to it on
70
+ * the percentiles it has, at most `limit`. No dimensions when the target has
71
+ * no percentile: fewer than 12 auctions of its tenor came before it.
72
+ */
73
+ export function rankAuctionAnalogs(
74
+ target: TreasuryAuction,
75
+ history: readonly TreasuryAuction[],
76
+ percentiles: ReadonlyMap<string, AuctionPercentiles>,
77
+ limit = LIKE_LIMIT,
78
+ ): AuctionAnalogs {
79
+ const own = percentiles.get(target.id);
80
+ const dimensions = LIKE_DIMENSIONS.filter((key) => own?.[key] != null);
81
+ if (!own || dimensions.length === 0) return { dimensions, analogs: [] };
82
+ const tenor = auctionTenorKey(target);
83
+ const analogs: AuctionAnalog[] = [];
84
+ for (const auction of history) {
85
+ if (auction.id === target.id || auction.auctionDate >= target.auctionDate || isPendingAuction(auction)) continue;
86
+ if (auctionTenorKey(auction) !== tenor) continue;
87
+ const theirs = percentiles.get(auction.id);
88
+ if (!theirs || dimensions.some((key) => theirs[key] == null)) continue;
89
+ const squares = dimensions.reduce((sum, key) => sum + (theirs[key]! - own[key]!) ** 2, 0);
90
+ analogs.push({ auction, distance: Math.round(Math.sqrt(squares / dimensions.length) * 10) / 10 });
91
+ }
92
+ analogs.sort((left, right) => left.distance - right.distance || right.auction.auctionDate.localeCompare(left.auction.auctionDate));
93
+ return { dimensions, analogs: analogs.slice(0, limit) };
94
+ }
95
+
96
+ const AFTER_MOVES: ReadonlyArray<{ key: AfterMove; label: string }> = [
97
+ { key: "after1d", label: "+1d" }, { key: "after5d", label: "+5d" }, { key: "after20d", label: "+20d" },
98
+ ];
99
+
100
+ export interface AnalogMoveSummary {
101
+ move: AfterMove;
102
+ /** "+1d", "+5d", "+20d". */
103
+ label: string;
104
+ /** The median move, bp; null when no analog has it yet. */
105
+ medianBp: number | null;
106
+ /** The share of them whose yield rose, 0 to 100. */
107
+ rosePct: number | null;
108
+ /** The analogs with the move: a recent one has no +20d yet. */
109
+ count: number;
110
+ }
111
+
112
+ const median = (values: readonly number[]) => {
113
+ const sorted = values.toSorted((left, right) => left - right);
114
+ const middle = sorted.length >> 1;
115
+ return sorted.length % 2 ? sorted[middle]! : (sorted[middle - 1]! + sorted[middle]!) / 2;
116
+ };
117
+
118
+ /**
119
+ * The median of each move after the analogs, and the share of them whose
120
+ * yield rose. A move left blank (not in yet, or after the asked date) is not
121
+ * counted.
122
+ */
123
+ export function summarizeAnalogMoves(analogs: readonly AuctionAnalog[], after: ReadonlyMap<string, Pick<AuctionAfter, AfterMove>>): AnalogMoveSummary[] {
124
+ return AFTER_MOVES.map(({ key, label }) => {
125
+ const moves = analogs.flatMap(({ auction }) => {
126
+ const value = after.get(auction.id)?.[key];
127
+ return value == null ? [] : [value];
128
+ });
129
+ return {
130
+ move: key,
131
+ label,
132
+ medianBp: moves.length ? Math.round(median(moves) * 10) / 10 : null,
133
+ rosePct: moves.length ? Math.round((moves.filter((value) => value > 0).length / moves.length) * 100) : null,
134
+ count: moves.length,
135
+ };
136
+ });
137
+ }
@@ -1,5 +1,5 @@
1
1
  import type { DataTableColumn } from "../../../components";
2
- import { dropColumnsToFit } from "../../../components/ui/table-layout";
2
+ import { dropColumnsToFit, getTableWidth } from "../../../components/ui/table-layout";
3
3
  import { displayWidth } from "../../../utils/format";
4
4
  import { compareSortValues, type SortDirection } from "../../../utils/sort-values";
5
5
  import { AUCTION_HISTORY_ALL, AUCTION_HISTORY_DAYS, AUCTION_HISTORY_START, type AuctionHistoryWindow } from "./client";
@@ -53,10 +53,11 @@ export const AUCTION_SEARCH_FIELDS = "type, benchmark (10Y), term, CUSIP, or dat
53
53
 
54
54
  export type AuctionColumnId =
55
55
  | "date" | "type" | "term" | "rate" | "stopOut" | "btc" | "indirect" | "direct" | "dealer" | "size" | "cusip"
56
- | "btcPctl" | "indirectPctl" | "dealerPctl" | "after1d" | "after5d" | "after20d";
56
+ | "stopOutPctl" | "btcPctl" | "indirectPctl" | "dealerPctl" | "after1d" | "after5d" | "after20d";
57
57
 
58
58
  /** What the after view adds to a row: its percentiles and the yield's moves after it (after.ts). */
59
59
  export interface AuctionAfterFigures {
60
+ stopOutPercentile: number | null;
60
61
  btcPercentile: number | null;
61
62
  indirectPercentile: number | null;
62
63
  dealerPercentile: number | null;
@@ -67,6 +68,8 @@ export interface AuctionAfterFigures {
67
68
 
68
69
  export interface AuctionColumn extends DataTableColumn {
69
70
  id: AuctionColumnId;
71
+ /** TERM written short (9Y10M) where the full term would crowd out a figure. */
72
+ compact?: boolean;
70
73
  }
71
74
 
72
75
  export interface AuctionSortPreference {
@@ -95,7 +98,8 @@ export const AUCTION_SORT_COLUMN_IDS: readonly AuctionColumnId[] = [
95
98
 
96
99
  /** The after view's columns, in the order [ and ] step through them. */
97
100
  export const AUCTION_AFTER_SORT_COLUMN_IDS: readonly AuctionColumnId[] = [
98
- "date", "type", "term", "rate", "btc", "btcPctl", "indirectPctl", "dealerPctl", "after1d", "after5d", "after20d", "cusip",
101
+ "date", "type", "term", "rate", "stopOut", "stopOutPctl", "btc", "btcPctl", "indirect", "indirectPctl", "dealerPctl",
102
+ "after1d", "after5d", "after20d", "cusip",
99
103
  ];
100
104
 
101
105
  /** `--sort` as typed, and the column it sorts. */
@@ -111,6 +115,7 @@ export const AUCTION_SORT_NAMES: ReadonlyArray<{ value: string; column: AuctionC
111
115
  { value: "dealer", column: "dealer" },
112
116
  { value: "size", column: "size" },
113
117
  { value: "cusip", column: "cusip", aliases: ["issue"] },
118
+ { value: "vs-median-pctl", column: "stopOutPctl", aliases: ["vs-med-pctl", "vs-avg-pctl", "stop-out-pctl", "vs-median-percentile"] },
114
119
  { value: "btc-pctl", column: "btcPctl", aliases: ["btc-percentile", "bc-pctl"] },
115
120
  { value: "indirect-pctl", column: "indirectPctl", aliases: ["indirect-percentile"] },
116
121
  { value: "dealer-pctl", column: "dealerPctl", aliases: ["dealer-percentile"] },
@@ -121,7 +126,7 @@ export const AUCTION_SORT_NAMES: ReadonlyArray<{ value: string; column: AuctionC
121
126
 
122
127
  /** The after view's columns are its own; the results view's sort by its own. */
123
128
  export const isAfterColumn = (column: AuctionColumnId) =>
124
- column === "btcPctl" || column === "indirectPctl" || column === "dealerPctl" || column === "after1d" || column === "after5d" || column === "after20d";
129
+ column === "stopOutPctl" || column === "btcPctl" || column === "indirectPctl" || column === "dealerPctl" || column === "after1d" || column === "after5d" || column === "after20d";
125
130
 
126
131
  export type AuctionFilter = "all" | "bill" | "note" | "bond";
127
132
 
@@ -434,6 +439,7 @@ function sortValue(auction: TreasuryAuction, columnId: AuctionColumnId, after?:
434
439
  case "dealer": return dealerPct(auction);
435
440
  case "size": return auctionSize(auction);
436
441
  case "cusip": return auction.cusip;
442
+ case "stopOutPctl": return after?.stopOutPercentile ?? null;
437
443
  case "btcPctl": return after?.btcPercentile ?? null;
438
444
  case "indirectPctl": return after?.indirectPercentile ?? null;
439
445
  case "dealerPctl": return after?.dealerPercentile ?? null;
@@ -470,18 +476,43 @@ export function firstAuctionSortDirection(columnId: AuctionColumnId): SortDirect
470
476
  }
471
477
 
472
478
  /**
473
- * "Oct 13" is ambiguous once a window spans years, so a window past a year
474
- * dates its rows in full (2026-10-13), the way the search takes a date.
479
+ * "Oct 13" is ambiguous once the rows span two calendar years ("Nov 10" of
480
+ * 2026 above "Nov 12" of 2025), so then every row is dated in full
481
+ * (2026-10-13), the way the search takes a date. A Hong Kong bond's issue
482
+ * month (2026-05) counts by its year.
475
483
  */
476
- export function auctionDatesShowYear(window: AuctionHistoryWindow): boolean {
477
- return window === AUCTION_HISTORY_ALL || window > 365;
484
+ export function auctionDatesShowYear(dates: readonly string[]): boolean {
485
+ const first = dates[0]?.slice(0, 4);
486
+ return dates.some((date) => date.slice(0, 4) !== first);
478
487
  }
479
488
 
489
+ /** A term written short: 9-Year 10-Month is 9Y10M, 13-Week 13W; a term this does not read stays as it is. */
490
+ export function compactTerm(term: string): string {
491
+ const parts = termParts(term);
492
+ if (!parts) return term;
493
+ return (["year", "month", "week", "day"] as const)
494
+ .filter((unit) => parts[unit])
495
+ .map((unit) => `${parts[unit]}${unit[0]!.toUpperCase()}`)
496
+ .join("");
497
+ }
498
+
499
+ /**
500
+ * The columns a narrow pane gives up, least needed first, after the CUSIP and
501
+ * after TERM is written short (9Y10M). The results view keeps its type and
502
+ * bidder split longest; the after view is read for its percentiles and the
503
+ * yield's moves after the auction, so +5D and +20D outlast the type, the
504
+ * dealer percentile and the raw figures beside each percentile.
505
+ */
506
+ const RESULTS_DROP_ORDER: readonly AuctionColumnId[] = ["size", "type", "direct", "dealer", "indirect", "stopOut"];
507
+ const AFTER_DROP_ORDER: readonly AuctionColumnId[] = ["type", "dealerPctl", "indirect", "btc", "stopOut", "stopOutPctl", "after1d"];
508
+
480
509
  /**
481
510
  * Widths are the data's own; the table widens a column to its label plus the
482
511
  * sort arrow. TERM is as wide as the longest term listed, and the CUSIP closes
483
- * the row where the pane has room for it, taking what width is left; a pane
484
- * too narrow for the rest scrolls sideways instead of clipping a figure.
512
+ * the row where the pane has room for it, taking what width is left. A pane
513
+ * too narrow for every column gives up the CUSIP, then writes TERM short,
514
+ * then drops whole columns in the view's order, so no column is ever cut at
515
+ * the pane's edge.
485
516
  */
486
517
  export function buildAuctionColumns(options: {
487
518
  showYear?: boolean;
@@ -491,23 +522,32 @@ export function buildAuctionColumns(options: {
491
522
  width?: number;
492
523
  } = {}): AuctionColumn[] {
493
524
  const { showYear = false, view = "results", rows = [], width } = options;
494
- const term = Math.max(6, ...rows.map((auction) => displayWidth(auction.securityTerm)));
525
+ const termWidth = (text: (term: string) => string) => Math.max(6, ...rows.map((auction) => displayWidth(text(auction.securityTerm))));
495
526
  const lead: AuctionColumn[] = [
496
527
  { id: "date", label: "DATE", width: showYear ? 10 : 6, align: "left" },
497
528
  { id: "type", label: "TYPE", width: 6, align: "left" },
498
- { id: "term", label: "TERM", width: term, align: "left" },
529
+ { id: "term", label: "TERM", width: termWidth((term) => term), align: "left" },
499
530
  { id: "rate", label: rateColumnLabel(rows, "pane"), width: 7, align: "right" },
500
531
  ];
532
+ const stopOut: AuctionColumn = {
533
+ id: "stopOut", label: stopOutColumnLabel(rows, "pane"), width: 7, align: "right", title: "Stop-out vs median yield (average before November 1998), bp",
534
+ };
535
+ const percentile = (id: AuctionColumnId, label: string, what: string): AuctionColumn => (
536
+ { id, label, width: 4, align: "right", title: `${what} percentile against the tenor's last 24 auctions` }
537
+ );
501
538
  const figures: AuctionColumn[] = view === "after" ? [
539
+ stopOut,
540
+ percentile("stopOutPctl", `${stopOutColumnLabel(rows, "pane").replace(/^VS /, "")} PCTL`, "Stop-out vs median"),
502
541
  { id: "btc", label: "B/C", width: 5, align: "right" },
503
- { id: "btcPctl", label: "B/C PCTL", width: 4, align: "right", title: "Bid-to-cover percentile against the tenor's last 24 auctions" },
504
- { id: "indirectPctl", label: "IND PCTL", width: 4, align: "right", title: "Indirect share percentile against the tenor's last 24 auctions" },
505
- { id: "dealerPctl", label: "DLR PCTL", width: 4, align: "right", title: "Dealer share percentile against the tenor's last 24 auctions" },
542
+ percentile("btcPctl", "B/C PCTL", "Bid-to-cover"),
543
+ { id: "indirect", label: "INDIRECT", width: 8, align: "right" },
544
+ percentile("indirectPctl", "IND PCTL", "Indirect share"),
545
+ percentile("dealerPctl", "DLR PCTL", "Dealer share"),
506
546
  { id: "after1d", label: "+1D BP", width: 5, align: "right", title: "Treasury yield change one session after the auction, bp" },
507
547
  { id: "after5d", label: "+5D BP", width: 5, align: "right", title: "Treasury yield change five sessions after the auction, bp" },
508
548
  { id: "after20d", label: "+20D BP", width: 5, align: "right", title: "Treasury yield change twenty sessions after the auction, bp" },
509
549
  ] : [
510
- { id: "stopOut", label: stopOutColumnLabel(rows, "pane"), width: 7, align: "right", title: "Stop-out vs median yield (average before November 1998), bp" },
550
+ stopOut,
511
551
  { id: "btc", label: "B/C", width: 5, align: "right" },
512
552
  { id: "indirect", label: "INDIRECT", width: 8, align: "right" },
513
553
  { id: "direct", label: "DIRECT", width: 6, align: "right" },
@@ -516,9 +556,13 @@ export function buildAuctionColumns(options: {
516
556
  ];
517
557
  const columns: AuctionColumn[] = [...lead, ...figures, { id: "cusip", label: "CUSIP", width: 9, align: "left", flexGrow: 1 }];
518
558
  if (width == null) return columns;
519
- const shown = dropColumnsToFit(columns, width, ["cusip"]);
559
+ let shown = dropColumnsToFit(columns, width, ["cusip"]);
560
+ if (shown.length === columns.length) return shown;
520
561
  // Without the CUSIP nothing grows: the figures keep their places at the left.
521
- return shown.length === columns.length ? shown : shown.map((column) => ({ ...column, flexGrow: undefined }));
562
+ shown = shown.map((column) => ({ ...column, flexGrow: undefined }));
563
+ if (getTableWidth(shown) <= width) return shown;
564
+ shown = shown.map((column) => column.id === "term" ? { ...column, width: termWidth(compactTerm), compact: true } : column);
565
+ return dropColumnsToFit(shown, width, view === "after" ? AFTER_DROP_ORDER : RESULTS_DROP_ORDER);
522
566
  }
523
567
 
524
568
  /**
@@ -535,7 +579,7 @@ function parseAuctionCommandArg(arg: string | undefined): {
535
579
  historyDays?: AuctionHistoryWindow;
536
580
  filter?: AuctionFilter;
537
581
  view?: "results" | "after";
538
- /** The sort's name as `--sort` takes it: "btc-pctl". */
582
+ /** The sort's name as `--sort` takes it: "btc-pctl", "-indirect-pctl". */
539
583
  sort?: string;
540
584
  } {
541
585
  const tokens = (arg ?? "").trim().split(/\s+/).filter(Boolean);
@@ -561,8 +605,8 @@ function parseAuctionCommandArg(arg: string | undefined): {
561
605
  } else if (name === "view") {
562
606
  if (value === "results" || value === "after") parsed.view = value;
563
607
  } else if (name === "sort") {
564
- const sort = auctionSortColumn(value);
565
- const name = sort && AUCTION_SORT_NAMES.find((entry) => entry.column === sort)?.value;
608
+ const sort = parseAuctionSort(value);
609
+ const name = sort && auctionSortName(sort);
566
610
  if (name) parsed.sort = name;
567
611
  }
568
612
  }
@@ -591,11 +635,45 @@ export function auctionCommandRequest(arg: string | undefined): {
591
635
  }
592
636
 
593
637
  /** The column `--sort` names, by its name or an alias; null for anything else. */
594
- export function auctionSortColumn(value: string): AuctionColumnId | null {
638
+ function auctionSortColumn(value: string): AuctionColumnId | null {
595
639
  const name = value.trim().toLowerCase();
596
640
  return AUCTION_SORT_NAMES.find((entry) => entry.value === name || entry.aliases?.includes(name))?.column ?? null;
597
641
  }
598
642
 
643
+ const reverse = (direction: SortDirection): SortDirection => direction === "asc" ? "desc" : "asc";
644
+
645
+ /**
646
+ * A sort as `--sort` takes it: a column by its name or an alias, its own way
647
+ * first (largest first for a figure, newest first for date, A to Z for text),
648
+ * or the other way round after a `-` (`-indirect-pctl`: lowest first). Null
649
+ * for a name no column has.
650
+ */
651
+ export function parseAuctionSort(value: string): AuctionSortPreference | null {
652
+ const text = value.trim().toLowerCase();
653
+ const reversed = text.startsWith("-");
654
+ const columnId = auctionSortColumn(reversed ? text.slice(1) : text);
655
+ if (!columnId) return null;
656
+ const first = firstAuctionSortDirection(columnId);
657
+ return { columnId, direction: reversed ? reverse(first) : first };
658
+ }
659
+
660
+ /** A sort's name as `--sort` writes it: `indirect-pctl`, `-indirect-pctl` the other way round; null for a column with none. */
661
+ export function auctionSortName(sort: AuctionSortPreference): string | null {
662
+ const name = AUCTION_SORT_NAMES.find((entry) => entry.column === sort.columnId)?.value;
663
+ if (!name) return null;
664
+ return sort.direction === firstAuctionSortDirection(sort.columnId) ? name : `-${name}`;
665
+ }
666
+
667
+ /** `--sort` as typed, as its canonical name (`-btc` for `-b/c`); throws naming the names it takes. */
668
+ export function normalizeAuctionSortOption(value: string): string {
669
+ const sort = parseAuctionSort(value);
670
+ const name = sort && auctionSortName(sort);
671
+ if (!name) {
672
+ throw new Error(`Invalid --sort value "${value}". Use one of: ${AUCTION_SORT_NAMES.map((entry) => entry.value).join(", ")}; a leading - sorts the other way (-indirect-pctl: lowest first).`);
673
+ }
674
+ return name;
675
+ }
676
+
599
677
  /** A query for a market AUCT does not cover: another country's government paper. */
600
678
  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;
601
679