gloomberb 0.20.3 → 0.20.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (348) hide show
  1. package/README.md +2 -0
  2. package/bin/gloom +9 -0
  3. package/bin/without-bun.cjs +98 -0
  4. package/package.json +3 -1
  5. package/src/account/auth-dialog.tsx +17 -0
  6. package/src/api-client/data.ts +144 -35
  7. package/src/api-client/fx-interventions.ts +64 -0
  8. package/src/api-client/index.ts +1 -0
  9. package/src/api-client/release-summaries.ts +21 -0
  10. package/src/api-client/types/econ.ts +12 -0
  11. package/src/api-client/yield-curves.ts +1 -1
  12. package/src/app/global-shortcuts.ts +4 -1
  13. package/src/app/keybindings/actions.ts +8 -2
  14. package/src/app/keybindings/config.ts +2 -1
  15. package/src/app/keybindings/index.ts +1 -0
  16. package/src/app/keybindings/labels.ts +6 -1
  17. package/src/app/keybindings/resolve.ts +23 -4
  18. package/src/app/keybindings/terminal-keys.ts +35 -0
  19. package/src/app/pane-runtime/index.tsx +2 -2
  20. package/src/app/pane-runtime/ticker-open-runtime.ts +274 -67
  21. package/src/architecture/ui-literals-allowlist.json +1 -1
  22. package/src/capabilities/chart-series.ts +27 -1
  23. package/src/cli/commands/keybindings.ts +5 -5
  24. package/src/cli/commands/market.ts +154 -21
  25. package/src/cli/commands/news-search.ts +60 -10
  26. package/src/cli/commands/overview.ts +16 -1
  27. package/src/cli/commands/plugins.ts +27 -5
  28. package/src/cli/commands/remote.ts +16 -17
  29. package/src/cli/commands/system.ts +20 -4
  30. package/src/cli/commands/ticker.ts +60 -19
  31. package/src/cli/fx-forward.ts +25 -7
  32. package/src/cli/glossary.ts +19 -5
  33. package/src/cli/history-rows.ts +5 -3
  34. package/src/cli/index.ts +8 -8
  35. package/src/cli/known-gaps.ts +27 -1
  36. package/src/cli/listing-arg.ts +11 -1
  37. package/src/cli/name-entries.ts +5 -1
  38. package/src/cli/not-a-ticker.ts +4 -0
  39. package/src/cli/pane-functions/function-help.ts +5 -5
  40. package/src/cli/report-tables.ts +18 -6
  41. package/src/cli/result.ts +15 -7
  42. package/src/cli/types.ts +2 -0
  43. package/src/components/chart/composite/axis-overlays.tsx +22 -0
  44. package/src/components/chart/composite/composite-chart.tsx +54 -13
  45. package/src/components/chart/composite/event-captions.ts +109 -0
  46. package/src/components/chart/composite/event-guides.ts +74 -0
  47. package/src/components/chart/composite/rasterizer.ts +2 -0
  48. package/src/components/chart/composite/text-renderer.ts +2 -0
  49. package/src/components/chart/composite/types.ts +31 -0
  50. package/src/components/command-bar/layout-items/focused-pane.ts +5 -5
  51. package/src/components/command-bar/pane-settings.ts +2 -2
  52. package/src/components/command-bar/routes/root/provider-search.ts +5 -4
  53. package/src/components/command-bar/routes/root/results.ts +6 -2
  54. package/src/components/command-bar/routes/ticker-search/results.ts +51 -0
  55. package/src/components/command-bar/routes/ticker-search/route.ts +3 -2
  56. package/src/components/input-search-bar.tsx +9 -2
  57. package/src/components/layout/detached-pane-shell.tsx +1 -1
  58. package/src/components/layout/floating-pane.tsx +5 -1
  59. package/src/components/layout/pane/footer/index.tsx +21 -14
  60. package/src/components/layout/pane/footer/model.ts +6 -0
  61. package/src/components/layout/pane/header.tsx +2 -0
  62. package/src/components/layout/shell/action-menu-overlay.tsx +10 -5
  63. package/src/components/layout/shell/active-drag.ts +149 -105
  64. package/src/components/layout/shell/drag/drop-zones.ts +162 -0
  65. package/src/components/layout/shell/drag/index.ts +47 -218
  66. package/src/components/layout/shell/drag/live.ts +10 -3
  67. package/src/components/layout/shell/drag/overlays.tsx +182 -5
  68. package/src/components/layout/shell/drag/runtime.ts +29 -6
  69. package/src/components/layout/shell/drag/shared-edges.ts +156 -0
  70. package/src/components/layout/shell/index.tsx +11 -6
  71. package/src/components/layout/shell/menu.ts +11 -2
  72. package/src/components/layout/shell/native/pointer-runtime.ts +25 -0
  73. package/src/components/layout/shell/native/window-state.ts +2 -2
  74. package/src/components/layout/shell/pane/capture.ts +4 -1
  75. package/src/components/layout/shell/pane/layers.tsx +71 -7
  76. package/src/components/layout/shell/terminal-pointer-runtime.ts +18 -9
  77. package/src/components/layout/shell/window-mode/index.ts +8 -10
  78. package/src/components/layout/status-bar.tsx +6 -1
  79. package/src/components/layout/window-edit/mode.ts +39 -7
  80. package/src/components/layout/window-edit/presentation.ts +1 -1
  81. package/src/components/onboarding/first-run-workspace.ts +44 -2
  82. package/src/components/onboarding/onboarding-frame.tsx +11 -2
  83. package/src/components/onboarding/onboarding-keyboard.ts +20 -0
  84. package/src/components/onboarding/onboarding-wizard.tsx +16 -11
  85. package/src/components/onboarding/portfolio-step/positions-panel.tsx +62 -1
  86. package/src/components/onboarding/use-onboarding-progress.ts +12 -4
  87. package/src/components/pane-settings-dialog/desktop.tsx +2 -2
  88. package/src/components/pane-settings-dialog/tui.tsx +2 -2
  89. package/src/components/pane-settings-dialog/value.ts +6 -0
  90. package/src/components/pane-settings-dialog.tsx +3 -3
  91. package/src/components/reader/detail-reader.tsx +4 -0
  92. package/src/components/ui/button.tsx +2 -0
  93. package/src/components/ui/choice-dialog.tsx +1 -0
  94. package/src/components/ui/data-table/index.tsx +4 -3
  95. package/src/components/ui/index.ts +1 -1
  96. package/src/components/ui/list-view.tsx +7 -12
  97. package/src/components/ui/loading.tsx +10 -3
  98. package/src/components/ui/menu.tsx +6 -2
  99. package/src/components/ui/page-stack-view.tsx +3 -0
  100. package/src/components/ui/pane-link-chip.tsx +269 -54
  101. package/src/components/ui/query-bar.tsx +2 -1
  102. package/src/components/ui/quote.ts +14 -1
  103. package/src/components/ui/tabs.tsx +97 -19
  104. package/src/core/state/app/layout-reducer.ts +7 -0
  105. package/src/core/state/app/layout.ts +44 -7
  106. package/src/core/state/app/state.ts +1 -1
  107. package/src/core/state/app/types.ts +22 -2
  108. package/src/data/config/layout.ts +5 -2
  109. package/src/docs/snapshot.json +54 -13
  110. package/src/i18n/es.ts +9 -8
  111. package/src/i18n/ja.ts +9 -8
  112. package/src/i18n/ko.ts +9 -8
  113. package/src/i18n/zh-cn.ts +9 -8
  114. package/src/i18n/zh-tw.ts +9 -8
  115. package/src/layout/pane-manager/floating-actions.ts +17 -0
  116. package/src/layout/pane-manager/floating-stack.ts +187 -0
  117. package/src/layout/pane-manager/floating.ts +4 -2
  118. package/src/layout/pane-manager/gridlock.ts +5 -1
  119. package/src/layout/pane-manager/index.ts +11 -0
  120. package/src/layout/pane-manager/layout-state.ts +10 -3
  121. package/src/market-data/depositary-pair.ts +5 -3
  122. package/src/market-data/futures-board.ts +46 -1
  123. package/src/market-data/futures-contract.ts +12 -3
  124. package/src/market-data/fx-interventions.ts +270 -0
  125. package/src/market-data/market/dated-previous-close.ts +94 -15
  126. package/src/market-data/market/status.ts +17 -1
  127. package/src/news/news-model.ts +44 -2
  128. package/src/plugins/builtin/alerts/cli.ts +4 -4
  129. package/src/plugins/builtin/alerts/format.ts +1 -2
  130. package/src/plugins/builtin/alerts/headless.ts +1 -2
  131. package/src/plugins/builtin/alerts/move-checks.ts +12 -6
  132. package/src/plugins/builtin/alerts/move.ts +30 -9
  133. package/src/plugins/builtin/alerts/pane.tsx +0 -2
  134. package/src/plugins/builtin/alerts/storage.ts +4 -2
  135. package/src/plugins/builtin/alerts/types.ts +12 -0
  136. package/src/plugins/builtin/analytics/risk-client.ts +10 -4
  137. package/src/plugins/builtin/analytics/risk-episodes.ts +5 -4
  138. package/src/plugins/builtin/analytics/risk-headless.ts +4 -2
  139. package/src/plugins/builtin/analytics/risk-sectors.ts +91 -0
  140. package/src/plugins/builtin/awards/index.tsx +1 -1
  141. package/src/plugins/builtin/buildout/index.tsx +1 -0
  142. package/src/plugins/builtin/catalysts/index.tsx +2 -2
  143. package/src/plugins/builtin/cds/headless.ts +4 -0
  144. package/src/plugins/builtin/changelog/index.tsx +292 -101
  145. package/src/plugins/builtin/changelog/versions.ts +293 -0
  146. package/src/plugins/builtin/chart-composer/headless.ts +2 -1
  147. package/src/plugins/builtin/chart-composer/index.tsx +1 -0
  148. package/src/plugins/builtin/chart-composer/intervention-events.ts +105 -0
  149. package/src/plugins/builtin/chart-composer/pane.tsx +21 -7
  150. package/src/plugins/builtin/chat/content/composer.tsx +5 -4
  151. package/src/plugins/builtin/chat/content/index.tsx +12 -2
  152. package/src/plugins/builtin/chat/content/layout-metrics.ts +3 -3
  153. package/src/plugins/builtin/chat/content/open-targets.ts +3 -3
  154. package/src/plugins/builtin/chat/layout.ts +5 -2
  155. package/src/plugins/builtin/chat/message/pane-chip.tsx +61 -40
  156. package/src/plugins/builtin/chat/message/render-state.ts +2 -5
  157. package/src/plugins/builtin/chat/message/terminal.tsx +13 -15
  158. package/src/plugins/builtin/chat/pane-links/previews.ts +51 -5
  159. package/src/plugins/builtin/chat/pane-links/share-card.ts +36 -0
  160. package/src/plugins/builtin/cloud/askg/attached-pane.tsx +10 -5
  161. package/src/plugins/builtin/cloud/askg/controller.ts +141 -5
  162. package/src/plugins/builtin/cloud/askg/executor.ts +113 -4
  163. package/src/plugins/builtin/cloud/askg/manifest.ts +28 -13
  164. package/src/plugins/builtin/cloud/askg/model.ts +14 -4
  165. package/src/plugins/builtin/cloud/askg/pane.tsx +70 -46
  166. package/src/plugins/builtin/cloud/askg/tool-display.ts +1 -0
  167. package/src/plugins/builtin/cloud/askg/turn-parts.tsx +70 -0
  168. package/src/plugins/builtin/cloud/terminal-relay/engine.ts +50 -130
  169. package/src/plugins/builtin/cloud/terminal-relay/policy.ts +327 -7
  170. package/src/plugins/builtin/cloud/terminal-relay/prompts.tsx +2 -1
  171. package/src/plugins/builtin/cloud/terminal-relay/redact.ts +52 -9
  172. package/src/plugins/builtin/commodities-energy/index.tsx +1 -3
  173. package/src/plugins/builtin/commodities-energy/view-state.ts +3 -0
  174. package/src/plugins/builtin/commodity-balances/index.tsx +1 -0
  175. package/src/plugins/builtin/company-attention/index.tsx +1 -1
  176. package/src/plugins/builtin/company-kpis/headless.ts +3 -1
  177. package/src/plugins/builtin/company-kpis/index.tsx +2 -2
  178. package/src/plugins/builtin/cot/headless.ts +14 -2
  179. package/src/plugins/builtin/cot/index.tsx +1 -1
  180. package/src/plugins/builtin/cpi/index.tsx +1 -1
  181. package/src/plugins/builtin/crypto-board/index.tsx +1 -0
  182. package/src/plugins/builtin/dividend-yield/index.tsx +1 -0
  183. package/src/plugins/builtin/doe/index.tsx +1 -1
  184. package/src/plugins/builtin/earnings/index.tsx +2 -2
  185. package/src/plugins/builtin/earnings-calls/headless.ts +5 -1
  186. package/src/plugins/builtin/earnings-calls/index.tsx +1 -0
  187. package/src/plugins/builtin/econ/calendar-model.ts +74 -1
  188. package/src/plugins/builtin/econ/fred-catalog.ts +3 -1
  189. package/src/plugins/builtin/econ/index.tsx +1 -0
  190. package/src/plugins/builtin/econ-statistics/index.tsx +1 -0
  191. package/src/plugins/builtin/econ-statistics/pane.tsx +6 -0
  192. package/src/plugins/builtin/estimate-revisions/index.tsx +1 -0
  193. package/src/plugins/builtin/executives/index.tsx +1 -0
  194. package/src/plugins/builtin/filing-events/index.tsx +1 -0
  195. package/src/plugins/builtin/fixed-income/index.tsx +1 -0
  196. package/src/plugins/builtin/futures/index.tsx +25 -4
  197. package/src/plugins/builtin/futures/model.ts +28 -32
  198. package/src/plugins/builtin/futures/series.ts +4 -3
  199. package/src/plugins/builtin/futures/table.tsx +16 -9
  200. package/src/plugins/builtin/futures/use-board-terms.ts +3 -3
  201. package/src/plugins/builtin/futures-curve/headless.ts +3 -3
  202. package/src/plugins/builtin/futures-curve/index.tsx +1 -1
  203. package/src/plugins/builtin/futures-curve/model.ts +18 -0
  204. package/src/plugins/builtin/gpu/index.tsx +1 -1
  205. package/src/plugins/builtin/help/functions-table.tsx +1 -1
  206. package/src/plugins/builtin/help/index.tsx +14 -4
  207. package/src/plugins/builtin/help/keybindings-editor.tsx +19 -5
  208. package/src/plugins/builtin/holders/index.tsx +1 -0
  209. package/src/plugins/builtin/holders/report-header.ts +2 -2
  210. package/src/plugins/builtin/insider/index.tsx +1 -0
  211. package/src/plugins/builtin/iv-history/index.tsx +1 -1
  212. package/src/plugins/builtin/jobs/index.tsx +1 -0
  213. package/src/plugins/builtin/layout-manager/index.tsx +8 -8
  214. package/src/plugins/builtin/macro-day/headless.ts +27 -8
  215. package/src/plugins/builtin/macro-day/index.tsx +1 -1
  216. package/src/plugins/builtin/macro-day/model.ts +19 -3
  217. package/src/plugins/builtin/macro-day/pane.tsx +14 -9
  218. package/src/plugins/builtin/macro-day/releases.ts +25 -7
  219. package/src/plugins/builtin/market-valuation/index.tsx +1 -0
  220. package/src/plugins/builtin/market-valuation/pane.tsx +8 -0
  221. package/src/plugins/builtin/members/index.tsx +1 -1
  222. package/src/plugins/builtin/mna/index.tsx +1 -0
  223. package/src/plugins/builtin/news/headless.ts +2 -2
  224. package/src/plugins/builtin/news/index.tsx +4 -3
  225. package/src/plugins/builtin/news/wire/index.tsx +5 -1
  226. package/src/plugins/builtin/news/wire/news/detail-view.tsx +4 -0
  227. package/src/plugins/builtin/news/wire/news/list-search.ts +5 -2
  228. package/src/plugins/builtin/options/index.tsx +1 -0
  229. package/src/plugins/builtin/options-positioning/index.tsx +1 -0
  230. package/src/plugins/builtin/pe-band/index.tsx +1 -1
  231. package/src/plugins/builtin/perps/markets-section.tsx +5 -2
  232. package/src/plugins/builtin/plugin-marketplace/pane.tsx +11 -11
  233. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +25 -0
  234. package/src/plugins/builtin/portfolio-list/headless.ts +15 -6
  235. package/src/plugins/builtin/portfolio-list/summary/index.tsx +3 -1
  236. package/src/plugins/builtin/power/index.tsx +1 -1
  237. package/src/plugins/builtin/realized-vol/index.tsx +1 -1
  238. package/src/plugins/builtin/research/event-model.ts +9 -1
  239. package/src/plugins/builtin/research/event-sources.ts +22 -0
  240. package/src/plugins/builtin/research/headless.ts +11 -5
  241. package/src/plugins/builtin/research/index.tsx +4 -0
  242. package/src/plugins/builtin/research-search/index.tsx +1 -0
  243. package/src/plugins/builtin/research-search/pane.tsx +8 -0
  244. package/src/plugins/builtin/revenue-breakdown/index.tsx +1 -0
  245. package/src/plugins/builtin/reverse-dcf/index.tsx +1 -1
  246. package/src/plugins/builtin/risk-factors/index.tsx +1 -0
  247. package/src/plugins/builtin/scanner/headless.ts +52 -13
  248. package/src/plugins/builtin/seasonality/index.tsx +1 -1
  249. package/src/plugins/builtin/sec/index.tsx +1 -0
  250. package/src/plugins/builtin/series-inventory.ts +1 -1
  251. package/src/plugins/builtin/shared/cloud-upgrade.ts +27 -3
  252. package/src/plugins/builtin/shared/scanner-capture.ts +11 -3
  253. package/src/plugins/builtin/shared/series-list-detail.tsx +5 -0
  254. package/src/plugins/builtin/short-interest/index.tsx +1 -0
  255. package/src/plugins/builtin/social-mentions/index.tsx +1 -1
  256. package/src/plugins/builtin/supply-chain/index.tsx +1 -0
  257. package/src/plugins/builtin/thirteenf/data.ts +43 -10
  258. package/src/plugins/builtin/thirteenf/headless.ts +55 -11
  259. package/src/plugins/builtin/thirteenf/model.ts +25 -9
  260. package/src/plugins/builtin/thirteenf/report-notes.ts +27 -6
  261. package/src/plugins/builtin/thirteenf/types.ts +2 -0
  262. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +1 -1
  263. package/src/plugins/builtin/ticker-detail/financials/model.ts +12 -0
  264. package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +3 -3
  265. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +5 -5
  266. package/src/plugins/builtin/ticker-detail/headless.ts +18 -13
  267. package/src/plugins/builtin/ticker-detail/index.tsx +4 -0
  268. package/src/plugins/builtin/ticker-detail/overview/components.tsx +54 -5
  269. package/src/plugins/builtin/ticker-detail/overview/model.ts +6 -4
  270. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +34 -17
  271. package/src/plugins/builtin/ticker-detail/pane.tsx +7 -2
  272. package/src/plugins/builtin/time-sales/client.ts +9 -11
  273. package/src/plugins/builtin/time-sales/index.tsx +1 -1
  274. package/src/plugins/builtin/treasury-auctions/after.ts +267 -0
  275. package/src/plugins/builtin/treasury-auctions/cache.ts +18 -3
  276. package/src/plugins/builtin/treasury-auctions/client.ts +33 -2
  277. package/src/plugins/builtin/treasury-auctions/headless.ts +109 -19
  278. package/src/plugins/builtin/treasury-auctions/index.tsx +14 -4
  279. package/src/plugins/builtin/treasury-auctions/model.ts +256 -28
  280. package/src/plugins/builtin/treasury-auctions/pane.tsx +139 -28
  281. package/src/plugins/builtin/treasury-auctions/treasury-direct.ts +5 -2
  282. package/src/plugins/builtin/treasury-auctions/types.ts +7 -1
  283. package/src/plugins/builtin/vol-surface/index.tsx +1 -1
  284. package/src/plugins/builtin/world-venue-map/index.ts +1 -0
  285. package/src/plugins/builtin/yield-curve/curves.ts +10 -4
  286. package/src/plugins/builtin/yield-curve/headless.ts +6 -2
  287. package/src/plugins/builtin/yield-curve/index.tsx +3 -3
  288. package/src/plugins/builtin/yield-curve/series.ts +10 -0
  289. package/src/plugins/builtin/yield-curve/world.ts +3 -1
  290. package/src/plugins/installer.ts +45 -0
  291. package/src/portfolio/column-values.ts +2 -1
  292. package/src/public/__snapshots__/public-api.test.ts.snap +4 -0
  293. package/src/public/remote.ts +7 -1
  294. package/src/remote/client.ts +191 -11
  295. package/src/remote/controller-utils.ts +13 -1
  296. package/src/remote/controller.ts +88 -26
  297. package/src/remote/endpoint.ts +24 -0
  298. package/src/remote/form.ts +59 -4
  299. package/src/remote/resources.ts +56 -19
  300. package/src/remote/schema.ts +22 -9
  301. package/src/remote/secrets.ts +12 -0
  302. package/src/remote/semantic-helpers.ts +29 -1
  303. package/src/remote/semantic-tree.tsx +44 -15
  304. package/src/remote/server.ts +2 -1
  305. package/src/remote/surface.tsx +192 -0
  306. package/src/remote/types.ts +5 -0
  307. package/src/renderers/cloudflare/worker.ts +16 -1
  308. package/src/renderers/dom/styles.css +40 -6
  309. package/src/renderers/opentui/host.tsx +6 -0
  310. package/src/renderers/share/layout-view.tsx +1 -1
  311. package/src/series/standalone.ts +2 -2
  312. package/src/shares/api.ts +21 -4
  313. package/src/shares/item.ts +73 -0
  314. package/src/shares/pane-item.ts +205 -0
  315. package/src/shares/pane.ts +4 -0
  316. package/src/shares/payload.ts +9 -5
  317. package/src/sources/gloomberb-cloud/news.ts +37 -12
  318. package/src/state/opening-ticker-panes.ts +47 -0
  319. package/src/test-support/cli-context.ts +2 -0
  320. package/src/test-support/preload.ts +4 -1
  321. package/src/tickers/instrument-kind.ts +23 -3
  322. package/src/tickers/renamed-listings.ts +105 -0
  323. package/src/tickers/search/index.ts +103 -16
  324. package/src/time-series/resolve.ts +2 -2
  325. package/src/types/config.ts +5 -0
  326. package/src/types/context-menu.ts +2 -0
  327. package/src/types/financials.ts +1 -0
  328. package/src/types/plugin-commands.ts +140 -0
  329. package/src/types/plugin-context.ts +125 -0
  330. package/src/types/plugin-contributions.ts +55 -0
  331. package/src/types/plugin-definition.ts +234 -0
  332. package/src/types/plugin-notifications.ts +38 -0
  333. package/src/types/plugin-pane-settings.ts +116 -0
  334. package/src/types/plugin-pane-templates.ts +160 -0
  335. package/src/types/plugin-panes.ts +243 -0
  336. package/src/types/plugin-reports.ts +35 -0
  337. package/src/types/plugin-shared.ts +14 -0
  338. package/src/types/plugin-state.ts +71 -0
  339. package/src/types/plugin.ts +14 -1169
  340. package/src/ui/index.tsx +14 -3
  341. package/src/updater/github-releases.ts +23 -0
  342. package/src/utils/central-banks.ts +86 -1
  343. package/src/utils/cli-output.ts +22 -9
  344. package/src/utils/datetime-format.ts +12 -3
  345. package/src/utils/depositary-receipt.ts +28 -3
  346. package/src/utils/fundamentals.ts +14 -0
  347. package/src/utils/max-drawdown.ts +97 -16
  348. package/src/utils/untrusted-text.ts +29 -0
