gloomberb 0.19.4 → 0.19.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (321) hide show
  1. package/package.json +3 -1
  2. package/patches/@opentui%2Fcore@0.3.2.patch +86 -25
  3. package/src/api-client/equity-screener.ts +23 -0
  4. package/src/app/pane-runtime/index.tsx +2 -0
  5. package/src/app/pane-runtime/plugin-bindings.ts +10 -1
  6. package/src/app.tsx +63 -16
  7. package/src/cli/commands/command-utils.ts +4 -0
  8. package/src/cli/commands/market.ts +264 -33
  9. package/src/cli/commands/search.ts +22 -4
  10. package/src/cli/commands/ticker.ts +84 -39
  11. package/src/cli/currency-name-hint.ts +60 -0
  12. package/src/cli/glossary.ts +3 -3
  13. package/src/cli/history-rows.ts +18 -1
  14. package/src/cli/known-gaps.ts +25 -2
  15. package/src/cli/listing-arg.ts +12 -0
  16. package/src/cli/not-a-ticker.ts +5 -3
  17. package/src/cli/pane-functions/capabilities.ts +2 -0
  18. package/src/cli/pane-functions/catalog.ts +31 -5
  19. package/src/cli/pane-functions/function-help.ts +8 -5
  20. package/src/cli/pane-functions/headless.ts +11 -6
  21. package/src/cli/pane-functions/market-session.ts +6 -7
  22. package/src/cli/pane-functions/resolver.ts +75 -2
  23. package/src/cli/quote-answer.ts +9 -0
  24. package/src/cli/series-search.ts +4 -5
  25. package/src/cli/symbol-list.ts +54 -2
  26. package/src/cli/symbol-rows.ts +14 -2
  27. package/src/cli/ticker-resolution.ts +89 -20
  28. package/src/components/chart/composite/axis-overlays.tsx +60 -27
  29. package/src/components/chart/composite/composite-chart.tsx +118 -63
  30. package/src/components/chart/composite/cursor-source.ts +111 -0
  31. package/src/components/chart/composite/format.ts +168 -6
  32. package/src/components/chart/composite/legend.tsx +8 -4
  33. package/src/components/chart/composite/panel-bitmap.ts +28 -2
  34. package/src/components/chart/composite/panel-labels.ts +20 -1
  35. package/src/components/chart/composite/panel-surface.tsx +201 -92
  36. package/src/components/chart/composite/price-axis-labels.tsx +92 -46
  37. package/src/components/chart/composite/price-series.ts +31 -8
  38. package/src/components/chart/composite/scene.ts +154 -59
  39. package/src/components/chart/composite/series-axis-tags.tsx +4 -2
  40. package/src/components/chart/composite/time-axis.ts +30 -7
  41. package/src/components/chart/composite/time-scale.ts +211 -56
  42. package/src/components/chart/composite/types.ts +11 -1
  43. package/src/components/chart/composite/use-composite-chart-keyboard.ts +32 -12
  44. package/src/components/chart/curve/curve-surface.tsx +5 -2
  45. package/src/components/chart/curve/model.ts +4 -1
  46. package/src/components/chart/native/use-bitmap-metrics.ts +81 -0
  47. package/src/components/chart/static/series.ts +3 -0
  48. package/src/components/command-bar/commands/collection-list.ts +81 -0
  49. package/src/components/command-bar/commands/direct/index.ts +6 -0
  50. package/src/components/command-bar/commands/registry.ts +8 -0
  51. package/src/components/command-bar/layout-items/current-layout.ts +22 -1
  52. package/src/components/command-bar/layout-items/focused-pane.ts +22 -1
  53. package/src/components/command-bar/pane-templates/items.ts +19 -3
  54. package/src/components/command-bar/pane-templates/workflow.ts +5 -0
  55. package/src/components/command-bar/routes/root/results.ts +23 -3
  56. package/src/components/command-bar/routes/root/selection.ts +4 -2
  57. package/src/components/command-bar/routes/root/shortcut-feedback.ts +1 -1
  58. package/src/components/command-bar/routes/root/shortcut-items.ts +3 -4
  59. package/src/components/command-bar/routes/root/shortcuts.ts +58 -14
  60. package/src/components/command-bar/routes/root/ticker-first.ts +32 -0
  61. package/src/components/command-bar/surface/environment.ts +2 -0
  62. package/src/components/command-bar/view-model.ts +7 -0
  63. package/src/components/command-bar/workflow/ops.ts +2 -1
  64. package/src/components/command-bar/workflow/tickers.ts +20 -0
  65. package/src/components/layout/shell/active-drag.ts +38 -7
  66. package/src/components/layout/shell/drag/magnets.ts +106 -0
  67. package/src/components/layout/shell/menu.ts +15 -1
  68. package/src/components/layout/shell/pane/actions.ts +4 -0
  69. package/src/components/layout/shell/ticker-link-menu.ts +12 -3
  70. package/src/components/layout/status-bar.tsx +20 -0
  71. package/src/components/layout/window-controls.tsx +96 -35
  72. package/src/components/layout/window-fullscreen.ts +20 -0
  73. package/src/components/onboarding/onboarding-keyboard.ts +5 -1
  74. package/src/components/onboarding/onboarding-wizard.tsx +15 -4
  75. package/src/components/onboarding/portfolio-step/positions-panel.tsx +8 -5
  76. package/src/components/onboarding/use-onboarding-progress.ts +20 -1
  77. package/src/components/price-sparkline/view.tsx +14 -6
  78. package/src/components/quote-flash.ts +36 -32
  79. package/src/components/ticker/badge/index.tsx +8 -4
  80. package/src/components/ticker/badge/list.tsx +23 -7
  81. package/src/components/ui/column-grid.tsx +8 -2
  82. package/src/components/ui/data-table/opentui/model.ts +4 -1
  83. package/src/components/ui/tabs.tsx +5 -2
  84. package/src/core/state/app/layout.ts +18 -3
  85. package/src/core/state/app/state.ts +2 -0
  86. package/src/core/state/app/types.ts +5 -0
  87. package/src/data/config/layout.ts +3 -0
  88. package/src/data/config/store/normalize.ts +39 -4
  89. package/src/i18n/es.ts +10 -0
  90. package/src/i18n/ja.ts +10 -0
  91. package/src/i18n/ko.ts +10 -0
  92. package/src/i18n/zh-cn.ts +10 -0
  93. package/src/i18n/zh-tw.ts +10 -0
  94. package/src/layout/pane-manager/floating-placement.ts +7 -4
  95. package/src/layout/pane-manager/floating.ts +5 -2
  96. package/src/market-data/bond-funds.ts +19 -0
  97. package/src/market-data/coordinator/events.ts +17 -1
  98. package/src/market-data/frame-scheduler.ts +47 -10
  99. package/src/market-data/frame-wake.ts +74 -0
  100. package/src/market-data/futures-board.ts +7 -6
  101. package/src/market-data/futures-contract.ts +14 -3
  102. package/src/market-data/hooks.tsx +12 -3
  103. package/src/market-data/market/freshness.ts +18 -0
  104. package/src/market-data/market/status.ts +15 -2
  105. package/src/market-data/performance.ts +78 -9
  106. package/src/market-data/request-types.ts +6 -3
  107. package/src/plugins/builtin/alerts/cli.ts +2 -1
  108. package/src/plugins/builtin/analytics/risk-evidence.ts +1 -0
  109. package/src/plugins/builtin/attention/evidence.ts +1 -1
  110. package/src/plugins/builtin/awards/client.ts +1 -1
  111. package/src/plugins/builtin/awards/evidence.ts +1 -1
  112. package/src/plugins/builtin/awards/pane.tsx +2 -1
  113. package/src/plugins/builtin/bond-calculator/headless.ts +2 -1
  114. package/src/plugins/builtin/bond-calculator/index.tsx +1 -1
  115. package/src/plugins/builtin/bond-calculator/math.ts +1 -1
  116. package/src/plugins/builtin/bond-calculator/model.ts +14 -5
  117. package/src/plugins/builtin/bond-calculator/pane.tsx +1 -1
  118. package/src/plugins/builtin/broker-manager/footer.ts +3 -2
  119. package/src/plugins/builtin/broker-manager/index.tsx +2 -1
  120. package/src/plugins/builtin/broker-manager/keyboard.ts +2 -1
  121. package/src/plugins/builtin/buildout/cells.tsx +25 -45
  122. package/src/plugins/builtin/buildout/detail/company.tsx +3 -3
  123. package/src/plugins/builtin/buildout/detail/index.tsx +1 -1
  124. package/src/plugins/builtin/buildout/detail/intel.tsx +4 -7
  125. package/src/plugins/builtin/buildout/detail/site.tsx +4 -4
  126. package/src/plugins/builtin/buildout/detail/ui.tsx +39 -38
  127. package/src/plugins/builtin/buildout/format.ts +23 -1
  128. package/src/plugins/builtin/buildout/model/types.ts +1 -0
  129. package/src/plugins/builtin/buildout/pane/index.tsx +2 -8
  130. package/src/plugins/builtin/buildout/table-model.ts +12 -4
  131. package/src/plugins/builtin/catalysts/evidence.ts +1 -1
  132. package/src/plugins/builtin/catalysts/pane.tsx +2 -1
  133. package/src/plugins/builtin/cds/headless.ts +1 -0
  134. package/src/plugins/builtin/cds/index.tsx +1 -1
  135. package/src/plugins/builtin/chart-composer/headless.ts +40 -1
  136. package/src/plugins/builtin/cloud/plugin.tsx +2 -0
  137. package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +28 -3
  138. package/src/plugins/builtin/cloud-tweets/table.tsx +3 -2
  139. package/src/plugins/builtin/comment-letters/client.ts +2 -1
  140. package/src/plugins/builtin/company-kpis/client.ts +1 -1
  141. package/src/plugins/builtin/company-kpis/pane.tsx +2 -1
  142. package/src/plugins/builtin/company-kpis/screenshot-evidence.ts +3 -2
  143. package/src/plugins/builtin/correlation/headless.ts +3 -2
  144. package/src/plugins/builtin/cot/headless.ts +9 -3
  145. package/src/plugins/builtin/cot/model.ts +44 -3
  146. package/src/plugins/builtin/credit-documents/client.ts +1 -1
  147. package/src/plugins/builtin/credit-documents/evidence.ts +1 -1
  148. package/src/plugins/builtin/credit-documents/pane.tsx +2 -1
  149. package/src/plugins/builtin/crypto-board/pane.tsx +5 -4
  150. package/src/plugins/builtin/debt-maturities/headless.ts +11 -2
  151. package/src/plugins/builtin/debt-maturities/model.ts +66 -0
  152. package/src/plugins/builtin/debt-maturities/pane.tsx +23 -4
  153. package/src/plugins/builtin/earnings-calls/pane.tsx +1 -1
  154. package/src/plugins/builtin/earnings-ripple/index.tsx +6 -1
  155. package/src/plugins/builtin/earnings-ripple/pane.tsx +1 -1
  156. package/src/plugins/builtin/econ/calendar-model.ts +30 -6
  157. package/src/plugins/builtin/econ/fred-catalog.ts +5 -5
  158. package/src/plugins/builtin/econ/print-watch.ts +3 -1
  159. package/src/plugins/builtin/equity-screener/client.ts +1 -1
  160. package/src/plugins/builtin/equity-screener/criterion-editor.tsx +4 -16
  161. package/src/plugins/builtin/equity-screener/headless.ts +4 -2
  162. package/src/plugins/builtin/equity-screener/ideas.ts +67 -3
  163. package/src/plugins/builtin/equity-screener/model.ts +180 -12
  164. package/src/plugins/builtin/equity-screener/pane.tsx +52 -12
  165. package/src/plugins/builtin/equity-screener/screen-check.ts +7 -4
  166. package/src/plugins/builtin/equity-screener/watchlist.ts +33 -0
  167. package/src/plugins/builtin/futures/series.ts +16 -1
  168. package/src/plugins/builtin/futures-curve/client.ts +19 -0
  169. package/src/plugins/builtin/futures-curve/headless.ts +52 -13
  170. package/src/plugins/builtin/futures-curve/index.tsx +1 -1
  171. package/src/plugins/builtin/futures-curve/model.ts +77 -6
  172. package/src/plugins/builtin/futures-curve/pane.tsx +19 -3
  173. package/src/plugins/builtin/fx-matrix/headless.ts +4 -2
  174. package/src/plugins/builtin/fx-matrix/index.tsx +37 -3
  175. package/src/plugins/builtin/fx-matrix/pairs.ts +15 -0
  176. package/src/plugins/builtin/gpu/headless.ts +2 -1
  177. package/src/plugins/builtin/help/function-card.tsx +2 -1
  178. package/src/plugins/builtin/help/index.tsx +2 -1
  179. package/src/plugins/builtin/insider/display.ts +45 -6
  180. package/src/plugins/builtin/ipo-calendar/model.ts +2 -0
  181. package/src/plugins/builtin/iv-history/client.ts +2 -1
  182. package/src/plugins/builtin/iv-history/headless.ts +2 -1
  183. package/src/plugins/builtin/jobs/pages.ts +4 -4
  184. package/src/plugins/builtin/kelly-sizer/headless.ts +2 -1
  185. package/src/plugins/builtin/macro-day/client.ts +41 -0
  186. package/src/plugins/builtin/macro-day/headless.ts +19 -9
  187. package/src/plugins/builtin/macro-day/model.ts +3 -1
  188. package/src/plugins/builtin/market-heatmap/index.tsx +2 -1
  189. package/src/plugins/builtin/market-movers/index.tsx +4 -3
  190. package/src/plugins/builtin/members/client.ts +1 -1
  191. package/src/plugins/builtin/mna/distress/client.ts +1 -0
  192. package/src/plugins/builtin/mna/distress/headless.ts +1 -0
  193. package/src/plugins/builtin/mna/pane.tsx +4 -1
  194. package/src/plugins/builtin/options/market-reference.ts +1 -1
  195. package/src/plugins/builtin/options/open-interest-as-of.ts +3 -1
  196. package/src/plugins/builtin/options/view.tsx +2 -1
  197. package/src/plugins/builtin/options-calculator/evidence.ts +1 -1
  198. package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +1 -1
  199. package/src/plugins/builtin/options-scenario/csp-screen.ts +8 -4
  200. package/src/plugins/builtin/options-scenario/csp.ts +28 -9
  201. package/src/plugins/builtin/options-scenario/evidence.ts +5 -4
  202. package/src/plugins/builtin/options-scenario/pane.tsx +2 -1
  203. package/src/plugins/builtin/perps/client.ts +1 -1
  204. package/src/plugins/builtin/perps/pane.tsx +3 -1
  205. package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +17 -0
  206. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +2 -1
  207. package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +4 -2
  208. package/src/plugins/builtin/portfolio-list/pane/index.tsx +7 -3
  209. package/src/plugins/builtin/portfolio-list/use-throttled-memo.ts +10 -19
  210. package/src/plugins/builtin/rate-path/headless.ts +24 -10
  211. package/src/plugins/builtin/research/analyst-model.ts +1 -0
  212. package/src/plugins/builtin/research/equity-diagnostic-pane.tsx +2 -1
  213. package/src/plugins/builtin/research/event-model.ts +10 -3
  214. package/src/plugins/builtin/research/events-headless.ts +20 -2
  215. package/src/plugins/builtin/research/index.tsx +1 -0
  216. package/src/plugins/builtin/research/relative-valuation-currency.ts +1 -1
  217. package/src/plugins/builtin/research/relative-valuation-peers.ts +2 -1
  218. package/src/plugins/builtin/research-search/command-bar-search.ts +3 -1
  219. package/src/plugins/builtin/research-search/snippet.ts +1 -0
  220. package/src/plugins/builtin/revenue-breakdown/client.ts +3 -2
  221. package/src/plugins/builtin/seasonality/headless.ts +2 -1
  222. package/src/plugins/builtin/sec/command-bar-search.ts +3 -2
  223. package/src/plugins/builtin/sec/fund-facts.ts +17 -1
  224. package/src/plugins/builtin/sec/index.tsx +8 -5
  225. package/src/plugins/builtin/sec/row-summaries.ts +28 -12
  226. package/src/plugins/builtin/shared/members-menu.tsx +103 -38
  227. package/src/plugins/builtin/short-interest/publications-model.ts +22 -1
  228. package/src/plugins/builtin/short-interest/publications-pane.tsx +13 -4
  229. package/src/plugins/builtin/short-interest/watch-client.ts +2 -1
  230. package/src/plugins/builtin/short-interest/watch-model.ts +1 -1
  231. package/src/plugins/builtin/social-mentions/client.ts +2 -1
  232. package/src/plugins/builtin/supply-chain/client.ts +1 -1
  233. package/src/plugins/builtin/supply-chain/evidence.ts +1 -1
  234. package/src/plugins/builtin/supply-chain/graph-pane.tsx +2 -1
  235. package/src/plugins/builtin/supply-chain/pane.tsx +2 -1
  236. package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +1 -1
  237. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +24 -4
  238. package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +1 -1
  239. package/src/plugins/builtin/time-sales/client.ts +1 -0
  240. package/src/plugins/builtin/time-sales/pane.tsx +3 -2
  241. package/src/plugins/builtin/trace-bonds/client.ts +7 -4
  242. package/src/plugins/builtin/trace-bonds/index.tsx +1 -1
  243. package/src/plugins/builtin/vol-surface/client.ts +2 -1
  244. package/src/plugins/builtin/volatility/client.ts +6 -1
  245. package/src/plugins/builtin/volatility/headless.ts +0 -1
  246. package/src/plugins/builtin/yield-curve/curves.ts +15 -0
  247. package/src/plugins/builtin/yield-curve/headless.ts +9 -2
  248. package/src/plugins/builtin/yield-curve/index.tsx +5 -8
  249. package/src/plugins/host-modules.ts +22 -3
  250. package/src/plugins/host-smoke.ts +6 -3
  251. package/src/portfolio/collection-name.ts +19 -0
  252. package/src/portfolio/column-values.ts +76 -10
  253. package/src/renderers/browser/http-proxy-transport.ts +78 -8
  254. package/src/renderers/cloudflare/http-proxy.ts +13 -2
  255. package/src/renderers/cloudflare/proxy-session.ts +47 -24
  256. package/src/renderers/cloudflare/worker.ts +15 -2
  257. package/src/renderers/desktop/geometry.ts +279 -0
  258. package/src/renderers/desktop/screen-setup.ts +246 -0
  259. package/src/renderers/desktop/sequential-window-host.ts +179 -0
  260. package/src/renderers/desktop/test-utils.ts +71 -0
  261. package/src/renderers/desktop/window-controller.ts +433 -0
  262. package/src/renderers/desktop/window-host.ts +70 -0
  263. package/src/renderers/desktop/window-layouts.ts +630 -0
  264. package/src/renderers/dom/data-frames.ts +15 -4
  265. package/src/renderers/dom/host/box.tsx +204 -176
  266. package/src/renderers/dom/host/style.ts +49 -20
  267. package/src/renderers/dom/host/text.tsx +3 -2
  268. package/src/renderers/electrobun/bun/application-menu/click.ts +1 -0
  269. package/src/renderers/electrobun/bun/application-menu/index.ts +4 -1
  270. package/src/renderers/electrobun/bun/desktop/backend-requests.ts +19 -8
  271. package/src/renderers/electrobun/bun/desktop/backend.ts +322 -19
  272. package/src/renderers/electrobun/bun/desktop/detached-windows.ts +83 -61
  273. package/src/renderers/electrobun/bun/desktop/host-requests.ts +29 -15
  274. package/src/renderers/electrobun/bun/desktop/initialization.ts +30 -11
  275. package/src/renderers/electrobun/bun/desktop/relaunch.ts +9 -1
  276. package/src/renderers/electrobun/bun/desktop/screen-setup-file.ts +55 -0
  277. package/src/renderers/electrobun/bun/desktop/state-broadcaster.ts +44 -8
  278. package/src/renderers/electrobun/bun/desktop/windows-script.ts +9 -6
  279. package/src/renderers/electrobun/bun/desktop/workspace/index.ts +298 -97
  280. package/src/renderers/electrobun/bun/desktop/workspace/requests.ts +44 -6
  281. package/src/renderers/electrobun/bun/index.ts +4 -97
  282. package/src/renderers/electrobun/bun/window/electrobun-window-host.ts +306 -0
  283. package/src/renderers/electrobun/bun/window/focus.ts +0 -25
  284. package/src/renderers/electrobun/bun/window/remembered-frame.ts +4 -82
  285. package/src/renderers/electrobun/bun/window/windows-native.ts +26 -1
  286. package/src/renderers/electrobun/shared/protocol.ts +50 -2
  287. package/src/renderers/electrobun/view/backend-rpc.ts +15 -0
  288. package/src/renderers/electrobun/view/desktop/window/bridge.ts +63 -3
  289. package/src/renderers/electrobun/view/main.tsx +13 -7
  290. package/src/renderers/electrobun/view/ui-host.tsx +7 -0
  291. package/src/renderers/electrobun/view/window-fullscreen.ts +10 -3
  292. package/src/series/fred-argument.ts +17 -0
  293. package/src/sources/provider-router/financial-routes.ts +7 -1
  294. package/src/sources/provider-router/index.ts +7 -1
  295. package/src/state/app/context/index.tsx +16 -2
  296. package/src/state/desktop-windows.ts +63 -0
  297. package/src/sync/other-window-tabs.ts +62 -0
  298. package/src/tickers/company-name-listing.ts +23 -3
  299. package/src/tickers/listing-fate.ts +147 -1
  300. package/src/tickers/terminal-codes.ts +5 -0
  301. package/src/time-series/price-units.ts +11 -0
  302. package/src/time-series/types.ts +6 -0
  303. package/src/types/config.ts +10 -1
  304. package/src/types/desktop-window.ts +71 -2
  305. package/src/types/financials.ts +4 -0
  306. package/src/types/headless.ts +19 -0
  307. package/src/types/plugin.ts +6 -0
  308. package/src/ui/host.tsx +2 -0
  309. package/src/ui/index.tsx +14 -13
  310. package/src/ui/same-props.ts +58 -0
  311. package/src/utils/cli-output.ts +33 -4
  312. package/src/utils/currency-names.ts +20 -0
  313. package/src/utils/currency-pair.ts +6 -0
  314. package/src/utils/exchange-rate-snapshot.ts +20 -2
  315. package/src/utils/format.ts +7 -2
  316. package/src/utils/futures-generic.ts +12 -0
  317. package/src/utils/fx-market-hours.ts +43 -0
  318. package/src/utils/http-proxy-upstream.ts +6 -2
  319. package/src/utils/plugin-proxy-hosts.json +0 -4
  320. package/src/utils/plugin-proxy-hosts.ts +22 -0
  321. package/src/utils/sec-filings.ts +7 -1
