@gloom-sh/terminal 0.20.17 → 0.20.18
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/package.json +3 -1
- package/src/account/auth-dialog.tsx +19 -1
- package/src/account/billing.ts +2 -1
- package/src/account/heard-from-question.tsx +235 -0
- package/src/account/heard-from.ts +97 -0
- package/src/api-client/data.ts +3 -2
- package/src/api-client/heard-from.ts +72 -0
- package/src/api-client/index.ts +63 -6
- package/src/api-client/mna.ts +18 -0
- package/src/api-client/supply-chain.ts +9 -0
- package/src/api-client/types/billing.ts +35 -1
- package/src/app/global-shortcuts.ts +5 -3
- package/src/app/pro-welcome/keys.ts +27 -0
- package/src/app/pro-welcome/model.ts +158 -0
- package/src/app/pro-welcome/row.tsx +176 -0
- package/src/app/pro-welcome/use-pro-welcome.ts +156 -0
- package/src/app/runtime/external-profile-changes.ts +135 -0
- package/src/app.tsx +33 -2
- package/src/architecture/core-builtin-allowlist.json +1 -1
- package/src/architecture/floating-promise-allowlist.json +0 -1
- package/src/architecture/shortcut-labels-allowlist.json +1 -0
- package/src/cli/alert-listing.ts +98 -0
- package/src/cli/commands/market.ts +138 -22
- package/src/cli/commands/overview.ts +7 -1
- package/src/cli/commands/plugins.ts +3 -2
- package/src/cli/commands/search.ts +30 -6
- package/src/cli/context.ts +16 -5
- package/src/cli/csv-export.ts +2 -1
- package/src/cli/desktop-pane-shot.ts +72 -9
- package/src/cli/glossary.ts +64 -10
- package/src/cli/history-demergers.ts +117 -0
- package/src/cli/history-rows.ts +6 -2
- package/src/cli/index.ts +1 -0
- package/src/cli/known-gaps.ts +16 -0
- package/src/cli/known-us-stocks.ts +18 -0
- package/src/cli/listing-arg.ts +105 -15
- package/src/cli/pane-functions/catalog-snapshot-build.ts +83 -0
- package/src/cli/pane-functions/catalog-snapshot.json +866 -0
- package/src/cli/pane-functions/catalog-snapshot.ts +62 -0
- package/src/cli/pane-functions/catalog.ts +50 -16
- package/src/cli/pane-functions/data.ts +16 -4
- package/src/cli/pane-functions/dom.ts +24 -6
- package/src/cli/pane-functions/freshness.ts +17 -1
- package/src/cli/pane-functions/index.ts +100 -42
- package/src/cli/pane-functions/resolver.ts +8 -5
- package/src/cli/pane-functions/screenshot-assessment.ts +30 -7
- package/src/cli/pane-functions/screenshot-payload.ts +21 -0
- package/src/cli/pane-functions/screenshot-render.ts +3 -1
- package/src/cli/quote-answer.ts +32 -16
- package/src/cli/registry.ts +22 -2
- package/src/cli/result.ts +5 -4
- package/src/cli/series-search.ts +45 -6
- package/src/cli/shot-temp-dir.ts +4 -9
- package/src/components/chart/composite/legend.tsx +43 -18
- package/src/components/chart/composite/panel-surface/panel-cursor.tsx +3 -3
- package/src/components/chart/composite/price-axis-labels.tsx +7 -5
- package/src/components/chart-table/header.tsx +9 -0
- package/src/components/chart-table/layout.ts +11 -11
- package/src/components/command-bar/pane-templates/items.ts +17 -1
- package/src/components/command-bar/routes/root/provider-search.ts +10 -1
- package/src/components/command-bar/routes/root/results.ts +34 -2
- package/src/components/command-bar/routes/root/runtime.ts +8 -1
- package/src/components/command-bar/routes/ticker-search/route.ts +5 -0
- package/src/components/command-bar/workflow/alert.ts +19 -8
- package/src/components/data-table/view.tsx +15 -2
- package/src/components/form-modal/content.tsx +9 -4
- package/src/components/index.ts +1 -1
- package/src/components/layout/header.tsx +9 -5
- package/src/components/layout/pane/capture-status.ts +6 -0
- package/src/components/layout/pane/footer/index.tsx +2 -0
- package/src/components/layout/pane/footer/model.ts +113 -15
- package/src/components/layout/pane/header.tsx +16 -2
- package/src/components/market-board/index.tsx +4 -2
- package/src/components/onboarding/onboarding-frame.tsx +6 -2
- package/src/components/onboarding/onboarding-keyboard.ts +7 -1
- package/src/components/onboarding/onboarding-wizard.tsx +3 -1
- package/src/components/onboarding/portfolio-step/positions-panel.tsx +24 -15
- package/src/components/onboarding/setup-cards.ts +36 -0
- package/src/components/onboarding/use-onboarding-progress.ts +22 -1
- package/src/components/onboarding/wizard-account.ts +6 -1
- package/src/components/onboarding/wizard-model.ts +32 -6
- package/src/components/onboarding/wizard-positions.ts +1 -1
- package/src/components/sign-in-gate.tsx +3 -1
- package/src/components/toggle-list.tsx +6 -8
- package/src/components/ui/confirm-dialog.tsx +47 -7
- package/src/components/ui/data-table/types.ts +8 -0
- package/src/components/ui/display.tsx +17 -2
- package/src/components/ui/index.ts +1 -1
- package/src/components/ui/stat-grid.tsx +4 -0
- package/src/components/ui/status.tsx +13 -1
- package/src/components/ui/table-layout.ts +2 -1
- package/src/components/use-pane-notice-footer.tsx +16 -3
- package/src/data/config/store/index.ts +31 -0
- package/src/data/config/store/node.ts +61 -11
- package/src/data/config/store/normalize.ts +4 -6
- package/src/data/config/store/shared-file.ts +309 -0
- package/src/data/profile-merge.ts +299 -0
- package/src/data/sqlite/checkpointer.ts +11 -1
- package/src/data/sqlite/database.ts +1 -1
- package/src/data/ticker-repository.ts +134 -10
- package/src/data/ticker-store.ts +67 -0
- package/src/data/ticker-writes.ts +5 -0
- package/src/i18n/es.ts +27 -0
- package/src/i18n/ja.ts +27 -0
- package/src/i18n/ko.ts +27 -0
- package/src/i18n/zh-cn.ts +27 -0
- package/src/i18n/zh-tw.ts +27 -0
- package/src/layout-marketplace/gallery-desktop.tsx +2 -2
- package/src/market-data/ah-pair.ts +103 -0
- package/src/market-data/depositary-pair.ts +6 -2
- package/src/market-data/hooks.tsx +33 -2
- package/src/market-data/market/change-basis.ts +2 -1
- package/src/market-data/market/header-market.ts +11 -0
- package/src/market-data/split-terms.ts +28 -0
- package/src/plugins/builtin/account-management/footer.ts +1 -1
- package/src/plugins/builtin/account-management/keyboard.ts +4 -0
- package/src/plugins/builtin/account-management/model.ts +1 -0
- package/src/plugins/builtin/account-management/pane.tsx +75 -7
- package/src/plugins/builtin/account-management/payment-recovery-row.tsx +12 -5
- package/src/plugins/builtin/account-management/pro-cancel.tsx +197 -0
- package/src/plugins/builtin/account-management/trial-cancel.ts +1 -1
- package/src/plugins/builtin/alerts/cli-move.ts +2 -2
- package/src/plugins/builtin/alerts/cli.ts +36 -30
- package/src/plugins/builtin/alerts/constants.ts +10 -0
- package/src/plugins/builtin/alerts/earnings-listing.ts +20 -0
- package/src/plugins/builtin/alerts/format.ts +24 -8
- package/src/plugins/builtin/alerts/index.tsx +38 -9
- package/src/plugins/builtin/alerts/move-checks.ts +7 -0
- package/src/plugins/builtin/alerts/pane.tsx +1 -1
- package/src/plugins/builtin/alerts/quotes.ts +26 -2
- package/src/plugins/builtin/alerts/scheduled.ts +6 -1
- package/src/plugins/builtin/alerts/types.ts +7 -0
- package/src/plugins/builtin/analytics/manual-value.ts +61 -0
- package/src/plugins/builtin/analytics/risk-book.ts +7 -7
- package/src/plugins/builtin/analytics/risk-client.ts +26 -13
- package/src/plugins/builtin/analytics/risk-headless.ts +13 -8
- package/src/plugins/builtin/analytics/risk-model.ts +92 -4
- package/src/plugins/builtin/analytics/risk-pane.tsx +85 -38
- package/src/plugins/builtin/awards/pane.tsx +1 -1
- package/src/plugins/builtin/broker-trading/orders.tsx +2 -2
- package/src/plugins/builtin/central-bank-rates/model.ts +8 -2
- package/src/plugins/builtin/central-bank-rates/pane.tsx +5 -3
- package/src/plugins/builtin/chart-composer/cli-options.ts +4 -2
- package/src/plugins/builtin/chart-composer/data-catalog-pane.tsx +2 -6
- package/src/plugins/builtin/chart-composer/pane.tsx +5 -2
- package/src/plugins/builtin/cloud/auth-actions.tsx +11 -6
- package/src/plugins/builtin/cloud/company-picker.tsx +5 -3
- package/src/plugins/builtin/cloud/upgrade-command.ts +1 -1
- package/src/plugins/builtin/company-kpis/headless.ts +9 -4
- package/src/plugins/builtin/company-kpis/latest.ts +45 -0
- package/src/plugins/builtin/company-kpis/model.ts +38 -8
- package/src/plugins/builtin/company-kpis/pane.tsx +22 -8
- package/src/plugins/builtin/composite/alt-data.ts +20 -0
- package/src/plugins/builtin/composite/application.ts +14 -0
- package/src/plugins/builtin/composite/broker.ts +12 -0
- package/src/plugins/builtin/composite/credit.ts +33 -0
- package/src/plugins/builtin/composite/crypto.ts +10 -0
- package/src/plugins/builtin/composite/earnings.ts +12 -0
- package/src/plugins/builtin/composite/filings.ts +13 -0
- package/src/plugins/builtin/composite/futures-commodities.ts +23 -0
- package/src/plugins/builtin/composite/global-markets.ts +12 -0
- package/src/plugins/builtin/composite/options-volatility.ts +23 -0
- package/src/plugins/builtin/composite/ownership.ts +23 -0
- package/src/plugins/builtin/composite/portfolio.ts +10 -0
- package/src/plugins/builtin/composite/quant.ts +15 -0
- package/src/plugins/builtin/composite/rates-macro.ts +30 -0
- package/src/plugins/builtin/composite/screeners.ts +11 -0
- package/src/plugins/builtin/composite/shared.ts +11 -0
- package/src/plugins/builtin/composite/ticker-core.ts +36 -0
- package/src/plugins/builtin/congress-trades/headless.ts +31 -3
- package/src/plugins/builtin/correlation/index.tsx +13 -17
- package/src/plugins/builtin/correlation/matrix/model.ts +18 -0
- package/src/plugins/builtin/dividend-yield/client.ts +57 -16
- package/src/plugins/builtin/dividend-yield/headless.ts +17 -11
- package/src/plugins/builtin/dividend-yield/model.ts +4 -3
- package/src/plugins/builtin/dividend-yield/pane.tsx +22 -18
- package/src/plugins/builtin/dividend-yield/ranking.ts +1 -1
- package/src/plugins/builtin/dividend-yield/types.ts +4 -0
- package/src/plugins/builtin/dividend-yield/view.ts +23 -12
- package/src/plugins/builtin/earnings/fiscal-quarter.ts +39 -0
- package/src/plugins/builtin/earnings/headless.ts +7 -4
- package/src/plugins/builtin/earnings/history-model.ts +6 -4
- package/src/plugins/builtin/earnings/history-table.ts +4 -3
- package/src/plugins/builtin/earnings-calls/pane.tsx +8 -2
- package/src/plugins/builtin/econ/calendar-model.ts +16 -0
- package/src/plugins/builtin/econ/index.tsx +3 -0
- package/src/plugins/builtin/equity-screener/headless.ts +4 -1
- package/src/plugins/builtin/equity-screener/model.ts +7 -6
- package/src/plugins/builtin/estimate-revisions/headless.ts +1 -1
- package/src/plugins/builtin/exposure/model.ts +10 -0
- package/src/plugins/builtin/exposure/pane.tsx +10 -3
- package/src/plugins/builtin/fx-matrix/amount.ts +15 -1
- package/src/plugins/builtin/fx-matrix/headless.ts +12 -6
- package/src/plugins/builtin/fx-matrix/index.tsx +23 -5
- package/src/plugins/builtin/fx-matrix/settings.ts +9 -4
- package/src/plugins/builtin/kelly-sizer/pane.tsx +9 -4
- package/src/plugins/builtin/market-valuation/pane.tsx +22 -10
- package/src/plugins/builtin/mna/detail.tsx +67 -6
- package/src/plugins/builtin/mna/headless.ts +128 -13
- package/src/plugins/builtin/mna/model.ts +219 -16
- package/src/plugins/builtin/mna/pane.tsx +34 -6
- package/src/plugins/builtin/money-markets/model.ts +14 -5
- package/src/plugins/builtin/money-markets/pane.tsx +4 -3
- package/src/plugins/builtin/news/wire/news/footer.ts +3 -8
- package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +22 -6
- package/src/plugins/builtin/options-scenario/csp-screen.ts +39 -12
- package/src/plugins/builtin/options-scenario/strategy-screen.ts +7 -5
- package/src/plugins/builtin/pe-band/client.ts +13 -1
- package/src/plugins/builtin/pe-band/headless.ts +2 -2
- package/src/plugins/builtin/pe-band/model.ts +63 -10
- package/src/plugins/builtin/pe-band/pane.tsx +5 -5
- package/src/plugins/builtin/portfolio-list/allocation-rows.ts +26 -7
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +66 -13
- package/src/plugins/builtin/portfolio-list/cli/render.ts +76 -33
- package/src/plugins/builtin/portfolio-list/headless.ts +69 -22
- package/src/plugins/builtin/portfolio-list/pane/data.ts +3 -3
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +29 -14
- package/src/plugins/builtin/portfolio-list/summary/index.tsx +2 -2
- package/src/plugins/builtin/relative-rotation/pane.tsx +2 -3
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +5 -1
- package/src/plugins/builtin/research/event-model.ts +31 -13
- package/src/plugins/builtin/research/headless.ts +8 -1
- package/src/plugins/builtin/research/relative-valuation-pane.tsx +19 -17
- package/src/plugins/builtin/sectors/index.tsx +6 -9
- package/src/plugins/builtin/shared/cloud-upgrade.ts +1 -1
- package/src/plugins/builtin/shared/earnings-report.ts +19 -4
- package/src/plugins/builtin/shared/report-freshness.ts +2 -3
- package/src/plugins/builtin/supply-chain/client.ts +34 -9
- package/src/plugins/builtin/supply-chain/evidence.ts +3 -2
- package/src/plugins/builtin/supply-chain/flow.tsx +4 -3
- package/src/plugins/builtin/supply-chain/graph-model.ts +14 -7
- package/src/plugins/builtin/supply-chain/graph-pane.tsx +3 -1
- package/src/plugins/builtin/supply-chain/graph.tsx +6 -3
- package/src/plugins/builtin/supply-chain/headless.ts +19 -4
- package/src/plugins/builtin/supply-chain/model.ts +50 -6
- package/src/plugins/builtin/supply-chain/pane.tsx +76 -16
- package/src/plugins/builtin/ticker-detail/adr-pair/ah.ts +62 -0
- package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +119 -20
- package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +51 -1
- package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +25 -14
- package/src/plugins/builtin/ticker-detail/overview/model.ts +17 -1
- package/src/plugins/builtin/ticker-detail/overview/pane.tsx +4 -0
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +9 -2
- package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +9 -2
- package/src/plugins/builtin/ticker-detail/quote-monitor/index.tsx +5 -2
- package/src/plugins/builtin/volatility/model.ts +17 -0
- package/src/plugins/builtin/volatility/pane.tsx +13 -4
- package/src/plugins/builtin/world-indices/index.tsx +2 -0
- package/src/plugins/builtin/world-indices/table.tsx +15 -0
- package/src/plugins/builtin/world-venue-map/evidence.ts +3 -2
- package/src/plugins/builtin/world-venue-map/headless.ts +28 -16
- package/src/plugins/builtin/world-venue-map/index.ts +19 -6
- package/src/plugins/builtin/world-venue-map/layered-pane.tsx +9 -5
- package/src/plugins/builtin/world-venue-map/layers.ts +33 -11
- package/src/plugins/builtin/world-venue-map/map.tsx +12 -0
- package/src/plugins/builtin/world-venue-map/pane.tsx +35 -6
- package/src/plugins/builtin/world-venue-map/place.ts +119 -0
- package/src/plugins/catalog-data.ts +20 -0
- package/src/plugins/catalog-lazy.ts +51 -0
- package/src/plugins/catalog-ui.ts +16 -18
- package/src/plugins/host-smoke.ts +5 -2
- package/src/portfolio/allocation.ts +79 -19
- package/src/portfolio/cash-balances.ts +76 -0
- package/src/portfolio/mutations.ts +43 -8
- package/src/public/__snapshots__/public-api.test.ts.snap +1 -0
- package/src/renderers/desktop/window-layouts.ts +14 -0
- package/src/renderers/dom/data-table/row.tsx +2 -0
- package/src/renderers/dom/host/tabs.tsx +57 -8
- package/src/renderers/dom/styles.css +13 -5
- package/src/renderers/electrobun/bun/desktop/backend-requests.ts +4 -0
- package/src/renderers/electrobun/bun/desktop/backend.ts +22 -1
- package/src/renderers/electrobun/bun/window/native-min-size.ts +6 -1
- package/src/renderers/electrobun/shared/protocol.ts +4 -0
- package/src/renderers/electrobun/view/cli-pane-shot-frame.tsx +50 -12
- package/src/renderers/electrobun/view/remote/ticker-repository.ts +10 -0
- package/src/series/standalone-catalog.ts +5 -4
- package/src/series/standalone.ts +13 -7
- package/src/sources/gloomberb-cloud/index.ts +14 -3
- package/src/sources/gloomberb-cloud/perpetuals.ts +60 -3
- package/src/sources/provider-router/financials.ts +20 -13
- package/src/sources/provider-router/index.ts +4 -0
- package/src/sources/provider-router/search.ts +1 -0
- package/src/sync/collections-contributor.ts +3 -1
- package/src/sync/config-merge.ts +10 -1
- package/src/sync/sanitize.ts +26 -2
- package/src/tickers/company-name-listing.ts +16 -2
- package/src/tickers/listing-fate.ts +12 -8
- package/src/tickers/renamed-listings.ts +43 -10
- package/src/tickers/search/home-listing.ts +28 -0
- package/src/tickers/search/index.ts +19 -7
- package/src/tickers/terminal-codes.ts +11 -1
- package/src/time-series/resolve.ts +3 -1
- package/src/time-series/spec.ts +2 -2
- package/src/time-series/types.ts +1 -1
- package/src/types/data-provider.ts +11 -0
- package/src/types/financials.ts +39 -3
- package/src/types/ticker.ts +10 -2
- package/src/utils/cli-output.ts +1 -1
- package/src/utils/declared-dividends.ts +13 -1
- package/src/utils/dividend-cash.ts +5 -1
- package/src/utils/forward-dividend.ts +4 -3
- package/src/utils/remove-folder.ts +37 -0
- package/src/utils/trailing-dividend.ts +1 -1
- package/src/plugins/builtin/composite-plugins.ts +0 -285
|
@@ -5,7 +5,7 @@ import { firstDailyCheck, metricAvailabilityError, metricReadings } from "./metr
|
|
|
5
5
|
import { ALERT_ADD_FORMS, ALERT_KINDS_TEXT, parseRuleAddArgs, RULE_US_DATA, ruleDelivery, type RuleAddRequest } from "./cli-forms";
|
|
6
6
|
import { alertChangeEntry, appendAlertLog, type AlertLogAction } from "./fired-log";
|
|
7
7
|
import { alertLogRule } from "./alert-log";
|
|
8
|
-
import { alertListing, alertReadingAt, alertReadingText, isoUtc, listingWithCurrency, measureLabel, NOT_CHECKED_YET } from "./format";
|
|
8
|
+
import { alertListing, alertReadingAt, alertReadingText, isoUtc, listingWithCurrency, measureLabel, NOT_CHECKED_YET, readingSessionWords } from "./format";
|
|
9
9
|
import { isQuoteStaleForCurrentSession } from "../../../market-data/quotes/freshness";
|
|
10
10
|
import { quoteAlertFields } from "./quotes";
|
|
11
11
|
import { createEventAlert } from "./events";
|
|
@@ -18,13 +18,14 @@ import { checkedWhenSignedIn, NEEDS_SIGN_IN, needsSignInNote } from "./event-row
|
|
|
18
18
|
import { CLI_COMMAND_GROUPS } from "../../../cli/help";
|
|
19
19
|
import { dryRunNote } from "../../../cli/helpers";
|
|
20
20
|
import { requireArg, takeOption } from "../../../cli/commands/command-utils";
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
21
|
+
import { AlertListingRefusal, resolveAlertListing } from "../../../cli/alert-listing";
|
|
22
|
+
import { earningsListingVenue } from "./earnings-listing";
|
|
23
|
+
import { coinListingNotes, EXCHANGE_OPTION, listingReadNotes, requireListingArg, usListingsOnlyMessage, type ListingDeps } from "../../../cli/listing-arg";
|
|
23
24
|
import { saveConfig } from "../../../data/config/store";
|
|
24
25
|
import { resumeStateKey } from "../../registry/plugin-state";
|
|
25
26
|
import type { CliCommandDef } from "../../../types/plugin";
|
|
26
27
|
import type { Quote } from "../../../types/financials";
|
|
27
|
-
import { getActiveQuoteDisplay } from "../../../market-data/market/status";
|
|
28
|
+
import { extendedPrintSession, getActiveQuoteDisplay } from "../../../market-data/market/status";
|
|
28
29
|
import { cliStyles } from "../../../utils/cli-output";
|
|
29
30
|
import { canonicalExchange, isUsListingExchange, parsePublicTickerKey } from "../../../utils/exchanges";
|
|
30
31
|
import { isRoundTheClockCoin } from "../../../utils/crypto-pair";
|
|
@@ -51,13 +52,13 @@ import {
|
|
|
51
52
|
} from "./calendar-events";
|
|
52
53
|
import { createAlert, formatAlertDescription, levelAlreadyMet, rearmAlert, sameLevelRule } from "./alert-engine";
|
|
53
54
|
import { alertPriceText } from "./price-text";
|
|
54
|
-
import { ALERTS_PLUGIN_ID } from "./constants";
|
|
55
|
+
import { ALERTS_PLUGIN_ID, PRICE_DELIVERY } from "./constants";
|
|
55
56
|
import { MAX_EVENT_ALERTS, eventAlertTarget, toggleEventAlert, writeEventAlertStores, type EventAlertRule } from "./events";
|
|
56
57
|
import { alertKindLabel, fetchAlertHistory, ruleStateText, type AlertRuleState } from "./history";
|
|
57
58
|
import { apiClient } from "../../../api-client";
|
|
58
59
|
import { IV_LEVEL_CHECKS_KEY, ivLevelCheckText, readIvLevelChecks, rearmIvLevelAlert, type IvLevelCheck } from "./iv-level";
|
|
59
60
|
import { isPenceLevel, parseAlertPrice, readAlertLevel } from "./price";
|
|
60
|
-
import { farTargetMessage, levelInQuoteUnit } from "./quotes";
|
|
61
|
+
import { commodityFutureNote, farTargetMessage, levelInQuoteUnit } from "./quotes";
|
|
61
62
|
import { isPenceQuotedLine } from "../../../market-data/market/format";
|
|
62
63
|
import { MACRO_EVENT_NAMES, createResearchAlert, formatPremium, ivLevelUnitError, parseAmount, parseIvLevel } from "./research-builder";
|
|
63
64
|
import { IV_LEVEL_RANGES, MAX_LEAD_DAYS, type IvLevelMetric, type MacroAlertEvent } from "./research-rules";
|
|
@@ -93,14 +94,6 @@ import { MOVE_CHECKS_KEY, moveChecksOf, readMoveChecks, withMoveChecks, type Mov
|
|
|
93
94
|
import { listAddLookups } from "../portfolio-list/cli/bulk-symbols";
|
|
94
95
|
import type { AlertCondition, AlertRule } from "./types";
|
|
95
96
|
|
|
96
|
-
/**
|
|
97
|
-
* What delivers a price alert, as docs/usage.md states it: the app checks it on
|
|
98
|
-
* every tick while it runs. Signed in with Cloud sync on, Gloom Cloud also
|
|
99
|
-
* pushes the trigger to a registered phone, and emails it once no app has
|
|
100
|
-
* synced the account for a while, so a rule the app has synced reaches you
|
|
101
|
-
* with the app closed. Signed out, only the running app does.
|
|
102
|
-
*/
|
|
103
|
-
const PRICE_DELIVERY = "the app alerts while it is running; sign in with Cloud sync for email or phone alerts when it is closed";
|
|
104
97
|
|
|
105
98
|
const ADD_USAGE = `Usage: gloom alerts add <symbol> <above|below|crosses> <price>, or another kind. ${ALERT_KINDS_TEXT}`;
|
|
106
99
|
const DAYS_RULE = `--days takes a whole number of days from 1 to ${MAX_LEAD_DAYS}; without it the alert goes off 1 day before.`;
|
|
@@ -110,11 +103,6 @@ const COUNTRY_RULE = "--country is for an alert on a calendar event, such as ale
|
|
|
110
103
|
const BENCHMARK_RULE = "--benchmark takes the listing an RRG alert is measured against (SPY by default, as in RRG),";
|
|
111
104
|
/** `XLK/SPY`, `XLK:NYSEARCA/SPY`: two listings, or one written with a slash (BRK/B, EUR/USD). */
|
|
112
105
|
const PAIR_SHAPE = /^[^/\s]+\/[^/\s]+$/;
|
|
113
|
-
/** A listing check that hands back its refusal instead of ending the command, so a pair can be read as a ratio. */
|
|
114
|
-
class ListingRefusal extends Error {
|
|
115
|
-
constructor(message: string, readonly details?: string) { super(message); }
|
|
116
|
-
}
|
|
117
|
-
const PROBE = { fail: (message: string, details?: string): never => { throw new ListingRefusal(message, details); } };
|
|
118
106
|
|
|
119
107
|
/** What `alerts add` was asked for, before any listing or date is looked up. */
|
|
120
108
|
export type AlertAddRequest =
|
|
@@ -888,6 +876,14 @@ export const alertsCliCommand: CliCommandDef = {
|
|
|
888
876
|
const now = Date.now();
|
|
889
877
|
const today = newYorkToday(new Date(now));
|
|
890
878
|
const failWith = (error: unknown): never => ctx.fail(error instanceof Error ? error.message : String(error));
|
|
879
|
+
// A symbol whose company moved names the same add on its new symbol.
|
|
880
|
+
const alertRetry = (symbol: string) => `gloom alerts add ${symbol} ${args.slice(2).join(" ")}`;
|
|
881
|
+
// The listing an alert follows, read as `quote` reads it and held to one that trades (`resolveAlertListing`).
|
|
882
|
+
const requireAlertListing = (typed: string, market: ListingDeps, exchange: string | null | undefined = exchangeOption) =>
|
|
883
|
+
resolveAlertListing(typed, exchange, market, { retry: alertRetry }).catch((error: unknown) => {
|
|
884
|
+
if (error instanceof AlertListingRefusal) return ctx.fail(error.message, error.details);
|
|
885
|
+
throw error;
|
|
886
|
+
});
|
|
891
887
|
|
|
892
888
|
const parseAdd = (): AlertAddRequest => {
|
|
893
889
|
try {
|
|
@@ -916,18 +912,18 @@ export const alertsCliCommand: CliCommandDef = {
|
|
|
916
912
|
// of several, each that fails is named in the summary.
|
|
917
913
|
if (unique.inputs.length === 1) {
|
|
918
914
|
const input = unique.inputs[0]!.input;
|
|
919
|
-
const quoted = await
|
|
915
|
+
const quoted = await requireAlertListing(input, market);
|
|
920
916
|
const exchange = quoted.listing.exchange || canonicalExchange(quoted.quote.listingExchangeName || quoted.quote.exchangeName);
|
|
921
917
|
return { listings: [{ input, listing: { symbol: quoted.listing.key, ...exchange ? { exchange } : {} }, quote: quoted.quote, notes: quoted.notes }], repeats: unique.repeats, leftOut: 0 };
|
|
922
918
|
}
|
|
923
|
-
const listings = await quoteTypedSymbols(unique.inputs.map((entry) => entry.input), (symbol) =>
|
|
919
|
+
const listings = await quoteTypedSymbols(unique.inputs.map((entry) => entry.input), (symbol) => resolveAlertListing(symbol, exchangeOption, market, { retry: alertRetry }));
|
|
924
920
|
return { listings, repeats: unique.repeats, leftOut: unique.leftOut };
|
|
925
921
|
});
|
|
926
922
|
}
|
|
927
923
|
// XLK/SPY is first a listing written with a slash (BRK/B, EUR/USD); one that quotes nothing is the ratio of the two.
|
|
928
924
|
const pairListing = typedRequest?.kind === "price" && PAIR_SHAPE.test(typedRequest.symbol)
|
|
929
|
-
? await withMarketData(ctx, (market) =>
|
|
930
|
-
if (!(error instanceof
|
|
925
|
+
? await withMarketData(ctx, (market) => resolveAlertListing(typedRequest.symbol, exchangeOption, market, { retry: alertRetry })).catch((error: unknown) => {
|
|
926
|
+
if (!(error instanceof AlertListingRefusal)) throw error;
|
|
931
927
|
if (!notATickerSymbol(error.message)) return ctx.fail(error.message, error.details);
|
|
932
928
|
return null;
|
|
933
929
|
})
|
|
@@ -952,7 +948,7 @@ export const alertsCliCommand: CliCommandDef = {
|
|
|
952
948
|
// a news, flow or IV rule on a symbol follows that listing too, and only in the US, where their data is.
|
|
953
949
|
const priced = pairListing ? pairListing : listedSymbol
|
|
954
950
|
? await withMarketData(ctx, async (market) => {
|
|
955
|
-
const quoted = await
|
|
951
|
+
const quoted = await requireAlertListing(listedSymbol, market);
|
|
956
952
|
// BTC-USD and ETH-USD have Deribit's options, which OPX and OVDV read: an IV level or risk reversal follows that fit.
|
|
957
953
|
const coinOptions = research?.kind === "iv_level" && listedCoinOptions(quoted.listing.key) != null;
|
|
958
954
|
if (usOnly && !coinOptions) {
|
|
@@ -972,6 +968,9 @@ export const alertsCliCommand: CliCommandDef = {
|
|
|
972
968
|
// A bare coin ticker read as another listing (SOL, a stale company; BTC, the Grayscale trust) gets `quote`'s note
|
|
973
969
|
// naming the coin's pair, before a metric alert names the venue it was read on.
|
|
974
970
|
const coinNote = priced ? coinListingNotes(priced.listing, priced.quote)[0] ?? null : null;
|
|
971
|
+
// GOLD is Gold.com, whose price is no gold future's: `quote` names GC=F beside it, and so does the alert.
|
|
972
|
+
const futureNote = priced && listedSymbol && !exchangeOption && !coinNote
|
|
973
|
+
? commodityFutureNote(listedSymbol, priced.quote, request?.kind === "price" ? alertRetry : null) : null;
|
|
975
974
|
// What the alert reads now, which it is saved with, so lists and ALRT show it before the app has run.
|
|
976
975
|
let reading: Partial<AlertRule> = {};
|
|
977
976
|
// A daily rule whose close could not be read yet: why, which the add says beside when it is first checked.
|
|
@@ -983,7 +982,7 @@ export const alertsCliCommand: CliCommandDef = {
|
|
|
983
982
|
const typedMetric = request.metric;
|
|
984
983
|
if (isRelativeMetric(typedMetric)) {
|
|
985
984
|
// The benchmark is held to a listing that quotes, as the symbol is.
|
|
986
|
-
const reference = await withMarketData(ctx, (market) =>
|
|
985
|
+
const reference = await withMarketData(ctx, (market) => requireAlertListing(benchmarkKey(typedMetric), market, null));
|
|
987
986
|
const benchmarkExchange = canonicalExchange(reference.listing.exchange || reference.quote.listingExchangeName || reference.quote.exchangeName);
|
|
988
987
|
if (reference.listing.symbol === priced.listing.symbol && benchmarkExchange === exchange) {
|
|
989
988
|
ctx.fail(`${typedMetric.kind === "rrg" ? "An RRG alert" : "A ratio alert"} compares two listings; ${priced.listing.symbol} is on both sides.`);
|
|
@@ -1033,7 +1032,7 @@ export const alertsCliCommand: CliCommandDef = {
|
|
|
1033
1032
|
if (request?.kind === "price" && priced) {
|
|
1034
1033
|
// A target ten times away is a slip or another instrument's price, such as bitcoin's on the BTC fund.
|
|
1035
1034
|
// Against the price the alert is checked on, as Add Alert measures it.
|
|
1036
|
-
const far = farTargetMessage(priced.listing.key, request.price, priced.quote.price, coinNote, isPenceQuotedLine(priced.quote));
|
|
1035
|
+
const far = farTargetMessage(priced.listing.key, request.price, priced.quote.price, coinNote ?? futureNote, isPenceQuotedLine(priced.quote));
|
|
1037
1036
|
if (far) ctx.fail(far);
|
|
1038
1037
|
}
|
|
1039
1038
|
// What a typed listing was read as (7203:TSE as 7203:JPX, MXN as MXN:FWB2), said beside what was added.
|
|
@@ -1042,7 +1041,7 @@ export const alertsCliCommand: CliCommandDef = {
|
|
|
1042
1041
|
&& !listedSymbol.includes(":") && !PAIR_SHAPE.test(listedSymbol)
|
|
1043
1042
|
? await withMarketData(ctx, (market) => sameNameSeriesNote(listedSymbol, priced, market.findCatalogSeriesNamed?.(listedSymbol), request))
|
|
1044
1043
|
: null;
|
|
1045
|
-
let read = [...priced?.notes ?? [], ...coinNote ? [coinNote] : [], ...seriesNote ? [seriesNote] : [], ...benchmarkNotes, ...penceNote ? [penceNote] : []];
|
|
1044
|
+
let read = [...priced?.notes ?? [], ...coinNote ? [coinNote] : [], ...futureNote ? [futureNote] : [], ...seriesNote ? [seriesNote] : [], ...benchmarkNotes, ...penceNote ? [penceNote] : []];
|
|
1046
1045
|
let newEventRule: EventAlertRule | null = null;
|
|
1047
1046
|
let newResearchRule: EventAlertRule | null = null;
|
|
1048
1047
|
if (research) {
|
|
@@ -1114,9 +1113,16 @@ export const alertsCliCommand: CliCommandDef = {
|
|
|
1114
1113
|
const target: ScheduledEventTarget = macro
|
|
1115
1114
|
? { kind: "macro", event: macro.event }
|
|
1116
1115
|
: await requireListingArg(earnings!.symbol, exchangeOption, ctx)
|
|
1117
|
-
.then((listing) => {
|
|
1116
|
+
.then(async (listing) => {
|
|
1118
1117
|
read = listingReadNotes(listing);
|
|
1119
|
-
return { kind: "earnings" as const, symbol: listing.symbol, exchange: listing.exchange };
|
|
1118
|
+
if (listing.exchange) return { kind: "earnings" as const, symbol: listing.symbol, exchange: listing.exchange };
|
|
1119
|
+
// A bare symbol is the listing `quote` reads it as: D05 and "Singtel" are on SGX, which earnings alerts do not follow.
|
|
1120
|
+
const abroad = await withMarketData(ctx, (market) => earningsListingVenue(earnings!.symbol, market, { retry: alertRetry })
|
|
1121
|
+
.catch((error: unknown) => error instanceof AlertListingRefusal ? ctx.fail(error.message, error.details) : Promise.reject(error)));
|
|
1122
|
+
read.push(...abroad.notes);
|
|
1123
|
+
return abroad.exchange
|
|
1124
|
+
? { kind: "earnings" as const, symbol: abroad.symbol, exchange: abroad.exchange }
|
|
1125
|
+
: { kind: "earnings" as const, symbol: listing.symbol, exchange: listing.exchange };
|
|
1120
1126
|
});
|
|
1121
1127
|
const lead = earnings?.results ? "results" as const : (macro ?? earnings!).leadDays;
|
|
1122
1128
|
// A listing the rule cannot follow fails before any request.
|
|
@@ -1311,7 +1317,7 @@ export const alertsCliCommand: CliCommandDef = {
|
|
|
1311
1317
|
const goesOffThen = daily && alreadyMet ? ` It goes off then if it is still ${alert.condition}.` : "";
|
|
1312
1318
|
const notes = [
|
|
1313
1319
|
alert.metric ? unread ? `Not read yet: ${unread.replace(/\.$/, "")}.` : `${metricReadingNote(alert)}${met}.`
|
|
1314
|
-
: checkedPrice != null ? `Last price ${alertPriceText(alert, checkedPrice)}${met}.` : null,
|
|
1320
|
+
: checkedPrice != null ? `Last price ${alertPriceText(alert, checkedPrice)}${readingSessionWords({ lastQuoteSession: extendedPrintSession(priced?.quote, checkedPrice) ?? undefined })}${met}.` : null,
|
|
1315
1321
|
firstCheck ? `First checked on the ${firstCheck.day} ${weekly ? "weekly close" : "close"}, from ${isoUtc(firstCheck.at).slice(11, 16)} UTC.${goesOffThen}`
|
|
1316
1322
|
: goesOffThen ? `It goes off on the first close it is checked on if it is still ${alert.condition}.` : null,
|
|
1317
1323
|
].filter(Boolean).join(" ");
|
|
@@ -10,3 +10,13 @@ export const ALERT_TABS = [
|
|
|
10
10
|
/** Fallback cadence when the pane's Check interval setting is unset. */
|
|
11
11
|
export const POLL_INTERVAL_MS = 30_000;
|
|
12
12
|
export const POLL_SECONDS_KEY = "pollSeconds";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* What delivers a price alert, as docs/usage.md states it: the app checks it on
|
|
16
|
+
* every tick while it runs. Signed in with Cloud sync on, Gloom Cloud also
|
|
17
|
+
* pushes the trigger to a registered phone, and emails it once no app has
|
|
18
|
+
* synced the account for a while, so a rule the app has synced reaches you
|
|
19
|
+
* with the app closed. Signed out, only the running app does. `alerts add`
|
|
20
|
+
* and Add Alert both say it.
|
|
21
|
+
*/
|
|
22
|
+
export const PRICE_DELIVERY = "the app alerts while it is running; sign in with Cloud sync for email or phone alerts when it is closed";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { resolveAlertListing, type AlertListingOptions } from "../../../cli/alert-listing";
|
|
2
|
+
import type { ListingDeps } from "../../../cli/listing-arg";
|
|
3
|
+
import { canonicalExchange, isUsListingExchange } from "../../../utils/exchanges";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The venue of a bare symbol an earnings alert is asked for, read as every
|
|
7
|
+
* alert reads its symbol (`resolveAlertListing`): D05 and "Singtel" are on
|
|
8
|
+
* SGX, which earnings alerts do not follow, so they get the line any listing
|
|
9
|
+
* outside the US gets. A US listing comes back without a venue, as typed.
|
|
10
|
+
* Throws `AlertListingRefusal` for a symbol no alert can follow.
|
|
11
|
+
*/
|
|
12
|
+
export async function earningsListingVenue(
|
|
13
|
+
typed: string,
|
|
14
|
+
deps: ListingDeps,
|
|
15
|
+
options: AlertListingOptions = {},
|
|
16
|
+
): Promise<{ symbol: string; exchange: string | null; notes: string[] }> {
|
|
17
|
+
const { listing, quote, notes } = await resolveAlertListing(typed, null, deps, options);
|
|
18
|
+
const venue = canonicalExchange(listing.exchange || quote.listingExchangeName || quote.exchangeName || "");
|
|
19
|
+
return { symbol: listing.symbol, exchange: venue && !isUsListingExchange(venue) ? venue : null, notes };
|
|
20
|
+
}
|
|
@@ -2,6 +2,8 @@ import { MISSING_VALUE } from "../../../utils/format";
|
|
|
2
2
|
import { closeBasis, metricName, metricReadingText, rotationQuadrant } from "./metric-model";
|
|
3
3
|
import { moveBasisText, movePercentText, moveTargetText, moveTriggerLabel } from "./move";
|
|
4
4
|
import { formatMarketPrice } from "../../../market-data/market/format";
|
|
5
|
+
import { EXTENDED_PRINT_WORDS } from "../../../market-data/market/change-basis";
|
|
6
|
+
import { EXTENDED_SESSION_MARKS } from "../../../market-data/market/status";
|
|
5
7
|
import { formatShortDate } from "../../../utils/datetime-format";
|
|
6
8
|
import { formatQuoteAgeWithSource } from "../../../market-data/quotes/time";
|
|
7
9
|
import { alertListingKey, alertPriceText } from "./price-text";
|
|
@@ -27,7 +29,12 @@ export function relativeTime(ts: number): string {
|
|
|
27
29
|
/** A price ratio to four decimals, as GR states the latest ratio. */
|
|
28
30
|
const formatRatio = (value: number) => value.toFixed(Math.abs(value) >= 100 ? 2 : 4);
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
/**
|
|
33
|
+
* The current reading in a cell: an after-hours, pre-market or overnight
|
|
34
|
+
* print marked before it as the portfolio marks a price (AH 158.78), or in
|
|
35
|
+
* words after it where there is room to say it (`words`: 158.78 after hours).
|
|
36
|
+
*/
|
|
37
|
+
export function formatCurrentPrice(alert: AlertRule, maxWidth = 9, { words = false }: { words?: boolean } = {}): string {
|
|
31
38
|
if (alert.lastCheckError) return !alert.metric ? "No quote"
|
|
32
39
|
: /US listing|US equities|calendar/.test(alert.lastCheckError) ? "US only"
|
|
33
40
|
: /missing|bars|history|weekly closes/i.test(alert.lastCheckError) ? "Bar gap" : "No data";
|
|
@@ -35,10 +42,19 @@ export function formatCurrentPrice(alert: AlertRule, maxWidth = 9): string {
|
|
|
35
42
|
if (alert.metric?.kind === "rrg") return rotationQuadrant(alert.lastCheckedPrice, alert.lastCheckedTarget) ?? MISSING_VALUE;
|
|
36
43
|
if (alert.metric?.kind === "rs_ratio" && alert.lastCheckedPrice != null) return formatRatio(alert.lastCheckedPrice);
|
|
37
44
|
if (alert.lastCheckedPrice == null) return MISSING_VALUE;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
// A price at its instrument's precision (1.34032 on GBP/USD, 117.35p
|
|
41
|
-
|
|
45
|
+
const session = alert.metric ? undefined : alert.lastQuoteSession;
|
|
46
|
+
const mark = session && !words ? `${EXTENDED_SESSION_MARKS[session]} ` : "";
|
|
47
|
+
// A move rule reads the day's move: -0.38%. A price at its instrument's precision (1.34032 on GBP/USD, 117.35p
|
|
48
|
+
// on a London line), as `quote` prints it.
|
|
49
|
+
const figure = alert.move ? movePercentText(alert.lastCheckedPrice)
|
|
50
|
+
: alert.metric ? formatMarketPrice(alert.lastCheckedPrice, { maxWidth, minimumFractionDigits: 2 })
|
|
51
|
+
: alertPriceText(alert, alert.lastCheckedPrice, Math.max(1, maxWidth - mark.length));
|
|
52
|
+
return session && words ? `${figure} ${EXTENDED_PRINT_WORDS[session]}` : `${mark}${figure}`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** " after hours" after a reading that is an extended session's print; nothing for the regular session's. */
|
|
56
|
+
export function readingSessionWords(alert: Pick<AlertRule, "lastQuoteSession" | "metric">): string {
|
|
57
|
+
return alert.lastQuoteSession && !alert.metric ? ` ${EXTENDED_PRINT_WORDS[alert.lastQuoteSession]}` : "";
|
|
42
58
|
}
|
|
43
59
|
|
|
44
60
|
export function formatAlertTargetPrice(alert: AlertRule, maxWidth = 9): string {
|
|
@@ -135,7 +151,7 @@ export function alertReadingText(alert: AlertRule): string {
|
|
|
135
151
|
// A move, with the close it is measured from: `-0.38% vs Thu 5 Nov close as of 2026-11-06T08:47Z`.
|
|
136
152
|
if (alert.move) {
|
|
137
153
|
const at = alertReadingAt(alert);
|
|
138
|
-
const figure = `${movePercentText(value)} ${moveBasisText(alert.lastMoveBasis)}`;
|
|
154
|
+
const figure = `${movePercentText(value)}${readingSessionWords(alert)} ${moveBasisText(alert.lastMoveBasis)}`;
|
|
139
155
|
return at ? `${figure} as of ${isoUtc(at).replace(/:\d{2}Z$/, "Z")}` : figure;
|
|
140
156
|
}
|
|
141
157
|
const unit = readingUnit(alert);
|
|
@@ -144,8 +160,8 @@ export function alertReadingText(alert: AlertRule): string {
|
|
|
144
160
|
const price = !alert.metric ? alertPriceText(alert, value) : null;
|
|
145
161
|
const figure = alert.metric?.kind === "rrg" ? metricReadingText(alert.metric, { value, target: alert.lastCheckedTarget ?? Number.NaN })
|
|
146
162
|
: alert.metric?.kind === "rs_ratio" ? formatRatio(value)
|
|
147
|
-
: price?.endsWith("p") ? price
|
|
148
|
-
: `${price ?? value.toFixed(2)}${unit === "x" ? "x" : unit ? ` ${unit}` : ""}`;
|
|
163
|
+
: price?.endsWith("p") ? `${price}${readingSessionWords(alert)}`
|
|
164
|
+
: `${price ?? value.toFixed(2)}${unit === "x" ? "x" : unit ? ` ${unit}` : ""}${readingSessionWords(alert)}`;
|
|
149
165
|
const basis = alert.metric ? closeBasis(alert.metric) : null;
|
|
150
166
|
if (basis && alert.lastDailyClose) return `${figure} on the ${alert.lastDailyClose} ${basis === "weekly close" ? "weekly close" : "close"}`;
|
|
151
167
|
const at = alertReadingAt(alert);
|
|
@@ -13,6 +13,7 @@ import { newYorkToday } from "../earnings/board-model";
|
|
|
13
13
|
import { checkScheduledEventAlertsNow, startScheduledEventAlerts } from "./scheduled-check";
|
|
14
14
|
import { scheduledEventSources } from "./scheduled-sources";
|
|
15
15
|
import {
|
|
16
|
+
earningsUsOnlyMessage,
|
|
16
17
|
eventDateUnavailableMessage,
|
|
17
18
|
lookupScheduledDates,
|
|
18
19
|
noUpcomingEventMessage,
|
|
@@ -22,7 +23,8 @@ import {
|
|
|
22
23
|
} from "./scheduled";
|
|
23
24
|
import { isResearchAlertKind, MAX_LEAD_DAYS } from "./research-rules";
|
|
24
25
|
import { EVENT_ALERT_TEMPLATES, MAX_EVENT_ALERTS, createEventAlert, eventAlertStoreKey, readEventAlertStores, updateEventAlerts } from "./events";
|
|
25
|
-
import {
|
|
26
|
+
import { AlertListingRefusal, resolveAlertListing } from "../../../cli/alert-listing";
|
|
27
|
+
import { earningsListingVenue } from "./earnings-listing";
|
|
26
28
|
import { parseListingArg } from "../../../cli/listing-arg";
|
|
27
29
|
import { notATickerSymbol } from "../../../sources/provider-errors";
|
|
28
30
|
import type { Quote } from "../../../types/financials";
|
|
@@ -38,16 +40,18 @@ import {
|
|
|
38
40
|
parseAlertCommandValues,
|
|
39
41
|
parseAlertShortcutValues,
|
|
40
42
|
} from "./command";
|
|
41
|
-
import { ALERTS_PLUGIN_ID, POLL_INTERVAL_MS, POLL_SECONDS_KEY } from "./constants";
|
|
43
|
+
import { ALERTS_PLUGIN_ID, POLL_INTERVAL_MS, POLL_SECONDS_KEY, PRICE_DELIVERY } from "./constants";
|
|
42
44
|
import { alertHistoryLockNote, alertsHeadless } from "./headless";
|
|
43
45
|
import { alertsCliCommand } from "./cli";
|
|
44
46
|
import {
|
|
47
|
+
commodityFutureNote,
|
|
45
48
|
createQuoteErrorMessage,
|
|
46
49
|
farTargetMessage,
|
|
47
50
|
levelInQuoteUnit,
|
|
48
51
|
moveQuoteFields,
|
|
49
52
|
quoteAlertFields,
|
|
50
53
|
quoteErrorAlertFields,
|
|
54
|
+
alertQuote,
|
|
51
55
|
resolveAlertQuote,
|
|
52
56
|
resolveAlertQuotes,
|
|
53
57
|
} from "./quotes";
|
|
@@ -60,7 +64,7 @@ import { createAlertQuoteStream, readStreamedAlertQuote, type AlertQuoteStream }
|
|
|
60
64
|
import { alertPriceText } from "./price-text";
|
|
61
65
|
import { isPenceQuotedLine } from "../../../market-data/market/format";
|
|
62
66
|
import { judgeMove, moveBasisText, moveFiredText } from "./move";
|
|
63
|
-
import { alertListing } from "./format";
|
|
67
|
+
import { alertListing, readingSessionWords } from "./format";
|
|
64
68
|
import type { AlertRule } from "./types";
|
|
65
69
|
|
|
66
70
|
let catalystAlertsStop: (() => void) | null = null;
|
|
@@ -264,10 +268,18 @@ export const alertsPlugin: GloomPlugin = {
|
|
|
264
268
|
async execute(values) {
|
|
265
269
|
let input = parseAlertCommandValues(values);
|
|
266
270
|
if (!input) throw new Error("Use a symbol, condition, and target price.");
|
|
267
|
-
//
|
|
271
|
+
// Read as `alerts add` and `quote` read it (`resolveAlertListing`): 7203:TSE is the venue its symbol trades on,
|
|
272
|
+
// "Singtel" is Z74:SGX, a listing that stopped trading is refused, and FB says Meta trades as META.
|
|
273
|
+
const notes: string[] = [];
|
|
268
274
|
const quoteFor = async (typed: string) => {
|
|
269
|
-
const
|
|
270
|
-
|
|
275
|
+
const found = await resolveAlertListing(typed, null, { store: ctx.tickerRepository, dataProvider: ctx.marketData })
|
|
276
|
+
.catch((error: unknown) => {
|
|
277
|
+
if (error instanceof AlertListingRefusal) throw new Error(error.details ? `${error.message} ${error.details}` : error.message);
|
|
278
|
+
throw error;
|
|
279
|
+
});
|
|
280
|
+
notes.push(...found.notes);
|
|
281
|
+
const key = found.listing.key.toUpperCase();
|
|
282
|
+
return { key, quote: alertQuote(found.quote, key) };
|
|
271
283
|
};
|
|
272
284
|
let resolved: Awaited<ReturnType<typeof quoteFor>>;
|
|
273
285
|
try {
|
|
@@ -296,7 +308,9 @@ export const alertsPlugin: GloomPlugin = {
|
|
|
296
308
|
// A London line's level is in the pence its quote shows: 70p, or 70 where 70 in pounds is far off.
|
|
297
309
|
if (!input.metric) input = { ...input, price: levelInQuoteUnit(input, quote, symbol).price };
|
|
298
310
|
// A target ten times away is a slip or another instrument's price, such as bitcoin's on the BTC fund.
|
|
299
|
-
|
|
311
|
+
// GOLD is Gold.com: a target at gold's price names the future, as `alerts add` does.
|
|
312
|
+
const named = input.symbol.includes(":");
|
|
313
|
+
const far = farTargetMessage(symbol, input.price, quote.price, named ? null : notTheCoinNote(input.symbol.toUpperCase(), quote) ?? commodityFutureNote(input.symbol, quote), isPenceQuotedLine(quote));
|
|
300
314
|
if (!input.metric && far) throw new Error(far);
|
|
301
315
|
|
|
302
316
|
const alert: AlertRule = {
|
|
@@ -334,8 +348,13 @@ export const alertsPlugin: GloomPlugin = {
|
|
|
334
348
|
// A level the price is already past goes off at the next check, as `alerts add` says.
|
|
335
349
|
const met = !input.metric && levelAlreadyMet(alert.condition, quote.price, alert.targetPrice)
|
|
336
350
|
? `, already ${alert.condition}, so it goes off at the next check` : "";
|
|
351
|
+
// What delivers it and what became of the symbol, as `alerts add` says them.
|
|
337
352
|
ctx.notify({
|
|
338
|
-
body:
|
|
353
|
+
body: [
|
|
354
|
+
`Alert set: ${formatAlertDescription(alert)}${input.metric ? firstCheck ? `, ${firstCheck}` : "" : ` (current ${alertPriceText(alert, quote.price)}${readingSessionWords(alert)}${met})`}.`,
|
|
355
|
+
`${PRICE_DELIVERY.charAt(0).toUpperCase()}${PRICE_DELIVERY.slice(1)}.`,
|
|
356
|
+
...notes.map((note) => /[.?!]$/.test(note) ? note : `${note}.`),
|
|
357
|
+
].join(" "),
|
|
339
358
|
type: "success",
|
|
340
359
|
});
|
|
341
360
|
},
|
|
@@ -358,7 +377,8 @@ export const alertsPlugin: GloomPlugin = {
|
|
|
358
377
|
key: "event",
|
|
359
378
|
label: "Event",
|
|
360
379
|
type: "select",
|
|
361
|
-
|
|
380
|
+
// Earnings first, as the command describes itself: an alert anyone can add for any US listing.
|
|
381
|
+
defaultValue: "earnings_date",
|
|
362
382
|
options: [...RESEARCH_FORM_KINDS.map((value) => ({ value, label: RESEARCH_LABELS[value] })), ...EVENT_ALERT_TEMPLATES.map((entry) => ({ label: entry.label, value: entry.id }))],
|
|
363
383
|
},
|
|
364
384
|
...EVENT_ALERT_TEMPLATES.filter((entry) => entry.field != null).map((entry) => ({
|
|
@@ -383,6 +403,15 @@ export const alertsPlugin: GloomPlugin = {
|
|
|
383
403
|
const awaitsResults = event === "earnings_date" && values["earnings_date:when"] === "results";
|
|
384
404
|
if (scheduled && !awaitsResults && parseLeadDays(values[`${event}:leadDays`]) == null)
|
|
385
405
|
throw new Error(`Days before must be a whole number from 1 to ${MAX_LEAD_DAYS}.`);
|
|
406
|
+
// A bare symbol is read as every alert reads it: D05 is on SGX, which earnings alerts do not follow, as `alerts add` says.
|
|
407
|
+
const earningsSymbol = event === "earnings_date" ? String(values["earnings_date:symbol"] ?? "").trim() : "";
|
|
408
|
+
if (earningsSymbol && (values["earnings_date:exchange"] ?? "US") === "US" && !parseListingArg(earningsSymbol).exchange) {
|
|
409
|
+
const abroad = await earningsListingVenue(earningsSymbol, { store: ctx.tickerRepository, dataProvider: ctx.marketData }).catch((error: unknown) => {
|
|
410
|
+
if (error instanceof AlertListingRefusal) throw new Error(error.details ? `${error.message} ${error.details}` : error.message);
|
|
411
|
+
throw error;
|
|
412
|
+
});
|
|
413
|
+
if (abroad.exchange) throw new Error(earningsUsOnlyMessage(`${abroad.symbol}:${abroad.exchange}`));
|
|
414
|
+
}
|
|
386
415
|
let rule = isResearchAlertKind(event) ? createResearchAlert(event, values) : createEventAlert(event, values?.[event] || "");
|
|
387
416
|
const target = scheduled ? readScheduledRule(rule)?.target : null;
|
|
388
417
|
if (target) {
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// off; every check and every re-arm for the next session stay in plugin resume
|
|
5
5
|
// state, as IV levels' readings do.
|
|
6
6
|
import type { QuoteChangeBasis } from "../../../market-data/market/change-basis";
|
|
7
|
+
import type { ExtendedSession } from "../../../market-data/market/status";
|
|
7
8
|
import type { QuoteDataSource } from "../../../types/financials";
|
|
8
9
|
import type { AlertRule } from "./types";
|
|
9
10
|
|
|
@@ -23,6 +24,8 @@ export interface MoveCheck {
|
|
|
23
24
|
currency?: string;
|
|
24
25
|
exchange?: string;
|
|
25
26
|
pence?: true;
|
|
27
|
+
/** The extended session the move's price is a print of (`AlertRule.lastQuoteSession`). */
|
|
28
|
+
print?: ExtendedSession;
|
|
26
29
|
/** Why the last check had no quote. */
|
|
27
30
|
error?: string;
|
|
28
31
|
/** It went off, and waits for a later session to arm it again. */
|
|
@@ -36,6 +39,7 @@ const isText = (value: unknown): value is string => typeof value === "string" &&
|
|
|
36
39
|
const isNumber = (value: unknown): value is number => typeof value === "number" && Number.isFinite(value);
|
|
37
40
|
const BASIS_KINDS = new Set(["close", "settle", "previous close", "utc day", "24h"]);
|
|
38
41
|
const SOURCES = new Set<QuoteDataSource>(["live", "delayed", "snapshot"]);
|
|
42
|
+
const PRINTS = new Set<ExtendedSession>(["PRE", "POST", "OVERNIGHT"]);
|
|
39
43
|
|
|
40
44
|
function readBasis(value: unknown): QuoteChangeBasis | undefined {
|
|
41
45
|
if (!value || typeof value !== "object") return undefined;
|
|
@@ -64,6 +68,7 @@ export function readMoveChecks(value: unknown): Record<string, MoveCheck> {
|
|
|
64
68
|
...isText(check.currency) ? { currency: check.currency } : {},
|
|
65
69
|
...isText(check.exchange) ? { exchange: check.exchange } : {},
|
|
66
70
|
...check.pence === true ? { pence: true as const } : {},
|
|
71
|
+
...PRINTS.has(check.print as ExtendedSession) ? { print: check.print as ExtendedSession } : {},
|
|
67
72
|
...isText(check.error) ? { error: check.error } : {},
|
|
68
73
|
...check.fired === true ? { fired: true as const } : {},
|
|
69
74
|
...isNumber(check.firedAt) ? { firedAt: check.firedAt } : {},
|
|
@@ -88,6 +93,7 @@ function moveCheckOf(alert: AlertRule): MoveCheck | null {
|
|
|
88
93
|
...alert.lastQuoteCurrency ? { currency: alert.lastQuoteCurrency } : {},
|
|
89
94
|
...alert.lastQuoteExchange ? { exchange: alert.lastQuoteExchange } : {},
|
|
90
95
|
...alert.lastQuotePence ? { pence: true as const } : {},
|
|
96
|
+
...alert.lastQuoteSession ? { print: alert.lastQuoteSession } : {},
|
|
91
97
|
...alert.lastCheckError ? { error: alert.lastCheckError } : {},
|
|
92
98
|
...alert.status === "triggered" ? { fired: true as const, ...alert.triggeredAt ? { firedAt: alert.triggeredAt } : {} } : {},
|
|
93
99
|
...alert.moveSession ? { session: alert.moveSession } : {},
|
|
@@ -114,6 +120,7 @@ function withMoveCheck(alert: AlertRule, check: MoveCheck | undefined): AlertRul
|
|
|
114
120
|
...check.currency ? { lastQuoteCurrency: check.currency } : {},
|
|
115
121
|
...check.exchange ? { lastQuoteExchange: check.exchange } : {},
|
|
116
122
|
...check.pence ? { lastQuotePence: true } : {},
|
|
123
|
+
...check.print ? { lastQuoteSession: check.print } : {},
|
|
117
124
|
...check.error ? { lastCheckError: check.error } : {},
|
|
118
125
|
...check.fired ? { status: "triggered" as const, ...check.firedAt ? { triggeredAt: check.firedAt } : {} } : {},
|
|
119
126
|
...check.session ? { moveSession: check.session } : {},
|
|
@@ -116,7 +116,7 @@ function AlertDetail({ alert, scrollRef }: { alert: AlertRule; scrollRef: RefObj
|
|
|
116
116
|
<KeyValueRow {...DETAIL_ROW} label="Listing" value={listingWithCurrency(alertListing(alert), alert.lastQuoteCurrency)} />
|
|
117
117
|
{/* With no quote the reason above says why; the price and its distance wait for one. */}
|
|
118
118
|
{basis ? <KeyValueRow {...DETAIL_ROW} label="Close date" value={alert.lastDailyClose ?? `Awaiting ${basis}`} /> : null}
|
|
119
|
-
{reason ? null : <KeyValueRow {...DETAIL_ROW} label={alert.move ? "Move" : "Current"} value={formatCurrentPrice(alert, 24)} />}
|
|
119
|
+
{reason ? null : <KeyValueRow {...DETAIL_ROW} label={alert.move ? "Move" : "Current"} value={formatCurrentPrice(alert, 24, { words: true })} />}
|
|
120
120
|
{/* What a move is measured from, as the quote's change line names it. */}
|
|
121
121
|
{!reason && alert.move ? <KeyValueRow {...DETAIL_ROW} label="From" value={moveBasisText(alert.lastMoveBasis).replace(/^vs /, "")} tone="muted" /> : null}
|
|
122
122
|
{/* The two readings that place the quadrant, as RRG states them. */}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { DataProvider } from "../../../types/data-provider";
|
|
2
2
|
import { chunked } from "../../../utils/concurrency";
|
|
3
3
|
import type { Quote } from "../../../types/financials";
|
|
4
|
-
import { getActiveQuoteDisplay } from "../../../market-data/market/status";
|
|
4
|
+
import { extendedPrintSession, getActiveQuoteDisplay } from "../../../market-data/market/status";
|
|
5
5
|
import { isPenceQuotedLine } from "../../../market-data/market/format";
|
|
6
6
|
import { isQuoteStaleForCurrentSession } from "../../../market-data/quotes/freshness";
|
|
7
7
|
import { canonicalExchange } from "../../../utils/exchanges";
|
|
8
|
+
import { futuresContractByWord } from "../../../market-data/futures-board";
|
|
9
|
+
import { isFuturesInstrument } from "../../../market-data/futures-contract";
|
|
8
10
|
import { readMove } from "./move";
|
|
9
11
|
import type { AlertRule } from "./types";
|
|
10
12
|
|
|
@@ -63,7 +65,7 @@ export async function resolveAlertQuotes(
|
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
/** A quote an alert may be judged on, at the price its active session shows; throws for a stale one or one with no price. */
|
|
66
|
-
function alertQuote(quote: Quote, symbol: string): Quote {
|
|
68
|
+
export function alertQuote(quote: Quote, symbol: string): Quote {
|
|
67
69
|
// A last known price is not the price now: it must neither trigger an alert nor set its baseline.
|
|
68
70
|
if (isQuoteStaleForCurrentSession(quote)) throw new Error(`The quote for "${symbol}" is stale.`);
|
|
69
71
|
const display = getActiveQuoteDisplay(quote);
|
|
@@ -91,6 +93,7 @@ export function quoteAlertFields(
|
|
|
91
93
|
| "lastQuoteCurrency"
|
|
92
94
|
| "lastQuoteExchange"
|
|
93
95
|
| "lastQuotePence"
|
|
96
|
+
| "lastQuoteSession"
|
|
94
97
|
> & { lastCheckError?: undefined } {
|
|
95
98
|
const exchange = quote.listingExchangeName || quote.exchangeName;
|
|
96
99
|
return {
|
|
@@ -103,6 +106,8 @@ export function quoteAlertFields(
|
|
|
103
106
|
...(exchange ? { lastQuoteExchange: canonicalExchange(exchange) } : {}),
|
|
104
107
|
// A London line in pence writes its levels in pence; a quote that is not clears it.
|
|
105
108
|
lastQuotePence: isPenceQuotedLine(quote) || undefined,
|
|
109
|
+
// An after-hours print says so wherever the reading is shown, as `quote` names it beside Last.
|
|
110
|
+
lastQuoteSession: extendedPrintSession(quote, quote.price) ?? undefined,
|
|
106
111
|
lastCheckError: undefined,
|
|
107
112
|
};
|
|
108
113
|
}
|
|
@@ -134,6 +139,25 @@ const priceText = (value: number) => value.toLocaleString("en-US", Math.abs(valu
|
|
|
134
139
|
? { maximumFractionDigits: 2 }
|
|
135
140
|
: { maximumSignificantDigits: 4 });
|
|
136
141
|
|
|
142
|
+
/**
|
|
143
|
+
* "GOLD is Gold.com, Inc.; for Gold, the future is GC=F (gloom alerts add
|
|
144
|
+
* GC=F below 3700).": a commodity's word typed bare that a security trades as
|
|
145
|
+
* (GOLD is Gold.com, WTI is W&T Offshore), with the future it may have meant,
|
|
146
|
+
* as `quote` says it. Null for any other symbol, a venue named, or a future.
|
|
147
|
+
*/
|
|
148
|
+
export function commodityFutureNote(
|
|
149
|
+
typed: string,
|
|
150
|
+
quote: Pick<Quote, "name" | "instrumentType">,
|
|
151
|
+
retry: ((symbol: string) => string | null) | null = null,
|
|
152
|
+
): string | null {
|
|
153
|
+
const symbol = typed.trim().toUpperCase();
|
|
154
|
+
if (symbol.includes(":")) return null;
|
|
155
|
+
const contract = futuresContractByWord(symbol);
|
|
156
|
+
if (!contract || isFuturesInstrument(symbol, quote.instrumentType)) return null;
|
|
157
|
+
const command = retry?.(contract.symbol);
|
|
158
|
+
return `${symbol} is ${quote.name?.trim() || "a security"}; for ${contract.name}, the future is ${contract.symbol}${command ? ` (${command})` : ""}.`;
|
|
159
|
+
}
|
|
160
|
+
|
|
137
161
|
/**
|
|
138
162
|
* Why a price target is refused: more than ten times the last price, or under
|
|
139
163
|
* a tenth of it, which is a slip or another instrument's price (bitcoin's,
|
|
@@ -164,6 +164,11 @@ export function scheduledTriggerText(rule: Pick<ScheduledRule, "leadDays" | "tri
|
|
|
164
164
|
return `${rule.leadDays} day${rule.leadDays === 1 ? "" : "s"} before${rule.prints ? " and when it prints" : ""}`;
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
+
/** Why an earnings alert is refused for a listing outside the US: 0700:HKEX, and D05, which is D05:SGX. */
|
|
168
|
+
export function earningsUsOnlyMessage(listing: string): string {
|
|
169
|
+
return `Earnings alerts follow US listings, such as CRWV or AAPL:NASDAQ. ${listing} is not one.`;
|
|
170
|
+
}
|
|
171
|
+
|
|
167
172
|
/**
|
|
168
173
|
* A new rule for `target`, alerting `lead` days before it or, for earnings,
|
|
169
174
|
* once the results are out, with the event date the caller looked up. Throws
|
|
@@ -185,7 +190,7 @@ export function createScheduledAlert(
|
|
|
185
190
|
: { version: 1, event: target.event, ...timing });
|
|
186
191
|
if (!value) {
|
|
187
192
|
throw new Error(target.kind === "earnings"
|
|
188
|
-
?
|
|
193
|
+
? earningsUsOnlyMessage(target.exchange ? `${target.symbol}:${target.exchange}` : target.symbol)
|
|
189
194
|
: target.kind === "release"
|
|
190
195
|
? `A calendar event alert takes the event's name, a two-letter country and 1 to ${MAX_LEAD_DAYS} days before.`
|
|
191
196
|
: `Days before must be a whole number from 1 to ${MAX_LEAD_DAYS}.`);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { QuoteDataSource } from "../../../types/financials";
|
|
2
2
|
import type { QuoteChangeBasis } from "../../../market-data/market/change-basis";
|
|
3
|
+
import type { ExtendedSession } from "../../../market-data/market/status";
|
|
3
4
|
|
|
4
5
|
export type AlertCondition = "above" | "below" | "crosses";
|
|
5
6
|
export type AlertStatus = "active" | "triggered" | "expired";
|
|
@@ -52,5 +53,11 @@ export interface AlertRule {
|
|
|
52
53
|
lastQuoteExchange?: string;
|
|
53
54
|
/** That quote was of a London line in pence (117.35p), whose levels are written in pence. */
|
|
54
55
|
lastQuotePence?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* The pre-market, after-hours or overnight session the last reading's price
|
|
58
|
+
* is a print of, which lists say beside it; absent for the regular session's
|
|
59
|
+
* price or close.
|
|
60
|
+
*/
|
|
61
|
+
lastQuoteSession?: ExtendedSession;
|
|
55
62
|
message?: string;
|
|
56
63
|
}
|