@@ -1,4 +1,6 @@
1
1
  import type { DataTableColumn } from "../../../components";
2
+ import { dropColumnsToFit } from "../../../components/ui/table-layout";
3
+ import { displayWidth } from "../../../utils/format";
2
4
  import { compareSortValues, type SortDirection } from "../../../utils/sort-values";
3
5
  import { AUCTION_HISTORY_ALL, AUCTION_HISTORY_DAYS, AUCTION_HISTORY_START, type AuctionHistoryWindow } from "./client";
4
6
  import type { TreasuryAuction } from "./types";
@@ -20,9 +22,10 @@ const AUCTION_HISTORY_LABELS: Record<string, { label: string; phrase: string }>
20
22
  [AUCTION_HISTORY_ALL]: { label: `All, since ${AUCTION_HISTORY_START.slice(0, 4)}`, phrase: `every auction since ${AUCTION_HISTORY_START}` },
21
23
  };
22
24
 
23
- /** The window as the settings menu names it: "120 days", "5 years". */
25
+ /** The window as the settings menu names it: "120 days", "5 years"; the default says so. */
24
26
  export function auctionHistoryLabel(window: AuctionHistoryWindow): string {
25
- return AUCTION_HISTORY_LABELS[window]?.label ?? `${window} days`;
27
+ const label = AUCTION_HISTORY_LABELS[window]?.label ?? `${window} days`;
28
+ return window === AUCTION_HISTORY_DAYS ? `${label} (default)` : label;
26
29
  }