@@ -3,12 +3,16 @@ import {
3
3
  DIVIDEND_FIELDS,
4
4
  HIRING_APP_FIELDS,
5
5
  CATEGORY_FIELDS,
6
+ GRADE_FIELDS,
7
+ LETTER_GRADE_FIELDS,
6
8
  NUMERIC_FIELDS,
7
9
  OPTION_VOLATILITY_FIELDS,
8
10
  OWNERSHIP_FIELDS,
9
11
  QUALITY_FIELDS,
10
12
  RESEARCH_FIELDS,
11
13
  KPI_FIELDS,
14
+ MEMBERSHIP_FIELDS,
15
+ SCORE_FIELDS,
12
16
  SOCIAL_FIELDS,
13
17
  TECHNICAL_FIELDS,
14
18
  VOLATILITY_FIELDS,
@@ -137,6 +141,31 @@ export const SHORT_LABELS: Record<NumericField, string> = {
137
141
  epsCagr5YPercent: "EPS CAGR 5Y%",
138
142
  forwardRevenueGrowthPercent: "FWD REV GR%",
139
143
  forwardEpsGrowthPercent: "FWD EPS GR%",
144
+ piotroskiFScore: "F-SCORE",
145
+ altmanZScore: "ALTMAN Z",
146
+ grahamNumber: "GRAHAM #",
147
+ grahamUpsidePercent: "GRAHAM UPS%",
148
+ lynchFairValue: "LYNCH FV",
149
+ lynchUpsidePercent: "LYNCH UPS%",
150
+ earningsYieldPercent: "EBIT/EV%",
151
+ returnOnCapitalPercent: "ROC%",
152
+ magicFormulaRank: "MAGIC RANK",
153
+ totalReturn1YPercent: "1Y TR%",
154
+ rsRating: "RS RATING",
155
+ profitableYears: "PROFIT YRS",
156
+ revenueGrowthYears: "REV GR YRS",
157
+ dividendGrowthYears: "DIV GR YRS",
158
+ sp500Member: "S&P 500",
159
+ dowMember: "DOW",
160
+ // Letter grades, F to A+, and the composite with its label.
161
+ valueGrade: "VALUE",
162
+ growthGrade: "GROWTH",
163
+ profitabilityGrade: "PROFIT",
164
+ momentumGrade: "MOMENTUM",
165
+ revisionsGrade: "REVISIONS",
166
+ gradeComposite: "COMPOSITE",
167
+ nextYearEpsRevision30dPercent: "NXT EPS REV%",
168
+ revenueRevision30dPercent: "REVENUE REV%",
140
169
  hiringOpenRoles: "OPEN ROLES",
141
170
  hiringNetAddsWeek: "NET ROLES/WK",
142
171
  hiringRemotePercent: "REMOTE%",
@@ -161,14 +190,51 @@ const SIGNED = new Set<NumericField>(["hiringNetAddsWeek", "hiringZScore", "appR
161
190
  "iv30Change1d", "iv30Change5d",
162
191
  "revenueCagr3YPercent", "revenueCagr5YPercent", "epsCagr3YPercent", "epsCagr5YPercent",
163
192
  "forwardRevenueGrowthPercent", "forwardEpsGrowthPercent",
193
+ "totalReturn1YPercent", "grahamUpsidePercent", "lynchUpsidePercent",
194
+ "nextYearEpsRevision30dPercent", "revenueRevision30dPercent",
164
195
  ]);
165
- /** Moves whose sign is the news: they take the sign colour. */
196
+ /** Moves whose sign is the news: they take the sign colour. A fair value's upside reads as the analysts' does. */
166
197
  export const SIGN_COLORED = new Set<NumericField>(["changePercent", ...RETURNS, "epsRevision30dPercent", "analystUpsidePercent",
167
- "priceVsSma20Percent", "priceVsSma50Percent", "priceVsSma200Percent"]);
198
+ "priceVsSma20Percent", "priceVsSma50Percent", "priceVsSma200Percent",
199
+ "totalReturn1YPercent", "grahamUpsidePercent", "lynchUpsidePercent",
200
+ "nextYearEpsRevision30dPercent", "revenueRevision30dPercent"]);
201
+ const LETTER_GRADES = new Set<NumericField>(LETTER_GRADE_FIELDS);
202
+ /** Fields that print as a grade, a letter or the composite with its label, never as a number and a unit. */
203
+ export const GRADE_DISPLAY_FIELDS: ReadonlySet<string> = new Set<string>([...LETTER_GRADE_FIELDS, "gradeComposite"]);
204
+ /** A grade's letter by its value: 1 is F, 13 is A+. */
205
+ const GRADE_LETTERS = ["F", "D-", "D", "D+", "C-", "C", "C+", "B-", "B", "B+", "A-", "A", "A+"] as const;
206
+ /** The composite's labels from the score each starts at: its nearest whole number. */
207
+ const COMPOSITE_BANDS = [
208
+ { from: 4.5, label: "Top" },
209
+ { from: 3.5, label: "Strong" },
210
+ { from: 2.5, label: "Neutral" },
211
+ { from: 1.5, label: "Weak" },
212
+ { from: 1, label: "Bottom" },
213
+ ] as const;
214
+ const gradeLetter = (value: number): string | null =>
215
+ Number.isInteger(value) ? GRADE_LETTERS[value - 1] ?? null : null;
216
+ const compositeLabel = (score: number): string =>
217
+ (COMPOSITE_BANDS.find((band) => score >= band.from) ?? COMPOSITE_BANDS.at(-1)!).label;
218
+ /**
219
+ * The number a cell's sign colour reads, or null for a field without one: a move is its own sign, and a grade the side
220
+ * of the middle it falls on, B- and up above it and D+ and down below, Strong and Top above the composite's middle and
221
+ * Weak and Bottom below. So every grade reads in the colours a move does, in every view that shows it.
222
+ */
223
+ export function screenSignValue(field: NumericField, value: number | null): number | null {
224
+ if (value == null || !Number.isFinite(value)) return null;
225
+ if (SIGN_COLORED.has(field)) return Math.abs(value) < 0.05 ? 0 : value;
226
+ if (LETTER_GRADES.has(field)) return value >= 8 ? 1 : value <= 4 ? -1 : 0;
227
+ if (field === "gradeComposite") return value >= 3.5 ? 1 : value < 2.5 ? -1 : 0;
228
+ return null;
229
+ }
168
230
  const COUNTS = new Set<NumericField>(["appRatingCountGrowth7d", "hiringNetAddsWeek", "hiringOpenRoles", "attentionResearchUnits", "insiderPurchases90d", "insiderSales90d", "institutionalHolders", "institutionalNewHolders", "institutionalExits", "ivRank", "ivPercentile", "hvRank",
169
231
  "macdBullishCrossDays", "macdBearishCrossDays", "goldenCrossDays", "deathCrossDays",
170
- "newHigh20dDays", "newLow20dDays", "newHigh52wDays", "newLow52wDays", "bollingerWidthPercentile"]);
171
- const MONETARY = new Set<NumericField>(["price", "marketCap", "kpiArr", "kpiRpo", "kpiCrpo", "kpiGmv", "kpiBacklog"]);
232
+ "newHigh20dDays", "newLow20dDays", "newHigh52wDays", "newLow52wDays", "bollingerWidthPercentile",
233
+ "piotroskiFScore", "magicFormulaRank", "rsRating", "profitableYears", "revenueGrowthYears", "dividendGrowthYears"]);
234
+ const MONETARY = new Set<NumericField>(["price", "marketCap", "kpiArr", "kpiRpo", "kpiCrpo", "kpiGmv", "kpiBacklog", "grahamNumber", "lynchFairValue"]);
235
+ /** Prices and scores read to two decimals, as the quote and beta are. */
236
+ const HUNDREDTHS = new Set<NumericField>(["price", "beta", "altmanZScore", "grahamNumber", "lynchFairValue"]);
237
+ const MEMBERSHIP = new Set<NumericField>(MEMBERSHIP_FIELDS);
172
238
  /** Shown after the screen's own criteria when the pane has room. */
