gloomberb 0.20.4 → 0.20.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (316) hide show
  1. package/README.md +3 -1
  2. package/README.zh-CN.md +1 -1
  3. package/bin/gloom +9 -0
  4. package/bin/without-bun.cjs +98 -0
  5. package/package.json +4 -1
  6. package/src/api-client/data.ts +148 -37
  7. package/src/api-client/hk-tenders.ts +59 -0
  8. package/src/api-client/index.ts +1 -0
  9. package/src/api-client/types/econ.ts +30 -0
  10. package/src/api-client/yield-curves.ts +1 -1
  11. package/src/app/global-shortcuts.ts +4 -1
  12. package/src/app/keybindings/actions.ts +6 -0
  13. package/src/app/keybindings/config.ts +2 -1
  14. package/src/app/keybindings/index.ts +1 -0
  15. package/src/app/keybindings/labels.ts +6 -1
  16. package/src/app/keybindings/resolve.ts +23 -4
  17. package/src/app/keybindings/terminal-keys.ts +35 -0
  18. package/src/app/pane-runtime/index.tsx +2 -2
  19. package/src/app/pane-runtime/ticker-open-runtime.ts +68 -40
  20. package/src/app.tsx +18 -13
  21. package/src/architecture/floating-promise-allowlist.json +313 -0
  22. package/src/architecture/ui-literals-allowlist.json +1 -1
  23. package/src/capabilities/chart-series.ts +27 -1
  24. package/src/cli/commands/keybindings.ts +5 -5
  25. package/src/cli/commands/market.ts +238 -57
  26. package/src/cli/commands/news-search.ts +81 -14
  27. package/src/cli/commands/overview.ts +27 -6
  28. package/src/cli/commands/remote.ts +16 -17
  29. package/src/cli/commands/system.ts +1 -1
  30. package/src/cli/commands/ticker.ts +3 -1
  31. package/src/cli/early-command.ts +2 -0
  32. package/src/cli/errors.ts +10 -1
  33. package/src/cli/fx-forward.ts +89 -7
  34. package/src/cli/fx-pair.ts +1 -1
  35. package/src/cli/fx-quote-rate.ts +23 -0
  36. package/src/cli/glossary.ts +19 -5
  37. package/src/cli/help.ts +1 -0
  38. package/src/cli/history-rows.ts +5 -3
  39. package/src/cli/index-roots.ts +5 -4
  40. package/src/cli/index.ts +40 -3
  41. package/src/cli/known-gaps.ts +38 -9
  42. package/src/cli/listing-arg.ts +17 -5
  43. package/src/cli/name-entries.ts +5 -1
  44. package/src/cli/not-a-ticker.ts +4 -0
  45. package/src/cli/options.ts +52 -3
  46. package/src/cli/output-file.ts +5 -3
  47. package/src/cli/pane-functions/catalog.ts +15 -0
  48. package/src/cli/pane-functions/function-help.ts +4 -4
  49. package/src/cli/pane-functions/headless.ts +9 -4
  50. package/src/cli/pane-functions/index.ts +6 -4
  51. package/src/cli/pane-functions/resolver.ts +2 -2
  52. package/src/cli/result.ts +21 -2
  53. package/src/cli/spreadsheet-hint.ts +7 -3
  54. package/src/cli/treasury-yields.ts +5 -3
  55. package/src/components/chart/composite/legend.tsx +40 -2
  56. package/src/components/command-bar/pane-settings.ts +2 -2
  57. package/src/components/command-bar/routes/root/results.ts +6 -2
  58. package/src/components/command-bar/workflow/tickers.ts +2 -2
  59. package/src/components/data-table/view.tsx +9 -2
  60. package/src/components/input-search-bar.tsx +9 -2
  61. package/src/components/layout/pane/header.tsx +2 -0
  62. package/src/components/layout/shell/pane/capture.ts +4 -1
  63. package/src/components/layout/status-bar.tsx +6 -1
  64. package/src/components/onboarding/first-run-workspace.ts +44 -2
  65. package/src/components/onboarding/onboarding-frame.tsx +11 -2
  66. package/src/components/onboarding/onboarding-keyboard.ts +16 -0
  67. package/src/components/onboarding/onboarding-wizard.tsx +8 -8
  68. package/src/components/onboarding/portfolio-step/positions-panel.tsx +62 -1
  69. package/src/components/onboarding/use-onboarding-progress.ts +12 -4
  70. package/src/components/pane-settings-dialog/desktop.tsx +2 -2
  71. package/src/components/pane-settings-dialog/tui.tsx +2 -2
  72. package/src/components/pane-settings-dialog/value.ts +6 -0
  73. package/src/components/pane-settings-dialog.tsx +3 -3
  74. package/src/components/reader/detail-reader.tsx +4 -0
  75. package/src/components/ui/data-table/opentui/index.tsx +11 -4
  76. package/src/components/ui/data-table/opentui/model.ts +8 -6
  77. package/src/components/ui/data-table/types.ts +6 -1
  78. package/src/components/ui/index.ts +1 -1
  79. package/src/components/ui/page-stack-view.tsx +3 -0
  80. package/src/components/ui/pane-link-chip.tsx +269 -54
  81. package/src/components/ui/query-bar.tsx +2 -1
  82. package/src/components/ui/table-layout.ts +38 -1
  83. package/src/components/ui/tabs.tsx +97 -19
  84. package/src/core/state/app/layout-reducer.ts +7 -0
  85. package/src/core/state/app/layout.ts +44 -7
  86. package/src/core/state/app/state.ts +1 -1
  87. package/src/core/state/app/types.ts +22 -2
  88. package/src/docs/snapshot.json +30 -13
  89. package/src/market-data/depositary-pair.ts +5 -3
  90. package/src/market-data/market/change-basis.ts +9 -5
  91. package/src/market-data/market/dated-previous-close.ts +147 -17
  92. package/src/market-data/market/status.ts +17 -1
  93. package/src/market-data/quotes/contributions.ts +2 -0
  94. package/src/market-data/quotes/listing-enterprise-value.ts +50 -0
  95. package/src/plugins/builtin/alerts/metric-data.ts +15 -2
  96. package/src/plugins/builtin/analytics/risk-client.ts +10 -4
  97. package/src/plugins/builtin/analytics/risk-episodes.ts +5 -4
  98. package/src/plugins/builtin/analytics/risk-headless.ts +4 -2
  99. package/src/plugins/builtin/analytics/risk-sectors.ts +91 -0
  100. package/src/plugins/builtin/awards/index.tsx +1 -1
  101. package/src/plugins/builtin/backtest/headless.ts +1 -1
  102. package/src/plugins/builtin/buildout/index.tsx +1 -0
  103. package/src/plugins/builtin/catalysts/index.tsx +2 -2
  104. package/src/plugins/builtin/cds/headless.ts +4 -0
  105. package/src/plugins/builtin/cds/model.ts +0 -6
  106. package/src/plugins/builtin/chart-composer/formula.ts +16 -3
  107. package/src/plugins/builtin/chart-composer/headless-schema.ts +2 -0
  108. package/src/plugins/builtin/chart-composer/headless.ts +4 -2
  109. package/src/plugins/builtin/chart-composer/index.tsx +1 -0
  110. package/src/plugins/builtin/chart-composer/presets.ts +1 -0
  111. package/src/plugins/builtin/chat/content/composer.tsx +5 -4
  112. package/src/plugins/builtin/chat/content/index.tsx +12 -2
  113. package/src/plugins/builtin/chat/content/layout-metrics.ts +3 -3
  114. package/src/plugins/builtin/chat/content/open-targets.ts +3 -3
  115. package/src/plugins/builtin/chat/layout.ts +5 -2
  116. package/src/plugins/builtin/chat/message/pane-chip.tsx +61 -40
  117. package/src/plugins/builtin/chat/message/terminal.tsx +13 -15
  118. package/src/plugins/builtin/chat/pane-links/previews.ts +51 -5
  119. package/src/plugins/builtin/chat/pane-links/share-card.ts +36 -0
  120. package/src/plugins/builtin/cloud/askg/pane.tsx +55 -13
  121. package/src/plugins/builtin/cloud/askg/tool-display.ts +1 -0
  122. package/src/plugins/builtin/cloud/terminal-relay/redact.ts +5 -3
  123. package/src/plugins/builtin/commodity-balances/index.tsx +1 -0
  124. package/src/plugins/builtin/company-attention/index.tsx +1 -1
  125. package/src/plugins/builtin/company-kpis/headless.ts +3 -1
  126. package/src/plugins/builtin/company-kpis/index.tsx +2 -2
  127. package/src/plugins/builtin/cot/index.tsx +1 -1
  128. package/src/plugins/builtin/cpi/index.tsx +1 -1
  129. package/src/plugins/builtin/credit-boards/cdx-pane.tsx +20 -7
  130. package/src/plugins/builtin/credit-boards/client.ts +8 -0
  131. package/src/plugins/builtin/credit-boards/headless.ts +4 -1
  132. package/src/plugins/builtin/credit-boards/model.ts +58 -4
  133. package/src/plugins/builtin/credit-boards/series.ts +63 -6
  134. package/src/plugins/builtin/credit-boards/sovr-pane.tsx +3 -2
  135. package/src/plugins/builtin/credit-conditions/headless.ts +24 -6
  136. package/src/plugins/builtin/credit-conditions/index.tsx +1 -1
  137. package/src/plugins/builtin/credit-conditions/model.ts +12 -6
  138. package/src/plugins/builtin/credit-conditions/series.ts +2 -1
  139. package/src/plugins/builtin/crypto-board/index.tsx +1 -0
  140. package/src/plugins/builtin/dividend-yield/index.tsx +1 -0
  141. package/src/plugins/builtin/doe/index.tsx +1 -1
  142. package/src/plugins/builtin/earnings-calls/headless.ts +5 -1
  143. package/src/plugins/builtin/earnings-calls/index.tsx +1 -0
  144. package/src/plugins/builtin/econ/calendar-model.ts +115 -8
  145. package/src/plugins/builtin/econ/calendar-source.ts +7 -1
  146. package/src/plugins/builtin/econ/fred-catalog.ts +3 -1
  147. package/src/plugins/builtin/econ/index.tsx +42 -8
  148. package/src/plugins/builtin/econ/types.ts +3 -0
  149. package/src/plugins/builtin/econ-statistics/index.tsx +1 -0
  150. package/src/plugins/builtin/econ-statistics/pane.tsx +6 -0
  151. package/src/plugins/builtin/estimate-revisions/index.tsx +1 -0
  152. package/src/plugins/builtin/executives/index.tsx +1 -0
  153. package/src/plugins/builtin/filing-events/index.tsx +1 -0
  154. package/src/plugins/builtin/fixed-income/index.tsx +3 -0
  155. package/src/plugins/builtin/futures-curve/headless.ts +3 -3
  156. package/src/plugins/builtin/futures-curve/index.tsx +1 -1
  157. package/src/plugins/builtin/futures-curve/model.ts +18 -0
  158. package/src/plugins/builtin/fx-matrix/index.tsx +44 -14
  159. package/src/plugins/builtin/gpu/index.tsx +1 -1
  160. package/src/plugins/builtin/help/functions-table.tsx +1 -1
  161. package/src/plugins/builtin/help/index.tsx +11 -1
  162. package/src/plugins/builtin/help/keybindings-editor.tsx +7 -3
  163. package/src/plugins/builtin/holders/index.tsx +1 -0
  164. package/src/plugins/builtin/holders/report-header.ts +2 -2
  165. package/src/plugins/builtin/insider/index.tsx +1 -0
  166. package/src/plugins/builtin/iv-history/index.tsx +1 -1
  167. package/src/plugins/builtin/jobs/index.tsx +1 -0
  168. package/src/plugins/builtin/macro-day/headless.ts +27 -8
  169. package/src/plugins/builtin/macro-day/index.tsx +1 -1
  170. package/src/plugins/builtin/macro-day/model.ts +19 -3
  171. package/src/plugins/builtin/macro-day/pane.tsx +14 -9
  172. package/src/plugins/builtin/macro-day/releases.ts +25 -7
  173. package/src/plugins/builtin/market-valuation/index.tsx +1 -0
  174. package/src/plugins/builtin/market-valuation/pane.tsx +8 -0
  175. package/src/plugins/builtin/members/index.tsx +1 -1
  176. package/src/plugins/builtin/mna/index.tsx +1 -0
  177. package/src/plugins/builtin/news/index.tsx +1 -0
  178. package/src/plugins/builtin/news/wire/index.tsx +5 -1
  179. package/src/plugins/builtin/news/wire/news/detail-view.tsx +4 -0
  180. package/src/plugins/builtin/news/wire/news/list-search.ts +5 -2
  181. package/src/plugins/builtin/options/index.tsx +1 -0
  182. package/src/plugins/builtin/options-positioning/index.tsx +1 -0
  183. package/src/plugins/builtin/pe-band/index.tsx +1 -1
  184. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +25 -0
  185. package/src/plugins/builtin/portfolio-list/cli/render.ts +20 -3
  186. package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +5 -1
  187. package/src/plugins/builtin/portfolio-list/headless.ts +15 -6
  188. package/src/plugins/builtin/power/index.tsx +1 -1
  189. package/src/plugins/builtin/realized-vol/index.tsx +1 -1
  190. package/src/plugins/builtin/research/headless-schema.ts +4 -3
  191. package/src/plugins/builtin/research/headless.ts +10 -4
  192. package/src/plugins/builtin/research/index.tsx +4 -0
  193. package/src/plugins/builtin/research/relative-valuation-columns.ts +145 -47
  194. package/src/plugins/builtin/research/relative-valuation-currency.ts +31 -0
  195. package/src/plugins/builtin/research/relative-valuation-headless.ts +25 -8
  196. package/src/plugins/builtin/research/relative-valuation-model.ts +40 -9
  197. package/src/plugins/builtin/research/relative-valuation-pane.tsx +3 -2
  198. package/src/plugins/builtin/research/relative-valuation-peers.ts +2 -2
  199. package/src/plugins/builtin/research-search/index.tsx +1 -0
  200. package/src/plugins/builtin/research-search/pane.tsx +8 -0
  201. package/src/plugins/builtin/revenue-breakdown/index.tsx +1 -0
  202. package/src/plugins/builtin/reverse-dcf/index.tsx +1 -1
  203. package/src/plugins/builtin/risk-factors/index.tsx +1 -0
  204. package/src/plugins/builtin/scanner/headless.ts +52 -13
  205. package/src/plugins/builtin/seasonality/index.tsx +1 -1
  206. package/src/plugins/builtin/sec/index.tsx +1 -0
  207. package/src/plugins/builtin/series-inventory.ts +1 -1
  208. package/src/plugins/builtin/shared/scanner-capture.ts +11 -3
  209. package/src/plugins/builtin/shared/series-list-detail.tsx +5 -0
  210. package/src/plugins/builtin/short-interest/index.tsx +1 -0
  211. package/src/plugins/builtin/social-mentions/index.tsx +1 -1
  212. package/src/plugins/builtin/supply-chain/index.tsx +1 -0
  213. package/src/plugins/builtin/thirteenf/api.ts +47 -4
  214. package/src/plugins/builtin/thirteenf/data.ts +43 -10
  215. package/src/plugins/builtin/thirteenf/headless.ts +55 -11
  216. package/src/plugins/builtin/thirteenf/model.ts +25 -9
  217. package/src/plugins/builtin/thirteenf/report-notes.ts +27 -6
  218. package/src/plugins/builtin/thirteenf/types.ts +2 -0
  219. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +1 -1
  220. package/src/plugins/builtin/ticker-detail/data-panes/historical-prices.tsx +8 -7
  221. package/src/plugins/builtin/ticker-detail/data-panes/history-bars.ts +8 -5
  222. package/src/plugins/builtin/ticker-detail/financials/model.ts +18 -2
  223. package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +3 -3
  224. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +6 -6
  225. package/src/plugins/builtin/ticker-detail/headless.ts +24 -17
  226. package/src/plugins/builtin/ticker-detail/index.tsx +4 -0
  227. package/src/plugins/builtin/ticker-detail/overview/model.ts +6 -4
  228. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +6 -4
  229. package/src/plugins/builtin/time-sales/client.ts +9 -11
  230. package/src/plugins/builtin/time-sales/index.tsx +1 -1
  231. package/src/plugins/builtin/treasury-auctions/after.ts +267 -0
  232. package/src/plugins/builtin/treasury-auctions/cache.ts +54 -5
  233. package/src/plugins/builtin/treasury-auctions/client.ts +33 -2
  234. package/src/plugins/builtin/treasury-auctions/headless.ts +150 -22
  235. package/src/plugins/builtin/treasury-auctions/hk-headless.ts +126 -0
  236. package/src/plugins/builtin/treasury-auctions/hk-view.tsx +347 -0
  237. package/src/plugins/builtin/treasury-auctions/hk.ts +363 -0
  238. package/src/plugins/builtin/treasury-auctions/index.tsx +27 -4
  239. package/src/plugins/builtin/treasury-auctions/model.ts +264 -28
  240. package/src/plugins/builtin/treasury-auctions/pane.tsx +176 -41
  241. package/src/plugins/builtin/treasury-auctions/treasury-direct.ts +5 -2
  242. package/src/plugins/builtin/treasury-auctions/types.ts +7 -1
  243. package/src/plugins/builtin/vol-surface/index.tsx +1 -1
  244. package/src/plugins/builtin/world-venue-map/index.ts +1 -0
  245. package/src/plugins/builtin/yield-curve/curves.ts +10 -4
  246. package/src/plugins/builtin/yield-curve/headless.ts +6 -2
  247. package/src/plugins/builtin/yield-curve/index.tsx +3 -3
  248. package/src/plugins/builtin/yield-curve/series.ts +10 -0
  249. package/src/plugins/builtin/yield-curve/world.ts +3 -1
  250. package/src/portfolio/collection-name.ts +22 -0
  251. package/src/portfolio/column-values.ts +2 -1
  252. package/src/public/__snapshots__/public-api.test.ts.snap +4 -0
  253. package/src/public/remote.ts +7 -1
  254. package/src/remote/client.ts +191 -11
  255. package/src/remote/controller-utils.ts +13 -1
  256. package/src/remote/controller.ts +88 -26
  257. package/src/remote/endpoint.ts +24 -0
  258. package/src/remote/form.ts +59 -4
  259. package/src/remote/resources.ts +44 -18
  260. package/src/remote/schema.ts +21 -9
  261. package/src/remote/secrets.ts +12 -0
  262. package/src/remote/semantic-tree.tsx +14 -2
  263. package/src/remote/server.ts +2 -1
  264. package/src/remote/surface.tsx +192 -0
  265. package/src/remote/types.ts +5 -0
  266. package/src/renderers/dom/data-table/frozen-column.ts +3 -1
  267. package/src/renderers/dom/data-table/index.tsx +27 -9
  268. package/src/renderers/dom/data-table/row.tsx +2 -0
  269. package/src/renderers/electrobun/bun/desktop/backend.ts +27 -24
  270. package/src/renderers/electrobun/bun/desktop/detached-windows.ts +3 -3
  271. package/src/renderers/electrobun/bun/desktop/snapshot-commit.ts +77 -0
  272. package/src/renderers/electrobun/shared/protocol.ts +4 -0
  273. package/src/renderers/electrobun/view/backend-rpc.ts +3 -0
  274. package/src/renderers/electrobun/view/desktop/window/bridge.ts +3 -0
  275. package/src/renderers/opentui/host.tsx +6 -0
  276. package/src/series/standalone.ts +2 -2
  277. package/src/shares/api.ts +21 -4
  278. package/src/shares/item.ts +73 -0
  279. package/src/shares/pane-item.ts +205 -0
  280. package/src/shares/pane.ts +4 -0
  281. package/src/shares/payload.ts +9 -5
  282. package/src/sources/gloomberb-cloud/news.ts +2 -0
  283. package/src/sources/gloomberb-cloud/normalizers.ts +9 -5
  284. package/src/sources/provider-router/cache.ts +3 -1
  285. package/src/sync/controller.ts +17 -2
  286. package/src/sync/other-window-tabs.ts +32 -1
  287. package/src/sync/react.ts +4 -4
  288. package/src/tickers/renamed-listings.ts +105 -0
  289. package/src/tickers/search/index.ts +103 -16
  290. package/src/time-series/bar-spacing.ts +33 -0
  291. package/src/time-series/base-series.ts +21 -3
  292. package/src/time-series/chart-bounds.ts +31 -0
  293. package/src/time-series/field-catalog.ts +17 -0
  294. package/src/time-series/fundamentals.ts +143 -11
  295. package/src/time-series/ice-credit.ts +32 -6
  296. package/src/time-series/resolve.ts +11 -7
  297. package/src/time-series/session-bar.ts +78 -9
  298. package/src/time-series/studies/formula.ts +53 -10
  299. package/src/time-series/studies/pair.ts +18 -7
  300. package/src/time-series/studies/units.ts +49 -2
  301. package/src/time-series/types.ts +12 -0
  302. package/src/types/desktop-window.ts +2 -0
  303. package/src/types/financials.ts +7 -0
  304. package/src/types/headless.ts +8 -0
  305. package/src/types/plugin-pane-settings.ts +2 -0
  306. package/src/types/plugin-panes.ts +22 -0
  307. package/src/utils/central-banks.ts +86 -1
  308. package/src/utils/cli-output.ts +6 -3
  309. package/src/utils/datetime-format.ts +12 -3
  310. package/src/utils/depositary-receipt.ts +28 -3
  311. package/src/utils/ebitda.ts +128 -0
  312. package/src/utils/format.ts +1 -1
  313. package/src/utils/fundamentals.ts +14 -0
  314. package/src/utils/max-drawdown.ts +97 -16
  315. package/src/utils/shell-word.ts +13 -0
  316. package/src/utils/untrusted-text.ts +29 -0
