@gloom-sh/terminal 0.20.17 → 0.20.19

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 (453) hide show
  1. package/package.json +3 -1
  2. package/src/account/auth-dialog.tsx +19 -1
  3. package/src/account/billing.ts +2 -1
  4. package/src/account/heard-from-question.tsx +235 -0
  5. package/src/account/heard-from.ts +97 -0
  6. package/src/api-client/cot.ts +5 -6
  7. package/src/api-client/data.ts +14 -3
  8. package/src/api-client/heard-from.ts +72 -0
  9. package/src/api-client/index.ts +64 -6
  10. package/src/api-client/mna.ts +18 -0
  11. package/src/api-client/request.ts +162 -40
  12. package/src/api-client/supply-chain.ts +9 -0
  13. package/src/api-client/types/billing.ts +35 -1
  14. package/src/api-client/types/news.ts +45 -0
  15. package/src/api-client/types/world-venues.ts +9 -0
  16. package/src/app/global-shortcuts.ts +5 -3
  17. package/src/app/pro-welcome/keys.ts +27 -0
  18. package/src/app/pro-welcome/model.ts +158 -0
  19. package/src/app/pro-welcome/row.tsx +176 -0
  20. package/src/app/pro-welcome/use-pro-welcome.ts +156 -0
  21. package/src/app/runtime/external-profile-changes.ts +135 -0
  22. package/src/app.tsx +37 -4
  23. package/src/architecture/core-builtin-allowlist.json +1 -1
  24. package/src/architecture/floating-promise-allowlist.json +1 -2
  25. package/src/architecture/shortcut-labels-allowlist.json +1 -0
  26. package/src/cli/alert-listing.ts +98 -0
  27. package/src/cli/commands/market.ts +191 -39
  28. package/src/cli/commands/overview.ts +7 -1
  29. package/src/cli/commands/plugins.ts +3 -2
  30. package/src/cli/commands/search.ts +30 -6
  31. package/src/cli/commands/ticker.ts +13 -6
  32. package/src/cli/context.ts +24 -5
  33. package/src/cli/csv-export.ts +2 -1
  34. package/src/cli/desktop-pane-shot-browser.ts +3 -1
  35. package/src/cli/desktop-pane-shot-view.ts +0 -1
  36. package/src/cli/desktop-pane-shot.ts +276 -52
  37. package/src/cli/errors.ts +3 -9
  38. package/src/cli/exit-codes.ts +1 -1
  39. package/src/cli/glossary.ts +65 -11
  40. package/src/cli/help.ts +1 -1
  41. package/src/cli/history-demergers.ts +117 -0
  42. package/src/cli/history-rows.ts +8 -4
  43. package/src/cli/index.ts +2 -1
  44. package/src/cli/known-gaps.ts +16 -0
  45. package/src/cli/known-us-stocks.ts +18 -0
  46. package/src/cli/listing-arg.ts +192 -38
  47. package/src/cli/pane-functions/catalog-snapshot-build.ts +83 -0
  48. package/src/cli/pane-functions/catalog-snapshot.json +877 -0
  49. package/src/cli/pane-functions/catalog-snapshot.ts +62 -0
  50. package/src/cli/pane-functions/catalog.ts +50 -16
  51. package/src/cli/pane-functions/data.ts +16 -4
  52. package/src/cli/pane-functions/dom.ts +54 -8
  53. package/src/cli/pane-functions/freshness.ts +39 -4
  54. package/src/cli/pane-functions/function-help.ts +3 -3
  55. package/src/cli/pane-functions/headless.ts +9 -1
  56. package/src/cli/pane-functions/index.ts +175 -50
  57. package/src/cli/pane-functions/report-notices.ts +10 -0
  58. package/src/cli/pane-functions/resolver.ts +11 -7
  59. package/src/cli/pane-functions/screenshot-assessment.ts +38 -10
  60. package/src/cli/pane-functions/screenshot-data-evidence.ts +7 -15
  61. package/src/cli/pane-functions/screenshot-payload.ts +36 -1
  62. package/src/cli/pane-functions/screenshot-render.ts +24 -9
  63. package/src/cli/pane-functions/screenshot-types.ts +9 -0
  64. package/src/cli/quote-answer.ts +33 -17
  65. package/src/cli/registry.ts +22 -2
  66. package/src/cli/result.ts +22 -4
  67. package/src/cli/scroll-truncation.ts +7 -2
  68. package/src/cli/series-search.ts +45 -6
  69. package/src/cli/shot-temp-dir.ts +4 -9
  70. package/src/cli/ticker-resolution.ts +1 -1
  71. package/src/cli/unreachable.ts +21 -0
  72. package/src/components/chart/composite/drawing-store.ts +11 -7
  73. package/src/components/chart/composite/format.ts +1 -0
  74. package/src/components/chart/composite/legend.tsx +48 -20
  75. package/src/components/chart/composite/panel-surface/panel-cursor.tsx +3 -3
  76. package/src/components/chart/composite/panel-surface/plot-gestures.ts +9 -2
  77. package/src/components/chart/composite/panel-surface.tsx +1 -1
  78. package/src/components/chart/composite/price-axis-labels.tsx +7 -5
  79. package/src/components/chart/composite/tools.ts +164 -39
  80. package/src/components/chart-table/header.tsx +11 -2
  81. package/src/components/chart-table/layout.ts +16 -17
  82. package/src/components/command-bar/pane-templates/items.ts +17 -1
  83. package/src/components/command-bar/routes/root/provider-search.ts +10 -1
  84. package/src/components/command-bar/routes/root/results.ts +34 -2
  85. package/src/components/command-bar/routes/root/runtime.ts +19 -4
  86. package/src/components/command-bar/routes/ticker-search/results.ts +5 -0
  87. package/src/components/command-bar/routes/ticker-search/route.ts +5 -0
  88. package/src/components/command-bar/selection-runtime.ts +29 -5
  89. package/src/components/command-bar/surface/index.tsx +4 -1
  90. package/src/components/command-bar/workflow/alert.ts +32 -13
  91. package/src/components/data-table/view.tsx +15 -2
  92. package/src/components/form-modal/content.tsx +9 -4
  93. package/src/components/index.ts +1 -1
  94. package/src/components/layout/header.tsx +9 -5
  95. package/src/components/layout/pane/capture-status.ts +6 -0
  96. package/src/components/layout/pane/footer/index.tsx +2 -0
  97. package/src/components/layout/pane/footer/model.ts +123 -17
  98. package/src/components/layout/pane/header.tsx +16 -2
  99. package/src/components/layout/pane/status-footer.ts +24 -0
  100. package/src/components/market-board/index.tsx +4 -2
  101. package/src/components/onboarding/onboarding-frame.tsx +6 -2
  102. package/src/components/onboarding/onboarding-keyboard.ts +7 -1
  103. package/src/components/onboarding/onboarding-wizard.tsx +3 -1
  104. package/src/components/onboarding/portfolio-step/positions-panel.tsx +24 -15
  105. package/src/components/onboarding/setup-cards.ts +36 -0
  106. package/src/components/onboarding/use-onboarding-progress.ts +22 -1
  107. package/src/components/onboarding/wizard-account.ts +6 -1
  108. package/src/components/onboarding/wizard-model.ts +32 -6
  109. package/src/components/onboarding/wizard-positions.ts +1 -1
  110. package/src/components/price-performance.tsx +26 -8
  111. package/src/components/reader/article-reader.tsx +12 -5
  112. package/src/components/sign-in-gate.tsx +3 -1
  113. package/src/components/toggle-list.tsx +6 -8
  114. package/src/components/ui/confirm-dialog.tsx +47 -7
  115. package/src/components/ui/data-table/opentui/index.tsx +7 -0
  116. package/src/components/ui/data-table/types.ts +8 -0
  117. package/src/components/ui/display.tsx +17 -2
  118. package/src/components/ui/index.ts +1 -1
  119. package/src/components/ui/stat-grid.tsx +4 -0
  120. package/src/components/ui/status.tsx +13 -1
  121. package/src/components/ui/table-layout.ts +34 -2
  122. package/src/components/use-pane-notice-footer.tsx +16 -3
  123. package/src/data/config/store/index.ts +31 -0
  124. package/src/data/config/store/node.ts +61 -11
  125. package/src/data/config/store/normalize.ts +4 -6
  126. package/src/data/config/store/shared-file.ts +309 -0
  127. package/src/data/profile-merge.ts +299 -0
  128. package/src/data/sqlite/checkpointer.ts +11 -1
  129. package/src/data/sqlite/database.ts +1 -1
  130. package/src/data/ticker-repository.ts +134 -10
  131. package/src/data/ticker-store.ts +67 -0
  132. package/src/data/ticker-writes.ts +5 -0
  133. package/src/i18n/es.ts +27 -0
  134. package/src/i18n/ja.ts +27 -0
  135. package/src/i18n/ko.ts +27 -0
  136. package/src/i18n/zh-cn.ts +27 -0
  137. package/src/i18n/zh-tw.ts +27 -0
  138. package/src/layout-marketplace/gallery-desktop.tsx +2 -2
  139. package/src/market-data/ah-pair.ts +122 -0
  140. package/src/market-data/coordinator/entries.ts +6 -4
  141. package/src/market-data/coordinator/index.ts +14 -3
  142. package/src/market-data/depositary-pair.ts +6 -2
  143. package/src/market-data/futures-board.ts +36 -29
  144. package/src/market-data/futures-contract.ts +37 -1
  145. package/src/market-data/hooks.tsx +33 -2
  146. package/src/market-data/market/change-basis.ts +11 -1
  147. package/src/market-data/market/header-market.ts +11 -0
  148. package/src/market-data/market/status.ts +40 -4
  149. package/src/market-data/performance.ts +127 -32
  150. package/src/market-data/quotes/time.ts +5 -2
  151. package/src/market-data/split-terms.ts +28 -0
  152. package/src/news/types.ts +28 -0
  153. package/src/notifications/app-badge.ts +2 -3
  154. package/src/notifications/app-notifier.ts +5 -0
  155. package/src/plugins/builtin/account-management/footer.ts +1 -1
  156. package/src/plugins/builtin/account-management/keyboard.ts +4 -0
  157. package/src/plugins/builtin/account-management/model.ts +1 -0
  158. package/src/plugins/builtin/account-management/pane.tsx +75 -7
  159. package/src/plugins/builtin/account-management/payment-recovery-row.tsx +12 -5
  160. package/src/plugins/builtin/account-management/pro-cancel.tsx +197 -0
  161. package/src/plugins/builtin/account-management/trial-cancel.ts +1 -1
  162. package/src/plugins/builtin/alerts/cli-move.ts +2 -2
  163. package/src/plugins/builtin/alerts/cli.ts +101 -48
  164. package/src/plugins/builtin/alerts/command.ts +39 -9
  165. package/src/plugins/builtin/alerts/constants.ts +10 -0
  166. package/src/plugins/builtin/alerts/earnings-listing.ts +20 -0
  167. package/src/plugins/builtin/alerts/event-rows.ts +9 -3
  168. package/src/plugins/builtin/alerts/events-pane.tsx +16 -10
  169. package/src/plugins/builtin/alerts/format.ts +24 -8
  170. package/src/plugins/builtin/alerts/headless.ts +12 -6
  171. package/src/plugins/builtin/alerts/index.tsx +97 -16
  172. package/src/plugins/builtin/alerts/move-checks.ts +7 -0
  173. package/src/plugins/builtin/alerts/option-contract.ts +197 -0
  174. package/src/plugins/builtin/alerts/pane.tsx +1 -1
  175. package/src/plugins/builtin/alerts/price.ts +30 -5
  176. package/src/plugins/builtin/alerts/pro-rules.ts +62 -0
  177. package/src/plugins/builtin/alerts/quotes.ts +26 -2
  178. package/src/plugins/builtin/alerts/research-builder.ts +5 -10
  179. package/src/plugins/builtin/alerts/scheduled.ts +6 -1
  180. package/src/plugins/builtin/alerts/types.ts +7 -0
  181. package/src/plugins/builtin/analytics/account-returns.ts +1 -1
  182. package/src/plugins/builtin/analytics/manual-value.ts +61 -0
  183. package/src/plugins/builtin/analytics/pane-model.ts +2 -2
  184. package/src/plugins/builtin/analytics/risk-book.ts +7 -7
  185. package/src/plugins/builtin/analytics/risk-client.ts +27 -14
  186. package/src/plugins/builtin/analytics/risk-headless.ts +13 -8
  187. package/src/plugins/builtin/analytics/risk-model.ts +92 -4
  188. package/src/plugins/builtin/analytics/risk-pane.tsx +85 -38
  189. package/src/plugins/builtin/awards/pane.tsx +1 -1
  190. package/src/plugins/builtin/broker-trading/orders.tsx +2 -2
  191. package/src/plugins/builtin/buildout/company/pane.tsx +4 -14
  192. package/src/plugins/builtin/catalysts/model.ts +2 -1
  193. package/src/plugins/builtin/central-bank-rates/model.ts +8 -2
  194. package/src/plugins/builtin/central-bank-rates/pane.tsx +5 -3
  195. package/src/plugins/builtin/chart-composer/chart-spec.ts +5 -0
  196. package/src/plugins/builtin/chart-composer/cli-options.ts +9 -5
  197. package/src/plugins/builtin/chart-composer/data-catalog-pane.tsx +2 -6
  198. package/src/plugins/builtin/chart-composer/headless-schema.ts +14 -10
  199. package/src/plugins/builtin/chart-composer/headless.ts +2 -0
  200. package/src/plugins/builtin/chart-composer/index.tsx +17 -5
  201. package/src/plugins/builtin/chart-composer/pane.tsx +19 -6
  202. package/src/plugins/builtin/chart-composer/viewport-labels.ts +2 -17
  203. package/src/plugins/builtin/chat/controller/notifications.ts +1 -0
  204. package/src/plugins/builtin/chat/index.tsx +0 -1
  205. package/src/plugins/builtin/cloud/auth-actions.tsx +11 -6
  206. package/src/plugins/builtin/cloud/company-picker.tsx +5 -3
  207. package/src/plugins/builtin/cloud/upgrade-command.ts +1 -1
  208. package/src/plugins/builtin/commodities-energy/index.tsx +1 -1
  209. package/src/plugins/builtin/company-kpis/headless.ts +10 -5
  210. package/src/plugins/builtin/company-kpis/latest.ts +45 -0
  211. package/src/plugins/builtin/company-kpis/model.ts +57 -15
  212. package/src/plugins/builtin/company-kpis/pane.tsx +22 -8
  213. package/src/plugins/builtin/composite/alt-data.ts +20 -0
  214. package/src/plugins/builtin/composite/application.ts +14 -0
  215. package/src/plugins/builtin/composite/broker.ts +12 -0
  216. package/src/plugins/builtin/composite/credit.ts +33 -0
  217. package/src/plugins/builtin/composite/crypto.ts +10 -0
  218. package/src/plugins/builtin/composite/earnings.ts +12 -0
  219. package/src/plugins/builtin/composite/filings.ts +13 -0
  220. package/src/plugins/builtin/composite/futures-commodities.ts +23 -0
  221. package/src/plugins/builtin/composite/global-markets.ts +12 -0
  222. package/src/plugins/builtin/composite/options-volatility.ts +23 -0
  223. package/src/plugins/builtin/composite/ownership.ts +23 -0
  224. package/src/plugins/builtin/composite/portfolio.ts +10 -0
  225. package/src/plugins/builtin/composite/quant.ts +15 -0
  226. package/src/plugins/builtin/composite/rates-macro.ts +30 -0
  227. package/src/plugins/builtin/composite/screeners.ts +11 -0
  228. package/src/plugins/builtin/composite/shared.ts +11 -0
  229. package/src/plugins/builtin/composite/ticker-core.ts +36 -0
  230. package/src/plugins/builtin/congress-trades/headless.ts +31 -3
  231. package/src/plugins/builtin/congress-trades/model.ts +9 -5
  232. package/src/plugins/builtin/correlation/index.tsx +13 -17
  233. package/src/plugins/builtin/correlation/matrix/model.ts +18 -0
  234. package/src/plugins/builtin/cot/client.ts +2 -3
  235. package/src/plugins/builtin/cot/headless.ts +16 -16
  236. package/src/plugins/builtin/cot/index.tsx +6 -6
  237. package/src/plugins/builtin/cot/model.ts +25 -5
  238. package/src/plugins/builtin/cot/pane.tsx +11 -6
  239. package/src/plugins/builtin/cot/series.ts +11 -8
  240. package/src/plugins/builtin/cpi/model.ts +15 -4
  241. package/src/plugins/builtin/cpi/pane.tsx +29 -7
  242. package/src/plugins/builtin/dividend-yield/client.ts +57 -16
  243. package/src/plugins/builtin/dividend-yield/headless.ts +17 -11
  244. package/src/plugins/builtin/dividend-yield/model.ts +4 -3
  245. package/src/plugins/builtin/dividend-yield/pane.tsx +22 -18
  246. package/src/plugins/builtin/dividend-yield/ranking.ts +1 -1
  247. package/src/plugins/builtin/dividend-yield/types.ts +4 -0
  248. package/src/plugins/builtin/dividend-yield/view.ts +23 -12
  249. package/src/plugins/builtin/doe/model.ts +30 -0
  250. package/src/plugins/builtin/doe/pane.tsx +8 -2
  251. package/src/plugins/builtin/earnings/board-table.ts +9 -4
  252. package/src/plugins/builtin/earnings/fiscal-quarter.ts +39 -0
  253. package/src/plugins/builtin/earnings/headless.ts +16 -6
  254. package/src/plugins/builtin/earnings/history-model.ts +6 -4
  255. package/src/plugins/builtin/earnings/history-table.ts +7 -4
  256. package/src/plugins/builtin/earnings-calls/calendar.tsx +4 -3
  257. package/src/plugins/builtin/earnings-calls/pane.tsx +8 -2
  258. package/src/plugins/builtin/earnings-ripple/pane.tsx +2 -2
  259. package/src/plugins/builtin/econ/calendar-model.ts +16 -0
  260. package/src/plugins/builtin/econ/index.tsx +7 -2
  261. package/src/plugins/builtin/equity-screener/headless.ts +4 -1
  262. package/src/plugins/builtin/equity-screener/model.ts +7 -6
  263. package/src/plugins/builtin/estimate-revisions/headless.ts +1 -1
  264. package/src/plugins/builtin/exposure/model.ts +10 -0
  265. package/src/plugins/builtin/exposure/pane.tsx +10 -3
  266. package/src/plugins/builtin/futures/model.ts +14 -1
  267. package/src/plugins/builtin/futures/series.ts +1 -8
  268. package/src/plugins/builtin/fx-matrix/amount.ts +15 -1
  269. package/src/plugins/builtin/fx-matrix/headless.ts +12 -6
  270. package/src/plugins/builtin/fx-matrix/index.tsx +25 -7
  271. package/src/plugins/builtin/fx-matrix/settings.ts +9 -4
  272. package/src/plugins/builtin/insider/detail.tsx +36 -7
  273. package/src/plugins/builtin/insider/filing-stories.ts +110 -0
  274. package/src/plugins/builtin/insider/headless.ts +37 -2
  275. package/src/plugins/builtin/insider/index.tsx +79 -10
  276. package/src/plugins/builtin/insider/model.ts +43 -5
  277. package/src/plugins/builtin/ipo-calendar/client.ts +11 -1
  278. package/src/plugins/builtin/ipo-calendar/model.ts +3 -7
  279. package/src/plugins/builtin/jobs/headless.ts +2 -1
  280. package/src/plugins/builtin/jobs/model.ts +6 -0
  281. package/src/plugins/builtin/jobs/pane.tsx +8 -3
  282. package/src/plugins/builtin/kelly-sizer/pane.tsx +9 -4
  283. package/src/plugins/builtin/market-valuation/pane.tsx +22 -10
  284. package/src/plugins/builtin/mna/detail.tsx +67 -6
  285. package/src/plugins/builtin/mna/headless.ts +128 -13
  286. package/src/plugins/builtin/mna/model.ts +219 -16
  287. package/src/plugins/builtin/mna/pane.tsx +34 -6
  288. package/src/plugins/builtin/money-markets/model.ts +14 -5
  289. package/src/plugins/builtin/money-markets/pane.tsx +4 -3
  290. package/src/plugins/builtin/news/wire/news/detail-view.tsx +118 -10
  291. package/src/plugins/builtin/news/wire/news/footer.ts +3 -8
  292. package/src/plugins/builtin/news/wire/news/story-evidence.ts +178 -0
  293. package/src/plugins/builtin/options/analytics.ts +1 -1
  294. package/src/plugins/builtin/options/view.tsx +18 -11
  295. package/src/plugins/builtin/options-positioning/model.ts +11 -0
  296. package/src/plugins/builtin/options-positioning/pane.tsx +22 -1
  297. package/src/plugins/builtin/options-scenario/client.ts +49 -8
  298. package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +22 -6
  299. package/src/plugins/builtin/options-scenario/csp-screen.ts +39 -12
  300. package/src/plugins/builtin/options-scenario/headless.ts +7 -3
  301. package/src/plugins/builtin/options-scenario/model.ts +33 -2
  302. package/src/plugins/builtin/options-scenario/pane.tsx +3 -4
  303. package/src/plugins/builtin/options-scenario/strategy-screen.ts +7 -5
  304. package/src/plugins/builtin/pe-band/client.ts +13 -1
  305. package/src/plugins/builtin/pe-band/headless.ts +2 -2
  306. package/src/plugins/builtin/pe-band/model.ts +63 -10
  307. package/src/plugins/builtin/pe-band/pane.tsx +5 -5
  308. package/src/plugins/builtin/perps/cascade.ts +4 -3
  309. package/src/plugins/builtin/perps/markets-section.tsx +5 -2
  310. package/src/plugins/builtin/perps/model.ts +4 -3
  311. package/src/plugins/builtin/portfolio-list/allocation-rows.ts +26 -7
  312. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +66 -13
  313. package/src/plugins/builtin/portfolio-list/cli/render.ts +76 -33
  314. package/src/plugins/builtin/portfolio-list/headless.ts +69 -22
  315. package/src/plugins/builtin/portfolio-list/pane/data.ts +3 -3
  316. package/src/plugins/builtin/portfolio-list/pane/index.tsx +29 -14
  317. package/src/plugins/builtin/portfolio-list/summary/index.tsx +2 -2
  318. package/src/plugins/builtin/portfolio-list/table.tsx +3 -2
  319. package/src/plugins/builtin/relative-rotation/pane.tsx +2 -3
  320. package/src/plugins/builtin/research/corporate-actions-pane.tsx +33 -14
  321. package/src/plugins/builtin/research/event-model.ts +43 -19
  322. package/src/plugins/builtin/research/headless.ts +8 -1
  323. package/src/plugins/builtin/research/relative-valuation-pane.tsx +19 -17
  324. package/src/plugins/builtin/research-search/index.tsx +3 -1
  325. package/src/plugins/builtin/scanner/denied.tsx +16 -4
  326. package/src/plugins/builtin/scanner/flow-pane.tsx +1 -1
  327. package/src/plugins/builtin/scanner/hilo-pane.tsx +1 -1
  328. package/src/plugins/builtin/sec/filing-display.tsx +14 -2
  329. package/src/plugins/builtin/sec/headless.ts +42 -4
  330. package/src/plugins/builtin/sec/index.tsx +21 -1
  331. package/src/plugins/builtin/sectors/index.tsx +6 -9
  332. package/src/plugins/builtin/sectors/sector-model.ts +1 -1
  333. package/src/plugins/builtin/shared/cloud-upgrade.ts +1 -1
  334. package/src/plugins/builtin/shared/earnings-report.ts +49 -5
  335. package/src/plugins/builtin/shared/options-pro-copy.ts +34 -0
  336. package/src/plugins/builtin/shared/report-freshness.ts +2 -3
  337. package/src/plugins/builtin/shared/statement-currency.ts +23 -0
  338. package/src/plugins/builtin/shared/ticker-surface.ts +1 -1
  339. package/src/plugins/builtin/supply-chain/client.ts +34 -9
  340. package/src/plugins/builtin/supply-chain/evidence.ts +3 -2
  341. package/src/plugins/builtin/supply-chain/flow.tsx +4 -3
  342. package/src/plugins/builtin/supply-chain/graph-model.ts +14 -7
  343. package/src/plugins/builtin/supply-chain/graph-pane.tsx +3 -1
  344. package/src/plugins/builtin/supply-chain/graph.tsx +6 -3
  345. package/src/plugins/builtin/supply-chain/headless.ts +19 -4
  346. package/src/plugins/builtin/supply-chain/model.ts +50 -6
  347. package/src/plugins/builtin/supply-chain/pane.tsx +79 -18
  348. package/src/plugins/builtin/themes/headless.ts +4 -4
  349. package/src/plugins/builtin/themes/model.ts +11 -8
  350. package/src/plugins/builtin/themes/pane.tsx +2 -2
  351. package/src/plugins/builtin/ticker-detail/adr-pair/ah.ts +62 -0
  352. package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +119 -20
  353. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +51 -1
  354. package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +25 -14
  355. package/src/plugins/builtin/ticker-detail/financials/model.ts +22 -32
  356. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +7 -9
  357. package/src/plugins/builtin/ticker-detail/headless-schema.ts +2 -0
  358. package/src/plugins/builtin/ticker-detail/headless.ts +28 -12
  359. package/src/plugins/builtin/ticker-detail/overview/board-lot.ts +21 -0
  360. package/src/plugins/builtin/ticker-detail/overview/model.ts +28 -2
  361. package/src/plugins/builtin/ticker-detail/overview/pane.tsx +8 -0
  362. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +68 -13
  363. package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +9 -2
  364. package/src/plugins/builtin/ticker-detail/quote-monitor/index.tsx +5 -2
  365. package/src/plugins/builtin/volatility/model.ts +17 -0
  366. package/src/plugins/builtin/volatility/pane.tsx +16 -7
  367. package/src/plugins/builtin/world-indices/index.tsx +2 -0
  368. package/src/plugins/builtin/world-indices/table.tsx +15 -0
  369. package/src/plugins/builtin/world-venue-map/evidence.ts +3 -2
  370. package/src/plugins/builtin/world-venue-map/headless.ts +32 -18
  371. package/src/plugins/builtin/world-venue-map/index.ts +19 -6
  372. package/src/plugins/builtin/world-venue-map/layered-pane.tsx +9 -5
  373. package/src/plugins/builtin/world-venue-map/layers.ts +33 -11
  374. package/src/plugins/builtin/world-venue-map/map.tsx +12 -0
  375. package/src/plugins/builtin/world-venue-map/model.ts +6 -1
  376. package/src/plugins/builtin/world-venue-map/pane.tsx +35 -6
  377. package/src/plugins/builtin/world-venue-map/place.ts +119 -0
  378. package/src/plugins/builtin/world-venue-map/venue-header.tsx +5 -3
  379. package/src/plugins/catalog-browser.ts +10 -1
  380. package/src/plugins/catalog-data.ts +20 -0
  381. package/src/plugins/catalog-lazy.ts +51 -0
  382. package/src/plugins/catalog-ui.ts +16 -18
  383. package/src/plugins/host-smoke.ts +5 -2
  384. package/src/portfolio/allocation.ts +79 -19
  385. package/src/portfolio/cash-balances.ts +76 -0
  386. package/src/portfolio/mutations.ts +43 -8
  387. package/src/public/__snapshots__/public-api.test.ts.snap +1 -0
  388. package/src/renderers/browser/activity.ts +16 -0
  389. package/src/renderers/browser/app-badge-host.ts +14 -0
  390. package/src/renderers/browser/main.tsx +5 -0
  391. package/src/renderers/browser/notifications.ts +103 -0
  392. package/src/renderers/browser/ui-host.tsx +4 -0
  393. package/src/renderers/desktop/window-layouts.ts +14 -0
  394. package/src/renderers/dom/data-table/index.tsx +27 -4
  395. package/src/renderers/dom/data-table/row.tsx +2 -0
  396. package/src/renderers/dom/host/tabs.tsx +57 -8
  397. package/src/renderers/dom/styles.css +13 -5
  398. package/src/renderers/electrobun/bun/desktop/backend-requests.ts +4 -0
  399. package/src/renderers/electrobun/bun/desktop/backend.ts +22 -1
  400. package/src/renderers/electrobun/bun/window/native-min-size.ts +6 -1
  401. package/src/renderers/electrobun/shared/protocol.ts +4 -0
  402. package/src/renderers/electrobun/view/cli-pane-shot-frame.tsx +50 -12
  403. package/src/renderers/electrobun/view/http-fetch.ts +3 -2
  404. package/src/renderers/electrobun/view/remote/ticker-repository.ts +10 -0
  405. package/src/series/standalone-catalog.ts +5 -4
  406. package/src/series/standalone.ts +13 -7
  407. package/src/sources/gloomberb-cloud/index.ts +22 -9
  408. package/src/sources/gloomberb-cloud/news.ts +35 -0
  409. package/src/sources/gloomberb-cloud/perpetuals.ts +60 -3
  410. package/src/sources/provider-errors.ts +34 -7
  411. package/src/sources/provider-router/financials.ts +20 -13
  412. package/src/sources/provider-router/history.ts +32 -6
  413. package/src/sources/provider-router/index.ts +4 -0
  414. package/src/sources/provider-router/search.ts +1 -0
  415. package/src/sync/collections-contributor.ts +3 -1
  416. package/src/sync/config-merge.ts +10 -1
  417. package/src/sync/sanitize.ts +26 -2
  418. package/src/tickers/company-name-listing.ts +16 -2
  419. package/src/tickers/listing-fate.ts +12 -8
  420. package/src/tickers/renamed-listings.ts +43 -10
  421. package/src/tickers/search/home-listing.ts +28 -0
  422. package/src/tickers/search/index.ts +19 -7
  423. package/src/tickers/terminal-codes.ts +11 -1
  424. package/src/time-series/base-series.ts +39 -6
  425. package/src/time-series/chart-seed.ts +2 -2
  426. package/src/time-series/history-quality.ts +4 -1
  427. package/src/time-series/hooks.ts +2 -0
  428. package/src/time-series/price-comparison.ts +17 -23
  429. package/src/time-series/reporting.ts +1 -1
  430. package/src/time-series/resolution.ts +13 -0
  431. package/src/time-series/resolve-context.ts +6 -0
  432. package/src/time-series/resolve.ts +42 -3
  433. package/src/time-series/spec.ts +2 -2
  434. package/src/time-series/types.ts +3 -2
  435. package/src/types/data-provider.ts +11 -0
  436. package/src/types/financials.ts +48 -4
  437. package/src/types/headless.ts +1 -0
  438. package/src/types/issuer-listings.ts +2 -0
  439. package/src/types/plugin-notifications.ts +3 -0
  440. package/src/types/price-history.ts +6 -4
  441. package/src/types/ticker.ts +10 -2
  442. package/src/ui/host.tsx +2 -0
  443. package/src/utils/cli-output.ts +1 -1
  444. package/src/utils/declared-dividends.ts +13 -1
  445. package/src/utils/dividend-cash.ts +5 -1
  446. package/src/utils/exchange-announcements.ts +7 -2
  447. package/src/utils/forward-dividend.ts +4 -3
  448. package/src/utils/fundamentals.ts +40 -0
  449. package/src/utils/network-failure.ts +2 -0
  450. package/src/utils/price-history-integrity.ts +9 -1
  451. package/src/utils/remove-folder.ts +37 -0
  452. package/src/utils/trailing-dividend.ts +1 -1
  453. package/src/plugins/builtin/composite-plugins.ts +0 -285