173
239
  const CONTEXT_FIELDS: NumericField[] = ["marketCap", "price", "changePercent", "trailingPE", "revenueGrowthPercent", "operatingMarginPercent", "dividendYieldPercent"];
174
240
 
@@ -178,7 +244,10 @@ export function formatScreenValue(field: NumericField, value: number | null): st
178
244
  if (DAILY_COUNTS.has(field)) return value < 1_000 ? value.toFixed(0) : formatCompact(value, { fixedDecimals: true });
179
245
  if (RATIOS.has(field)) return `${value.toFixed(1)}x`;
180
246
  if (COUNTS.has(field)) return formatNumber(value, 0);
181
- if (field === "price" || field === "beta") return formatNumber(value, 2);
247
+ if (MEMBERSHIP.has(field)) return value === 1 ? "Yes" : "No";
248
+ if (LETTER_GRADES.has(field)) return gradeLetter(value) ?? "--";
249
+ if (field === "gradeComposite") return `${formatNumber(value, 2)} ${compositeLabel(value)}`;
250
+ if (HUNDREDTHS.has(field)) return formatNumber(value, 2);
182
251
  // A value that rounds to zero prints 0.0, never -0.0.
183
252
  const fixed = Math.abs(value) < 0.05 ? "0.0" : formatNumber(value, 1);
