@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
@@ -77,6 +77,7 @@ import type { BrokerAccount } from "../../../../types/trading";
77
77
  import {
78
78
  BROKER_ACCOUNT_MISSING_NOTE,
79
79
  CASH_SYMBOL,
80
+ cashLineLabel,
80
81
  buildPortfolioAllocation,
81
82
  describeTargetSum,
82
83
  formatAllocationDrift,
@@ -750,20 +751,36 @@ function totalWeight(allocation: Pick<PortfolioAllocation, "weightBasis" | "tota
750
751
  return allocation.weightBasis === "total" && allocation.total != null && allocation.total > 0 ? 100 : null;
751
752
  }
752
753
 
753
- /** A portfolio's cash line, as `portfolio show` and `fn PF` report it. */
754
- export interface PortfolioCashReport {
755
- /** In the cash's own currency. */
754
+ /** One currency of a portfolio's cash, as `portfolio show` and `fn PF` report it. */
755
+ interface PortfolioCashBalanceReport {
756
+ /** In `currency`. */
756
757
  amount: number;
757
758
  currency: string;
759
+ /** In the portfolio's currency; null when the rate is unavailable, which leaves it out of the total. */
760
+ value: number | null;
761
+ /** Its own share of the weight base; null without a value or against a hedged book's gross exposure. */
762
+ weight: number | null;
763
+ }
764
+
765
+ /** A portfolio's cash line, as `portfolio show` and `fn PF` report it. */
766
+ export interface PortfolioCashReport {
767
+ /**
768
+ * The cash in its own currency when it is held in one; null for cash held in
769
+ * several, whose `balances` give each.
770
+ */
771
+ amount: number | null;
772
+ currency: string | null;
758
773
  /** Recorded with `portfolio cash set`, or reported by the broker account. */
759
774
  source: "manual" | "broker";
760
- /** In the portfolio's currency; null when the rate is unavailable. */
775
+ /** All of it in the portfolio's currency; null when a rate is unavailable. */
761
776
  value: number | null;
777
+ /** One per currency, largest first. */
778
+ balances: PortfolioCashBalanceReport[];
762
779
  }
763
780
 
764
781
  /**
765
782
  * Weights, targets and trades for a valued portfolio, with its cash: the
766
- * broker account's when it reports one, else the amount entered by hand.
783
+ * broker account's when it reports one, else each currency entered by hand.
767
784
  */
768
785
  export async function valuePortfolioAllocation({
769
786
  valuation,
@@ -776,15 +793,33 @@ export async function valuePortfolioAllocation({
776
793
  account?: BrokerAccount | null;
777
794
  toBase: (value: number, fromCurrency: string) => Promise<number>;
778
795
  }): Promise<{ allocation: PortfolioAllocation; cash: PortfolioCashReport | null }> {
779
- const line = resolvePortfolioCash(portfolio, account);
780
- const value = line && line.currency ? await toBase(line.amount, line.currency) : null;
781
- const cash = line ? { amount: line.amount, currency: line.currency, source: line.source, value: value != null && Number.isFinite(value) ? value : null } : null;
782
- const allocation = buildPortfolioAllocation({
783
- holdings: valuation.holdings,
784
- cashValue: cash ? cash.value ?? Number.NaN : null,
785
- targets: portfolio.targetWeights,
786
- });
787
- return { allocation, cash };
796
+ const resolved = resolvePortfolioCash(portfolio, account);
797
+ const balances = resolved ? await Promise.all(resolved.balances.map(async ({ amount, currency }) => {
798
+ const value = currency ? await toBase(amount, currency) : null;
799
+ return { amount, currency, value: value != null && Number.isFinite(value) ? value : null };
800
+ })) : [];
801
+ const allocation = buildPortfolioAllocation({ holdings: valuation.holdings, cash: balances, targets: portfolio.targetWeights });
802
+ if (!resolved || !allocation.cash) return { allocation, cash: null };
803
+ const sorted = allocation.cash.balances.map(({ amount, currency, value, weight }) => ({ amount, currency, value, weight }));
804
+ const one = sorted.length === 1 ? sorted[0]! : null;
805
+ return {
806
+ allocation,
807
+ cash: { amount: one?.amount ?? null, currency: one?.currency ?? null, source: resolved.source, value: allocation.cash.value, balances: sorted },
808
+ };
809
+ }
810
+
811
+ /**
812
+ * The note for cash left out of the total, as an unpriced holding is: `Total
813
+ * and weights exclude the TRY cash: no TRY/USD rate.` Null when every balance
814
+ * has a value.
815
+ */
816
+ export function unpricedCashNote(currencies: readonly string[], portfolioCurrency: string): string | null {
817
+ if (currencies.length === 0) return null;
818
+ const named = currencies.filter(Boolean);
819
+ if (named.length === 0) return "Total and weights exclude the cash: its currency is unknown.";
820
+ const list = named.length === 1 ? named[0]! : `${named.slice(0, -1).join(", ")} and ${named.at(-1)!}`;
821
+ const rates = named.map((code) => `${code}/${portfolioCurrency}`).join(" or ");
822
+ return `Total and weights exclude the ${list} cash: no ${rates} rate.`;
788
823
  }
789
824
 
790
825
  /** Colors a signed figure only when its text shows a nonzero digit. */
@@ -1138,17 +1173,16 @@ async function showCollectionWithMarketData(
1138
1173
  // The value's move from the closes before, totalled under Chg and said with its base under the table: at the close
1139
1174
  // that is Last times the shares; at the latest print, an after-hours print included, as Value is.
1140
1175
  const dayMove = portfolioDayMove(valuation);
1141
- const cashExport = cash && allocation.cash ? {
1142
- ...cash,
1176
+ // The whole cash line, whatever currencies it is in; a target without cash is a line of nothing.
1177
+ const cashExport = allocation.cash ? {
1178
+ ...(cash ?? { amount: 0, currency, source: "manual" as const, value: 0, balances: [] }),
1143
1179
  weight: allocation.cash.weight,
1144
1180
  targetWeight: allocation.cash.targetWeight,
1145
1181
  drift: allocation.cash.drift,
1146
1182
  tradeValue: allocation.cash.tradeValue,
1147
- } : allocation.cash ? {
1148
- amount: 0, currency, source: "manual" as const, value: 0,
1149
- weight: allocation.cash.weight, targetWeight: allocation.cash.targetWeight,
1150
- drift: allocation.cash.drift, tradeValue: allocation.cash.tradeValue,
1151
1183
  } : null;
1184
+ // Cash in several currencies is a row per currency, as a ticker held in several lots is a row per lot.
1185
+ const cashBalances = cashExport && cashExport.balances.length > 1 ? cashExport.balances : null;
1152
1186
 
1153
1187
  // `--drip`: each holding with a known income and a price, its lots netted: a long reinvests, a short owes.
1154
1188
  const dripNotProjected = new Set<string>();
@@ -1210,8 +1244,14 @@ async function showCollectionWithMarketData(
1210
1244
  if (structured) {
1211
1245
  // CSV and NDJSON read the cash and the total as rows; JSON keeps them in the metadata.
1212
1246
  const extraRows: Record<string, unknown>[] = [
1213
- ...(cashExport ? [{ symbol: CASH_SYMBOL, marketValue: cashExport.value, baseCurrency: currency, weight: cashExport.weight,
1214
- targetWeight: cashExport.targetWeight, drift: cashExport.drift, tradeShares: null, tradeValue: cashExport.tradeValue }] : []),
1247
+ // Several currencies: a CASH row each, the whole line's weight, target, drift and trade on the first as a ticker's
1248
+ // lots carry their position's; `balanceWeight` is each currency's own share.
1249
+ ...(cashBalances ? cashBalances.map((balance, index) => ({ symbol: CASH_SYMBOL, marketValue: balance.value, baseCurrency: currency,
1250
+ weight: index === 0 ? cashExport!.weight : null, targetWeight: index === 0 ? cashExport!.targetWeight : null,
1251
+ drift: index === 0 ? cashExport!.drift : null, tradeShares: null, tradeValue: index === 0 ? cashExport!.tradeValue : null,
1252
+ cashCurrency: balance.currency, cashAmount: balance.amount, balances: cashBalances.length, balanceWeight: balance.weight }))
1253
+ : cashExport ? [{ symbol: CASH_SYMBOL, marketValue: cashExport.value, baseCurrency: currency, weight: cashExport.weight,
1254
+ targetWeight: cashExport.targetWeight, drift: cashExport.drift, tradeShares: null, tradeValue: cashExport.tradeValue }] : []),
1215
1255
  { symbol: "TOTAL", marketValue: allocation.total, unrealizedPnl: totalPnlValue, baseCurrency: currency,
1216
1256
  weight: totalWeight(allocation), targetWeight: allocation.targetSum, valuationBasis: basis,
1217
1257
  annualIncome: totalIncome, incomeYield: portfolioYield },
@@ -1225,13 +1265,16 @@ async function showCollectionWithMarketData(
1225
1265
  dayChange: dayMove?.change ?? null, dayChangePercent: dayMove?.changePercent ?? null, dayChangeBasis: dayMove?.basis ?? null,
1226
1266
  dayChangeFx: dayMove?.fx ?? null,
1227
1267
  unpricedCount: allocation.unpriced.length, unpricedSymbols: allocation.unpriced,
1268
+ // Only while a currency's cash has no rate into the portfolio's: left out of the total and weights as an unpriced holding is.
1269
+ ...(allocation.unpricedCash.length > 0 ? { unpricedCashCurrencies: allocation.unpricedCash } : {}),
1228
1270
  totalUnrealizedPnl: totalPnlValue,
1229
1271
  annualIncome: totalIncome, knownAnnualIncome: income.knownIncome, portfolioYield,
1230
1272
  incomeComplete: income.gaps.size === 0, incomeUnavailable,
1231
1273
  incomeBasis: "Trailing twelve-month dividends per share times shares held, in the portfolio's currency; a short owes the dividend, so its income is negative. Portfolio yield is the total over the invested value without cash: the priced holdings' net value (exposure.net), or for a book that holds a short its gross exposure (weightBase), as its weights are; annualIncome is null when any holding's income is unknown, and knownAnnualIncome sums the holdings that have one.",
1232
1274
  // Each rate a holding in another currency was converted at, dated, and whether it is stale.
1233
1275
  fxRates: toBase.conversions().filter((conversion) => conversion.currency !== conversion.baseCurrency).map(fxRateRecord),
1234
- complete: unavailablePnl.size === 0 && unavailableCost.size === 0 && unavailableMarketValue.size === 0 && income.gaps.size === 0,
1276
+ complete: unavailablePnl.size === 0 && unavailableCost.size === 0 && unavailableMarketValue.size === 0 && income.gaps.size === 0
1277
+ && allocation.unpricedCash.length === 0,
1235
1278
  unavailableSymbols: [...new Set([...unavailablePnl, ...unavailableCost, ...unavailableMarketValue])],
1236
1279
  unavailableCostSymbols: [...unavailableCost], brokerPnlSymbols: [...brokerPnlSymbols],
1237
1280
  // The priced holdings' market value: longs, shorts (negative), net and gross. Cash and unpriced holdings are not in it.
@@ -1327,11 +1370,14 @@ async function showCollectionWithMarketData(
1327
1370
  ...allocationCells(whole, { unpriced: wholeValue == null, units: symbolUnits, assetCategory: ticker.metadata.assetCategory }),
1328
1371
  ...(showIncome ? ["", ""] : []), "", ""]];
1329
1372
  });
1330
- if (cashExport) {
1331
- const label = cashExport.currency && cashExport.currency !== currency ? `${CASH_SYMBOL} ${cashExport.currency}` : CASH_SYMBOL;
1332
- rows.push([label, "", "", ...extendedSessions.map(() => ""), "", "", cashExport.value == null ? NOT_AVAILABLE : wholeMoney(cashExport.value),
1333
- ...allocationCells(cashExport, { unpriced: cashExport.value == null }), ...(showIncome ? ["", ""] : []), "", ""]);
1373
+ const cashRow = (label: string, value: number | null, figures: Parameters<typeof allocationCells>[0]) => [label, "", "", ...extendedSessions.map(() => ""), "", "",
1374
+ value == null ? NOT_AVAILABLE : wholeMoney(value), ...allocationCells(figures, { unpriced: value == null }), ...(showIncome ? ["", ""] : []), "", ""];
1375
+ // Each currency's cash weighs by its own value; the target, drift and trade belong to the whole cash line under them.
1376
+ for (const balance of cashBalances ?? []) {
1377
+ rows.push(cashRow(cashLineLabel(balance.currency, currency, true), balance.value,
1378
+ { weight: balance.weight, targetWeight: null, drift: null, tradeValue: null }));
1334
1379
  }
1380
+ if (cashExport) rows.push(cashRow(cashBalances ? CASH_SYMBOL : cashLineLabel(cashExport.currency, currency), cashExport.value, cashExport));
1335
1381
  const total = allocation.total;
1336
1382
  const totalChange = dayMove?.changePercent != null ? colorBySign(formatPercentRaw(dayMove.changePercent), dayMove.change) : "—";
1337
1383
  rows.push([
@@ -1381,7 +1427,7 @@ async function showCollectionWithMarketData(
1381
1427
  // TOTAL's yield says what it divides: a hedged book's gross exposure, or, with cash in the book, the holdings alone.
1382
1428
  if (showIncome && portfolioYield != null && yieldBase != null && hedged) {
1383
1429
  notes.push(cliStyles.muted(`TOTAL yield is income over the gross exposure of ${wholeMoney(yieldBase)}, as the book holds a short; cash excluded.`));
1384
- } else if (showIncome && portfolioYield != null && yieldBase != null && cashExport?.value) {
1430
+ } else if (showIncome && portfolioYield != null && yieldBase != null && cashExport?.balances.some((balance) => balance.value)) {
1385
1431
  notes.push(cliStyles.muted(`TOTAL yield is income over the invested ${wholeMoney(yieldBase)}, cash excluded.`));
1386
1432
  }
1387
1433
  const weightNote = weightBasisLine(allocation, currency);
@@ -1397,11 +1443,8 @@ async function showCollectionWithMarketData(
1397
1443
  }
1398
1444
  if (cashExport?.source === "broker") notes.push(cliStyles.muted("Cash is the broker account's balance as of its last sync."));
1399
1445
  if (matchedPortfolio.brokerInstanceId && !account) notes.push(cliStyles.warning(BROKER_ACCOUNT_MISSING_NOTE));
1400
- if (cashExport && cashExport.value == null) {
1401
- notes.push(cliStyles.warning(cashExport.currency
1402
- ? `No ${cashExport.currency}/${currency} rate for the cash, so the total and weights are unavailable.`
1403
- : "The cash's currency is unknown, so the total and weights are unavailable."));
1404
- }
1446
+ const unpricedCash = unpricedCashNote(allocation.unpricedCash, currency);
1447
+ if (unpricedCash) notes.push(cliStyles.warning(unpricedCash));
1405
1448
  const targetNote = describeTargetSum(allocation.targetSum, allocation.weightBasis);
1406
1449
  if (targetNote) notes.push(cliStyles.muted(targetNote));
1407
1450
  if (brokerPnlSymbols.size > 0) notes.push(cliStyles.muted(`P&L for ${named(brokerPnlSymbols)} is the broker's last snapshot.`));
@@ -28,6 +28,7 @@ import {
28
28
  valuePortfolioAllocation,
29
29
  valuePortfolioPositions,
30
30
  costAtTodaysRateNotes,
31
+ unpricedCashNote,
31
32
  type CollectionMatch,
32
33
  type PortfolioValuation,
33
34
  } from "./cli/render";
@@ -39,6 +40,7 @@ import { EXTENDED_SESSION_LABELS, getCompletedRegularSessionDisplay, quoteHeadli
39
40
  import {
40
41
  BROKER_ACCOUNT_MISSING_NOTE,
41
42
  CASH_SYMBOL,
43
+ cashLineLabel,
42
44
  describeTargetSum,
43
45
  formatAllocationDrift,
44
46
  formatAllocationWeight,
@@ -261,23 +263,40 @@ function unavailableFigureErrors(
261
263
  const POSITION_LINE_KEYS = new Set(["symbol", "shares", "marketValue", "weight", "targetWeight", "drift", "tradeShares", "tradeValue"]);
262
264
 
263
265
  /**
264
- * The text report of a ticker held in several lots. Each lot weighs by its own
265
- * value, and a line under its lots gives the whole position: its shares, value,
266
- * weight, target, drift and trade, which no single lot owns. Null when no
267
- * ticker has several lots, so the report is the rows as they are. JSON and CSV
268
- * keep one row per lot.
266
+ * The text report of a ticker held in several lots, or of cash held in
267
+ * several currencies. Each lot weighs by its own value, and a line under its
268
+ * lots gives the whole position: its shares, value, weight, target, drift and
269
+ * trade, which no single lot owns. Each currency's cash (`CASH HKD`) weighs by
270
+ * its own value too, and the `CASH` line under them is the whole cash line,
271
+ * with its target. Null when there is neither, so the report is the rows as
272
+ * they are. JSON and CSV keep one row per lot and per currency.
269
273
  */
270
274
  function withPositionLines(
271
275
  rows: readonly HeadlessPaneRow[],
272
276
  columns: HeadlessPaneColumn[],
273
277
  positions: ReadonlyMap<string, PortfolioAllocation["rows"][number]>,
278
+ cash: PortfolioAllocation["cash"],
274
279
  ): { rows: HeadlessPaneRow[]; columns: HeadlessPaneColumn[] } | null {
275
280
  const lotted = (row: HeadlessPaneRow): row is HeadlessPaneRow & { lots: number } => typeof row.lots === "number";
276
- if (!rows.some(lotted)) return null;
281
+ const cashPart = (row: HeadlessPaneRow): row is HeadlessPaneRow & { balances: number } => typeof row.balances === "number";
282
+ if (!rows.some(lotted) && !rows.some(cashPart)) return null;
277
283
  const lastLot = new Map<string, number>();
278
284
  rows.forEach((row, index) => { if (lotted(row)) lastLot.set(String(row.symbol), index); });
285
+ const lastCash = rows.findLastIndex(cashPart);
286
+ // What a line under several rows is called: AAPL (2 lots), or CASH under its currencies.
287
+ const lineLabel = (row: HeadlessPaneRow) => typeof row.positionLots === "number" ? `(${row.positionLots} lots)` : null;
288
+ const isLine = (row: HeadlessPaneRow) => typeof row.positionLots === "number" || row.cashLine === true;
279
289
  return {
280
290
  rows: rows.flatMap((row, index): HeadlessPaneRow[] => {
291
+ if (cashPart(row)) {
292
+ const part = { ...row, cashLabel: cashLineLabel(String(row.priceCurrency ?? ""), "", true), weight: row.balanceWeight,
293
+ targetWeight: null, drift: null, tradeShares: null, tradeValue: null };
294
+ if (!cash || index !== lastCash) return [part];
295
+ return [part, {
296
+ cashLine: true, symbol: CASH_SYMBOL, marketValue: cash.value, weight: cash.weight, targetWeight: cash.targetWeight,
297
+ drift: cash.drift, tradeShares: null, tradeValue: cash.tradeValue,
298
+ }];
299
+ }
281
300
  if (!lotted(row)) return [row];
282
301
  const symbol = String(row.symbol);
283
302
  const lot = { ...row, weight: row.lotWeight, targetWeight: null, drift: null, tradeShares: null, tradeValue: null };
@@ -292,9 +311,12 @@ function withPositionLines(
292
311
  columns: columns.map((column) => {
293
312
  const text = (value: unknown, row: HeadlessPaneRow) => (column.textFormat ?? column.format)?.(value, row) ?? textOf(value) ?? formatNumber(undefined);
294
313
  if (column.key === "symbol") {
295
- return { ...column, textFormat: (value, row) => typeof row.positionLots === "number" ? `${text(value, row)} (${row.positionLots} lots)` : text(value, row) };
314
+ return { ...column, textFormat: (value, row) => typeof row.cashLabel === "string" ? row.cashLabel
315
+ : lineLabel(row) ? `${text(value, row)} ${lineLabel(row)}` : text(value, row) };
296
316
  }
297
- return POSITION_LINE_KEYS.has(column.key) ? column : { ...column, textFormat: (value, row) => typeof row.positionLots === "number" ? "" : text(value, row) };
317
+ // The cash line counts no units: its quantity is blank, as everything else it does not fill in is.
318
+ const blank = (row: HeadlessPaneRow) => isLine(row) && (!POSITION_LINE_KEYS.has(column.key) || (row.cashLine === true && column.key === "shares"));
319
+ return { ...column, textFormat: (value, row) => blank(row) ? "" : text(value, row) };
298
320
  }),
299
321
  };
300
322
  }
@@ -397,19 +419,41 @@ async function portfolioHoldings(
397
419
  };
398
420
  });
399
421
  const shown: HeadlessPaneRow[] = rows.slice(0, limit);
400
- // The cash line follows the positions, whatever the limit.
422
+ // The cash line follows the positions, whatever the limit. Cash in several currencies is a row per currency, the whole
423
+ // line's weight, target, drift and trade on the first as a ticker's lots carry their position's; `balanceWeight` is each
424
+ // currency's own share.
401
425
  if (allocation.cash) {
402
- shown.push({
403
- symbol: CASH_SYMBOL,
404
- name: cash?.source === "broker" ? "Cash (broker account)" : "Cash",
405
- priceCurrency: cash?.currency ?? null,
406
- marketValue: finite(allocation.cash.value),
407
- weight: allocation.cash.weight,
408
- targetWeight: allocation.cash.targetWeight,
409
- drift: allocation.cash.drift,
410
- tradeShares: null,
411
- tradeValue: allocation.cash.tradeValue,
412
- });
426
+ const name = cash?.source === "broker" ? "Cash (broker account)" : "Cash";
427
+ const line = allocation.cash;
428
+ const balances = cash && cash.balances.length > 1 ? cash.balances : null;
429
+ if (balances) {
430
+ balances.forEach((balance, index) => shown.push({
431
+ symbol: CASH_SYMBOL,
432
+ name,
433
+ priceCurrency: balance.currency,
434
+ cashAmount: balance.amount,
435
+ marketValue: finite(balance.value),
436
+ weight: index === 0 ? line.weight : null,
437
+ targetWeight: index === 0 ? line.targetWeight : null,
438
+ drift: index === 0 ? line.drift : null,
439
+ tradeShares: null,
440
+ tradeValue: index === 0 ? line.tradeValue : null,
441
+ balances: balances.length,
442
+ balanceWeight: balance.weight,
443
+ }));
444
+ } else {
445
+ shown.push({
446
+ symbol: CASH_SYMBOL,
447
+ name,
448
+ priceCurrency: cash?.currency ?? null,
449
+ marketValue: finite(line.value),
450
+ weight: line.weight,
451
+ targetWeight: line.targetWeight,
452
+ drift: line.drift,
453
+ tradeShares: null,
454
+ tradeValue: line.tradeValue,
455
+ });
456
+ }
413
457
  }
414
458
  const errors = unavailableFigureErrors(valuation);
415
459
  const broker = !!(target.portfolio.brokerId || target.portfolio.brokerInstanceId);
@@ -428,6 +472,7 @@ async function portfolioHoldings(
428
472
  : []),
429
473
  ...(targetNote ? [targetNote] : []),
430
474
  ...(target.portfolio.brokerInstanceId && !resolved.account ? [BROKER_ACCOUNT_MISSING_NOTE] : []),
475
+ ...[unpricedCashNote(allocation.unpricedCash, currency)].filter((line): line is string => !!line),
431
476
  ...costAtTodaysRateNotes(valuation, (symbols) => [...symbols].join(", ")),
432
477
  ];
433
478
 
@@ -438,7 +483,7 @@ async function portfolioHoldings(
438
483
  withExtendedColumns(withBookCurrency([...positionColumns, ...(showTargets ? TARGET_COLUMNS : []), VALUATION_TIME_COLUMN], currency), extendedSessions),
439
484
  tickers,
440
485
  );
441
- const lotted = withPositionLines(shown, columns, allocationBySymbol);
486
+ const lotted = withPositionLines(shown, columns, allocationBySymbol, allocation.cash);
442
487
 
443
488
  return {
444
489
  // Dated by the prices the value uses, and the oldest of them in exports, with the basis in the closing line.
@@ -478,6 +523,8 @@ async function portfolioHoldings(
478
523
  ...(cash ? { cash } : {}),
479
524
  ...(showTargets ? { targetSum: allocation.targetSum } : {}),
480
525
  unpricedCount: allocation.unpriced.length,
526
+ // Only while a currency's cash has no rate into the portfolio's: left out of the total and weights as an unpriced holding is.
527
+ ...(allocation.unpricedCash.length > 0 ? { unpricedCashCurrencies: allocation.unpricedCash } : {}),
481
528
  ...(notices.length > 0 ? { notices } : {}),
482
529
  },
483
530
  };
@@ -663,7 +710,7 @@ async function watchlistHoldings(
663
710
  export const collectionHoldingsHeadless: HeadlessPaneDefinition<"rows"> = {
664
711
  shape: "rows",
665
712
  description:
666
- "Positions held in a portfolio, broker or manual: symbol, exchange, shares, average cost, last price, market value, unrealized P&L, weight of the total with cash (of the gross exposure for a book that holds a short) and when each row's price is from, largest first, then the cash line and totals. Values are at the latest print, extended hours included, or at the regular close with close. With target weights set, each row adds its target, drift and the trade to reach it. For a watchlist, its tickers with quotes. Takes a portfolio or watchlist ID; the first portfolio when omitted.",
713
+ "Positions held in a portfolio, broker or manual: symbol, exchange, shares, average cost, last price, market value, unrealized P&L, weight of the total with cash (of the gross exposure for a book that holds a short) and when each row's price is from, largest first, then the cash line (a row per currency when it is held in several, the line's weight, target, drift and trade on the first) and totals. Values are at the latest print, extended hours included, or at the regular close with close. With target weights set, each row adds its target, drift and the trade to reach it. For a watchlist, its tickers with quotes. Takes a portfolio or watchlist ID; the first portfolio when omitted.",
667
714
  discovery: {
668
715
  dataRequirements: ["Local portfolios, watchlists and synced broker positions; current quotes"],
669
716
  limitations: ["Unrealized P&L on current positions; excludes realized trades, distributions and cash flows."],
@@ -192,12 +192,12 @@ export function buildTrackedCurrencies(
192
192
  financialsMap: Map<string, TickerFinancials>,
193
193
  accountState: ResolvedPortfolioAccountState | null,
194
194
  baseCurrency: string,
195
- /** The currency of cash entered by hand. */
196
- cashCurrency?: string,
195
+ /** The currencies of cash entered by hand. */
196
+ cashCurrencies?: readonly (string | null | undefined)[],
197
197
  ): string[] {
198
198
  const currencies = new Set<string>([baseCurrency]);
199
199
  if (accountState?.account.currency) currencies.add(accountState.account.currency);
200
- if (cashCurrency) currencies.add(cashCurrency);
200
+ for (const currency of cashCurrencies ?? []) if (currency) currencies.add(currency);
201
201
 
202
202
  for (const ticker of tickers) {
203
203
  if (ticker.metadata.currency) {
@@ -3,9 +3,11 @@ import { Box, useUiCapabilities } from "../../../../ui";
3
3
  import { brokerPortfolioLogo } from "../../../../brokers/logos";
4
4
  import { LogoMark } from "../../../../components/ui/logo-mark";
5
5
  import { describeFundamentalMarketCap } from "../../../../utils/market-capitalization";
6
+ import { wrapTextLines } from "../../../../utils/text-wrap";
6
7
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
7
8
  import {
8
9
  confirmDialog,
10
+ RowNote,
9
11
  usePaneFooter,
10
12
  usePaneMenuItems,
11
13
  usePaneNoticeFooter,
@@ -123,7 +125,9 @@ import {
123
125
  buildPortfolioAllocation,
124
126
  CASH_SYMBOL,
125
127
  hasTargetWeights,
128
+ pricedCashValue,
126
129
  resolvePortfolioCash,
130
+ type AllocationCashBalance,
127
131
  } from "../../../../portfolio/allocation";
128
132
  import { allocationSummaryRows, CASH_ROW_KEY } from "../allocation-rows";
129
133
  import { useTargetWeightActions, type TargetRow } from "./target-weights";
@@ -304,13 +308,14 @@ export function PortfolioListPane({ focused, width, height }: PaneProps) {
304
308
  [columns],
305
309
  );
306
310
 
307
- // The broker account's cash when it reports one, else the cash entered by hand.
311
+ // The broker account's cash when it reports one, else each currency's cash entered by hand.
308
312
  const cashLine = useMemo(
309
313
  () => isPortfolioTab ? resolvePortfolioCash(currentPortfolio, accountState?.account) : null,
310
314
  [accountState, currentPortfolio, isPortfolioTab],
311
315
  );
312
316
  const trackedCurrencies = useMemo(
313
- () => buildTrackedCurrencies(tickers, financialsMap, accountState, totalsCurrency, cashLine?.source === "manual" ? cashLine.currency : undefined),
317
+ () => buildTrackedCurrencies(tickers, financialsMap, accountState, totalsCurrency,
318
+ cashLine?.source === "manual" ? cashLine.balances.map((balance) => balance.currency) : undefined),
314
319
  [accountState, cashLine, financialsMap, tickers, totalsCurrency],
315
320
  );
316
321
  const exchangeRates = useFxRatesMap(trackedCurrencies);
@@ -325,9 +330,14 @@ export function PortfolioListPane({ focused, width, height }: PaneProps) {
325
330
  (value: number) => convertCurrency(value, accountCurrency, totalsCurrency, exchangeRates),
326
331
  [accountCurrency, exchangeRates, totalsCurrency],
327
332
  );
328
- const cashValue = cashLine == null ? null
329
- : cashLine.source === "broker" ? convertAccountValue(cashLine.amount)
330
- : convertCurrency(cashLine.amount, cashLine.currency, totalsCurrency, exchangeRates);
333
+ // Each balance in the totals currency; one without a rate has no value and stays out of the total, as an unpriced holding does.
334
+ const cashBalances = useMemo((): AllocationCashBalance[] => (cashLine?.balances ?? []).map(({ amount, currency }) => {
335
+ const value = cashLine?.source === "broker" ? convertAccountValue(amount) : convertCurrency(amount, currency, totalsCurrency, exchangeRates);
336
+ return { amount, currency, value: Number.isFinite(value) ? value : null };
337
+ }), [cashLine, convertAccountValue, exchangeRates, totalsCurrency]);
338
+ // The cash the total counts, and the whole cash line, unknown while a balance has no rate.
339
+ const cashValue = pricedCashValue(cashBalances);
340
+ const cashLineValue = cashBalances.every((balance) => balance.value != null) ? cashValue : null;
331
341
  // Only weights divide by the total: skip the walk when nothing shows one.
332
342
  const needsWeightTotal = isPortfolioTab
333
343
  && (viewMode === "grid" || columns.some((column) => ALLOCATION_COLUMN_IDS.has(column.id)));
@@ -511,11 +521,11 @@ export function PortfolioListPane({ focused, width, height }: PaneProps) {
511
521
  if (!isPortfolioTab || accountState || (cashLine == null && portfolioTargets?.[CASH_SYMBOL] == null)) return null;
512
522
  const allocation = buildPortfolioAllocation({
513
523
  holdings: portfolioSummaryTotals.allocationHoldings ?? [],
514
- cashValue: cashValue ?? (cashLine ? Number.NaN : null),
524
+ cash: cashBalances,
515
525
  targets: portfolioTargets,
516
526
  });
517
527
  return allocation.cash ? { ...allocation.cash, total: allocation.total } : null;
518
- }, [accountState, cashLine, cashValue, isPortfolioTab, portfolioSummaryTotals, portfolioTargets]);
528
+ }, [accountState, cashBalances, cashLine, isPortfolioTab, portfolioSummaryTotals, portfolioTargets]);
519
529
  // Under the holdings of a book with cash entered by hand or targets, its CASH and TOTAL rows, as
520
530
  // `portfolio show` prints them: cash takes a target and a trade like a holding, so the trades add up.
521
531
  const showsAllocationRows = isPortfolioTab && viewMode === "table" && !paneSettings.hideCash
@@ -524,11 +534,11 @@ export function PortfolioListPane({ focused, width, height }: PaneProps) {
524
534
  if (!showsAllocationRows) return undefined;
525
535
  const allocation = buildPortfolioAllocation({
526
536
  holdings: portfolioSummaryTotals.allocationHoldings ?? [],
527
- cashValue: cashValue ?? (cashLine ? Number.NaN : null),
537
+ cash: cashBalances,
528
538
  targets: portfolioTargets,
529
539
  });
530
- return allocationSummaryRows(allocation, { cashCurrency: cashLine?.currency, currency: totalsCurrency });
531
- }, [cashLine, cashValue, portfolioSummaryTotals, portfolioTargets, showsAllocationRows, totalsCurrency]);
540
+ return allocationSummaryRows(allocation, { currency: totalsCurrency });
541
+ }, [cashBalances, portfolioSummaryTotals, portfolioTargets, showsAllocationRows, totalsCurrency]);
532
542
  const cashRowShown = !!allocationRows?.some((row) => row.id === "cash");
533
543
  const summarySegments = useMemo(() => buildPortfolioSummarySegments({
534
544
  totals: portfolioSummaryTotals,
@@ -831,14 +841,14 @@ export function PortfolioListPane({ focused, width, height }: PaneProps) {
831
841
  const targetRow = useMemo<TargetRow | null>(() => {
832
842
  if (!isPortfolioTab || !currentPortfolio) return null;
833
843
  if (cursorSymbol === CASH_ROW_KEY) {
834
- return cashRowShown ? { cash: true, symbol: CASH_SYMBOL, label: "Cash", weight: cashWeight(cashValue, portfolioWeightBase, portfolioWeightBasis) } : null;
844
+ return cashRowShown ? { cash: true, symbol: CASH_SYMBOL, label: "Cash", weight: cashWeight(cashLineValue, portfolioWeightBase, portfolioWeightBasis) } : null;
835
845
  }
836
846
  if (!selectedTicker) return null;
837
847
  const symbol = selectedTicker.metadata.ticker;
838
848
  const holding = weightHoldings?.find((entry) => entry.symbol === symbol);
839
849
  const weight = holding ? allocationFigures(holding, portfolioWeightBase, null).weight : null;
840
850
  return { cash: false, symbol, label: symbol, weight };
841
- }, [cashRowShown, cashValue, currentPortfolio, cursorSymbol, isPortfolioTab, portfolioWeightBase, portfolioWeightBasis, selectedTicker, weightHoldings]);
851
+ }, [cashLineValue, cashRowShown, currentPortfolio, cursorSymbol, isPortfolioTab, portfolioWeightBase, portfolioWeightBasis, selectedTicker, weightHoldings]);
842
852
  const listedSymbols = useMemo(() => new Set(collectionTickers.map((ticker) => ticker.metadata.ticker)), [collectionTickers]);
843
853
  useTargetWeightActions({ portfolio: currentPortfolio, row: targetRow, listedSymbols, enabled: focused && viewMode === "table" && !quickAddFocused });
844
854
 
@@ -952,10 +962,14 @@ export function PortfolioListPane({ focused, width, height }: PaneProps) {
952
962
  const delistedNotice = selectedDelisting ? `${cursorSymbol}: ${delistingLabel(selectedDelisting)}.` : undefined;
953
963
  usePaneNoticeFooter({
954
964
  registrationId: "portfolio-list-notices",
955
- notices: [...summaryNotices, ...periodPnlNotices(periodPnl), delistedNotice, capNotice, multiplierNotice].filter((notice): notice is string => !!notice),
965
+ notices: [...summaryNotices, ...periodPnlNotices(periodPnl)],
956
966
  focused: focused && !quickAddFocused,
957
967
  });
958
- const contentHeight = Math.max(1, height - headerHeight - summaryHeight - drawerHeight - quickAddHeight);
968
+ // What concerns the selected holding is said under the list while it is selected, as a table's row note is:
969
+ // its delisting, where its market cap comes from, its missing multiplier. The footer's notes are the list's.
970
+ const cursorNote = [delistedNotice, capNotice, multiplierNotice].filter((notice): notice is string => !!notice).join(" ");
971
+ const cursorNoteHeight = cursorNote ? wrapTextLines(cursorNote, Math.max(1, width - 2)).length : 0;
972
+ const contentHeight = Math.max(1, height - headerHeight - summaryHeight - drawerHeight - quickAddHeight - cursorNoteHeight);
959
973
  const quickAddRow = activeCollectionId && activeCollectionEntry && quickAddCollectionKind ? (
960
974
  <QuickAddTickerInput
961
975
  collectionId={activeCollectionId}
@@ -1033,6 +1047,7 @@ export function PortfolioListPane({ focused, width, height }: PaneProps) {
1033
1047
  height={contentHeight}
1034
1048
  />
1035
1049
  )}
1050
+ <RowNote>{cursorNote}</RowNote>
1036
1051
 
1037
1052
  {quickAddRow}
1038
1053
  {positionsImport.picker}
@@ -282,7 +282,7 @@ export function buildPortfolioSummarySegments({
282
282
  /** The app's base currency: amounts are bare only when both are USD. */
283
283
  baseCurrency?: string;
284
284
  /** Cash entered by hand, in the totals currency, with the total it is weighed against. */
285
- manualCash?: (PortfolioCashLine & { total: number | null }) | null;
285
+ manualCash?: (Pick<PortfolioCashLine, "value" | "weight" | "targetWeight" | "drift"> & { total: number | null }) | null;
286
286
  }): PortfolioSummarySegment[] {
287
287
  const money = (value: number | undefined, signed = false) => formatPortfolioAmount(value, currency, { signed, baseCurrency, named: otherCurrencies });
288
288
  if (!isPortfolioTab) {
@@ -356,7 +356,7 @@ export function buildPortfolioSummarySegments({
356
356
  const drift = formatAllocationDrift(manualCash.drift);
357
357
  candidates.push(createSummarySegment("cash", [
358
358
  { text: "Cash", tone: "label" },
359
- { text: money(manualCash.value), tone: "value", bold: true },
359
+ { text: money(manualCash.value ?? Number.NaN), tone: "value", bold: true },
360
360
  ...(manualCash.weight != null ? [{ text: `(${formatAllocationWeight(manualCash.weight)})`, tone: "muted" as const }] : []),
361
361
  ...(manualCash.targetWeight != null && manualCash.drift != null
362
362
  ? [{ text: drift, tone: "muted" as const, color: /[1-9]/.test(drift) ? priceColor(manualCash.drift) : undefined }]
@@ -22,7 +22,7 @@ import { RANGE_FROM_BARS_NOTE } from "../../../portfolio/column-values";
22
22
  import { periodPnlFigure, tickerDisplayName } from "../../../portfolio/column-values";
23
23
  import { listedSymbol } from "../../../portfolio/listed-symbol";
24
24
  import { displayWidth } from "../../../utils/format";
25
- import { dropColumnsToFit } from "../../../components/ui/table-layout";
25
+ import { dropColumnsToFit, markHiddenTableColumns } from "../../../components/ui/table-layout";
26
26
  import { sinceLastSeenTint, type SinceLastSeenRecap } from "./since-last-seen";
27
27
  import { portfolioPnlLabel } from "../../../portfolio/position-metrics";
28
28
  import { PORTFOLIO_ROW_MENU_KEYS } from "./row-actions";
@@ -363,7 +363,8 @@ export function PortfolioTickerTable({
363
363
  hiddenCompanyRef.current.ids = new Set(hiddenColumnIds.split(",").filter((id) => COMPANY_COLUMN_IDS.has(id)));
364
364
  const displayColumns = useMemo(() => {
365
365
  const hidden = new Set(hiddenColumnIds.split(","));
366
- return hiddenColumnIds ? sizedColumns.filter((column) => !hidden.has(column.id)) : sizedColumns;
366
+ const eligible = sizedColumns.filter((column) => !hiddenCompanyRef.current.ids.has(column.id));
367
+ return hiddenColumnIds ? markHiddenTableColumns(eligible, eligible.filter((column) => !hidden.has(column.id))) : sizedColumns;
367
368
  }, [hiddenColumnIds, sizedColumns]);
368
369
  // Over a period, each currency's part under the rows, so P&L adds up to the header's total as portfolio show --from prints it.
369
370
  const periodLines = columnContext.periodPnl?.lines ?? null;
@@ -280,11 +280,9 @@ function RotationView({
280
280
  usePaneNoticeFooter({
281
281
  registrationId: "relative-rotation:notices",
282
282
  focused,
283
+ // What concerns the whole chart; a symbol's own gaps are its row's (`rowNote`).
283
284
  notices: [
284
285
  ...(data?.gaps ?? []),
285
- ...(data?.rows.flatMap((row) =>
286
- row.gaps.map((gap) => `${row.symbol}: ${gap}`),
287
- ) ?? []),
288
286
  ...(resource.data?.refreshError ? [resource.data.refreshError] : []),
289
287
  ],
290
288
  });
@@ -350,6 +348,7 @@ function RotationView({
350
348
  onChange: setSelectedId,
351
349
  }}
352
350
  onActivate={(row) => setOpenId(row.id)}
351
+ rowNote={(row) => row.gaps.length ? `${row.symbol}: ${row.gaps.join(" ")}` : null}
353
352
  detailOpen={!!selected}
354
353
  onBack={() => setOpenId(null)}
355
354
  detailTitle={selected?.label}