@@ -30,6 +30,7 @@ import {
30
30
  getPaneSidebarWidth,
31
31
  IconButton,
32
32
  MessageComposer,
33
+ PaneStatusBody,
33
34
  Prose,
34
35
  shouldShowPaneSidebar,
35
36
  usePaneFooter,
@@ -706,6 +707,10 @@ export function ASKGPane({ paneId, focused, width, height }: PaneProps) {
706
707
  // The expanded result's rows have the keyboard: j/k walk them and Enter
707
708
  // opens one. x moves in, Esc comes back to the timeline.
708
709
  const [resultFocused, setResultFocused] = useState(false);
710
+ // A conversation that could not be loaded: its failure takes the body until
711
+ // anything else is opened or asked.
712
+ const [openFailure, setOpenFailure] = useState<{ conversationId: string; message: string } | null>(null);
713
+ const openRequestRef = useRef(0);
709
714
 
710
715
  const conversations = useSyncExternalStore(
711
716
  useCallback((listener) => askgConversationListStore.subscribe(listener), []),
@@ -798,11 +803,19 @@ export function ASKGPane({ paneId, focused, width, height }: PaneProps) {
798
803
  // With a pane attached, the question in the field is about it; the examples are not.
799
804
  const examples = attached ? NO_EXAMPLES : profileExamples;
800
805
 
806
+ // Anything opened or asked since takes the body back from a conversation
807
+ // that failed to load, and a load still out no longer shows its failure.
808
+ const dropOpenFailure = useCallback(() => {
809
+ openRequestRef.current += 1;
810
+ setOpenFailure(null);
811
+ }, []);
812
+
801
813
  const ask = useCallback((question: string) => {
802
814
  const trimmed = question.trim();
803
815
  if (!trimmed) return;
816
+ dropOpenFailure();
804
817
  void controller.ask(trimmed);
805
- }, [controller]);
818
+ }, [controller, dropOpenFailure]);
806
819
 
807
820
  const focusInput = useCallback(() => {
808
821
  setInputFocused(true);
@@ -831,9 +844,10 @@ export function ASKGPane({ paneId, focused, width, height }: PaneProps) {
831
844
  if (focusedRef.current) focusInput();
832
845
  }, [ask, focusInput]);
833
846
  const retryAndCompose = useCallback((turnId: string) => {
847
+ dropOpenFailure();
834
848
  void controller.retryTurn(turnId);
835
849
  if (focusedRef.current) focusInput();
836
- }, [controller, focusInput]);
850
+ }, [controller, dropOpenFailure, focusInput]);
837
851
 
838
852
  const resetTimeline = useCallback(() => {
839
853
  setSelectedId(null);
@@ -841,14 +855,29 @@ export function ASKGPane({ paneId, focused, width, height }: PaneProps) {
841
855
  setOpenGroups(new Set());
842
856
  setExampleIndex(null);
843
857
  setFeedbackFollowUpTurnId(null);
844
- }, []);
858
+ dropOpenFailure();
859
+ }, [dropOpenFailure]);
845
860
 
