@gloom-sh/terminal 0.20.20 → 0.20.21

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 (365) hide show
  1. package/package.json +3 -1
  2. package/src/api-client/data.ts +1 -1
  3. package/src/api-client/equity-screener.ts +17 -0
  4. package/src/api-client/futures-curve.ts +5 -0
  5. package/src/api-client/market-discovery.ts +8 -0
  6. package/src/api-client/members.ts +2 -0
  7. package/src/api-client/paths.ts +3 -0
  8. package/src/api-client/perps.ts +20 -0
  9. package/src/api-client/request.ts +53 -7
  10. package/src/api-client/types/filings-and-calls.ts +2 -0
  11. package/src/app/pane-runtime/plugin-bindings.ts +6 -4
  12. package/src/app/pro-welcome/model.ts +15 -11
  13. package/src/app/pro-welcome/row.tsx +3 -3
  14. package/src/app/pro-welcome/use-pro-welcome.ts +2 -2
  15. package/src/app/runtime/startup.ts +3 -2
  16. package/src/app.tsx +3 -2
  17. package/src/capabilities/asset-data-inputs.ts +5 -0
  18. package/src/capabilities/factories.ts +8 -3
  19. package/src/capabilities/registry.ts +1 -0
  20. package/src/capabilities/types.ts +1 -0
  21. package/src/cli/commands/market.ts +68 -35
  22. package/src/cli/commands/options-chain.ts +2 -2
  23. package/src/cli/commands/overview.ts +10 -9
  24. package/src/cli/commands/ticker.ts +19 -4
  25. package/src/cli/desktop-pane-shot.ts +11 -3
  26. package/src/cli/export-source.ts +35 -2
  27. package/src/cli/glossary.ts +3 -2
  28. package/src/cli/helpers.ts +2 -1
  29. package/src/cli/history-demergers.ts +41 -10
  30. package/src/cli/history-rows.ts +3 -1
  31. package/src/cli/known-gaps.ts +21 -7
  32. package/src/cli/listing-arg.ts +22 -11
  33. package/src/cli/pane-functions/capabilities.ts +4 -9
  34. package/src/cli/pane-functions/catalog-snapshot.json +29 -29
  35. package/src/cli/pane-functions/catalog.ts +1 -18
  36. package/src/cli/pane-functions/data.ts +8 -4
  37. package/src/cli/pane-functions/financial-ratio-shot.ts +20 -5
  38. package/src/cli/pane-functions/freshness.ts +57 -12
  39. package/src/cli/pane-functions/function-help.ts +2 -2
  40. package/src/cli/pane-functions/headless.ts +6 -0
  41. package/src/cli/pane-functions/index.ts +11 -4
  42. package/src/cli/pane-functions/market-session.ts +25 -0
  43. package/src/cli/pane-functions/report-notices.ts +10 -0
  44. package/src/cli/pane-functions/resolver.ts +75 -3
  45. package/src/cli/pane-functions/screenshot-bridge.ts +1 -0
  46. package/src/cli/pane-functions/screenshot-data-evidence.ts +1 -0
  47. package/src/cli/pane-functions/screenshot-payload.ts +38 -5
  48. package/src/cli/pane-functions/screenshot-render.ts +20 -7
  49. package/src/cli/perpetual-contract.ts +14 -1
  50. package/src/cli/report-tables.ts +11 -2
  51. package/src/cli/result.ts +6 -1
  52. package/src/components/chart-table/layout.ts +8 -4
  53. package/src/components/command-bar/list/model.ts +2 -0
  54. package/src/components/command-bar/pane-templates/items.ts +5 -25
  55. package/src/components/command-bar/panel/index.tsx +7 -4
  56. package/src/components/command-bar/routes/root/provider-search.ts +4 -4
  57. package/src/components/command-bar/routes/root/results.ts +6 -2
  58. package/src/components/command-bar/routes/ticker-search/results.ts +19 -0
  59. package/src/components/command-bar/routes/ticker-search/route.ts +3 -3
  60. package/src/components/command-bar/routes/ticker-search/title.ts +23 -0
  61. package/src/components/command-bar/routing/list-state.ts +17 -5
  62. package/src/components/command-bar/selection-runtime.ts +3 -2
  63. package/src/components/command-bar/surface/index.tsx +2 -0
  64. package/src/components/command-bar/workflow/alert.ts +6 -4
  65. package/src/components/command-bar/workflow/collection-actions.ts +2 -1
  66. package/src/components/layout/pane/footer/index.tsx +1 -0
  67. package/src/components/layout/pane/footer/model.ts +20 -7
  68. package/src/components/layout/pane/title.ts +11 -2
  69. package/src/components/price-selector-dialog.tsx +8 -4
  70. package/src/components/ticker/badge/list.tsx +4 -3
  71. package/src/components/ticker/list-table-view.tsx +12 -1
  72. package/src/components/ui/query-bar.tsx +20 -14
  73. package/src/data/cached-query.ts +20 -4
  74. package/src/data/news-pane-snapshots.ts +2 -1
  75. package/src/data/plugin-cache.ts +5 -1
  76. package/src/data/saved-copies.ts +68 -2
  77. package/src/docs/snapshot.json +65 -14
  78. package/src/docs/topics.ts +11 -9
  79. package/src/i18n/es.ts +1 -0
  80. package/src/i18n/ja.ts +1 -0
  81. package/src/i18n/ko.ts +1 -0
  82. package/src/i18n/zh-cn.ts +1 -0
  83. package/src/i18n/zh-tw.ts +1 -0
  84. package/src/market-data/coordinator/index.ts +25 -5
  85. package/src/market-data/depositary-pair.ts +27 -10
  86. package/src/market-data/futures-roll-returns.ts +54 -7
  87. package/src/market-data/fx-closes.ts +14 -0
  88. package/src/market-data/market/futures-product-hours.ts +113 -0
  89. package/src/market-data/market/futures-week.ts +2 -0
  90. package/src/market-data/market/globex-day.ts +9 -2
  91. package/src/market-data/market/status.ts +32 -25
  92. package/src/market-data/market/venue-session.ts +18 -0
  93. package/src/market-data/options-alternatives.ts +49 -7
  94. package/src/market-data/perpetual-open-interest.ts +41 -0
  95. package/src/market-data/quotes/contributions.ts +4 -2
  96. package/src/market-data/quotes/export-identity.ts +11 -3
  97. package/src/market-data/quotes/freshness.ts +3 -2
  98. package/src/market-data/quotes/resolution.ts +9 -2
  99. package/src/market-data/quotes/tick-range.ts +22 -1
  100. package/src/market-data/quotes/time.ts +34 -4
  101. package/src/market-data/split-terms.ts +3 -2
  102. package/src/news/aggregator.ts +1 -0
  103. package/src/news/news-model.ts +12 -2
  104. package/src/news/types.ts +15 -0
  105. package/src/plugins/builtin/alerts/alert-engine.ts +2 -0
  106. package/src/plugins/builtin/alerts/cli-forms.ts +3 -2
  107. package/src/plugins/builtin/alerts/cli-move.ts +5 -2
  108. package/src/plugins/builtin/alerts/cli.ts +50 -25
  109. package/src/plugins/builtin/alerts/command.ts +51 -3
  110. package/src/plugins/builtin/alerts/event-rows.ts +1 -1
  111. package/src/plugins/builtin/alerts/events-pane.tsx +1 -1
  112. package/src/plugins/builtin/alerts/format.ts +67 -8
  113. package/src/plugins/builtin/alerts/headless.ts +22 -6
  114. package/src/plugins/builtin/alerts/index.tsx +26 -25
  115. package/src/plugins/builtin/alerts/move-checks.ts +1 -0
  116. package/src/plugins/builtin/alerts/pane.tsx +15 -6
  117. package/src/plugins/builtin/alerts/pro-rules.ts +9 -4
  118. package/src/plugins/builtin/alerts/quotes.ts +10 -5
  119. package/src/plugins/builtin/alerts/session.ts +28 -0
  120. package/src/plugins/builtin/alerts/types.ts +1 -0
  121. package/src/plugins/builtin/analytics/pane-model.ts +2 -1
  122. package/src/plugins/builtin/analytics/risk-model.ts +2 -2
  123. package/src/plugins/builtin/attention/headless.ts +2 -2
  124. package/src/plugins/builtin/attention/model.ts +7 -2
  125. package/src/plugins/builtin/attention/pane.tsx +2 -1
  126. package/src/plugins/builtin/awards/headless.ts +1 -1
  127. package/src/plugins/builtin/broker-trading/ticket.tsx +13 -5
  128. package/src/plugins/builtin/buildout/detail/company.tsx +0 -1
  129. package/src/plugins/builtin/buildout/detail/ui.tsx +7 -5
  130. package/src/plugins/builtin/buildout/model/normalizers.ts +0 -1
  131. package/src/plugins/builtin/buildout/model/types.ts +0 -1
  132. package/src/plugins/builtin/buildout/pane/index.tsx +9 -0
  133. package/src/plugins/builtin/buildout/pane/status.tsx +11 -0
  134. package/src/plugins/builtin/catalysts/headless.ts +1 -1
  135. package/src/plugins/builtin/chart-composer/headless.ts +14 -6
  136. package/src/plugins/builtin/chart-composer/pane.tsx +2 -1
  137. package/src/plugins/builtin/chart-composer/session-history.ts +14 -2
  138. package/src/plugins/builtin/chat/controller/index.ts +5 -3
  139. package/src/plugins/builtin/chat/controller/session-runtime.ts +18 -8
  140. package/src/plugins/builtin/chat/index.tsx +1 -1
  141. package/src/plugins/builtin/cloud/auth-actions.tsx +4 -2
  142. package/src/plugins/builtin/cloud/mcp-connect/dialog.tsx +4 -1
  143. package/src/plugins/builtin/cloud/thesis/ticker-tab.tsx +2 -1
  144. package/src/plugins/builtin/company-attention/headless.ts +2 -1
  145. package/src/plugins/builtin/company-kpis/headless.ts +1 -1
  146. package/src/plugins/builtin/correlation/headless.ts +3 -3
  147. package/src/plugins/builtin/correlation/history.ts +1 -0
  148. package/src/plugins/builtin/correlation/index.tsx +7 -5
  149. package/src/plugins/builtin/correlation/matrix/selection.ts +21 -3
  150. package/src/plugins/builtin/correlation/relationship/model.ts +5 -0
  151. package/src/plugins/builtin/correlation/relationship/pane.tsx +3 -2
  152. package/src/plugins/builtin/correlation/relationship/view-model.ts +3 -2
  153. package/src/plugins/builtin/credit-documents/headless.ts +1 -1
  154. package/src/plugins/builtin/dividend-yield/client.ts +81 -10
  155. package/src/plugins/builtin/dividend-yield/headless.ts +21 -10
  156. package/src/plugins/builtin/dividend-yield/model.ts +1 -1
  157. package/src/plugins/builtin/dividend-yield/pane.tsx +9 -5
  158. package/src/plugins/builtin/dividend-yield/ranking.ts +15 -5
  159. package/src/plugins/builtin/dividend-yield/reference-price.ts +3 -0
  160. package/src/plugins/builtin/dividend-yield/types.ts +12 -0
  161. package/src/plugins/builtin/dividend-yield/view.ts +30 -7
  162. package/src/plugins/builtin/doe/headless.ts +1 -1
  163. package/src/plugins/builtin/doe/pane.tsx +16 -7
  164. package/src/plugins/builtin/earnings-calls/data.ts +8 -5
  165. package/src/plugins/builtin/earnings-ripple/headless.ts +1 -1
  166. package/src/plugins/builtin/econ/calendar-model.ts +1 -1
  167. package/src/plugins/builtin/econ/index.tsx +26 -18
  168. package/src/plugins/builtin/equity-screener/client.ts +1 -1
  169. package/src/plugins/builtin/equity-screener/headless.ts +149 -31
  170. package/src/plugins/builtin/equity-screener/live.ts +23 -5
  171. package/src/plugins/builtin/equity-screener/model.ts +27 -12
  172. package/src/plugins/builtin/equity-screener/pane.tsx +5 -5
  173. package/src/plugins/builtin/exposure/headless.ts +1 -1
  174. package/src/plugins/builtin/exposure/holdings.ts +2 -2
  175. package/src/plugins/builtin/futures/index.tsx +29 -1
  176. package/src/plugins/builtin/futures/model.ts +93 -10
  177. package/src/plugins/builtin/futures/returns.ts +54 -1
  178. package/src/plugins/builtin/futures/table.tsx +14 -2
  179. package/src/plugins/builtin/futures/use-front-returns.ts +20 -3
  180. package/src/plugins/builtin/futures-curve/client.ts +1 -1
  181. package/src/plugins/builtin/futures-curve/headless.ts +9 -3
  182. package/src/plugins/builtin/futures-curve/model.ts +19 -5
  183. package/src/plugins/builtin/futures-curve/pane.tsx +12 -6
  184. package/src/plugins/builtin/gpu/headless.ts +1 -1
  185. package/src/plugins/builtin/gpu/model.ts +1 -1
  186. package/src/plugins/builtin/help/function-index.ts +16 -8
  187. package/src/plugins/builtin/help/functions-table.tsx +6 -4
  188. package/src/plugins/builtin/help/shortcut-model.ts +7 -2
  189. package/src/plugins/builtin/holders/headless.ts +16 -5
  190. package/src/plugins/builtin/holders/pane.tsx +43 -5
  191. package/src/plugins/builtin/insider/client.ts +118 -11
  192. package/src/plugins/builtin/insider/filing-stories.ts +36 -20
  193. package/src/plugins/builtin/insider/issuer.ts +5 -2
  194. package/src/plugins/builtin/iv-history/headless.ts +2 -0
  195. package/src/plugins/builtin/macro-day/client.ts +2 -3
  196. package/src/plugins/builtin/macro-day/comparison.ts +58 -0
  197. package/src/plugins/builtin/macro-day/headless.ts +47 -3
  198. package/src/plugins/builtin/macro-day/index.tsx +32 -9
  199. package/src/plugins/builtin/macro-day/model.ts +1 -1
  200. package/src/plugins/builtin/macro-day/pane.tsx +99 -12
  201. package/src/plugins/builtin/market-heatmap/index.tsx +2 -2
  202. package/src/plugins/builtin/market-movers/footer.ts +29 -3
  203. package/src/plugins/builtin/market-movers/headless.ts +12 -5
  204. package/src/plugins/builtin/market-movers/index.tsx +3 -3
  205. package/src/plugins/builtin/market-movers/session-body.tsx +6 -3
  206. package/src/plugins/builtin/market-valuation/detail.tsx +3 -3
  207. package/src/plugins/builtin/market-valuation/headless.ts +6 -6
  208. package/src/plugins/builtin/market-valuation/pane.tsx +2 -3
  209. package/src/plugins/builtin/market-valuation/view.ts +6 -8
  210. package/src/plugins/builtin/members/client.ts +9 -2
  211. package/src/plugins/builtin/members/headless.ts +8 -10
  212. package/src/plugins/builtin/members/model.ts +29 -17
  213. package/src/plugins/builtin/members/pane.tsx +10 -12
  214. package/src/plugins/builtin/money-markets/headless.ts +1 -1
  215. package/src/plugins/builtin/news/headless.ts +4 -0
  216. package/src/plugins/builtin/news/index.tsx +3 -1
  217. package/src/plugins/builtin/news/wire/industry-pane.tsx +2 -1
  218. package/src/plugins/builtin/news/wire/news/preset-pane.tsx +1 -1
  219. package/src/plugins/builtin/news/wire/persisted-articles.ts +8 -4
  220. package/src/plugins/builtin/notes/headless.ts +7 -0
  221. package/src/plugins/builtin/notes/index.tsx +1 -1
  222. package/src/plugins/builtin/notes/quick-notes-pane.tsx +18 -2
  223. package/src/plugins/builtin/options/view.tsx +7 -6
  224. package/src/plugins/builtin/options-positioning/headless.ts +4 -4
  225. package/src/plugins/builtin/options-positioning/pane.tsx +7 -3
  226. package/src/plugins/builtin/options-scenario/client.ts +20 -4
  227. package/src/plugins/builtin/options-scenario/headless.ts +1 -1
  228. package/src/plugins/builtin/pe-band/client.ts +5 -9
  229. package/src/plugins/builtin/pe-band/headless.ts +11 -13
  230. package/src/plugins/builtin/pe-band/model.ts +39 -60
  231. package/src/plugins/builtin/pe-band/pane.tsx +14 -15
  232. package/src/plugins/builtin/perps/equity-row.tsx +3 -1
  233. package/src/plugins/builtin/perps/freshness.ts +16 -9
  234. package/src/plugins/builtin/perps/headless.ts +4 -1
  235. package/src/plugins/builtin/perps/markets-section.tsx +16 -10
  236. package/src/plugins/builtin/perps/model.ts +33 -2
  237. package/src/plugins/builtin/perps/pane.tsx +3 -2
  238. package/src/plugins/builtin/perps/status-line.ts +12 -3
  239. package/src/plugins/builtin/perps/venue-markets.ts +38 -0
  240. package/src/plugins/builtin/plugin-marketplace/pane.tsx +4 -3
  241. package/src/plugins/builtin/portfolio-list/cell-version.ts +1 -1
  242. package/src/plugins/builtin/portfolio-list/cli/render.ts +46 -7
  243. package/src/plugins/builtin/portfolio-list/headless.ts +31 -8
  244. package/src/plugins/builtin/portfolio-list/settings.ts +3 -0
  245. package/src/plugins/builtin/portfolio-list/table.tsx +7 -1
  246. package/src/plugins/builtin/power/headless.ts +1 -1
  247. package/src/plugins/builtin/realized-vol/headless.ts +1 -1
  248. package/src/plugins/builtin/research/corporate-actions-pane.tsx +27 -13
  249. package/src/plugins/builtin/scanner/feed.ts +7 -4
  250. package/src/plugins/builtin/scanner/flow-pane.tsx +8 -4
  251. package/src/plugins/builtin/scanner/headless.ts +57 -26
  252. package/src/plugins/builtin/scanner/hilo-pane.tsx +6 -3
  253. package/src/plugins/builtin/scanner/lock-note.ts +3 -2
  254. package/src/plugins/builtin/scanner/us-session.ts +9 -0
  255. package/src/plugins/builtin/seasonality/client.ts +46 -10
  256. package/src/plugins/builtin/seasonality/headless.ts +29 -11
  257. package/src/plugins/builtin/seasonality/model.ts +101 -24
  258. package/src/plugins/builtin/seasonality/pane.tsx +10 -6
  259. package/src/plugins/builtin/sec/filing-content.ts +13 -0
  260. package/src/plugins/builtin/sec/index.tsx +16 -11
  261. package/src/plugins/builtin/sectors/client.ts +27 -5
  262. package/src/plugins/builtin/sectors/headless.ts +2 -1
  263. package/src/plugins/builtin/sectors/index.tsx +22 -10
  264. package/src/plugins/builtin/shared/cloud-resource.ts +3 -3
  265. package/src/plugins/builtin/shared/extended-print.ts +38 -0
  266. package/src/plugins/builtin/shared/pro-feature-wall.tsx +1 -1
  267. package/src/plugins/builtin/shared/report-freshness.ts +7 -3
  268. package/src/plugins/builtin/shared/scanner-capture.ts +16 -3
  269. package/src/plugins/builtin/shared/ticker-company.ts +17 -8
  270. package/src/plugins/builtin/shared/use-quote-board.ts +11 -4
  271. package/src/plugins/builtin/social-mentions/client.ts +7 -3
  272. package/src/plugins/builtin/social-mentions/outliers.tsx +9 -2
  273. package/src/plugins/builtin/thirteenf/api.ts +24 -3
  274. package/src/plugins/builtin/thirteenf/data.ts +21 -8
  275. package/src/plugins/builtin/thirteenf/headless.ts +7 -3
  276. package/src/plugins/builtin/thirteenf/signals-pane.tsx +10 -3
  277. package/src/plugins/builtin/thirteenf/signals.ts +22 -1
  278. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +4 -2
  279. package/src/plugins/builtin/ticker-detail/financials/model.ts +7 -0
  280. package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +15 -6
  281. package/src/plugins/builtin/ticker-detail/financials/ratios.ts +5 -4
  282. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +14 -5
  283. package/src/plugins/builtin/ticker-detail/headless.ts +32 -26
  284. package/src/plugins/builtin/ticker-detail/index.tsx +1 -1
  285. package/src/plugins/builtin/ticker-detail/overview/components.tsx +8 -3
  286. package/src/plugins/builtin/ticker-detail/overview/model.ts +28 -5
  287. package/src/plugins/builtin/ticker-detail/overview/pane.tsx +14 -1
  288. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +9 -8
  289. package/src/plugins/builtin/ticker-detail/pane.tsx +16 -9
  290. package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +41 -23
  291. package/src/plugins/builtin/ticker-detail/quote-monitor/rows.ts +30 -13
  292. package/src/plugins/builtin/ticker-detail/settings.ts +9 -2
  293. package/src/plugins/builtin/time-sales/headless.ts +49 -13
  294. package/src/plugins/builtin/time-sales/model.ts +2 -2
  295. package/src/plugins/builtin/time-sales/window.ts +84 -10
  296. package/src/plugins/builtin/vol-surface/charts.tsx +4 -2
  297. package/src/plugins/builtin/vol-surface/events.ts +12 -5
  298. package/src/plugins/builtin/vol-surface/headless.ts +1 -1
  299. package/src/plugins/builtin/vol-surface/pane.tsx +15 -7
  300. package/src/plugins/builtin/world-indices/footer.ts +1 -1
  301. package/src/plugins/builtin/world-venue-map/chokepoint-report.ts +3 -1
  302. package/src/plugins/builtin/world-venue-map/headless.ts +27 -13
  303. package/src/plugins/builtin/yield-curve/client.ts +3 -1
  304. package/src/plugins/duplicates.ts +60 -0
  305. package/src/plugins/loader.ts +12 -3
  306. package/src/plugins/marketplace/model.ts +10 -1
  307. package/src/portfolio/column-values.ts +52 -5
  308. package/src/react/async-resource.ts +8 -7
  309. package/src/renderers/browser/bundled-plugins.ts +2 -1
  310. package/src/renderers/dom/build-assets.ts +20 -0
  311. package/src/renderers/dom/data-table/index.tsx +36 -2
  312. package/src/renderers/dom/es2023-array-methods.ts +57 -0
  313. package/src/renderers/dom/host/surface-fit.ts +64 -13
  314. package/src/renderers/dom/styles.css +6 -1
  315. package/src/renderers/electrobun/bun/external-plugins.ts +16 -6
  316. package/src/renderers/electrobun/shared/protocol.ts +2 -0
  317. package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +31 -7
  318. package/src/renderers/electrobun/view/cli-pane-shot-frame.tsx +15 -8
  319. package/src/renderers/electrobun/view/external-plugins.ts +1 -0
  320. package/src/renderers/electrobun/view/remote/asset-data-client.ts +1 -0
  321. package/src/series/types.ts +1 -0
  322. package/src/sources/gloomberb-cloud/fred-attribution.ts +6 -5
  323. package/src/sources/gloomberb-cloud/index.ts +42 -5
  324. package/src/sources/gloomberb-cloud/news.ts +15 -2
  325. package/src/sources/gloomberb-cloud/normalizers.ts +9 -0
  326. package/src/sources/history-result.ts +2 -1
  327. package/src/sources/history-retention.ts +14 -2
  328. package/src/sources/listing-symbols.ts +1 -1
  329. package/src/sources/provider-router/cache.ts +32 -3
  330. package/src/sources/provider-router/cached-routes.ts +25 -0
  331. package/src/sources/provider-router/connection-health.ts +1 -0
  332. package/src/sources/provider-router/history.ts +2 -2
  333. package/src/sources/provider-router/index.ts +14 -0
  334. package/src/sources/provider-router/sec-filings-page.ts +25 -0
  335. package/src/sources/sec-edgar/content.ts +67 -36
  336. package/src/tickers/listing-fate.ts +28 -0
  337. package/src/tickers/search/home-listing.ts +3 -0
  338. package/src/tickers/search/index-root-lead.ts +40 -0
  339. package/src/tickers/terminal-codes.ts +7 -4
  340. package/src/time-series/base-series.ts +17 -8
  341. package/src/time-series/fundamentals/historical-valuation.ts +2 -2
  342. package/src/time-series/fundamentals/series.ts +15 -12
  343. package/src/time-series/history-acquisition.ts +2 -0
  344. package/src/time-series/market.ts +3 -1
  345. package/src/time-series/price-comparison.ts +3 -1
  346. package/src/time-series/resolve-context.ts +8 -0
  347. package/src/time-series/resolve.ts +50 -10
  348. package/src/time-series/types.ts +1 -0
  349. package/src/time-series/use-chart-resolution.ts +2 -2
  350. package/src/time-series/valuation-currency.ts +40 -12
  351. package/src/types/data-provider.ts +30 -1
  352. package/src/types/financials.ts +23 -0
  353. package/src/types/headless.ts +23 -0
  354. package/src/types/instrument.ts +1 -0
  355. package/src/utils/crypto-pair.ts +16 -0
  356. package/src/utils/exchange-announcements.ts +2 -1
  357. package/src/utils/exchange-notation.generated.ts +58 -1
  358. package/src/utils/exchanges.ts +43 -1
  359. package/src/utils/format.ts +37 -2
  360. package/src/utils/function-search.ts +38 -0
  361. package/src/utils/fuzzy-search.ts +10 -6
  362. package/src/utils/option-choice.ts +15 -0
  363. package/src/utils/price-history.ts +15 -1
  364. package/src/utils/reason-codes.ts +6 -3
  365. package/src/utils/trailing-dividend.ts +241 -28
