@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
@@ -1,6 +1,5 @@
1
- import { fxLegForCurrency } from "../../../market-data/coordinator/fx-legs";
2
1
  import { regularSessionValuationPrice } from "../../../market-data/quotes/regular-session-valuation";
3
- import { fxCloseOnOrBefore, type FxCloses } from "../../../market-data/fx-closes";
2
+ import { crossFxCloseOnOrBefore, dailyFxLeg, type FxCloses } from "../../../market-data/fx-closes";
4
3
  import { knownWhenFiled } from "../../../time-series/fundamentals";
5
4
  import { STALE_TRAILING_EPS_MS, trailingEpsSteps as sharedTrailingEpsSteps, type EpsStep } from "../../../time-series/filed-trailing-eps";
6
5
  import { createValuationCurrencyContext } from "../../../time-series/valuation-currency";
@@ -39,17 +38,17 @@ export interface PeBandRow extends EpsStep {
39
38
  fx: FxClose | null;
40
39
  }
41
40
 
42
- /** One completed daily FX close: USD per unit of the statement currency. */
41
+ /** Price currency per unit of the reporting currency. */
43
42
  interface FxClose {
44
43
  date: string;
45
44
  rate: number;
46
45
  }
47
46
 
48
- /** EPS reported in another currency than a dollar price, converted at daily FX closes. */
47
+ /** EPS converted from the reporting currency at the period's daily FX close. */
49
48
  interface EpsConversion {
50
49
  /** The statement currency of today's EPS. */
51
50
  currency: string;
52
- /** The latest completed close, which converts today's EPS. */
51
+ /** The rate that converts the trailing EPS currently in force. */
53
52
  latest: FxClose;
54
53
  }
55
54
 