184
253
  return SIGNED.has(field) && value > 0 && fixed !== "0.0" ? `+${fixed}` : fixed;
@@ -189,6 +258,36 @@ export function formatScreenMetric(field: NumericField, metric: Pick<ScreenMetri
189
258
  return metric.value == null && metric.notMeaningful ? formatPriceEarnings(NOT_MEANINGFUL) : formatScreenValue(field, metric.value);
190
259
  }
191
260
 
261
+ /** A metric as a company's detail prints it: with its unit, but a grade or the composite reads as itself (B+, 4.72 Top). */
262
+ export function screenDetailValue(field: NumericField, metric: Pick<ScreenMetric, "value" | "notMeaningful" | "unit">): string {
263
+ // A missing value is just "--", without the unit it would have had; N/M says so.
264
+ if (metric.value == null) return metric.notMeaningful ? formatScreenMetric(field, metric) : formatScreenValue(field, null);
265
+ const text = formatScreenValue(field, metric.value);
266
+ if (GRADE_DISPLAY_FIELDS.has(field)) return text;
267
+ // A count of one is singular: 1 year, 1 day.
268
+ const unit = metric.value === 1 && COUNT_UNITS.has(metric.unit) ? metric.unit.slice(0, -1) : metric.unit;
269
+ return unit ? `${text} ${unit}` : text;
270
+ }
271
+ const COUNT_UNITS: ReadonlySet<string> = new Set(["years", "days", "sessions", "weeks", "months"]);
272
+
273
+ /** The note a grade on a company's other line leads with, naming the line it was graded on (the server's text). */
274
+ const COMPANY_NOTE = /^One company with \S+, its primary line: graded once, on that line's figures\.\s*/;
275
+ /**
276
+ * A grade's reason split into the company note, which every grade of the line repeats and the detail says once, and
277
+ * what is this grade's own (its peers, an N/M or stale input), null when nothing is left.
278
+ */
279
+ export function splitGradeReason(reason: string | null): { company: string | null; own: string | null } {
280
+ const match = reason == null ? null : COMPANY_NOTE.exec(reason);
281
+ if (!match) return { company: null, own: reason };
282
+ return { company: match[0].trim(), own: reason!.slice(match[0].length).trim() || null };
283
+ }
284
+
285
+ /** Where a grade ranks, from its source without the letter it leads with: `percentile 82.4 among 412 Technology listings, from ...`. */
286
+ export function gradeRankText(metric: Pick<ScreenMetric, "source">): string | null {
287
+ const text = metric.source?.replace(/^[^:]{1,12}:\s*/, "").trim();
288
+ return text ? text : null;
289
+ }
290
+
192
291
  /**
193
292
  * A row's dividend yield basis, in the words `ticker` and `DVD` use. Gloom
194
293
  * Cloud serves each row's statistics yield as it is stated, forward for most
@@ -254,8 +353,9 @@ export function screenColumnLabel(field: NumericField, ytdBase: string | null, f
254
353
  return form === "compact" ? `YTD% ${ytdBase}` : `YTD% vs ${ytdBase}${form === "report" ? " close" : ""}`;
255
354
  }
256
355
 
257
- /** Prices get room for a separated six-figure quote (757,398.00). */
258
- export const columnWidth = (field: NumericField, label = SHORT_LABELS[field]) => Math.max(field === "price" ? 10 : 8, label.length);
356
+ /** Prices get room for a separated six-figure quote (757,398.00), the composite for its label (3.36 Neutral). */
357
+ export const columnWidth = (field: NumericField, label = SHORT_LABELS[field]) =>
358
+ Math.max(field === "price" ? 10 : field === "gradeComposite" ? 12 : 8, label.length);
259
359
 
