gloomberb 0.20.2 → 0.20.4
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/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/package.json +2 -1
- package/src/account/auth-dialog.tsx +17 -0
- package/src/account/auth-form.tsx +13 -8
- package/src/account/upgrade-dialog.tsx +1 -1
- package/src/api-client/central-bank-rates.ts +5 -0
- package/src/api-client/data.ts +23 -4
- package/src/api-client/debt-maturities.ts +45 -2
- package/src/api-client/earnings.ts +4 -2
- package/src/api-client/errors.ts +21 -11
- package/src/api-client/fx-interventions.ts +64 -0
- package/src/api-client/index.ts +2 -0
- package/src/api-client/paths.ts +9 -1
- package/src/api-client/release-summaries.ts +21 -0
- package/src/api-client/social-mentions.ts +47 -0
- package/src/api-client/types/econ.ts +4 -0
- package/src/app/keybindings/actions.ts +2 -2
- package/src/app/pane-runtime/ticker-open-runtime.ts +245 -66
- package/src/app.tsx +11 -1
- package/src/cli/command-options.ts +2 -1
- package/src/cli/commands/market.ts +188 -30
- package/src/cli/commands/news-search.ts +1 -3
- package/src/cli/commands/options-chain.ts +23 -6
- package/src/cli/commands/overview.ts +13 -5
- package/src/cli/commands/plugins.ts +76 -23
- package/src/cli/commands/search.ts +25 -6
- package/src/cli/commands/system.ts +19 -3
- package/src/cli/commands/ticker.ts +64 -21
- package/src/cli/fx-quote-rate.ts +49 -1
- package/src/cli/glossary.ts +95 -15
- package/src/cli/history-rows.ts +9 -25
- package/src/cli/index.ts +14 -46
- package/src/cli/known-gaps.ts +3 -3
- package/src/cli/listing-arg.ts +78 -18
- package/src/cli/name-entries.ts +3 -2
- package/src/cli/not-a-ticker.ts +6 -2
- package/src/cli/pane-functions/capabilities.ts +12 -1
- package/src/cli/pane-functions/function-help.ts +26 -14
- package/src/cli/pane-functions/headless.ts +3 -1
- package/src/cli/pane-functions/index.ts +32 -4
- package/src/cli/pane-functions/market-session.ts +8 -3
- package/src/cli/pane-functions/resolver.ts +18 -11
- package/src/cli/pane-functions/screenshot-payload.ts +36 -6
- package/src/cli/pane-functions/screenshot-render.ts +4 -0
- package/src/cli/quote-answer.ts +10 -0
- package/src/cli/report-tables.ts +40 -8
- package/src/cli/result.ts +21 -9
- package/src/cli/spreadsheet-hint.ts +43 -0
- package/src/cli/symbol-list.ts +58 -4
- package/src/cli/symbol-rows.ts +49 -2
- package/src/cli/ticker-resolution.ts +98 -5
- package/src/cli/types.ts +2 -0
- package/src/cli/unknown-command.ts +88 -0
- package/src/components/chart/composite/axis-overlays.tsx +22 -0
- package/src/components/chart/composite/composite-chart.tsx +54 -13
- package/src/components/chart/composite/event-captions.ts +109 -0
- package/src/components/chart/composite/event-guides.ts +74 -0
- package/src/components/chart/composite/rasterizer.ts +2 -0
- package/src/components/chart/composite/text-renderer.ts +2 -0
- package/src/components/chart/composite/types.ts +31 -0
- package/src/components/command-bar/assist/model.ts +6 -1
- package/src/components/command-bar/commands/direct/index.ts +9 -1
- package/src/components/command-bar/commands/registry.ts +18 -0
- package/src/components/command-bar/layout-items/focused-pane.ts +5 -5
- package/src/components/command-bar/pane-actions.ts +30 -13
- package/src/components/command-bar/panel/index.tsx +6 -3
- package/src/components/command-bar/panel/prompt-binding.ts +4 -0
- package/src/components/command-bar/panel/types.ts +3 -0
- package/src/components/command-bar/routes/header-market.ts +108 -0
- package/src/components/command-bar/routes/root/command-items.ts +5 -0
- package/src/components/command-bar/routes/root/provider-search.ts +192 -33
- package/src/components/command-bar/routes/root/results.ts +3 -0
- package/src/components/command-bar/routes/root/runtime.ts +28 -5
- package/src/components/command-bar/routes/ticker-search/results.ts +104 -6
- package/src/components/command-bar/routes/ticker-search/route.ts +3 -2
- package/src/components/command-bar/routing/list-state.ts +38 -0
- package/src/components/command-bar/selection-hint.ts +28 -0
- package/src/components/command-bar/surface/index.tsx +41 -3
- package/src/components/command-bar/view-model.ts +15 -0
- package/src/components/command-bar/workflow/tickers.ts +3 -2
- package/src/components/company-logo.tsx +20 -2
- package/src/components/data-table/export.ts +13 -8
- package/src/components/feedback-dialog.tsx +2 -1
- package/src/components/form-modal/field-row.tsx +2 -1
- package/src/components/input-search-bar.tsx +2 -2
- package/src/components/layout/detached-pane-shell.tsx +1 -1
- package/src/components/layout/double-escape-close.ts +8 -5
- package/src/components/layout/floating-pane.tsx +5 -1
- package/src/components/layout/header.tsx +75 -44
- package/src/components/layout/market-summary.ts +322 -116
- package/src/components/layout/pane/footer/index.tsx +44 -19
- package/src/components/layout/pane/footer/model.ts +52 -20
- package/src/components/layout/pane/header.tsx +3 -2
- package/src/components/layout/shell/action-menu-overlay.tsx +10 -5
- package/src/components/layout/shell/active-drag.ts +149 -105
- package/src/components/layout/shell/chrome.ts +15 -15
- package/src/components/layout/shell/drag/drop-zones.ts +162 -0
- package/src/components/layout/shell/drag/index.ts +47 -218
- package/src/components/layout/shell/drag/live.ts +10 -3
- package/src/components/layout/shell/drag/overlays.tsx +182 -5
- package/src/components/layout/shell/drag/runtime.ts +29 -6
- package/src/components/layout/shell/drag/shared-edges.ts +156 -0
- package/src/components/layout/shell/index.tsx +11 -6
- package/src/components/layout/shell/menu.ts +11 -2
- package/src/components/layout/shell/native/pointer-runtime.ts +25 -0
- package/src/components/layout/shell/native/window-state.ts +2 -2
- package/src/components/layout/shell/pane/layers.tsx +71 -7
- package/src/components/layout/shell/terminal-pointer-runtime.ts +18 -9
- package/src/components/layout/shell/window-mode/index.ts +8 -10
- package/src/components/layout/status-bar.tsx +8 -7
- package/src/components/layout/status-widget-space.ts +8 -0
- package/src/components/layout/window-edit/mode.ts +39 -7
- package/src/components/layout/window-edit/presentation.ts +1 -1
- package/src/components/markdown-editor.tsx +2 -2
- package/src/components/onboarding/account-step/form-panel.tsx +0 -3
- package/src/components/onboarding/onboarding-keyboard.ts +19 -6
- package/src/components/onboarding/onboarding-wizard.tsx +69 -14
- package/src/components/onboarding/portfolio-step/broker-fields-panel.tsx +0 -1
- package/src/components/onboarding/portfolio-step/positions-panel.tsx +0 -2
- package/src/components/price-sparkline/model.ts +26 -10
- package/src/components/ticker/list-table-view.tsx +29 -4
- package/src/components/ui/button.tsx +15 -2
- package/src/components/ui/choice-dialog.tsx +1 -0
- package/src/components/ui/column-grid.tsx +18 -9
- package/src/components/ui/data-table/index.tsx +5 -4
- package/src/components/ui/data-table/opentui/index.tsx +2 -1
- package/src/components/ui/data-table/types.ts +18 -0
- package/src/components/ui/delayed-mark.tsx +3 -2
- package/src/components/ui/field-grid.tsx +0 -2
- package/src/components/ui/fields.tsx +7 -4
- package/src/components/ui/inline-quick-add.tsx +2 -2
- package/src/components/ui/key-hint-words.ts +153 -0
- package/src/components/ui/key-hints.tsx +73 -0
- package/src/components/ui/list-view.tsx +7 -12
- package/src/components/ui/loading.tsx +10 -3
- package/src/components/ui/menu.tsx +9 -3
- package/src/components/ui/message-composer.tsx +2 -2
- package/src/components/ui/quote.ts +14 -1
- package/src/components/ui/shortcut-hint.tsx +28 -3
- package/src/components/ui/tabs.tsx +7 -0
- package/src/components/ui/text-prompt-dialog.tsx +2 -1
- package/src/core/state/app/command-bar-launch.ts +3 -0
- package/src/data/config/layout.ts +5 -2
- package/src/data/config/store/normalize.ts +6 -0
- package/src/docs/snapshot.json +149 -74
- package/src/i18n/es.ts +33 -9
- package/src/i18n/ja.ts +33 -9
- package/src/i18n/ko.ts +33 -9
- package/src/i18n/zh-cn.ts +33 -9
- package/src/i18n/zh-tw.ts +33 -9
- package/src/layout/pane-manager/floating-actions.ts +17 -0
- package/src/layout/pane-manager/floating-stack.ts +187 -0
- package/src/layout/pane-manager/floating.ts +4 -2
- package/src/layout/pane-manager/gridlock.ts +16 -1
- package/src/layout/pane-manager/index.ts +11 -0
- package/src/layout/pane-manager/layout-state.ts +10 -3
- package/src/market-data/bars-per-year.ts +27 -9
- package/src/market-data/coordinator/quotes.ts +22 -3
- package/src/market-data/futures-board.ts +126 -1
- package/src/market-data/futures-contract.ts +21 -6
- package/src/market-data/fx-interventions.ts +270 -0
- package/src/market-data/market/change-basis.ts +2 -2
- package/src/market-data/market/dated-previous-close.ts +163 -47
- package/src/market-data/market/format.ts +14 -3
- package/src/market-data/market/freshness.ts +24 -7
- package/src/market-data/market/header-market.ts +154 -0
- package/src/market-data/market/index-level.ts +29 -0
- package/src/market-data/market/index-session-venues.ts +44 -0
- package/src/market-data/market/status.ts +7 -2
- package/src/market-data/market/venue-session.ts +72 -0
- package/src/market-data/model-dividend-yield.ts +23 -8
- package/src/market-data/options-alternatives.ts +39 -4
- package/src/market-data/published-apac-sessions.ts +40 -2
- package/src/market-data/quotes/export-identity.ts +76 -0
- package/src/market-data/quotes/freshness.ts +22 -0
- package/src/market-data/quotes/time.ts +42 -1
- package/src/market-data/realized-volatility.ts +11 -7
- package/src/market-data/tax-equivalent.ts +145 -27
- package/src/news/news-model.ts +44 -2
- package/src/plugins/builtin/account-management/pane.tsx +2 -2
- package/src/plugins/builtin/alerts/alert-engine.ts +12 -6
- package/src/plugins/builtin/alerts/alert-log.ts +6 -2
- package/src/plugins/builtin/alerts/calendar-events.ts +74 -12
- package/src/plugins/builtin/alerts/cli-forms.ts +11 -1
- package/src/plugins/builtin/alerts/cli-move.ts +234 -0
- package/src/plugins/builtin/alerts/cli.ts +223 -32
- package/src/plugins/builtin/alerts/command.ts +33 -6
- package/src/plugins/builtin/alerts/event-rows.ts +18 -4
- package/src/plugins/builtin/alerts/events-pane.tsx +6 -2
- package/src/plugins/builtin/alerts/events.ts +9 -0
- package/src/plugins/builtin/alerts/format.ts +39 -15
- package/src/plugins/builtin/alerts/headless.ts +30 -18
- package/src/plugins/builtin/alerts/history.ts +1 -0
- package/src/plugins/builtin/alerts/index.tsx +86 -12
- package/src/plugins/builtin/alerts/live.ts +2 -1
- package/src/plugins/builtin/alerts/move-checks.ts +161 -0
- package/src/plugins/builtin/alerts/move.ts +181 -0
- package/src/plugins/builtin/alerts/pane.tsx +50 -22
- package/src/plugins/builtin/alerts/price-text.ts +62 -0
- package/src/plugins/builtin/alerts/price.ts +17 -0
- package/src/plugins/builtin/alerts/quotes.ts +84 -3
- package/src/plugins/builtin/alerts/scheduled-check.ts +7 -1
- package/src/plugins/builtin/alerts/storage.ts +22 -7
- package/src/plugins/builtin/alerts/types.ts +25 -0
- package/src/plugins/builtin/analytics/risk-client.ts +60 -39
- package/src/plugins/builtin/analytics/risk-episodes.ts +18 -0
- package/src/plugins/builtin/analytics/risk-headless.ts +20 -4
- package/src/plugins/builtin/analytics/risk-model.ts +68 -1
- package/src/plugins/builtin/analytics/risk-pane.tsx +15 -3
- package/src/plugins/builtin/backtest/engine.ts +4 -2
- package/src/plugins/builtin/backtest/window.ts +3 -1
- package/src/plugins/builtin/broker-manager/sign-in-end.ts +1 -1
- package/src/plugins/builtin/central-bank-rates/client.ts +4 -0
- package/src/plugins/builtin/central-bank-rates/headless.ts +1 -1
- package/src/plugins/builtin/central-bank-rates/model.ts +18 -8
- package/src/plugins/builtin/central-bank-rates/pane.tsx +6 -3
- package/src/plugins/builtin/changelog/index.tsx +292 -101
- package/src/plugins/builtin/changelog/versions.ts +293 -0
- package/src/plugins/builtin/chart-composer/cli-options.ts +5 -0
- package/src/plugins/builtin/chart-composer/headless-schema.ts +17 -1
- package/src/plugins/builtin/chart-composer/headless.ts +2 -0
- package/src/plugins/builtin/chart-composer/intervention-events.ts +105 -0
- package/src/plugins/builtin/chart-composer/pane.tsx +21 -7
- package/src/plugins/builtin/chat/message/render-state.ts +2 -5
- package/src/plugins/builtin/cloud/askg/attached-pane.tsx +10 -5
- package/src/plugins/builtin/cloud/askg/controller.ts +141 -5
- package/src/plugins/builtin/cloud/askg/executor.ts +113 -4
- package/src/plugins/builtin/cloud/askg/manifest.ts +28 -13
- package/src/plugins/builtin/cloud/askg/model.ts +14 -4
- package/src/plugins/builtin/cloud/askg/pane.tsx +70 -46
- package/src/plugins/builtin/cloud/askg/turn-parts.tsx +70 -0
- package/src/plugins/builtin/cloud/terminal-relay/engine.ts +50 -130
- package/src/plugins/builtin/cloud/terminal-relay/policy.ts +327 -7
- package/src/plugins/builtin/cloud/terminal-relay/prompts.tsx +2 -1
- package/src/plugins/builtin/cloud/terminal-relay/redact.ts +47 -6
- package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +9 -2
- package/src/plugins/builtin/commodities-energy/index.tsx +1 -3
- package/src/plugins/builtin/commodities-energy/view-state.ts +3 -0
- package/src/plugins/builtin/cot/headless.ts +14 -2
- package/src/plugins/builtin/crypto-board/headless.ts +82 -17
- package/src/plugins/builtin/crypto-board/index.tsx +24 -2
- package/src/plugins/builtin/crypto-board/model.ts +5 -2
- package/src/plugins/builtin/crypto-board/pane.tsx +4 -1
- package/src/plugins/builtin/debt-maturities/client.ts +111 -6
- package/src/plugins/builtin/debt-maturities/headless.ts +84 -1
- package/src/plugins/builtin/debt-maturities/model.ts +97 -14
- package/src/plugins/builtin/debt-maturities/pane.tsx +165 -15
- package/src/plugins/builtin/debt-maturities/series.ts +3 -1
- package/src/plugins/builtin/dividend-yield/client.ts +22 -6
- package/src/plugins/builtin/dividend-yield/headless.ts +113 -46
- package/src/plugins/builtin/dividend-yield/model.ts +5 -2
- package/src/plugins/builtin/dividend-yield/pane.tsx +6 -3
- package/src/plugins/builtin/dividend-yield/ranking-reads.ts +11 -4
- package/src/plugins/builtin/dividend-yield/ranking.ts +113 -18
- package/src/plugins/builtin/dividend-yield/types.ts +2 -0
- package/src/plugins/builtin/dividend-yield/view.ts +3 -0
- package/src/plugins/builtin/earnings/index.tsx +2 -2
- package/src/plugins/builtin/econ/calendar-model.ts +21 -3
- package/src/plugins/builtin/econ/detail-view.tsx +5 -3
- package/src/plugins/builtin/econ/figures.ts +13 -0
- package/src/plugins/builtin/econ/fred-catalog.ts +6 -3
- package/src/plugins/builtin/econ/index.tsx +5 -3
- package/src/plugins/builtin/econ/types.ts +5 -0
- package/src/plugins/builtin/equity-screener/footer.ts +45 -0
- package/src/plugins/builtin/equity-screener/pane.tsx +4 -18
- package/src/plugins/builtin/equity-screener/ticker-check.tsx +2 -1
- package/src/plugins/builtin/fixed-income/model.ts +1 -0
- package/src/plugins/builtin/futures/index.tsx +25 -4
- package/src/plugins/builtin/futures/model.ts +28 -32
- package/src/plugins/builtin/futures/series.ts +4 -3
- package/src/plugins/builtin/futures/table.tsx +17 -10
- package/src/plugins/builtin/futures/use-board-terms.ts +3 -3
- package/src/plugins/builtin/futures-curve/model.ts +3 -10
- package/src/plugins/builtin/help/function-card.tsx +2 -1
- package/src/plugins/builtin/help/function-index.ts +1 -0
- package/src/plugins/builtin/help/index.tsx +3 -3
- package/src/plugins/builtin/help/keybindings-editor.tsx +18 -4
- package/src/plugins/builtin/insider/client.ts +31 -14
- package/src/plugins/builtin/insider/signals-model.ts +2 -7
- package/src/plugins/builtin/iv-history/headless.ts +1 -2
- package/src/plugins/builtin/iv-history/model.ts +33 -23
- package/src/plugins/builtin/iv-history/screen-pane.tsx +0 -3
- package/src/plugins/builtin/kelly-sizer/headless.ts +64 -16
- package/src/plugins/builtin/kelly-sizer/history.ts +37 -28
- package/src/plugins/builtin/kelly-sizer/pane.tsx +43 -10
- package/src/plugins/builtin/kelly-sizer/sections.tsx +7 -2
- package/src/plugins/builtin/kelly-sizer/units.ts +29 -0
- package/src/plugins/builtin/layout-manager/index.tsx +8 -8
- package/src/plugins/builtin/news/headless.ts +2 -2
- package/src/plugins/builtin/news/index.tsx +10 -16
- package/src/plugins/builtin/news/overview-headlines.tsx +117 -0
- package/src/plugins/builtin/news/ticker-news.ts +35 -0
- package/src/plugins/builtin/news/wire/news/detail-view.tsx +8 -6
- package/src/plugins/builtin/news/wire/news/row.ts +49 -0
- package/src/plugins/builtin/news/wire/news/table.tsx +9 -20
- package/src/plugins/builtin/options/analytics.ts +7 -2
- package/src/plugins/builtin/options/live-quotes.ts +6 -1
- package/src/plugins/builtin/options/table.ts +3 -2
- package/src/plugins/builtin/options/view.tsx +11 -9
- package/src/plugins/builtin/options-scenario/client.ts +3 -0
- package/src/plugins/builtin/options-scenario/headless.ts +1 -1
- package/src/plugins/builtin/perps/client.ts +5 -4
- package/src/plugins/builtin/perps/headless.ts +134 -124
- package/src/plugins/builtin/perps/markets-section.tsx +7 -4
- package/src/plugins/builtin/perps/model.ts +8 -4
- package/src/plugins/builtin/perps/open-market.ts +4 -4
- package/src/plugins/builtin/perps/venue-markets.ts +3 -6
- package/src/plugins/builtin/plugin-marketplace/pane.tsx +11 -11
- package/src/plugins/builtin/portfolio-list/cell-version.ts +1 -0
- package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +34 -10
- package/src/plugins/builtin/portfolio-list/cli/period-report.ts +28 -2
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +7 -3
- package/src/plugins/builtin/portfolio-list/cli/render.ts +66 -22
- package/src/plugins/builtin/portfolio-list/grid.tsx +5 -3
- package/src/plugins/builtin/portfolio-list/pane/data.ts +34 -1
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +6 -0
- package/src/plugins/builtin/portfolio-list/pane/streaming.ts +15 -6
- package/src/plugins/builtin/portfolio-list/quick-add/resolution.ts +19 -7
- package/src/plugins/builtin/portfolio-list/summary/index.tsx +3 -1
- package/src/plugins/builtin/portfolio-list/table.tsx +30 -4
- package/src/plugins/builtin/realized-vol/evidence.ts +33 -6
- package/src/plugins/builtin/realized-vol/fx-proxy.ts +135 -0
- package/src/plugins/builtin/realized-vol/headless.ts +44 -8
- package/src/plugins/builtin/realized-vol/model.ts +9 -5
- package/src/plugins/builtin/realized-vol/pane.tsx +49 -15
- package/src/plugins/builtin/research/event-model.ts +9 -1
- package/src/plugins/builtin/research/event-sources.ts +22 -0
- package/src/plugins/builtin/research/headless.ts +3 -3
- package/src/plugins/builtin/sec/headless.ts +48 -6
- package/src/plugins/builtin/sec/index.tsx +6 -4
- package/src/plugins/builtin/sec/model.ts +4 -1
- package/src/plugins/builtin/shared/cloud-upgrade.ts +27 -3
- package/src/plugins/builtin/shared/earnings-calendar.ts +2 -0
- package/src/plugins/builtin/shared/market-cap-bands.ts +12 -0
- package/src/plugins/builtin/shared/report-freshness.ts +3 -1
- package/src/plugins/builtin/shared/use-quote-board.ts +5 -3
- package/src/plugins/builtin/shared/volatility/options.ts +63 -2
- package/src/plugins/builtin/social-mentions/headless.ts +72 -3
- package/src/plugins/builtin/social-mentions/index.tsx +8 -4
- package/src/plugins/builtin/social-mentions/lock-note.ts +6 -2
- package/src/plugins/builtin/social-mentions/outliers-client.ts +101 -0
- package/src/plugins/builtin/social-mentions/outliers-model.ts +162 -0
- package/src/plugins/builtin/social-mentions/outliers-names.ts +51 -0
- package/src/plugins/builtin/social-mentions/outliers.tsx +276 -0
- package/src/plugins/builtin/social-mentions/pane.tsx +32 -3
- package/src/plugins/builtin/supply-chain/graph-pane.tsx +2 -2
- package/src/plugins/builtin/thirteenf/api.ts +36 -2
- package/src/plugins/builtin/thirteenf/data.ts +4 -1
- package/src/plugins/builtin/thirteenf/headless.ts +14 -6
- package/src/plugins/builtin/thirteenf/model.ts +56 -1
- package/src/plugins/builtin/thirteenf/pane.tsx +8 -8
- package/src/plugins/builtin/thirteenf/report-notes.ts +11 -0
- package/src/plugins/builtin/thirteenf/table.ts +2 -1
- package/src/plugins/builtin/thirteenf/types.ts +6 -0
- package/src/plugins/builtin/ticker-detail/data-panes/historical-prices.tsx +23 -3
- package/src/plugins/builtin/ticker-detail/financials/model.ts +5 -0
- package/src/plugins/builtin/ticker-detail/headless-schema.ts +2 -1
- package/src/plugins/builtin/ticker-detail/headless.ts +21 -66
- package/src/plugins/builtin/ticker-detail/index.tsx +5 -0
- package/src/plugins/builtin/ticker-detail/overview/components.tsx +67 -6
- package/src/plugins/builtin/ticker-detail/overview/model.ts +6 -4
- package/src/plugins/builtin/ticker-detail/overview/pane.tsx +15 -0
- package/src/plugins/builtin/ticker-detail/overview/tax-equivalent.ts +69 -0
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +69 -19
- package/src/plugins/builtin/ticker-detail/pane.tsx +7 -2
- package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +47 -24
- package/src/plugins/builtin/ticker-detail/quote-monitor/export.ts +46 -0
- package/src/plugins/builtin/ticker-detail/quote-monitor/index.tsx +20 -1
- package/src/plugins/builtin/ticker-detail/quote-monitor/rows.ts +120 -0
- package/src/plugins/builtin/ticker-detail/research-tabs.ts +1 -5
- package/src/plugins/builtin/ticker-detail/settings.ts +6 -6
- package/src/plugins/builtin/treasury-auctions/cache.ts +85 -19
- package/src/plugins/builtin/treasury-auctions/index.tsx +22 -11
- package/src/plugins/builtin/treasury-auctions/model.ts +23 -0
- package/src/plugins/builtin/treasury-auctions/treasury-direct.ts +128 -0
- package/src/plugins/builtin/world-indices/client.ts +2 -0
- package/src/plugins/compat.ts +15 -0
- package/src/plugins/host-link.ts +6 -1
- package/src/plugins/installer.ts +53 -3
- package/src/portfolio/column-values.ts +14 -4
- package/src/portfolio/listed-symbol.ts +78 -0
- package/src/portfolio/real-return.ts +172 -0
- package/src/public/__snapshots__/public-api.test.ts.snap +1 -0
- package/src/remote/resources.ts +12 -1
- package/src/remote/schema.ts +1 -0
- package/src/remote/semantic-helpers.ts +29 -1
- package/src/remote/semantic-tree.tsx +32 -15
- package/src/renderers/browser/config-host.ts +56 -15
- package/src/renderers/browser/main.tsx +3 -1
- package/src/renderers/browser/ui-host.tsx +1 -0
- package/src/renderers/cloudflare/http-proxy.ts +1 -0
- package/src/renderers/cloudflare/worker.ts +16 -1
- package/src/renderers/dom/boot-frame.ts +2 -2
- package/src/renderers/dom/data-table/row.tsx +4 -1
- package/src/renderers/dom/desktop/controls.tsx +4 -4
- package/src/renderers/dom/desktop/dialog-actions.tsx +60 -41
- package/src/renderers/dom/dom-ui-host.tsx +3 -1
- package/src/renderers/dom/host/input.tsx +4 -1
- package/src/renderers/dom/host/tabs.tsx +10 -1
- package/src/renderers/dom/styles.css +73 -19
- package/src/renderers/electrobun/bun/desktop/app-name.ts +1 -1
- package/src/renderers/opentui/host.tsx +2 -1
- package/src/renderers/share/layout-view.tsx +1 -1
- package/src/sources/gloomberb-cloud/fred-series.ts +12 -0
- package/src/sources/gloomberb-cloud/index.ts +31 -2
- package/src/sources/gloomberb-cloud/news.ts +35 -12
- package/src/sources/gloomberb-cloud/normalizers.ts +29 -3
- package/src/sources/provider-router/cached-routes.ts +19 -7
- package/src/state/opening-ticker-panes.ts +47 -0
- package/src/state/pane-table-export-registry.ts +19 -6
- package/src/test-support/cli-context.ts +2 -0
- package/src/test-support/preload.ts +8 -1
- package/src/theme/colors.ts +9 -1
- package/src/theme/themes.ts +62 -15
- package/src/theme/tone-contrast.ts +40 -0
- package/src/theme/ui-tokens.ts +23 -3
- package/src/tickers/batched-lookups.ts +57 -8
- package/src/tickers/company-name-listing.ts +156 -14
- package/src/tickers/company-name.ts +30 -6
- package/src/tickers/instrument-kind.ts +23 -3
- package/src/tickers/list.ts +7 -0
- package/src/tickers/search/home-listing.ts +31 -9
- package/src/tickers/search/index.ts +13 -3
- package/src/tickers/search/listing-index.ts +558 -0
- package/src/tickers/search/major-listings.chunk.ts +10 -0
- package/src/tickers/search/major-listings.json +3346 -0
- package/src/tickers/search/ranking.ts +68 -1
- package/src/tickers/search/types.ts +4 -0
- package/src/tickers/terminal-codes.ts +26 -1
- package/src/time-series/calendar-month-returns.ts +47 -0
- package/src/time-series/currency-conversion.ts +130 -0
- package/src/time-series/hooks.ts +2 -0
- package/src/time-series/price-comparison.ts +34 -11
- package/src/time-series/resolve-context.ts +3 -0
- package/src/time-series/resolve.ts +14 -2
- package/src/time-series/spec.ts +1 -0
- package/src/time-series/studies/indicators.ts +4 -1
- package/src/time-series/types.ts +8 -0
- package/src/types/config.ts +13 -0
- package/src/types/context-menu.ts +2 -0
- package/src/types/data-provider.ts +28 -0
- package/src/types/financials.ts +20 -2
- package/src/types/headless.ts +12 -0
- package/src/types/plugin-commands.ts +140 -0
- package/src/types/plugin-context.ts +125 -0
- package/src/types/plugin-contributions.ts +55 -0
- package/src/types/plugin-definition.ts +234 -0
- package/src/types/plugin-notifications.ts +38 -0
- package/src/types/plugin-pane-settings.ts +114 -0
- package/src/types/plugin-pane-templates.ts +160 -0
- package/src/types/plugin-panes.ts +221 -0
- package/src/types/plugin-reports.ts +35 -0
- package/src/types/plugin-shared.ts +14 -0
- package/src/types/plugin-state.ts +71 -0
- package/src/types/plugin.ts +14 -1169
- package/src/ui/host.tsx +8 -0
- package/src/ui/index.tsx +14 -3
- package/src/updater/github-releases.ts +23 -0
- package/src/utils/cli-output.ts +22 -9
- package/src/utils/datetime-format.ts +17 -3
- package/src/utils/display-number.ts +15 -0
- package/src/utils/double-escape-close.ts +61 -16
- package/src/utils/float32-price.ts +24 -0
- package/src/utils/forward-dividend.ts +81 -16
- package/src/utils/fx-market-hours.ts +11 -0
- package/src/utils/plugin-proxy-hosts.json +2 -1
- package/src/utils/price-history.ts +7 -6
- package/src/utils/report-timing.ts +62 -0
- package/src/utils/sec-filings.ts +32 -0
- package/src/utils/utc-time.ts +5 -0
|
@@ -5,12 +5,13 @@ 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, NOT_CHECKED_YET } from "./format";
|
|
8
|
+
import { alertListing, alertReadingAt, alertReadingText, isoUtc, listingWithCurrency, measureLabel, NOT_CHECKED_YET } from "./format";
|
|
9
9
|
import { isQuoteStaleForCurrentSession } from "../../../market-data/quotes/freshness";
|
|
10
10
|
import { quoteAlertFields } from "./quotes";
|
|
11
11
|
import { createEventAlert } from "./events";
|
|
12
12
|
import { isResearchAlertKind, readResearchRule } from "./research-rules";
|
|
13
13
|
import { withConfigData, withMarketData } from "../../../cli/scoped-context";
|
|
14
|
+
import { localTimeSuffix } from "../../../utils/utc-time";
|
|
14
15
|
import { resolvePersistedCloudSessionToken } from "../../../cli/pane-functions/cloud-session";
|
|
15
16
|
import type { ConfigContext } from "../../../cli/types";
|
|
16
17
|
import { checkedWhenSignedIn, NEEDS_SIGN_IN, needsSignInNote } from "./event-rows";
|
|
@@ -44,14 +45,16 @@ import {
|
|
|
44
45
|
type CalendarEventChoice,
|
|
45
46
|
type ReleaseRename,
|
|
46
47
|
} from "./calendar-events";
|
|
47
|
-
import { createAlert, rearmAlert, sameLevelRule } from "./alert-engine";
|
|
48
|
+
import { createAlert, formatAlertDescription, rearmAlert, sameLevelRule } from "./alert-engine";
|
|
49
|
+
import { alertPriceText } from "./price-text";
|
|
48
50
|
import { ALERTS_PLUGIN_ID } from "./constants";
|
|
49
51
|
import { MAX_EVENT_ALERTS, eventAlertTarget, toggleEventAlert, writeEventAlertStores, type EventAlertRule } from "./events";
|
|
50
52
|
import { alertKindLabel, fetchAlertHistory, ruleStateText, type AlertRuleState } from "./history";
|
|
51
53
|
import { apiClient } from "../../../api-client";
|
|
52
54
|
import { IV_LEVEL_CHECKS_KEY, ivLevelCheckText, readIvLevelChecks, rearmIvLevelAlert, type IvLevelCheck } from "./iv-level";
|
|
53
|
-
import { parseAlertPrice,
|
|
54
|
-
import { farTargetMessage } from "./quotes";
|
|
55
|
+
import { isPenceLevel, parseAlertPrice, readAlertLevel } from "./price";
|
|
56
|
+
import { farTargetMessage, levelInQuoteUnit } from "./quotes";
|
|
57
|
+
import { isPenceQuotedLine } from "../../../market-data/market/format";
|
|
55
58
|
import { MACRO_EVENT_NAMES, createResearchAlert, formatPremium, ivLevelUnitError, parseAmount, parseIvLevel } from "./research-builder";
|
|
56
59
|
import { IV_LEVEL_RANGES, MAX_LEAD_DAYS, type IvLevelMetric, type MacroAlertEvent } from "./research-rules";
|
|
57
60
|
import {
|
|
@@ -77,6 +80,13 @@ import {
|
|
|
77
80
|
} from "./scheduled";
|
|
78
81
|
import { scheduledEventSources } from "./scheduled-sources";
|
|
79
82
|
import { readAlertStores, writeLevelAlertStores } from "./storage";
|
|
83
|
+
import {
|
|
84
|
+
bulkMoveLogRule, MOVE_REARM, moveNowText, parseMoveAddArgs, planMoveAlerts, quoteSavedListings, quoteTypedSymbols, uniqueInputs, venueCounts,
|
|
85
|
+
watchlistListings, MAX_BULK_ALERTS, type MoveAddRequest, type MoveListing, type MovePlan,
|
|
86
|
+
} from "./cli-move";
|
|
87
|
+
import { MOVE_DELIVERY, moveRuleWords } from "./move";
|
|
88
|
+
import { MOVE_CHECKS_KEY, moveChecksOf, readMoveChecks, withMoveChecks, type MoveCheck } from "./move-checks";
|
|
89
|
+
import { listAddLookups } from "../portfolio-list/cli/bulk-symbols";
|
|
80
90
|
import type { AlertCondition, AlertRule } from "./types";
|
|
81
91
|
|
|
82
92
|
/**
|
|
@@ -109,7 +119,12 @@ export type AlertAddRequest =
|
|
|
109
119
|
kind: "price"; symbol: string; condition: AlertCondition; price: number;
|
|
110
120
|
/** A price typed as 81.000, which the last price may show was 81000 with a dot between thousands. */
|
|
111
121
|
thousandsDot?: ThousandsDotReadings & { text: string };
|
|
122
|
+
/** The price as typed, `70p` for a London line in pence (`price` is then in pounds). */
|
|
123
|
+
typed?: string;
|
|
124
|
+
pence?: true;
|
|
112
125
|
}
|
|
126
|
+
/** A move from the previous close, on one symbol, several, or a watchlist's listings. */
|
|
127
|
+
| MoveAddRequest
|
|
113
128
|
/** `results`: once the report's actual EPS is out, rather than `leadDays` before the date. */
|
|
114
129
|
| { kind: "earnings"; symbol: string; leadDays: number; results?: true }
|
|
115
130
|
| { kind: "macro"; event: MacroAlertEvent; leadDays: number }
|
|
@@ -130,6 +145,32 @@ type ResearchAddRequest = Extract<AlertAddRequest, { kind: "news" | "flow" | "iv
|
|
|
130
145
|
|
|
131
146
|
const CONDITIONS: readonly AlertCondition[] = ["above", "below", "crosses"];
|
|
132
147
|
|
|
148
|
+
const capitalize = (text: string) => text.charAt(0).toUpperCase() + text.slice(1);
|
|
149
|
+
|
|
150
|
+
/** The lines under a bulk move add: what was set already, what quoted nothing, what was dropped, each named. */
|
|
151
|
+
function moveSummaryLines(
|
|
152
|
+
plan: Pick<MovePlan, "existing" | "sameListing" | "failed">,
|
|
153
|
+
moves: { repeats: number; leftOut: number },
|
|
154
|
+
): string[] {
|
|
155
|
+
const names = (inputs: string[]) => inputs.length > 12 ? `${inputs.slice(0, 12).join(", ")} and ${inputs.length - 12} more` : inputs.join(", ");
|
|
156
|
+
// 7203.T beside `7203 JP` is the alert the command just made, not one set before: "Same listing as 7203:JPX in this command: 7203.T."
|
|
157
|
+
const same = new Map<string, string[]>();
|
|
158
|
+
for (const entry of plan.sameListing) {
|
|
159
|
+
const listing = alertListing(entry.alert);
|
|
160
|
+
same.set(listing, [...same.get(listing) ?? [], entry.input]);
|
|
161
|
+
}
|
|
162
|
+
return [
|
|
163
|
+
...plan.existing.length ? [` Already set (${plan.existing.length}): ${names(plan.existing.map((entry) => entry.input))}.`] : [],
|
|
164
|
+
...[...same].slice(0, 12).map(([listing, inputs]) => ` Same listing as ${listing} in this command: ${names(inputs)}.`),
|
|
165
|
+
...same.size > 12 ? [` And ${same.size - 12} more listings typed twice.`] : [],
|
|
166
|
+
// Each with why, on its own line: `ZZZQQQ: Not a ticker: ZZZQQQ.`
|
|
167
|
+
...plan.failed.length ? [` Not added (${plan.failed.length}):`, ...plan.failed.slice(0, 12).map((entry) => ` ${entry.input}: ${entry.error.split("\n")[0]}`),
|
|
168
|
+
...plan.failed.length > 12 ? [` and ${plan.failed.length - 12} more: ${plan.failed.slice(12).map((entry) => entry.input).join(", ")}`] : []] : [],
|
|
169
|
+
...moves.repeats ? [` Repeats skipped: ${moves.repeats}.`] : [],
|
|
170
|
+
...moves.leftOut ? [` Left out: ${moves.leftOut}, past the ${MAX_BULK_ALERTS} one command adds.`] : [],
|
|
171
|
+
];
|
|
172
|
+
}
|
|
173
|
+
|
|
133
174
|
/** The first word of a price typed with a space between thousands and no quotes (`81 000`): one to three digits. */
|
|
134
175
|
const LEADING_GROUP = /^[+-]?\d{1,3}$/;
|
|
135
176
|
|
|
@@ -177,9 +218,11 @@ export function parseAlertAddArgs(
|
|
|
177
218
|
exchange?: string | null,
|
|
178
219
|
country?: string | null,
|
|
179
220
|
benchmark?: string | null,
|
|
221
|
+
/** `--watchlist` names the listings, so the words are only the move. */
|
|
222
|
+
watchlist = false,
|
|
180
223
|
): AlertAddRequest {
|
|
181
224
|
const [first, second, third, ...rest] = args;
|
|
182
|
-
if (!first) throw new Error(ADD_USAGE);
|
|
225
|
+
if (!first) throw new Error(watchlist ? `Name the move for the watchlist's listings: alerts add --watchlist <name> up 3%.` : ADD_USAGE);
|
|
183
226
|
const countryFilter = readCountryOption(country);
|
|
184
227
|
if (benchmark === null) throw new Error(`${BENCHMARK_RULE} such as alerts add XLE rrg leading --benchmark QQQ.`);
|
|
185
228
|
const rrgFlag = benchmark !== undefined && second?.toLowerCase() === "rrg";
|
|
@@ -197,12 +240,19 @@ export function parseAlertAddArgs(
|
|
|
197
240
|
if (days !== undefined || country !== undefined) throw new Error(`${isRelativeMetric(metric.metric) ? "Relative strength" : "Valuation and daily technical"} alerts take neither --days nor --country.`);
|
|
198
241
|
return { kind: "metric", ...metric };
|
|
199
242
|
}
|
|
200
|
-
const research = parseResearchAddArgs(args) ?? parseRuleAddArgs(args);
|
|
243
|
+
const research = watchlist ? null : parseResearchAddArgs(args) ?? parseRuleAddArgs(args);
|
|
201
244
|
if (research) {
|
|
202
245
|
if (days !== undefined) throw new Error("--days is for earnings and calendar event alerts, not this kind of alert.");
|
|
203
246
|
if (country !== undefined) throw new Error(COUNTRY_RULE);
|
|
204
247
|
return research;
|
|
205
248
|
}
|
|
249
|
+
// `moves 0.5%`, `up 3%`, `down 3%`, on one symbol, several or a watchlist; `below -3%` is down 3%.
|
|
250
|
+
const move = parseMoveAddArgs(args, watchlist);
|
|
251
|
+
if (move) {
|
|
252
|
+
if (days !== undefined || country !== undefined) throw new Error("A move alert takes neither --days nor --country.");
|
|
253
|
+
return move;
|
|
254
|
+
}
|
|
255
|
+
if (watchlist) throw new Error(`A watchlist takes a move from the previous close: alerts add --watchlist <name> up 3%, down 3% or moves 2%.`);
|
|
206
256
|
const leadDays = () => {
|
|
207
257
|
const parsed = days === null ? null : parseLeadDays(days);
|
|
208
258
|
if (parsed == null) throw new Error(DAYS_RULE);
|
|
@@ -226,7 +276,7 @@ export function parseAlertAddArgs(
|
|
|
226
276
|
const condition = second.toLowerCase() as AlertCondition;
|
|
227
277
|
if (!CONDITIONS.includes(condition)) {
|
|
228
278
|
// Words with no price after them name a release (CN PMI, Industrial Profits); a price ends a mistyped price alert.
|
|
229
|
-
if (parseAlertPrice(args.at(-1)!).kind === "invalid") return releaseRequest(args, countryFilter, leadDays());
|
|
279
|
+
if (parseAlertPrice(args.at(-1)!).kind === "invalid" && !isPenceLevel(args.at(-1)!)) return releaseRequest(args, countryFilter, leadDays());
|
|
230
280
|
throw new Error(`Unknown alert "${second}". ${ALERT_KINDS_TEXT}`);
|
|
231
281
|
}
|
|
232
282
|
if (country !== undefined) throw new Error(COUNTRY_RULE);
|
|
@@ -240,10 +290,12 @@ export function parseAlertAddArgs(
|
|
|
240
290
|
throw new Error(`${[third, ...rest].join(" ")} could be ${spaced.value} (thousands) or ${typed} and a stray ${rest.join(" ")}; type ${retype(spaced.value)} or ${retype(typed)}`);
|
|
241
291
|
}
|
|
242
292
|
// A price pasted from a sheet (1.350,5, 1,350.5, 1 350,5) reads as it is written; `1,350` could be either, so it asks.
|
|
243
|
-
|
|
293
|
+
// `70p` is pence, a London line's unit, kept in pounds as the line's quote is.
|
|
294
|
+
const { price, pence } = readAlertLevel(third);
|
|
244
295
|
if (rest.length > 0) throw new Error(`A price alert takes one price, not "${rest.join(" ")}" after ${third}; type ${retype(price)}`);
|
|
245
|
-
const thousandsDot = thousandsDotReadings(third);
|
|
246
|
-
return { kind: "price", symbol: first, condition, price,
|
|
296
|
+
const thousandsDot = pence ? null : thousandsDotReadings(third);
|
|
297
|
+
return { kind: "price", symbol: first, condition, price, typed: third.trim(), ...pence ? { pence } : {},
|
|
298
|
+
...(thousandsDot ? { thousandsDot: { ...thousandsDot, text: third.trim() } } : {}) };
|
|
247
299
|
}
|
|
248
300
|
|
|
249
301
|
const OCC_CONTRACT = /^(?:O:)?[A-Z.]{1,6}\d{6}[CP]\d{8}$/i;
|
|
@@ -439,8 +491,11 @@ type AlertListRow = Record<string, unknown> & {
|
|
|
439
491
|
|
|
440
492
|
function priceRow(alert: AlertRule): AlertListRow {
|
|
441
493
|
return {
|
|
442
|
-
...alert, kind: alert.metric?.kind ?? "price", rule: alert.metric ? metricDescription(alert) : undefined,
|
|
443
|
-
|
|
494
|
+
...alert, kind: alert.metric?.kind ?? (alert.move ? "move" : "price"), rule: alert.metric ? metricDescription(alert) : undefined,
|
|
495
|
+
// A move's rule in the words it was added with: `up 3.00%`, `moves 0.50%`.
|
|
496
|
+
...alert.move ? { rule: `${moveRuleWords(alert)} from the previous close`, appOnly: true } : {},
|
|
497
|
+
// The listing as it was kept: 7203:JPX, never 7203:JPX:JPX.
|
|
498
|
+
target: alertListing({ symbol: alert.symbol, exchange: alert.exchange }),
|
|
444
499
|
// The listing it is checked on, in its currency, and its last reading in words with when it is from.
|
|
445
500
|
listing: alertListing(alert), currency: alert.lastQuoteCurrency ?? null,
|
|
446
501
|
lastReading: alertReadingText(alert), lastReadingAt: isoUtc(alertReadingAt(alert)) || null,
|
|
@@ -511,6 +566,11 @@ async function cloudRuleStates(rules: readonly EventAlertRule[], session: string
|
|
|
511
566
|
}
|
|
512
567
|
|
|
513
568
|
/** The Gloom Cloud session the app saved after sign-in, as `fn` and market commands read with; null signed out. */
|
|
569
|
+
/** This device's readings of its move rules, as the app keeps them: never in the synced list. */
|
|
570
|
+
function savedMoveChecks(config: Partial<Pick<ConfigContext, "persistence">>): Record<string, MoveCheck> {
|
|
571
|
+
return readMoveChecks(config.persistence?.pluginState?.get(ALERTS_PLUGIN_ID, resumeStateKey(MOVE_CHECKS_KEY))?.value);
|
|
572
|
+
}
|
|
573
|
+
|
|
514
574
|
function savedSession(config: Partial<Pick<ConfigContext, "persistence">>): string | null {
|
|
515
575
|
const persistence = config.persistence;
|
|
516
576
|
return apiClient.getSessionToken() ?? (persistence?.pluginState ? resolvePersistedCloudSessionToken({ persistence }) : null);
|
|
@@ -536,10 +596,12 @@ function textRow(row: AlertListRow): Record<string, unknown> {
|
|
|
536
596
|
const price = row.kind === "price";
|
|
537
597
|
return {
|
|
538
598
|
id: row.id,
|
|
539
|
-
|
|
599
|
+
// A move says in its row that only the running app hears of it, as ALRT's Measure does.
|
|
600
|
+
kind: price ? "Price" : row.kind === "move" ? measureLabel({ move: true }) : alertKindLabel(row.kind),
|
|
540
601
|
target: row.target,
|
|
602
|
+
// A level at the instrument's precision, in the unit its quote shows: below 1.3375, below 70.00p.
|
|
541
603
|
trigger: row.rule ?? (price
|
|
542
|
-
? `${row.condition} ${row.targetPrice}`
|
|
604
|
+
? `${row.condition} ${alertPriceText(row as unknown as AlertRule, Number(row.targetPrice))}`
|
|
543
605
|
: typeof row.leadDays === "number"
|
|
544
606
|
? scheduledTriggerText({ leadDays: row.leadDays, trigger: row.when === "results" ? "results" : "date", prints: row.onRelease === true })
|
|
545
607
|
: ""),
|
|
@@ -601,7 +663,8 @@ const weekday = new Intl.DateTimeFormat("en-US", { weekday: "short", timeZone: "
|
|
|
601
663
|
function releaseWhen(event: EconEvent): string {
|
|
602
664
|
const day = `on ${weekday.format(event.date)} ${dateKey(event.date)}`;
|
|
603
665
|
if (isAllDayEvent(event)) return `${day}, all day`;
|
|
604
|
-
|
|
666
|
+
// The print time in UTC, and on the reader's clock beside it when they set a zone.
|
|
667
|
+
return event.timeNote ? day : `${day} ${event.date.toISOString().slice(11, 16)} UTC${localTimeSuffix(event.date.getTime())}`;
|
|
605
668
|
}
|
|
606
669
|
|
|
607
670
|
/** The release an alert was added for, as `--json` gives it. */
|
|
@@ -706,10 +769,15 @@ export const alertsCliCommand: CliCommandDef = {
|
|
|
706
769
|
{ flags: "--days <n>", description: `Days before the event the alert goes off, 1 to ${MAX_LEAD_DAYS} (default 1); earnings and calendar event alerts` },
|
|
707
770
|
{ flags: "--country <code>", description: "The country of a calendar event, as econ --country takes it (CN, US, DE); a code before the name does the same (alerts add CN PMI)" },
|
|
708
771
|
{ flags: "--benchmark <symbol>", description: "The listing an RRG alert is measured against; SPY by default, as in RRG" },
|
|
772
|
+
{ flags: "--watchlist <name>", description: `A move alert on each listing of the watchlist, up to ${MAX_BULK_ALERTS} (alerts add --watchlist Book up 3%)` },
|
|
709
773
|
],
|
|
710
774
|
examples: [
|
|
711
775
|
"alerts",
|
|
712
776
|
"alerts add AAPL above 250",
|
|
777
|
+
"alerts add GBPUSD=X moves 0.5%",
|
|
778
|
+
"alerts add HSBA.L BARC.L down 3%",
|
|
779
|
+
"alerts add --watchlist Book up 3%",
|
|
780
|
+
"alerts add VOD.L below 70p",
|
|
713
781
|
"alerts add AAPL pe below 25",
|
|
714
782
|
"alerts add AAPL ps above 8",
|
|
715
783
|
'alerts add NVDA "rsi(14)" under 30',
|
|
@@ -753,19 +821,50 @@ export const alertsCliCommand: CliCommandDef = {
|
|
|
753
821
|
const benchmarkFlag = rawArgs.some((arg) => arg === "--benchmark" || arg.startsWith("--benchmark="));
|
|
754
822
|
const benchmarkValue = takeOption(args, "--benchmark");
|
|
755
823
|
const benchmark = benchmarkFlag && benchmarkValue === undefined ? null : benchmarkValue;
|
|
824
|
+
const watchlistFlag = rawArgs.some((arg) => arg === "--watchlist" || arg.startsWith("--watchlist="));
|
|
825
|
+
const watchlistName = takeOption(args, "--watchlist");
|
|
826
|
+
if (watchlistFlag && !watchlistName?.trim()) ctx.fail("--watchlist takes a watchlist's name: alerts add --watchlist Book up 3%.");
|
|
756
827
|
const action = args[0] ?? "list";
|
|
828
|
+
if (watchlistFlag && action !== "add") ctx.fail("--watchlist is for alerts add: alerts add --watchlist Book up 3%.");
|
|
757
829
|
const now = Date.now();
|
|
758
830
|
const today = newYorkToday(new Date(now));
|
|
759
831
|
const failWith = (error: unknown): never => ctx.fail(error instanceof Error ? error.message : String(error));
|
|
760
832
|
|
|
761
833
|
const parseAdd = (): AlertAddRequest => {
|
|
762
834
|
try {
|
|
763
|
-
return parseAlertAddArgs(args.slice(1), days, exchangeOption, country, benchmark);
|
|
835
|
+
return parseAlertAddArgs(args.slice(1), days, exchangeOption, country, benchmark, watchlistFlag);
|
|
764
836
|
} catch (error) {
|
|
765
837
|
return failWith(error);
|
|
766
838
|
}
|
|
767
839
|
};
|
|
768
840
|
const typedRequest = action === "add" ? parseAdd() : null;
|
|
841
|
+
// A move's listings, each read as `quote` reads it, or a watchlist's as it keeps them, with what was dropped.
|
|
842
|
+
let moves: { listings: MoveListing[]; repeats: number; leftOut: number; watchlist?: string } | null = null;
|
|
843
|
+
if (typedRequest?.kind === "move") {
|
|
844
|
+
const move = typedRequest;
|
|
845
|
+
if (watchlistName && exchangeOption) ctx.fail("--exchange names a symbol's venue; a watchlist's listings keep their own.");
|
|
846
|
+
moves = await withMarketData(ctx, async (opened) => {
|
|
847
|
+
// Signed out, a list's quotes wait for room in the service's allowance rather than being refused.
|
|
848
|
+
const market = { ...opened, dataProvider: await listAddLookups(opened.dataProvider) as typeof opened.dataProvider };
|
|
849
|
+
if (watchlistName) {
|
|
850
|
+
const list = await watchlistListings(market, watchlistName, ctx.fail);
|
|
851
|
+
if (list.listings.length === 0) ctx.fail(`Watchlist "${list.name}" has no listings. Add some with gloom watchlist add ${list.name} <symbols>.`);
|
|
852
|
+
const unique = uniqueInputs(list.listings);
|
|
853
|
+
return { listings: await quoteSavedListings(market, unique.inputs), repeats: 0, leftOut: unique.leftOut, watchlist: list.name };
|
|
854
|
+
}
|
|
855
|
+
const unique = uniqueInputs(move.symbols.map((input) => ({ input })));
|
|
856
|
+
// One symbol, however often it was typed (`ZZZQQQ zzzqqq`), fails the command with why, as a price alert's does;
|
|
857
|
+
// of several, each that fails is named in the summary.
|
|
858
|
+
if (unique.inputs.length === 1) {
|
|
859
|
+
const input = unique.inputs[0]!.input;
|
|
860
|
+
const quoted = await requireQuotedListing(input, exchangeOption, market, ctx, "alerts add");
|
|
861
|
+
const exchange = quoted.listing.exchange || canonicalExchange(quoted.quote.listingExchangeName || quoted.quote.exchangeName);
|
|
862
|
+
return { listings: [{ input, listing: { symbol: quoted.listing.key, ...exchange ? { exchange } : {} }, quote: quoted.quote, notes: quoted.notes }], repeats: unique.repeats, leftOut: 0 };
|
|
863
|
+
}
|
|
864
|
+
const listings = await quoteTypedSymbols(unique.inputs.map((entry) => entry.input), (symbol) => requireQuotedListing(symbol, exchangeOption, market, PROBE, "alerts add"));
|
|
865
|
+
return { listings, repeats: unique.repeats, leftOut: unique.leftOut };
|
|
866
|
+
});
|
|
867
|
+
}
|
|
769
868
|
// XLK/SPY is first a listing written with a slash (BRK/B, EUR/USD); one that quotes nothing is the ratio of the two.
|
|
770
869
|
const pairListing = typedRequest?.kind === "price" && PAIR_SHAPE.test(typedRequest.symbol)
|
|
771
870
|
? await withMarketData(ctx, (market) => requireQuotedListing(typedRequest.symbol, exchangeOption, market, PROBE, "alerts add")).catch((error: unknown) => {
|
|
@@ -848,6 +947,17 @@ export const alertsCliCommand: CliCommandDef = {
|
|
|
848
947
|
if (priced.quote.currency) reading.lastQuoteCurrency = priced.quote.currency;
|
|
849
948
|
priced.listing.exchange = exchange;
|
|
850
949
|
}
|
|
950
|
+
// A London line's level is in the pence its quote shows: `70p`, or 70 where 70 in pounds is far off its price.
|
|
951
|
+
let penceNote: string | null = null;
|
|
952
|
+
if (request?.kind === "price" && priced) {
|
|
953
|
+
try {
|
|
954
|
+
const level = levelInQuoteUnit(request, priced.quote, priced.listing.key);
|
|
955
|
+
request.price = level.price;
|
|
956
|
+
penceNote = level.note;
|
|
957
|
+
} catch (error) {
|
|
958
|
+
failWith(error);
|
|
959
|
+
}
|
|
960
|
+
}
|
|
851
961
|
if (request?.kind === "price" && priced && !isQuoteStaleForCurrentSession(priced.quote)) {
|
|
852
962
|
// The price it is added at is its first reading and the baseline a crossing is measured from, as Add Alert keeps it.
|
|
853
963
|
const price = lastPrice(priced.quote);
|
|
@@ -860,11 +970,11 @@ export const alertsCliCommand: CliCommandDef = {
|
|
|
860
970
|
if (request?.kind === "price" && priced) {
|
|
861
971
|
// A target ten times away is a slip or another instrument's price, such as bitcoin's on the BTC fund.
|
|
862
972
|
// Against the price the alert is checked on, as Add Alert measures it.
|
|
863
|
-
const far = farTargetMessage(priced.listing.key, request.price, priced.quote.price, coinNote);
|
|
973
|
+
const far = farTargetMessage(priced.listing.key, request.price, priced.quote.price, coinNote, isPenceQuotedLine(priced.quote));
|
|
864
974
|
if (far) ctx.fail(far);
|
|
865
975
|
}
|
|
866
976
|
// What a typed listing was read as (7203:TSE as 7203:JPX, MXN as MXN:FWB2), said beside what was added.
|
|
867
|
-
let read = [...priced?.notes ?? [], ...coinNote ? [coinNote] : [], ...benchmarkNotes];
|
|
977
|
+
let read = [...priced?.notes ?? [], ...coinNote ? [coinNote] : [], ...benchmarkNotes, ...penceNote ? [penceNote] : []];
|
|
868
978
|
let newEventRule: EventAlertRule | null = null;
|
|
869
979
|
let newResearchRule: EventAlertRule | null = null;
|
|
870
980
|
if (research) {
|
|
@@ -879,9 +989,18 @@ export const alertsCliCommand: CliCommandDef = {
|
|
|
879
989
|
ctx.fail(error instanceof Error ? error.message : String(error));
|
|
880
990
|
}
|
|
881
991
|
}
|
|
992
|
+
if (formRule?.thirteenFFilerOf && priceListing) {
|
|
993
|
+
// The fund the company files its 13F as: the CIK its SEC filings are listed under.
|
|
994
|
+
const filer = await withMarketData(ctx, (market) => market.dataProvider.getSecFilings?.(priceListing.symbol, 1, priceListing.exchange))
|
|
995
|
+
.then((filings) => filings?.[0] ?? null, (error: unknown) => ctx.fail(`${priceListing.key}'s SEC filer could not be read for its 13F alert: ${error instanceof Error ? error.message : String(error)}`));
|
|
996
|
+
if (!filer?.cik) ctx.fail(`${priceListing.key} has no SEC filer to follow 13F filings for. A 13F alert follows a fund by its CIK: gloom alerts add 13f 1067983.`);
|
|
997
|
+
const cik = filer!.cik.replace(/^0+/, "");
|
|
998
|
+
Object.assign(formRule, { symbol: null, values: { value: cik } });
|
|
999
|
+
read = [...read, `A 13F alert follows ${priceListing.key}'s filer, ${filer!.companyName || "its company"} (CIK ${cik}), as gloom alerts add 13f ${cik} does.`];
|
|
1000
|
+
}
|
|
882
1001
|
if (formRule) {
|
|
883
1002
|
try {
|
|
884
|
-
newResearchRule = createFormRule(formRule, priceListing);
|
|
1003
|
+
newResearchRule = createFormRule(formRule, formRule.thirteenFFilerOf ? null : priceListing);
|
|
885
1004
|
} catch (error) {
|
|
886
1005
|
ctx.fail(error instanceof Error ? error.message : String(error));
|
|
887
1006
|
}
|
|
@@ -912,6 +1031,9 @@ export const alertsCliCommand: CliCommandDef = {
|
|
|
912
1031
|
const target: ScheduledEventTarget = { kind: "release", event: choice.name, country: choice.country, ...(choice.publisher ? { publisher: choice.publisher } : {}) };
|
|
913
1032
|
try {
|
|
914
1033
|
newEventRule = createScheduledAlert(target, request.leadDays, choice.next ? dateKey(choice.next.date) : null);
|
|
1034
|
+
// Its print time, which the Events tab and `fn ALRT` show beside the day.
|
|
1035
|
+
const at = choice.next ? releaseInstant(choice.next) : null;
|
|
1036
|
+
if (at != null) newEventRule.eventTime = new Date(at).toISOString().replace(/\.000Z$/, "Z");
|
|
915
1037
|
} catch (error) {
|
|
916
1038
|
ctx.fail(error instanceof Error ? error.message : String(error));
|
|
917
1039
|
}
|
|
@@ -951,12 +1073,16 @@ export const alertsCliCommand: CliCommandDef = {
|
|
|
951
1073
|
}
|
|
952
1074
|
|
|
953
1075
|
if (action === "list") {
|
|
954
|
-
// An IV level's last reading is this device's, beside the rules.
|
|
955
|
-
const { alerts, alertsError, events, checks, session } = await withConfigData(ctx, (config) =>
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
1076
|
+
// An IV level's last reading is this device's, beside the rules, as are a move rule's and whether it went off this session.
|
|
1077
|
+
const { alerts, alertsError, events, checks, session } = await withConfigData(ctx, (config) => {
|
|
1078
|
+
const stores = readAlertStores(config.config);
|
|
1079
|
+
return {
|
|
1080
|
+
...stores,
|
|
1081
|
+
alerts: withMoveChecks(stores.alerts, savedMoveChecks(config)),
|
|
1082
|
+
checks: readIvLevelChecks(config.persistence?.pluginState?.get(ALERTS_PLUGIN_ID, resumeStateKey(IV_LEVEL_CHECKS_KEY))?.value),
|
|
1083
|
+
session: savedSession(config),
|
|
1084
|
+
};
|
|
1085
|
+
});
|
|
960
1086
|
// Earnings dates come through market data; CPI, FOMC and calendar dates do not need it.
|
|
961
1087
|
const lookup = (targets: ScheduledEventTarget[]) => targets.some((target) => target.kind === "earnings")
|
|
962
1088
|
? withMarketData(ctx, (market) => lookupScheduledDates(targets, scheduledEventSources(market.dataProvider), today, now))
|
|
@@ -990,7 +1116,20 @@ export const alertsCliCommand: CliCommandDef = {
|
|
|
990
1116
|
}
|
|
991
1117
|
|
|
992
1118
|
await withConfigData(ctx, async (config) => {
|
|
993
|
-
const
|
|
1119
|
+
const stores = readAlertStores(config.config);
|
|
1120
|
+
const { pluginState, alertsError, levelErrors, events } = stores;
|
|
1121
|
+
// Move rules as this device reads them; saving writes the rules alone (`writeLevelAlertStores`).
|
|
1122
|
+
const alerts = withMoveChecks(stores.alerts, savedMoveChecks(config));
|
|
1123
|
+
// A move rule's readings are this device's, kept beside its alert log; a dry run keeps nothing.
|
|
1124
|
+
const keepMoveChecks = (update: (checks: Record<string, MoveCheck>) => Record<string, MoveCheck>) => {
|
|
1125
|
+
const state = config.persistence?.pluginState;
|
|
1126
|
+
if (ctx.cliOptions.dryRun || !state) return;
|
|
1127
|
+
try {
|
|
1128
|
+
state.set(ALERTS_PLUGIN_ID, resumeStateKey(MOVE_CHECKS_KEY), update(savedMoveChecks(config)));
|
|
1129
|
+
} catch (error) {
|
|
1130
|
+
logFailure("alerts.cli", "Keep move alert readings failed")(error);
|
|
1131
|
+
}
|
|
1132
|
+
};
|
|
994
1133
|
const save = async (next: { alerts?: AlertRule[]; events?: EventAlertRule[] }) => {
|
|
995
1134
|
if (next.alerts) for (const [key, value] of Object.entries(writeLevelAlertStores(next.alerts))) {
|
|
996
1135
|
if (levelErrors[key] && value !== "[]") ctx.fail(levelErrors[key]!);
|
|
@@ -1015,23 +1154,71 @@ export const alertsCliCommand: CliCommandDef = {
|
|
|
1015
1154
|
return events.rules;
|
|
1016
1155
|
};
|
|
1017
1156
|
// Each rule created, re-armed or deleted here goes in this device's alert log, beside the alerts that fired.
|
|
1018
|
-
const record = (action: AlertLogAction, rule: AlertRule | EventAlertRule) => {
|
|
1157
|
+
const record = (action: AlertLogAction, rule: AlertRule | EventAlertRule | Parameters<typeof alertChangeEntry>[1]) => {
|
|
1019
1158
|
const state = config.persistence?.pluginState;
|
|
1020
1159
|
if (ctx.cliOptions.dryRun || !state) return;
|
|
1021
1160
|
try {
|
|
1022
1161
|
appendAlertLog({
|
|
1023
1162
|
get: (key) => state.get(ALERTS_PLUGIN_ID, resumeStateKey(key))?.value,
|
|
1024
1163
|
set: (key, value) => state.set(ALERTS_PLUGIN_ID, resumeStateKey(key), value),
|
|
1025
|
-
}, [alertChangeEntry(action, alertLogRule(rule), Date.now())]);
|
|
1164
|
+
}, [alertChangeEntry(action, "ruleId" in rule ? rule : alertLogRule(rule), Date.now())]);
|
|
1026
1165
|
} catch (error) {
|
|
1027
1166
|
logFailure("alerts.cli", "Record alert change failed")(error);
|
|
1028
1167
|
}
|
|
1029
1168
|
};
|
|
1030
1169
|
|
|
1170
|
+
if (request?.kind === "move" && moves) {
|
|
1171
|
+
const plan = planMoveAlerts(request, moves.listings, alerts, now);
|
|
1172
|
+
const single = moves.listings.length === 1 && !moves.watchlist;
|
|
1173
|
+
const rule = moveRuleWords({ condition: request.condition, targetPrice: request.percent });
|
|
1174
|
+
if (single && plan.existing[0]) {
|
|
1175
|
+
const existing = plan.existing[0].alert;
|
|
1176
|
+
const rearm = existing.status === "triggered" ? "; it went off this session and arms again in the next" : "";
|
|
1177
|
+
ctx.fail(`${formatAlertDescription(existing)} already exists as alert ${existing.id}${rearm}. Nothing was added.`);
|
|
1178
|
+
}
|
|
1179
|
+
// One symbol that made no alert fails with why, never prints an alert it did not make.
|
|
1180
|
+
if (single && plan.added.length === 0) ctx.fail(plan.failed[0]?.error ?? "No move alert was added.");
|
|
1181
|
+
if (plan.added.length === 0 && !single) {
|
|
1182
|
+
ctx.fail(`No move alert was added: ${[plan.existing.length ? `${plan.existing.length} already set` : "", plan.failed.length ? `${plan.failed.length} not quoted` : ""].filter(Boolean).join(", ")}.`,
|
|
1183
|
+
moveSummaryLines(plan, moves).join("\n") || undefined);
|
|
1184
|
+
}
|
|
1185
|
+
await save({ alerts: [...alerts, ...plan.added] });
|
|
1186
|
+
// The reading each was added on is its first, on this device, until the app's next check.
|
|
1187
|
+
keepMoveChecks((checks) => ({ ...checks, ...moveChecksOf(plan.added) }));
|
|
1188
|
+
// One entry for the add, however many alerts it made: "109 move alerts up 3.00% on Book's listings: 1605:JPX, … and 106 more".
|
|
1189
|
+
if (plan.added.length === 1) record("created", plan.added[0]!);
|
|
1190
|
+
else if (plan.added.length > 1) record("created", bulkMoveLogRule(plan.added, moves.watchlist));
|
|
1191
|
+
const notes = [...request.readAs ? [request.readAs] : [], ...moves.listings.flatMap((entry) => entry.notes ?? [])];
|
|
1192
|
+
if (single) {
|
|
1193
|
+
const alert = plan.added[0]!;
|
|
1194
|
+
const nowText = moveNowText(alert, now);
|
|
1195
|
+
ctx.printResult({ data: { changed: !ctx.cliOptions.dryRun, dryRun: ctx.cliOptions.dryRun, alert }, ...(notes.length ? { warnings: notes } : {}) }, {
|
|
1196
|
+
text: (data) => `Added alert ${data.alert.id}: ${formatAlertDescription(data.alert)} (${MOVE_REARM}).${nowText ? ` ${capitalize(nowText)}.` : ""}${dryRunNote(data.dryRun)}\n${MOVE_DELIVERY}`,
|
|
1197
|
+
});
|
|
1198
|
+
return;
|
|
1199
|
+
}
|
|
1200
|
+
const source = moves.watchlist ? `on ${moves.watchlist}'s listings` : "";
|
|
1201
|
+
ctx.printResult({
|
|
1202
|
+
data: { changed: !ctx.cliOptions.dryRun, dryRun: ctx.cliOptions.dryRun, added: plan.added,
|
|
1203
|
+
existing: plan.existing.map((entry) => ({ input: entry.input, id: entry.alert.id })), failed: plan.failed,
|
|
1204
|
+
repeats: moves.repeats, leftOut: moves.leftOut },
|
|
1205
|
+
...(notes.length ? { warnings: notes } : {}),
|
|
1206
|
+
}, {
|
|
1207
|
+
text: (data) => [
|
|
1208
|
+
`Added ${data.added.length} move ${data.added.length === 1 ? "alert" : "alerts"}${source ? ` ${source}` : ""}: ${rule} from the previous close (${MOVE_REARM}).${dryRunNote(data.dryRun)}`,
|
|
1209
|
+
...data.added.length ? [` ${MOVE_DELIVERY}`] : [],
|
|
1210
|
+
...data.added.length ? [` By venue: ${venueCounts(data.added)}.`] : [],
|
|
1211
|
+
...moveSummaryLines(plan, moves),
|
|
1212
|
+
].join("\n"),
|
|
1213
|
+
});
|
|
1214
|
+
return;
|
|
1215
|
+
}
|
|
1031
1216
|
if (request?.kind === "price" || request?.kind === "metric") {
|
|
1032
|
-
const { condition
|
|
1217
|
+
const { condition } = request;
|
|
1033
1218
|
const symbol = requireArg(priceListing?.key, ADD_USAGE, ctx);
|
|
1034
|
-
const alert: AlertRule = { ...createAlert(symbol, condition, price, priceListing?.exchange), ...(request.kind === "metric" ? { metric: request.metric } : {}),
|
|
1219
|
+
const alert: AlertRule = { ...createAlert(symbol, condition, request.price, priceListing?.exchange), ...(request.kind === "metric" ? { metric: request.metric } : {}),
|
|
1220
|
+
// A London line's level is shown in pence from the first, before any check has read its quote.
|
|
1221
|
+
...request.kind === "price" && priced && isPenceQuotedLine(priced.quote) ? { lastQuotePence: true } : {}, ...reading };
|
|
1035
1222
|
// The same rule on the same listing is one alert: a second add names it and adds nothing.
|
|
1036
1223
|
const existing = alerts.find((entry) => sameLevelRule(entry, alert));
|
|
1037
1224
|
if (existing) {
|
|
@@ -1052,7 +1239,9 @@ export const alertsCliCommand: CliCommandDef = {
|
|
|
1052
1239
|
...firstCheck ? { firstCheck: { close: firstCheck.day, at: isoUtc(firstCheck.at) } } : {},
|
|
1053
1240
|
...unread ? { unread } : {} }, ...(read.length > 0 ? { warnings: read } : {}) }, {
|
|
1054
1241
|
// The delivery, as docs/usage.md states it, before any full stop, which after the price would read as part of it (below 81.).
|
|
1055
|
-
|
|
1242
|
+
// The listing with its venue, the level at its precision and in its unit: `VOD:LSE below 70.00p`, `GBPUSD=X below 1.33750`.
|
|
1243
|
+
text: (data) => `Added alert ${data.alert.id}: ${data.alert.metric ? metricDescription(data.alert)
|
|
1244
|
+
: `${alertListing(data.alert)} ${condition} ${alertPriceText(data.alert, data.alert.targetPrice)}`} (${PRICE_DELIVERY}).${notes ? ` ${notes}` : ""}${dryRunNote(data.dryRun)}`,
|
|
1056
1245
|
});
|
|
1057
1246
|
return;
|
|
1058
1247
|
}
|
|
@@ -1135,7 +1324,9 @@ export const alertsCliCommand: CliCommandDef = {
|
|
|
1135
1324
|
if (!level && !rule && alertsError) ctx.fail(alertsError);
|
|
1136
1325
|
// An alert still waiting to go off has nothing to re-arm, and is left as it is.
|
|
1137
1326
|
const active = level ? level.status === "active" : rule ? eventRuleArmed(rule, now) : false;
|
|
1138
|
-
|
|
1327
|
+
// A move rule that went off this session is armed again on this device, where it went off: its reading goes, the rule stays.
|
|
1328
|
+
if (level?.move && !active) keepMoveChecks((checks) => Object.fromEntries(Object.entries(checks).filter(([key]) => key !== id)));
|
|
1329
|
+
else if (level && !active) await save({ alerts: alerts.map((alert) => alert.id === id ? rearmAlert(alert) : alert) });
|
|
1139
1330
|
if (rule && !active) {
|
|
1140
1331
|
// A scheduled alert alerts again for its coming event; any other event alert resumes.
|
|
1141
1332
|
const next = readScheduledRule(rule) ? rearmScheduledAlert(rule)
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { metricFormInput, metricShortcut, parseMetricAlert } from "./metric-command";
|
|
2
2
|
import { isRelativeMetric, type AlertMetric } from "./metric-model";
|
|
3
3
|
import type { AlertCondition } from "./types";
|
|
4
|
-
import { readAlertPrice } from "./price";
|
|
4
|
+
import { isPenceLevel, readAlertLevel, readAlertPrice } from "./price";
|
|
5
5
|
import { normalizeAlertSymbol } from "./quotes";
|
|
6
|
+
import { moveCondition, parseMovePercent } from "./move";
|
|
6
7
|
|
|
7
8
|
export interface AlertCommandInput {
|
|
8
9
|
symbol: string;
|
|
9
10
|
condition: AlertCondition;
|
|
10
11
|
price: number;
|
|
12
|
+
/** Typed in pence (`70p`): `price` is in pounds, for a London line quoted in pence. */
|
|
13
|
+
pence?: true;
|
|
11
14
|
metric?: AlertMetric;
|
|
12
15
|
}
|
|
13
16
|
|
|
@@ -54,6 +57,10 @@ export function parseAlertShortcutValues(
|
|
|
54
57
|
|
|
55
58
|
if (parts[1]) {
|
|
56
59
|
const condition = parseAlertCondition(parts[1]);
|
|
60
|
+
// A move from the previous close is added where its delivery can be said: `alerts add`.
|
|
61
|
+
if (!condition && moveCondition(parts[1])) {
|
|
62
|
+
throw new Error(`Add a move alert with gloom alerts add ${values.symbol} ${parts[1].toLowerCase()} ${parts[2] ?? "0.5%"}.`);
|
|
63
|
+
}
|
|
57
64
|
if (!condition) {
|
|
58
65
|
throw new Error("Use above, below, crosses, >, <, or x.");
|
|
59
66
|
}
|
|
@@ -61,7 +68,8 @@ export function parseAlertShortcutValues(
|
|
|
61
68
|
}
|
|
62
69
|
|
|
63
70
|
// The price reads as `alerts add` reads it: 81k is 81000, 81,000 asks which was meant, and text that is no number says what to type.
|
|
64
|
-
|
|
71
|
+
// `70p`, pence on a London line, stays as typed for the add to hold to its line.
|
|
72
|
+
if (parts[2]) values.price = isPenceLevel(parts[2]) ? (readAlertLevel(parts[2]), parts[2].trim()) : String(readAlertPrice(parts[2].replace(/^\$/, "")));
|
|
65
73
|
|
|
66
74
|
return values;
|
|
67
75
|
}
|
|
@@ -84,17 +92,36 @@ export function parseAlertCommandValues(
|
|
|
84
92
|
const condition = parseAlertCondition(values?.condition);
|
|
85
93
|
const priceStr = values?.price?.trim();
|
|
86
94
|
if (!symbol || !condition || !priceStr) return null;
|
|
87
|
-
return { symbol, condition,
|
|
95
|
+
return { symbol, condition, ...readAlertLevel(priceStr.replace(/^\$/, "")) };
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** A move rule's edit read: `GBPUSD=X moves 0.5%`, `HSBA:LSE down 3`, as `alerts add` takes it. Null for another form. */
|
|
99
|
+
function parseMoveEdit(value: string): (AlertCommandInput & { move: true }) | null {
|
|
100
|
+
const parts = value.trim().split(/\s+/).filter(Boolean);
|
|
101
|
+
const condition = parts.length === 3 ? moveCondition(parts[1]) : null;
|
|
102
|
+
if (!condition) return null;
|
|
103
|
+
const percent = parseMovePercent(parts[2]);
|
|
104
|
+
if (percent == null) throw new Error(`A move is a percent from the previous close, above 0 and up to 100, not "${parts[2]}".`);
|
|
105
|
+
return { symbol: normalizeAlertSymbol(parts[0]), condition, price: percent, move: true };
|
|
88
106
|
}
|
|
89
107
|
|
|
90
108
|
/**
|
|
91
109
|
* The edit dialog's text read against the alert it changes. An edit keeps the alert in its kind and its synced list:
|
|
92
|
-
* price stays price, a valuation or technical measure stays one, and a ratio or RRG alert keeps its listings.
|
|
110
|
+
* price stays price, a move stays a move, a valuation or technical measure stays one, and a ratio or RRG alert keeps its listings.
|
|
93
111
|
*/
|
|
94
112
|
export function parseAlertEdit(
|
|
95
|
-
selected: { symbol: string; metric?: AlertMetric },
|
|
113
|
+
selected: { symbol: string; metric?: AlertMetric; move?: boolean },
|
|
96
114
|
value: string,
|
|
97
|
-
): AlertCommandInput {
|
|
115
|
+
): AlertCommandInput & { move?: true } {
|
|
116
|
+
const move = selected.metric ? null : parseMoveEdit(value);
|
|
117
|
+
// A move and a price level are kept in different lists, so one never becomes the other: the other kind is a new alert.
|
|
118
|
+
if (move && !selected.move) throw new Error(`A move is its own alert: gloom alerts add ${move.symbol} ${value.trim().split(/\s+/).slice(1).join(" ")}.`);
|
|
119
|
+
if (move) return move;
|
|
120
|
+
if (selected.move) {
|
|
121
|
+
const level = parseAlertCommandValues({ shortcut: value });
|
|
122
|
+
if (level && !level.metric) throw new Error(`A price level is its own alert: gloom alerts add ${level.symbol} ${value.trim().split(/\s+/).slice(1).join(" ")}.`);
|
|
123
|
+
throw new Error("Use SYMBOL moves|up|down PERCENT, such as GBPUSD=X moves 0.5%.");
|
|
124
|
+
}
|
|
98
125
|
const parsed = parseAlertCommandValues({ shortcut: value });
|
|
99
126
|
if (!parsed) throw new Error("Use SYMBOL above|below|crosses PRICE.");
|
|
100
127
|
if (!!parsed.metric !== !!selected.metric) throw new Error("Add a new alert to change between price and a valuation or technical measure.");
|
|
@@ -1,11 +1,25 @@
|
|
|
1
|
-
import { eventAlertTarget, type EventAlertRule } from "./events";
|
|
1
|
+
import { eventAlertTarget, releaseTimeOn, type EventAlertRule } from "./events";
|
|
2
|
+
import { timeZoneCity, zonedClock } from "../../../utils/utc-time";
|
|
2
3
|
import { readScheduledRule, scheduledAlertStatus, scheduledToday } from "./scheduled";
|
|
3
4
|
|
|
4
|
-
/**
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Earnings, macro and calendar event rules name the event day they wait for,
|
|
7
|
+
* a release with its print time in UTC and on the reader's clock when they
|
|
8
|
+
* set a zone (`2026-11-06 13:30 UTC, 08:30 New York`); the rest name what they follow.
|
|
9
|
+
*/
|
|
10
|
+
export function ruleTarget(rule: EventAlertRule, zone: string | null = null): string {
|
|
6
11
|
const target = eventAlertTarget(rule);
|
|
7
12
|
if (!readScheduledRule(rule)) return target;
|
|
8
|
-
return `${target} · ${rule.eventDate
|
|
13
|
+
return `${target} · ${rule.eventDate ? eventWhen(rule, zone) : "date not known yet"}`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** `2026-11-06 13:30 UTC, 08:30 New York`, or the day alone without a print time. */
|
|
17
|
+
export function eventWhen(rule: Pick<EventAlertRule, "eventDate" | "eventTime">, zone: string | null = null): string {
|
|
18
|
+
if (!rule.eventDate) return "";
|
|
19
|
+
if (!releaseTimeOn(rule.eventTime, rule.eventDate)) return rule.eventDate;
|
|
20
|
+
const at = Date.parse(rule.eventTime);
|
|
21
|
+
const local = zone ? zonedClock(at, zone) : null;
|
|
22
|
+
return `${rule.eventDate} ${rule.eventTime.slice(11, 16)} UTC${local ? `, ${local.label} ${timeZoneCity(zone!)}` : ""}`;
|
|
9
23
|
}
|
|
10
24
|
|
|
11
25
|
/**
|
|
@@ -30,7 +30,8 @@ import { ruleState, ruleTarget } from "./event-rows";
|
|
|
30
30
|
import { relativeTime } from "./format";
|
|
31
31
|
import { alertKindLabel, fetchAlertHistory, ruleStateText } from "./history";
|
|
32
32
|
import { isResearchAlertKind } from "./research-rules";
|
|
33
|
-
import { useAsyncResource } from "../../../public/react";
|
|
33
|
+
import { useAppConfig, useAsyncResource } from "../../../public/react";
|
|
34
|
+
import { readerTimeZone } from "../../../utils/utc-time";
|
|
34
35
|
import { usePlanAccess } from "../../../api-client/plan-access";
|
|
35
36
|
import { apiClient } from "../../../api-client";
|
|
36
37
|
import { useResearchCloudSession } from "../shared/research-cloud-session";
|
|
@@ -53,6 +54,8 @@ const columnsFor = (width: number, lastCheck: boolean, needsSignIn: boolean): Da
|
|
|
53
54
|
];
|
|
54
55
|
|
|
55
56
|
export function EventAlertsPane({ focused, width, height }: PaneProps) {
|
|
57
|
+
// A release's print time is on the reader's clock too, as ECO shows it.
|
|
58
|
+
const readerZone = readerTimeZone(useAppConfig().timezone);
|
|
56
59
|
const [catalystStatus] = usePluginConfigState<string>(CATALYST_POLL_STATUS, "Catalyst alerts check every five minutes while the app is open");
|
|
57
60
|
const [json, setJson] = usePluginConfigState<string>(EVENT_ALERTS_KEY, "[]");
|
|
58
61
|
// IV levels, calendar events and IPOs are kept in their own lists, which released versions never read.
|
|
@@ -185,6 +188,7 @@ export function EventAlertsPane({ focused, width, height }: PaneProps) {
|
|
|
185
188
|
id: "toggle",
|
|
186
189
|
key: "p",
|
|
187
190
|
label: selectedRule?.status === "paused" ? "resume" : "ause",
|
|
191
|
+
title: selectedRule?.status === "paused" ? "Resume" : "Pause",
|
|
188
192
|
onPress: () => toggle(selectedRule),
|
|
189
193
|
disabled: !selectedRule,
|
|
190
194
|
},
|
|
@@ -237,7 +241,7 @@ export function EventAlertsPane({ focused, width, height }: PaneProps) {
|
|
|
237
241
|
? ruleStateText(states.get(rule.id))
|
|
238
242
|
: ""
|
|
239
243
|
: column.id === "target"
|
|
240
|
-
? ruleTarget(rule)
|
|
244
|
+
? ruleTarget(rule, readerZone)
|
|
241
245
|
: column.id === "status"
|
|
242
246
|
? unread ? "No data" : state
|
|
243
247
|
: new Date(rule.createdAt).toISOString().slice(0, 10),
|