27
30
 
28
31
  /** The window inside a sentence: "the last 120 days", "the last 5 years". */
@@ -48,7 +51,18 @@ export function auctionHistoryWindow(settings: Record<string, unknown> | undefin
48
51
  export const AUCTION_SEARCH_FIELDS = "type, benchmark (10Y), term, CUSIP, or date (YYYY-MM-DD)";
49
52
 
50
53
  export type AuctionColumnId =
51
- | "date" | "type" | "term" | "rate" | "stopOut" | "btc" | "indirect" | "direct" | "dealer" | "size";
54
+ | "date" | "type" | "term" | "rate" | "stopOut" | "btc" | "indirect" | "direct" | "dealer" | "size" | "cusip"
55
+ | "btcPctl" | "indirectPctl" | "dealerPctl" | "after1d" | "after5d" | "after20d";
56
+
57
+ /** What the after view adds to a row: its percentiles and the yield's moves after it (after.ts). */
58
+ export interface AuctionAfterFigures {
59
+ btcPercentile: number | null;
60
+ indirectPercentile: number | null;
61
+ dealerPercentile: number | null;
62
+ after1d: number | null;
63
+ after5d: number | null;
64
+ after20d: number | null;
65
+ }
52
66
 
53
67
  export interface AuctionColumn extends DataTableColumn {
54
68
  id: AuctionColumnId;
@@ -75,8 +89,39 @@ export const AUCTION_SORT_COLUMN_IDS: readonly AuctionColumnId[] = [
75
89
  "direct",
76
90
  "dealer",
77
91
  "size",
92
+ "cusip",
93
+ ];
94
+
95
+ /** The after view's columns, in the order [ and ] step through them. */
96
+ export const AUCTION_AFTER_SORT_COLUMN_IDS: readonly AuctionColumnId[] = [
97
+ "date", "type", "term", "rate", "btc", "btcPctl", "indirectPctl", "dealerPctl", "after1d", "after5d", "after20d", "cusip",
78
98
  ];
79
99
 
100
+ /** `--sort` as typed, and the column it sorts. */
101
+ export const AUCTION_SORT_NAMES: ReadonlyArray<{ value: string; column: AuctionColumnId; aliases?: string[] }> = [
102
+ { value: "date", column: "date" },
103
+ { value: "type", column: "type" },
104
+ { value: "term", column: "term" },
105
+ { value: "rate", column: "rate", aliases: ["yield"] },
106
+ { value: "vs-median", column: "stopOut", aliases: ["vs-med", "vs-average", "vs-avg", "stop-out", "stopout"] },
107
+ { value: "btc", column: "btc", aliases: ["b/c", "bid-to-cover", "bc"] },
108
+ { value: "indirect", column: "indirect" },
109
+ { value: "direct", column: "direct" },
110
+ { value: "dealer", column: "dealer" },
111
+ { value: "size", column: "size" },
112
+ { value: "cusip", column: "cusip" },
113
+ { value: "btc-pctl", column: "btcPctl", aliases: ["btc-percentile", "bc-pctl"] },
114
+ { value: "indirect-pctl", column: "indirectPctl", aliases: ["indirect-percentile"] },
115
+ { value: "dealer-pctl", column: "dealerPctl", aliases: ["dealer-percentile"] },
116
+ { value: "1d", column: "after1d", aliases: ["after-1d", "+1d"] },
117
+ { value: "5d", column: "after5d", aliases: ["after-5d", "+5d"] },
118
+ { value: "20d", column: "after20d", aliases: ["after-20d", "+20d"] },
119
+ ];
120
+
121
+ /** The after view's columns are its own; the results view's sort by its own. */
122
+ export const isAfterColumn = (column: AuctionColumnId) =>
123
+ column === "btcPctl" || column === "indirectPctl" || column === "dealerPctl" || column === "after1d" || column === "after5d" || column === "after20d";
124
+
80
125
  export type AuctionFilter = "all" | "bill" | "note" | "bond";
81
126
 
82
127
  export const AUCTION_FILTERS: ReadonlyArray<{ value: AuctionFilter; label: string }> = [
@@ -133,7 +178,7 @@ interface Benchmark {
133
178
  * at auction is what the market calls the auction, so a 5-year auction that
134
179
  * reopens an older 7-year note is still the 5Y.
135
180
  */
136
- function auctionBenchmark(term: string): Benchmark | null {
181
+ export function auctionBenchmark(term: string): Benchmark | null {
137
182
  const parts = termParts(term);
138
183
  if (!parts) return null;
139
184
  if (parts.year) {
@@ -245,16 +290,45 @@ export function dealerPct(auction: TreasuryAuction): number | null {
245
290
  }
246
291
 
247
292
  /**
248
- * The stop-out (high yield) minus the average/median yield Treasury publishes
249
- * for the same auction, in basis points; a wider gap means the last dollars
250
- * had to clear well above where most of the auction priced. Bills compare
251
- * discount rates, which is how they trade. FRNs and auctions missing either
252
- * leg are null.
293
+ * Treasury has sold every note, bond and bill at a single price since November
294
+ * 1998, and publishes the median accepted bid in its average/median field.
295
+ * Before, most auctions were multiple-price and the field is the average.
296
+ */
297
+ const SINGLE_PRICE_FROM = "1998-11-01";
298
+
299
+ /** Whether an auction's average/median figure is the median (single-price) rather than the average. */
300
+ export const publishesMedian = (auction: Pick<TreasuryAuction, "auctionDate">) => auction.auctionDate >= SINGLE_PRICE_FROM;
301
+
302
+ /** The detail's name for the stop-out spread: against the median, or the average before November 1998. */
303
+ export const stopOutLabel = (auction: TreasuryAuction) => publishesMedian(auction) ? "Stop-out vs median" : "Stop-out vs average";
304
+
305
+ /** The detail's name for the middle figure itself: "Median yield", "Average discount rate". */
306
+ export function middleRateLabel(auction: TreasuryAuction, rate: "yield" | "discount rate"): string {
307
+ return `${publishesMedian(auction) ? "Median" : "Average"} ${rate}`;
308
+ }
309
+
310
+ /**
311
+ * The stop-out column's heading for a list: VS MED when every row is from
312
+ * November 1998 on, VS AVG when every row is older, both when it spans the change.
313
+ */
314
+ export function stopOutColumnLabel(auctions: readonly TreasuryAuction[], style: "pane" | "report"): string {
315
+ const median = auctions.some(publishesMedian);
316
+ const average = auctions.some((auction) => !publishesMedian(auction));
317
+ const which = median && average ? ["AVG/MED", "average/median"] : average ? ["AVG", "average"] : ["MED", "median"];
318
+ return style === "pane" ? `VS ${which[0]}` : `Stop-out vs ${which[1]} (bp)`;
319
+ }
320
+
321
+ /**
322
+ * The stop-out (high yield) minus the median yield Treasury publishes for the
323
+ * same auction (the average before November 1998: publishesMedian), in basis
324
+ * points; a wider gap means the last dollars had to clear well above where
325
+ * most of the auction priced. Bills compare discount rates, which is how they
326
+ * trade. FRNs and auctions missing either leg are null.
253
327
  *
254
328
  * This is not a tail: a tail is the stop-out against the 1 pm when-issued
255
329
  * yield, which the source does not carry.
256
330
  */
257
- export function stopOutVsAverageBp(auction: TreasuryAuction): number | null {
331
+ export function stopOutVsAvgBp(auction: TreasuryAuction): number | null {
258
332
  if (auction.secType === "FRN") return null;
259
333
  const bill = FILTER_TYPES.bill.has(auction.secType);
260
334
  const high = bill ? auction.highDiscountRate : auction.highYield;
@@ -276,7 +350,16 @@ export function rateValue(auction: TreasuryAuction): number | null {
276
350
  /** Treasury's name for the rate rateValue reports; a bill's High Rate is its discount rate. */
277
351
  export function rateLabel(auction: TreasuryAuction): string {
278
352
  if (auction.secType === "FRN") return "High discount margin";
279
- return FILTER_TYPES.bill.has(auction.secType) ? "Investment rate" : "High yield";
353
+ return isBill(auction) ? "Investment rate" : "High yield";
354
+ }
355
+
356
+ /** A bill or cash management bill: its headline rate is the investment rate, and it trades on its discount rate. */
357
+ export const isBill = (auction: TreasuryAuction) => FILTER_TYPES.bill.has(auction.secType);
358
+
359
+ /** The rate column's heading: a board of bills says its rate is the investment rate Treasury states beside the discount rate. */
360
+ export function rateColumnLabel(auctions: readonly TreasuryAuction[], style: "pane" | "report"): string {
361
+ const bills = auctions.length > 0 && auctions.every(isBill);
362
+ return style === "pane" ? bills ? "INV RATE" : "RATE" : bills ? "Investment rate" : "Rate";
280
363
  }
281
364
 
282
365
  /**
@@ -293,9 +376,14 @@ export function formatAuctionRate(auction: TreasuryAuction, value: number | null
293
376
  return auction.secType === "FRN" ? `${(value * 100).toFixed(1)}bp` : `${value.toFixed(3)}%`;
294
377
  }
295
378
 
296
- /** Announced auctions appear in the feed days before any results are published. */
379
+ /**
380
+ * Announced auctions appear in the feed days before any results are published.
381
+ * An early bill whose investment rate was blanked (inClearingOrder) still has
382
+ * its discount rates, so it is a result, not an announcement.
383
+ */
297
384
  export function isPendingAuction(auction: TreasuryAuction): boolean {
298
- return rateValue(auction) == null && auction.bidToCoverRatio == null;
385
+ return rateValue(auction) == null && auction.bidToCoverRatio == null
386
+ && auction.highDiscountRate == null && auction.avgMedDiscountRate == null && auction.avgMedYield == null;
299
387
  }
300
388
 
301
389
  /**
@@ -329,7 +417,7 @@ export function auctionSize(auction: TreasuryAuction): number | null {
329
417
  return auction.offeringAmount ?? auction.totalAccepted;
330
418
  }
331
419
 
332
- function sortValue(auction: TreasuryAuction, columnId: AuctionColumnId): number | string | null {
420
+ function sortValue(auction: TreasuryAuction, columnId: AuctionColumnId, after?: AuctionAfterFigures): number | string | null {
333
421
  switch (columnId) {
334
422
  case "date": return auctionDateValue(auction.auctionDate);
335
423
  case "type": return auction.secType;
@@ -338,24 +426,32 @@ function sortValue(auction: TreasuryAuction, columnId: AuctionColumnId): number
338
426
  return days === Number.MAX_SAFE_INTEGER ? null : days;
339
427
  }
340
428
  case "rate": return rateValue(auction);
341
- case "stopOut": return stopOutVsAverageBp(auction);
429
+ case "stopOut": return stopOutVsAvgBp(auction);
342
430
  case "btc": return auction.bidToCoverRatio;
343
431
  case "indirect": return indirectPct(auction);
344
432
  case "direct": return directPct(auction);
345
433
  case "dealer": return dealerPct(auction);
346
434
  case "size": return auctionSize(auction);
435
+ case "cusip": return auction.cusip;
436
+ case "btcPctl": return after?.btcPercentile ?? null;
437
+ case "indirectPctl": return after?.indirectPercentile ?? null;
438
+ case "dealerPctl": return after?.dealerPercentile ?? null;
439
+ case "after1d": return after?.after1d ?? null;
440
+ case "after5d": return after?.after5d ?? null;
441
+ case "after20d": return after?.after20d ?? null;
347
442
  }
348
443
  }
349
444
 
350
445
  export function visibleAuctions(
351
446
  auctions: readonly TreasuryAuction[],
352
- options: { filter: AuctionFilter; query: string; sort: AuctionSortPreference },
447
+ options: { filter: AuctionFilter; query: string; sort: AuctionSortPreference; after?: ReadonlyMap<string, AuctionAfterFigures>; from?: string },
353
448
  ): TreasuryAuction[] {
354
449
  return auctions
355
- .filter((auction) => matchesFilter(auction, options.filter) && matchesAuctionQuery(auction, options.query))
450
+ .filter((auction) => matchesFilter(auction, options.filter) && matchesAuctionQuery(auction, options.query)
451
+ && (!options.from || auction.auctionDate >= options.from))
356
452
  .sort((left, right) => {
357
- const leftValue = sortValue(left, options.sort.columnId);
358
- const rightValue = sortValue(right, options.sort.columnId);
453
+ const leftValue = sortValue(left, options.sort.columnId, options.after?.get(left.id));
454
+ const rightValue = sortValue(right, options.sort.columnId, options.after?.get(right.id));
359
455
  const comparison = compareSortValues(
360
456
  typeof leftValue === "string" ? leftValue.toLowerCase() : leftValue,
361
457
  typeof rightValue === "string" ? rightValue.toLowerCase() : rightValue,
@@ -369,7 +465,7 @@ export function visibleAuctions(
369
465
 
370
466
  /** Text columns read best ascending; every metric reads best highest-first. */
371
467
  export function firstAuctionSortDirection(columnId: AuctionColumnId): SortDirection {
372
- return columnId === "type" || columnId === "term" ? "asc" : "desc";
468
+ return columnId === "type" || columnId === "term" || columnId === "cusip" ? "asc" : "desc";
373
469
  }
374
470
 
375
471
  /**
@@ -382,21 +478,153 @@ export function auctionDatesShowYear(window: AuctionHistoryWindow): boolean {
382
478
 
383
479
  /**
384
480
  * Widths are the data's own; the table widens a column to its label plus the
385
- * sort arrow. All ten columns then take 93 cells. TERM takes the spare width
386
- * but never less than the longest term ("29-Year 10-Month"), so a narrower
387
- * pane scrolls sideways instead of clipping it.
481
+ * sort arrow. TERM is as wide as the longest term listed, and the CUSIP closes
482
+ * the row where the pane has room for it, taking what width is left; a pane
483
+ * too narrow for the rest scrolls sideways instead of clipping a figure.
388
484
  */
389
- export function buildAuctionColumns(showYear = false): AuctionColumn[] {
390
- return [
485
+ export function buildAuctionColumns(options: {
486
+ showYear?: boolean;
487
+ view?: "results" | "after";
488
+ rows?: readonly TreasuryAuction[];
489
+ /** The table's width; without one every column is listed. */
490
+ width?: number;
491
+ } = {}): AuctionColumn[] {
492
+ const { showYear = false, view = "results", rows = [], width } = options;
493
+ const term = Math.max(6, ...rows.map((auction) => displayWidth(auction.securityTerm)));
494
+ const lead: AuctionColumn[] = [
391
495
  { id: "date", label: "DATE", width: showYear ? 10 : 6, align: "left" },
392
496
  { id: "type", label: "TYPE", width: 6, align: "left" },
393
- { id: "term", label: "TERM", width: 16, align: "left", flexGrow: 1 },
394
- { id: "rate", label: "RATE", width: 7, align: "right" },
395
- { id: "stopOut", label: "VS AVG", width: 7, align: "right" },
497
+ { id: "term", label: "TERM", width: term, align: "left" },
498
+ { id: "rate", label: rateColumnLabel(rows, "pane"), width: 7, align: "right" },
499
+ ];
500
+ const figures: AuctionColumn[] = view === "after" ? [
501
+ { id: "btc", label: "B/C", width: 5, align: "right" },
502
+ { id: "btcPctl", label: "B/C PCTL", width: 4, align: "right", title: "Bid-to-cover percentile against the tenor's last 24 auctions" },
503
+ { id: "indirectPctl", label: "IND PCTL", width: 4, align: "right", title: "Indirect share percentile against the tenor's last 24 auctions" },
504
+ { id: "dealerPctl", label: "DLR PCTL", width: 4, align: "right", title: "Dealer share percentile against the tenor's last 24 auctions" },
505
+ { id: "after1d", label: "+1D BP", width: 5, align: "right", title: "Treasury yield change one session after the auction, bp" },
506
+ { id: "after5d", label: "+5D BP", width: 5, align: "right", title: "Treasury yield change five sessions after the auction, bp" },
507
+ { id: "after20d", label: "+20D BP", width: 5, align: "right", title: "Treasury yield change twenty sessions after the auction, bp" },
508
+ ] : [
509
+ { id: "stopOut", label: stopOutColumnLabel(rows, "pane"), width: 7, align: "right", title: "Stop-out vs median yield (average before November 1998), bp" },
396
510
  { id: "btc", label: "B/C", width: 5, align: "right" },
397
511
  { id: "indirect", label: "INDIRECT", width: 8, align: "right" },
398
512
  { id: "direct", label: "DIRECT", width: 6, align: "right" },
399
513
  { id: "dealer", label: "DEALER", width: 6, align: "right" },
400
514
  { id: "size", label: "SIZE", width: 7, align: "right" },
401
515
  ];
516
+ const columns: AuctionColumn[] = [...lead, ...figures, { id: "cusip", label: "CUSIP", width: 9, align: "left", flexGrow: 1 }];
517
+ if (width == null) return columns;
518
+ const shown = dropColumnsToFit(columns, width, ["cusip"]);
519
+ // Without the CUSIP nothing grows: the figures keep their places at the left.
520
+ return shown.length === columns.length ? shown : shown.map((column) => ({ ...column, flexGrow: undefined }));
521
+ }
522
+
523
+ /**
524
+ * What `AUCT 10Y --history-days 3650` asks of the pane, typed in the command
525
+ * bar as it is to `fn AUCT`: the search, and the window, group, view and sort
526
+ * given as flags (`--history-days`, `--historyDays` or `--history`;
527
+ * `--filter`, `--view`, `--sort`), each as `--flag value` or `--flag=value`.
528
+ * A flag whose value is not one of its own is left out.
529
+ */
530
+ function parseAuctionCommandArg(arg: string | undefined): {
531
+ search: string;
532
+ historyDays?: AuctionHistoryWindow;
533
+ filter?: AuctionFilter;
534
+ view?: "results" | "after";
535
+ /** The sort's name as `--sort` takes it: "btc-pctl". */
536
+ sort?: string;
537
+ } {
538
+ const tokens = (arg ?? "").trim().split(/\s+/).filter(Boolean);
539
+ const words: string[] = [];
540
+ const parsed: ReturnType<typeof parseAuctionCommandArg> = { search: "" };
541
+ for (let index = 0; index < tokens.length; index++) {
542
+ const token = tokens[index]!;
543
+ const flag = /^--([a-z-]+)(?:=(.*))?$/i.exec(token);
544
+ if (!flag) {
545
+ words.push(token);
546
+ continue;
547
+ }
548
+ const name = flag[1]!.toLowerCase().replace(/-/g, "");
549
+ const value = (flag[2] ?? tokens[++index] ?? "").toLowerCase();
550
+ if (name === "historydays" || name === "history") {
551
+ const window = auctionHistoryWindow({ historyDays: value });
552
+ if (value === AUCTION_HISTORY_ALL || String(window) === value) parsed.historyDays = window;
553
+ } else if (name === "filter") {
554
+ const filter = AUCTION_FILTERS.find((entry) => entry.value === value)?.value;
555
+ if (filter) parsed.filter = filter;
556
+ } else if (name === "view") {
557
+ if (value === "results" || value === "after") parsed.view = value;
558
+ } else if (name === "sort") {
559
+ const sort = auctionSortColumn(value);
560
+ const name = sort && AUCTION_SORT_NAMES.find((entry) => entry.column === sort)?.value;
561
+ if (name) parsed.sort = name;
562
+ }
563
+ }
564
+ parsed.search = words.join(" ");
565
+ return parsed;
566
+ }
567
+
568
+ /**
569
+ * What `AUCT <arg>` asks of the pane: the search and every view key, defaults
570
+ * included, since an open pane merges a command's params into its own; a plain
571
+ * `AUCT 10Y` after `AUCT 7Y --view after --sort 5d --filter note` opens on
572
+ * results, newest first, all types. A window is a setting, sent when named.
573
+ */
574
+ export function auctionCommandRequest(arg: string | undefined): {
575
+ params: Record<string, string>;
576
+ settings: Record<string, string> | null;
577
+ } {
578
+ const { search, historyDays, filter, view, sort } = parseAuctionCommandArg(arg);
579
+ return {
580
+ params: { search, auctionView: view ?? "results", auctionSort: sort ?? "date", auctionFilter: filter ?? "all" },
581
+ settings: historyDays != null ? { historyDays: String(historyDays) } : null,
582
+ };
583
+ }
584
+
585
+ /** The column `--sort` names, by its name or an alias; null for anything else. */
586
+ export function auctionSortColumn(value: string): AuctionColumnId | null {
587
+ const name = value.trim().toLowerCase();
588
+ return AUCTION_SORT_NAMES.find((entry) => entry.value === name || entry.aliases?.includes(name))?.column ?? null;
589
+ }
590
+
591
+ /** A query for a market AUCT does not cover: another country's government paper. */
592
+ const NON_US_PAPER = /\b(jgb|jgbs|gilt|gilts|bund|bunds|bobl|schatz|oat|oats|btp|btps|bono|bonos|acgb|cgb|cgbs|ktb|ktbs|sgs|btf|euro|eur|gbp|jpy|uk|japan|japanese|german|germany|france|french|italy|italian|spain|canada|canadian|australia|australian|china|chinese|korea|singapore|india|indian|brazil|mexico)\b/i;
593
+
594
+ /** Whether a search names another market's government paper, which AUCT does not list. */
595
+ export function namesOtherMarket(query: string): boolean {
596
+ return NON_US_PAPER.test(query.trim());
597
+ }
598
+
599
+ /** A whole CUSIP: nine letters and digits with a digit. */
600
+ const isWholeCusip = (query: string) => /^[a-z0-9]{9}$/i.test(query.trim()) && /\d/.test(query);
601
+
602
+ /**
603
+ * Whether a longer window could list more rows for this search: not with
604
+ * every auction already read, not for another market's paper, not for a
605
+ * CUSIP whose first auction is listed (its reopenings come after it), and not
606
+ * for a date inside the window.
607
+ */
608
+ export function widerWindowCouldAdd(query: string, rows: readonly TreasuryAuction[], window: AuctionHistoryWindow, now = Date.now()): boolean {
609
+ if (window === AUCTION_HISTORY_ALL) return false;
610
+ const text = query.trim();
611
+ if (!text) return true;
612
+ if (namesOtherMarket(text)) return false;
613
+ const from = new Date(now - window * 86_400_000).toISOString().slice(0, 10);
614
+ const date = /\b(\d{4})(?:-(\d{2}))?(?:-(\d{2}))?\b/.exec(text);
615
+ if (date && !parseBenchmarkQuery(text.toLowerCase())) {
616
+ // The latest day the search can mean: a year's last day, a month's last day, the day itself.
617
+ const latest = date[3] ? date[0] : date[2] ? `${date[1]}-${date[2]}-31` : `${date[1]}-12-31`;
618
+ return latest < from;
619
+ }
620
+ if (isWholeCusip(text)) {
621
+ // A note or bond reopening's term has a month part (9-Year 10-Month); its first auction's is whole (10-Year).
622
+ // A bill's term is whole either way: a 13-week bill can reopen a 26-week CUSIP, so a bill is never known first.
623
+ const first = rows.some((auction) => {
624
+ const parts = termParts(auction.securityTerm);
625
+ return !isBill(auction) && !!parts && Object.keys(parts).length === 1;
626
+ });
627
+ return !first;
628
+ }
629
+ return true;
402
630
  }