@gloom-sh/terminal 0.20.17 → 0.20.19
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/cot.ts +5 -6
- package/src/api-client/data.ts +14 -3
- package/src/api-client/heard-from.ts +72 -0
- package/src/api-client/index.ts +64 -6
- package/src/api-client/mna.ts +18 -0
- package/src/api-client/request.ts +162 -40
- package/src/api-client/supply-chain.ts +9 -0
- package/src/api-client/types/billing.ts +35 -1
- package/src/api-client/types/news.ts +45 -0
- package/src/api-client/types/world-venues.ts +9 -0
- 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 +37 -4
- package/src/architecture/core-builtin-allowlist.json +1 -1
- package/src/architecture/floating-promise-allowlist.json +1 -2
- package/src/architecture/shortcut-labels-allowlist.json +1 -0
- package/src/cli/alert-listing.ts +98 -0
- package/src/cli/commands/market.ts +191 -39
- 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/commands/ticker.ts +13 -6
- package/src/cli/context.ts +24 -5
- package/src/cli/csv-export.ts +2 -1
- package/src/cli/desktop-pane-shot-browser.ts +3 -1
- package/src/cli/desktop-pane-shot-view.ts +0 -1
- package/src/cli/desktop-pane-shot.ts +276 -52
- package/src/cli/errors.ts +3 -9
- package/src/cli/exit-codes.ts +1 -1
- package/src/cli/glossary.ts +65 -11
- package/src/cli/help.ts +1 -1
- package/src/cli/history-demergers.ts +117 -0
- package/src/cli/history-rows.ts +8 -4
- package/src/cli/index.ts +2 -1
- package/src/cli/known-gaps.ts +16 -0
- package/src/cli/known-us-stocks.ts +18 -0
- package/src/cli/listing-arg.ts +192 -38
- package/src/cli/pane-functions/catalog-snapshot-build.ts +83 -0
- package/src/cli/pane-functions/catalog-snapshot.json +877 -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 +54 -8
- package/src/cli/pane-functions/freshness.ts +39 -4
- package/src/cli/pane-functions/function-help.ts +3 -3
- package/src/cli/pane-functions/headless.ts +9 -1
- package/src/cli/pane-functions/index.ts +175 -50
- package/src/cli/pane-functions/report-notices.ts +10 -0
- package/src/cli/pane-functions/resolver.ts +11 -7
- package/src/cli/pane-functions/screenshot-assessment.ts +38 -10
- package/src/cli/pane-functions/screenshot-data-evidence.ts +7 -15
- package/src/cli/pane-functions/screenshot-payload.ts +36 -1
- package/src/cli/pane-functions/screenshot-render.ts +24 -9
- package/src/cli/pane-functions/screenshot-types.ts +9 -0
- package/src/cli/quote-answer.ts +33 -17
- package/src/cli/registry.ts +22 -2
- package/src/cli/result.ts +22 -4
- package/src/cli/scroll-truncation.ts +7 -2
- package/src/cli/series-search.ts +45 -6
- package/src/cli/shot-temp-dir.ts +4 -9
- package/src/cli/ticker-resolution.ts +1 -1
- package/src/cli/unreachable.ts +21 -0
- package/src/components/chart/composite/drawing-store.ts +11 -7
- package/src/components/chart/composite/format.ts +1 -0
- package/src/components/chart/composite/legend.tsx +48 -20
- package/src/components/chart/composite/panel-surface/panel-cursor.tsx +3 -3
- package/src/components/chart/composite/panel-surface/plot-gestures.ts +9 -2
- package/src/components/chart/composite/panel-surface.tsx +1 -1
- package/src/components/chart/composite/price-axis-labels.tsx +7 -5
- package/src/components/chart/composite/tools.ts +164 -39
- package/src/components/chart-table/header.tsx +11 -2
- package/src/components/chart-table/layout.ts +16 -17
- 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 +19 -4
- package/src/components/command-bar/routes/ticker-search/results.ts +5 -0
- package/src/components/command-bar/routes/ticker-search/route.ts +5 -0
- package/src/components/command-bar/selection-runtime.ts +29 -5
- package/src/components/command-bar/surface/index.tsx +4 -1
- package/src/components/command-bar/workflow/alert.ts +32 -13
- 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 +123 -17
- package/src/components/layout/pane/header.tsx +16 -2
- package/src/components/layout/pane/status-footer.ts +24 -0
- 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/price-performance.tsx +26 -8
- package/src/components/reader/article-reader.tsx +12 -5
- 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/opentui/index.tsx +7 -0
- 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 +34 -2
- 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 +122 -0
- package/src/market-data/coordinator/entries.ts +6 -4
- package/src/market-data/coordinator/index.ts +14 -3
- package/src/market-data/depositary-pair.ts +6 -2
- package/src/market-data/futures-board.ts +36 -29
- package/src/market-data/futures-contract.ts +37 -1
- package/src/market-data/hooks.tsx +33 -2
- package/src/market-data/market/change-basis.ts +11 -1
- package/src/market-data/market/header-market.ts +11 -0
- package/src/market-data/market/status.ts +40 -4
- package/src/market-data/performance.ts +127 -32
- package/src/market-data/quotes/time.ts +5 -2
- package/src/market-data/split-terms.ts +28 -0
- package/src/news/types.ts +28 -0
- package/src/notifications/app-badge.ts +2 -3
- package/src/notifications/app-notifier.ts +5 -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 +101 -48
- package/src/plugins/builtin/alerts/command.ts +39 -9
- package/src/plugins/builtin/alerts/constants.ts +10 -0
- package/src/plugins/builtin/alerts/earnings-listing.ts +20 -0
- package/src/plugins/builtin/alerts/event-rows.ts +9 -3
- package/src/plugins/builtin/alerts/events-pane.tsx +16 -10
- package/src/plugins/builtin/alerts/format.ts +24 -8
- package/src/plugins/builtin/alerts/headless.ts +12 -6
- package/src/plugins/builtin/alerts/index.tsx +97 -16
- package/src/plugins/builtin/alerts/move-checks.ts +7 -0
- package/src/plugins/builtin/alerts/option-contract.ts +197 -0
- package/src/plugins/builtin/alerts/pane.tsx +1 -1
- package/src/plugins/builtin/alerts/price.ts +30 -5
- package/src/plugins/builtin/alerts/pro-rules.ts +62 -0
- package/src/plugins/builtin/alerts/quotes.ts +26 -2
- package/src/plugins/builtin/alerts/research-builder.ts +5 -10
- package/src/plugins/builtin/alerts/scheduled.ts +6 -1
- package/src/plugins/builtin/alerts/types.ts +7 -0
- package/src/plugins/builtin/analytics/account-returns.ts +1 -1
- package/src/plugins/builtin/analytics/manual-value.ts +61 -0
- package/src/plugins/builtin/analytics/pane-model.ts +2 -2
- package/src/plugins/builtin/analytics/risk-book.ts +7 -7
- package/src/plugins/builtin/analytics/risk-client.ts +27 -14
- 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/buildout/company/pane.tsx +4 -14
- package/src/plugins/builtin/catalysts/model.ts +2 -1
- 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/chart-spec.ts +5 -0
- package/src/plugins/builtin/chart-composer/cli-options.ts +9 -5
- package/src/plugins/builtin/chart-composer/data-catalog-pane.tsx +2 -6
- package/src/plugins/builtin/chart-composer/headless-schema.ts +14 -10
- package/src/plugins/builtin/chart-composer/headless.ts +2 -0
- package/src/plugins/builtin/chart-composer/index.tsx +17 -5
- package/src/plugins/builtin/chart-composer/pane.tsx +19 -6
- package/src/plugins/builtin/chart-composer/viewport-labels.ts +2 -17
- package/src/plugins/builtin/chat/controller/notifications.ts +1 -0
- package/src/plugins/builtin/chat/index.tsx +0 -1
- 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/commodities-energy/index.tsx +1 -1
- package/src/plugins/builtin/company-kpis/headless.ts +10 -5
- package/src/plugins/builtin/company-kpis/latest.ts +45 -0
- package/src/plugins/builtin/company-kpis/model.ts +57 -15
- 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/congress-trades/model.ts +9 -5
- package/src/plugins/builtin/correlation/index.tsx +13 -17
- package/src/plugins/builtin/correlation/matrix/model.ts +18 -0
- package/src/plugins/builtin/cot/client.ts +2 -3
- package/src/plugins/builtin/cot/headless.ts +16 -16
- package/src/plugins/builtin/cot/index.tsx +6 -6
- package/src/plugins/builtin/cot/model.ts +25 -5
- package/src/plugins/builtin/cot/pane.tsx +11 -6
- package/src/plugins/builtin/cot/series.ts +11 -8
- package/src/plugins/builtin/cpi/model.ts +15 -4
- package/src/plugins/builtin/cpi/pane.tsx +29 -7
- 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/doe/model.ts +30 -0
- package/src/plugins/builtin/doe/pane.tsx +8 -2
- package/src/plugins/builtin/earnings/board-table.ts +9 -4
- package/src/plugins/builtin/earnings/fiscal-quarter.ts +39 -0
- package/src/plugins/builtin/earnings/headless.ts +16 -6
- package/src/plugins/builtin/earnings/history-model.ts +6 -4
- package/src/plugins/builtin/earnings/history-table.ts +7 -4
- package/src/plugins/builtin/earnings-calls/calendar.tsx +4 -3
- package/src/plugins/builtin/earnings-calls/pane.tsx +8 -2
- package/src/plugins/builtin/earnings-ripple/pane.tsx +2 -2
- package/src/plugins/builtin/econ/calendar-model.ts +16 -0
- package/src/plugins/builtin/econ/index.tsx +7 -2
- 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/futures/model.ts +14 -1
- package/src/plugins/builtin/futures/series.ts +1 -8
- 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 +25 -7
- package/src/plugins/builtin/fx-matrix/settings.ts +9 -4
- package/src/plugins/builtin/insider/detail.tsx +36 -7
- package/src/plugins/builtin/insider/filing-stories.ts +110 -0
- package/src/plugins/builtin/insider/headless.ts +37 -2
- package/src/plugins/builtin/insider/index.tsx +79 -10
- package/src/plugins/builtin/insider/model.ts +43 -5
- package/src/plugins/builtin/ipo-calendar/client.ts +11 -1
- package/src/plugins/builtin/ipo-calendar/model.ts +3 -7
- package/src/plugins/builtin/jobs/headless.ts +2 -1
- package/src/plugins/builtin/jobs/model.ts +6 -0
- package/src/plugins/builtin/jobs/pane.tsx +8 -3
- 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/detail-view.tsx +118 -10
- package/src/plugins/builtin/news/wire/news/footer.ts +3 -8
- package/src/plugins/builtin/news/wire/news/story-evidence.ts +178 -0
- package/src/plugins/builtin/options/analytics.ts +1 -1
- package/src/plugins/builtin/options/view.tsx +18 -11
- package/src/plugins/builtin/options-positioning/model.ts +11 -0
- package/src/plugins/builtin/options-positioning/pane.tsx +22 -1
- package/src/plugins/builtin/options-scenario/client.ts +49 -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/headless.ts +7 -3
- package/src/plugins/builtin/options-scenario/model.ts +33 -2
- package/src/plugins/builtin/options-scenario/pane.tsx +3 -4
- 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/perps/cascade.ts +4 -3
- package/src/plugins/builtin/perps/markets-section.tsx +5 -2
- package/src/plugins/builtin/perps/model.ts +4 -3
- 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/portfolio-list/table.tsx +3 -2
- package/src/plugins/builtin/relative-rotation/pane.tsx +2 -3
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +33 -14
- package/src/plugins/builtin/research/event-model.ts +43 -19
- package/src/plugins/builtin/research/headless.ts +8 -1
- package/src/plugins/builtin/research/relative-valuation-pane.tsx +19 -17
- package/src/plugins/builtin/research-search/index.tsx +3 -1
- package/src/plugins/builtin/scanner/denied.tsx +16 -4
- package/src/plugins/builtin/scanner/flow-pane.tsx +1 -1
- package/src/plugins/builtin/scanner/hilo-pane.tsx +1 -1
- package/src/plugins/builtin/sec/filing-display.tsx +14 -2
- package/src/plugins/builtin/sec/headless.ts +42 -4
- package/src/plugins/builtin/sec/index.tsx +21 -1
- package/src/plugins/builtin/sectors/index.tsx +6 -9
- package/src/plugins/builtin/sectors/sector-model.ts +1 -1
- package/src/plugins/builtin/shared/cloud-upgrade.ts +1 -1
- package/src/plugins/builtin/shared/earnings-report.ts +49 -5
- package/src/plugins/builtin/shared/options-pro-copy.ts +34 -0
- package/src/plugins/builtin/shared/report-freshness.ts +2 -3
- package/src/plugins/builtin/shared/statement-currency.ts +23 -0
- package/src/plugins/builtin/shared/ticker-surface.ts +1 -1
- 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 +79 -18
- package/src/plugins/builtin/themes/headless.ts +4 -4
- package/src/plugins/builtin/themes/model.ts +11 -8
- package/src/plugins/builtin/themes/pane.tsx +2 -2
- 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/financials/model.ts +22 -32
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +7 -9
- package/src/plugins/builtin/ticker-detail/headless-schema.ts +2 -0
- package/src/plugins/builtin/ticker-detail/headless.ts +28 -12
- package/src/plugins/builtin/ticker-detail/overview/board-lot.ts +21 -0
- package/src/plugins/builtin/ticker-detail/overview/model.ts +28 -2
- package/src/plugins/builtin/ticker-detail/overview/pane.tsx +8 -0
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +68 -13
- 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 +16 -7
- 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 +32 -18
- 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/model.ts +6 -1
- 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/builtin/world-venue-map/venue-header.tsx +5 -3
- package/src/plugins/catalog-browser.ts +10 -1
- 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/browser/activity.ts +16 -0
- package/src/renderers/browser/app-badge-host.ts +14 -0
- package/src/renderers/browser/main.tsx +5 -0
- package/src/renderers/browser/notifications.ts +103 -0
- package/src/renderers/browser/ui-host.tsx +4 -0
- package/src/renderers/desktop/window-layouts.ts +14 -0
- package/src/renderers/dom/data-table/index.tsx +27 -4
- 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/http-fetch.ts +3 -2
- 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 +22 -9
- package/src/sources/gloomberb-cloud/news.ts +35 -0
- package/src/sources/gloomberb-cloud/perpetuals.ts +60 -3
- package/src/sources/provider-errors.ts +34 -7
- package/src/sources/provider-router/financials.ts +20 -13
- package/src/sources/provider-router/history.ts +32 -6
- 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/base-series.ts +39 -6
- package/src/time-series/chart-seed.ts +2 -2
- package/src/time-series/history-quality.ts +4 -1
- package/src/time-series/hooks.ts +2 -0
- package/src/time-series/price-comparison.ts +17 -23
- package/src/time-series/reporting.ts +1 -1
- package/src/time-series/resolution.ts +13 -0
- package/src/time-series/resolve-context.ts +6 -0
- package/src/time-series/resolve.ts +42 -3
- package/src/time-series/spec.ts +2 -2
- package/src/time-series/types.ts +3 -2
- package/src/types/data-provider.ts +11 -0
- package/src/types/financials.ts +48 -4
- package/src/types/headless.ts +1 -0
- package/src/types/issuer-listings.ts +2 -0
- package/src/types/plugin-notifications.ts +3 -0
- package/src/types/price-history.ts +6 -4
- package/src/types/ticker.ts +10 -2
- package/src/ui/host.tsx +2 -0
- 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/exchange-announcements.ts +7 -2
- package/src/utils/forward-dividend.ts +4 -3
- package/src/utils/fundamentals.ts +40 -0
- package/src/utils/network-failure.ts +2 -0
- package/src/utils/price-history-integrity.ts +9 -1
- 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
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useState, type Ref } from "react";
|
|
2
|
-
import { apiClient } from "../../../api-client";
|
|
2
|
+
import { apiClient, type CloudAccountPlan } from "../../../api-client";
|
|
3
3
|
import { Button, FieldLabel } from "../../../components";
|
|
4
4
|
import { t } from "../../../i18n";
|
|
5
5
|
import { colors } from "../../../theme/colors";
|
|
6
6
|
import { Box, Text, useRendererHost, type BoxRenderable } from "../../../ui";
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* The Pro tab's read of the account's own subscription (`/account/cloud`): the
|
|
10
|
+
* payment row while a charge failed, and the plan the cancel action reads.
|
|
11
|
+
*/
|
|
8
12
|
export function usePaymentRecovery(enabled: boolean, sessionMarker: string) {
|
|
9
13
|
const renderer = useRendererHost();
|
|
10
|
-
const [
|
|
14
|
+
const [plan, setPlan] = useState<CloudAccountPlan | null>(null);
|
|
15
|
+
const status = plan?.subscription?.status ?? null;
|
|
11
16
|
const [message, setMessage] = useState<string | null>(null);
|
|
12
17
|
const [busy, setBusy] = useState(false);
|
|
13
18
|
const [loaded, setLoaded] = useState(false);
|
|
@@ -21,7 +26,7 @@ export function usePaymentRecovery(enabled: boolean, sessionMarker: string) {
|
|
|
21
26
|
const sequence = ++refreshSequence.current;
|
|
22
27
|
try {
|
|
23
28
|
const plan = await apiClient.getCloudAccountPlan();
|
|
24
|
-
if (generation.current === current && refreshSequence.current === sequence)
|
|
29
|
+
if (generation.current === current && refreshSequence.current === sequence) setPlan(plan);
|
|
25
30
|
} catch {
|
|
26
31
|
if (generation.current === current && refreshSequence.current === sequence) setMessage(t("Could not refresh your account. Try again."));
|
|
27
32
|
} finally {
|
|
@@ -31,7 +36,7 @@ export function usePaymentRecovery(enabled: boolean, sessionMarker: string) {
|
|
|
31
36
|
|
|
32
37
|
useEffect(() => {
|
|
33
38
|
const current = ++generation.current;
|
|
34
|
-
|
|
39
|
+
setPlan(null);
|
|
35
40
|
setMessage(null);
|
|
36
41
|
setBusy(false);
|
|
37
42
|
setLoaded(false);
|
|
@@ -72,7 +77,9 @@ export function usePaymentRecovery(enabled: boolean, sessionMarker: string) {
|
|
|
72
77
|
void pay().catch(() => setMessage(t("Could not open invoice payment. Try again.")));
|
|
73
78
|
}, [pay]);
|
|
74
79
|
|
|
75
|
-
|
|
80
|
+
const reload = useCallback(() => refresh(generation.current), [refresh]);
|
|
81
|
+
|
|
82
|
+
return { visible, busy, message, pay: openPayment, checking: enabled && !loaded, plan, reload };
|
|
76
83
|
}
|
|
77
84
|
|
|
78
85
|
export function PaymentRecoveryRow({ active, busy, message, labelWidth, nodeRef, onPay, onFocus }: {
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { confirmDialog, confirmDialogChoice, confirmDialogWithAnswer } from "../../../components/ui/confirm-dialog";
|
|
2
|
+
import { formatUsdCents } from "../../../account/billing";
|
|
3
|
+
import { t, tf } from "../../../i18n";
|
|
4
|
+
import {
|
|
5
|
+
CLOUD_CANCEL_COMMENT_MAX,
|
|
6
|
+
type CloudCancelFeedback,
|
|
7
|
+
type CloudCancelReason,
|
|
8
|
+
type CloudKeptPrice,
|
|
9
|
+
type CloudRetentionOffer,
|
|
10
|
+
type CloudRetentionOfferAnswer,
|
|
11
|
+
} from "../../../api-client";
|
|
12
|
+
import { colors } from "../../../theme/colors";
|
|
13
|
+
import { Text } from "../../../ui";
|
|
14
|
+
import type { DialogApi } from "../../../ui/dialog";
|
|
15
|
+
import { formatShortDate } from "../../../utils/datetime-format";
|
|
16
|
+
import { CANCEL_REASONS } from "./trial-cancel";
|
|
17
|
+
|
|
18
|
+
/** How long the reason step waits for the offer once it is answered, as gloom.sh's window does. */
|
|
19
|
+
const OFFER_WAIT_MS = 5_000;
|
|
20
|
+
|
|
21
|
+
/** One honest opening line per reason, gloom.sh's; the offer itself says the rest. */
|
|
22
|
+
const OPENING_LINES: Record<CloudCancelReason, string> = {
|
|
23
|
+
bugs: "Sorry Gloom got in your way. Gloom is still new, and we know some rough edges remain.",
|
|
24
|
+
missing_feature: "Sorry Gloom does not do what you need yet. It is still new and we are building it out.",
|
|
25
|
+
too_expensive: "Fair. The price has to be worth it.",
|
|
26
|
+
not_using: "Fair. It has to earn the time it takes.",
|
|
27
|
+
temporary: "Makes sense. Thanks for giving it a run.",
|
|
28
|
+
other: "Thanks for telling us.",
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/** What the paid cancel flow talks to: gloom.sh's cancel window's three requests. */
|
|
32
|
+
export interface ProCancelApi {
|
|
33
|
+
/** The offer and kept price for this subscription; the server counts the flow as started. */
|
|
34
|
+
retentionOffer(signal: AbortSignal): Promise<CloudRetentionOfferAnswer>;
|
|
35
|
+
acceptOffer(feedback: CloudCancelFeedback): Promise<{ offer: CloudRetentionOffer | null; extendedTrialEndsAt: string | null }>;
|
|
36
|
+
cancel(feedback: CloudCancelFeedback): Promise<unknown>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface ProCancelHooks {
|
|
40
|
+
/** A request the person asked for is out: the pane says so and holds its buttons. */
|
|
41
|
+
onWorking?(message: string): void;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** How the flow ended, in words for the pane's message line; null when Pro was kept as it was. */
|
|
45
|
+
export type ProCancelOutcome =
|
|
46
|
+
| { kind: "cancelled"; message: string }
|
|
47
|
+
| { kind: "saved"; message: string }
|
|
48
|
+
| null;
|
|
49
|
+
|
|
50
|
+
function priceWithPeriod(cents: number, interval: CloudKeptPrice["interval"]): string {
|
|
51
|
+
const amount = formatUsdCents(cents);
|
|
52
|
+
return interval === "year" ? tf("{amount}/yr", { amount }) : tf("{amount}/mo", { amount });
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** The kept price against what a new subscriber pays, and what cancelling gives up. */
|
|
56
|
+
function keptPriceLines(kept: CloudKeptPrice): string[] {
|
|
57
|
+
const list = priceWithPeriod(kept.listAmount, kept.interval);
|
|
58
|
+
return [
|
|
59
|
+
tf("Your price is {price}. New subscribers pay {list}.", { price: priceWithPeriod(kept.amount, kept.interval), list }),
|
|
60
|
+
tf("If you cancel, you lose this price. Coming back costs {list}.", { list }),
|
|
61
|
+
];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** The offer in gloom.sh's words: its opening line for the reason given, the offer, and its button. */
|
|
65
|
+
function offerCopy(offer: CloudRetentionOffer, reason: CloudCancelReason | undefined, date: string) {
|
|
66
|
+
return {
|
|
67
|
+
lines: [
|
|
68
|
+
...(reason ? [t(OPENING_LINES[reason])] : []),
|
|
69
|
+
offer === "trial_extension"
|
|
70
|
+
? tf("We would like to give you 14 more days free while we improve it. You will not be charged until {date}.", { date })
|
|
71
|
+
: tf("Take 50% off your next three months while we improve it. Your payment on {date} drops to half price.", { date }),
|
|
72
|
+
],
|
|
73
|
+
accept: offer === "trial_extension" ? t("Extend My Trial") : t("Get 50% Off for 3 Months"),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function dateLabel(iso: string | null | undefined): string | null {
|
|
78
|
+
if (!iso) return null;
|
|
79
|
+
const date = new Date(iso);
|
|
80
|
+
return Number.isNaN(date.getTime()) ? null : formatShortDate(date);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Cancels a paid Pro plan the way gloom.sh's cancel window does, in the same
|
|
85
|
+
* three steps and with the same requests: why (the reason and a note, both
|
|
86
|
+
* optional here as in the trial's warning), the one save offer the server has
|
|
87
|
+
* for this subscription when it has one, then a plain confirmation with the
|
|
88
|
+
* date Pro stays on to and the price it gives up. The offer is asked for as
|
|
89
|
+
* the flow opens, so the second step never waits on it for long; one that
|
|
90
|
+
* does not come counts as none, so nobody is held mid-cancel. Esc or Keep
|
|
91
|
+
* leaves at any step with nothing sent.
|
|
92
|
+
*/
|
|
93
|
+
export async function cancelProAfterSteps(
|
|
94
|
+
dialog: DialogApi,
|
|
95
|
+
plan: { currentPeriodEnd: string | null | undefined },
|
|
96
|
+
api: ProCancelApi,
|
|
97
|
+
hooks: ProCancelHooks = {},
|
|
98
|
+
): Promise<ProCancelOutcome> {
|
|
99
|
+
const controller = new AbortController();
|
|
100
|
+
const timer = setTimeout(() => controller.abort(), OFFER_WAIT_MS);
|
|
101
|
+
const offerLookup: Promise<CloudRetentionOfferAnswer | null> = api.retentionOffer(controller.signal).catch(() => {
|
|
102
|
+
// Intentional ignore: a failed or slow offer lookup is no offer, never a stuck cancel.
|
|
103
|
+
return null;
|
|
104
|
+
});
|
|
105
|
+
try {
|
|
106
|
+
const date = dateLabel(plan.currentPeriodEnd);
|
|
107
|
+
const until = date
|
|
108
|
+
? tf("Pro stays on until {date}.", { date })
|
|
109
|
+
: t("Pro stays on until the end of the billing period.");
|
|
110
|
+
const answer = await confirmDialogWithAnswer(dialog, {
|
|
111
|
+
closeOnClickOutside: false,
|
|
112
|
+
title: t("Cancel Pro?"),
|
|
113
|
+
body: [until],
|
|
114
|
+
confirmLabel: t("Continue"),
|
|
115
|
+
cancelLabel: t("Keep Pro"),
|
|
116
|
+
confirmVariant: "primary",
|
|
117
|
+
footer: t("Enter continue · Tab note · Esc keep Pro"),
|
|
118
|
+
wrapButtons: true,
|
|
119
|
+
question: {
|
|
120
|
+
label: "What made you decide to cancel? (optional)",
|
|
121
|
+
choices: CANCEL_REASONS,
|
|
122
|
+
notePlaceholder: "Anything else? (optional)",
|
|
123
|
+
noteMaxLength: CLOUD_CANCEL_COMMENT_MAX,
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
if (!answer) return null;
|
|
127
|
+
const reason = CANCEL_REASONS.find(({ id }) => id === answer.choice)?.id;
|
|
128
|
+
const feedback: CloudCancelFeedback = {
|
|
129
|
+
...(reason ? { reason } : {}),
|
|
130
|
+
...(answer.note ? { comment: answer.note } : {}),
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const found = await offerLookup;
|
|
134
|
+
let status: string | undefined;
|
|
135
|
+
if (found?.offer) {
|
|
136
|
+
const offerDate = found.offer === "trial_extension" ? dateLabel(found.extendedTrialEndsAt) : date;
|
|
137
|
+
const copy = offerCopy(found.offer, reason, offerDate ?? t("your next billing date"));
|
|
138
|
+
const choice = await confirmDialogChoice(dialog, {
|
|
139
|
+
closeOnClickOutside: false,
|
|
140
|
+
title: t("Cancel Pro?"),
|
|
141
|
+
body: copy.lines,
|
|
142
|
+
confirmLabel: copy.accept,
|
|
143
|
+
cancelLabel: t("Continue Cancellation"),
|
|
144
|
+
confirmVariant: "primary",
|
|
145
|
+
footer: t("Enter take the offer · n continue · Esc close"),
|
|
146
|
+
wrapButtons: true,
|
|
147
|
+
});
|
|
148
|
+
if (choice === null) return null;
|
|
149
|
+
if (choice === "confirm") {
|
|
150
|
+
hooks.onWorking?.(t("Applying..."));
|
|
151
|
+
try {
|
|
152
|
+
const taken = await api.acceptOffer(feedback);
|
|
153
|
+
const extended = dateLabel(taken.extendedTrialEndsAt);
|
|
154
|
+
return {
|
|
155
|
+
kind: "saved",
|
|
156
|
+
message: taken.offer === "trial_extension"
|
|
157
|
+
? extended ? tf("Trial extended to {date}.", { date: extended }) : t("Trial extended.")
|
|
158
|
+
: t("50% off applied to your next three months."),
|
|
159
|
+
};
|
|
160
|
+
} catch (error) {
|
|
161
|
+
// The offer went away (used already, or the plan changed): the honest
|
|
162
|
+
// move is to let them finish cancelling, not to trap them here.
|
|
163
|
+
status = error instanceof Error && error.message ? error.message : t("Offer could not be applied.");
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const confirmed = await confirmDialog(dialog, {
|
|
169
|
+
closeOnClickOutside: false,
|
|
170
|
+
title: t("Cancel Pro?"),
|
|
171
|
+
body: [
|
|
172
|
+
...(found?.keptPrice ? keptPriceLines(found.keptPrice) : []),
|
|
173
|
+
date
|
|
174
|
+
? tf("Pro stays on until {date}. Cancelling now stops the renewal after that date.", { date })
|
|
175
|
+
: t("Pro stays on until the end of the billing period. Cancelling now stops the renewal after that."),
|
|
176
|
+
],
|
|
177
|
+
...(status ? { status: <Text fg={colors.textDim} wrapText>{status}</Text> } : {}),
|
|
178
|
+
confirmLabel: t("Cancel Subscription"),
|
|
179
|
+
cancelLabel: t("Keep My Subscription"),
|
|
180
|
+
confirmVariant: "danger",
|
|
181
|
+
footer: t("y cancel · Enter or Esc keep Pro"),
|
|
182
|
+
wrapButtons: true,
|
|
183
|
+
// Keeping is the primary answer, as on gloom.sh: a stray Enter keeps Pro.
|
|
184
|
+
defaultAction: "cancel",
|
|
185
|
+
});
|
|
186
|
+
if (!confirmed) return null;
|
|
187
|
+
hooks.onWorking?.(t("Cancelling..."));
|
|
188
|
+
await api.cancel(feedback);
|
|
189
|
+
return {
|
|
190
|
+
kind: "cancelled",
|
|
191
|
+
message: date ? tf("Cancelled. Pro stays on until {date}.", { date }) : t("Cancelled. Pro stays on until the end of the billing period."),
|
|
192
|
+
};
|
|
193
|
+
} finally {
|
|
194
|
+
clearTimeout(timer);
|
|
195
|
+
controller.abort();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
@@ -7,7 +7,7 @@ import type { PlanAccess } from "../../../api-client/plan-rules";
|
|
|
7
7
|
import type { DialogApi } from "../../../ui/dialog";
|
|
8
8
|
|
|
9
9
|
/** The reasons gloom.sh's cancel window offers, in its words and order. */
|
|
10
|
-
const CANCEL_REASONS: ReadonlyArray<{ id: CloudCancelReason; label: string }> = [
|
|
10
|
+
export const CANCEL_REASONS: ReadonlyArray<{ id: CloudCancelReason; label: string }> = [
|
|
11
11
|
{ id: "bugs", label: "Bugs or reliability" },
|
|
12
12
|
{ id: "missing_feature", label: "Missing feature" },
|
|
13
13
|
{ id: "too_expensive", label: "Too expensive" },
|
|
@@ -8,7 +8,7 @@ import { canonicalExchange, parsePublicTickerKey } from "../../../utils/exchange
|
|
|
8
8
|
import { chunked, mapWithConcurrency } from "../../../utils/concurrency";
|
|
9
9
|
import type { QuoteBatchResult } from "../../../types/data-provider";
|
|
10
10
|
import { findCollection } from "../portfolio-list/cli/render";
|
|
11
|
-
import { alertListing } from "./format";
|
|
11
|
+
import { alertListing, readingSessionWords } from "./format";
|
|
12
12
|
import { createAlert, sameLevelRule } from "./alert-engine";
|
|
13
13
|
import { moveBasisText, moveCondition, movePercentText, moveReached, moveRuleWords, parseMovePercent } from "./move";
|
|
14
14
|
import { moveQuoteFields } from "./quotes";
|
|
@@ -220,7 +220,7 @@ export function moveNowText(alert: AlertRule, now = Date.now()): string | null {
|
|
|
220
220
|
const percent = alert.lastCheckedPrice;
|
|
221
221
|
if (percent == null || !Number.isFinite(percent)) return null;
|
|
222
222
|
const reached = moveReached(alert, percent) ? ", so it goes off at the app's next check" : "";
|
|
223
|
-
return `now ${movePercentText(percent)} ${moveBasisText(alert.lastMoveBasis, now)}${reached}`;
|
|
223
|
+
return `now ${movePercentText(percent)}${readingSessionWords(alert)} ${moveBasisText(alert.lastMoveBasis, now)}${reached}`;
|
|
224
224
|
}
|
|
225
225
|
|
|
226
226
|
/** "LSE 120, JPX 100, NYSE 3": how many alerts were added on each venue, most first. */
|
|
@@ -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";
|
|
@@ -15,16 +15,19 @@ import { localTimeSuffix } from "../../../utils/utc-time";
|
|
|
15
15
|
import { resolvePersistedCloudSessionToken } from "../../../cli/pane-functions/cloud-session";
|
|
16
16
|
import type { ConfigContext } from "../../../cli/types";
|
|
17
17
|
import { checkedWhenSignedIn, NEEDS_SIGN_IN, needsSignInNote } from "./event-rows";
|
|
18
|
+
import { checkedOnlyWithPro, checksProRules, NEEDS_PRO, needsProNote, savedWithoutProNote } from "./pro-rules";
|
|
19
|
+
import { OCC_CONTRACT, occContractExample, occFormText, parseLooseOptionContract, resolveLooseOptionContract, type LooseOptionContract } from "./option-contract";
|
|
18
20
|
import { CLI_COMMAND_GROUPS } from "../../../cli/help";
|
|
19
21
|
import { dryRunNote } from "../../../cli/helpers";
|
|
20
22
|
import { requireArg, takeOption } from "../../../cli/commands/command-utils";
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
+
import { AlertListingRefusal, resolveAlertListing } from "../../../cli/alert-listing";
|
|
24
|
+
import { earningsListingVenue } from "./earnings-listing";
|
|
25
|
+
import { coinListingNotes, EXCHANGE_OPTION, listingReadNotes, requireListingArg, usListingsOnlyMessage, type ListingDeps } from "../../../cli/listing-arg";
|
|
23
26
|
import { saveConfig } from "../../../data/config/store";
|
|
24
27
|
import { resumeStateKey } from "../../registry/plugin-state";
|
|
25
28
|
import type { CliCommandDef } from "../../../types/plugin";
|
|
26
29
|
import type { Quote } from "../../../types/financials";
|
|
27
|
-
import { getActiveQuoteDisplay } from "../../../market-data/market/status";
|
|
30
|
+
import { extendedPrintSession, getActiveQuoteDisplay } from "../../../market-data/market/status";
|
|
28
31
|
import { cliStyles } from "../../../utils/cli-output";
|
|
29
32
|
import { canonicalExchange, isUsListingExchange, parsePublicTickerKey } from "../../../utils/exchanges";
|
|
30
33
|
import { isRoundTheClockCoin } from "../../../utils/crypto-pair";
|
|
@@ -51,13 +54,13 @@ import {
|
|
|
51
54
|
} from "./calendar-events";
|
|
52
55
|
import { createAlert, formatAlertDescription, levelAlreadyMet, rearmAlert, sameLevelRule } from "./alert-engine";
|
|
53
56
|
import { alertPriceText } from "./price-text";
|
|
54
|
-
import { ALERTS_PLUGIN_ID } from "./constants";
|
|
57
|
+
import { ALERTS_PLUGIN_ID, PRICE_DELIVERY } from "./constants";
|
|
55
58
|
import { MAX_EVENT_ALERTS, eventAlertTarget, toggleEventAlert, writeEventAlertStores, type EventAlertRule } from "./events";
|
|
56
59
|
import { alertKindLabel, fetchAlertHistory, ruleStateText, type AlertRuleState } from "./history";
|
|
57
60
|
import { apiClient } from "../../../api-client";
|
|
58
61
|
import { IV_LEVEL_CHECKS_KEY, ivLevelCheckText, readIvLevelChecks, rearmIvLevelAlert, type IvLevelCheck } from "./iv-level";
|
|
59
|
-
import { isPenceLevel, parseAlertPrice, readAlertLevel } from "./price";
|
|
60
|
-
import { farTargetMessage, levelInQuoteUnit } from "./quotes";
|
|
62
|
+
import { isDollarMark, isPenceLevel, parseAlertPrice, readAlertLevel } from "./price";
|
|
63
|
+
import { commodityFutureNote, farTargetMessage, levelInQuoteUnit } from "./quotes";
|
|
61
64
|
import { isPenceQuotedLine } from "../../../market-data/market/format";
|
|
62
65
|
import { MACRO_EVENT_NAMES, createResearchAlert, formatPremium, ivLevelUnitError, parseAmount, parseIvLevel } from "./research-builder";
|
|
63
66
|
import { IV_LEVEL_RANGES, MAX_LEAD_DAYS, type IvLevelMetric, type MacroAlertEvent } from "./research-rules";
|
|
@@ -93,14 +96,6 @@ import { MOVE_CHECKS_KEY, moveChecksOf, readMoveChecks, withMoveChecks, type Mov
|
|
|
93
96
|
import { listAddLookups } from "../portfolio-list/cli/bulk-symbols";
|
|
94
97
|
import type { AlertCondition, AlertRule } from "./types";
|
|
95
98
|
|
|
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
99
|
|
|
105
100
|
const ADD_USAGE = `Usage: gloom alerts add <symbol> <above|below|crosses> <price>, or another kind. ${ALERT_KINDS_TEXT}`;
|
|
106
101
|
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 +105,6 @@ const COUNTRY_RULE = "--country is for an alert on a calendar event, such as ale
|
|
|
110
105
|
const BENCHMARK_RULE = "--benchmark takes the listing an RRG alert is measured against (SPY by default, as in RRG),";
|
|
111
106
|
/** `XLK/SPY`, `XLK:NYSEARCA/SPY`: two listings, or one written with a slash (BRK/B, EUR/USD). */
|
|
112
107
|
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
108
|
|
|
119
109
|
/** What `alerts add` was asked for, before any listing or date is looked up. */
|
|
120
110
|
export type AlertAddRequest =
|
|
@@ -139,8 +129,11 @@ export type AlertAddRequest =
|
|
|
139
129
|
| { kind: "flow"; symbol: string | null; premium: number; side: "any" | "calls" | "puts"; print: "any" | "sweep" | "block" }
|
|
140
130
|
/** The symbol's 30-day ATM IV (`atm`, in %) or 25-delta risk reversal (`rr`, in vol points) above or below a level, checked by the running app. */
|
|
141
131
|
| { kind: "iv_level"; symbol: string; metric: IvLevelMetric; direction: "above" | "below"; level: number }
|
|
142
|
-
/**
|
|
143
|
-
|
|
132
|
+
/**
|
|
133
|
+
* One OCC contract's IV rising by `points`. A contract typed loosely (`SPY 680C 11/19`) carries what it was
|
|
134
|
+
* read as (`loose`), for the chain to name the one listed contract it is before the rule is made.
|
|
135
|
+
*/
|
|
136
|
+
| { kind: "iv_spike"; contract: string; points: number; loose?: LooseOptionContract }
|
|
144
137
|
/** The rest of what Add Event Alert offers: 52-week range, unusual volume, filings, insiders, short interest and more. */
|
|
145
138
|
| RuleAddRequest;
|
|
146
139
|
|
|
@@ -286,6 +279,8 @@ export function parseAlertAddArgs(
|
|
|
286
279
|
if (country !== undefined) throw new Error(COUNTRY_RULE);
|
|
287
280
|
if (days !== undefined) throw new Error("--days is for earnings and calendar event alerts, not price alerts.");
|
|
288
281
|
if (third === undefined) throw new Error(ADD_USAGE);
|
|
282
|
+
// A dollar mark the shell split from its price (`$ 757.75`, `757.75 USD`) is part of it.
|
|
283
|
+
if (rest.length === 1 && (isDollarMark(third) || isDollarMark(rest[0]!))) return parseAlertAddArgs([first, second, `${third} ${rest[0]}`], days, exchange, country, benchmark, watchlist);
|
|
289
284
|
const retype = (price: number) => retypeCommand(first, condition, price, exchange);
|
|
290
285
|
// `81 000` without quotes arrives as 81 and a stray 000; neither reading is taken for granted.
|
|
291
286
|
const spaced = rest.length > 0 && LEADING_GROUP.test(third) ? parsePastedNumber([third, ...rest].join(" ")) : null;
|
|
@@ -302,9 +297,17 @@ export function parseAlertAddArgs(
|
|
|
302
297
|
...(thousandsDot ? { thousandsDot: { ...thousandsDot, text: third.trim() } } : {}) };
|
|
303
298
|
}
|
|
304
299
|
|
|
305
|
-
const OCC_CONTRACT = /^(?:O:)?[A-Z.]{1,6}\d{6}[CP]\d{8}$/i;
|
|
306
300
|
const LEVEL_DIRECTIONS = ["above", "below"] as const;
|
|
307
301
|
|
|
302
|
+
/** An IV spike's rise in vol points, with the unit or without it (`5`, `5 pts`), refused with its range when it does not read. */
|
|
303
|
+
function readSpikePoints(typed: string, contract: string): number {
|
|
304
|
+
const value = typed && !/%/.test(typed) ? parseIvLevel(typed) : Number.NaN;
|
|
305
|
+
if (!Number.isFinite(value) || value < 0.1 || value > 100) {
|
|
306
|
+
throw new Error(`An IV spike is a rise of 0.1 to 100 vol points: gloom alerts add ${/\s/.test(contract) ? `"${contract}"` : contract} iv spike 5.`);
|
|
307
|
+
}
|
|
308
|
+
return value;
|
|
309
|
+
}
|
|
310
|
+
|
|
308
311
|
/** A level typed for an IV level rule, with its unit or without (`50`, `50%`, `-5.5 pts`), refused with its unit and range when it does not read. */
|
|
309
312
|
function readLevel(metric: IvLevelMetric, typed: string | undefined, symbol: string): number {
|
|
310
313
|
const word = metric === "atm" ? "iv" : "rr";
|
|
@@ -333,6 +336,21 @@ function parseResearchAddArgs(args: readonly string[]): ResearchAddRequest | nul
|
|
|
333
336
|
const word = (value: string | undefined) => value?.toLowerCase() ?? "";
|
|
334
337
|
const isCondition = (value: string | undefined) => (CONDITIONS as readonly string[]).includes(word(value)) || word(value) === "earnings";
|
|
335
338
|
const lead = word(first);
|
|
339
|
+
// `<contract> iv spike <points>`, the contract typed as OCC writes it or loosely, over one word or several
|
|
340
|
+
// (`SPY 680C 11/19`, `SPY241119C680`), read against the listed chain once the command runs.
|
|
341
|
+
const spikeAt = args.findIndex((arg, index) => index > 0 && word(arg) === "iv" && word(args[index + 1]) === "spike");
|
|
342
|
+
if (spikeAt > 0 && !(spikeAt === 1 && OCC_CONTRACT.test(first.trim()))) {
|
|
343
|
+
const typed = args.slice(0, spikeAt).join(" ").trim();
|
|
344
|
+
const points = readSpikePoints(args.slice(spikeAt + 2).join(" "), typed);
|
|
345
|
+
if (OCC_CONTRACT.test(typed.replace(/\s+/g, ""))) return { kind: "iv_spike", contract: typed.replace(/\s+/g, "").toUpperCase(), points };
|
|
346
|
+
const loose = parseLooseOptionContract(typed);
|
|
347
|
+
if (!loose) {
|
|
348
|
+
// A ticker alone has an IV level to follow, not one contract's spike.
|
|
349
|
+
const level = /^[A-Z.^=:-]+$/i.test(typed) ? ` For ${typed.toUpperCase()}'s 30-day ATM IV, add a level: gloom alerts add ${typed.toUpperCase()} iv above 50.` : "";
|
|
350
|
+
throw new Error(`"${typed}" is not an option contract. ${occFormText(occContractExample())}: gloom alerts add ${occContractExample()} iv spike 5.${level}`);
|
|
351
|
+
}
|
|
352
|
+
return { kind: "iv_spike", contract: typed, points, loose };
|
|
353
|
+
}
|
|
336
354
|
const [symbol, kind, tail] = (lead === "news" || lead === "flow") && !isCondition(second)
|
|
337
355
|
? [null, lead, args.slice(1)] as const
|
|
338
356
|
: [first, word(second), args.slice(2)] as const;
|
|
@@ -362,13 +380,7 @@ function parseResearchAddArgs(args: readonly string[]): ResearchAddRequest | nul
|
|
|
362
380
|
if (kind !== "iv" || word(third) !== "spike") {
|
|
363
381
|
throw new Error(`An option contract takes an IV spike in vol points: gloom alerts add ${symbol.toUpperCase()} iv spike 5. For a level, name the underlying: alerts add ${symbol.replace(/^O:/i, "").match(/^[A-Z.]+/i)![0]!.toUpperCase()} iv above 50.`);
|
|
364
382
|
}
|
|
365
|
-
|
|
366
|
-
const typed = rest.join(" ");
|
|
367
|
-
const value = typed && !/%/.test(typed) ? parseIvLevel(typed) : Number.NaN;
|
|
368
|
-
if (!Number.isFinite(value) || value < 0.1 || value > 100) {
|
|
369
|
-
throw new Error(`An IV spike is a rise of 0.1 to 100 vol points: gloom alerts add ${symbol.toUpperCase()} iv spike 5.`);
|
|
370
|
-
}
|
|
371
|
-
return { kind: "iv_spike", contract: symbol.toUpperCase(), points: value };
|
|
383
|
+
return { kind: "iv_spike", contract: symbol.toUpperCase(), points: readSpikePoints(rest.join(" "), symbol.toUpperCase()) };
|
|
372
384
|
}
|
|
373
385
|
const metric: IvLevelMetric = kind === "iv" ? "atm" : "rr";
|
|
374
386
|
const direction = word(third);
|
|
@@ -563,12 +575,16 @@ function priceRow(alert: AlertRule): AlertListRow {
|
|
|
563
575
|
|
|
564
576
|
function eventRow(
|
|
565
577
|
rule: EventAlertRule, now: number, eventDate: string | null | undefined, check?: IvLevelCheck, cloud?: CloudRuleStates, signedIn = true,
|
|
578
|
+
pro = signedIn,
|
|
566
579
|
): AlertListRow {
|
|
567
580
|
const scheduled = readScheduledRule(rule);
|
|
568
581
|
if (!scheduled) {
|
|
569
582
|
const triggered = rule.status === "active" && rule.triggeredAt ? "triggered" : rule.status;
|
|
570
|
-
//
|
|
571
|
-
|
|
583
|
+
// Without Pro, nothing checks options flow or an IV spike, signed in or not: it waits on Pro. Signed out,
|
|
584
|
+
// nothing checks any other rule only a signed-in account gets checked: it waits on a sign-in, not on its event.
|
|
585
|
+
const status = triggered !== "active" ? triggered
|
|
586
|
+
: !pro && checkedOnlyWithPro(rule) ? NEEDS_PRO
|
|
587
|
+
: !signedIn && checkedWhenSignedIn(rule) ? NEEDS_SIGN_IN : triggered;
|
|
572
588
|
// An IV level is read by this app, so its last reading is this device's; Gloom Cloud reads the rest.
|
|
573
589
|
const state = cloud?.states.get(rule.id);
|
|
574
590
|
const reading = rule.kind === "iv_level" ? {
|
|
@@ -888,6 +904,14 @@ export const alertsCliCommand: CliCommandDef = {
|
|
|
888
904
|
const now = Date.now();
|
|
889
905
|
const today = newYorkToday(new Date(now));
|
|
890
906
|
const failWith = (error: unknown): never => ctx.fail(error instanceof Error ? error.message : String(error));
|
|
907
|
+
// A symbol whose company moved names the same add on its new symbol.
|
|
908
|
+
const alertRetry = (symbol: string) => `gloom alerts add ${symbol} ${args.slice(2).join(" ")}`;
|
|
909
|
+
// The listing an alert follows, read as `quote` reads it and held to one that trades (`resolveAlertListing`).
|
|
910
|
+
const requireAlertListing = (typed: string, market: ListingDeps, exchange: string | null | undefined = exchangeOption) =>
|
|
911
|
+
resolveAlertListing(typed, exchange, market, { retry: alertRetry }).catch((error: unknown) => {
|
|
912
|
+
if (error instanceof AlertListingRefusal) return ctx.fail(error.message, error.details);
|
|
913
|
+
throw error;
|
|
914
|
+
});
|
|
891
915
|
|
|
892
916
|
const parseAdd = (): AlertAddRequest => {
|
|
893
917
|
try {
|
|
@@ -916,18 +940,18 @@ export const alertsCliCommand: CliCommandDef = {
|
|
|
916
940
|
// of several, each that fails is named in the summary.
|
|
917
941
|
if (unique.inputs.length === 1) {
|
|
918
942
|
const input = unique.inputs[0]!.input;
|
|
919
|
-
const quoted = await
|
|
943
|
+
const quoted = await requireAlertListing(input, market);
|
|
920
944
|
const exchange = quoted.listing.exchange || canonicalExchange(quoted.quote.listingExchangeName || quoted.quote.exchangeName);
|
|
921
945
|
return { listings: [{ input, listing: { symbol: quoted.listing.key, ...exchange ? { exchange } : {} }, quote: quoted.quote, notes: quoted.notes }], repeats: unique.repeats, leftOut: 0 };
|
|
922
946
|
}
|
|
923
|
-
const listings = await quoteTypedSymbols(unique.inputs.map((entry) => entry.input), (symbol) =>
|
|
947
|
+
const listings = await quoteTypedSymbols(unique.inputs.map((entry) => entry.input), (symbol) => resolveAlertListing(symbol, exchangeOption, market, { retry: alertRetry }));
|
|
924
948
|
return { listings, repeats: unique.repeats, leftOut: unique.leftOut };
|
|
925
949
|
});
|
|
926
950
|
}
|
|
927
951
|
// 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
952
|
const pairListing = typedRequest?.kind === "price" && PAIR_SHAPE.test(typedRequest.symbol)
|
|
929
|
-
? await withMarketData(ctx, (market) =>
|
|
930
|
-
if (!(error instanceof
|
|
953
|
+
? await withMarketData(ctx, (market) => resolveAlertListing(typedRequest.symbol, exchangeOption, market, { retry: alertRetry })).catch((error: unknown) => {
|
|
954
|
+
if (!(error instanceof AlertListingRefusal)) throw error;
|
|
931
955
|
if (!notATickerSymbol(error.message)) return ctx.fail(error.message, error.details);
|
|
932
956
|
return null;
|
|
933
957
|
})
|
|
@@ -952,7 +976,7 @@ export const alertsCliCommand: CliCommandDef = {
|
|
|
952
976
|
// a news, flow or IV rule on a symbol follows that listing too, and only in the US, where their data is.
|
|
953
977
|
const priced = pairListing ? pairListing : listedSymbol
|
|
954
978
|
? await withMarketData(ctx, async (market) => {
|
|
955
|
-
const quoted = await
|
|
979
|
+
const quoted = await requireAlertListing(listedSymbol, market);
|
|
956
980
|
// BTC-USD and ETH-USD have Deribit's options, which OPX and OVDV read: an IV level or risk reversal follows that fit.
|
|
957
981
|
const coinOptions = research?.kind === "iv_level" && listedCoinOptions(quoted.listing.key) != null;
|
|
958
982
|
if (usOnly && !coinOptions) {
|
|
@@ -972,6 +996,9 @@ export const alertsCliCommand: CliCommandDef = {
|
|
|
972
996
|
// A bare coin ticker read as another listing (SOL, a stale company; BTC, the Grayscale trust) gets `quote`'s note
|
|
973
997
|
// naming the coin's pair, before a metric alert names the venue it was read on.
|
|
974
998
|
const coinNote = priced ? coinListingNotes(priced.listing, priced.quote)[0] ?? null : null;
|
|
999
|
+
// GOLD is Gold.com, whose price is no gold future's: `quote` names GC=F beside it, and so does the alert.
|
|
1000
|
+
const futureNote = priced && listedSymbol && !exchangeOption && !coinNote
|
|
1001
|
+
? commodityFutureNote(listedSymbol, priced.quote, request?.kind === "price" ? alertRetry : null) : null;
|
|
975
1002
|
// What the alert reads now, which it is saved with, so lists and ALRT show it before the app has run.
|
|
976
1003
|
let reading: Partial<AlertRule> = {};
|
|
977
1004
|
// A daily rule whose close could not be read yet: why, which the add says beside when it is first checked.
|
|
@@ -983,7 +1010,7 @@ export const alertsCliCommand: CliCommandDef = {
|
|
|
983
1010
|
const typedMetric = request.metric;
|
|
984
1011
|
if (isRelativeMetric(typedMetric)) {
|
|
985
1012
|
// The benchmark is held to a listing that quotes, as the symbol is.
|
|
986
|
-
const reference = await withMarketData(ctx, (market) =>
|
|
1013
|
+
const reference = await withMarketData(ctx, (market) => requireAlertListing(benchmarkKey(typedMetric), market, null));
|
|
987
1014
|
const benchmarkExchange = canonicalExchange(reference.listing.exchange || reference.quote.listingExchangeName || reference.quote.exchangeName);
|
|
988
1015
|
if (reference.listing.symbol === priced.listing.symbol && benchmarkExchange === exchange) {
|
|
989
1016
|
ctx.fail(`${typedMetric.kind === "rrg" ? "An RRG alert" : "A ratio alert"} compares two listings; ${priced.listing.symbol} is on both sides.`);
|
|
@@ -1033,7 +1060,7 @@ export const alertsCliCommand: CliCommandDef = {
|
|
|
1033
1060
|
if (request?.kind === "price" && priced) {
|
|
1034
1061
|
// A target ten times away is a slip or another instrument's price, such as bitcoin's on the BTC fund.
|
|
1035
1062
|
// 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));
|
|
1063
|
+
const far = farTargetMessage(priced.listing.key, request.price, priced.quote.price, coinNote ?? futureNote, isPenceQuotedLine(priced.quote));
|
|
1037
1064
|
if (far) ctx.fail(far);
|
|
1038
1065
|
}
|
|
1039
1066
|
// What a typed listing was read as (7203:TSE as 7203:JPX, MXN as MXN:FWB2), said beside what was added.
|
|
@@ -1042,9 +1069,20 @@ export const alertsCliCommand: CliCommandDef = {
|
|
|
1042
1069
|
&& !listedSymbol.includes(":") && !PAIR_SHAPE.test(listedSymbol)
|
|
1043
1070
|
? await withMarketData(ctx, (market) => sameNameSeriesNote(listedSymbol, priced, market.findCatalogSeriesNamed?.(listedSymbol), request))
|
|
1044
1071
|
: null;
|
|
1045
|
-
let read = [...priced?.notes ?? [], ...coinNote ? [coinNote] : [], ...seriesNote ? [seriesNote] : [], ...benchmarkNotes, ...penceNote ? [penceNote] : []];
|
|
1072
|
+
let read = [...priced?.notes ?? [], ...coinNote ? [coinNote] : [], ...futureNote ? [futureNote] : [], ...seriesNote ? [seriesNote] : [], ...benchmarkNotes, ...penceNote ? [penceNote] : []];
|
|
1046
1073
|
let newEventRule: EventAlertRule | null = null;
|
|
1047
1074
|
let newResearchRule: EventAlertRule | null = null;
|
|
1075
|
+
// A contract typed loosely is the one listed contract it names, read from the chain; one past its expiry is
|
|
1076
|
+
// kept as typed, for the rule to refuse it as expired.
|
|
1077
|
+
if (research?.kind === "iv_spike" && research.loose) {
|
|
1078
|
+
const { loose, contract: typedContract } = research;
|
|
1079
|
+
const resolved = await withMarketData(ctx, (market) => resolveLooseOptionContract(typedContract, loose, (expiration) => {
|
|
1080
|
+
if (!market.dataProvider.getOptionsChain) throw new Error(`Option chains cannot be read here to find ${typedContract}.`);
|
|
1081
|
+
return market.dataProvider.getOptionsChain(loose.root, "", expiration);
|
|
1082
|
+
}, now)).catch(failWith);
|
|
1083
|
+
research.contract = resolved.contract;
|
|
1084
|
+
if (resolved.readAs) read = [...read, resolved.readAs];
|
|
1085
|
+
}
|
|
1048
1086
|
if (research) {
|
|
1049
1087
|
const typed = priceListing?.exchange ? canonicalExchange(priceListing.exchange) : "";
|
|
1050
1088
|
const { kind, values } = researchFormValues(
|
|
@@ -1114,9 +1152,16 @@ export const alertsCliCommand: CliCommandDef = {
|
|
|
1114
1152
|
const target: ScheduledEventTarget = macro
|
|
1115
1153
|
? { kind: "macro", event: macro.event }
|
|
1116
1154
|
: await requireListingArg(earnings!.symbol, exchangeOption, ctx)
|
|
1117
|
-
.then((listing) => {
|
|
1155
|
+
.then(async (listing) => {
|
|
1118
1156
|
read = listingReadNotes(listing);
|
|
1119
|
-
return { kind: "earnings" as const, symbol: listing.symbol, exchange: listing.exchange };
|
|
1157
|
+
if (listing.exchange) return { kind: "earnings" as const, symbol: listing.symbol, exchange: listing.exchange };
|
|
1158
|
+
// A bare symbol is the listing `quote` reads it as: D05 and "Singtel" are on SGX, which earnings alerts do not follow.
|
|
1159
|
+
const abroad = await withMarketData(ctx, (market) => earningsListingVenue(earnings!.symbol, market, { retry: alertRetry })
|
|
1160
|
+
.catch((error: unknown) => error instanceof AlertListingRefusal ? ctx.fail(error.message, error.details) : Promise.reject(error)));
|
|
1161
|
+
read.push(...abroad.notes);
|
|
1162
|
+
return abroad.exchange
|
|
1163
|
+
? { kind: "earnings" as const, symbol: abroad.symbol, exchange: abroad.exchange }
|
|
1164
|
+
: { kind: "earnings" as const, symbol: listing.symbol, exchange: listing.exchange };
|
|
1120
1165
|
});
|
|
1121
1166
|
const lead = earnings?.results ? "results" as const : (macro ?? earnings!).leadDays;
|
|
1122
1167
|
// A listing the rule cannot follow fails before any request.
|
|
@@ -1158,11 +1203,15 @@ export const alertsCliCommand: CliCommandDef = {
|
|
|
1158
1203
|
const [{ dates, warnings }, cloud] = await Promise.all([listEventDates(events.rules, now, lookup), cloudRuleStates(events.rules, session)]);
|
|
1159
1204
|
const rows = [
|
|
1160
1205
|
...alerts.map(priceRow),
|
|
1161
|
-
...events.rules.map((rule) => eventRow(rule, now, dates.has(rule.id) ? dates.get(rule.id) : rule.eventDate, checks[rule.id], cloud, !!session
|
|
1206
|
+
...events.rules.map((rule) => eventRow(rule, now, dates.has(rule.id) ? dates.get(rule.id) : rule.eventDate, checks[rule.id], cloud, !!session,
|
|
1207
|
+
checksProRules(!!session, apiClient.getCurrentUser()))),
|
|
1162
1208
|
];
|
|
1163
1209
|
const waiting = rows.filter((row) => row.status === NEEDS_SIGN_IN).length;
|
|
1210
|
+
// The Pro note `alerts add` prints, once for the list: options flow and IV spikes are checked only with Pro.
|
|
1211
|
+
const proRules = events.rules.filter(checkedOnlyWithPro);
|
|
1164
1212
|
const allWarnings = [...(alertsError ? [alertsError] : []), ...(events.error ? [events.error] : []), ...warnings, ...cloud.warning ? [cloud.warning] : [],
|
|
1165
|
-
...waiting ? [needsSignInNote(waiting)] : []
|
|
1213
|
+
...waiting ? [needsSignInNote(waiting)] : [],
|
|
1214
|
+
...proRules.length ? [needsProNote(proRules, rows.filter((row) => row.status === NEEDS_PRO).length)] : []];
|
|
1166
1215
|
ctx.printResult({ data: rows, ...(allWarnings.length ? { warnings: allWarnings } : {}) }, {
|
|
1167
1216
|
rows: (data) => data.map(textRow),
|
|
1168
1217
|
textColumns: [
|
|
@@ -1311,7 +1360,7 @@ export const alertsCliCommand: CliCommandDef = {
|
|
|
1311
1360
|
const goesOffThen = daily && alreadyMet ? ` It goes off then if it is still ${alert.condition}.` : "";
|
|
1312
1361
|
const notes = [
|
|
1313
1362
|
alert.metric ? unread ? `Not read yet: ${unread.replace(/\.$/, "")}.` : `${metricReadingNote(alert)}${met}.`
|
|
1314
|
-
: checkedPrice != null ? `Last price ${alertPriceText(alert, checkedPrice)}${met}.` : null,
|
|
1363
|
+
: checkedPrice != null ? `Last price ${alertPriceText(alert, checkedPrice)}${readingSessionWords({ lastQuoteSession: extendedPrintSession(priced?.quote, checkedPrice) ?? undefined })}${met}.` : null,
|
|
1315
1364
|
firstCheck ? `First checked on the ${firstCheck.day} ${weekly ? "weekly close" : "close"}, from ${isoUtc(firstCheck.at).slice(11, 16)} UTC.${goesOffThen}`
|
|
1316
1365
|
: goesOffThen ? `It goes off on the first close it is checked on if it is still ${alert.condition}.` : null,
|
|
1317
1366
|
].filter(Boolean).join(" ");
|
|
@@ -1336,11 +1385,15 @@ export const alertsCliCommand: CliCommandDef = {
|
|
|
1336
1385
|
record("created", rule);
|
|
1337
1386
|
const delivery = research ? researchDelivery(research.kind) : ruleDelivery(formRule!.event);
|
|
1338
1387
|
// Saved signed out, it waits on a sign-in, and `alerts list` and ALRT say so until there is one.
|
|
1339
|
-
|
|
1340
|
-
const
|
|
1388
|
+
// Options flow and an IV spike wait on Pro, which a free sign-in does not bring.
|
|
1389
|
+
const session = savedSession(config);
|
|
1390
|
+
const needsPro = checkedOnlyWithPro(rule) && !checksProRules(!!session, apiClient.getCurrentUser());
|
|
1391
|
+
const needsSignIn = !needsPro && checkedWhenSignedIn(rule) && !session;
|
|
1392
|
+
const signIn = needsPro ? savedWithoutProNote(rule) : needsSignIn
|
|
1341
1393
|
? " It needs sign-in: nothing checks it while you are signed out. Open the app (gloom) and log in or sign up free from the command bar (Ctrl+P, Log In or Sign Up)."
|
|
1342
1394
|
: "";
|
|
1343
|
-
ctx.printResult({ data: { changed: !ctx.cliOptions.dryRun, dryRun: ctx.cliOptions.dryRun, alert: rule,
|
|
1395
|
+
ctx.printResult({ data: { changed: !ctx.cliOptions.dryRun, dryRun: ctx.cliOptions.dryRun, alert: rule,
|
|
1396
|
+
...needsPro ? { status: NEEDS_PRO } : needsSignIn ? { status: NEEDS_SIGN_IN } : {} },
|
|
1344
1397
|
...(read.length > 0 ? { warnings: read } : {}) }, {
|
|
1345
1398
|
text: (data) => `Added alert ${data.alert.id}: ${alertKindLabel(rule.kind)} ${eventAlertTarget(rule)} (${delivery}).${signIn}${dryRunNote(data.dryRun)}`,
|
|
1346
1399
|
});
|