846
- const openConversation = useCallback(async (conversationId: string) => {
847
- setSidebarFocused(false);
848
- setSidebarCursorId(null);
849
- if (focusedRef.current) focusInput();
850
- if (conversationId === state.conversationId) return;
851
- const conversation = await apiClient.askg.loadConversation(conversationId);
861
+ /** Loads a conversation into the body; one that cannot be loaded leaves its failure there. */
862
+ const showConversation = useCallback(async (conversationId: string) => {
863
+ if (conversationId === state.conversationId) {
864
+ dropOpenFailure();
865
+ return;
866
+ }
867
+ const request = ++openRequestRef.current;
868
+ let conversation: Awaited<ReturnType<typeof apiClient.askg.loadConversation>>;
869
+ try {
870
+ conversation = await apiClient.askg.loadConversation(conversationId);
871
+ } catch (error) {
872
+ logFailure("cloud.askg.pane", "Load a conversation failed")(error);
873
+ if (request !== openRequestRef.current) return;
874
+ resetTimeline();
875
+ setOpenFailure({
876
+ conversationId,
877
+ message: error instanceof Error && error.message ? error.message : "Could not load this conversation.",
878
+ });
879
+ return;
880
+ }
852
881
  // A row the sidebar still shows may be gone; the refresh drops it.
853
882
  if (!conversation) {
854
883
  void askgConversationListStore.refresh();
@@ -857,7 +886,14 @@ export function ASKGPane({ paneId, focused, width, height }: PaneProps) {
857
886
  resetTimeline();
858
887
  setAttached(null);
859
888
  controller.openConversation(conversation);
860
- }, [controller, focusInput, resetTimeline, setAttached, state.conversationId]);
889
+ }, [controller, dropOpenFailure, resetTimeline, setAttached, state.conversationId]);
890
+
891
+ const openConversation = useCallback((conversationId: string) => {
892
+ setSidebarFocused(false);
893
+ setSidebarCursorId(null);
894
+ if (focusedRef.current) focusInput();
895
+ showConversation(conversationId).catch(logFailure("cloud.askg.pane", "Open a conversation failed"));
896
+ }, [focusInput, showConversation]);
861
897
 
862
898
  const newConversation = useCallback(() => {
863
899
  resetTimeline();
@@ -1499,7 +1535,7 @@ export function ASKGPane({ paneId, focused, width, height }: PaneProps) {
1499
1535
  consume();
1500
1536
  const target = sidebarTargetId;
1501
1537
  leaveSidebar();
1502
- if (target) void openConversation(target);
1538
+ if (target) openConversation(target);
1503
1539
  else focusInput();
1504
1540
  } else if (isPlainKey(event, "j", "down")) {
1505
1541
  consume();
@@ -1896,7 +1932,7 @@ export function ASKGPane({ paneId, focused, width, height }: PaneProps) {
1896
1932
  height={height}
1897
1933
  focused={focused}
1898
1934
  keyboardFocused={focused}
1899
- onSelect={(conversationId) => void openConversation(conversationId)}
1935
+ onSelect={openConversation}
1900
1936
  onFocusRequest={() => {
1901
1937
  if (inputFocused) blurInput();
1902
1938
  setResultFocused(false);
@@ -1924,7 +1960,13 @@ export function ASKGPane({ paneId, focused, width, height }: PaneProps) {
1924
1960
  onMouseDown={() => setSidebarFocused(false)}
1925
1961
  >
1926
1962
  <ScrollBox ref={scrollRef} flexGrow={1} minHeight={0} scrollY focusable={false} paddingX={1}>
1927
- {state.turns.length === 0 ? (
1963
+ {openFailure ? (
1964
+ <PaneStatusBody
1965
+ subject="Conversation"
1966
+ error={openFailure.message}
1967
+ retry={{ onRetry: () => showConversation(openFailure.conversationId) }}
1968
+ />
1969
+ ) : state.turns.length === 0 ? (
1928
1970
  <ASKGWelcome
1929
1971
  examples={examples}
1930
1972
  width={contentWidth}
@@ -86,6 +86,7 @@ const TOOL_TITLES: Record<string, string> = {
86
86
  const RESOURCE_SUBJECTS: Record<string, string> = {
87
87
  "app://accounts": "broker accounts",
88
88
  "app://snapshot": "your layout",
89
+ "app://snapshot/full": "your layout",
89
90
  "app://panes": "open panes",
90
91
  "app://config": "settings",
91
92
  "app://layout/current": "your layout",
@@ -6,7 +6,9 @@
6
6
  * through here, with every such value replaced, so an assistant steered by
7
7
  * what it reads cannot copy a credential out of the terminal.
8
8
  */
9
- const SECRET_KEY = /(pass(word|phrase)?|secret|token|api[-_]?key|private[-_]?key|credential|cookie)/i;
9
+
10
+ import { SECRET_NAME } from "../../../../remote/secrets";
11
+
10
12
  /** Fields of a form field or input that hold what was typed. */
11
13
  const TYPED_VALUE_KEYS = ["value", "summary", "defaultValue", "initialValue"];
12
14
  export const REDACTED = "[redacted]";
@@ -24,7 +26,7 @@ function redactSecrets(value: unknown, depth = 0, withheld?: (secret: unknown) =
24
26
  const result: Record<string, unknown> = {};
25
27
  for (const [key, entry] of Object.entries(record)) {
26
28
  const filled = entry !== null && entry !== undefined && entry !== "" && typeof entry !== "boolean";
27
- if (filled && (SECRET_KEY.test(key) || (password && TYPED_VALUE_KEYS.includes(key)))) {
29
+ if (filled && (SECRET_NAME.test(key) || (password && TYPED_VALUE_KEYS.includes(key)))) {
28
30
  withheld?.(entry);
29
31
  result[key] = REDACTED;
30
32
  } else {
@@ -62,7 +64,7 @@ export function redactConfig(config: unknown): unknown {
62
64
  /** Resources that carry the whole configuration, before the general pass. */
63
65
  export function redactResource(resource: string, value: unknown): unknown {
64
66
  if (resource === "app://config") return redactConfig(value);
65
- if (resource === "app://snapshot" && value && typeof value === "object") {
67
+ if ((resource === "app://snapshot" || resource === "app://snapshot/full") && value && typeof value === "object") {
66
68
  const snapshot = value as Record<string, unknown>;
67
69
  return { ...snapshot, config: redactConfig(snapshot.config) };
68
70
  }
@@ -9,6 +9,7 @@ export const commodityBalancesModule: PluginModule = {
9
9
  id: "commodity-balances",
10
10
  name: "Crop Balances",
11
11
  icon: "B",
12
+ shareItem: { argument: true },
12
13
  get component(): typeof import("./pane").CommodityBalancesPane { const { CommodityBalancesPane } = require("./pane"); return CommodityBalancesPane; },
13
14
  defaultPosition: "right",
14
15
  defaultMode: "floating",
@@ -30,6 +30,6 @@ export const companyAttentionModule: PluginModule = {
30
30
  ctx.registerTickerResearchTab({ id: "app-attention", name: "Apps", order: 39, component: AppsPane, instruments: ["equity"] });
31
31
  },
32
32
  dispose() { attentionCache.reset(); movesCache.reset(); signalsCache.reset(); buildingCache.reset(); appRankCache.reset(); },
33
- panes: definitions.map((def) => ({ id: def.id, name: def.label, icon: def.prefix[0]!, component: def.component, defaultPosition: "right", defaultMode: "floating", defaultFloatingSize: { width: 130, height: 32 }, tickerFollower: true, instruments: ["equity"], tableExport: true, headless: attentionHeadless(def.id) })),
33
+ panes: definitions.map((def) => ({ id: def.id, name: def.label, icon: def.prefix[0]!, component: def.component, defaultPosition: "right", defaultMode: "floating", defaultFloatingSize: { width: 130, height: 32 }, shareItem: { ticker: true }, tickerFollower: true, instruments: ["equity"], tableExport: true, headless: attentionHeadless(def.id) })),
34
34
  paneTemplates: templates,
35
35
  };
@@ -29,7 +29,9 @@ function reportColumns(mode: CompanyMode, history: boolean, revisions: boolean,
29
29
  ...(revisions ? [{ id: "revision", label: "Revision", width: 12, align: "left" as const }] : [])];
30
30
  return [...withoutQuietColumns(columns, rows, (row, id) => companyCellText(row, id, observations), QUIET_COLUMNS).map((column): HeadlessPaneColumn => ({
31
31
  key: column.id === "value" && mode === "guidance" ? "rangeText" : ROW_KEYS[column.id] ?? column.id, header: column.label, align: column.align === "right" ? "right" : "left",
32
- format: (_value, row) => companyCellText(row as unknown as CompanyRow, column.id, observations),
32
+ format: (_value, row) => mode === "guidance" && column.id === "value" && typeof row.rangeText === "string" && /plus or minus|±/i.test(row.rangeText)
33
+ ? `${row.rangeText}${row.currency ? ` ${row.currency}` : ""}`
34
+ : companyCellText(row as unknown as CompanyRow, column.id, observations),
33
35
  })), { key: "asOf", header: "As of", format: (value) => typeof value === "string" ? value.slice(0, 10) : "--" }];
34
36
  }
35
37
 
@@ -11,9 +11,9 @@ export const companyKpisModule: PluginModule = {
11
11
  dispose() { companyKpisCache.reset(); },
12
12
  panes: [
13
13
  { id: "company-kpis", name: "Company KPIs", icon: "K", component: CompanyKpisPane, defaultPosition: "right", defaultMode: "floating",
14
- defaultFloatingSize: { width: 130, height: 30 }, tickerFollower: true, instruments: ["equity"], tableExport: true, headless: kpisHeadless },
14
+ defaultFloatingSize: { width: 130, height: 30 }, shareItem: { ticker: true }, tickerFollower: true, instruments: ["equity"], tableExport: true, headless: kpisHeadless },
15
15
  { id: "company-guidance", name: "Company Guidance", icon: "G", component: CompanyGuidancePane, defaultPosition: "right", defaultMode: "floating",
16
- defaultFloatingSize: { width: 130, height: 30 }, tickerFollower: true, instruments: ["equity"], tableExport: true, headless: guidanceHeadless },
16
+ defaultFloatingSize: { width: 130, height: 30 }, shareItem: { ticker: true }, tickerFollower: true, instruments: ["equity"], tableExport: true, headless: guidanceHeadless },
17
17
  ],
18
18
  paneTemplates: [
19
19
  { ...createTickerSurfacePaneTemplate({ id: "company-kpis-pane", paneId: "company-kpis", label: "Company KPIs", shortcut: "KPIS",
@@ -6,7 +6,7 @@ import { COT_SERIES } from "./series";
6
6
 
7
7
  export const cotModule: PluginModule = {
8
8
  series: COT_SERIES,
9
- panes: [{ id: "cot", name: "CFTC Positioning", icon: "P", get component(): typeof import("./pane").CotPane { const { CotPane } = require("./pane"); return CotPane; },
9
+ panes: [{ id: "cot", name: "CFTC Positioning", icon: "P", shareItem: { argument: true }, get component(): typeof import("./pane").CotPane { const { CotPane } = require("./pane"); return CotPane; },
10
10
  defaultPosition: "right", defaultMode: "floating", defaultFloatingSize: { width: 106, height: 30 },
11
11
  tableExport: true, headless: cotHeadless }],
12
12
  paneTemplates: [{ id: "cot-cot", paneId: "cot", label: "CFTC Positioning",
@@ -13,7 +13,7 @@ function cpiInstance(options?: PaneTemplateCreateOptions): PaneTemplateInstanceC
13
13
  }
14
14
 
15
15
  export const cpiModule: PluginModule = {
16
- panes: [{ id: "cpi", name: "US Consumer Prices", icon: "C", get component(): typeof import("./pane").CpiPane { const { CpiPane } = require("./pane"); return CpiPane; },
16
+ panes: [{ id: "cpi", name: "US Consumer Prices", icon: "C", shareItem: { argument: true }, get component(): typeof import("./pane").CpiPane { const { CpiPane } = require("./pane"); return CpiPane; },
17
17
  defaultPosition: "right", defaultMode: "floating", defaultFloatingSize: { width: 100, height: 36 },
18
18
  tableExport: true, headless: cpiHeadless }],
19
19
  paneTemplates: [{
@@ -18,9 +18,7 @@ import { useAutoRefresh } from "../../../react/auto-refresh";
18
18
  import { colors } from "../../../theme/colors";
19
19
  import { useThemeColors } from "../../../theme/theme-context";
20
20
  import type { PaneProps } from "../../../types/plugin";
21
- import { formatPercentileRank } from "../../../utils/format";
22
21
  import { usePluginPaneState } from "../../runtime";
23
- import { formatAsOf } from "../cds/model";
24
22
  import { FIXED_INCOME_PANE_ID } from "../fixed-income/model";
25
23
  import { useCommandValue } from "../shared/command-tab";
26
24
  import { getCachedCdxBoard, loadCdxBoard } from "./client";
@@ -31,6 +29,8 @@ import {
31
29
  formatContract,
32
30
  formatLevel,
33
31
  formatMove,
32
+ formatSpreadRank,
33
+ newestRowDate,
34
34
  partialDayText,
35
35
  SETTLEMENT_TEXT,
36
36
  type CdxRow,
@@ -65,14 +65,18 @@ function HistoryChart({ row, width, height, focused }: { row: CdxRow; width: num
65
65
  }
66
66
 
67
67
  function IndexDetail({ row, width, height, focused }: { row: CdxRow; width: number; height: number; focused: boolean }) {
68
- const { index, year, day } = row;
68
+ const { index, year, day, rank } = row;
69
69
  // While today trades the moves run to the last complete day, which the 1D says.
70
70
  const through = day.partial && day.changeDate ? `to ${day.changeDate}` : undefined;
71
+ // The rank sits beside what it ranks: HY and EM's spread equivalent, not their price.
72
+ const rankOnSpreadEq = rank.basis === "spread-eq";
73
+ const spreadDetail = [...(rankOnSpreadEq ? [formatSpreadRank(rank)] : []),
74
+ ...(index.recovery != null ? [`${Math.round(index.recovery * 100)}% recovery`] : [])].join(" · ");
71
75
  const items: StatItem[] = [
72
76
  { id: "level", label: index.quote === "spread" ? "5Y spread" : "5Y price", value: formatLevel(index.quote, index.level),
73
- detail: [formatPercentileRank(year.percentile, "1Y"), index.date ?? "--", ...(index.kind === "settlement" ? [SETTLEMENT_TEXT] : [])].join(" · ") },
77
+ detail: [...(rankOnSpreadEq ? [] : [formatSpreadRank(rank)]), index.date ?? "--", ...(index.kind === "settlement" ? [SETTLEMENT_TEXT] : [])].join(" · ") },
74
78
  ...(index.quote === "price" && index.spreadBp !== undefined ? [{ id: "spread", label: "Spread eq", value: formatLevel("spread", index.spreadBp ?? null),
75
- ...(index.recovery != null ? { detail: `${Math.round(index.recovery * 100)}% recovery` } : {}) }] : []),
79
+ ...(spreadDetail ? { detail: spreadDetail } : {}) }] : []),
76
80
  { id: "1d", label: "1D", value: formatMove(index.quote, day.change1D), ...(through ? { detail: through } : {}) },
77
81
  { id: "1w", label: "1W", value: formatMove(index.quote, day.change1W) },
78
82
  { id: "1m", label: "1M", value: formatMove(index.quote, day.change1M) },
@@ -106,12 +110,21 @@ export function CdxPane({ focused, width, height }: PaneProps) {
106
110
  useAutoRefresh(resource.updatedAt, refresh);
107
111
  usePaneRefreshKey(reload, { focused, enabled: !loading });
108
112
 
109
- const asOf = formatAsOf(payload?.asOf ?? null);
113
+ // Dated by the newest day the rows carry, not when the response was put together.
114
+ const asOf = newestRowDate(payload?.indexes.map((index) => index.date) ?? []);
115
+ // PCTL 1Y ranks spreads; the rows quoted in price (HY, EM) rank their spread equivalent, which a picture keeps.
116
+ const spreadEqRanked = useMemo(() => rows.filter((row) => row.rank.basis === "spread-eq")
117
+ .map((row) => row.index.name.replace(/^CDX\s+/i, "")).join(", "), [rows]);
110
118
  const info = useMemo<PaneFooterSegment[]>(() => [
111
119
  ...(asOf ? [{ id: "as-of", parts: [{ text: `as of ${asOf}`, tone: "muted" as const }] }] : []),
112
120
  ...(payload ? [DELAYED_SEGMENT] : []),
113
121
  ...(resource.data?.stale ? [{ id: "stale", parts: [{ text: "STALE", tone: "warning" as const }] }] : []),
114
- ], [asOf, payload, resource.data?.stale]);
122
+ ...(spreadEqRanked ? [{
123
+ id: "rank-basis", capture: true,
124
+ parts: [{ text: `${spreadEqRanked} pctl on spread eq`, tone: "muted" as const }],
125
+ variants: [[{ text: "pctl on spread eq", tone: "muted" as const }]],
126
+ }] : []),
127
+ ], [asOf, payload, resource.data?.stale, spreadEqRanked]);
115
128
  usePaneStatusFooter({
116
129
  registrationId: "cdx",
117
130
  loading,
@@ -73,6 +73,14 @@ export async function fetchSovrBoard(client: BoardClient = apiClient): Promise<S
73
73
  catch (error) { throw unavailableOnServer(error, "Sovereign CDS levels are not available yet."); }
74
74
  }
75
75
 
76
+ /** Daily levels: the full history a chart reaches back for stays good for an hour. */
77
+ export const fullCdxHistory = createTtlCache<CdxBoardPayload>({ ttlMs: 60 * 60_000 });
78
+
79
+ /** Every day of index history the server keeps, for a chart that reaches back past the board's year. */
80
+ export function loadFullCdxHistory(client: BoardClient = apiClient): Promise<CdxBoardPayload> {
81
+ return fullCdxHistory.load("all", () => fetchCdxBoard(client, CDX_MAX_DAYS));
82
+ }
83
+
76
84
  export const getCachedCdxBoard = () => cachedCloudResource(cdxBoardCache, "5y", validateCdxBoard);
77
85
  export const loadCdxBoard = (force = false) =>
78
86
  loadCloudResource(cdxBoardCache, "5y", () => fetchCdxBoard(), { force, validate: validateCdxBoard });
@@ -109,7 +109,10 @@ const CDX_COLUMNS: HeadlessPaneColumn[] = [
109
109
  moveColumn("change1W", "1W", "changeUnit"),
110
110
  moveColumn("change1M", "1M", "changeUnit"),
111
111
  spreadColumn,
112
- { key: "percentile", header: "Pctl 1Y", align: "right", format: percentile },
112
+ { key: "percentile", header: "Pctl 1Y", align: "right", format: percentile,
113
+ description: "Where the spread sits in its last year, 100 the widest. IG and iTraxx rank their spread; HY and EM rank the spread "
114
+ + "equivalent of each day's on-the-run contract, not their price; CMBX, quoted in price alone, ranks its price upside down, "
115
+ + "so its lowest price is 100. Blank with fewer than 20 days of spreads in the year." },
113
116
  { key: "prints", header: "Prints", align: "right" },
114
117
  { key: "contract", header: "Contract" },
115
118
  { key: "date", header: "As of" },
@@ -10,6 +10,7 @@ import { historyStatistics } from "../../../components/chart/curve/model";
10
10
  import type { MarketBoardRow } from "../../../components/market-board";
11
11
  import type { PricePoint } from "../../../types/financials";
12
12
  import type { HeadlessPaneColumn } from "../../../types/plugin";
13
+ import { formatPercentileRank } from "../../../utils/format";
13
14
 
14
15
  const YEAR_DAYS = 365;
15
16
  /** A level older than this is not the current market. */
@@ -173,12 +174,60 @@ interface YearStatistics {
173
174
  high: number | null;
174
175
  }
175
176
 
176
- /** Where the latest level sits in its own year: midrank, with the range. */
177
- function yearStatistics(points: readonly CreditBoardPoint[], level: number | null, date: string | null): YearStatistics {
177
+ /** Where the latest level sits in its own year: midrank, with the range, and no rank from fewer than `minCount` days. */
178
+ function yearStatistics(points: readonly CreditBoardPoint[], level: number | null, date: string | null, minCount = 2): YearStatistics {
178
179
  if (level == null || !date) return { percentile: null, low: null, high: null };
179
180
  const year = historyStatistics(points.map((point) => ({ date: point.date, value: point.level })), level,
180
181
  { asOf: date, windowDays: YEAR_DAYS });
181
- return { percentile: year.count >= 2 ? year.percentile : null, low: year.min, high: year.max };
182
+ return { percentile: year.count >= minCount ? year.percentile : null, low: year.min, high: year.max };
183
+ }
184
+
185
+ /** The fewest days of spreads in its year a CDX rank is read from: a month of trading; fewer leave it blank. */
186
+ const MIN_SPREAD_RANK_POINTS = 20;
187
+
188
+ /**
189
+ * What a credit rank ranks, so it always reads high = wide: the spread a row
190
+ * quotes; HY and EM's spread equivalent, each day's on its on-the-run
191
+ * contract; or, for a price with no spread beside it (CMBX), the price
192
+ * upside down, the lowest price ranking 100.
193
+ */
194
+ type SpreadRankBasis = "spread" | "spread-eq" | "price-inverted";
195
+
196
+ export interface SpreadRank {
197
+ percentile: number | null;
198
+ basis: SpreadRankBasis;
199
+ }
200
+
201
+ /**
202
+ * Where an index's spread sits in its own year, 100 the widest. A price
203
+ * quote ranks backwards (a falling price is a widening spread), so HY and EM
204
+ * rank their spread equivalent instead, and a price without one is ranked
205
+ * from the top. A spread rank needs a month of spreads in the year
206
+ * (MIN_SPREAD_RANK_POINTS); with fewer it is blank, never read off a handful.
207
+ */
208
+ export function spreadRank(index: Pick<CdxBoardIndex, "quote" | "points" | "level" | "date" | "spreadBp">): SpreadRank {
209
+ if (index.quote === "spread") {
210
+ return { percentile: yearStatistics(index.points, index.level, index.date, MIN_SPREAD_RANK_POINTS).percentile, basis: "spread" };
211
+ }
212
+ const spreads = index.points.flatMap((point) => typeof point.spreadBp === "number" && Number.isFinite(point.spreadBp)
213
+ ? [{ ...point, level: point.spreadBp }] : []);
214
+ if (spreads.length > 0 && typeof index.spreadBp === "number") {
215
+ return { percentile: yearStatistics(spreads, index.spreadBp, index.date, MIN_SPREAD_RANK_POINTS).percentile, basis: "spread-eq" };
216
+ }
217
+ const price = yearStatistics(index.points, index.level, index.date).percentile;
218
+ return { percentile: price == null ? null : 100 - price, basis: "price-inverted" };
219
+ }
220
+
221
+ /** A spread rank as a detail line says it: `89 pctl 1Y`, and for a price ranked upside down, says so. */
222
+ export function formatSpreadRank(rank: SpreadRank): string {
223
+ const text = formatPercentileRank(rank.percentile, "1Y");
224
+ return rank.basis === "price-inverted" && rank.percentile != null ? `${text}, price inverted` : text;
225
+ }
226
+
227
+ /** The newest day a board's rows are dated, which its footer dates the board by; null with none. */
228
+ export function newestRowDate(dates: ReadonlyArray<string | null | undefined>): string | null {
229
+ return dates.reduce<string | null>((newest, date) => date && /^\d{4}-\d{2}-\d{2}/.test(date) && (!newest || date > newest)
230
+ ? date.slice(0, 10) : newest, null);
182
231
  }
183
232
 
184
233
  function daysBetween(from: string, to: string): number {
@@ -219,7 +268,10 @@ export function findSovereign<T extends { id: string; name: string }>(sovereigns
219
268
 
220
269
  export interface CdxRow extends MarketBoardRow {
221
270
  index: CdxBoardIndex;
271
+ /** The level's own year: its range, in the quote's unit. */
222
272
  year: YearStatistics;
273
+ /** The rank the board shows, high = wide whatever the quote. */
274
+ rank: SpreadRank;
223
275
  /** The latest day's standing and the moves between complete days. */
224
276
  day: CdxDay;
225
277
  /** The 1W and 1M moves as shown. */
@@ -230,6 +282,7 @@ export interface CdxRow extends MarketBoardRow {
230
282
  export function cdxRows(indexes: readonly CdxBoardIndex[], asOf: string | null, now = Date.now()): CdxRow[] {
231
283
  return indexes.map((index) => {
232
284
  const year = yearStatistics(index.points, index.level, index.date);
285
+ const rank = spreadRank(index);
233
286
  const day = cdxDay(index, now);
234
287
  return {
235
288
  id: index.id,
@@ -238,13 +291,14 @@ export function cdxRows(indexes: readonly CdxBoardIndex[], asOf: string | null,
238
291
  valueText: formatLevel(index.quote, index.level),
239
292
  change: shown(index.quote, day.change1D),
240
293
  changeText: formatMove(index.quote, day.change1D),
241
- percentile: year.percentile,
294
+ percentile: rank.percentile,
242
295
  asOf: index.date,
243
296
  history: pointHistory(index.points),
244
297
  status: index.level == null ? "unavailable" : stale(index.date, asOf) ? "stale" : day.partial ? "partial" : "available",
245
298
  adverseMove: adverseMove(index.quote),
246
299
  index,
247
300
  year,
301
+ rank,
248
302
  day,
249
303
  week: shown(index.quote, day.change1W),
250
304
  month: shown(index.quote, day.change1M),
@@ -1,7 +1,8 @@
1
- import type { CreditBoardPoint } from "../../../api-client/credit-boards";
2
- import type { SeriesDefinition, SeriesLoadResult } from "../../../series/types";
1
+ import type { CdxBoardIndex, CreditBoardPoint } from "../../../api-client/credit-boards";
2
+ import type { SeriesDefinition, SeriesLoadRequest, SeriesLoadResult, SeriesPoint } from "../../../series/types";
3
+ import { logFailure } from "../../../utils/log-failure";
3
4
  import { cachedSeriesNote } from "../shared/series-warning";
4
- import { loadCdxBoard, loadSovrBoard } from "./client";
5
+ import { loadCdxBoard, loadFullCdxHistory, loadSovrBoard } from "./client";
5
6
 
6
7
  /** The five on-the-run 5Y index contracts the CDX tab lists; IG and iTraxx quote spread, HY and EM price. */
7
8
  const INDEXES = [
@@ -37,6 +38,49 @@ function boardPoints(
37
38
  };
38
39
  }
39
40
 
41
+ /** A chart that starts within this of the board's first day is drawn from the board. */
42
+ const BOARD_SLACK_MS = 7 * 86_400_000;
43
+
44
+ type CdxSeriesResource = { stale?: boolean; refreshError?: string | null; savedAt?: number };
45
+
46
+ /** What a chart that asked for more than the board's year says when the rest did not load. */
47
+ const BOARD_YEAR_ONLY = "The full history did not load; showing the last year.";
48
+
49
+ /**
50
+ * The indexes as a chart asks for them: the board, which holds a year, or
51
+ * every day the server keeps when the chart starts before it (ALL, 5Y).
52
+ * When that read fails the board's year stands in, said with `warning`.
53
+ */
54
+ async function cdxIndexes(request: SeriesLoadRequest): Promise<{ indexes: readonly CdxBoardIndex[]; resource: CdxSeriesResource; warning?: string }> {
55
+ const resource = await loadCdxBoard();
56
+ const first = Math.min(...resource.payload.indexes.flatMap((index) => index.points.slice(0, 1).map((point) => Date.parse(`${point.date}T00:00:00Z`))));
57
+ if (!request.start || request.start.getTime() < first - BOARD_SLACK_MS) {
58
+ const full = await loadFullCdxHistory().catch(logFailure("credit-boards", "Read the full index CDS history failed", null));
59
+ if (full) return { indexes: full.indexes, resource: {} };
60
+ return { indexes: resource.payload.indexes, resource, warning: BOARD_YEAR_ONLY };
61
+ }
62
+ return { indexes: resource.payload.indexes, resource };
63
+ }
64
+
65
+ /** A CDX series' note: the board's own, or, when it stood in for the full history, that. */
66
+ function cdxSeriesNote({ resource, warning }: { resource: CdxSeriesResource; warning?: string }): Pick<SeriesLoadResult, "warning" | "savedAt"> {
67
+ const note = cachedSeriesNote(resource);
68
+ return warning ? { ...note, warning: note.warning ? `${warning} ${note.warning}` : warning } : note;
69
+ }
70
+
71
+ /**
72
+ * HY and EM's price as the spread credit desks compare (each day's on its
73
+ * on-the-run contract, ISDA standard model at the index's coupon and standard
74
+ * recovery), so HY less IG, or cash less CDX, is one formula in bp.
75
+ */
76
+ function spreadEquivalentPoints(indexes: readonly CdxBoardIndex[], code: string, name: string): SeriesPoint[] {
77
+ const row = indexes.find((entry) => entry.id === code);
78
+ if (!row) throw new Error(`${name} is not on the board right now.`);
79
+ const points = row.points.flatMap((point) => typeof point.spreadBp === "number" ? [{ date: point.date, value: point.spreadBp }] : []);
80
+ if (points.length === 0) throw new Error(`${name} has no spread equivalent from this server yet.`);
81
+ return points;
82
+ }
83
+
40
84
  export const CREDIT_BOARD_SERIES: readonly SeriesDefinition[] = [
41
85
  ...INDEXES.map((index): SeriesDefinition => ({
42
86
  id: `cdx:${index.code.toLowerCase()}`,
@@ -45,9 +89,22 @@ export const CREDIT_BOARD_SERIES: readonly SeriesDefinition[] = [
45
89
  frequency: "daily",
46
90
  group: "Credit",
47
91
  tags: ["CDS", "index CDS", index.quote, "credit default swap"],
48
- load: async () => {
49
- const resource = await loadCdxBoard();
50
- return boardPoints(resource.payload.indexes, index.code, index.name, resource);
92
+ load: async (request) => {
93
+ const read = await cdxIndexes(request);
94
+ return { ...boardPoints(read.indexes, index.code, index.name, read.resource), ...cdxSeriesNote(read) };
95
+ },
96
+ })),
97
+ ...INDEXES.filter((index) => index.quote === "price").map((index): SeriesDefinition => ({
98
+ id: `cdx:${index.code.toLowerCase()}-spread`,
99
+ name: `${index.name} spread eq`,
100
+ unit: "bp",
101
+ frequency: "daily",
102
+ group: "Credit",
103
+ tags: ["CDS", "index CDS", "spread", "spread equivalent", index.code, "credit default swap"],
104
+ description: `${index.name}'s daily price as a conventional spread: a model figure from the ISDA standard model at the index's coupon and standard recovery, on each day's on-the-run contract, not a traded spread.`,
105
+ load: async (request) => {
106
+ const read = await cdxIndexes(request);
107
+ return { points: spreadEquivalentPoints(read.indexes, index.code, `${index.name} spread eq`), ...cdxSeriesNote(read) };
51
108
  },
52
109
  })),
53
110
  ...SOVEREIGNS.map(([code, name]): SeriesDefinition => ({
@@ -21,7 +21,6 @@ import { useThemeColors } from "../../../theme/theme-context";
21
21
  import type { PaneProps } from "../../../types/plugin";
22
22
  import { formatPercentileRank } from "../../../utils/format";
23
23
  import { useAssetData, usePluginPaneState } from "../../runtime";
24
- import { formatAsOf } from "../cds/model";
25
24
  import { FIXED_INCOME_PANE_ID } from "../fixed-income/model";
26
25
  import { useCommandValue } from "../shared/command-tab";
27
26
  import { getCachedSovrBoard, loadCurrencyMoves, loadSovrBoard } from "./client";
@@ -32,6 +31,7 @@ import {
32
31
  formatCurrencyMove,
33
32
  formatLevel,
34
33
  formatMove,
34
+ newestRowDate,
35
35
  SETTLEMENT_TEXT,
36
36
  sovrRows,
37
37
  type SovrRow,
@@ -115,7 +115,8 @@ export function SovrPane({ focused, width, height }: PaneProps) {
115
115
  moves.reload();
116
116
  }, { focused, enabled: !loading });
117
117
 
118
- const asOf = formatAsOf(payload?.asOf ?? null);
118
+ // Dated by the newest day the rows carry, not when the response was put together.
119
+ const asOf = newestRowDate(payload?.sovereigns.map((sovereign) => sovereign.date) ?? []);
119
120
  const info = useMemo<PaneFooterSegment[]>(() => [
120
121
  ...(asOf ? [{ id: "as-of", parts: [{ text: `as of ${asOf}`, tone: "muted" as const }] }] : []),
121
122
  ...(payload ? [DELAYED_SEGMENT] : []),
@@ -9,6 +9,24 @@ import {
9
9
  } from "./client";
10
10
  import { creditRegion, creditSeriesIn, type CreditConditionRow } from "./model";
11
11
 
12
+ const REGION_VALUES = [
13
+ { value: "all" },
14
+ { value: "us", aliases: ["usa", "united states", "america"] },
15
+ { value: "euro", aliases: ["eu", "eur", "europe", "eurozone", "euro area", "ea"] },
16
+ { value: "em", aliases: ["emerging", "emerging markets", "emerging market", "ems"] },
17
+ { value: "asia", aliases: ["asian", "apac", "asia pacific", "asia em"] },
18
+ ];
19
+
20
+ const regionToken = (text: string) => text.toLowerCase().replace(/[^a-z]/g, "");
21
+
22
+ /** A region as typed (`Asia`, `emerging markets`), as the option's value. */
23
+ function regionValue(text: string): string {
24
+ const token = regionToken(text);
25
+ const found = REGION_VALUES.find((region) => [region.value, ...region.aliases ?? []].some((name) => regionToken(name) === token));
26
+ if (!found) throw new Error(`Invalid --region value "${text}". Use one or more of: ${REGION_VALUES.map(({ value }) => value).join(", ")}.`);
27
+ return found.value;
28
+ }
29
+
12
30
  const COLUMNS = [
13
31
  { key: "label", header: "Index" },
14
32
  { key: "seriesId", header: "FRED series" },
@@ -43,14 +61,14 @@ function createCreditConditionsHeadless(
43
61
  argument: { kind: "none" },
44
62
  options: [{
45
63
  key: "region",
46
- description: "Indexes to list. FRED publishes euro high yield but no euro investment grade spread.",
64
+ description: "Indexes to list, one region or several as a comma list. em is the emerging markets corporate indexes, Asia's among them; "
65
+ + "FRED publishes euro high yield but no euro investment grade spread.",
47
66
  type: "enum",
48
- values: [
49
- { value: "all" },
50
- { value: "us", aliases: ["usa", "united states", "america"] },
51
- { value: "euro", aliases: ["eu", "eur", "europe", "eurozone", "euro area", "ea"] },
52
- ],
67
+ list: true,
68
+ values: REGION_VALUES,
53
69
  defaultValue: "all",
70
+ example: "--region asia,us",
71
+ normalize: (value) => value.split(",").map((part) => part.trim()).filter(Boolean).map((part) => regionValue(part)).join(","),
54
72
  }],
55
73
  columns: COLUMNS,
56
74
  describe: "Credit Spreads",
@@ -154,7 +154,7 @@ export const creditConditionsModule: PluginModule = {
154
154
  id: "credit-conditions-pane",
155
155
  paneId: "credit-conditions",
156
156
  label: "Credit Spreads",
157
- description: "ICE BofA option-adjusted spreads from FRED: US investment grade and high yield by rating, and euro high yield.",
157
+ description: "ICE BofA option-adjusted spreads from FRED: US investment grade and high yield by rating, euro high yield, and emerging markets and Asia corporates.",
158
158
  keywords: ["credit", "spread", "oas", "corporate", "high yield", "investment grade", "macro", "euro", "europe", "bb", "ccc", "rating"],
159
159
  shortcut: { prefix: "CRD" },
160
160
  headless: creditConditionsHeadless,