@@ -86,7 +85,7 @@ export interface PeBandModel {
86
85
  undated: number;
87
86
  /** Trailing sums in the window that are unavailable (a quarter's EPS is withheld or not reported). */
88
87
  unavailable: number;
89
- /** Set when today's EPS is in another currency than the dollar price. */
88
+ /** Set when current EPS was converted to the listing currency. */
90
89
  conversion: EpsConversion | null;
91
90
  /** Blocks the pane: nothing can be priced. */
92
91
  error: string | null;
@@ -116,35 +115,22 @@ export function perShareDigits(value: number): number {
116
115
 
117
116
  export const formatPerShare = (value: number) => value.toFixed(perShareDigits(value));
118
117
 
119
- /**
120
- * A rate in the pair's market convention: "USD/TWD 31.99" (Taiwan dollars per
121
- * dollar) or "EUR/USD 1.17" (dollars per euro), from USD per unit.
122
- */
123
- export function fxPairQuote(currency: string, usdPerUnit: number): { pair: string; value: number } {
124
- const perDollar = fxLegForCurrency(currency)?.invert ?? true;
125
- return perDollar ? { pair: `USD/${currency}`, value: 1 / usdPerUnit } : { pair: `${currency}/USD`, value: usdPerUnit };
126
- }
127
-
128
- /** The statement unit of an EPS currency when it is a whole currency other than USD with a daily pair, else null. */
129
- function fxCurrency(code: string | null | undefined): string | null {
130
- const unit = resolveCurrencyUnit(code);
131
- return unit.divisor === 1 && unit.currency !== "USD" && fxLegForCurrency(unit.currency) ? unit.currency : null;
118
+ export function formatEpsFx(from: string, to: string, rate: number): string {
119
+ return `${resolveCurrencyUnit(from).currency}/${resolveCurrencyUnit(to).currency} ${rate.toPrecision(5)}`;
132
120
  }
133
121
 
134
- const isDollarPrice = (currency: string | null | undefined) => {
135
- const unit = resolveCurrencyUnit(currency);
136
- return unit.currency === "USD" && unit.divisor === 1;
137
- };
138
-
139
- /**
140
- * The currencies whose daily FX closes a dollar-priced listing needs: those
141
- * its EPS is reported in, other than USD. Rows without a declared currency
142
- * are never converted.
143
- */
144
- export function epsFxCurrencies(financials: TickerFinancials): string[] {
145
- if (!isDollarPrice(financials.quote?.currency)) return [];
146
- const rows = [...financials.annualStatements, ...financials.quarterlyStatements].filter((row) => typeof row.eps === "number");
147
- return [...new Set(rows.flatMap((row) => fxCurrency(row.currency?.trim()) ?? []))];
122
+ export function epsFxCurrencies(financials: TickerFinancials, reports: readonly ReportDate[]): Map<string, string> {
123
+ const target = resolveCurrencyUnit(financials.quote?.currency).currency;
124
+ const starts = new Map<string, string>();
125
+ if (target !== "USD" && !dailyFxLeg(target)) return starts;
126
+ for (const step of trailingEpsSteps(financials, reports)) {
127
+ const source = resolveCurrencyUnit(step.currency).currency;
128
+ if (step.eps == null || source === target || (source !== "USD" && !dailyFxLeg(source))) continue;
129
+ for (const currency of [source, target]) {
130
+ if (currency !== "USD" && (!starts.has(currency) || step.periodEnd < starts.get(currency)!)) starts.set(currency, step.periodEnd);
131
+ }
132
+ }
133
+ return starts;
148
134
  }
149
135
 
150
136
  function quantile(sorted: readonly number[], q: number): number {
@@ -241,7 +227,7 @@ export function projectPeBand(
241
227
  history: readonly PricePoint[],
242
228
  options: {
243
229
  symbol: string; lookbackYears: number; now?: number; reports?: readonly ReportDate[];
244
- /** Daily FX closes by statement currency, for a dollar price against EPS in another currency. */
230
+ /** Daily FX closes by currency, quoted in USD per unit. */
245
231
  fx?: ReadonlyMap<string, FxCloses>;
246
232
  /** Why a needed FX history is missing, said when it leaves today's EPS unconverted. */
247
233
  fxError?: string | null;
@@ -265,26 +251,20 @@ export function projectPeBand(
265
251
  const factor = units.priceInStatementUnits({ date: step.periodEnd, currency: step.currency ?? undefined }, 1);
266
252
  return factor ? 1 / factor : null;
267
253
  };
268
- // ADRs report in one currency and trade in dollars: their EPS converts at a daily FX close.
269
- const fxFor = (step: EpsStep) => {
270
- const code = isDollarPrice(currency) ? fxCurrency(step.currency) : null;
271
- return code ? options.fx?.get(code) ?? null : null;
272
- };
273
- if (unitScale(latest) == null && !fxFor(latest)) {
274
- const fxCode = isDollarPrice(currency) ? fxCurrency(latest.currency) : null;
275
- return { ...empty, error: !currency || !latest.currency ? "The price or EPS currency is unknown."
276
- : `EPS is reported in ${latest.currency} and the price is in ${currency}${fxCode && options.fxError ? `; ${options.fxError}` : ""}.` };
277
- }
278
- /** The EPS in price units on `date` (YYYY-MM-DD), with the FX close used when it was converted. */
279
- const priced = (step: EpsStep | null, date: string): { eps: number; fx: FxClose | null } | null => {
254
+ const quoteUnit = resolveCurrencyUnit(currency);
255
+ const priced = (step: EpsStep | null): { eps: number; fx: FxClose | null } | null => {
280
256
  if (step?.eps == null) return null;
281
257
  const factor = unitScale(step);
282
258
  if (factor != null) return { eps: step.eps * factor, fx: null };
283
- const history = fxFor(step);
284
- const close = history ? fxCloseOnOrBefore(history, date) : null;
285
- return close ? { eps: step.eps * close.rate, fx: close } : null;
259
+ const source = resolveCurrencyUnit(step.currency);
260
+ const close = options.fx && crossFxCloseOnOrBefore(options.fx, source.currency, quoteUnit.currency, step.periodEnd);
261
+ return close ? { eps: step.eps / source.divisor * close.rate * quoteUnit.divisor, fx: close } : null;
286
262
  };
287
- const day = (time: Date | number) => new Date(time).toISOString().slice(0, 10);
263
+ const pricedSteps = new Map(allSteps.map((step) => [step, priced(step)]));
264
+ if (!pricedSteps.get(latest) && !allSteps.some((step) => pricedSteps.get(step))) {
265
+ return { ...empty, error: !currency || !latest.currency ? "The price or EPS currency is unknown."
266
+ : `EPS is reported in ${latest.currency} and the price is in ${currency}; ${options.fxError ?? `no FX close for ${latest.periodEnd}`}.` };
267
+ }
288
268
 
289
269
  const now = options.now ?? Date.now();
290
270
  const firstKnown = allSteps.find((step) => step.eps != null)!.knownAt.getTime();
@@ -294,9 +274,8 @@ export function projectPeBand(
294
274
  const dailyStart = daily[0]?.date.getTime() ?? Number.POSITIVE_INFINITY;
295
275
  /** A close as the chart reads it: with the EPS in force on its day, and the P/E they make. */
296
276
  const reading = (point: { date: Date; close: number }): PeBandWeek => {
297
- // Converted at the FX close of the bar's date, the same date that picks the EPS in force, so each week's multiple
298
- // moves with the price and the currency together rather than with the rate of an old publication date.
299
- const eps = priced(stepAt(allSteps, point.date.getTime()), day(point.date))?.eps ?? null;
277
+ const step = stepAt(allSteps, point.date.getTime());
278
+ const eps = step ? pricedSteps.get(step)?.eps ?? null : null;
300
279
  const positive = eps != null && eps > 0 ? eps : null;
301
280
  return { date: point.date, close: point.close, eps: positive, pe: positive ? point.close / positive : null };
302
281
  };
@@ -308,8 +287,7 @@ export function projectPeBand(
308
287
  const rows = steps.filter((step) => step.eps != null).map((step): PeBandRow => {
309
288
  const time = step.knownAt.getTime();
310
289
  const price = (dayClose(time) ?? sorted.findLast((point) => point.date.getTime() <= time))?.close ?? null;
311
- // Converted at the FX close of the day it became known.
312
- const converted = priced(step, day(step.knownAt));
290
+ const converted = pricedSteps.get(step);
313
291
  const eps = converted?.eps ?? null;
314
292
  const prior = allSteps.find((other) => other.eps != null && other.currency === step.currency
315
293
  && Math.abs(Date.parse(step.periodEnd) - Date.parse(other.periodEnd) - 365 * DAY_MS) <= 20 * DAY_MS);
@@ -325,9 +303,9 @@ export function projectPeBand(
325
303
  // Today's figure reads like every week's: one whose newest quarter has no EPS keeps the last figure, dated in the
326
304
  // table, where the headline EPS (TTM) needs that quarter's own (filed-trailing-eps) and shows Gloom Cloud's, labelled.
327
305
  const currentStep = stepAt(allSteps, now);
328
- // Today's EPS at the latest completed FX close.
329
- const currentEps = priced(currentStep, day(now))?.eps ?? null;
330
- const latestFx = unitScale(latest) == null ? fxFor(latest) : null;
306
+ const currentConversion = currentStep ? pricedSteps.get(currentStep) : null;
307
+ const currentEps = currentConversion?.eps ?? null;
308
+ const latestFx = currentConversion?.fx;
331
309
  const currentPe = price != null && currentEps != null && currentEps > 0 ? price / currentEps : null;
332
310
  const multiples = chooseMultiples(pes, currentPe);
333
311
  const above = currentPe == null ? undefined : multiples.find((multiple) => multiple >= currentPe);
@@ -341,7 +319,7 @@ export function projectPeBand(
341
319
  const points = [...byTime.values()].sort((a, b) => a.date.getTime() - b.date.getTime());
342
320
  return {
343
321
  ...empty, weeks, points, rows, multiples,
344
- conversion: latestFx ? { currency: latestFx.currency, latest: fxCloseOnOrBefore(latestFx, day(now))! } : null,
322
+ conversion: latestFx && currentStep?.currency ? { currency: currentStep.currency, latest: latestFx } : null,
345
323
  sample: ranked.length ? { start: ranked[0]!.date, weeks: ranked.length } : null,
346
324
  bandCeiling: highestClose > 0 ? Math.max(highestClose * 1.5, above != null && currentEps != null ? above * currentEps : 0) : null,
347
325
  current: price == null ? null : { price, eps: currentEps, pe: currentPe, step: currentStep,
@@ -349,6 +327,7 @@ export function projectPeBand(
349
327
  range: ordered.length ? { min: ordered[0]!, median: quantile(ordered, 0.5), max: ordered.at(-1)! } : null,
350
328
  undated: steps.filter((step) => !step.dated && step.eps != null).length,
351
329
  unavailable: steps.filter((step) => step.eps == null).length,
352
- notice: pes.length ? null : "Trailing EPS was not positive in this window, so there is no P/E band.",
330
+ notice: currentStep && !currentConversion ? options.fxError ?? `No FX close for ${currentStep.periodEnd}.`
331
+ : pes.length ? null : "Trailing EPS was not positive in this window, so there is no P/E band.",
353
332
  };
354
333
  }
@@ -15,7 +15,7 @@ import { Box } from "../../../ui";
15
15
  import { MISSING_VALUE, formatCurrency, formatPercentileRank } from "../../../utils/format";
16
16
  import { useAssetData } from "../../runtime";
17
17
  import { loadPeBandInputs } from "./client";
18
- import { formatPerShare, fxPairQuote, perShareDigits, projectPeBand, type PeBandModel, type PeBandRow } from "./model";
18
+ import { formatEpsFx, formatPerShare, perShareDigits, projectPeBand, type PeBandModel, type PeBandRow } from "./model";
19
19
 
20
20
  export const LOOKBACK_OPTIONS = [{ value: "5", label: "5Y" }, { value: "10", label: "10Y" }, { value: "0", label: "Max" }];
21
21
 
@@ -30,12 +30,12 @@ const periodLabel = (row: Pick<PeBandRow, "basis" | "periodEnd">) =>
30
30
  `${row.basis === "annual" ? "FY" : "TTM"} ${MONTHS[Number(row.periodEnd.slice(5, 7)) - 1]} ${row.periodEnd.slice(0, 4)}`;
31
31
 
32
32
  /** With EPS converted from another currency, the table keeps the reported figure and adds the FX close it was converted at. */
33
- function tableColumns(conversion: PeBandModel["conversion"]): DataTableColumn[] {
33
+ function tableColumns(showFx: boolean): DataTableColumn[] {
34
34
  return [
35
35
  { id: "period", label: "Period", width: 13, align: "left" },
36
36
  { id: "known", label: "Known", width: 11, align: "left" },
37
- { id: "eps", label: conversion ? `EPS ${conversion.currency}` : "EPS", width: 9, align: "right" },
38
- ...(conversion ? [{ id: "fx", label: fxPairQuote(conversion.currency, conversion.latest.rate).pair, width: 9, align: "right" as const }] : []),
37
+ { id: "eps", label: "EPS", width: showFx ? 14 : 9, align: "right" },
38
+ ...(showFx ? [{ id: "fx", label: "Period-end FX", width: 17, align: "right" as const }] : []),
39
39
  { id: "yoy", label: "YoY", width: 8, align: "right", omitWhenEmpty: true },
40
40
  { id: "price", label: "Price", width: 10, align: "right" },
41
41
  { id: "pe", label: "P/E", width: 7, align: "right" },
@@ -44,19 +44,18 @@ function tableColumns(conversion: PeBandModel["conversion"]): DataTableColumn[]
44
44
 
45
45
  const rowKey = (row: PeBandRow) => `${row.basis}:${row.periodEnd}`;
46
46
 
47
- function renderCell(row: PeBandRow, column: DataTableColumn, colors: ReturnType<typeof useThemeColors>): DataTableCell {
47
+ function renderCell(row: PeBandRow, column: DataTableColumn, colors: ReturnType<typeof useThemeColors>, fxTarget?: string): DataTableCell {
48
48
  switch (column.id) {
49
49
  case "period": return { text: periodLabel(row) };
50
50
  // A figure with no publication date on record steps at its period end.
51
51
  case "known": return row.dated ? { text: row.knownAt.toISOString().slice(0, 10), value: row.knownAt.toISOString().slice(0, 10) }
52
52
  : { text: "period end", color: colors.textMuted };
53
- case "eps": return { text: row.eps == null ? MISSING_VALUE : formatPerShare(row.eps), value: row.eps,
53
+ case "eps": return { text: row.eps == null ? MISSING_VALUE : `${formatPerShare(row.eps)}${fxTarget && row.currency ? ` ${row.currency}` : ""}`, value: row.eps,
54
54
  color: row.eps != null && row.eps <= 0 ? colors.negative : undefined };
55
55
  case "yoy": return { text: pct(row.yoy), value: row.yoy == null ? null : row.yoy * 100,
56
56
  color: row.yoy == null || Math.abs(row.yoy) < 0.0005 ? undefined : row.yoy > 0 ? colors.positive : colors.negative };
57
57
  case "fx": {
58
- const quote = row.fx && row.currency ? fxPairQuote(row.currency, row.fx.rate).value : null;
59
- return { text: quote == null ? MISSING_VALUE : quote.toPrecision(5), value: quote };
58
+ return { text: row.fx && row.currency && fxTarget ? formatEpsFx(row.currency, fxTarget, row.fx.rate) : MISSING_VALUE, value: row.fx?.rate };
60
59
  }
61
60
  case "price": return { text: row.price == null ? MISSING_VALUE : formatPerShare(row.price), value: row.price };
62
61
  default: return { text: multiple(row.pe), value: row.pe };
@@ -111,7 +110,8 @@ export function PeBandPane({ width, height, focused }: PaneProps) {
111
110
  : null, [inputs.data, lookbackYears, symbol]);
112
111
  const rows = model?.rows ?? [];
113
112
  const conversion = model?.conversion ?? null;
114
- const columns = useMemo(() => tableColumns(conversion), [conversion?.currency, conversion?.latest.rate]);
113
+ const showFx = !!conversion || rows.some((row) => row.fx);
114
+ const columns = useMemo(() => tableColumns(showFx), [showFx]);
115
115
  const series = useMemo(() => model && !model.error ? chartSeries(model, colors) : [], [model, colors]);
116
116
  const currency = model?.currency ?? undefined;
117
117
  const firstWeek = model?.weeks[0]?.date;
@@ -144,9 +144,8 @@ export function PeBandPane({ width, height, focused }: PaneProps) {
144
144
  const { current, range } = model;
145
145
  const step = current.step;
146
146
  // Converted EPS says what it was converted from, and at which close.
147
- const pair = conversion ? fxPairQuote(conversion.currency, conversion.latest.rate) : null;
148
- const converted = step?.eps != null && conversion && pair && step.currency === conversion.currency
149
- ? `, from ${conversion.currency} ${formatPerShare(step.eps)} at ${pair.pair} ${pair.value.toPrecision(5)}` : "";
147
+ const converted = step?.eps != null && conversion && currency && step.currency === conversion.currency
148
+ ? ` · from ${conversion.currency} ${formatPerShare(step.eps)} at ${formatEpsFx(conversion.currency, currency, conversion.latest.rate)}` : "";
150
149
  return [
151
150
  { id: "pe", label: "P/E", value: multiple(current.pe),
152
151
  detail: current.pe != null ? formatPercentileRank(current.percentile, windowLabel) : current.eps != null ? "EPS not positive" : "EPS unavailable" },
@@ -169,10 +168,10 @@ export function PeBandPane({ width, height, focused }: PaneProps) {
169
168
  selection={{ kind: "id", selectedId: selected, getId: rowKey, onChange: (id) => setSelectedId(id) }}
170
169
  selectedTextOverridesCellColor
171
170
  getExportMetadata={() => [["symbol", model.symbol], ["currency", model.currency ?? ""],
172
- ["units", conversion
173
- ? `EPS as reported in ${conversion.currency}; FX close of the day it became known; price in ${model.currency ?? ""}; P/E at that day's close`
171
+ ["units", showFx
172
+ ? `EPS as reported; period-end FX to ${model.currency ?? ""}; P/E at the close of the day the EPS became known`
174
173
  : "EPS and price in the listing currency; P/E at the close of the day the EPS became known"]]}
175
- renderCell={(row, column) => renderCell(row, column, colors)}
174
+ renderCell={(row, column) => renderCell(row, column, colors, showFx ? currency : undefined)}
176
175
  rootBefore={<ChartTableHeader width={width} height={height} tableRows={rows.length} tableColumns={columns} query={query} figures={figures}
177
176
  chart={model.weeks.length >= 2 ? { series, formatValue: formatPrice, formatAxisValue: formatAxis, remoteKind: "pe-band", ...link } : null} />} />
178
177
  : null}
@@ -9,6 +9,7 @@ import { useResearchCloudSession } from "../shared/research-cloud-session";
9
9
  import { perpEquityIdentity } from "./equity-identity";
10
10
  import { perpetualListing } from "../../../tickers/perpetual-listing";
11
11
  import { loadPerpSelection, loadPerpsEquity } from "./client";
12
+ import { rowReadAt } from "../../../market-data/perpetual-open-interest";
12
13
  import { compact, percent, perpDescription, price, readingTime } from "./model";
13
14
  import { useLivePerpRows } from "./live-rows";
14
15
  import { openPerpLabel, useOpenPerpMarket } from "./open-market";
@@ -62,7 +63,8 @@ function PerpRow({ row, stale, width, own = false }: { row: PerpBoardRow; stale:
62
63
  const openMarket = useOpenPerpMarket();
63
64
  const open = () => openMarket(row.marketId);
64
65
  usePaneLinkMenuEntry(`function:perps-pane:${row.marketId}`, openPerpLabel(row), open);
65
- const read = readingTime(row.observedAt);
66
+ // Dated by its oldest figure: a streamed mark can sit beside the open interest the last poll read.
67
+ const read = readingTime(rowReadAt(row));
66
68
  const staleText = row.stale || stale ? " · stale" : "";
67
69
  const figures = own
68
70
  ? row.underlyingPremium != null ? [`${percent(row.underlyingPremium, 2)} vs ${row.underlyingSymbol ?? "underlying"} last${staleText}`] : staleText ? ["stale"] : []
@@ -1,8 +1,9 @@
1
1
  import type { PerpBoardRow } from "../../../api-client/perps";
2
2
  import type { HeadlessPaneFreshness } from "../../../types/headless";
3
+ import { readAsOne, rowReadAt, type PerpOpenInterest } from "../../../market-data/perpetual-open-interest";
3
4
  import { venueName, venuesOf } from "./model";
4
5
 
5
- type Dated = Pick<PerpBoardRow, "venue" | "observedAt" | "stale">;
6
+ type Dated = Pick<PerpBoardRow, "venue" | "observedAt" | "stale"> & PerpOpenInterest;
6
7
  type Funded = Pick<PerpBoardRow, "venue" | "fundingRate" | "fundingRate8h" | "fundingKind" | "nextFundingAt">;
7
8
 
8
9
  const WEEKDAYS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] as const;
@@ -47,25 +48,31 @@ export function fundingNote(rows: readonly Funded[], now = Date.now()): string |
47
48
  }).join("; ")}`;
48
49
  }
49
50
 
50
- /** What a capture reads of a row: when it was observed and whether the venue has stopped answering for it. */
51
- const perpObservation = (row: Pick<PerpBoardRow, "observedAt" | "stale">) => ({ observedAt: row.observedAt, stale: row.stale });
51
+ /**
52
+ * What a capture reads of a row: when its figures were read, its open interest's own read when that is older (a
53
+ * streamed mark beside polled open interest), and whether the venue has stopped answering for it.
54
+ */
55
+ const perpObservation = (row: Dated) => ({ observedAt: rowReadAt(row), stale: row.stale });
52
56
 
53
57
  /**
54
58
  * How current a view of perpetual markets is: each venue's own newest observation, how old the oldest price shown is,
55
59
  * and what the funding figures it shows (`funding`) are. `live` only while every row followed streams from its venue's
56
- * socket; otherwise no feed word, since a row off the stream is the venue's own reading from the last pass (about once
57
- * a minute), neither streamed nor held back. Stale after an hour without a read, or for a row whose venue stopped
58
- * answering. The report, the capture and the pane footer all read this, rows and all, so they end with the same line.
60
+ * socket and every figure on it came with the stream: a streamed mark beside the open interest the last poll read
61
+ * (Binance's socket carries none) is not live. Otherwise no feed word, since a row off the stream is the venue's own
62
+ * reading from the last pass (about once a minute), neither streamed nor held back. Stale after an hour without a
63
+ * read, or for a row whose venue stopped answering. The report, the capture and the pane footer all read this, rows
64
+ * and all, so they end with the same line.
59
65
  */
60
66
  export function perpFreshness(rows: readonly Dated[], { funding = [], venue = "all", now = Date.now(), live = false }: {
61
67
  funding?: readonly Funded[]; venue?: string; now?: number;
62
- /** Every row followed moves with its venue's socket: the view is a live feed. */
68
+ /** Every row followed moves with its venue's socket. */
63
69
  live?: boolean;
64
70
  } = {}): HeadlessPaneFreshness {
65
71
  const sources = venuesOf(rows).map((id) => ({ source: venueName(id), asOf: new Date(Math.max(...rows.filter((row) => row.venue === id)
66
- .map((row) => Date.parse(row.observedAt)))).toISOString() }));
72
+ .map((row) => Date.parse(rowReadAt(row))))).toISOString() }));
67
73
  const source = sources.length ? sources.map((entry) => entry.source).join(", ") : venue !== "all" ? venueName(venue) : null;
68
74
  const note = fundingNote(funding, now);
69
- return { ...(source ? { source } : {}), sources, ...(live ? { status: "live" as const } : {}), ageOnly: true, maxAgeMinutes: 60,
75
+ const streamed = live && rows.every(readAsOne);
76
+ return { ...(source ? { source } : {}), sources, ...(streamed ? { status: "live" as const } : {}), ageOnly: true, maxAgeMinutes: 60,
70
77
  observations: rows.map(perpObservation), ...(note ? { note } : {}) };
71
78
  }
@@ -6,7 +6,7 @@ import { DEPTH_COLUMN_IDS, depthBandTotals, depthCellText, depthColumnLabel, dep
6
6
  PRINT_COLUMN_IDS, printCellText, printColumnLabel, type DepthColumnId, type LiquidationColumnId, type PrintColumnId } from "./cascade";
7
7
  import { boardSearchText, fetchPerpSelection, fetchPerpsBoard, fetchPerpsCompare, fetchPerpsDepth, fetchPerpsHistory, fetchPerpsLiquidations, fetchPerpsRankings, marketQuery, nearestPerpMarkets } from "./client";
8
8
  import { perpFreshness } from "./freshness";
9
- import { aprFootnote, ASSET_FILTERS, BOARD_COLUMNS, BOARD_SORTS, collectedVenueCount, COMPARE_COLUMNS, compact, fundingSpread, HISTORY_METRICS, label, marketLabel, observed, openingTab, PERP_TABS, perpCellText,
9
+ import { aprFootnote, ASSET_FILTERS, BOARD_COLUMNS, BOARD_SORTS, collectedVenueCount, COMPARE_COLUMNS, compact, fundingSpread, HISTORY_METRICS, label, marketLabel, observed, openInterestFields, openingTab, PERP_TABS, perpCellText,
10
10
  perpColumnLabel, percent, perpHistoryProText, positioningFields, price, RANKING_COLUMNS, rankingRows, RANKINGS, ratioText, share, time, uncoveredVenueNote, VENUES, venueAprSummary, venueName, venuesOf, IDENTITY_VENUES,
11
11
  type PerpColumnId } from "./model";
12
12
  import { freePreviewNote } from "../shared/free-preview";
@@ -342,6 +342,9 @@ async function loadPerpTab(args: HeadlessPaneLoadArgs, ctx: HeadlessPaneContext)
342
342
  // Where the figures were read, as the pane's Evidence names it: the venue's own endpoint and its time.
343
343
  { title: "Source", entries: [{ key: "sourceUrl", label: "URL", value: selected.sourceUrl },
344
344
  { key: "sourceAsOf", label: "Venue as of", value: selected.sourceAsOf, formatted: time(selected.sourceAsOf) }] },
345
+ // The open interest's own read, which the market's source and time above do not date, and how its USD was made.
346
+ { title: "Open interest", entries: openInterestFields(selected).map((field) => ({ key: field.key, label: field.label, value: field.value,
347
+ formatted: field.detail ? `${field.text} · ${field.detail}` : field.text })) },
345
348
  ...(positioning ? [{ title: "Positioning", entries: positioning.map((field) => ({ key: field.key, label: field.label, value: field.value,
346
349
  formatted: field.detail ? `${field.text} · ${field.detail}` : field.text })) }] : []),
347
350
  { title: "Observation revisions", columns: REVISION_COLUMNS, rows: market.evidence.map((row) => ({ ...row })), ...lockedTable(market.access !== "pro") }],
@@ -6,6 +6,7 @@ import { ActionRow, ColumnGrid, SectionHeading, type ColumnGridCell, type Column
6
6
  import { hiddenTableColumnText, markHiddenTableColumns } from "../../../components/ui/table-layout";
7
7
  import { t, tf } from "../../../i18n";
8
8
  import { useAsyncResource, useAutoRefresh } from "../../../public/react";
9
+ import { useAgeClock } from "../../../react/auto-refresh";
9
10
  import { useThemeColors } from "../../../theme/theme-context";
10
11
  import { perpetualListing } from "../../../tickers/perpetual-listing";
11
12
  import { premiumToUnderlying } from "../../../market-data/perpetual-premium";
@@ -18,9 +19,10 @@ import { useResearchCloudSession } from "../shared/research-cloud-session";
18
19
  import { loadPerpsCompare, loadPerpsEquity } from "./client";
19
20
  import { perpEquityIdentity } from "./equity-identity";
20
21
  import { useLivePerpRows } from "./live-rows";
21
- import { compact, perpCell, percent, price, readingTime, venueName } from "./model";
22
+ import { compact, perpCell, percent, price, venueName } from "./model";
22
23
  import { openPerpLabel, useOpenPerpMarket } from "./open-market";
23
- import { contractText, foldSmallMarkets, mergeVenueMarkets, type PerpVenueMarket } from "./venue-markets";
24
+ import { freshnessLine } from "./status-line";
25
+ import { contractText, foldSmallMarkets, mergeVenueMarkets, venueMarketsFreshness, withPrimaryReading, type PerpVenueMarket } from "./venue-markets";
24
26
 
25
27
  const STOCK_TYPES = new Set(["STK", "EQUITY", "STOCK", "COMMON STOCK"]);
26
28
  const COIN_PAIR = /^([A-Z0-9]{1,15})[-/](?:USD|USDT|USDC)$/;
@@ -74,8 +76,8 @@ function fitColumns(width: number, venueWidth: number): Column[] {
74
76
  /**
75
77
  * DES's perpetual markets on a stock or a coin: one row per venue (its contracts merged, `venue-markets.ts`), the
76
78
  * deepest first, markets with a small share of the open interest folded behind a row that shows them. A row opens
77
- * PERP on its venue's deepest contract. The figures move with the quote stream while the venue streams; otherwise
78
- * the section says when the venues were read.
79
+ * PERP on its venue's deepest contract. The figures move with the quote stream while the venue streams, and the
80
+ * section ends with PERP's status line: each venue's time, never newer than a figure on its row.
79
81
  */
80
82
  export function PerpMarketsSection({ symbol, exchange, instrumentType, quote, width }: {
81
83
  symbol: string;
@@ -105,8 +107,13 @@ export function PerpMarketsSection({ symbol, exchange, instrumentType, quote, wi
105
107
  // The deepest contract of each row on screen follows the quote stream.
106
108
  const primaries = useMemo(() => visible.map((market) => market.primary), [visible]);
107
109
  const live = useLivePerpRows(primaries, { surface: "detail" });
110
+ const now = useAgeClock(resource.updatedAt);
108
111
  if (!assetKey || !markets.length) return null;
109
- const rows = visible.map((market, index) => ({ market, row: live.rows[index] ?? market.primary }));
112
+ // A streamed reading moves the venue's whole row: its mark, and the open interest and volume counted with it.
113
+ const rows = visible.map((market, index) => {
114
+ const row = live.rows[index] ?? market.primary;
115
+ return { market: withPrimaryReading(market, row), row };
116
+ });
110
117
  const premiumLabel = asset?.kind === "stock" ? "vs last" : "Premium";
111
118
  // The venue column fits the longest venue name shown.
112
119
  const venueWidth = Math.min(VENUE_MAX_WIDTH, Math.max(VENUE_MIN_WIDTH, ...visible.map((market) => displayWidth(venueName(market.venue)))));
@@ -140,10 +147,9 @@ export function PerpMarketsSection({ symbol, exchange, instrumentType, quote, wi
140
147
  return { text: compact(column.id === "oi" ? market.openInterestUsd : market.volume24hUsd), color: colors.text };
141
148
  };
142
149
  const body = rows.map(({ market, row }) => columns.map((column) => cell(column, market, row)));
143
- // Streaming figures date themselves; the rows from the minute's read say when it was.
144
- const read = rows.filter(({ row }) => !live.liveMarkets.has(row.marketId));
145
- const readAt = read.length ? readingTime(read.reduce<string | null>((latest, { row }) => !latest || row.observedAt > latest ? row.observedAt : latest, null)) : null;
146
- const stale = read.length > 0 && (!!resource.data?.stale || read.some(({ row }) => row.stale));
150
+ // Each venue's own time, as PERP's footer gives it: the first form that fits.
151
+ const status = freshnessLine(venueMarketsFreshness(rows.map(({ market }) => market), { now, streaming: live.liveMarkets, refreshFailed: !!resource.data?.stale }), now);
152
+ const statusText = status.variants.find((variant) => displayWidth(variant) <= width) ?? status.variants.at(-1);
147
153
  return (
148
154
  <Box flexDirection="column" data-gloom-role="perp-markets">
149
155
  <SectionHeading title={t("Perpetuals")} />
@@ -154,7 +160,7 @@ export function PerpMarketsSection({ symbol, exchange, instrumentType, quote, wi
154
160
  label={expanded ? t("Fewer markets") : folded.length === 1 ? t("1 smaller market") : tf("{count} smaller markets", { count: String(folded.length) })}
155
161
  onPress={() => setExpanded((value) => !value)} />
156
162
  )}
157
- {readAt && <Text fg={stale ? colors.warning : colors.textDim}>{`${read.length < rows.length ? `${[...new Set(read.map(({ market }) => venueName(market.venue)))].join(", ")} ` : ""}${t("as of")} ${readAt}${stale ? ` · ${t("stale")}` : ""}`}</Text>}
163
+ {statusText && <Text fg={status.stale ? colors.warning : colors.textDim}>{statusText}</Text>}
158
164
  </Box>
159
165
  );
160
166
  }
@@ -2,6 +2,7 @@ import type { PerpBoardRow, PerpHistoryPayload, PerpLongShortRatio, PerpRankings
2
2
  import type { DataTableCell, DataTableColumn } from "../../../components";
3
3
  import { scalarPoint, staticSeries } from "../../../components/chart/static/series";
4
4
  import { getTableWidth, markHiddenTableColumns } from "../../../components/ui/table-layout";
5
+ import { openInterestSourceOf, rowReadAt, type PerpOpenInterest } from "../../../market-data/perpetual-open-interest";
5
6
  import { MISSING_VALUE, formatCompact } from "../../../utils/format";
6
7
  import { isUsListingExchange, publicTickerKey } from "../../../utils/exchanges";
7
8
  import { isRecord } from "../../../utils/guards";
@@ -206,6 +207,35 @@ export function positioningFields(row: Pick<PerpBoardRow, "longShortRatio" | "lo
206
207
  ];
207
208
  }
208
209
 
210
+ const USD_BASES: Record<"mark" | "oracle" | "face-value", string> = { mark: "mark × contracts", oracle: "oracle × contracts", "face-value": "contracts × face value" };
211
+ /**
212
+ * How a market's OI USD was made: `mark × contracts, USDT valued at 1 USD`, or the venue's own figure
213
+ * (`Bybit's own USDT value, USDT valued at 1 USD`). Null without a USD figure or when the server does not say.
214
+ */
215
+ function openInterestUsdBasis(row: PerpOpenInterest & Pick<PerpBoardRow, "venue">): string | null {
216
+ const source = openInterestSourceOf(row);
217
+ if (row.openInterestUsd == null || !source?.usdBasis) return null;
218
+ const made = source.usdBasis === "venue" ? `${venueName(row.venue)}'s own ${source.usdParity ?? "USD"} value` : USD_BASES[source.usdBasis];
219
+ return made ? `${made}${source.usdParity ? `, ${source.usdParity} valued at 1 USD` : ""}` : null;
220
+ }
221
+ /**
222
+ * The open interest as Evidence lists it, shared by the pane and the text report: the figure with how its USD was
223
+ * made, then its own read, the venue's time for it and the endpoint, never the market's. A server that does not say
224
+ * where it read the open interest leaves its time "Not stated".
225
+ */
226
+ export function openInterestFields(row: Pick<PerpBoardRow, "venue" | "baseAsset" | "openInterestBase" | "openInterestUsd" | "openInterestSource">): PositioningField[] {
227
+ const basis = openInterestUsdBasis(row);
228
+ const amount: PositioningField = { key: "openInterest", label: "Open interest", value: row.openInterestUsd,
229
+ text: `${compact(row.openInterestBase)} ${row.baseAsset} · ${compact(row.openInterestUsd)} USD`, ...(basis ? { detail: `USD = ${basis}` } : {}) };
230
+ if (row.openInterestBase == null && row.openInterestUsd == null) return [amount];
231
+ const source = openInterestSourceOf(row);
232
+ if (!source) return [amount, { key: "openInterestObservedAt", label: "OI observed", value: null, text: "Not stated" }];
233
+ return [amount,
234
+ { key: "openInterestObservedAt", label: "OI observed", value: source.observedAt, text: time(source.observedAt) },
235
+ { key: "openInterestAsOf", label: "OI source as of", value: source.asOf, text: time(source.asOf) },
236
+ { key: "openInterestSourceUrl", label: "OI source", value: source.url, text: source.url }];
237
+ }
238
+
209
239
  // One text per figure, shared by the pane cells and the text report so the two always agree.
210
240
  const markText = (row: Pick<PerpBoardRow, "markPrice" | "quoteCurrency">) => row.markPrice == null ? MISSING_VALUE : `${price(row.markPrice)} ${row.quoteCurrency}`;
211
241
  const fundingPerInterval = (row: Pick<PerpBoardRow, "fundingRate" | "fundingIntervalHours" | "fundingKind">) => row.fundingRate == null ? MISSING_VALUE : `${percent(row.fundingRate, 5)} /${fundingInterval(row)}`;
@@ -313,7 +343,8 @@ export function perpCellText(row: PerpBoardRow, id: PerpColumnId): string {
313
343
  if (id === "markPrice") return markText(row);
314
344
  if (id === "fundingRate") return fundingPerInterval(row);
315
345
  if (id === "openInterestUsd") return compact(row.openInterestUsd);
316
- if (id === "observedAt") return observed(row.observedAt);
346
+ // A row is dated by its oldest figure: a streamed mark can sit beside the open interest the last poll read.
347
+ if (id === "observedAt") return observed(rowReadAt(row));
317
348
  if (id === "longShare") return share(row.longShortRatio?.longShare);
318
349
  const digits = SIGNED[id];
319
350
  return digits === undefined ? MISSING_VALUE : percent(row[id as keyof PerpBoardRow] as number | null, digits);
@@ -322,7 +353,7 @@ export function perpCell(row: PerpBoardRow, id: PerpColumnId, colors: Pick<Theme
322
353
  const text = perpCellText(row, id);
323
354
  if (id === "market") return { text, color: row.stale ? colors.textDim : colors.textBright };
324
355
  if (id === "venue" || id === "symbol") return { text, color: colors.textMuted };
325
- if (id === "observedAt") return { text, value: row.observedAt, color: row.stale ? colors.textMuted : colors.textDim };
356
+ if (id === "observedAt") return { text, value: rowReadAt(row), color: row.stale ? colors.textMuted : colors.textDim };
326
357
  if (id === "markPrice") return { text, value: row.markPrice };
327
358
  if (id === "openInterestUsd") return { text, value: row.openInterestUsd };
328
359
  // A share, not a signed move: no tone, dimmed like a stale market when its bucket is old.
@@ -28,7 +28,7 @@ import { useFreshnessStatusLine } from "./status-line";
28
28
  import { useLivePerpRows, useLivePerpTableRows } from "./live-rows";
29
29
  import { perpBoardRowSource, readPerpBoardRow } from "./board-row-source";
30
30
  import { aprFormula, ASSET_FILTERS, BOARD_SORTS, boardColumns, collectedVenueCount, compact, compareColumns, dayChange, fundingInterval, fundingSpread, historyCaption, historyCell, historyChange, historyColumns,
31
- HISTORY_METRICS, historyRows, historySeries, historyValue, inPoints, isAssetTab, isMarketTab, label, longShortReason, marketLabel, metricLabel, openingTab, perpCell, perpHistoryProText, PERP_TABS, percent,
31
+ HISTORY_METRICS, historyRows, historySeries, historyValue, inPoints, isAssetTab, isMarketTab, label, longShortReason, marketLabel, metricLabel, openInterestFields, openingTab, perpCell, perpHistoryProText, PERP_TABS, percent,
32
32
  positioningFields, price, rankingColumns, rankingRows, RANKINGS, ratioText, share, sortLabel, time, underlyingTicker, venueAprSummary, venueLabel, venueName, venuesOf, type HistoryMetric,
33
33
  type PerpColumnId, type PerpTab, type RankingKey } from "./model";
34
34
 
@@ -81,7 +81,8 @@ function MarketEvidence({ row, data, width, height }: { row: PerpBoardRow; data:
81
81
  ...(row.predictedFundingRate != null ? [["Predicted funding", `${percent(row.predictedFundingRate)} / ${row.predictedFundingIntervalHours ?? MISSING_VALUE}h`] as [string, string]] : []),
82
82
  ...(row.nextFundingAt ? [["Next funding", time(row.nextFundingAt)] as [string, string]] : []),
83
83
  ...(acrossVenues ? [["APR across venues", acrossVenues.text] as [string, string]] : [])]],
84
- ["Open Interest", [["Open interest", `${compact(row.openInterestBase)} ${row.baseAsset} · ${compact(row.openInterestUsd)} USD`],
84
+ // The open interest is dated and sourced by its own read, not the market's above.
85
+ ["Open Interest", [...openInterestFields(row).map((field): EvidenceField => [field.label, field.text, field.detail]),
85
86
  ["OI change 1h / 24h", row.oiChange1h == null && row.oiChange24h == null ? "Collecting" : `${percent(row.oiChange1h, 2)} / ${percent(row.oiChange24h, 2)}`, "own snapshots"]]],
86
87
  ...(positioning ? [["Positioning", positioning.map((field) => [field.label, field.text, field.detail])] as [string, EvidenceField[]]] : []),
87
88
  ...(row.underlying ? [["Underlying", [...listed, ["Underlying last", `${price(row.underlying.price)} ${row.underlying.currency}`, time(row.underlying.asOf)], ["Underlying session", row.underlying.marketState ?? "Unknown"],
@@ -5,6 +5,15 @@ import { useAgeClock } from "../../../react/auto-refresh";
5
5
  import { useRemoteUiNode } from "../../../remote/semantic-tree";
6
6
  import type { HeadlessPaneFreshness } from "../../../types/headless";
7
7
 
8
+ /**
9
+ * A declared freshness as a pane writes it, PERP's status line: its forms from longest to shortest, for the first that
10
+ * fits, and whether it is stale.
11
+ */
12
+ export function freshnessLine(declared: HeadlessPaneFreshness, now: number): { variants: string[]; stale: boolean } {
13
+ const freshness = deriveHeadlessFreshness({ shape: "rows" }, { rows: [], freshness: declared }, now);
14
+ return { variants: paneStatusLineVariants(freshness), stale: freshness.status === "stale" };
15
+ }
16
+
8
17
  /**
9
18
  * The footer line a tab ends with, from the same freshness its text report declares (`declare`, null while there is
10
19
  * nothing to date): the source, its time and how old it is, the line `fn PERP` and `shot PERP` end with. It keeps ageing
@@ -16,10 +25,10 @@ export function useFreshnessStatusLine(declare: ((now: number) => HeadlessPaneFr
16
25
  useRemoteUiNode(declared ? { role: "report-freshness", label: "Venue freshness", getMetadata: () => ({ ...declared }) } : null);
17
26
  return useMemo(() => {
18
27
  if (!declared) return [];
19
- const freshness = deriveHeadlessFreshness({ shape: "rows" }, { rows: [], freshness: declared }, now);
20
- const tone = freshness.status === "stale" ? "warning" as const : "muted" as const;
28
+ const { variants, stale } = freshnessLine(declared, now);
29
+ const tone = stale ? "warning" as const : "muted" as const;
21
30
  // A footer too narrow beside its keys gives up the note before any venue's time.
22
- const [line, ...shorter] = paneStatusLineVariants(freshness).map((text) => [{ text, tone }]);
31
+ const [line, ...shorter] = variants.map((text) => [{ text, tone }]);
23
32
  return [{ id: "perp-freshness", asOf: true, parts: line!, variants: shorter }];
24
33
  }, [declared, now]);
25
34
  }
@@ -1,4 +1,7 @@
1
1
  import type { PerpBoardRow } from "../../../api-client/perps";
2
+ import type { HeadlessPaneFreshness } from "../../../types/headless";
3
+ import { readAsOne, rowReadAt } from "../../../market-data/perpetual-open-interest";
4
+ import { perpFreshness } from "./freshness";
2
5
  import { venueName } from "./model";
3
6
 
4
7
  /**
@@ -60,6 +63,41 @@ export function mergeVenueMarkets(rows: readonly PerpBoardRow[]): PerpVenueMarke
60
63
  }).sort((a, b) => deeper(a, b) || venueName(a.venue).localeCompare(venueName(b.venue)) || a.key.localeCompare(b.key));
61
64
  }
62
65
 
66
+ /**
67
+ * A venue's row with its deepest contract's newer reading (the quote stream's) laid over it: the open interest and
68
+ * volume count that reading, so they move with the mark beside them. The row itself for the reading it was made from.
69
+ */
70
+ export function withPrimaryReading(market: PerpVenueMarket, row: PerpBoardRow): PerpVenueMarket {
71
+ if (row === market.primary) return market;
72
+ const contracts = [row, ...market.contracts.slice(1)];
73
+ return { ...market, primary: row, contracts, openInterestUsd: sumOrNull(contracts.map((contract) => contract.openInterestUsd)),
74
+ volume24hUsd: sumOrNull(contracts.map((contract) => contract.volume24hUsd)) };
75
+ }
76
+
77
+ /**
78
+ * When a venue's row was read: the oldest reading among the contracts its figures are made of, each one's open
79
+ * interest by its own read, so the row is never dated newer than a figure it shows.
80
+ */
81
+ export function venueMarketReadAt(market: Pick<PerpVenueMarket, "contracts">): string {
82
+ return market.contracts.map(rowReadAt).reduce((oldest, at) => Date.parse(at) < Date.parse(oldest) ? at : oldest);
83
+ }
84
+
85
+ /**
86
+ * How current a list of venue rows is, in PERP's status line: each venue dated by its row's oldest figure, how old the
87
+ * oldest row is, and `live` only while every figure shown streams. A market streams when its deepest contract follows
88
+ * its venue's socket (`streaming`) and its open interest came with it, not from the last poll (Binance's socket carries
89
+ * none); a venue's other contracts are the last read. `refreshFailed` marks the rows off the stream stale: the last
90
+ * read failed and its saved copy is shown.
91
+ */
92
+ export function venueMarketsFreshness(markets: readonly PerpVenueMarket[], { now = Date.now(), streaming, refreshFailed = false }: {
93
+ now?: number; streaming: ReadonlySet<string>; refreshFailed?: boolean;
94
+ }): HeadlessPaneFreshness {
95
+ const streams = (market: PerpVenueMarket) => streaming.has(market.primary.marketId) && readAsOne(market.primary);
96
+ const rows = markets.map((market) => ({ venue: market.primary.venue, observedAt: venueMarketReadAt(market),
97
+ stale: market.contracts.some((contract) => contract.stale) || refreshFailed && !streams(market) }));
98
+ return perpFreshness(rows, { now, live: markets.length > 0 && markets.every((market) => streams(market) && market.contracts.length === 1) });
99
+ }
100
+
63
101
  /** A market under this share of the asset's open interest is folded behind "more". */
64
102
  const SMALL_MARKET_SHARE = 0.02;
65
103