@@ -38,6 +38,8 @@ export interface RiskInstrument {
38
38
  }
39
39
  /** A holding to load: what ranks it by value before any daily history is requested. */
40
40
  export interface RiskHoldingRequest extends RiskInstrument {
41
+ estimate?: boolean;
42
+ estimateStart?: string;
41
43
  /** Signed quantity; with a USD quote it ranks the holding by current value. */
42
44
  quantity?: number;
43
45
  /** The currency the position is recorded in, for the rate that values it when it is left out. */
@@ -52,6 +54,7 @@ interface RiskMarketHistory {
52
54
  currency: string | null;
53
55
  quote: CloudQuotePayload | null;
54
56
  returns: DatedReturn[];
57
+ closes?: Array<{ date: string; close: number }>;
55
58
  asOf: string | null;
56
59
  /** Latest completed close, used as the mark when no current quote arrived. */
57
60
  closeMark?: { price: number; date: string; currency: string } | null;
@@ -183,8 +186,11 @@ export function validateRiskHistory(
183
186
  quote: CloudQuotePayload | null,
184
187
  now = new Date(),
185
188
  conversion?: { listingCurrency: string; divisor: number; fx: FxCloses },
189
+ options: { estimate?: boolean; returnsSince?: string } = {},
186
190
  ): {
187
191
  returns: DatedReturn[];
192
+ closes: Array<{ date: string; close: number }>;
193
+ cadenceError: string | null;
188
194
  asOf: string;
189
195
  closeMark: { price: number; date: string; currency: string } | null;
190
196
  /** Latest completed close in the returns' currency, whatever marks the holding. */
@@ -233,7 +239,7 @@ export function validateRiskHistory(
233
239
  )
234
240
  )
235
241
  throw new Error("History and quote currencies differ");
236
- if (response.data.length > 1500)
242
+ if (response.data.length > (options.estimate ? 10_000 : 1500))
237
243
  throw new Error("Cloud daily history exceeds the supported buffer");
238
244
  const today = now.toISOString().slice(0, 10);
239
245
  // Today's bar is still trading until the listing's session ends; after its close it is final (PORT at 23:10Z
@@ -274,7 +280,7 @@ export function validateRiskHistory(
274
280
  }));