@@ -4,7 +4,7 @@ import { fiscalYearEndMonth } from "../../utils/fiscal-period";
4
4
  import { canonicalTimeSeriesFieldId, getTimeSeriesField } from "../field-catalog";
5
5
  import { dailyForwardPeHistory, forwardPeHistory, realizedNtmPeHistory } from "../forward-valuation";
6
6
  import { reportingCurrencySeries } from "../reporting-currency";
7
- import { createValuationCurrencyContext } from "../valuation-currency";
7
+ import { createValuationCurrencyContext, type ValuationCurrencyContext } from "../valuation-currency";
8
8
  import { valuationPriceAtOrBefore, valuationQuoteIssue, type ValuationPriceIssue } from "../valuation-price";
9
9
  import type { SecuritySeriesSource, TimeSeriesPoint } from "../types";
10
10
  import { isBankOrInsurerIndustry } from "../../utils/ebitda";
@@ -24,6 +24,7 @@ const SHARE_PRICE_EARNINGS = new Set(["trailingPE", "forwardPE", "realizedNtmPE"
24
24
  export function extractFundamentalSeries(
25
25
  financials: TickerFinancials | null,
26
26
  source: SecuritySeriesSource,
27
+ currencyContext?: ValuationCurrencyContext,
27
28
  ): TimeSeriesPoint[] {
28
29
  if (!financials) return [];
29
30
  const canonicalId = canonicalTimeSeriesFieldId(source.fieldId);
@@ -57,24 +58,25 @@ export function extractFundamentalSeries(
57
58
  if (SHARE_PRICE_EARNINGS.has(metric) && notTheShare(financials)) return [];
58
59
  // A bank's or an insurer's EBITDA measures nothing: its EV/EBITDA is N/M throughout (valuationNotMeaningful).
59
60
  if (metric === "evEbitda" && isBankOrInsurerIndustry(financials.profile?.industry)) return [];
61
+ const currencies = currencyContext ?? createValuationCurrencyContext(financials);
60
62
  const fallback = dailyValuationFallbackPeriod(financials, source);
61
- if (fallback) return extractFundamentalSeries(financials, { ...source, period: fallback });
63
+ if (fallback) return extractFundamentalSeries(financials, { ...source, period: fallback }, currencies);
62
64
  if (source.period === "daily" && metric !== "realizedNtmPE") {
63
- if (metric !== "forwardPE") return dailyStatementValuation(financials, metric, source.instrument.exchange);
64
- const points = dailyForwardPeHistory(financials, createValuationCurrencyContext(financials), source.instrument.exchange);
65
+ if (metric !== "forwardPE") return dailyStatementValuation(financials, metric, source.instrument.exchange, currencies);
66
+ const points = dailyForwardPeHistory(financials, currencies, source.instrument.exchange);
65
67
  if (points.some((point) => point.value !== null)) return points;
66
68
  const current = providerCurrentValuationPoint(financials, metric);
67
69
  return current ? [current] : [];
68
70
  }
69
71
  if (metric === "forwardPE") {
70
- const points = forwardPeHistory(financials, createValuationCurrencyContext(financials));
72
+ const points = forwardPeHistory(financials, currencies);
71
73
  if (points.length > 0) return points;
72
74
  // Without an estimate history the provider's own figure is all there is.
73
75
  const current = providerCurrentValuationPoint(financials, metric);
74
76
  return current ? [current] : [];
75
77
  }
76
78
  if (metric === "realizedNtmPE") {
77
- return realizedNtmPeHistory(financials, createValuationCurrencyContext(financials));
79
+ return realizedNtmPeHistory(financials, currencies);
78
80
  }
79
81
  if (metric === "pegRatio") {
80
82
  const current = providerCurrentValuationPoint(financials, metric);
@@ -82,7 +84,6 @@ export function extractFundamentalSeries(
82
84
  }
83
85
 
84
86
  const selected = sourceStatements(financials, source.period, metric);
85
- const currencies = createValuationCurrencyContext(financials);
86
87
  const yearEndMonth = fiscalYearEndMonth(financials.annualStatements);
87
88
  let hasHistoricalObservation = false;
88
89
  const historical = selected.statements.flatMap((statement) => {
@@ -138,23 +139,25 @@ export function fundamentalSeriesUsesAvailabilityFallback(
138
139
  }
139
140
 
140
141
  /** Explains withheld currency-dependent values through chart and export metadata. */
141
- export function valuationCurrencyWarning(financials: TickerFinancials, source: SecuritySeriesSource): string | undefined {
142
+ export function valuationCurrencyWarning(financials: TickerFinancials, source: SecuritySeriesSource,
143
+ currencies?: ValuationCurrencyContext): string | undefined {
142
144
  const [namespace, metric = ""] = canonicalTimeSeriesFieldId(source.fieldId).split(".");
143
145
  if (namespace !== "valuation" || !QUOTE_DERIVED_VALUATION_IDS.has(metric)) return undefined;
144
146
  const selected = sourceStatements(financials, source.period, metric);
145
- return createValuationCurrencyContext(financials).warning(selected.statements.filter((row) => (
147
+ return (currencies ?? createValuationCurrencyContext(financials)).warning(selected.statements.filter((row) => (
146
148
  valuationAtPrice(row, metric, 1) !== null
147
149
  )));
148
150
  }
149
151
 
150
152
  /** Structured failures preserve source values independently of the chart's ratios. */
151
- export function valuationPriceIssues(financials: TickerFinancials, source: SecuritySeriesSource): ValuationPriceIssue[] {
153
+ export function valuationPriceIssues(financials: TickerFinancials, source: SecuritySeriesSource,
154
+ currencyContext?: ValuationCurrencyContext): ValuationPriceIssue[] {
152
155
  if (source.period === "daily" && canonicalTimeSeriesFieldId(source.fieldId).startsWith("valuation.")) {
153
- return extractFundamentalSeries(financials, source).flatMap((point) => point.provenance?.valuationPriceIssues ?? []);
156
+ return extractFundamentalSeries(financials, source, currencyContext).flatMap((point) => point.provenance?.valuationPriceIssues ?? []);
154
157
  }
155
158
  if (!valuationSeriesUsesLiveQuote(source.fieldId)) return [];
159
+ const currencies = currencyContext ?? createValuationCurrencyContext(financials);
156
160
  const metric = canonicalTimeSeriesFieldId(source.fieldId).split(".")[1]!;
157
- const currencies = createValuationCurrencyContext(financials);
158
161
  const selected = sourceStatements(financials, source.period, metric);
159
162
  const rows = selected.statements.filter((row) => (
160
163
  currencies.priceInStatementUnits(row, 1) !== null && valuationAtPrice(row, metric, 1) !== null
@@ -47,6 +47,7 @@ export interface PriceHistoryRequest {
47
47
  support: readonly ChartResolutionSupport[];
48
48
  requiredWarmupPoints: number;
49
49
  historyRequestKey?: string;
50
+ refresh?: boolean;
50
51
  /** Ask for pre-market and after-hours bars. */
51
52
  historySession?: "extended";
52
53
  }
@@ -379,6 +380,7 @@ export async function loadPriceHistory(
379
380
  request: PriceHistoryRequest,
380
381
  ): Promise<LoadedPriceHistory> {
381
382
  const context = { ...requestContext(source), historyRequestKey: request.historyRequestKey,
383
+ ...(request.refresh ? { cacheMode: "refresh" as const } : {}),
382
384
  ...(request.historySession ? { historySession: request.historySession } : {}) };
383
385
  let coverageNotice: string | null = null;
384
386
  let retentionError: HistoryRetentionError | null = null;
@@ -5,6 +5,7 @@ import {
5
5
  } from "../utils/price-history-integrity";
6
6
  import { canonicalTimeSeriesFieldId, isFundamentalFieldId, isMarketFieldId } from "./field-catalog";
7
7
  import { extractFundamentalSeries } from "./fundamentals";
8
+ import type { ValuationCurrencyContext } from "./valuation-currency";
8
9
  import type { ChartSeriesPriceHistoryIntegrity, ResolvedSeries, SecuritySeriesSource, SeriesPeriod, TimeSeriesPoint } from "./types";
9
10
  import type { ManualChartResolution } from "./resolution";
10
11
  import { isFiniteNumber } from "../utils/guards";
@@ -184,9 +185,10 @@ export function chartPriceHistoryIntegrityNotices(entries: readonly ChartSeriesP
184
185
  export function extractSecuritySeries(
185
186
  financials: TickerFinancials | null,
186
187
  source: SecuritySeriesSource,
188
+ currencies?: ValuationCurrencyContext,
187
189
  ): TimeSeriesPoint[] {
188
190
  if (!financials) return [];
189
191
  if (isMarketFieldId(source.fieldId)) return extractPriceSeries(financials.priceHistory, source);
190
- if (isFundamentalFieldId(source.fieldId)) return extractFundamentalSeries(financials, source);
192
+ if (isFundamentalFieldId(source.fieldId)) return extractFundamentalSeries(financials, source, currencies);
191
193
  return [];
192
194
  }
@@ -351,7 +351,9 @@ export function resolvePriceComparison(
351
351
  return source?.kind === "security" ? source.instrument.symbol : id;
352
352
  };
353
353
  // A leg not loaded yet (a seed from cached history) has not failed: nothing compares until it is.
354
- const basis = comparisonBasis(spec, seriesIds.map((id) => ({ label: symbolOf(id), entry: byId.get(id) })));
354
+ const basisLegs = seriesIds.map((id) => ({ label: symbolOf(id), entry: byId.get(id) }));
355
+ const basis = [comparisonBasis(spec, basisLegs), ...basisLegs.flatMap(({ label, entry }) =>
356
+ entry?.returnRollNote ? [`${label}: ${entry.returnRollNote}.`] : [])].join(" ");
355
357
  const unavailable = `${basis} Comparison unavailable: need two shared dates and a nonzero baseline.`;
356
358
  if (seriesIds.some((id) => !byId.has(id))) return { seriesIds, start: null, end: null, notice: unavailable };
357
359
  const dropped: NonNullable<PriceComparison["dropped"]> = [];
@@ -23,6 +23,13 @@ export interface ChartResolveSources {
23
23
  now?: Date;
24
24
  /** Latest streamed quote per security identity, layered over snapshot data. */
25
25
  quoteOverrides?: ReadonlyMap<string, Quote>;
26
+ /**
27
+ * Settles, never rejecting, once `quoteOverrides` holds what it will: a
28
+ * report reads one quote per current listing beside the histories, and a
29
+ * listing named with its venue (AAPL:NASDAQ) starts its history without
30
+ * waiting for it. The overrides are read only once it settles.
31
+ */
32
+ quoteOverridesReady?: Promise<unknown>;
26
33
  /**
27
34
  * Start of the current uninterrupted quote observation. Bars formed from
28
35
  * quotes inside it are continuous with the loaded history.
@@ -63,6 +70,7 @@ export interface ChartResolveSources {
63
70
  }
64
71
 
65
72
  export interface ChartResolveOptions {
73
+ refreshHistory?: boolean;
66
74
  /** Runtime zoom window used only to choose an adaptive Auto resolution. */
67
75
  autoViewport?: { start: Date; end: Date } | null;
68
76
  /** Runtime interaction window used to load history around the visible chart. */
@@ -1,6 +1,7 @@
1
1
  import { logFailure } from "../utils/log-failure";
2
- import { servedFromSavedCopy } from "../data/saved-copies";
2
+ import { savedCopyAt, servedFromSavedCopy } from "../data/saved-copies";
3
3
  import { hasValidQuoteObservationTime } from "../market-data/quotes/freshness";
4
+ import { rollAdjustedHistory } from "../market-data/futures-roll-returns";
4
5
  import { delistingLabel } from "../market-data/quotes/delisting";
5
6
  import { financialPeriodCoverage, financialPeriodCoverageWarnings, limitSeriesObservations } from "./financial-period-coverage";
6
7
  import { historyCoverageNotice } from "../sources/history-coverage";
@@ -45,7 +46,7 @@ import {
45
46
  } from "./fundamentals";
46
47
  import { FORWARD_PE_BASIS_NOTICE, REALIZED_NTM_PE_BASIS_NOTICE } from "./forward-valuation";
47
48
  import { valuationPriceWarning } from "./valuation-price";
48
- import { VALUATION_CURRENCY_WARNING_PREFIX } from "./valuation-currency";
49
+ import { createValuationCurrencyContext, valuationFxHistories, VALUATION_CURRENCY_WARNING_PREFIX } from "./valuation-currency";
49
50
  import { chartPriceHistoryIntegrityNotices } from "./market";
50
51
  import { maxStudyWarmupPoints, resolveStudies } from "./studies/resolve";
51
52
  import { isFormulaNextMonth, withFormulaNextMonths, withoutFormulaNextMonths } from "./formula-months";
@@ -549,10 +550,12 @@ async function resolveChartSpecPass(
549
550
  }
550
551
  return Promise.resolve(DEFAULT_CHART_RESOLUTION_SUPPORT);
551
552
  };
552
- const sourceWithResolvedExchange = (
553
+ const sourceWithResolvedExchange = async (
553
554
  source: Extract<ChartSeriesSpec["source"], { kind: "security" }>,
554
555
  financials: TickerFinancials | null,
555
556
  ) => {
557
+ // A report's quotes arrive beside the histories: the venue one names waits for them.
558
+ await sources.quoteOverridesReady;
556
559
  const quoteOverride = sources.quoteOverrides?.get(chartQuoteOverrideKeyForSource(source));
557
560
  return withQuoteExchange(
558
561
  source,
@@ -659,6 +662,7 @@ async function resolveChartSpecPass(
659
662
  allowProviderDefaultFallback: !dailyValuation && spec.viewport.resolution === "auto",
660
663
  support,
661
664
  requiredWarmupPoints: maxStudyWarmupPoints(spec.studies),
665
+ refresh: options.refreshHistory,
662
666
  ...(extendedHoursFor(source, initialResolution) ? { historySession: "extended" as const } : {}),
663
667
  };
664
668
  const key = [
@@ -878,6 +882,8 @@ async function resolveChartSpecPass(
878
882
  if (!calculationSeriesIds.has(seriesSpec.id)) return null;
879
883
  const { warnings, errors, priorityWarnings, coverageNotices } = quietSeriesIds.has(seriesSpec.id)
880
884
  ? { warnings: [] as string[], errors: [] as string[], priorityWarnings: [] as string[], coverageNotices: [] as string[] } : messages;
885
+ // The listing's own facts (its quote), read beside its history: a series whose history fails keeps the unit they give.
886
+ let listingFacts: Promise<TickerFinancials | null> | null = null;
881
887
  try {
882
888
  if (seriesSpec.source.kind === "capability") {
883
889
  if (!sources.resolveCapabilitySeries) {
@@ -942,6 +948,7 @@ async function resolveChartSpecPass(
942
948
  const needsFinancials = !isPriceOnlyMarketFieldId(source.fieldId)
943
949
  || !source.instrument.exchange?.trim();
944
950
  const financialsPromise = needsFinancials ? loadFinancials(source) : Promise.resolve(null);
951
+ listingFacts = financialsPromise;
945
952
  // A continuous future (HO=F) is known by its symbol: its terms load beside its
946
953
  // history and are read below. A failed read already answers null.
947
954
  loadPriceUnit(source, undefined).catch(logFailure("time-series-resolve", "Starting a futures price unit read failed"));
@@ -950,14 +957,14 @@ async function resolveChartSpecPass(
950
957
  let history: LoadedPriceHistory | null;
951
958
  if (needsHistory && !source.instrument.exchange?.trim()) {
952
959
  financials = await financialsPromise;
953
- resolvedSource = sourceWithResolvedExchange(source, financials);
960
+ resolvedSource = await sourceWithResolvedExchange(source, financials);
954
961
  history = await loadHistory(resolvedSource, historyPricedValuation);
955
962
  } else {
956
963
  [financials, history] = await Promise.all([
957
964
  financialsPromise,
958
965
  needsHistory ? loadHistory(source, historyPricedValuation) : Promise.resolve(null),
959
966
  ]);
960
- resolvedSource = sourceWithResolvedExchange(source, financials);
967
+ resolvedSource = await sourceWithResolvedExchange(source, financials);
961
968
  }
962
969
  if (history?.extendedHours) extendedHistories.add(seriesSpec.id);
963
970
  else if (history && marketField && seriesSpec.visible !== false && extendedHoursFor(resolvedSource, initialResolution)) {
@@ -973,6 +980,7 @@ async function resolveChartSpecPass(
973
980
  // that prices today's consensus itself follows the live quote.
974
981
  const followsLiveQuote = marketField
975
982
  || (quoteDerivedValuation && (!forwardPE || !!financials?.epsEstimates));
983
+ if (followsLiveQuote) await sources.quoteOverridesReady;
976
984
  const quoteOverride = followsLiveQuote
977
985
  ? sources.quoteOverrides?.get(chartQuoteOverrideKeyForSource(source))
978
986
  : undefined;
@@ -1040,16 +1048,35 @@ async function resolveChartSpecPass(
1040
1048
  // mark is not a daily closing observation, including on snapshot replay.
1041
1049
  const historical = history ? { ...merged, priceHistory: history.points } : merged;
1042
1050
  sources.onSecurityData?.(resolvedSpec, dailyValuation || history?.session || realizedVolInputs.has(seriesSpec.id) ? historical : sourceBars, history !== null);
1051
+ const forwardEps = (forwardPE || source.fieldId === "valuation.realizedNtmPE") ? merged.epsEstimates : undefined;
1052
+ const estimateCurrency = forwardEps?.currency ?? merged.financialCurrency;
1053
+ const valuationDates = !historyPricedValuation || !sources.loadFxCloses ? [] : forwardEps ? [
1054
+ ...forwardEps.reported.map((row) => ({ date: row.date, currency: estimateCurrency })),
1055
+ ...forwardEps.snapshots.map((row) => ({ date: row.observedOn, currency: estimateCurrency })),
1056
+ { date: dateOnly(referenceNow), currency: estimateCurrency },
1057
+ ] : [...merged.annualStatements, ...merged.quarterlyStatements];
1058
+ const valuationBasis = valuationDates.filter((row) => /^\d{4}-\d{2}-\d{2}/.test(row.date));
1059
+ const fxCodes = valuationBasis.length ? createValuationCurrencyContext(merged).fxCurrencies(valuationBasis) : [];
1060
+ const currencies = sources.loadFxCloses && fxCodes.length ? createValuationCurrencyContext(merged, await valuationFxHistories(
1061
+ fxCodes, valuationBasis.map((row) => row.date.slice(0, 10)).sort()[0]!, sources.loadFxCloses,
1062
+ )) : undefined;
1063
+ if (currencies) {
1064
+ const note = currencies.conversionNote(valuationBasis, (row) => row.date.slice(0, 10));
1065
+ if (note) warnings.push(`${instrumentLabel(resolvedSource)}: ${forwardEps ? note.replace("Period-end FX", "Dated FX") : note}`);
1066
+ }
1067
+ const returnHistory = comparedSeriesIds.has(seriesSpec.id) && history?.resolution === "1d"
1068
+ ? rollAdjustedHistory(merged.priceHistory, resolvedSource.instrument.symbol) : null;
1043
1069
  const base = baseSecuritySeries(
1044
1070
  resolvedSpec,
1045
- dailyValuation ? historical : merged,
1071
+ dailyValuation ? historical : returnHistory?.note ? { ...merged, priceHistory: returnHistory.points } : merged,
1046
1072
  index,
1047
1073
  history?.resolution,
1048
1074
  quoteMetadata,
1049
1075
  contractUnit,
1050
- { extendedHours: history?.extendedHours === true },
1076
+ { extendedHours: history?.extendedHours === true, currencies },
1051
1077
  );
1052
1078
  if (!base) throw new Error(`Unknown field ${source.fieldId}.`);
1079
+ if (returnHistory?.note) base.returnRollNote = returnHistory.note;
1053
1080
  let result = builtBars ? withBuiltBarSize(base, builtBars) : base;
1054
1081
  if (spec.viewport.totalReturn === true && totalReturnFieldId(source.fieldId)) {
1055
1082
  const outcome = await totalReturnSeries(result, () => loadDistributions(resolvedSource),
@@ -1094,12 +1121,20 @@ async function resolveChartSpecPass(
1094
1121
  if (!dailyValuation && isFundamentalFieldId(source.fieldId) && fundamentalSeriesUsesAvailabilityFallback(merged, source)) {
1095
1122
  result.warning = [result.warning, "Publication dates are unavailable for some observations; period-end dates are used as a fallback."].filter(Boolean).join(" ");
1096
1123
  }
1097
- return result;
1124
+ const savedAt = savedCopyAt(history);
1125
+ return savedAt == null ? result : asSavedCopy({ ...result, savedAt });
1098
1126
  } catch (error) {
1099
1127
  const message = error instanceof Error ? error.message : String(error);
1100
1128
  errors.push(`${seriesMessageName(seriesSpec)}: ${message}`);
1101
1129
  if (error instanceof NoPriceHistoryError) onNoPriceHistory?.();
1102
- return unloadableSeries(seriesSpec, index, message);
1130
+ const facts = await listingFacts?.catch(() => {
1131
+ // Intentional ignore: the series already failed; without its quote it keeps the unit its symbol gives.
1132
+ return null;
1133
+ });
1134
+ // A future's unit is its terms' (USD / troy oz), which load beside its history and never reject.
1135
+ const contractUnit = seriesSpec.source.kind === "security"
1136
+ ? await loadPriceUnit(seriesSpec.source, facts?.quote?.instrumentType || facts?.quoteMetadata?.instrumentType) : null;
1137
+ return unloadableSeries(seriesSpec, index, message, facts ?? undefined, contractUnit);
1103
1138
  }
1104
1139
  }));
1105
1140
 
@@ -1136,7 +1171,12 @@ async function resolveChartSpecPass(
1136
1171
  // asynchronously can be timestamped just after that reference, so advance an
1137
1172
  // untouched market viewport by the same amount instead of clipping its tail.
1138
1173
  // Explicit and user-created windows stay fixed through hasExplicitWindow.
1139
- const primaryRaw = primaryMarketSeries ? rawSeries.find((entry) => entry.id === primaryMarketSeries.id) : undefined;
1174
+ const firstRaw = primaryMarketSeries ? rawSeries.find((entry) => entry.id === primaryMarketSeries.id) : undefined;
1175
+ // The day is the first market listing's; when its history failed, the next one with bars, so the others are not
1176
+ // drawn on a rolling day that ends on a weekend.
1177
+ const primaryRaw = firstRaw && firstRaw.points.length === 0
1178
+ ? rawSeries.find((entry) => entry.observationKind === "market" && entry.listing && entry.points.length > 0) ?? firstRaw
1179
+ : firstRaw;
1140
1180
  // A panned day keeps its reference line; an authored date window has no latest session.
1141
1181
  const sessionView = spec.viewport.range === "1D" && !explicitBounds(spec)
1142
1182
  ? latestSessionView(primaryRaw, rawSeries.filter((entry) => entry.observationKind === "market"),
@@ -229,6 +229,7 @@ export interface ResolvedSeries {
229
229
  * source gave none to reinvest (`warning` says why).
230
230
  */
231
231
  returnBasis?: "total" | "price";
232
+ returnRollNote?: string;
232
233
  /** The listing currency a price series was converted from into the chart's `viewport.currency`. */
233
234
  convertedFrom?: string;
234
235
  unitGroup: string;
@@ -351,7 +351,7 @@ export function useChartResolution(
351
351
  // instead of keeping the failure.
352
352
  const live = !snapshot;
353
353
  const failedRef = useRef(false);
354
- failedRef.current = live && displayed.errors.length > 0 && !displayed.loading;
354
+ failedRef.current = live && (displayed.errors.length > 0 || displayed.savedAt != null) && !displayed.loading;
355
355
  useEffect(() => {
356
356
  if (!live) return;
357
357
  return connectionHealth.subscribeRecovery((sourceId) => {
@@ -570,7 +570,7 @@ export function useChartResolution(
570
570
  spec,
571
571
  withQuoteOverrides(sources, liveQuoteOverridesRef.current, liveSinceRef.current),
572
572
  cache,
573
- resolveOptions,
573
+ { ...resolveOptions, refreshHistory: isExplicitReload || stateSavedAt != null },
574
574
  );
575
575
  const frame = stateSavedAt != null ? afterSavedCopyFrame() : undefined;
576
576
  (frame ? frame.then(() => generationRef.current === generation ? resolve() : EMPTY_RESULT) : resolve())
@@ -1,5 +1,7 @@
1
+ import { crossFxCloseOnOrBefore, dailyFxLeg, loadDailyFxCloses, type FxCloses, type FxHistoryClient } from "../market-data/fx-closes";
1
2
  import type { FinancialStatement, TickerFinancials } from "../types/financials";
2
3
  import { resolveCurrencyUnit, type CurrencyUnitInfo } from "../utils/currency-units";
4
+ import { logFailure } from "../utils/log-failure";
3
5
 
4
6
  function knownUnit(currency?: string): CurrencyUnitInfo | null {
5
7
  const unit = resolveCurrencyUnit(currency);
@@ -13,7 +15,7 @@ function sameUnit(left: CurrencyUnitInfo, right: CurrencyUnitInfo): boolean {
13
15
  export const VALUATION_CURRENCY_WARNING_PREFIX = "Valuation currency mismatch or unknown basis:";
14
16
 
15
17
  /** Price and statement amounts must share a verified monetary basis before division. */
16
- export function createValuationCurrencyContext(financials: TickerFinancials) {
18
+ export function createValuationCurrencyContext(financials: TickerFinancials, fx?: ReadonlyMap<string, FxCloses>) {
17
19
  const quoteUnit = knownUnit(financials.quote?.currency);
18
20
  const declared = knownUnit(financials.financialCurrency);
19
21
  const explicit = [...financials.annualStatements, ...financials.quarterlyStatements]
@@ -24,25 +26,51 @@ export function createValuationCurrencyContext(financials: TickerFinancials) {
24
26
  ? declared : null;
25
27
  const statementUnit = (row: FinancialStatement) => row.currency?.trim()
26
28
  ? knownUnit(row.currency) : fallback;
29
+ const rateFor = (row: FinancialStatement, date: string) => {
30
+ const unit = statementUnit(row);
31
+ if (!quoteUnit || !unit) return null;
32
+ if (unit.currency === quoteUnit.currency) return unit.divisor / quoteUnit.divisor;
33
+ const close = fx && crossFxCloseOnOrBefore(fx, quoteUnit.currency, unit.currency, date);
34
+ return close ? close.rate * unit.divisor / quoteUnit.divisor : null;
35
+ };
27
36
 
28
37
  return {
29
- priceInStatementUnits(row: FinancialStatement, price: number): number | null {
30
- const unit = statementUnit(row);
31
- if (!quoteUnit || !unit || unit.currency !== quoteUnit.currency) return null;
32
- // GBp/GBX prices can be compared with GBP statements without an FX rate.
33
- // Already normalized GBP prices retain divisor 1 and are not scaled twice.
34
- return price / quoteUnit.divisor * unit.divisor;
38
+ priceInStatementUnits(row: FinancialStatement, price: number, date = row.date.slice(0, 10)): number | null {
39
+ const rate = rateFor(row, date);
40
+ return rate == null ? null : price * rate;
35
41
  },
36
- warning(rows: readonly FinancialStatement[]): string | undefined {
37
- const incompatible = rows.filter((row) => {
38
- const unit = statementUnit(row);
39
- return !quoteUnit || !unit || unit.currency !== quoteUnit.currency;
40
- });
42
+ warning(rows: readonly FinancialStatement[], dateOf = (row: FinancialStatement) => row.date.slice(0, 10)): string | undefined {
43
+ const incompatible = rows.filter((row) => rateFor(row, dateOf(row)) == null);
41
44
  if (!incompatible.length) return undefined;
42
45
  const currencies = [...new Set(incompatible.map((row) => statementUnit(row)?.currency ?? "unknown"))];
43
46
  return `${VALUATION_CURRENCY_WARNING_PREFIX} ${currencies.join("/")} reporting, ${quoteUnit?.currency ?? "unknown"} price. Affected ratios are unavailable.`;
44
47
  },
48
+ conversionNote(rows: readonly FinancialStatement[], dateOf: (row: FinancialStatement) => string): string | undefined {
49
+ const currencies = new Set(rows.flatMap((row) => {
50
+ const unit = statementUnit(row);
51
+ return unit && unit.currency !== quoteUnit?.currency && rateFor(row, dateOf(row)) != null ? [unit.currency] : [];
52
+ }));
53
+ return currencies.size ? `Period-end FX: ${quoteUnit!.currency} prices converted to ${[...currencies].join("/")}.` : undefined;
54
+ },
55
+ fxCurrencies(rows: readonly FinancialStatement[]): string[] {
56
+ if (!quoteUnit) return [];
57
+ const mismatches = rows.flatMap((row) => {
58
+ const unit = statementUnit(row);
59
+ return unit && unit.currency !== quoteUnit.currency ? [unit.currency, quoteUnit.currency] : [];
60
+ });
61
+ return [...new Set(mismatches)].filter((code) => code !== "USD" && dailyFxLeg(code));
62
+ },
45
63
  };
46
64
  }
47
65
 
48
66
  export type ValuationCurrencyContext = ReturnType<typeof createValuationCurrencyContext>;
67
+
68
+ export async function valuationFxHistories(currencies: readonly string[], since: string, load: (code: string, since: string) => Promise<FxCloses>): Promise<ReadonlyMap<string, FxCloses>> {
69
+ const histories = await Promise.all(currencies.map((code) => load(code, since)
70
+ .catch(logFailure("valuation-currency", `Daily ${code} FX closes unavailable`, null))));
71
+ return new Map(histories.flatMap((history) => history ? [[history.currency, history] as const] : []));
72
+ }
73
+
74
+ export function loadValuationFx(currencies: readonly string[], since: string, client: FxHistoryClient): Promise<ReadonlyMap<string, FxCloses>> {
75
+ return valuationFxHistories(currencies, since, (code, date) => loadDailyFxCloses(code, date, client));
76
+ }
@@ -22,7 +22,7 @@ import type { IssuerListings } from "./issuer-listings";
22
22
  import type { StreamTickRange } from "../market-data/quotes/tick-range";
23
23
 
24
24
  export type CachedAssetMethod = "getExchangeRate" | "getHolders" | "getAnalystResearch" | "getCorporateActions"
25
- | "getOptionsChain" | "getSecFilings" | "getSecFilingDocuments" | "getSecFilingContent" | "getArticleSummary";
25
+ | "getOptionsChain" | "getSecFilings" | "getSecFilingsPage" | "getSecFilingDocuments" | "getSecFilingContent" | "getArticleSummary";
26
26
  export type CachedAssetArgs<K extends CachedAssetMethod> = Parameters<NonNullable<AssetDataProvider[K]>>;
27
27
  export type CachedAssetValue<K extends CachedAssetMethod> = Awaited<ReturnType<NonNullable<AssetDataProvider[K]>>>;
28
28
 
@@ -83,6 +83,29 @@ export interface SecFilingItem {
83
83
  form4?: SecForm4Trade;
84
84
  }
85
85
 
86
+ /** Which of a listing's filings `getSecFilingsPage` reads. */
87
+ export interface SecFilingsPageQuery {
88
+ /** The forms, each with its amendment: `["4"]` is every Form 4 and 4/A. */
89
+ forms: readonly string[];
90
+ limit: number;
91
+ offset?: number;
92
+ }
93
+
94
+ export interface SecFilingsPage {
95
+ filings: SecFilingItem[];
96
+ /** The source holds more of these forms past this page, from `nextOffset`. */
97
+ hasMore: boolean;
98
+ nextOffset: number;
99
+ /**
100
+ * The newest filing day (YYYY-MM-DD) of each form the company's whole list
101
+ * holds, by the form as filed (`10-K/A` apart from `10-K`), whatever forms
102
+ * the page asks for: what the company reports as, and empty when the SEC
103
+ * lists no filing for it. Absent when the source does not say (an older
104
+ * server).
105
+ */
106
+ newestByForm?: Record<string, string>;
107
+ }
108
+
86
109
  /** A Form 4's main transaction, the one moving the most shares. */
87
110
  export interface SecForm4Trade {
88
111
  /** The first reporting owner, as filed. */
@@ -353,6 +376,12 @@ export interface AssetDataProvider {
353
376
  getExchangeRateSnapshot?(fromCurrency: string): Promise<ExchangeRateSnapshot>;
354
377
  search(query: string, context?: SearchRequestContext): Promise<InstrumentSearchResult[]>;
355
378
  getSecFilings?(ticker: string, count?: number, exchange?: string, context?: MarketDataRequestContext): Promise<SecFilingItem[]>;
379
+ /**
380
+ * One page of a listing's filings of some forms, newest first, picked by the
381
+ * source: a reader of one form (INS's Form 4s) never takes the company's
382
+ * whole list to filter it.
383
+ */
384
+ getSecFilingsPage?(ticker: string, query: SecFilingsPageQuery, exchange?: string, context?: MarketDataRequestContext): Promise<SecFilingsPage>;
356
385
  getHolders?(ticker: string, exchange?: string, context?: MarketDataRequestContext): Promise<HolderData>;
357
386
  getAnalystResearch?(ticker: string, exchange?: string, context?: MarketDataRequestContext): Promise<AnalystResearchData>;
358
387
  getCorporateActions?(ticker: string, exchange?: string, context?: MarketDataRequestContext): Promise<CorporateActionsData>;
@@ -147,6 +147,7 @@ export interface Quote extends DepositaryReceiptFacts {
147
147
  priceBasis?: PriceBasis;
148
148
  /** Daily fund net asset value; independent of the units used to format its price. */
149
149
  priceObservation?: "nav";
150
+ futuresPriceKind?: "settlement" | "last-trade";
150
151
  symbol: string;
151
152
  /** Provider-reported security type, independent of the company profile. */
152
153
  instrumentType?: string;
@@ -298,6 +299,14 @@ export interface Quote extends DepositaryReceiptFacts {
298
299
  ask?: number;
299
300
  bidSize?: number;
300
301
  askSize?: number;
302
+ /**
303
+ * When the bid and ask were quoted, in milliseconds, as the source stamps
304
+ * the book; absent when it sends a book without a time. A book can be hours
305
+ * from the trade beside it (an after-hours quote left at 19:55 New York
306
+ * against the 16:00 close), so it is never dated by lastUpdated or
307
+ * lastTradeTime (formatQuoteBookTime).
308
+ */
309
+ bidAskTime?: number;
301
310
  open?: number;
302
311
  high?: number;
303
312
  low?: number;
@@ -499,6 +508,13 @@ export interface Fundamentals extends DepositaryReceiptFacts {
499
508
  * can be repriced from a live quote; absent otherwise.
500
509
  */
501
510
  dividendRate?: number;
511
+ /**
512
+ * `uneven-regular-payments`: `dividendRate` (a forward one) is the trailing
513
+ * year's regular payments summed, as DVD's forward rate reads a year whose
514
+ * payments differ too widely for one to stand for it (HSBC's three interims
515
+ * beside its final). Absent where the latest distribution is annualized.
516
+ */
517
+ dividendRateBasis?: "uneven-regular-payments";
502
518
  revenue?: number;
503
519
  netIncome?: number;
504
520
  eps?: number;
@@ -683,6 +699,13 @@ export interface DividendAction {
683
699
  * VanEck), and the page it is published on. Absent elsewhere and from older servers.
684
700
  */
685
701
  source?: { publisher: string; url: string };
702
+ /**
703
+ * The dividends the row holds by the issuer's own dividend announcement
704
+ * forms (an HKEX listing's): each in the row's currency, summing to its
705
+ * amount, a special marked, with the form's type and where it is published.
706
+ * Absent where no form speaks for the row, and from older servers.
707
+ */
708
+ parts?: { amount: number; special: boolean; type: string; form: { url: string; publishedOn: string } }[];
686
709
  }
687
710
 
688
711
  /**
@@ -42,6 +42,7 @@ export interface HeadlessPaneReference {
42
42
 
43
43
  export interface HeadlessPaneOptionValue {
44
44
  value: string;
45
+ label?: string;
45
46
  aliases?: string[];
46
47
  }
47
48
 
@@ -319,6 +320,7 @@ export interface HeadlessPaneFreshness {
319
320
  publisher?: string;
320
321
  /** When the publisher released the data, as the data states it. Exports cite it; left out, they say it was not published. */
321
322
  publishedAt?: string | number | Date | null;
323
+ fredUpdatedAt?: string;
322
324
  /** Newest observation in the data. A `YYYY-MM-DD` string reads as a date without a time. */
323
325
  asOf?: string | number | Date | null;
324
326
  /** Oldest observation, mentioned when it is far older than `asOf`; `null` when the rows are a history. */
@@ -408,6 +410,16 @@ export interface HeadlessPaneFreshness {
408
410
  * one market's.
409
411
  */
410
412
  tradingDayMarket?: string;
413
+ /**
414
+ * The rows are one market's list from a session (MOST's movers, a scan, a
415
+ * sector board). Once that market is shut, the report names the session
416
+ * the list shows, `US trading day Fri 20 Nov 2026 close`, with when the
417
+ * market reopens, never the time the list was taken after the close
418
+ * (`shownSessionDay`). `session` is the trading day a list states for
419
+ * itself; `part` names a list of a part of the session that has ended, a
420
+ * pre-market or after-hours list, dated `... Fri 20 Nov 2026 pre-market`.
421
+ */
422
+ sessionList?: { exchange: string; session?: string; part?: "pre-market" | "after-hours" };
411
423
  /** The newest observation is stale once this time (the next scheduled release) has passed by a day. */
412
424
  nextExpectedAt?: string | number | Date | null;
413
425
  /**
@@ -777,6 +789,8 @@ export interface HeadlessSeriesTrailing {
777
789
  avg28: number | null;
778
790
  /** The mean over the 28 days that ended one year before the latest day. */
779
791
  yearAgoAvg28: number | null;
792
+ /** The days `yearAgoAvg28` is the mean of, YYYY-MM-DD; null when there is no such mean. */
793
+ yearAgoWindow: { start: string; end: string } | null;
780
794
  /** `avg28` against `yearAgoAvg28`, in percent. */
781
795
  changeVsYearAgoPct: number | null;
782
796
  }
@@ -891,6 +905,13 @@ export interface HeadlessPaneDefinition<Shape extends HeadlessPaneShape = Headle
891
905
  * the line after `message`, left out when the message says it all.
892
906
  */
893
907
  refuseSymbol?(key: string): { message: string; details?: string } | null;
908
+ /**
909
+ * The function reads each symbol's fate itself (VCA and HIVG refuse a
910
+ * moved one and keep its row in a list, with the new symbol), so `fn` does
911
+ * not read a ticker whose company moved (SQ) as its new symbol (XYZ) first,
912
+ * as it does for any other function that takes tickers.
913
+ */
914
+ readsSymbolFate?: boolean;
894
915
  /**
895
916
  * `fn` exits 1 when the report has no name with data: no rows, or every row
896
917
  * is one of `unavailableSymbols`. A list that gives data for some names
@@ -923,6 +944,8 @@ export interface HeadlessPaneDefinition<Shape extends HeadlessPaneShape = Headle
923
944
  load: () => Promise<HeadlessPaneResultByShape[Shape]>,
924
945
  given: ReadonlySet<string>,
925
946
  ): HeadlessShotState | Promise<HeadlessShotState>;
947
+ /** Device-only state the screenshot pane needs in its isolated persistence store. */
948
+ shotDeviceState?: ReadonlyArray<{ pluginId: string; key: string }>;
926
949
  /** What is true of every load: its source, and whether it is a feed. */
927
950
  freshness?: HeadlessPaneFreshness;
928
951
  /**
@@ -93,6 +93,7 @@ export interface InstrumentSearchResult {
93
93
  /** The company's home line, its common stock on its home exchange (7203 on JPX for Toyota), sent by newer
94
94
  * cloud servers. Search lists it before the company's depositary receipts and other lines. Only `true` counts. */
95
95
  homeListing?: boolean;
96
+ preferredNameMatch?: boolean;
96
97
  /**
97
98
  * The company the line belongs to, as the data service identifies it, sent by newer cloud servers on a bare
98
99
  * symbol's own lines: DHL's Xetra and Vienna lines carry one id however each venue names the company. Two lines
@@ -193,6 +193,22 @@ export function isCryptoPairSymbol(symbol: string): boolean {
193
193
  return CRYPTO_PAIR.test(symbol);
194
194
  }
195
195
 
196
+ // A coin and its quote run together, as crypto venues and charting sites write a pair: BTCUSDT, ETHUSDC, BTCUSD.
197
+ const RUN_TOGETHER_COIN_PAIR = /^([A-Z0-9]{2,15}?)(USDT|USDC|USD)$/;
198
+
199
+ /**
200
+ * The coin's dollar pair for a pair written with no separator (BTC-USD for
201
+ * BTCUSDT or BTCUSD), which is how the crypto venue lists it: a coin quoted in
202
+ * dollars or a stablecoin, six characters or more, so no US ticker (five
203
+ * letters at most) reads as one. Null for anything else, a currency's code
204
+ * before USD (EURUSD, spot FX) included.
205
+ */
206
+ export function runTogetherCoinPair(symbol: string): string | null {
207
+ const code = symbol.trim().toUpperCase();
208
+ const base = RUN_TOGETHER_COIN_PAIR.exec(code)?.[1];
209
+ return code.length >= 6 && base !== undefined && !isIsoCurrencyCode(base) ? `${base}-USD` : null;
210
+ }
211
+
196
212
  /**
197
213
  * The coins whose bare ticker is most often typed for the coin itself, with
198
214
  * how stories and notes name each: the name a listing's own may not say
@@ -31,6 +31,7 @@ const PAGES: Readonly<Record<string, (code: string) => ExchangeAnnouncementsPage
31
31
  FWB2: () => PAGES.XETRA!(""),
32
32
  JPX: () => ({ name: "TDnet timely disclosures", url: "https://www.release.tdnet.info/inbs/I_main_00.html" }),
33
33
  HKEX: () => ({ name: "HKEXnews", url: "https://www1.hkexnews.hk/search/titlesearch.xhtml?lang=en" }),
34
+ SWX: () => ({ name: "SIX Swiss Exchange", url: "https://www.six-group.com/en/market-data/news-tools/equity-issuer-news.html" }),
34
35
  KRX: () => ({ name: "DART filings", url: "https://dart.fss.or.kr/" }),
35
36
  KOSDAQ: () => PAGES.KRX!(""),
36
37
  TWSE: () => ({ name: "MOPS filings", url: "https://mops.twse.com.tw/mops/web/index" }),
@@ -61,7 +62,7 @@ function exchangeAnnouncementsPage(symbol: string, exchange: string | null | und
61
62
  */
62
63
  export function exchangeAnnouncementsPublisher(exchange: string | null | undefined): string | null {
63
64
  const venue = canonicalExchange(exchange ?? "");
64
- return venue === "ASX" || venue === "CXA" ? "ASX" : venue === "HKEX" ? "HKEXnews" : null;
65
+ return venue === "ASX" || venue === "CXA" ? "ASX" : venue === "HKEX" ? "HKEXnews" : venue === "SWX" ? "SIX Swiss Exchange" : null;
65
66
  }
66
67
 
67
68
  /** Whether Gloom Cloud lists the company's announcements on this venue (ASX, HKEX). */