260
360
  export const DEFAULT_SCREEN: ScreenDefinition = {
261
361
  version: 1,
@@ -393,6 +493,30 @@ export const screenLabel = (field: string) =>
393
493
  epsCagr5YPercent: "EPS CAGR 5Y %",
394
494
  forwardRevenueGrowthPercent: "Forward revenue growth %",
395
495
  forwardEpsGrowthPercent: "Forward EPS growth %",
496
+ piotroskiFScore: "Piotroski F-score",
497
+ altmanZScore: "Altman Z-score",
498
+ grahamNumber: "Graham number",
499
+ grahamUpsidePercent: "Graham number upside %",
500
+ lynchFairValue: "Lynch fair value",
501
+ lynchUpsidePercent: "Lynch fair value upside %",
502
+ earningsYieldPercent: "Earnings yield (EBIT / EV) %",
503
+ returnOnCapitalPercent: "Return on capital (Greenblatt) %",
504
+ magicFormulaRank: "Magic Formula rank",
505
+ totalReturn1YPercent: "1Y total return %",
506
+ rsRating: "RS rating",
507
+ profitableYears: "Profitable years",
508
+ revenueGrowthYears: "Revenue growth years",
509
+ dividendGrowthYears: "Dividend growth years",
510
+ sp500Member: "S&P 500 member",
511
+ dowMember: "Dow member",
512
+ valueGrade: "Value grade",
513
+ growthGrade: "Growth grade",
514
+ profitabilityGrade: "Profitability grade",
515
+ momentumGrade: "Momentum grade",
516
+ revisionsGrade: "Revisions grade",
517
+ gradeComposite: "Grade composite",
518
+ nextYearEpsRevision30dPercent: "Next FY EPS revision 30D %",
519
+ revenueRevision30dPercent: "Revenue revision 30D %",
396
520
  hiringOpenRoles: "Hiring open roles",
397
521
  hiringNetAddsWeek: "Net open roles per week",
398
522
  hiringRemotePercent: "Remote roles %",
@@ -431,9 +555,11 @@ export function parseCriterion(
431
555
  value: values,
432
556
  };
433
557
  }
434
- const values = text.split(",").map(parseThreshold);
558
+ const values = text.split(",").map((part) => parseGradeThreshold(field.id, part) ?? parseThreshold(part));
435
559
  if (values.some((value) => value === null))
436
- throw new Error("Enter a finite numeric threshold, such as 25 or 10B.");
560
+ throw new Error(LETTER_GRADES.has(field.id as NumericField)
561
+ ? "Enter a grade from F to A+, such as B+."
562
+ : "Enter a finite numeric threshold, such as 25 or 10B.");
437
563
  if (operator === "between") {
438
564
  if (values.length !== 2 || Number(values[0]) > Number(values[1]))
439
565
  throw new Error("Enter minimum, maximum in ascending order.");
@@ -454,6 +580,34 @@ export function parseCriterion(
454
580
  value: Number(values[0]),
455
581
  };
456
582
  }
583
+ /** A grade typed as its letter (`b+`, `A`), or the composite as its label (`Strong` is 3.5); null for anything else. */
584
+ function parseGradeThreshold(field: string, text: string): number | null {
585
+ const typed = text.trim().toUpperCase();
586
+ if (LETTER_GRADES.has(field as NumericField)) {
587
+ const index = (GRADE_LETTERS as readonly string[]).indexOf(typed);
588
+ return index >= 0 ? index + 1 : null;
589
+ }
590
+ if (field === "gradeComposite") return COMPOSITE_BANDS.find((band) => band.label.toUpperCase() === typed)?.from ?? null;
591
+ return null;
592
+ }
593
+ /** A criterion's value as the editor shows it: a grade as its letter, a range as `min, max`. */
594
+ export function criterionInputText(criterion: ScreenCriterion | null): string {
595
+ if (!criterion || !("value" in criterion)) return "";
596
+ const shown = (value: string | number) => typeof value === "number" && LETTER_GRADES.has(criterion.field as NumericField)
597
+ ? gradeLetter(value) ?? String(value) : String(value);
598
+ return Array.isArray(criterion.value) ? criterion.value.map(shown).join(", ") : shown(criterion.value);
599
+ }
600
+ /** What the value field asks for: the grade's range for a grade, else the field's unit. */
601
+ export function criterionValueLabel(field: Pick<ScreenFieldDefinition, "id" | "unit">): string {
602
+ const unit = LETTER_GRADES.has(field.id as NumericField) ? "F to A+" : field.unit;
603
+ return `Value${unit ? ` (${unit})` : ""}`;
604
+ }
605
+ /** An example value: a letter for a grade, a score or label for the composite. */
606
+ export function criterionValueHint(field: Pick<ScreenFieldDefinition, "id">, operator: ScreenOperator): string {
607
+ if (LETTER_GRADES.has(field.id as NumericField)) return operator === "between" ? "lowest, highest grade, e.g. B, A+" : "grade, e.g. B+";
608
+ if (field.id === "gradeComposite") return operator === "between" ? "minimum, maximum, e.g. 3.5, 5" : "score or label, e.g. 3.5 or Strong";
609
+ return operator === "between" ? "minimum, maximum" : operator === "in" ? "comma-separated values" : "threshold, e.g. 25 or 10B";
610
+ }
457
611
  const SCALE: Record<string, number> = { k: 1e3, m: 1e6, b: 1e9, t: 1e12 };