275
281
  const local = resolveDatedReturns(prices);
276
282
  if (local.integrity)
277
- throw new Error("Daily history has inconsistent OHLC observations");
283
+ throw new Error("Daily history has contradictory prices");
278
284
  // A converted series is on the NYSE calendar the basket and SPY share.
279
285
  const usd = conversion
280
286
  ? convertClosesToUsd(
@@ -284,11 +290,12 @@ export function validateRiskHistory(
284
290
  )
285
291
  : null;
286
292
  const series = usd ? usd.points : prices;
287
- const returns = conversion ? resolveDatedReturns(series).returns : local.returns;
293
+ const returns = (conversion ? resolveDatedReturns(series).returns : local.returns)
294
+ .filter((point) => !options.returnsSince || point.startDateKey >= options.returnsSince);
288
295
  const cadence = qualifySharpeCadence(returns, [
289
296
  { symbol: instrument.symbol, exchange: conversion ? "NYSE" : exchange, history: series },
290
297
  ]);
291
- if (!cadence.supported)
298
+ if (!cadence.supported && !options.estimate)
292
299
  throw new Error(cadence.reason ?? "Daily session cadence unavailable");
293
300
  const lastPoint = series.at(-1)!;
294
301
  const latestClose = {
@@ -296,7 +303,9 @@ export function validateRiskHistory(
296
303
  date: lastPoint.date.toISOString().slice(0, 10),
297
304
  };
298
305
  return {
299
- returns,
306
+ returns: cadence.supported ? returns : [],
307
+ cadenceError: cadence.supported ? null : cadence.reason ?? "Daily session cadence unavailable",
308
+ closes: series.map((point) => ({ date: point.date.toISOString().slice(0, 10), close: point.close })),
300
309
  ...(usd?.bridged.length ? { fxBridged: usd.bridged } : {}),
301
310
  asOf: latestClose.date,
302
311
  // A missing or stale quote is not a current mark; the latest dated close is.
@@ -407,13 +416,16 @@ export async function fetchPortfolioRiskMarket(
407
416
  endDate = new Date(Date.parse(today) - 86_400_000)
408
417
  .toISOString()
409
418
  .slice(0, 10);
419
+ const estimateStart = holdings.map((row) => row.estimateStart).filter((date): date is string => !!date && evidenceDay(date)).sort()[0];
420
+ const estimate = holdings.some((row) => row.estimate);
421
+ const historyStart = estimateStart && estimateStart < startDate ? estimateStart : startDate;
410
422
  const historyParams = {
411
423
  interval: "1day",
412
- startDate,
424
+ startDate: historyStart,
413
425
  // validateRiskHistory keeps today's bar only once its session closed; ending on
414
426
  // yesterday loses yesterday's close for most listings.
415
427
  endDate: today,
416
- outputsize: 1000,
428
+ outputsize: estimate ? 10_000 : 1000,
417
429
  rangeKey: "2Y",
418
430
  } as const;
419
431
  const account = accountCurrency === "USD" ? null : accountCurrency;
@@ -491,7 +503,7 @@ export async function fetchPortfolioRiskMarket(
491
503
  if (!factors.has(id) && item.data.currency && item.data.currency !== "USD") {
492
504
  if (Number.isFinite(item.data.price) && item.data.price > 0)
493
505
  listings.set(id, { price: item.data.price, currency: item.data.currency });
494
- if (entries.get(id)?.request.unsupported) continue;
506
+ if (entries.get(id)?.request.unsupported && !entries.get(id)?.request.estimate) continue;
495
507
  const conversion = riskConversion(item.data.currency);
496
508
  if (!conversion) {
497
509
  foreignReasons.set(id, FX_NO_PAIR);
@@ -567,14 +579,14 @@ export async function fetchPortfolioRiskMarket(
567
579
  .filter(
568
580
  (row) =>
569
581
  !factors.has(row.id) &&
570
- !row.request.unsupported &&
571
582
  (!listings.has(row.id) || conversions.has(row.id)),
572
583
  )
573
584
  .map((row) => ({ ...row, rank: rankValue(row.request, usdQuote(row.id)) }))
574
585
  .sort(largestFirst);
575
586
  const requestedIds = new Set([
576
587
  ...factors.keys(),
577
- ...candidates.slice(0, RISK_HISTORY_LIMIT).map((row) => row.id),
588
+ ...candidates.filter((row) => !row.request.unsupported).slice(0, RISK_HISTORY_LIMIT).map((row) => row.id),
589
+ ...candidates.filter((row) => row.request.estimate).slice(0, RISK_HISTORY_LIMIT).map((row) => row.id),
578
590
  ]);
579
591
  const instruments = [
580
592
  ...new Map([...factors, ...[...entries.values()].map((row) => [row.id, row.instrument] as const)]).entries(),
@@ -663,7 +675,7 @@ export async function fetchPortfolioRiskMarket(
663
675
  requesting = true;
664
676
  const response = await historyOf(instrument.symbol, instrument.exchange || quote?.listingExchangeName || "");
665
677
  requesting = false;
666
- const { latestClose, fxBridged, ...resolved } = validateRiskHistory(
678
+ const { latestClose, fxBridged, cadenceError, ...resolved } = validateRiskHistory(
667
679
  response,
668
680
  instrument,
669
681
  quote,
@@ -671,6 +683,7 @@ export async function fetchPortfolioRiskMarket(
671
683
  conversion && fxCloses
672
684
  ? { listingCurrency: conversion.listingCurrency, divisor: conversion.divisor, fx: fxCloses }
673
685
  : undefined,
686
+ { estimate, returnsSince: startDate },
674
687
  );
675
688
  if (conversion && fxCloses) {
676
689
  // A current quote marks at the current rate; without one, or without
@@ -685,7 +698,7 @@ export async function fetchPortfolioRiskMarket(
685
698
  converted: {
686
699
  currency: conversion.listingCurrency, fxAsOf: fxCloses.asOf, ...(fxBridged?.length ? { fxBridged } : {}),
687
700
  },
688
- error: null,
701
+ error: cadenceError,
689
702
  };
690
703
  continue;
691
704
  }
@@ -693,7 +706,7 @@ export async function fetchPortfolioRiskMarket(
693
706
  ...entry,
694
707
  currency: quote?.currency ?? resolved.closeMark?.currency ?? null,
695
708
  ...resolved,
696
- error: null,
709
+ error: cadenceError,
697
710
  };
698
711
  } catch (error) {
699
712
  if (isAccessDenied(error) || signal?.aborted) throw error;
@@ -734,7 +747,7 @@ const cacheKey = (holdings: readonly RiskHoldingRequest[], accountCurrency: stri
734
747
  [
735
748
  ...new Set(
736
749
  holdings.map(
737
- (row) => `${riskInstrumentId(row)}|${row.quantity ?? ""}|${row.currency ?? ""}|${row.unsupported ? 1 : 0}`,
750
+ (row) => `${riskInstrumentId(row)}|${row.quantity ?? ""}|${row.currency ?? ""}|${row.unsupported ? 1 : 0}|${row.estimate ? 1 : 0}|${row.estimateStart ?? ""}`,
738
751
  ),
739
752
  ),
740
753
  ].sort().join(",") + (accountCurrency === "USD" ? "" : `@${accountCurrency}`)
@@ -73,10 +73,7 @@ function emptyPortfolioHint(name: string, listed: readonly string[]): string {
73
73
 
74
74
  /**
75
75
  * Why a view of PORT has no rows, in one line, as its section says it in
76
- * place of a bare "No data.": what it needs, and where the trustee's question
77
- * is answered instead. Performance reads the account's own history, which a
78
- * book entered by hand has none of; its P&L over a period is `portfolio show
79
- * --from`.
76
+ * place of a bare "No data.": what it needs, and where P&L is answered instead.
80
77
  */
81
78
  function riskSectionEmpty(
82
79
  view: RiskView,
@@ -373,7 +370,7 @@ export const portfolioRiskHeadless: HeadlessPaneDefinition<"bundle"> = {
373
370
  fetchedAt: new Date().toISOString(),
374
371
  })
375
372
  : fetchPortfolioRiskMarket(
376
- portfolioRiskRequests(tickers, id),
373
+ portfolioRiskRequests(tickers, id, !(local.portfolio.brokerId || local.portfolio.brokerInstanceId || local.portfolio.brokerAccountId)),
377
374
  ctx.apiClient,
378
375
  new Date(),
379
376
  ctx.signal,
@@ -429,7 +426,7 @@ export const portfolioRiskHeadless: HeadlessPaneDefinition<"bundle"> = {
429
426
  const covered = !riskHoldingsLeftOut(model.coverage);
430
427
  const complete =
431
428
  view === "performance"
432
- ? model.performance != null
429
+ ? model.performance != null || model.performanceEstimate?.complete === true
433
430
  : view === "attribution"
434
431
  ? model.attribution != null
435
432
  : view === "greeks"
@@ -454,8 +451,9 @@ export const portfolioRiskHeadless: HeadlessPaneDefinition<"bundle"> = {
454
451
  : views).map(({ view, rows }) => ({ view, rows: rows.map(displayRow) }));
455
452
  return {
456
453
  complete,
457
- errors: model.warnings,
458
- notes: [...riskCoverageNotices(model.coverage), ...model.notes.filter((note) => note !== fallback)],
454
+ errors: requestedView === "performance" && model.performanceEstimate ? [] : model.warnings,
455
+ notes: [...(requestedView === "performance" && model.performanceEstimate ? [] : riskCoverageNotices(model.coverage)), ...model.notes.filter((note) => note !== fallback),
456
+ ...(!requestedView || requestedView === "performance" ? model.performanceEstimate?.warnings ?? [] : [])],
459
457
  // A view with nothing to show says why in one line.
460
458
  sections: shown.map(({ view, rows }) => ({ title: view, columns: RISK_COLUMNS, rows, ...(rows.length === 0 ? { empty: riskSectionEmpty(view, {
461
459
  name: local.portfolio.name,
@@ -494,6 +492,13 @@ export const portfolioRiskHeadless: HeadlessPaneDefinition<"bundle"> = {
494
492
  currency: model.portfolio.currency,
495
493
  },
496
494
  view,
495
+ ...(view === "performance" && model.performanceEstimate ? { performanceEstimate: {
496
+ kind: model.performanceEstimate.kind,
497
+ label: model.performanceEstimate.label,
498
+ currency: model.performanceEstimate.currency,
499
+ startDate: model.performanceEstimate.points[0]?.date ?? null,
500
+ endDate: model.performanceEstimate.points.at(-1)?.date ?? null,
501
+ } } : {}),
497
502
  benchmark: model.benchmark,
498
503
  window: model.window,
499
504
  ...(basketView && model.coverage
@@ -1,7 +1,9 @@
1
1
  import { portfolioOptionGreeks } from "./risk-options";
2
+ import { manualPortfolioValue } from "./manual-value";
2
3
  import type { Portfolio, TickerRecord } from "../../../types/ticker";
3
4
  import { MISSING_VALUE, formatCurrency, formatNumber } from "../../../utils/format";
4
5
  import { resolveCurrencyUnit } from "../../../utils/currency-units";
6
+ import { canonicalExchange, isUsEquityExchange } from "../../../utils/exchanges";
5
7
  import {
6
8
  getPortfolioPositionMetrics,
7
9
  resolvePortfolioMarketValue,
@@ -171,6 +173,8 @@ export interface RiskDisplayRow {
171
173
  amountBase?: number;
172
174
  /** What a tail loss in money is taken on: the basket's value and share of the book, and what it leaves out. */
173
175
  basis?: string;
176
+ /** The trading days the tail rows' returns are on, when the basket mixes markets (`riskReturnCalendar`). */
177
+ calendar?: string;
174
178
  /**
175
179
  * The caveat a narrow pane puts beside the label when it has no room for
176
180
  * the evidence: the basket share an episode replays by beta proxy ("22% proxy").
@@ -408,6 +412,7 @@ const signedQuantity = (lots: TickerRecord["metadata"]["positions"]) =>
408
412
  export function portfolioRiskRequests(
409
413
  tickers: readonly TickerRecord[],
410
414
  portfolioId: string,
415
+ estimate = false,
411
416
  ): RiskHoldingRequest[] {
412
417
  return tickers.map((ticker) => {
413
418
  const lots = positions(ticker, portfolioId);
@@ -419,6 +424,7 @@ export function portfolioRiskRequests(
419
424
  : null;
420
425
  return {
421
426
  ...riskInstrumentOf(ticker),
427
+ ...(estimate ? { estimate: true, estimateStart: lots.map((lot) => lot.dateAcquired).filter((date): date is string => !!date).sort()[0] } : {}),
422
428
  quantity: signedQuantity(lots),
423
429
  currency,
424
430
  snapshotValue: snapshot,
@@ -553,18 +559,61 @@ const NAMED_EXCLUSIONS = 2;
553
559
  * values is named with "value unknown". Converted listings are counted after.
554
560
  */
555
561
  export function riskCoverageLine(coverage: RiskCoverage | undefined): string | null {
562
+ const parts = riskCoverageParts(coverage);
563
+ return parts ? [parts.text, parts.converted].filter(Boolean).join(" · ") : null;
564
+ }
565
+ /**
566
+ * The coverage line's parts, for a footer that sets them apart: `text`
567
+ * ("basket 48,286 USD = 72% of book; left out: BTC-USD 10%, TRY cash 18%"),
568
+ * `short`, the same without the basket's value ("72% of book; left out: ..."),
569
+ * `shortest`, without their shares ("72% of book; BTC-USD, TRY cash left out"),
570
+ * and `converted` ("2 holdings converted from local currency"), null when none was.
571
+ */
572
+ export function riskCoverageParts(
573
+ coverage: RiskCoverage | undefined,
574
+ ): { text: string; short: string; shortest: string; converted: string | null } | null {
556
575
  if (!coverage) return null;
557
576
  const named = coverage.leftOut.length <= NAMED_EXCLUSIONS + 1 ? coverage.leftOut : coverage.leftOut.slice(0, NAMED_EXCLUSIONS);
558
577
  const rest = coverage.leftOut.slice(named.length);
559
578
  const restShare = rest.reduce((sum, row) => sum + (row.share ?? 0), 0);
560
579
  const shares = [coverage.share ?? 0, ...named.map((row) => row.share ?? 0), ...(rest.length ? [restShare] : [])];
561
580
  const percents = wholePercents(shares);
562
- const basket = `basket ${formatNumber(coverage.coveredValue, 0)} ${coverage.currency}${coverage.share == null ? "" : ` = ${coverage.unvalued ? "at most " : ""}${percentText(percents[0]!, shares[0]!)} of book`}`;
581
+ const share = coverage.share == null ? null : `${coverage.unvalued ? "at most " : ""}${percentText(percents[0]!, shares[0]!)} of book`;
582
+ const basket = `basket ${formatNumber(coverage.coveredValue, 0)} ${coverage.currency}${share ? ` = ${share}` : ""}`;
563
583
  const items = [
564
584
  ...named.map((row, index) => `${row.symbol} ${row.share == null ? "value unknown" : percentText(percents[index + 1]!, row.share)}`),
565
585
  ...(rest.length ? [`${rest.length} more${restShare > 0 ? ` ${percentText(percents.at(-1)!, restShare)}` : ""}`] : []),
566
586
  ];
567
- return [`${basket}${items.length ? `; left out: ${items.join(", ")}` : ""}`, convertedText(coverage)].filter(Boolean).join(" · ");
587
+ const leftOut = items.length ? `; left out: ${items.join(", ")}` : "";
588
+ const symbols = [...named.map((row) => row.symbol), ...(rest.length ? [`${rest.length} more`] : [])];
589
+ return {
590
+ text: `${basket}${leftOut}`,
591
+ short: `${share ?? basket}${leftOut}`,
592
+ shortest: `${share ?? basket}${symbols.length ? `; ${symbols.join(", ")} left out` : ""}`,
593
+ converted: convertedText(coverage),
594
+ };
595
+ }
596
+ /** US futures exchanges, whose settlements follow the US trading days the basket is on. */
597
+ const US_FUTURES_VENUES: ReadonlySet<string> = new Set(["CME", "CBT", "NYM", "CMX", "NYB", "CFE"]);
598
+ /** Venues a calendar line names before it says "other markets". */
599
+ const NAMED_CALENDAR_VENUES = 2;
600
+ /**
601
+ * "US trading days, BIST at its last close": the days the basket's returns
602
+ * are on when it holds a listing abroad. The basket, SPY and the factor
603
+ * proxies share the US calendar; a market abroad carries its last close over
604
+ * a US trading day it did not trade (convertClosesToUsd). Null when every
605
+ * holding in the basket trades on a US venue.
606
+ */
607
+ export function riskReturnCalendar(members: ReadonlyArray<{ exchange: string; convertedFrom?: string | null }>): string | null {
608
+ const abroad = [...new Set(members.flatMap((row) => {
609
+ const venue = canonicalExchange(row.exchange);
610
+ if (!venue) return row.convertedFrom ? ["other"] : [];
611
+ return isUsEquityExchange(venue) || US_FUTURES_VENUES.has(venue) ? [] : [venue];
612
+ }))];
613
+ if (abroad.length === 0) return null;
614
+ const named = abroad.filter((venue) => venue !== "other");
615
+ if (named.length === 0 || named.length > NAMED_CALENDAR_VENUES || named.length < abroad.length) return "US trading days, other markets at their last close";
616
+ return `US trading days, ${named.join(" and ")} at ${named.length === 1 ? "its" : "their"} last close`;
568
617
  }
569
618
  /** Whether the basket leaves out a holding, which makes a report incomplete; cash never is in it. */
570
619
  export const riskHoldingsLeftOut = (coverage: RiskCoverage) => coverage.leftOut.some((row) => !row.cash);
@@ -881,6 +930,8 @@ export function buildPortfolioRisk(
881
930
  const book = concentration(
882
931
  valued.filter((row) => row.marketValue! > 0).map((row) => ({ id: row.id, value: row.marketValue })),
883
932
  );
933
+ // The days the returns are on, when the basket holds a market abroad that carries its last close over US days.
934
+ const calendar = riskReturnCalendar(members);
884
935
  const closeMarked = members.filter((row) => row.markSource === "close").length;
885
936
  const converted = members.filter((row) => row.convertedFrom != null).length;
886
937
  const held = new Set(holdings.map((row) => row.id));
@@ -1129,6 +1180,10 @@ export function buildPortfolioRisk(
1129
1180
  const performance = evidence?.performance
1130
1181
  ? calculateAccountPerformance(evidence.performance)
1131
1182
  : null;
1183
+ const performanceEstimate = performance ? null : manualPortfolioValue(
1184
+ portfolio, tickers, market,
1185
+ cashHoldings.every((line) => line.value != null) ? cashHoldings.reduce((sum, line) => sum + line.value!, 0) : null,
1186
+ );
1132
1187
  const attribution = evidence?.attribution
1133
1188
  ? calculateBrinson(evidence.attribution)
1134
1189
  : null;
@@ -1154,6 +1209,7 @@ export function buildPortfolioRisk(
1154
1209
  percentile: row.rank.percentile,
1155
1210
  // The tail rows name how they are estimated; the other rows' method (price returns, bought and held or at fixed current weights) is in docs.
1156
1211
  detail: TAIL_ROW_IDS.has(row.id) ? riskTailMethod(row.samples, row.value != null) : `${row.samples} sessions`,
1212
+ ...(TAIL_ROW_IDS.has(row.id) && calendar ? { calendar } : {}),
1157
1213
  ...(tail
1158
1214
  ? {
1159
1215
  amount: (row.value! / 100) * tailBase,
@@ -1289,7 +1345,15 @@ export function buildPortfolioRisk(
1289
1345
  asOf: performance.endDate,
1290
1346
  detail: `${performance.startDate} to ${performance.endDate}; ${row.detail}`,
1291
1347
  }))
1292
- : [],
1348
+ : performanceEstimate ? [{
1349
+ id: "estimated-value",
1350
+ label: performanceEstimate.label,
1351
+ value: performanceEstimate.points.at(-1)?.value ?? null,
1352
+ unit: portfolio.currency,
1353
+ percentile: null,
1354
+ asOf: performanceEstimate.points.at(-1)?.date ?? null,
1355
+ detail: "Today's holdings at daily closes; cash held flat; not account performance",
1356
+ }] : [],
1293
1357
  attribution: attribution
1294
1358
  ? attribution.rows.map((row) => ({
1295
1359
  id: row.sector,
@@ -1403,6 +1467,7 @@ export function buildPortfolioRisk(
1403
1467
  stresses,
1404
1468
  episodes,
1405
1469
  performance,
1470
+ performanceEstimate,
1406
1471
  attribution,
1407
1472
  greeks,
1408
1473
  evidence,
@@ -1418,6 +1483,8 @@ export function buildPortfolioRisk(
1418
1483
  notes,
1419
1484
  fetchedAt: market.fetchedAt,
1420
1485
  benchmark: RISK_BENCHMARK,
1486
+ /** The days the basket's returns are on when it mixes markets (`riskReturnCalendar`); null when it trades in the US only. */
1487
+ calendar,
1421
1488
  /** The currency a non-USD account's returns converted into, at the daily closes of `pair`; null for USD. */
1422
1489
  accountConversion:
1423
1490
  account && !account.error && account.pair
@@ -1436,6 +1503,26 @@ export function buildPortfolioRisk(
1436
1503
  };
1437
1504
  }
1438
1505
  export type PortfolioRiskModel = ReturnType<typeof buildPortfolioRisk>;
1506
+
1507
+ /** The holdings and options the views list by symbol, each a row of its own. */
1508
+ function riskRowSymbols(model: Pick<PortfolioRiskModel, "holdings" | "greeks">): string[] {
1509
+ return [...model.holdings.map((row) => row.symbol), ...(model.greeks?.rows ?? []).map((row) => row.symbol)];
1510
+ }
1511
+
1512
+ /** What a warning says of one holding or option (`AAPL: …`), named by `symbol`, less the name: its row's note. */
1513
+ export function riskRowWarnings(model: Pick<PortfolioRiskModel, "warnings">, symbol: string): string[] {
1514
+ return model.warnings.flatMap((warning) => warning.startsWith(`${symbol}: `) ? [warning.slice(symbol.length + 2)] : []);
1515
+ }
1516
+
1517
+ /**
1518
+ * The warnings the footer says, which concern the whole book: a holding's or
1519
+ * an option's own are its row's (its detail, its note under the table), as
1520
+ * a left-out holding's reason is.
1521
+ */
1522
+ export function riskPaneWarnings(model: Pick<PortfolioRiskModel, "warnings" | "holdings" | "greeks">): string[] {
1523
+ const symbols = riskRowSymbols(model);
1524
+ return model.warnings.filter((warning) => !symbols.some((symbol) => warning.startsWith(`${symbol}: `)));
1525
+ }
1439
1526
  export const riskValue = (row: RiskDisplayRow) =>
1440
1527
  row.leftOut
1441
1528
  ? "left out"
@@ -1444,7 +1531,8 @@ export const riskValue = (row: RiskDisplayRow) =>
1444
1531
  : `${row.value.toFixed(2)}${row.unit === "%" ? "%" : ` ${row.unit}`}${riskAmount(row)}`;
1445
1532
  /** A row's evidence with what a tail loss in money is taken on: the basket, its share of the book and what it leaves out. */
1446
1533
  export function riskEvidence(row: RiskDisplayRow): string {
1447
- return row.basis ? `${row.detail}; ${row.basis}` : row.detail;
1534
+ const method = row.calendar ? `${row.detail} on ${row.calendar}` : row.detail;
1535
+ return row.basis ? `${method}; ${row.basis}` : method;
1448
1536
  }
1449
1537
  /** " ($5,735)": a loss or change in money beside its percent. */
1450
1538
  function riskAmount(row: RiskDisplayRow): string {
@@ -1,4 +1,4 @@
1
- import { MISSING_VALUE } from "../../../utils/format";
1
+ import { MISSING_VALUE, formatCurrency } from "../../../utils/format";
2
2
  import {
3
3
  staticSeries,
4
4
  scalarPoint,
@@ -25,6 +25,7 @@ import {
25
25
  usePaneTabs,
26
26
  type ChartTableChart,
27
27
  type DataTableColumn,
28
+ type PaneFooterSegment,
28
29
  type StatItem,
29
30
  } from "../../../components";
30
31
  import {
@@ -60,11 +61,12 @@ import {
60
61
  NO_HOLDINGS_HINT,
61
62
  portfolioRiskRequests,
62
63
  portfolioRiskTickers,
63
- riskCoverageLine,
64
- riskCoverageNotices,
64
+ riskCoverageParts,
65
65
  riskCoverageShortfall,
66
+ riskPaneWarnings,
66
67
  riskPercentile,
67
68
  riskEvidence,
69
+ riskRowWarnings,
68
70
  riskReturnsCurrency,
69
71
  riskValue,
70
72
  RISK_VIEWS,
@@ -83,6 +85,7 @@ import { CorrelationMatrixGrid, correlationMatrixFits, useCorrelationMatrixNavig
83
85
  import { usePluginTickerActions } from "../../runtime";
84
86
  import { TICKER_RESEARCH_PANE_ID } from "../../../types/config";
85
87
  import { formatTickerListInput } from "../../../tickers/list";
88
+ import { getTableWidth } from "../../../components/ui/table-layout";
86
89
 
87
90
  const titles = {
88
91
  risk: "Risk",
@@ -421,8 +424,8 @@ export function PortfolioRiskPane({ focused, width, height }: PaneProps) {
421
424
  [portfolio?.id, tickers],
422
425
  );
423
426
  const requests = useMemo(
424
- () => (portfolio ? portfolioRiskRequests(localTickers, portfolio.id) : []),
425
- [localTickers, portfolio?.id],
427
+ () => (portfolio ? portfolioRiskRequests(localTickers, portfolio.id, !(portfolio.brokerId || portfolio.brokerInstanceId || portfolio.brokerAccountId)) : []),
428
+ [localTickers, portfolio],
426
429
  );
427
430
  const session = useResearchCloudSession();
428
431
  const loader = useCallback(
@@ -562,7 +565,8 @@ export function PortfolioRiskPane({ focused, width, height }: PaneProps) {
562
565
  // A broker linked to the portfolio may still be sending its account history.
563
566
  const evidenceLoading = evidenceMissing && view === "performance" && brokerPerformance.loading;
564
567
  const detailScrollRef = useRef<ScrollBoxRenderable | null>(null);
565
- // Columns that say the same thing on every row belong in the footer, not repeated per row.
568
+ // Evidence that says the same thing on every row belongs in the footer, not repeated per row; a shared date shows
569
+ // where there is room, so every number keeps its date beside it.
566
570
  const showPercentile = rows.some((row) => row.percentile != null);
567
571
  const sharedDate =
568
572
  rows.length > 1 &&
@@ -628,48 +632,70 @@ export function PortfolioRiskPane({ focused, width, height }: PaneProps) {
628
632
  [frozen, importEvidence, portfolios.length, nextPortfolio],
629
633
  );
630
634
  // Only real data limitations raise the footer warning; the empty evidence
631
- // views say what they need in the body, with the import action.
632
- const notices = [
633
- ...riskCoverageNotices(model?.coverage),
634
- ...(model?.notes ?? []),
635
- ...(model?.warnings ?? []),
635
+ // views say what they need in the body, with the import action. What
636
+ // concerns one holding is its row's: a left-out holding's reason is its
637
+ // detail, a holding's or an option's failure its note under the table.
638
+ const failures = [
639
+ ...(model ? riskPaneWarnings(model) : []),
640
+ ...(view === "performance" ? model?.performanceEstimate?.warnings ?? [] : []),
636
641
  ...shocks.errors,
637
642
  ...(derived.error ? [derived.error] : []),
638
643
  ...(resource.error ? [resource.error] : []),
639
644
  ];
645
+ const notices = [
646
+ ...(model?.notes ?? []),
647
+ ...failures,
648
+ ];
640
649
  // What the basket views cover of the book and leave out, unless the body already says why they show nothing.
641
650
  // Stress showing its shocks alone says instead why the basket scenarios are not there.
651
+ const coverage = useMemo(
652
+ () => (!model || !BASKET_VIEWS.has(view) || basketBody || stressShortfall ? null : riskCoverageParts(model.coverage)),
653
+ [basketBody, model, stressShortfall, view],
654
+ );
642
655
  const coverageText = !model || !BASKET_VIEWS.has(view) || basketBody
643
656
  ? null
644
657
  : stressShortfall
645
658
  ? `Index, 10Y, VIX and episode scenarios: ${stressShortfall.title.replace(/\.$/, "").replace(/^[A-Z](?=[a-z])/, (letter) => letter.toLowerCase())}`
646
- : riskCoverageLine(model.coverage);
659
+ : coverage?.text ?? null;
660
+ // The days the returns are on, for a basket that mixes markets: the views read from its returns say so.
661
+ const calendar = model && DAILY_CLOSE_VIEWS.has(view) && !basketBody && !stressShortfall ? model.calendar ?? null : null;
647
662
  const asOfDate = (stressShortfall ? rows : model?.rows[view])?.find((row) => row.asOf)?.asOf?.slice(0, 10) ?? null;
648
663
  // The views estimated from returns name the currency a non-USD account's returns were converted into.
649
664
  const returnsCurrency = BASKET_VIEWS.has(view) && view !== "holdings" && !stressShortfall ? riskReturnsCurrency(model) : null;
650
- // Dated evidence only when a row has a date; a missing date is not a claim about history.
651
- const asOfText = !model
652
- ? null
653
- : [
654
- ...(basketBody ? [] : [
655
- ...(coverageText ? [coverageText] : []),
656
- ...(asOfDate && footerEvidence ? [footerEvidence] : []),
657
- // The coverage names the currency of its basket value; a non-USD account's returns say what they converted into.
658
- // An evidence view with nothing in it has no amounts for a currency to describe.
659
- ...(returnsCurrency ? [returnsCurrency] : coverageText || evidenceMissing ? [] : [model.portfolio.currency]),
660
- ...(EVIDENCE_VIEWS.has(view) && model.evidence ? [model.evidence.source] : []),
661
- ]),
662
- ].join(" · ") || null;
663
665
  // What the figures are read from and to when: the basket's daily closes, or the marks and evidence of that day.
664
666
  // The shocks alone are repriced at the current marks.
665
667
  const sourceText = basketBody || !asOfDate
666
668
  ? null
667
669
  : DAILY_CLOSE_VIEWS.has(view) && !stressShortfall ? `daily closes to ${asOfDate}` : `as of ${asOfDate}`;
670
+ // Each fact its own segment, in the order a narrow footer keeps them: what the numbers cover, how the tail rows are
671
+ // estimated and on which days; the date and the currency give way first. A capture keeps the first three, which say
672
+ // what its rows leave out and how they read. Dated evidence only when a row has a date; a missing date is not a
673
+ // claim about history.
674
+ const tailMethodShort = view === "risk" && footerEvidence ? footerEvidence.replace(/^historical, 1-day, \d+%, /, "historical, ") : null;
675
+ const infoSegments = useMemo((): PaneFooterSegment[] => {
676
+ if (!model || basketBody) return [];
677
+ const muted = (text: string) => [{ text, tone: "muted" as const }];
678
+ const text = (id: string, value: string | null | undefined, extra: Partial<PaneFooterSegment> = {}): PaneFooterSegment[] =>
679
+ value ? [{ id, parts: muted(value), ...extra }] : [];
680
+ return [
681
+ ...text("coverage", coverageText, { capture: true, ...(coverage && coverage.short !== coverage.text ? { variants: [muted(coverage.short), muted(coverage.shortest)] } : {}) }),
682
+ // The tail rows' labels say 1D and 95%: a narrow row keeps the rest of the method.
683
+ ...text("method", asOfDate ? footerEvidence : null, { capture: true, ...(tailMethodShort && tailMethodShort !== footerEvidence ? { variants: [muted(tailMethodShort)] } : {}) }),
684
+ ...text("calendar", calendar, { capture: true }),
685
+ ...text("source", sourceText, { asOf: true }),
686
+ // The coverage names the currency of its basket value; a non-USD account's returns say what they converted into.
687
+ // An evidence view with nothing in it has no amounts for a currency to describe.
688
+ ...text("currency", returnsCurrency ?? (coverageText || evidenceMissing ? null : model.portfolio.currency)),
689
+ ...text("evidence", EVIDENCE_VIEWS.has(view) && model.evidence ? model.evidence.source : null),
690
+ ];
691
+ }, [asOfDate, basketBody, calendar, coverage, coverageText, evidenceMissing, footerEvidence, model, returnsCurrency, sourceText, tailMethodShort, view]);
668
692
  usePaneNoticeFooter({
669
693
  registrationId: "portfolio-risk-notices",
670
694
  notices,
671
695
  focused,
672
696
  enabled: !openRow,
697
+ // A capture's footer says what the basket leaves out and how it reads; of the warnings it prints only what failed.
698
+ captureNotes: failures,
673
699
  });
674
700
  usePaneFooter(
675
701
  "portfolio-risk",
@@ -685,14 +711,9 @@ export function PortfolioRiskPane({ focused, width, height }: PaneProps) {
685
711
  },
686
712
  ]
687
713
  : []),
688
- // Coverage first: a narrow footer cuts the method and the date before what the numbers cover.
689
- ...(asOfText
690
- ? [{ id: "asof", parts: [{ text: asOfText, tone: "muted" as const }] }]
691
- : []),
692
- // The source and its date, which a capture's own dated status line stands in for.
693
- ...(sourceText
694
- ? [{ id: "source", asOf: true, parts: [{ text: sourceText, tone: "muted" as const }] }]
695
- : []),
714
+ // Coverage first: a narrow footer cuts the method and the date before what the numbers cover. The source's
715
+ // date gives way to a capture's own dated status line.
716
+ ...infoSegments,
696
717
  ...(actionStatus
697
718
  ? [
698
719
  {
@@ -704,7 +725,7 @@ export function PortfolioRiskPane({ focused, width, height }: PaneProps) {
704
725
  ],
705
726
  hints,
706
727
  }),
707
- [resource.loading, view, episodeResource.loading, asOfText, sourceText, actionStatus, hints],
728
+ [resource.loading, view, episodeResource.loading, infoSegments, actionStatus, hints],
708
729
  );
709
730
  useShortcut(
710
731
  (event) => {
@@ -738,6 +759,15 @@ export function PortfolioRiskPane({ focused, width, height }: PaneProps) {
738
759
  const chart = useMemo<ChartTableChart | null>(() => {
739
760
  if (!model) return null;
740
761
  if (view === "performance") {
762
+ if (model.performanceEstimate) return {
763
+ series: [staticSeries(
764
+ model.performanceEstimate.points.map((row) => scalarPoint(new Date(row.date), row.value)),
765
+ { id: "estimated-value", label: model.performanceEstimate.label, color: colors.positive, calendarSpaced: true },
766
+ )],
767
+ formatValue: (value: number) => formatCurrency(value, model.portfolio.currency),
768
+ formatAxisValue: formatPlainAxis,
769
+ remoteKind: "portfolio-risk-history",
770
+ };
741
771
  if (!model.performance) return null;
742
772
  return {
743
773
  series: [staticSeries(
@@ -772,6 +802,20 @@ export function PortfolioRiskPane({ focused, width, height }: PaneProps) {
772
802
  : sharedUnit
773
803
  ? sharedUnit.length <= 3 ? `Value ${sharedUnit}` : sharedUnit
774
804
  : "Value";
805
+ // Dates that differ always show; one every row shares shows where the row has room for it beside the figures.
806
+ const asOfColumn = useMemo<DataTableColumn | null>(() => {
807
+ const column: DataTableColumn = { id: "asOf", label: "As of", width: 11, align: "left" };
808
+ if (!sharedDate) return column;
809
+ const figures = [
810
+ { width: 19, align: "left" as const },
811
+ { width: sharedUnit || attributionParts ? Math.max(9, valueHeader.length) : rows.some((row) => row.amount != null) ? 18 : 16, align: "right" as const },
812
+ ...(attributionParts ? ATTRIBUTION_PARTS.map(() => ({ width: 11, align: "right" as const })) : []),
813
+ ...(factorFits ? [{ width: 9, align: "right" as const }] : []),
814
+ ...(showPercentile ? [{ width: 8, align: "right" as const }] : []),
815
+ ];
816
+ // A cell for the scrollbar a long table draws.
817
+ return getTableWidth([...figures, column]) + 1 <= width ? column : null;
818
+ }, [attributionParts, factorFits, rows, sharedDate, sharedUnit, showPercentile, valueHeader, width]);
775
819
  const columns = useMemo<DataTableColumn[]>(
776
820
  () => [
777
821
  {
@@ -797,9 +841,8 @@ export function PortfolioRiskPane({ focused, width, height }: PaneProps) {
797
841
  ...(showPercentile
798
842
  ? [{ id: "percentile", label: "Pctl 1Y", width: 8, align: "right" as const }]
799
843
  : []),
800
- ...(sharedDate
801
- ? []
802
- : [{ id: "asOf", label: "As of", width: 11, align: "left" as const }]),
844
+ // Every row's date where there is room, the one they share too: each number says when it is from.
845
+ ...(asOfColumn ? [asOfColumn] : []),
803
846
  // Attribution's evidence is the three effects, now columns of their own.
804
847
  ...(width >= 95 && !footerEvidence && !attributionParts
805
848
  ? [
@@ -813,7 +856,7 @@ export function PortfolioRiskPane({ focused, width, height }: PaneProps) {
813
856
  ]
814
857
  : []),
815
858
  ],
816
- [width, view, valueHeader, sharedUnit, attributionParts, factorFits, footerEvidence, showPercentile, sharedDate, rows],
859
+ [width, view, valueHeader, sharedUnit, attributionParts, factorFits, footerEvidence, showPercentile, asOfColumn, rows],
817
860
  );
818
861
  const selectView = (value: string) => {
819
862
  setView(value);
@@ -982,6 +1025,10 @@ export function PortfolioRiskPane({ focused, width, height }: PaneProps) {
982
1025
  return { text: factorFits ? withoutFactorFit(row.detail) : row.detail };
983
1026
  }}
984
1027
  selectedTextOverridesCellColor
1028
+ rowNote={(row) => {
1029
+ const notes = model ? riskRowWarnings(model, row.label) : [];
1030
+ return notes.length ? `${row.label}: ${notes.join(" ")}` : null;
1031
+ }}
985
1032
  onActivate={(row) => setOpen(row.id)}
986
1033
  detailOpen={!!openRow}
987
1034
  detailTitle={openRow?.label}
@@ -194,7 +194,7 @@ function AwardsView({ width, height, focused, symbol }: PaneProps & { symbol: st
194
194
  // The same coverage notes `fn AWARDS` prints: what the awards shown may be missing.
195
195
  ...(data ? awardsCoverageNotes(data) : []),
196
196
  ...(loaded?.refreshError ? [loaded.refreshError] : []),
197
- ...(data?.truncated && Object.values(data.truncated).some(Boolean) ? ["Some aggregate history exceeds this response's limit. Narrow the date range or scope."] : []),
197
+ ...(data?.truncated && Object.values(data.truncated).some(Boolean) ? ["Some breakdowns list only their first entries; narrow the date range or scope to see the rest."] : []),
198
198
  ...(tab === "company" && currencies.length > 1 && !currency ? [`Chart in ${chartCurrency}; select a currency to inspect other obligations.`] : []),
199
199
  ...(tab === "company" && scopes.length > 1 && !source ? [`Chart covers ${awardScope(chartSource).toLowerCase()}; select a scope to inspect other contracts.`] : []),
200
200
  ...(data && (tab === "feed" || tab === "company") ? [futureAwardDatesNote(rows, data.generatedAt)].filter((note): note is string => !!note) : []),