@gloom-sh/terminal 0.19.5 → 0.20.0
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.
- package/LICENSE +0 -4
- package/package.json +6 -5
- package/patches/@opentui%2Fcore@0.3.2.patch +86 -25
- package/patches/electrobun-devkit@2.0.5.patch +148 -0
- package/src/api-client/bond-trades.ts +59 -0
- package/src/api-client/data.ts +21 -0
- package/src/api-client/equity-screener.ts +23 -0
- package/src/api-client/index.ts +2 -0
- package/src/api-client/types/account.ts +86 -0
- package/src/api-client/types/assist.ts +32 -0
- package/src/api-client/types/auth.ts +63 -0
- package/src/api-client/types/billing.ts +54 -0
- package/src/api-client/types/chat.ts +180 -0
- package/src/api-client/types/congress.ts +107 -0
- package/src/api-client/types/credit.ts +110 -0
- package/src/api-client/types/econ.ts +158 -0
- package/src/api-client/types/equity-diagnostic.ts +73 -0
- package/src/api-client/types/filings-and-calls.ts +350 -0
- package/src/api-client/types/index.ts +25 -0
- package/src/api-client/types/jobs.ts +147 -0
- package/src/api-client/types/market.ts +122 -0
- package/src/api-client/types/news.ts +91 -0
- package/src/api-client/types/notes-and-theses.ts +172 -0
- package/src/api-client/types/quotes.ts +28 -0
- package/src/api-client/types/scanners.ts +125 -0
- package/src/api-client/types/screener.ts +65 -0
- package/src/api-client/types/search.ts +107 -0
- package/src/api-client/types/sync.ts +14 -0
- package/src/api-client/types/team-collections.ts +43 -0
- package/src/api-client/types/team-views.ts +32 -0
- package/src/api-client/types/teams.ts +135 -0
- package/src/api-client/types/ticker-data.ts +57 -0
- package/src/api-client/types/tweets.ts +59 -0
- package/src/api-client/types/world-venues.ts +23 -0
- package/src/app/pane-runtime/index.tsx +2 -0
- package/src/app/pane-runtime/plugin-bindings.ts +10 -1
- package/src/app/runtime/desktop-deeplink.ts +41 -6
- package/src/app/star-prompt/status-line.tsx +1 -1
- package/src/app.tsx +64 -23
- package/src/architecture/ui-tokens-allowlist.json +0 -8
- package/src/cli/commands/market.ts +149 -10
- package/src/cli/commands/search.ts +21 -3
- package/src/cli/commands/ticker.ts +90 -36
- package/src/cli/desktop-pane-shot-browser.ts +69 -3
- package/src/cli/glossary.ts +3 -3
- package/src/cli/known-gaps.ts +8 -0
- package/src/cli/listing-arg.ts +12 -0
- package/src/cli/pane-functions/capabilities.ts +2 -0
- package/src/cli/pane-functions/catalog.ts +25 -5
- package/src/cli/pane-functions/function-help.ts +8 -5
- package/src/cli/pane-functions/headless.ts +4 -3
- package/src/cli/pane-functions/resolver.ts +75 -2
- package/src/cli/quote-answer.ts +9 -0
- package/src/cli/symbol-list.ts +54 -2
- package/src/cli/symbol-rows.ts +14 -2
- package/src/cli/ticker-resolution.ts +89 -20
- package/src/components/chart/composite/axis-overlays.tsx +60 -27
- package/src/components/chart/composite/composite-chart.tsx +118 -63
- package/src/components/chart/composite/cursor-source.ts +111 -0
- package/src/components/chart/composite/format.ts +168 -6
- package/src/components/chart/composite/legend.tsx +8 -4
- package/src/components/chart/composite/panel-labels.ts +20 -1
- package/src/components/chart/composite/panel-surface.tsx +201 -92
- package/src/components/chart/composite/price-axis-labels.tsx +92 -46
- package/src/components/chart/composite/price-series.ts +31 -8
- package/src/components/chart/composite/scene.ts +154 -59
- package/src/components/chart/composite/series-axis-tags.tsx +4 -2
- package/src/components/chart/composite/time-axis.ts +13 -5
- package/src/components/chart/composite/time-scale.ts +211 -56
- package/src/components/chart/composite/types.ts +11 -1
- package/src/components/chart/composite/use-composite-chart-keyboard.ts +43 -14
- package/src/components/chart/curve/curve-surface.tsx +5 -2
- package/src/components/chart/curve/model.ts +4 -1
- package/src/components/chart/native/use-bitmap-metrics.ts +81 -0
- package/src/components/chart/static/series.ts +3 -0
- package/src/components/command-bar/commands/collection-list.ts +81 -0
- package/src/components/command-bar/commands/direct/index.ts +6 -0
- package/src/components/command-bar/commands/registry.ts +8 -0
- package/src/components/command-bar/layout-items/current-layout.ts +22 -1
- package/src/components/command-bar/layout-items/focused-pane.ts +22 -1
- package/src/components/command-bar/pane-templates/items.ts +19 -3
- package/src/components/command-bar/pane-templates/workflow.ts +5 -0
- package/src/components/command-bar/routes/root/results.ts +23 -3
- package/src/components/command-bar/routes/root/selection.ts +4 -2
- package/src/components/command-bar/routes/root/shortcut-feedback.ts +1 -1
- package/src/components/command-bar/routes/root/shortcut-items.ts +3 -4
- package/src/components/command-bar/routes/root/shortcuts.ts +58 -14
- package/src/components/command-bar/routes/root/ticker-first.ts +32 -0
- package/src/components/command-bar/surface/environment.ts +2 -0
- package/src/components/command-bar/view-model.ts +7 -0
- package/src/components/command-bar/workflow/ops.ts +2 -1
- package/src/components/command-bar/workflow/tickers.ts +20 -0
- package/src/components/data-table/export.ts +4 -1
- package/src/components/layout/detached-pane-shell.tsx +10 -37
- package/src/components/layout/double-escape-close.ts +90 -0
- package/src/components/layout/header.tsx +3 -2
- package/src/components/layout/market-summary.ts +6 -3
- package/src/components/layout/pane/footer/index.tsx +2 -6
- package/src/components/layout/pane/footer/model.ts +6 -12
- package/src/components/layout/shell/active-drag.ts +53 -11
- package/src/components/layout/shell/drag/magnets.ts +128 -19
- package/src/components/layout/shell/menu.ts +15 -1
- package/src/components/layout/shell/pane/actions.ts +10 -2
- package/src/components/layout/shell/pane/management-shortcuts.ts +13 -51
- package/src/components/layout/shell/ticker-link-menu.ts +12 -3
- package/src/components/layout/status-bar.tsx +24 -78
- package/src/components/layout/status-widget-space.ts +5 -5
- package/src/components/onboarding/onboarding-keyboard.ts +5 -1
- package/src/components/onboarding/onboarding-wizard.tsx +15 -4
- package/src/components/onboarding/portfolio-step/positions-panel.tsx +9 -6
- package/src/components/onboarding/use-onboarding-progress.ts +20 -1
- package/src/components/price-sparkline/view.tsx +14 -6
- package/src/components/ticker/badge/index.tsx +8 -4
- package/src/components/ticker/badge/list.tsx +23 -7
- package/src/components/ui/column-grid.tsx +8 -2
- package/src/components/ui/data-table/index.tsx +5 -1
- package/src/components/ui/data-table/opentui/model.ts +4 -1
- package/src/components/ui/data-table/render-cell.ts +19 -0
- package/src/components/ui/delayed-mark.tsx +59 -7
- package/src/components/ui/icon.tsx +1 -8
- package/src/components/ui/menu.tsx +6 -1
- package/src/components/ui/tabs.tsx +5 -2
- package/src/core/state/app/layout.ts +18 -3
- package/src/core/state/app/state.ts +2 -0
- package/src/core/state/app/types.ts +5 -0
- package/src/data/config/layout.ts +3 -0
- package/src/data/config/store/normalize.ts +39 -4
- package/src/i18n/es.ts +13 -3
- package/src/i18n/ja.ts +13 -3
- package/src/i18n/ko.ts +13 -3
- package/src/i18n/zh-cn.ts +13 -3
- package/src/i18n/zh-tw.ts +13 -3
- package/src/layout/pane-manager/floating-placement.ts +7 -4
- package/src/layout/pane-manager/floating.ts +5 -2
- package/src/market-data/bond-funds.ts +19 -0
- package/src/market-data/futures-contract.ts +14 -3
- package/src/market-data/market/freshness.ts +18 -0
- package/src/market-data/market/status.ts +15 -2
- package/src/plugins/builtin/bond-calculator/headless.ts +2 -1
- package/src/plugins/builtin/bond-calculator/index.tsx +1 -1
- package/src/plugins/builtin/bond-calculator/model.ts +14 -5
- package/src/plugins/builtin/bond-calculator/pane.tsx +1 -1
- package/src/plugins/builtin/buildout/cells.tsx +25 -45
- package/src/plugins/builtin/buildout/detail/company.tsx +3 -3
- package/src/plugins/builtin/buildout/detail/index.tsx +1 -1
- package/src/plugins/builtin/buildout/detail/intel.tsx +4 -7
- package/src/plugins/builtin/buildout/detail/site.tsx +4 -4
- package/src/plugins/builtin/buildout/detail/ui.tsx +39 -38
- package/src/plugins/builtin/buildout/format.ts +23 -1
- package/src/plugins/builtin/buildout/model/types.ts +1 -0
- package/src/plugins/builtin/buildout/pane/index.tsx +2 -8
- package/src/plugins/builtin/buildout/table-model.ts +12 -4
- package/src/plugins/builtin/cds/headless.ts +1 -0
- package/src/plugins/builtin/cds/index.tsx +1 -1
- package/src/plugins/builtin/chat/content/composer.tsx +21 -27
- package/src/plugins/builtin/chat/content/index.tsx +31 -3
- package/src/plugins/builtin/chat/content/shortcuts.ts +4 -2
- package/src/plugins/builtin/chat/content/snapshot.ts +0 -3
- package/src/plugins/builtin/cloud/auth-actions.tsx +51 -23
- package/src/plugins/builtin/cloud/plugin.tsx +2 -0
- package/src/plugins/builtin/cloud/trial-offer-status-widget.tsx +3 -3
- package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +44 -12
- package/src/plugins/builtin/congress-trades/model.ts +2 -1
- package/src/plugins/builtin/congress-trades/pane.tsx +3 -0
- package/src/plugins/builtin/correlation/headless.ts +3 -2
- package/src/plugins/builtin/crypto-board/pane.tsx +5 -4
- package/src/plugins/builtin/custom-view/index.tsx +1 -1
- package/src/plugins/builtin/custom-view/loader.ts +85 -8
- package/src/plugins/builtin/custom-view/view-spec.ts +28 -0
- package/src/plugins/builtin/debt-maturities/headless.ts +11 -2
- package/src/plugins/builtin/debt-maturities/model.ts +66 -0
- package/src/plugins/builtin/debt-maturities/pane.tsx +23 -4
- package/src/plugins/builtin/earnings-ripple/pane.tsx +1 -1
- package/src/plugins/builtin/econ/calendar-model.ts +28 -6
- package/src/plugins/builtin/equity-screener/client.ts +1 -1
- package/src/plugins/builtin/equity-screener/criterion-editor.tsx +16 -19
- package/src/plugins/builtin/equity-screener/headless.ts +37 -3
- package/src/plugins/builtin/equity-screener/ideas.ts +67 -3
- package/src/plugins/builtin/equity-screener/model.ts +238 -27
- package/src/plugins/builtin/equity-screener/pane.tsx +88 -18
- package/src/plugins/builtin/equity-screener/screen-check.ts +7 -4
- package/src/plugins/builtin/equity-screener/watchlist.ts +33 -0
- package/src/plugins/builtin/executives/format.ts +5 -4
- package/src/plugins/builtin/executives/pane.tsx +1 -1
- package/src/plugins/builtin/futures-curve/client.ts +19 -0
- package/src/plugins/builtin/futures-curve/headless.ts +52 -13
- package/src/plugins/builtin/futures-curve/index.tsx +1 -1
- package/src/plugins/builtin/futures-curve/model.ts +77 -6
- package/src/plugins/builtin/futures-curve/pane.tsx +19 -3
- package/src/plugins/builtin/help/index.tsx +55 -1
- package/src/plugins/builtin/insider/model.ts +30 -2
- package/src/plugins/builtin/jobs/model.ts +2 -2
- package/src/plugins/builtin/macro-day/client.ts +41 -0
- package/src/plugins/builtin/macro-day/headless.ts +19 -9
- package/src/plugins/builtin/macro-day/model.ts +3 -1
- package/src/plugins/builtin/market-movers/index.tsx +4 -3
- package/src/plugins/builtin/mna/distress/headless.ts +1 -0
- package/src/plugins/builtin/mna/model.ts +2 -2
- package/src/plugins/builtin/notes/files.ts +2 -0
- package/src/plugins/builtin/notes/owner.tsx +20 -1
- package/src/plugins/builtin/notes/quick-notes-pane.tsx +22 -4
- package/src/plugins/builtin/notes/store.ts +6 -1
- package/src/plugins/builtin/perps/pane.tsx +3 -1
- package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +17 -0
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +2 -1
- package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +2 -1
- package/src/plugins/builtin/portfolio-list/header.tsx +1 -1
- package/src/plugins/builtin/rate-path/headless.ts +24 -10
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +29 -25
- package/src/plugins/builtin/research/event-model.ts +10 -3
- package/src/plugins/builtin/research/events-headless.ts +20 -2
- package/src/plugins/builtin/sec/fund-facts.ts +17 -1
- package/src/plugins/builtin/sec/index.tsx +1 -1
- package/src/plugins/builtin/series-inventory.ts +1 -0
- package/src/plugins/builtin/shared/earnings-report.ts +7 -2
- package/src/plugins/builtin/shared/members-menu.tsx +103 -38
- package/src/plugins/builtin/shared/use-quote-board.ts +85 -46
- package/src/plugins/builtin/short-interest/headless.ts +1 -1
- package/src/plugins/builtin/short-interest/model.ts +15 -6
- package/src/plugins/builtin/short-interest/publications-model.ts +22 -1
- package/src/plugins/builtin/short-interest/publications-pane.tsx +13 -4
- package/src/plugins/builtin/short-interest/types.ts +2 -0
- package/src/plugins/builtin/short-interest/watch-model.ts +1 -1
- package/src/plugins/builtin/thirteenf/overlap-pane.tsx +3 -0
- package/src/plugins/builtin/thirteenf/pane.tsx +3 -0
- package/src/plugins/builtin/ticker-detail/overview/model.ts +5 -3
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +4 -4
- package/src/plugins/builtin/time-sales/pane.tsx +3 -2
- package/src/plugins/builtin/trace-bonds/client.ts +7 -4
- package/src/plugins/builtin/trace-bonds/detail.tsx +198 -0
- package/src/plugins/builtin/trace-bonds/headless.ts +62 -4
- package/src/plugins/builtin/trace-bonds/history.ts +155 -0
- package/src/plugins/builtin/trace-bonds/index.tsx +1 -1
- package/src/plugins/builtin/trace-bonds/pane.tsx +64 -5
- package/src/plugins/builtin/volatility/client.ts +6 -1
- package/src/plugins/builtin/volatility/headless.ts +0 -1
- package/src/plugins/builtin/yield-curve/curves.ts +15 -0
- package/src/plugins/builtin/yield-curve/headless.ts +6 -1
- package/src/plugins/builtin/yield-curve/index.tsx +5 -8
- package/src/plugins/host-modules.ts +22 -3
- package/src/plugins/host-smoke.ts +6 -3
- package/src/plugins/installer.ts +16 -3
- package/src/plugins/plugin-names.ts +11 -2
- package/src/portfolio/collection-name.ts +19 -0
- package/src/remote/controller.ts +9 -2
- package/src/remote/schema.ts +2 -1
- package/src/renderers/browser/http-proxy-transport.ts +78 -8
- package/src/renderers/cloudflare/http-proxy.ts +73 -3
- package/src/renderers/cloudflare/proxy-session.ts +47 -24
- package/src/renderers/cloudflare/worker.ts +44 -4
- package/src/renderers/desktop/geometry.ts +279 -0
- package/src/renderers/desktop/screen-setup.ts +246 -0
- package/src/renderers/desktop/sequential-window-host.ts +179 -0
- package/src/renderers/desktop/test-utils.ts +71 -0
- package/src/renderers/desktop/window-controller.ts +433 -0
- package/src/renderers/desktop/window-host.ts +70 -0
- package/src/renderers/desktop/window-layouts.ts +630 -0
- package/src/renderers/dom/data-frames.ts +15 -4
- package/src/renderers/dom/desktop/icons.tsx +0 -2
- package/src/renderers/dom/styles.css +0 -3
- package/src/renderers/electrobun/bun/application-menu/click.ts +1 -0
- package/src/renderers/electrobun/bun/application-menu/index.ts +4 -1
- package/src/renderers/electrobun/bun/desktop/backend-requests.ts +19 -8
- package/src/renderers/electrobun/bun/desktop/backend.ts +320 -19
- package/src/renderers/electrobun/bun/desktop/detached-windows.ts +83 -61
- package/src/renderers/electrobun/bun/desktop/host-requests.ts +4 -14
- package/src/renderers/electrobun/bun/desktop/initialization.ts +30 -11
- package/src/renderers/electrobun/bun/desktop/install-records.ts +59 -0
- package/src/renderers/electrobun/bun/desktop/installer-folder.ts +208 -592
- package/src/renderers/electrobun/bun/desktop/macos-objc.ts +14 -0
- package/src/renderers/electrobun/bun/desktop/screen-setup-file.ts +55 -0
- package/src/renderers/electrobun/bun/desktop/state-broadcaster.ts +44 -8
- package/src/renderers/electrobun/bun/desktop/update.ts +1 -1
- package/src/renderers/electrobun/bun/desktop/workspace/index.ts +298 -97
- package/src/renderers/electrobun/bun/desktop/workspace/requests.ts +44 -6
- package/src/renderers/electrobun/bun/index.ts +22 -109
- package/src/renderers/electrobun/bun/window/create.ts +23 -3
- package/src/renderers/electrobun/bun/window/electrobun-window-host.ts +306 -0
- package/src/renderers/electrobun/bun/window/events.ts +4 -4
- package/src/renderers/electrobun/bun/window/focus.ts +0 -25
- package/src/renderers/electrobun/bun/window/frame.ts +2 -1
- package/src/renderers/electrobun/bun/window/native-min-size.ts +322 -0
- package/src/renderers/electrobun/bun/window/remembered-frame.ts +4 -82
- package/src/renderers/electrobun/shared/protocol.ts +44 -2
- package/src/renderers/electrobun/view/backend-rpc.ts +16 -1
- package/src/renderers/electrobun/view/desktop/window/bridge.ts +63 -3
- package/src/renderers/electrobun/view/main.tsx +13 -7
- package/src/series/fred-argument.ts +17 -0
- package/src/sources/gloomberb-cloud/index.ts +5 -7
- package/src/sources/provider-router/batches.ts +18 -3
- package/src/sources/provider-router/financial-routes.ts +7 -1
- package/src/sources/provider-router/financials.ts +18 -4
- package/src/state/app/context/index.tsx +16 -2
- package/src/state/desktop-windows.ts +63 -0
- package/src/sync/other-window-tabs.ts +62 -0
- package/src/tickers/company-name-listing.ts +23 -3
- package/src/tickers/listing-fate.ts +147 -1
- package/src/tickers/terminal-codes.ts +5 -0
- package/src/time-series/types.ts +6 -0
- package/src/types/config.ts +10 -1
- package/src/types/data-provider.ts +14 -0
- package/src/types/desktop-window.ts +71 -2
- package/src/types/financials.ts +19 -3
- package/src/types/headless.ts +21 -0
- package/src/types/plugin.ts +6 -0
- package/src/ui/index.tsx +14 -13
- package/src/ui/same-props.ts +58 -0
- package/src/utils/cli-output.ts +33 -4
- package/src/utils/double-escape-close.ts +38 -16
- package/src/utils/format.ts +30 -5
- package/src/utils/futures-generic.ts +12 -0
- package/src/utils/http-proxy-upstream.ts +6 -2
- package/src/utils/plugin-proxy-hosts.json +0 -4
- package/src/utils/plugin-proxy-hosts.ts +22 -0
- package/src/utils/price-earnings.ts +18 -0
- package/src/utils/sec-filings.ts +7 -1
- package/patches/electrobun@1.18.1.patch +0 -633
- package/src/api-client/types.ts +0 -2441
|
@@ -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,
|
|
@@ -22,7 +26,7 @@ import {
|
|
|
22
26
|
type ScreenRow,
|
|
23
27
|
} from "../../../api-client/equity-screener";
|
|
24
28
|
import { yearToDateBaseLabel } from "../../../market-data/market/year-to-date";
|
|
25
|
-
import { canonicalExchange } from "../../../utils/exchanges";
|
|
29
|
+
import { canonicalExchange, parsePublicTickerKey } from "../../../utils/exchanges";
|
|
26
30
|
import { LATEST_DISTRIBUTION, TRAILING_DIVIDEND_BASIS } from "../../../utils/forward-dividend";
|
|
27
31
|
import { formatCompact, formatNumber } from "../../../utils/format";
|
|
28
32
|
import { formatPriceEarnings, NOT_MEANINGFUL } from "../../../utils/price-earnings";
|
|
@@ -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
|
-
|
|
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
|
|
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]) =>
|
|
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 %",
|
|
@@ -405,35 +529,63 @@ export const screenLabel = (field: string) =>
|
|
|
405
529
|
field
|
|
406
530
|
.replace(/([A-Z])/g, " $1")
|
|
407
531
|
.replace(/^./, (value) => value.toUpperCase());
|
|
532
|
+
/** A category's `in` alternatives. */
|
|
533
|
+
const MAX_CATEGORY_VALUES = 25;
|
|
534
|
+
/** A list of symbols is a watchlist or a pasted list, so it takes up to 500 names. */
|
|
535
|
+
export const MAX_SYMBOL_VALUES = 500;
|
|
536
|
+
const maxCategoryValues = (field: string) => (field === "symbol" ? MAX_SYMBOL_VALUES : MAX_CATEGORY_VALUES);
|
|
537
|
+
|
|
538
|
+
/** A watchlist's tickers as a screen's symbols: each without its venue (`SAP:XETRA` is SAP), once. */
|
|
539
|
+
export function screenSymbols(tickers: readonly string[]): string[] {
|
|
540
|
+
return [...new Set(tickers.map((ticker) => parsePublicTickerKey(ticker).symbol).filter(Boolean))];
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
/** The one name typed for a symbol list, which may name a watchlist (`HY3`), or null. */
|
|
544
|
+
export function typedListName(fieldId: string, operator: ScreenOperator, text: string): string | null {
|
|
545
|
+
if (fieldId !== "symbol" || operator !== "in") return null;
|
|
546
|
+
const typed = text.split(",").map((value) => value.trim()).filter(Boolean);
|
|
547
|
+
return typed.length === 1 ? typed[0]! : null;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* A criterion as the editor's fields give it. `readWatchlist` reads one name
|
|
552
|
+
* typed for the symbol field as that watchlist's symbols (`HY3`), or null
|
|
553
|
+
* when it names none.
|
|
554
|
+
*/
|
|
408
555
|
export function parseCriterion(
|
|
409
556
|
field: ScreenFieldDefinition,
|
|
410
557
|
operator: ScreenOperator,
|
|
411
558
|
text: string,
|
|
559
|
+
readWatchlist?: (typed: string) => { symbols: readonly string[] } | null,
|
|
412
560
|
): ScreenCriterion {
|
|
413
561
|
if (!field.operators.includes(operator))
|
|
414
562
|
throw new Error("Choose a supported operator for this field.");
|
|
415
563
|
if (operator === "present" || operator === "missing")
|
|
416
564
|
return { field: field.id, op: operator };
|
|
417
565
|
if (field.kind === "category") {
|
|
418
|
-
const
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
if (operator !== "in" || !values.length || values.length >
|
|
427
|
-
throw new Error(
|
|
566
|
+
const typed = text
|
|
567
|
+
.split(",")
|
|
568
|
+
.map((value) => value.trim())
|
|
569
|
+
.filter(Boolean);
|
|
570
|
+
const name = typedListName(field.id, operator, text);
|
|
571
|
+
const listed = name ? readWatchlist?.(name)?.symbols ?? null : null;
|
|
572
|
+
const values = [...new Set(listed ?? typed)];
|
|
573
|
+
const maximum = maxCategoryValues(field.id);
|
|
574
|
+
if (operator !== "in" || !values.length || values.length > maximum || values.some((value) => value.length > 120))
|
|
575
|
+
throw new Error(field.id === "symbol"
|
|
576
|
+
? `Enter a watchlist name or 1-${maximum} comma-separated symbols, up to 120 characters each.`
|
|
577
|
+
: `Enter 1-${maximum} comma-separated values, up to 120 characters each.`);
|
|
428
578
|
return {
|
|
429
579
|
field: field.id as (typeof CATEGORY_FIELDS)[number],
|
|
430
580
|
op: "in",
|
|
431
581
|
value: values,
|
|
432
582
|
};
|
|
433
583
|
}
|
|
434
|
-
const values = text.split(",").map(parseThreshold);
|
|
584
|
+
const values = text.split(",").map((part) => parseGradeThreshold(field.id, part) ?? parseThreshold(part));
|
|
435
585
|
if (values.some((value) => value === null))
|
|
436
|
-
throw new Error(
|
|
586
|
+
throw new Error(LETTER_GRADES.has(field.id as NumericField)
|
|
587
|
+
? "Enter a grade from F to A+, such as B+."
|
|
588
|
+
: "Enter a finite numeric threshold, such as 25 or 10B.");
|
|
437
589
|
if (operator === "between") {
|
|
438
590
|
if (values.length !== 2 || Number(values[0]) > Number(values[1]))
|
|
439
591
|
throw new Error("Enter minimum, maximum in ascending order.");
|
|
@@ -454,6 +606,35 @@ export function parseCriterion(
|
|
|
454
606
|
value: Number(values[0]),
|
|
455
607
|
};
|
|
456
608
|
}
|
|
609
|
+
/** A grade typed as its letter (`b+`, `A`), or the composite as its label (`Strong` is 3.5); null for anything else. */
|
|
610
|
+
function parseGradeThreshold(field: string, text: string): number | null {
|
|
611
|
+
const typed = text.trim().toUpperCase();
|
|
612
|
+
if (LETTER_GRADES.has(field as NumericField)) {
|
|
613
|
+
const index = (GRADE_LETTERS as readonly string[]).indexOf(typed);
|
|
614
|
+
return index >= 0 ? index + 1 : null;
|
|
615
|
+
}
|
|
616
|
+
if (field === "gradeComposite") return COMPOSITE_BANDS.find((band) => band.label.toUpperCase() === typed)?.from ?? null;
|
|
617
|
+
return null;
|
|
618
|
+
}
|
|
619
|
+
/** A criterion's value as the editor shows it: a grade as its letter, a range as `min, max`. */
|
|
620
|
+
export function criterionInputText(criterion: ScreenCriterion | null): string {
|
|
621
|
+
if (!criterion || !("value" in criterion)) return "";
|
|
622
|
+
const shown = (value: string | number) => typeof value === "number" && LETTER_GRADES.has(criterion.field as NumericField)
|
|
623
|
+
? gradeLetter(value) ?? String(value) : String(value);
|
|
624
|
+
return Array.isArray(criterion.value) ? criterion.value.map(shown).join(", ") : shown(criterion.value);
|
|
625
|
+
}
|
|
626
|
+
/** What the value field asks for: the grade's range for a grade, else the field's unit. */
|
|
627
|
+
export function criterionValueLabel(field: Pick<ScreenFieldDefinition, "id" | "unit">): string {
|
|
628
|
+
const unit = LETTER_GRADES.has(field.id as NumericField) ? "F to A+" : field.unit;
|
|
629
|
+
return `Value${unit ? ` (${unit})` : ""}`;
|
|
630
|
+
}
|
|
631
|
+
/** An example value: a letter for a grade, a score or label for the composite. */
|
|
632
|
+
export function criterionValueHint(field: Pick<ScreenFieldDefinition, "id">, operator: ScreenOperator): string {
|
|
633
|
+
if (LETTER_GRADES.has(field.id as NumericField)) return operator === "between" ? "lowest, highest grade, e.g. B, A+" : "grade, e.g. B+";
|
|
634
|
+
if (field.id === "gradeComposite") return operator === "between" ? "minimum, maximum, e.g. 3.5, 5" : "score or label, e.g. 3.5 or Strong";
|
|
635
|
+
if (field.id === "symbol" && operator === "in") return "a watchlist's name or symbols, e.g. AAPL, MSFT";
|
|
636
|
+
return operator === "between" ? "minimum, maximum" : operator === "in" ? "comma-separated values" : "threshold, e.g. 25 or 10B";
|
|
637
|
+
}
|
|
457
638
|
const SCALE: Record<string, number> = { k: 1e3, m: 1e6, b: 1e9, t: 1e12 };
|
|
458
639
|
/** A plain number or one with a k/M/B/T scale suffix: 25, -0.5, 1e6, 10B. */
|
|
459
640
|
export function parseThreshold(text: string): number | null {
|
|
@@ -465,6 +646,13 @@ export function parseThreshold(text: string): number | null {
|
|
|
465
646
|
const thresholdText = (value: number) =>
|
|
466
647
|
Math.abs(value) >= 1e6 ? formatCompact(value) : String(value);
|
|
467
648
|
|
|
649
|
+
/** A list past a category's length names its first values and counts the rest: a watchlist's 300 symbols do not fill a line. */
|
|
650
|
+
function listText(items: readonly string[]): string {
|
|
651
|
+
return items.length > MAX_CATEGORY_VALUES
|
|
652
|
+
? `${items.slice(0, 8).join(", ")} and ${items.length - 8} more`
|
|
653
|
+
: items.join(", ");
|
|
654
|
+
}
|
|
655
|
+
|
|
468
656
|
export function criterionText(criterion: ScreenCriterion): string {
|
|
469
657
|
const symbols = {
|
|
470
658
|
gte: ">=",
|
|
@@ -479,8 +667,17 @@ export function criterionText(criterion: ScreenCriterion): string {
|
|
|
479
667
|
};
|
|
480
668
|
const value = !("value" in criterion)
|
|
481
669
|
? ""
|
|
670
|
+
// Membership is 1 or 0: `S&P 500 member = yes`.
|
|
671
|
+
: MEMBERSHIP.has(criterion.field as NumericField) && typeof criterion.value === "number" && [0, 1].includes(criterion.value)
|
|
672
|
+
? ` ${criterion.value === 1 ? "yes" : "no"}`
|
|
673
|
+
// A grade reads as its letter: `Value grade >= B+`.
|
|
674
|
+
: LETTER_GRADES.has(criterion.field as NumericField)
|
|
675
|
+
? ` ${criterionInputText(criterion)}`
|
|
676
|
+
// The composite names the label a threshold starts: `Grade composite >= 4.5 (Top)`.
|
|
677
|
+
: criterion.field === "gradeComposite" && typeof criterion.value === "number"
|
|
678
|
+
? ` ${thresholdText(criterion.value)}${COMPOSITE_BANDS.some((band) => band.from === criterion.value && band.from > 1) ? ` (${compositeLabel(criterion.value)})` : ""}`
|
|
482
679
|
: Array.isArray(criterion.value)
|
|
483
|
-
? ` ${criterion.value.map((item) => (typeof item === "number" ? thresholdText(item) : item))
|
|
680
|
+
? ` ${listText(criterion.value.map((item) => (typeof item === "number" ? thresholdText(item) : item)))}`
|
|
484
681
|
: ` ${thresholdText(criterion.value)}`;
|
|
485
682
|
return `${screenLabel(criterion.field)} ${symbols[criterion.op]}${value}`;
|
|
486
683
|
}
|
|
@@ -488,6 +685,8 @@ export function criterionText(criterion: ScreenCriterion): string {
|
|
|
488
685
|
const OBSERVED_SUBSET_FIELDS: readonly string[] = ["insiderPurchases90d", "insiderSales90d"];
|
|
489
686
|
const NUMERIC_OPERATORS: ScreenOperator[] = ["gte", "lte", "gt", "lt", "eq", "between", "present", "missing"];
|
|
490
687
|
const OBSERVED_SUBSET_OPERATORS: ScreenOperator[] = ["gte", "gt", "present", "missing"];
|
|
688
|
+
/** Index membership is 1 or 0: equal to one, or there or not. */
|
|
689
|
+
const MEMBERSHIP_OPERATORS: ScreenOperator[] = ["eq", "present", "missing"];
|
|
491
690
|
const CATEGORY_OPERATORS: ScreenOperator[] = ["in", "present", "missing"];
|
|
492
691
|
|
|
493
692
|
/**
|
|
@@ -513,6 +712,7 @@ function unknownFieldText(field: unknown): string {
|
|
|
513
712
|
/** The operators a definition may use on a field, or null for a field screens do not have. */
|
|
514
713
|
function screenFieldOperators(field: string): ScreenOperator[] | null {
|
|
515
714
|
if (OBSERVED_SUBSET_FIELDS.includes(field)) return [...OBSERVED_SUBSET_OPERATORS];
|
|
715
|
+
if ((MEMBERSHIP_FIELDS as readonly string[]).includes(field)) return [...MEMBERSHIP_OPERATORS];
|
|
516
716
|
if ((NUMERIC_FIELDS as readonly string[]).includes(field)) return [...NUMERIC_OPERATORS];
|
|
517
717
|
if ((CATEGORY_FIELDS as readonly string[]).includes(field)) return [...CATEGORY_OPERATORS];
|
|
518
718
|
return null;
|
|
@@ -530,7 +730,10 @@ export function screenDefinitionSyntax(): string {
|
|
|
530
730
|
`Operators by field: numeric fields (the --metric values) take ${single.join(", ")} with one number,`,
|
|
531
731
|
"between with [min, max], present and missing with no value;",
|
|
532
732
|
`${OBSERVED_SUBSET_FIELDS.join(" and ")} take only ${OBSERVED_SUBSET_OPERATORS.join(", ")};`,
|
|
533
|
-
|
|
733
|
+
`${MEMBERSHIP_FIELDS.join(" and ")} take only ${MEMBERSHIP_OPERATORS.join(", ")}, eq with 1 for a member or 0;`,
|
|
734
|
+
`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);`,
|
|
735
|
+
`category fields (${CATEGORY_FIELDS.join(", ")}) take in with an array of 1-${MAX_CATEGORY_VALUES} names, present, missing;`,
|
|
736
|
+
`symbol takes up to ${MAX_SYMBOL_VALUES}, or one watchlist's name, which reads as its symbols.`,
|
|
534
737
|
].join(" ");
|
|
535
738
|
}
|
|
536
739
|
|
|
@@ -546,8 +749,16 @@ export const EXAMPLE_SCREEN_DEFINITION: ScreenDefinition = {
|
|
|
546
749
|
sort: { field: "marketCap", direction: "desc" },
|
|
547
750
|
};
|
|
548
751
|
|
|
752
|
+
/** A screen of one watchlist's names: the name stands for its symbols. */
|
|
753
|
+
export const WATCHLIST_SCREEN_DEFINITION: ScreenDefinition = {
|
|
754
|
+
version: 1,
|
|
755
|
+
currency: "USD",
|
|
756
|
+
criteria: [{ field: "symbol", op: "in", value: ["Watchlist"] }],
|
|
757
|
+
sort: { field: "marketCap", direction: "desc" },
|
|
758
|
+
};
|
|
759
|
+
|
|
549
760
|
const VALUE_SHAPES: Partial<Record<ScreenOperator, string>> = {
|
|
550
|
-
in:
|
|
761
|
+
in: `an array of 1-${MAX_CATEGORY_VALUES} names (symbol: 1-${MAX_SYMBOL_VALUES}, or a watchlist's name), such as ["Gold"]`,
|
|
551
762
|
between: "[min, max] in ascending order, such as [5, 30]",
|
|
552
763
|
};
|
|
553
764
|
|
|
@@ -579,7 +790,7 @@ function checkCriterion(criterion: unknown, index: number): ScreenCriterion {
|
|
|
579
790
|
const value = item.value;
|
|
580
791
|
const shape = VALUE_SHAPES[op] ?? "one number, such as 10000000000";
|
|
581
792
|
const valid = op === "in"
|
|
582
|
-
? Array.isArray(value) && value.length >= 1 && value.length <=
|
|
793
|
+
? Array.isArray(value) && value.length >= 1 && value.length <= maxCategoryValues(field)
|
|
583
794
|
&& value.every((entry) => typeof entry === "string" && entry.trim().length > 0 && entry.length <= 120)
|
|
584
795
|
: op === "between"
|
|
585
796
|
? Array.isArray(value) && value.length === 2 && value.every((entry) => typeof entry === "number" && Number.isFinite(entry))
|
|
@@ -706,9 +917,9 @@ export function validateScreenPayload(value: unknown): ScreenPayload {
|
|
|
706
917
|
throw new Error("Invalid screener listing identity.");
|
|
707
918
|
ids.add(screenRowId(row));
|
|
708
919
|
for (const field of NUMERIC_FIELDS) {
|
|
709
|
-
// A server from before social, research, volatility, dividend, technical, option volatility, ownership
|
|
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))
|
|
920
|
+
// A server from before social, research, volatility, dividend, technical, option volatility, ownership, quality,
|
|
921
|
+
// score or grade fields omits them; they read as unavailable. A Pro field it left out was held back from this caller.
|
|
922
|
+
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
923
|
row.metrics[field] = PRO_FIELDS.has(field) ? withheldMetric() : unavailableMetric();
|
|
713
924
|
const metric = row.metrics[field];
|
|
714
925
|
if (
|