458
612
  /** A plain number or one with a k/M/B/T scale suffix: 25, -0.5, 1e6, 10B. */
459
613
  export function parseThreshold(text: string): number | null {
@@ -479,6 +633,15 @@ export function criterionText(criterion: ScreenCriterion): string {
479
633
  };
480
634
  const value = !("value" in criterion)
481
635
  ? ""
636
+ // Membership is 1 or 0: `S&P 500 member = yes`.
637
+ : MEMBERSHIP.has(criterion.field as NumericField) && typeof criterion.value === "number" && [0, 1].includes(criterion.value)
638
+ ? ` ${criterion.value === 1 ? "yes" : "no"}`
639
+ // A grade reads as its letter: `Value grade >= B+`.
640
+ : LETTER_GRADES.has(criterion.field as NumericField)
641
+ ? ` ${criterionInputText(criterion)}`
642
+ // The composite names the label a threshold starts: `Grade composite >= 4.5 (Top)`.
643
+ : criterion.field === "gradeComposite" && typeof criterion.value === "number"
644
+ ? ` ${thresholdText(criterion.value)}${COMPOSITE_BANDS.some((band) => band.from === criterion.value && band.from > 1) ? ` (${compositeLabel(criterion.value)})` : ""}`
482
645
  : Array.isArray(criterion.value)
483
646
  ? ` ${criterion.value.map((item) => (typeof item === "number" ? thresholdText(item) : item)).join(", ")}`
484
647
  : ` ${thresholdText(criterion.value)}`;
@@ -488,6 +651,8 @@ export function criterionText(criterion: ScreenCriterion): string {
488
651
  const OBSERVED_SUBSET_FIELDS: readonly string[] = ["insiderPurchases90d", "insiderSales90d"];
489
652
  const NUMERIC_OPERATORS: ScreenOperator[] = ["gte", "lte", "gt", "lt", "eq", "between", "present", "missing"];
490
653
  const OBSERVED_SUBSET_OPERATORS: ScreenOperator[] = ["gte", "gt", "present", "missing"];
654
+ /** Index membership is 1 or 0: equal to one, or there or not. */
655
+ const MEMBERSHIP_OPERATORS: ScreenOperator[] = ["eq", "present", "missing"];
491
656
  const CATEGORY_OPERATORS: ScreenOperator[] = ["in", "present", "missing"];
492
657
 
493
658
  /**
@@ -513,6 +678,7 @@ function unknownFieldText(field: unknown): string {
513
678
  /** The operators a definition may use on a field, or null for a field screens do not have. */
514
679
  function screenFieldOperators(field: string): ScreenOperator[] | null {
515
680
  if (OBSERVED_SUBSET_FIELDS.includes(field)) return [...OBSERVED_SUBSET_OPERATORS];
681
+ if ((MEMBERSHIP_FIELDS as readonly string[]).includes(field)) return [...MEMBERSHIP_OPERATORS];
516
682
  if ((NUMERIC_FIELDS as readonly string[]).includes(field)) return [...NUMERIC_OPERATORS];
517
683
  if ((CATEGORY_FIELDS as readonly string[]).includes(field)) return [...CATEGORY_OPERATORS];
518
684
  return null;
@@ -530,6 +696,8 @@ export function screenDefinitionSyntax(): string {
530
696
  `Operators by field: numeric fields (the --metric values) take ${single.join(", ")} with one number,`,
531
697
  "between with [min, max], present and missing with no value;",
532
698
  `${OBSERVED_SUBSET_FIELDS.join(" and ")} take only ${OBSERVED_SUBSET_OPERATORS.join(", ")};`,
699
+ `${MEMBERSHIP_FIELDS.join(" and ")} take only ${MEMBERSHIP_OPERATORS.join(", ")}, eq with 1 for a member or 0;`,
700
+ `the grades (${LETTER_GRADE_FIELDS.join(", ")}) are numbers from 1 (F) to 13 (A+), so B+ or better is gte 10, and gradeComposite runs from 1 to 5 (4.5 and up is Top);`,
533
701
  `category fields (${CATEGORY_FIELDS.join(", ")}) take in with an array of 1-25 names, present, missing.`,
534
702
  ].join(" ");
535
703
  }
@@ -706,9 +874,9 @@ export function validateScreenPayload(value: unknown): ScreenPayload {
706
874
  throw new Error("Invalid screener listing identity.");
707
875
  ids.add(screenRowId(row));
708
876
  for (const field of NUMERIC_FIELDS) {
709
- // A server from before social, research, volatility, dividend, technical, option volatility, ownership or quality
710
- // fields omits them; they read as unavailable. A Pro field it left out was held back from this caller.
711
- if (!row.metrics[field] && ([...SOCIAL_FIELDS, ...RESEARCH_FIELDS, ...VOLATILITY_FIELDS, ...TECHNICAL_FIELDS, ...OPTION_VOLATILITY_FIELDS, ...OWNERSHIP_FIELDS, ...QUALITY_FIELDS, ...ATTENTION_FIELDS, ...HIRING_APP_FIELDS, ...KPI_FIELDS, ...DIVIDEND_FIELDS] as readonly string[]).includes(field))
877
+ // A server from before social, research, volatility, dividend, technical, option volatility, ownership, quality,
878
+ // score or grade fields omits them; they read as unavailable. A Pro field it left out was held back from this caller.
879
+ if (!row.metrics[field] && ([...SOCIAL_FIELDS, ...RESEARCH_FIELDS, ...VOLATILITY_FIELDS, ...TECHNICAL_FIELDS, ...OPTION_VOLATILITY_FIELDS, ...OWNERSHIP_FIELDS, ...QUALITY_FIELDS, ...SCORE_FIELDS, ...GRADE_FIELDS, ...ATTENTION_FIELDS, ...HIRING_APP_FIELDS, ...KPI_FIELDS, ...DIVIDEND_FIELDS] as readonly string[]).includes(field))
712
880
  row.metrics[field] = PRO_FIELDS.has(field) ? withheldMetric() : unavailableMetric();
713
881
  const metric = row.metrics[field];
714
882
  if (
@@ -39,6 +39,7 @@ import { useThemeColors } from "../../../theme/theme-context";
39
39
  import { priceColor, shownPriceColor } from "../../../theme/colors";
40
40
  import { apiClient } from "../../../api-client";
41
41
  import {
42
+ LETTER_GRADE_FIELDS,
42
43
  NUMERIC_FIELDS,
43
44
  type NumericField,
44
45
  type ScreenDefinition,
@@ -46,8 +47,10 @@ import {
46
47
  } from "../../../api-client/equity-screener";
47
48
  import type { PaneProps } from "../../../types/plugin";
48
49
  import { formatPercentileRank, formatPercentRaw } from "../../../utils/format";
50
+ import { wrapTextLines } from "../../../utils/text-wrap";
49
51
  import { EXTENDED_SESSION_LABELS, extendedSessionStateLabel, type ExtendedSession } from "../../../market-data/market/status";
50
52
  import { useOpenDescription } from "../shared/open-description";
53
+ import { useMembersMenu } from "../shared/members-menu";
51
54
  import { useResearchCloudSession } from "../shared/research-cloud-session";
52
55
  import { INITIAL_STREAM_RANGE, streamWindowRows } from "../shared/use-quote-board";
53
56
  import { useSampledValue } from "../../../state/hooks/live-ticker-financials";
@@ -55,7 +58,7 @@ import { usePlanAccess } from "../../../api-client/plan-access";
55
58
  import { useQuoteDelayFooter } from "../shared/cloud-upgrade";
56
59
  import { SignInWall } from "../cloud/auth-actions";
57
60
  import { CriterionEditor } from "./criterion-editor";
58
- import { SCREEN_IDEAS, screenIdea } from "./ideas";
61
+ import { ideaMetricSetting, SCREEN_IDEAS, screenIdea } from "./ideas";
59
62
  import { ScreenTickerCheck } from "./ticker-check";
60
63
  import {
61
64
  fetchSavedScreens,
@@ -70,20 +73,25 @@ import {
70
73
  dividendYieldBasis,
71
74
  formatScreenMetric,
72
75
  formatScreenValue,
76
+ GRADE_DISPLAY_FIELDS,
77
+ gradeRankText,
73
78
  metricDate,
74
79
  parseScreenDefinition,
75
80
  pickerFields,
76
81
  resultFields,
77
82
  screenMetricSetting,
78
- SIGN_COLORED,
79
83
  screenColumnLabel,
80
84
  screenCurrencyEmpty,
81
85
  screenDefinitionKey,
86
+ screenDetailValue,
82
87
  screenLabel,
83
88
  screenRowId,
89
+ screenSignValue,
84
90
  screenYtdBase,
91
+ splitGradeReason,
85
92
  } from "./model";
86
93
  import { useScreenResults } from "./results";
94
+ import { screenWatchlistList } from "./watchlist";
87
95
  import { unmatchedCategoryText, unmatchedCategoryValues } from "./categories";
88
96
  import { overlayLiveScreenRows, screenExtendedMove, screenExtendedSessions, sortLiveScreenRows, type LiveScreenRow } from "./live";
89
97
  import { useLiveQuoteEntries } from "../../../state/hooks/quote-streaming";
@@ -169,6 +177,19 @@ export function resultColumns(
169
177
  return fits(named) ? named : build(compact.slice(0, shown), exchange, sector, "compact");
170
178
  }
171
179
  const loadFields = () => fetchScreenFields();
180
+ const DETAIL_LABEL_WIDTH = 24;
181
+ /** A long note under a value, wrapped to the detail's width rather than cut: one row per line, the label on the first. */
182
+ function WrappedDetailRows({ label, text, width }: { label: string; text: string; width: number }) {
183
+ // The detail's padding, the label column and the gap after it.
184
+ const lines = wrapTextLines(text, Math.max(16, width - 2 - DETAIL_LABEL_WIDTH - 1));
185
+ return (
186
+ <>
187
+ {lines.map((line, index) => (
188
+ <KeyValueRow key={index} label={index === 0 ? label : ""} labelWidth={DETAIL_LABEL_WIDTH} value={line} emphasis={false} />
189
+ ))}
190
+ </>
191
+ );
192
+ }
172
193
  function ScreenDetail({
173
194
  row,
174
195
  width,
@@ -189,19 +210,25 @@ function ScreenDetail({
189
210
  {NUMERIC_FIELDS.map((field) => {
190
211
  const metric = row.metrics[field];
191
212
  const stamp = metricDate(metric);
213
+ // A grade's company note (graded on another line of the company) is said once, above the grades.
214
+ const reason = GRADE_DISPLAY_FIELDS.has(field) ? splitGradeReason(metric.reason).own : metric.reason;
215
+ const company = field === LETTER_GRADE_FIELDS[0] ? splitGradeReason(metric.reason).company : null;
192
216
  const extended = field === "changePercent" ? row.extended : undefined;
193
217
  const basis = field === "dividendYieldPercent" ? dividendYieldBasis(metric) : null;
218
+ // A grade's rank in its sector and the inputs it read, and its notes: peers, N/M or stale inputs, its company.
219
+ const graded = GRADE_DISPLAY_FIELDS.has(field) && metric.value !== null ? gradeRankText(metric) : null;
194
220
  return (
195
221
  <Fragment key={field}>
222
+ {company ? <WrappedDetailRows label="Grades" text={company} width={width} /> : null}
196
223
  <KeyValueRow
197
224
  label={screenLabel(field)}
198
225
  labelWidth={24}
199
- value={metric.value == null && metric.notMeaningful ? formatScreenMetric(field, metric) : `${formatScreenValue(field, metric.value)} ${metric.unit}`}
226
+ value={screenDetailValue(field, metric)}
200
227
  detail={
201
228
  metric.value === null
202
- ? (metric.reason ?? "unavailable")
229
+ ? (reason ?? "unavailable")
203
230
  : [
204
- metric.percentile.value == null ? null : formatPercentileRank(metric.percentile.value),
231
+ graded || metric.percentile.value == null ? null : formatPercentileRank(metric.percentile.value),
205
232
  stamp.collected ? `collected ${stamp.text}` : stamp.text,
206
233
  metric.state === "available" ? null : metric.state,
207
234
  ].filter(Boolean).join(" \u00b7 ")
@@ -217,6 +244,8 @@ function ScreenDetail({
217
244
  />
218
245
  ) : null}
219
246
  {basis ? <KeyValueRow label="Yield basis" labelWidth={24} value={basis} /> : null}
247
+ {graded ? <WrappedDetailRows label="Ranked" text={graded} width={width} /> : null}
248
+ {graded && reason ? <WrappedDetailRows label="Note" text={reason} width={width} /> : null}
220
249
  </Fragment>
221
250
  );
222
251
  })}
@@ -247,6 +276,7 @@ export function EquityScreenerPane(props: PaneProps) {
247
276
  {...props}
248
277
  initial={initial}
249
278
  initialMetric={preset?.metric ?? "marketCap"}
279
+ initialMetricSetting={preset ? ideaMetricSetting(preset) : undefined}
250
280
  />
251
281
  );
252
282
  }
@@ -256,7 +286,8 @@ function EquityScreenView({
256
286
  focused,
257
287
  initial,
258
288
  initialMetric,
259
- }: PaneProps & { initial: ScreenDefinition; initialMetric: NumericField }) {
289
+ initialMetricSetting,
290
+ }: PaneProps & { initial: ScreenDefinition; initialMetric: NumericField; initialMetricSetting?: string }) {
260
291
  const colors = useThemeColors(),
261
292
  dialog = useDialog(),
262
293
  host = useRendererHost();
@@ -268,7 +299,7 @@ function EquityScreenView({
268
299
  const [definition, setDefinition] = usePluginPaneState("definition", initial);
269
300
  const [metricSetting, setMetric] = usePaneSettingValue<string>(
270
301
  "metric",
271
- initialMetric,
302
+ initialMetricSetting ?? initialMetric,
272
303
  );
273
304
  // `--metric trailingPE,dividendYieldPercent` leads with the first and adds the others as columns.
274
305
  const [metric, ...otherMetrics] = screenMetricSetting(metricSetting, initialMetric);
@@ -348,6 +379,16 @@ function EquityScreenView({
348
379
  const selected =
349
380
  opened ?? rows.find((row) => screenRowId(row) === selectedId) ?? rows[0];
350
381
  const currentSaved = saved.data?.find((row) => row.id === currentSavedId);
382
+ // The pane menu's Save to Watchlist… takes the matches loaded, in the order shown (the first page is 100). A live
383
+ // quote changes the rows but not who they are, so the menu is rebuilt only when the order does.
384
+ const shownOrder = rows.map(screenRowId).join(" ");
385
+ const watchlistList = useMemo(
386
+ () => mode === "results" && !openId && data && screenDefinitionKey(data.definition) === screenDefinitionKey(definition)
387
+ ? screenWatchlistList({ definition, rows, matched: data.universe.matched, savedName: currentSaved?.name })
388
+ : null,
389
+ [currentSaved?.name, data, definition, mode, openId, shownOrder], // eslint-disable-line react-hooks/exhaustive-deps
390
+ );
391
+ useMembersMenu("equity-screener:watchlist", watchlistList);
351
392
  const selectedSaved =
352
393
  saved.data?.find((row) => row.id === savedSelectedId) ?? saved.data?.[0];
353
394
  useEffect(() => {
@@ -910,7 +951,7 @@ function EquityScreenView({
910
951
  onChange: setIdeaSelectedId,
911
952
  }}
912
953
  onActivate={(row) => {
913
- setMetric(row.metric);
954
+ setMetric(ideaMetricSetting(row));
914
955
  apply(row.definition);
915
956
  setCurrentSavedId(null);
916
957
  setMode("results");
@@ -1053,10 +1094,9 @@ function EquityScreenView({
1053
1094
  : null;
1054
1095
  if (field) {
1055
1096
  const observation = row.metrics[field];
1056
- const change = SIGN_COLORED.has(field) && observation.value != null
1057
- // A move that prints 0.0 stays neutral.
1058
- ? priceColor(Math.abs(observation.value) < 0.05 ? 0 : observation.value, colors)
1059
- : undefined;
1097
+ // A move by its sign (one that prints 0.0 stays neutral), a grade by its side of the middle.
1098
+ const sign = screenSignValue(field, observation.value);
1099
+ const change = sign == null ? undefined : priceColor(sign, colors);
1060
1100
  return {
1061
1101
  text: formatScreenMetric(field, observation),
1062
1102
  color: observation.state === "stale" ? colors.warning : change,
@@ -1,6 +1,6 @@
1
- import type { ScreenCheckPayload, ScreenCriterion, ScreenDefinition } from "../../../api-client/equity-screener";
1
+ import type { NumericField, ScreenCheckPayload, ScreenCriterion, ScreenDefinition } from "../../../api-client/equity-screener";
2
2
  import { canonicalExchange, parsePublicTickerKey } from "../../../utils/exchanges";
3
- import { criterionText, parseScreenDefinition, screenDefinitionKey, screenLabel } from "./model";
3
+ import { criterionText, formatScreenValue, GRADE_DISPLAY_FIELDS, parseScreenDefinition, screenDefinitionKey, screenLabel } from "./model";
4
4
 
5
5
  /** One listing, with the same exchange aliases the rest of the app accepts. */
6
6
  export function screenCheckTicker(text: string): { symbol: string; exchange?: string } {
@@ -64,7 +64,8 @@ export function validateScreenCheck(
64
64
 
65
65
  const number = (value: number) => value.toLocaleString("en-US", { maximumSignificantDigits: 21 });
66
66
  function checkCriterionText(criterion: ScreenCriterion): string {
67
- if (!("value" in criterion) || criterion.op === "in") return criterionText(criterion);
67
+ // A grade compares letters (`Value grade >= B+`), and the composite reads as the screen writes it.
68
+ if (!("value" in criterion) || criterion.op === "in" || GRADE_DISPLAY_FIELDS.has(criterion.field)) return criterionText(criterion);
68
69
  const operators = { gte: ">=", lte: "<=", gt: ">", lt: "<", eq: "=", between: "between" };
69
70
  const threshold = Array.isArray(criterion.value) ? criterion.value.map(number).join(", ") : number(criterion.value);
70
71
  return `${screenLabel(criterion.field)} ${operators[criterion.op]} ${threshold}`;
@@ -102,7 +103,9 @@ export function checkRows(data: ScreenCheckPayload) {
102
103
  id: String(index),
103
104
  criterion: checkCriterionText(entry.criterion),
104
105
  value: entry.state === "not-covered" ? "Not covered" : entry.value === null ? "Missing" : typeof entry.value === "number"
105
- ? checkValueText(entry.value, entry.unit, entry.criterion) : entry.value,
106
+ ? GRADE_DISPLAY_FIELDS.has(entry.criterion.field) ? formatScreenValue(entry.criterion.field as NumericField, entry.value)
107
+ : checkValueText(entry.value, entry.unit, entry.criterion)
108
+ : entry.value,
106
109
  result: entry.passes === null ? "Not evaluated" : entry.passes ? "Pass" : "Fail",
107
110
  asOf: entry.asOf?.slice(0, 10) ?? (entry.observedAt ? `${entry.observedAt.slice(0, 10)} (collected)` : "--"),
108
111
  state: entry.state,
@@ -0,0 +1,33 @@
1
+ import type { ScreenDefinition, ScreenRow } from "../../../api-client/equity-screener";
2
+ import type { MemberList } from "../shared/members-menu";
3
+ import { SCREEN_IDEAS } from "./ideas";
4
+ import { screenDefinitionKey } from "./model";
5
+
6
+ /** What a screen is called: the idea it is, else the saved screen it was opened from, else EQS. */
7
+ function screenTitle(definition: ScreenDefinition, savedName?: string | null): string {
8
+ const key = screenDefinitionKey(definition);
9
+ return SCREEN_IDEAS.find((idea) => screenDefinitionKey(idea.definition) === key)?.name ?? (savedName?.trim() || "EQS");
10
+ }
11
+
12
+ /**
13
+ * A screen's matches as the shared watchlist menu takes them: the rows loaded, in
14
+ * the order shown, each listing with its exchange and quote currency, and how
15
+ * many match in all. A watchlist keeps at most the first 100 of them.
16
+ */
17
+ export function screenWatchlistList(options: {
18
+ definition: ScreenDefinition;
19
+ rows: readonly Pick<ScreenRow, "symbol" | "name" | "exchange" | "currency">[];
20
+ matched: number;
21
+ savedName?: string | null;
22
+ }): MemberList | null {
23
+ if (!options.rows.length) return null;
24
+ const title = screenTitle(options.definition, options.savedName);
25
+ return {
26
+ title,
27
+ watchlistName: title === "EQS" ? "EQS screen" : title,
28
+ noun: "matches",
29
+ total: options.matched,
30
+ openIn: false,
31
+ members: options.rows.map((row) => ({ symbol: row.symbol, name: row.name, exchange: row.exchange, currency: row.currency })),
32
+ };
33
+ }
@@ -22,6 +22,21 @@ function futuresSeriesUnit(contract: FuturesContract): string {
22
22
  return "USD";
23
23
  }
24
24
 
25
+ /**
26
+ * Words a contract is looked for by that its name does not hold: a currency
27
+ * future by its currency's code and name (`yen`, `JPY` for 6J), and the safe
28
+ * havens, gold, the yen and the franc.
29
+ */
30
+ const CONTRACT_TAGS: Readonly<Record<string, readonly string[]>> = {
31
+ GC: ["safe haven"],
32
+ "6E": ["EUR", "euro"],
33
+ "6J": ["JPY", "yen", "safe haven"],
34
+ "6B": ["GBP", "pound", "sterling"],
35
+ "6A": ["AUD", "aussie"],
36
+ "6C": ["CAD", "loonie"],
37
+ "6S": ["CHF", "franc", "swiss franc", "safe haven"],
38
+ };
39
+
25
40
  /** Each continuous front-month contract on the futures board, as `FUT:ES`. */
26
41
  const FRONT_MONTH_SERIES: readonly SeriesDefinition[] = FUTURES_CONTRACTS.map((contract) => ({
27
42
  id: `fut:${contract.code}`,
@@ -29,7 +44,7 @@ const FRONT_MONTH_SERIES: readonly SeriesDefinition[] = FUTURES_CONTRACTS.map((c
29
44
  unit: futuresSeriesUnit(contract),
30
45
  frequency: "daily",
31
46
  group: "Futures",
32
- tags: [contract.code, FUTURES_SECTOR_LABELS[contract.sector], "futures", "front month"],
47
+ tags: [contract.code, FUTURES_SECTOR_LABELS[contract.sector], "futures", "front month", ...CONTRACT_TAGS[contract.code] ?? []],
33
48
  expression: `FUT:${contract.code}`,
34
49
  }));
35
50
 
@@ -111,6 +111,25 @@ export async function loadCurveSpot(symbol: string, provider: Pick<DataProvider,
111
111
  return curveSpot(symbol, await provider.getQuote(symbol, "").catch(logFailure("futures-curve.client", "Load curve spot quote failed", null)), now);
112
112
  }
113
113
 
114
+ /**
115
+ * A month of the spot index's daily closes, read through the same history path
116
+ * the charts use, which the front premium takes its settlement session's close
117
+ * from. A failed read has none: the curve stands, its premium saying why.
118
+ */
119
+ export async function loadCurveSpotCloses(symbol: string,
120
+ provider: Pick<AssetDataProvider, "getPriceHistoryForResolutionWithMetadata" | "getPriceHistoryForResolution">, force = false): Promise<{ date: Date; close: number }[]> {
121
+ const context = force ? { cacheMode: "refresh" as const } : undefined;
122
+ try {
123
+ if (provider.getPriceHistoryForResolutionWithMetadata) {
124
+ const history = await provider.getPriceHistoryForResolutionWithMetadata(symbol, "", "1M", "1d", context);
125
+ return history.resolution && history.resolution !== "1d" ? [] : history.points;
126
+ }
127
+ return provider.getPriceHistoryForResolution ? await provider.getPriceHistoryForResolution(symbol, "", "1M", "1d", context) : [];
128
+ } catch (error) {
129
+ return logFailure("futures-curve.client", "Load curve spot closes failed", [] as { date: Date; close: number }[])(error);
130
+ }
131
+ }
132
+
114
133
  /** The last day of one-minute bars: the reach of a curve's trades a basis is read for, the far months' older ones aside. */
115
134
  const SPOT_BAR_RANGE: TimeRange = "1D";
116
135