@gloom-sh/terminal 0.20.16 → 0.20.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -1
- package/src/account/auth-dialog.tsx +19 -1
- package/src/account/billing.ts +2 -1
- package/src/account/heard-from-question.tsx +235 -0
- package/src/account/heard-from.ts +97 -0
- package/src/api-client/data.ts +16 -5
- package/src/api-client/heard-from.ts +72 -0
- package/src/api-client/index.ts +63 -6
- package/src/api-client/mna.ts +18 -0
- package/src/api-client/supply-chain.ts +9 -0
- package/src/api-client/types/billing.ts +35 -1
- package/src/api-client/types/econ.ts +3 -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 +33 -2
- package/src/architecture/core-builtin-allowlist.json +1 -1
- package/src/architecture/floating-promise-allowlist.json +0 -1
- package/src/architecture/shortcut-labels-allowlist.json +1 -0
- package/src/cli/alert-listing.ts +98 -0
- package/src/cli/commands/fred-series.ts +3 -1
- package/src/cli/commands/market.ts +138 -22
- package/src/cli/commands/overview.ts +72 -14
- package/src/cli/commands/plugins.ts +3 -2
- package/src/cli/commands/search.ts +30 -6
- package/src/cli/context.ts +16 -5
- package/src/cli/csv-export.ts +74 -0
- package/src/cli/desktop-pane-shot.ts +75 -11
- package/src/cli/glossary.ts +64 -10
- package/src/cli/help.ts +4 -2
- package/src/cli/history-demergers.ts +117 -0
- package/src/cli/history-rows.ts +6 -2
- package/src/cli/index.ts +1 -0
- package/src/cli/known-gaps.ts +16 -0
- package/src/cli/known-us-stocks.ts +18 -0
- package/src/cli/listing-arg.ts +105 -15
- package/src/cli/pane-functions/catalog-snapshot-build.ts +83 -0
- package/src/cli/pane-functions/catalog-snapshot.json +866 -0
- package/src/cli/pane-functions/catalog-snapshot.ts +62 -0
- package/src/cli/pane-functions/catalog.ts +50 -16
- package/src/cli/pane-functions/data.ts +16 -4
- package/src/cli/pane-functions/dom.ts +24 -6
- package/src/cli/pane-functions/freshness.ts +17 -1
- package/src/cli/pane-functions/headless.ts +7 -2
- package/src/cli/pane-functions/index.ts +102 -44
- package/src/cli/pane-functions/resolver.ts +8 -5
- package/src/cli/pane-functions/screenshot-assessment.ts +30 -7
- package/src/cli/pane-functions/screenshot-bridge.ts +4 -2
- package/src/cli/pane-functions/screenshot-payload.ts +21 -0
- package/src/cli/pane-functions/screenshot-render.ts +3 -1
- package/src/cli/quote-answer.ts +32 -16
- package/src/cli/registry.ts +22 -2
- package/src/cli/report-tables.ts +17 -3
- package/src/cli/result.ts +8 -10
- package/src/cli/series-search.ts +45 -6
- package/src/cli/shot-temp-dir.ts +4 -9
- package/src/components/chart/composite/legend.tsx +80 -25
- package/src/components/chart/composite/panel-surface/panel-cursor.tsx +3 -3
- package/src/components/chart/composite/price-axis-labels.tsx +7 -5
- package/src/components/chart-table/header.tsx +9 -0
- package/src/components/chart-table/layout.ts +11 -11
- package/src/components/command-bar/pane-templates/items.ts +17 -1
- package/src/components/command-bar/routes/root/provider-search.ts +10 -1
- package/src/components/command-bar/routes/root/results.ts +34 -2
- package/src/components/command-bar/routes/root/runtime.ts +8 -1
- package/src/components/command-bar/routes/ticker-search/route.ts +5 -0
- package/src/components/command-bar/workflow/alert.ts +19 -8
- package/src/components/data-table/view.tsx +15 -2
- package/src/components/form-modal/content.tsx +9 -4
- package/src/components/index.ts +1 -1
- package/src/components/layout/header.tsx +9 -5
- package/src/components/layout/pane/capture-status.ts +6 -0
- package/src/components/layout/pane/footer/index.tsx +2 -0
- package/src/components/layout/pane/footer/model.ts +113 -15
- package/src/components/layout/pane/header.tsx +16 -2
- package/src/components/market-board/index.tsx +4 -2
- package/src/components/onboarding/onboarding-frame.tsx +6 -2
- package/src/components/onboarding/onboarding-keyboard.ts +7 -1
- package/src/components/onboarding/onboarding-wizard.tsx +3 -1
- package/src/components/onboarding/portfolio-step/positions-panel.tsx +24 -15
- package/src/components/onboarding/setup-cards.ts +36 -0
- package/src/components/onboarding/use-onboarding-progress.ts +22 -1
- package/src/components/onboarding/wizard-account.ts +6 -1
- package/src/components/onboarding/wizard-model.ts +32 -6
- package/src/components/onboarding/wizard-positions.ts +1 -1
- package/src/components/sign-in-gate.tsx +3 -1
- package/src/components/toggle-list.tsx +6 -8
- package/src/components/ui/confirm-dialog.tsx +47 -7
- package/src/components/ui/data-table/display-columns.ts +4 -1
- package/src/components/ui/data-table/hooks.ts +2 -3
- package/src/components/ui/data-table/index.tsx +4 -1
- package/src/components/ui/data-table/types.ts +19 -4
- package/src/components/ui/data-table/visible-range.ts +11 -1
- package/src/components/ui/display.tsx +17 -2
- package/src/components/ui/index.ts +1 -1
- package/src/components/ui/stat-grid.tsx +4 -0
- package/src/components/ui/status.tsx +13 -1
- package/src/components/ui/table-layout.ts +2 -1
- package/src/components/use-pane-notice-footer.tsx +16 -3
- package/src/data/config/store/index.ts +31 -0
- package/src/data/config/store/node.ts +61 -11
- package/src/data/config/store/normalize.ts +4 -6
- package/src/data/config/store/shared-file.ts +309 -0
- package/src/data/profile-merge.ts +299 -0
- package/src/data/sqlite/checkpointer.ts +11 -1
- package/src/data/sqlite/database.ts +1 -1
- package/src/data/ticker-repository.ts +134 -10
- package/src/data/ticker-store.ts +67 -0
- package/src/data/ticker-writes.ts +5 -0
- package/src/i18n/es.ts +27 -0
- package/src/i18n/ja.ts +27 -0
- package/src/i18n/ko.ts +27 -0
- package/src/i18n/zh-cn.ts +27 -0
- package/src/i18n/zh-tw.ts +27 -0
- package/src/layout-marketplace/gallery-desktop.tsx +2 -2
- package/src/market-data/ah-pair.ts +103 -0
- package/src/market-data/depositary-pair.ts +6 -2
- package/src/market-data/hooks.tsx +33 -2
- package/src/market-data/market/change-basis.ts +2 -1
- package/src/market-data/market/header-market.ts +11 -0
- package/src/market-data/split-terms.ts +28 -0
- package/src/plugins/builtin/account-management/footer.ts +1 -1
- package/src/plugins/builtin/account-management/keyboard.ts +4 -0
- package/src/plugins/builtin/account-management/model.ts +1 -0
- package/src/plugins/builtin/account-management/pane.tsx +75 -7
- package/src/plugins/builtin/account-management/payment-recovery-row.tsx +12 -5
- package/src/plugins/builtin/account-management/pro-cancel.tsx +197 -0
- package/src/plugins/builtin/account-management/trial-cancel.ts +1 -1
- package/src/plugins/builtin/alerts/cli-move.ts +2 -2
- package/src/plugins/builtin/alerts/cli.ts +36 -30
- package/src/plugins/builtin/alerts/constants.ts +10 -0
- package/src/plugins/builtin/alerts/earnings-listing.ts +20 -0
- package/src/plugins/builtin/alerts/format.ts +24 -8
- package/src/plugins/builtin/alerts/index.tsx +38 -9
- package/src/plugins/builtin/alerts/move-checks.ts +7 -0
- package/src/plugins/builtin/alerts/pane.tsx +1 -1
- package/src/plugins/builtin/alerts/quotes.ts +26 -2
- package/src/plugins/builtin/alerts/scheduled.ts +6 -1
- package/src/plugins/builtin/alerts/types.ts +7 -0
- package/src/plugins/builtin/analytics/manual-value.ts +61 -0
- package/src/plugins/builtin/analytics/risk-book.ts +7 -7
- package/src/plugins/builtin/analytics/risk-client.ts +26 -13
- package/src/plugins/builtin/analytics/risk-headless.ts +13 -8
- package/src/plugins/builtin/analytics/risk-model.ts +92 -4
- package/src/plugins/builtin/analytics/risk-pane.tsx +85 -38
- package/src/plugins/builtin/awards/pane.tsx +7 -3
- package/src/plugins/builtin/broker-trading/orders.tsx +2 -2
- package/src/plugins/builtin/central-bank-rates/model.ts +8 -2
- package/src/plugins/builtin/central-bank-rates/pane.tsx +5 -3
- package/src/plugins/builtin/chart-composer/cli-options.ts +4 -2
- package/src/plugins/builtin/chart-composer/data-catalog-pane.tsx +2 -6
- package/src/plugins/builtin/chart-composer/pane.tsx +9 -3
- package/src/plugins/builtin/cloud/auth-actions.tsx +11 -6
- package/src/plugins/builtin/cloud/company-picker.tsx +5 -3
- package/src/plugins/builtin/cloud/upgrade-command.ts +1 -1
- package/src/plugins/builtin/company-kpis/headless.ts +9 -4
- package/src/plugins/builtin/company-kpis/latest.ts +45 -0
- package/src/plugins/builtin/company-kpis/model.ts +38 -8
- package/src/plugins/builtin/company-kpis/pane.tsx +22 -8
- package/src/plugins/builtin/composite/alt-data.ts +20 -0
- package/src/plugins/builtin/composite/application.ts +14 -0
- package/src/plugins/builtin/composite/broker.ts +12 -0
- package/src/plugins/builtin/composite/credit.ts +33 -0
- package/src/plugins/builtin/composite/crypto.ts +10 -0
- package/src/plugins/builtin/composite/earnings.ts +12 -0
- package/src/plugins/builtin/composite/filings.ts +13 -0
- package/src/plugins/builtin/composite/futures-commodities.ts +23 -0
- package/src/plugins/builtin/composite/global-markets.ts +12 -0
- package/src/plugins/builtin/composite/options-volatility.ts +23 -0
- package/src/plugins/builtin/composite/ownership.ts +23 -0
- package/src/plugins/builtin/composite/portfolio.ts +10 -0
- package/src/plugins/builtin/composite/quant.ts +15 -0
- package/src/plugins/builtin/composite/rates-macro.ts +30 -0
- package/src/plugins/builtin/composite/screeners.ts +11 -0
- package/src/plugins/builtin/composite/shared.ts +11 -0
- package/src/plugins/builtin/composite/ticker-core.ts +36 -0
- package/src/plugins/builtin/congress-trades/headless.ts +31 -3
- package/src/plugins/builtin/correlation/index.tsx +13 -17
- package/src/plugins/builtin/correlation/matrix/model.ts +18 -0
- package/src/plugins/builtin/credit-conditions/series.ts +2 -2
- package/src/plugins/builtin/dividend-yield/client.ts +57 -16
- package/src/plugins/builtin/dividend-yield/headless.ts +17 -11
- package/src/plugins/builtin/dividend-yield/model.ts +4 -3
- package/src/plugins/builtin/dividend-yield/pane.tsx +22 -18
- package/src/plugins/builtin/dividend-yield/ranking.ts +1 -1
- package/src/plugins/builtin/dividend-yield/types.ts +4 -0
- package/src/plugins/builtin/dividend-yield/view.ts +23 -12
- package/src/plugins/builtin/earnings/board-model.ts +12 -0
- package/src/plugins/builtin/earnings/board-table.ts +7 -4
- package/src/plugins/builtin/earnings/board.tsx +2 -2
- package/src/plugins/builtin/earnings/fiscal-quarter.ts +39 -0
- package/src/plugins/builtin/earnings/headless.ts +7 -4
- package/src/plugins/builtin/earnings/highlight.ts +1 -1
- package/src/plugins/builtin/earnings/history-model.ts +6 -4
- package/src/plugins/builtin/earnings/history-table.ts +4 -3
- package/src/plugins/builtin/earnings-calls/pane.tsx +8 -2
- package/src/plugins/builtin/econ/calendar-model.ts +18 -0
- package/src/plugins/builtin/econ/fred-catalog.ts +1 -256
- package/src/plugins/builtin/econ/index.tsx +3 -0
- package/src/plugins/builtin/econ-statistics/cache.ts +1 -1
- package/src/plugins/builtin/econ-statistics/client.ts +11 -10
- package/src/plugins/builtin/econ-statistics/detail.tsx +1 -0
- package/src/plugins/builtin/econ-statistics/headless.ts +42 -6
- package/src/plugins/builtin/econ-statistics/index.tsx +1 -0
- package/src/plugins/builtin/econ-statistics/pane.tsx +7 -2
- package/src/plugins/builtin/econ-statistics/stats.ts +2 -1
- package/src/plugins/builtin/econ-statistics/view.ts +9 -3
- package/src/plugins/builtin/equity-screener/headless.ts +4 -1
- package/src/plugins/builtin/equity-screener/model.ts +7 -6
- package/src/plugins/builtin/estimate-revisions/headless.ts +1 -1
- package/src/plugins/builtin/exposure/model.ts +10 -0
- package/src/plugins/builtin/exposure/pane.tsx +10 -3
- package/src/plugins/builtin/fx-matrix/amount.ts +15 -1
- package/src/plugins/builtin/fx-matrix/headless.ts +12 -6
- package/src/plugins/builtin/fx-matrix/index.tsx +23 -5
- package/src/plugins/builtin/fx-matrix/settings.ts +9 -4
- package/src/plugins/builtin/kelly-sizer/pane.tsx +9 -4
- package/src/plugins/builtin/market-valuation/pane.tsx +22 -10
- package/src/plugins/builtin/mna/detail.tsx +67 -6
- package/src/plugins/builtin/mna/headless.ts +128 -13
- package/src/plugins/builtin/mna/model.ts +219 -16
- package/src/plugins/builtin/mna/pane.tsx +34 -6
- package/src/plugins/builtin/money-markets/model.ts +14 -5
- package/src/plugins/builtin/money-markets/pane.tsx +4 -3
- package/src/plugins/builtin/news/wire/news/footer.ts +3 -8
- package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +22 -6
- package/src/plugins/builtin/options-scenario/csp-screen.ts +39 -12
- package/src/plugins/builtin/options-scenario/strategy-screen.ts +7 -5
- package/src/plugins/builtin/pe-band/client.ts +13 -1
- package/src/plugins/builtin/pe-band/headless.ts +2 -2
- package/src/plugins/builtin/pe-band/model.ts +63 -10
- package/src/plugins/builtin/pe-band/pane.tsx +5 -5
- package/src/plugins/builtin/portfolio-list/allocation-rows.ts +26 -7
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +66 -13
- package/src/plugins/builtin/portfolio-list/cli/render.ts +76 -33
- package/src/plugins/builtin/portfolio-list/headless.ts +69 -22
- package/src/plugins/builtin/portfolio-list/pane/data.ts +3 -3
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +29 -14
- package/src/plugins/builtin/portfolio-list/summary/index.tsx +2 -2
- package/src/plugins/builtin/relative-rotation/pane.tsx +2 -3
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +5 -1
- package/src/plugins/builtin/research/event-model.ts +31 -13
- package/src/plugins/builtin/research/headless.ts +8 -1
- package/src/plugins/builtin/research/relative-valuation-pane.tsx +19 -17
- package/src/plugins/builtin/sectors/index.tsx +6 -9
- package/src/plugins/builtin/shared/cloud-upgrade.ts +1 -1
- package/src/plugins/builtin/shared/earnings-report.ts +19 -4
- package/src/plugins/builtin/shared/fred-catalog.ts +256 -0
- package/src/plugins/builtin/shared/report-freshness.ts +2 -3
- package/src/plugins/builtin/shared/series-cache.ts +3 -0
- package/src/plugins/builtin/shared/series-detail-chart.tsx +3 -0
- package/src/plugins/builtin/short-interest/watch-pane.tsx +7 -7
- package/src/plugins/builtin/supply-chain/client.ts +34 -9
- package/src/plugins/builtin/supply-chain/evidence.ts +3 -2
- package/src/plugins/builtin/supply-chain/flow.tsx +4 -3
- package/src/plugins/builtin/supply-chain/graph-model.ts +14 -7
- package/src/plugins/builtin/supply-chain/graph-pane.tsx +3 -1
- package/src/plugins/builtin/supply-chain/graph.tsx +6 -3
- package/src/plugins/builtin/supply-chain/headless.ts +19 -4
- package/src/plugins/builtin/supply-chain/model.ts +50 -6
- package/src/plugins/builtin/supply-chain/pane.tsx +76 -16
- package/src/plugins/builtin/ticker-detail/adr-pair/ah.ts +62 -0
- package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +119 -20
- package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +67 -1
- package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +31 -16
- package/src/plugins/builtin/ticker-detail/overview/model.ts +17 -1
- package/src/plugins/builtin/ticker-detail/overview/pane.tsx +4 -0
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +9 -2
- package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +9 -2
- package/src/plugins/builtin/ticker-detail/quote-monitor/index.tsx +5 -2
- package/src/plugins/builtin/time-sales/headless.ts +4 -1
- package/src/plugins/builtin/time-sales/pane.tsx +2 -0
- package/src/plugins/builtin/time-sales/window.ts +12 -0
- package/src/plugins/builtin/treasury-auctions/client.ts +4 -0
- package/src/plugins/builtin/treasury-auctions/treasury-direct.ts +2 -0
- package/src/plugins/builtin/treasury-daily/client.ts +23 -11
- package/src/plugins/builtin/volatility/model.ts +17 -0
- package/src/plugins/builtin/volatility/pane.tsx +13 -4
- package/src/plugins/builtin/world-indices/index.tsx +2 -0
- package/src/plugins/builtin/world-indices/table.tsx +15 -0
- package/src/plugins/builtin/world-venue-map/evidence.ts +3 -2
- package/src/plugins/builtin/world-venue-map/headless.ts +28 -16
- package/src/plugins/builtin/world-venue-map/index.ts +19 -6
- package/src/plugins/builtin/world-venue-map/layered-pane.tsx +9 -5
- package/src/plugins/builtin/world-venue-map/layers.ts +33 -11
- package/src/plugins/builtin/world-venue-map/map.tsx +12 -0
- package/src/plugins/builtin/world-venue-map/pane.tsx +35 -6
- package/src/plugins/builtin/world-venue-map/place.ts +119 -0
- package/src/plugins/catalog-data.ts +20 -0
- package/src/plugins/catalog-lazy.ts +51 -0
- package/src/plugins/catalog-ui.ts +16 -18
- package/src/plugins/host-smoke.ts +5 -2
- package/src/portfolio/allocation.ts +79 -19
- package/src/portfolio/cash-balances.ts +76 -0
- package/src/portfolio/mutations.ts +43 -8
- package/src/public/__snapshots__/public-api.test.ts.snap +1 -0
- package/src/renderers/desktop/window-layouts.ts +14 -0
- package/src/renderers/dom/data-table/row.tsx +2 -0
- package/src/renderers/dom/host/tabs.tsx +57 -8
- package/src/renderers/dom/styles.css +13 -5
- package/src/renderers/electrobun/bun/desktop/backend-requests.ts +4 -0
- package/src/renderers/electrobun/bun/desktop/backend.ts +22 -1
- package/src/renderers/electrobun/bun/window/native-min-size.ts +6 -1
- package/src/renderers/electrobun/shared/protocol.ts +4 -0
- package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +2 -0
- package/src/renderers/electrobun/view/cli-pane-shot-frame.tsx +50 -12
- package/src/renderers/electrobun/view/remote/ticker-repository.ts +10 -0
- package/src/series/standalone-catalog.ts +5 -4
- package/src/series/standalone.ts +13 -7
- package/src/sources/gloomberb-cloud/fred-publisher.ts +25 -0
- package/src/sources/gloomberb-cloud/fred-series.ts +1 -1
- package/src/sources/gloomberb-cloud/index.ts +14 -3
- package/src/sources/gloomberb-cloud/perpetuals.ts +60 -3
- package/src/sources/provider-router/financials.ts +20 -13
- package/src/sources/provider-router/index.ts +4 -0
- package/src/sources/provider-router/search.ts +1 -0
- package/src/sync/collections-contributor.ts +3 -1
- package/src/sync/config-merge.ts +10 -1
- package/src/sync/sanitize.ts +26 -2
- package/src/tickers/company-name-listing.ts +16 -2
- package/src/tickers/listing-fate.ts +12 -8
- package/src/tickers/renamed-listings.ts +43 -10
- package/src/tickers/search/home-listing.ts +28 -0
- package/src/tickers/search/index.ts +19 -7
- package/src/tickers/terminal-codes.ts +11 -1
- package/src/time-series/base-series.ts +3 -0
- package/src/time-series/ice-credit.ts +1 -0
- package/src/time-series/resolve.ts +3 -1
- package/src/time-series/spec.ts +2 -2
- package/src/time-series/types.ts +2 -1
- package/src/types/data-provider.ts +11 -0
- package/src/types/financials.ts +39 -3
- package/src/types/headless.ts +4 -2
- package/src/types/ticker.ts +10 -2
- package/src/utils/cli-output.ts +1 -1
- package/src/utils/declared-dividends.ts +13 -1
- package/src/utils/dividend-cash.ts +5 -1
- package/src/utils/forward-dividend.ts +4 -3
- package/src/utils/remove-folder.ts +37 -0
- package/src/utils/throttled-fetch.ts +15 -1
- package/src/utils/trailing-dividend.ts +1 -1
- package/src/plugins/builtin/composite-plugins.ts +0 -285
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type { MnaDeal, MnaStatus, MnaTerms } from "../../../api-client/mna";
|
|
1
|
+
import type { MnaDeal, MnaOutsideDate, MnaStatus, MnaTerms } from "../../../api-client/mna";
|
|
2
2
|
import type { Quote } from "../../../types/financials";
|
|
3
3
|
import { getListingSymbol } from "../../../sources/listing-symbols";
|
|
4
|
-
import {
|
|
4
|
+
import { isRegularSessionTime, isVenueTradingDay, latestRegularSessionClose, regularSessionCloseOn } from "../../../market-data/market/freshness";
|
|
5
|
+
import { canonicalExchange, isUsListingExchange, parsePublicTickerKey } from "../../../utils/exchanges";
|
|
6
|
+
import { zonedDateTimeParts } from "../../../utils/zoned-date-time";
|
|
5
7
|
import { MISSING_VALUE, formatCompact } from "../../../utils/format";
|
|
6
8
|
import { nonUsSecListingVenue } from "../../../utils/sec";
|
|
7
9
|
|
|
@@ -114,8 +116,7 @@ function cashLeg(terms: MnaTerms, targetQuote: Quote | null): number | null {
|
|
|
114
116
|
return terms.cashPerShare == null ? null : inQuoteCurrency(terms.cashPerShare, terms.currency, targetQuote?.currency);
|
|
115
117
|
}
|
|
116
118
|
|
|
117
|
-
function stockLeg(terms: MnaTerms, targetQuote: Quote | null, ratioQuote: Quote | null): number | null {
|
|
118
|
-
const price = ratioQuote?.price;
|
|
119
|
+
function stockLeg(terms: MnaTerms, targetQuote: Quote | null, ratioQuote: Quote | null, price = ratioQuote?.price): number | null {
|
|
119
120
|
if (terms.exchangeRatio == null || !terms.ratioSymbol || price == null || !Number.isFinite(price) || price <= 0) return null;
|
|
120
121
|
const leg = inQuoteCurrency(price, ratioQuote?.currency ?? null, targetQuote?.currency);
|
|
121
122
|
return leg == null ? null : terms.exchangeRatio * leg;
|
|
@@ -138,22 +139,29 @@ export function electionLeg(terms: MnaTerms, targetQuote: Quote | null): "cash"
|
|
|
138
139
|
* without its listing, or cash in another currency. An election is one leg,
|
|
139
140
|
* the one {@link electionLeg} picks.
|
|
140
141
|
*/
|
|
141
|
-
function offerValue(deal: MnaDeal, targetQuote: Quote | null, ratioQuote: Quote | null): number | null {
|
|
142
|
+
function offerValue(deal: MnaDeal, targetQuote: Quote | null, ratioQuote: Quote | null, ratioPrice = ratioQuote?.price): number | null {
|
|
142
143
|
const { terms } = deal;
|
|
143
144
|
if (terms.cashPerShare == null && terms.exchangeRatio == null) return null;
|
|
144
145
|
let total: number | null;
|
|
145
146
|
if (isElection(terms)) {
|
|
146
147
|
total = electionLeg(terms, targetQuote) === "cash"
|
|
147
148
|
? cashLeg(terms, targetQuote)
|
|
148
|
-
: stockLeg(terms, targetQuote, ratioQuote);
|
|
149
|
+
: stockLeg(terms, targetQuote, ratioQuote, ratioPrice);
|
|
149
150
|
} else {
|
|
150
151
|
const cash = terms.cashPerShare == null ? 0 : cashLeg(terms, targetQuote);
|
|
151
|
-
const stock = terms.exchangeRatio == null ? 0 : stockLeg(terms, targetQuote, ratioQuote);
|
|
152
|
+
const stock = terms.exchangeRatio == null ? 0 : stockLeg(terms, targetQuote, ratioQuote, ratioPrice);
|
|
152
153
|
total = cash == null || stock == null ? null : cash + stock;
|
|
153
154
|
}
|
|
154
155
|
return total != null && total > 0 ? total : null;
|
|
155
156
|
}
|
|
156
157
|
|
|
158
|
+
/** Whether the offer moves with the paying listing's price: a share leg it is priced at. */
|
|
159
|
+
function pricedByRatio(deal: MnaDeal, targetQuote: Quote | null): boolean {
|
|
160
|
+
const { terms } = deal;
|
|
161
|
+
if (terms.exchangeRatio == null || !terms.ratioSymbol) return false;
|
|
162
|
+
return !isElection(terms) || electionLeg(terms, targetQuote) === "stock";
|
|
163
|
+
}
|
|
164
|
+
|
|
157
165
|
/**
|
|
158
166
|
* What the terms were worth each day since the announcement: flat for cash,
|
|
159
167
|
* the ratio times the paying listing's close for stock. An election draws
|
|
@@ -187,6 +195,38 @@ export function offerSeries(
|
|
|
187
195
|
return out;
|
|
188
196
|
}
|
|
189
197
|
|
|
198
|
+
/** Legs whose prints are further apart than this are not one moment's prices: the row flags them. */
|
|
199
|
+
const LEGS_APART_MS = 30 * 60_000;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* The session a print was made in, as its venue's hours place it: `closed`
|
|
203
|
+
* for one made when no session was open, on a weekend or a holiday, or on a
|
|
204
|
+
* night no overnight session follows.
|
|
205
|
+
*/
|
|
206
|
+
export type PrintSession = "regular" | "pre-market" | "after-hours" | "overnight" | "closed";
|
|
207
|
+
|
|
208
|
+
/** One leg's latest print: the target's, or the listing a ratio pays in. */
|
|
209
|
+
export interface SpreadLeg {
|
|
210
|
+
symbol: string;
|
|
211
|
+
/** In the leg's own quote currency. */
|
|
212
|
+
price: number;
|
|
213
|
+
/** When it traded (epoch ms); null when the quote does not say. */
|
|
214
|
+
at: number | null;
|
|
215
|
+
session: PrintSession | null;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* What a spread's two prices are. `close`: each leg's official close of one
|
|
220
|
+
* regular session (`session`, the venues' local date), which is how it is
|
|
221
|
+
* priced whenever a leg's venue is out of its regular session. `last`: the
|
|
222
|
+
* legs' last trades, in the regular session or when no matching closes are
|
|
223
|
+
* known; `at` is the older trade's time, `apartMs` how far apart the two
|
|
224
|
+
* trades are (null without both times; 0 for one leg).
|
|
225
|
+
*/
|
|
226
|
+
export type SpreadBasis =
|
|
227
|
+
| { kind: "close"; session: string }
|
|
228
|
+
| { kind: "last"; at: number | null; apartMs: number | null; session: PrintSession | null };
|
|
229
|
+
|
|
190
230
|
export interface DealSpread {
|
|
191
231
|
offer: number;
|
|
192
232
|
price: number;
|
|
@@ -194,6 +234,77 @@ export interface DealSpread {
|
|
|
194
234
|
spread: number;
|
|
195
235
|
/** Simple annualized spread to the expected close; null past it or without a date. */
|
|
196
236
|
annualized: number | null;
|
|
237
|
+
/** Which prices the offer and the spread are at. */
|
|
238
|
+
basis: SpreadBasis;
|
|
239
|
+
/**
|
|
240
|
+
* The spread at the legs' latest prints, beside a close basis whose legs
|
|
241
|
+
* have traded since that close (pre-market, after hours): its own basis
|
|
242
|
+
* says when they traded and how far apart. Null otherwise.
|
|
243
|
+
*/
|
|
244
|
+
latest: { offer: number; price: number; spread: number; basis: Extract<SpreadBasis, { kind: "last" }> } | null;
|
|
245
|
+
/** Each leg's latest print, the target first. */
|
|
246
|
+
legs: SpreadLeg[];
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/** When a quote's price traded: its last trade, else its last update. */
|
|
250
|
+
function printTime(quote: Quote): number | null {
|
|
251
|
+
const at = quote.lastTradeTime ?? quote.lastUpdated;
|
|
252
|
+
return typeof at === "number" && Number.isFinite(at) && at > 0 ? at : null;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/** The calendar day after a `YYYY-MM-DD`. */
|
|
256
|
+
function nextDay(date: string): string {
|
|
257
|
+
return new Date(Date.parse(`${date}T00:00:00Z`) + 86_400_000).toISOString().slice(0, 10);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* The session `at` falls in on the quote's venue, read from its calendar:
|
|
262
|
+
* its regular hours; on a trading day, before the open (pre-market; for a
|
|
263
|
+
* US listing overnight before 04:00 New York) or after the close (after
|
|
264
|
+
* hours; for a US listing overnight from 20:00 when the next day trades).
|
|
265
|
+
* A day the venue does not trade (a weekend, a holiday) has no session of
|
|
266
|
+
* its own: `closed`, but for a US listing's overnight session from 20:00 on
|
|
267
|
+
* the eve of a trading day (Sunday night). Null for a venue with unknown hours.
|
|
268
|
+
*/
|
|
269
|
+
function printSession(quote: Pick<Quote, "listingExchangeName" | "exchangeName">, at: number): PrintSession | null {
|
|
270
|
+
const exchange = quote.listingExchangeName || quote.exchangeName;
|
|
271
|
+
const regular = isRegularSessionTime(exchange, at);
|
|
272
|
+
if (regular === null) return null;
|
|
273
|
+
if (regular) return "regular";
|
|
274
|
+
const latest = latestRegularSessionClose(exchange, at);
|
|
275
|
+
if (!latest) return null;
|
|
276
|
+
const local = zonedDateTimeParts(at, latest.timeZone);
|
|
277
|
+
const date = `${local.year}-${String(local.month).padStart(2, "0")}-${String(local.day).padStart(2, "0")}`;
|
|
278
|
+
const minutes = local.hour * 60 + local.minute;
|
|
279
|
+
const us = isUsListingExchange(canonicalExchange(exchange));
|
|
280
|
+
const eveOfSession = us && minutes >= 20 * 60 && isVenueTradingDay(exchange, nextDay(date));
|
|
281
|
+
if (!isVenueTradingDay(exchange, date)) return eveOfSession ? "overnight" : "closed";
|
|
282
|
+
const close = regularSessionCloseOn(exchange, date);
|
|
283
|
+
if (close != null && at >= close) return eveOfSession ? "overnight" : us && minutes >= 20 * 60 ? "closed" : "after-hours";
|
|
284
|
+
return us && minutes < 4 * 60 ? "overnight" : "pre-market";
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function leg(quote: Quote): SpreadLeg | null {
|
|
288
|
+
const price = quote.price;
|
|
289
|
+
if (price == null || !Number.isFinite(price) || price <= 0) return null;
|
|
290
|
+
const at = printTime(quote);
|
|
291
|
+
return { symbol: quote.symbol, price, at, session: at == null ? null : printSession(quote, at) };
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/** The last-trade basis of these legs: the older trade, and how far apart the two are. */
|
|
295
|
+
function lastBasis(legs: readonly SpreadLeg[]): Extract<SpreadBasis, { kind: "last" }> {
|
|
296
|
+
const times = legs.map((entry) => entry.at);
|
|
297
|
+
if (times.some((at) => at == null)) return { kind: "last", at: null, apartMs: null, session: null };
|
|
298
|
+
const known = times as number[];
|
|
299
|
+
const at = Math.min(...known);
|
|
300
|
+
return { kind: "last", at, apartMs: Math.max(...known) - at, session: legs[known.indexOf(at)]!.session };
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/** The close a quote reports of a completed regular session, with that session's date. */
|
|
304
|
+
function sessionClose(quote: Quote): { price: number; session: string } | null {
|
|
305
|
+
const price = quote.regularClose;
|
|
306
|
+
const session = quote.regularCloseSessionDate;
|
|
307
|
+
return price != null && Number.isFinite(price) && price > 0 && session ? { price, session } : null;
|
|
197
308
|
}
|
|
198
309
|
|
|
199
310
|
/** Last day of a "Q1 2027", "H2 2026" or "2026" close; a full date passes through. */
|
|
@@ -241,18 +352,91 @@ export function dealSpread(
|
|
|
241
352
|
ratioQuote: Quote | null,
|
|
242
353
|
now = Date.now(),
|
|
243
354
|
): DealSpread | null {
|
|
244
|
-
if (deal.status !== "pending" || !deal.target.symbol) return null;
|
|
245
|
-
const
|
|
246
|
-
if (
|
|
247
|
-
const
|
|
248
|
-
|
|
249
|
-
|
|
355
|
+
if (deal.status !== "pending" || !deal.target.symbol || !targetQuote) return null;
|
|
356
|
+
const target = leg(targetQuote);
|
|
357
|
+
if (!target) return null;
|
|
358
|
+
const ratio = pricedByRatio(deal, targetQuote) ? (ratioQuote ? leg(ratioQuote) : null) : null;
|
|
359
|
+
const latestOffer = offerValue(deal, targetQuote, ratioQuote);
|
|
360
|
+
if (latestOffer == null) return null;
|
|
361
|
+
const legs = ratio ? [target, ratio] : [target];
|
|
362
|
+
const quotes = ratio ? [targetQuote, ratioQuote!] : [targetQuote];
|
|
363
|
+
const latest = { offer: latestOffer, price: target.price, spread: latestOffer / target.price - 1, basis: lastBasis(legs) };
|
|
364
|
+
|
|
365
|
+
// Out of the regular session, the legs' closes of one session: the latest
|
|
366
|
+
// prints of a pre-market or an evening are hours apart and thinly traded.
|
|
367
|
+
const outOfSession = quotes.some((quote) => quote.marketState != null && quote.marketState !== "REGULAR");
|
|
368
|
+
const closes = quotes.map(sessionClose);
|
|
369
|
+
const matched = outOfSession && closes.every((close) => close && close.session === closes[0]!.session);
|
|
370
|
+
let priced: Pick<DealSpread, "offer" | "price" | "spread" | "basis" | "latest">;
|
|
371
|
+
if (matched) {
|
|
372
|
+
const offer = offerValue(deal, targetQuote, ratioQuote, ratio ? closes[1]!.price : undefined);
|
|
373
|
+
if (offer == null) return null;
|
|
374
|
+
const price = closes[0]!.price;
|
|
375
|
+
// The latest prints are worth showing beside the close once a leg has traded since it.
|
|
376
|
+
const traded = legs.some((entry, index) => entry.price !== closes[index]!.price);
|
|
377
|
+
priced = { offer, price, spread: offer / price - 1, basis: { kind: "close", session: closes[0]!.session }, latest: traded ? latest : null };
|
|
378
|
+
} else {
|
|
379
|
+
priced = { ...latest, latest: null };
|
|
380
|
+
}
|
|
250
381
|
const close = expectedCloseDate(deal.expectedClose);
|
|
251
382
|
const days = close ? (close.getTime() - now) / MS_PER_DAY : null;
|
|
252
|
-
const annualized = !deal.terms.partial && spread > 0 && days != null && days >= 1
|
|
253
|
-
? spread * 365 / days
|
|
383
|
+
const annualized = !deal.terms.partial && priced.spread > 0 && days != null && days >= 1
|
|
384
|
+
? priced.spread * 365 / days
|
|
254
385
|
: null;
|
|
255
|
-
return {
|
|
386
|
+
return { ...priced, annualized, legs };
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
const WEEKDAYS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] as const;
|
|
390
|
+
const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] as const;
|
|
391
|
+
|
|
392
|
+
/** `Mon close` within the week, `6 Nov close` before it; `Mon 16 Nov close` dated in full. */
|
|
393
|
+
export function closeBasisLabel(session: string, now = Date.now(), { dated = false }: { dated?: boolean } = {}): string {
|
|
394
|
+
const day = new Date(`${session}T00:00:00Z`);
|
|
395
|
+
if (!Number.isFinite(day.getTime())) return "close";
|
|
396
|
+
const weekday = WEEKDAYS[day.getUTCDay()]!;
|
|
397
|
+
const date = `${day.getUTCDate()} ${MONTHS[day.getUTCMonth()]}`;
|
|
398
|
+
if (dated) return `${weekday} ${date} close`;
|
|
399
|
+
return (now - day.getTime()) / MS_PER_DAY < 6 ? `${weekday} close` : `${date} close`;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/** How far apart two prints are, in the larger unit that says it: `45m`, `8h`, `3d`. */
|
|
403
|
+
export function apartText(ms: number): string {
|
|
404
|
+
const minutes = Math.floor(ms / 60_000);
|
|
405
|
+
if (minutes < 60) return `${minutes}m`;
|
|
406
|
+
const hours = Math.floor(minutes / 60);
|
|
407
|
+
return hours < 48 ? `${hours}h` : `${Math.floor(hours / 24)}d`;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/** Whether a basis is two trades far enough apart that the spread is no one moment's. */
|
|
411
|
+
export function legsApart(basis: SpreadBasis): boolean {
|
|
412
|
+
return basis.kind === "last" && basis.apartMs != null && basis.apartMs > LEGS_APART_MS;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/** A print's session when it is not the regular one (`pre-market`, `after-hours`, `overnight`, `closed`); empty for the regular session. */
|
|
416
|
+
function extendedSessionWord(session: PrintSession | null): string {
|
|
417
|
+
return session && session !== "regular" ? session : "";
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/** A print's time, after its session when that is not the regular one: `pre-market 04:24`, `15:42`. */
|
|
421
|
+
export function printWhen(at: number, session: PrintSession | null, clock: (at: number) => string): string {
|
|
422
|
+
const word = extendedSessionWord(session);
|
|
423
|
+
return word ? `${word} ${clock(at)}` : clock(at);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* The basis as the detail's figures say it: `Mon close`; the older trade's
|
|
428
|
+
* time (`clock`), after its session when that is not the regular one
|
|
429
|
+
* (`pre-market 04:24`); `8h apart` for trades too far apart to be one
|
|
430
|
+
* moment's. With `timed: false`, as the narrow AS OF cell says it, a trade
|
|
431
|
+
* outside the regular session is its session alone (`pre-market`): the
|
|
432
|
+
* detail times it. MISSING when the trades are not timed.
|
|
433
|
+
*/
|
|
434
|
+
export function spreadBasisLabel(basis: SpreadBasis, clock: (at: number) => string, now = Date.now(), { timed = true }: { timed?: boolean } = {}): string {
|
|
435
|
+
if (basis.kind === "close") return closeBasisLabel(basis.session, now);
|
|
436
|
+
if (legsApart(basis)) return `${apartText(basis.apartMs!)} apart`;
|
|
437
|
+
if (basis.at == null) return MISSING;
|
|
438
|
+
const word = extendedSessionWord(basis.session);
|
|
439
|
+
return word && !timed ? word : printWhen(basis.at, basis.session, clock);
|
|
256
440
|
}
|
|
257
441
|
|
|
258
442
|
/** Target name for a table cell: the symbol when listed, else the name. */
|
|
@@ -269,6 +453,25 @@ export function formatListDate(value: string, now = new Date()): string {
|
|
|
269
453
|
return date.getUTCFullYear() === now.getUTCFullYear() ? `${date.getUTCDate()} ${month}` : `${month} ${date.getUTCFullYear()}`;
|
|
270
454
|
}
|
|
271
455
|
|
|
456
|
+
/** `4 May 2027`: a deadline's whole day, its year always, since it is usually next year's. */
|
|
457
|
+
function formatDeadline(value: string): string {
|
|
458
|
+
const date = new Date(`${value}T00:00:00Z`);
|
|
459
|
+
if (!Number.isFinite(date.getTime())) return value;
|
|
460
|
+
return `${date.getUTCDate()} ${MONTHS[date.getUTCMonth()]} ${date.getUTCFullYear()}`;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* An outside date in its parts: the date (`4 May 2027`), the later one it
|
|
465
|
+
* moves to and on what (`to 4 Nov 2027 if only antitrust approvals remain`),
|
|
466
|
+
* and the filing it is read from (`8-K 4 Nov 2026`).
|
|
467
|
+
*/
|
|
468
|
+
export function outsideDateParts(outside: MnaOutsideDate): { date: string; extension: string | null; source: string } {
|
|
469
|
+
const extension = outside.extendedTo
|
|
470
|
+
? `to ${formatDeadline(outside.extendedTo)}${outside.extension ? ` ${outside.extension}` : ""}`
|
|
471
|
+
: null;
|
|
472
|
+
return { date: formatDeadline(outside.date), extension, source: `${outside.source.form} ${formatDeadline(outside.source.filed)}` };
|
|
473
|
+
}
|
|
474
|
+
|
|
272
475
|
/** 0.0038 is "0.38%", -0.049 is "-4.9%": tight arb spreads keep two decimals. */
|
|
273
476
|
export function formatPercentShort(value: number): string {
|
|
274
477
|
const percent = value * 100;
|
|
@@ -48,11 +48,15 @@ import {
|
|
|
48
48
|
formatListDate,
|
|
49
49
|
formatPercentShort,
|
|
50
50
|
formatPrice,
|
|
51
|
+
legsApart,
|
|
51
52
|
MISSING,
|
|
52
53
|
partyCell,
|
|
54
|
+
spreadBasisLabel,
|
|
53
55
|
stageLabel,
|
|
54
56
|
termsLabel,
|
|
55
57
|
} from "./model";
|
|
58
|
+
import { formatFeedTime } from "../../../utils/datetime-format";
|
|
59
|
+
import { createDataTableCsv } from "../../../components/data-table/export";
|
|
56
60
|
import { logFailure } from "../../../utils/log-failure";
|
|
57
61
|
|
|
58
62
|
const STATUS_OPTIONS: { value: MnaStatusFilter; label: string }[] = [
|
|
@@ -73,7 +77,7 @@ const REGION_OPTIONS: { value: MnaRegionFilter; label: string }[] = [
|
|
|
73
77
|
{ value: "intl", label: "International" },
|
|
74
78
|
];
|
|
75
79
|
|
|
76
|
-
type ColumnId = "date" | "target" | "acquirer" | "terms" | "value" | "price" | "spread" | "annualized" | "close" | "stage";
|
|
80
|
+
type ColumnId = "date" | "target" | "acquirer" | "terms" | "value" | "price" | "spread" | "annualized" | "basis" | "close" | "stage";
|
|
77
81
|
|
|
78
82
|
const COLUMNS: Record<ColumnId, DataTableColumn> = {
|
|
79
83
|
date: { id: "date", label: "DATE", width: 8, align: "left" },
|
|
@@ -84,20 +88,26 @@ const COLUMNS: Record<ColumnId, DataTableColumn> = {
|
|
|
84
88
|
price: { id: "price", label: "PRICE", width: 9, align: "right" },
|
|
85
89
|
spread: { id: "spread", label: "SPREAD", width: 7, align: "right" },
|
|
86
90
|
annualized: { id: "annualized", label: "ANN.", width: 7, align: "right" },
|
|
91
|
+
// What the spread's prices are: a session's closes (`Mon close`), or trades and when (`15:42`, `8h apart`).
|
|
92
|
+
basis: { id: "basis", label: "AS OF", width: 12, align: "left" },
|
|
87
93
|
close: { id: "close", label: "CLOSE", width: 7, align: "left" },
|
|
88
94
|
stage: { id: "stage", label: "STAGE", width: 16, align: "left" },
|
|
89
95
|
};
|
|
90
96
|
|
|
91
97
|
const COLUMNS_BY_STATUS: Record<MnaStatusFilter, ColumnId[]> = {
|
|
92
|
-
pending: ["date", "target", "acquirer", "terms", "value", "price", "spread", "annualized", "close", "stage"],
|
|
98
|
+
pending: ["date", "target", "acquirer", "terms", "value", "price", "spread", "annualized", "basis", "close", "stage"],
|
|
93
99
|
talks: ["date", "target", "acquirer", "value", "stage"],
|
|
94
100
|
completed: ["date", "target", "acquirer", "terms", "value", "close"],
|
|
95
101
|
terminated: ["date", "target", "acquirer", "terms", "value", "close"],
|
|
96
|
-
all: ["date", "target", "acquirer", "terms", "value", "spread", "stage"],
|
|
102
|
+
all: ["date", "target", "acquirer", "terms", "value", "spread", "basis", "stage"],
|
|
97
103
|
};
|
|
98
104
|
|
|
99
|
-
/**
|
|
100
|
-
|
|
105
|
+
/**
|
|
106
|
+
* What goes first when the pane is too narrow for every column. The spread
|
|
107
|
+
* never shows without what it is as of: AS OF goes only with it. The
|
|
108
|
+
* announcement date goes before the expected close, which an arb reads.
|
|
109
|
+
*/
|
|
110
|
+
const DROP_ORDER: ColumnId[] = ["price", "date", "close", "value", "annualized", "terms", "stage", "acquirer", "spread"];
|
|
101
111
|
|
|
102
112
|
/** Columns that fit `width`; `targetWidth` widens the target column, e.g. for the unlock prompt. */
|
|
103
113
|
function mnaColumns(status: MnaStatusFilter, width: number, targetWidth = COLUMNS.target.width): DataTableColumn[] {
|
|
@@ -106,7 +116,7 @@ function mnaColumns(status: MnaStatusFilter, width: number, targetWidth = COLUMN
|
|
|
106
116
|
const need = (list: ColumnId[]) => list.reduce((sum, id) => sum + widthOf(id) + 1, 0);
|
|
107
117
|
for (const drop of DROP_ORDER) {
|
|
108
118
|
if (need(ids) <= width) break;
|
|
109
|
-
ids = ids.filter((id) => id !== drop);
|
|
119
|
+
ids = ids.filter((id) => id !== drop && !(drop === "spread" && id === "basis"));
|
|
110
120
|
}
|
|
111
121
|
const ended = status === "completed" || status === "terminated";
|
|
112
122
|
return ids.map((id) => ({
|
|
@@ -282,6 +292,11 @@ function MnaDealsView({ focused, width, height, symbol }: {
|
|
|
282
292
|
case "price": return spreadOf(deal)?.price ?? null;
|
|
283
293
|
case "spread": return spreadOf(deal)?.spread ?? null;
|
|
284
294
|
case "annualized": return spreadOf(deal)?.annualized ?? null;
|
|
295
|
+
case "basis": {
|
|
296
|
+
const basis = spreadOf(deal)?.basis;
|
|
297
|
+
// As of when: a close at its New York evening, a trade at its time.
|
|
298
|
+
return !basis ? null : basis.kind === "close" ? Date.parse(`${basis.session}T21:00:00Z`) : basis.at;
|
|
299
|
+
}
|
|
285
300
|
case "close": return deal.closed ?? expectedCloseDate(deal.expectedClose)?.toISOString().slice(0, 10) ?? null;
|
|
286
301
|
case "stage": return stageLabel(deal);
|
|
287
302
|
default: return null;
|
|
@@ -297,6 +312,11 @@ function MnaDealsView({ focused, width, height, symbol }: {
|
|
|
297
312
|
() => mnaColumns(status, width, locked > 0 ? Math.min(lockedText.length + 3, Math.floor(width / 3)) : undefined),
|
|
298
313
|
[locked, lockedText, status, width],
|
|
299
314
|
);
|
|
315
|
+
// Export CSV keeps the columns an earlier export had where they were: AS OF, drawn beside the spread, comes last.
|
|
316
|
+
const exportColumns = useMemo(
|
|
317
|
+
() => [...columns.filter((column) => column.id !== "basis"), ...columns.filter((column) => column.id === "basis")],
|
|
318
|
+
[columns],
|
|
319
|
+
);
|
|
300
320
|
const items = useMemo<Item[]>(() => [
|
|
301
321
|
...Array.from({ length: Math.min(MAX_LOCKED_ROWS, locked) }, (_, index) => ({ kind: "locked" as const, index })),
|
|
302
322
|
...sorted.map((deal) => ({ kind: "deal" as const, deal })),
|
|
@@ -382,6 +402,13 @@ function MnaDealsView({ focused, width, height, symbol }: {
|
|
|
382
402
|
const annualized = spreadOf(deal)?.annualized ?? null;
|
|
383
403
|
return { text: annualized == null ? MISSING : formatPercentShort(annualized), color: annualized == null ? muted : base };
|
|
384
404
|
}
|
|
405
|
+
case "basis": {
|
|
406
|
+
const spread = spreadOf(deal);
|
|
407
|
+
if (!spread) return { text: MISSING, color: muted };
|
|
408
|
+
// Trades too far apart to be one moment's take the warning tone every stale mark has.
|
|
409
|
+
const apart = legsApart(spread.basis);
|
|
410
|
+
return { text: spreadBasisLabel(spread.basis, (at) => formatFeedTime(at), Date.now(), { timed: false }), color: apart && !state.selected ? colors.warning : muted };
|
|
411
|
+
}
|
|
385
412
|
case "close": {
|
|
386
413
|
const ended = deal.status === "completed" || deal.status === "terminated";
|
|
387
414
|
return ended
|
|
@@ -460,6 +487,7 @@ function MnaDealsView({ focused, width, height, symbol }: {
|
|
|
460
487
|
resetTo: { columnId: null, direction: "desc" },
|
|
461
488
|
}))}
|
|
462
489
|
renderCell={renderCell}
|
|
490
|
+
exportCsv={() => createDataTableCsv({ columns: exportColumns, items, renderCell })}
|
|
463
491
|
scrollRef={scrollRef}
|
|
464
492
|
onBodyScrollActivity={onScroll}
|
|
465
493
|
resetScrollKey={paramsKey}
|
|
@@ -29,19 +29,28 @@ export const MONEY_MARKET_TABS = [{ value: "rates", label: "Rates" }, { value: "
|
|
|
29
29
|
export const isHongKongTab = (tab: unknown) => tab === "hk";
|
|
30
30
|
|
|
31
31
|
/** Why a row has no figure, or an old one. */
|
|
32
|
+
export function moneyMarketRowNote(row: MoneyMarketRow): string | null {
|
|
33
|
+
return row.status === "unavailable" ? `${row.label}: ${(row.unavailableReason ?? "unavailable").replaceAll("-", " ")}.`
|
|
34
|
+
: row.status === "stale" ? `${row.label}: stale, last observation ${row.asOf ?? "unknown"}.` : null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Each row's note: the report's, which lists them; the pane says each on its row (`moneyMarketRowNote`). */
|
|
32
38
|
export function moneyMarketRowNotices(rows: readonly MoneyMarketRow[]): string[] {
|
|
33
|
-
return rows.flatMap((row) => row
|
|
34
|
-
? [`${row.label}: ${(row.unavailableReason ?? "unavailable").replaceAll("-", " ")}.`]
|
|
35
|
-
: row.status === "stale" ? [`${row.label}: stale, last observation ${row.asOf ?? "unknown"}.`] : []);
|
|
39
|
+
return rows.flatMap((row) => moneyMarketRowNote(row) ?? []);
|
|
36
40
|
}
|
|
37
41
|
|
|
38
|
-
|
|
39
|
-
|
|
42
|
+
/** What concerns the whole board: the bills curve and its comparisons, which are no row of it. */
|
|
43
|
+
export function moneyMarketBoardNotices(data: MoneyMarketsPayload): string[] {
|
|
44
|
+
const notices: string[] = [];
|
|
40
45
|
if (data.billsCurve.status === "unavailable") notices.push("Bills curve: no common observation date across all four tenors.");
|
|
41
46
|
else if (data.billsCurve.status === "stale") notices.push(`Bills curve: stale, last common observation ${data.billsCurve.asOf}.`);
|
|
42
47
|
for (const ghost of data.billsCurve.comparisons) if (!ghost.points.length) notices.push(`Bills ${ghost.period}: no common observation within seven days before ${ghost.targetDate ?? "the comparison date"}.`);
|
|
43
48
|
return notices;
|
|
44
49
|
}
|
|
50
|
+
|
|
51
|
+
export function moneyMarketNotices(data: MoneyMarketsPayload): string[] {
|
|
52
|
+
return [...moneyMarketRowNotices([...data.rows, data.netLiquidity]), ...moneyMarketBoardNotices(data)];
|
|
53
|
+
}
|
|
45
54
|
export function moneyMarketCurves(data: MoneyMarketsPayload, palette?: CurvePalette): CurveSeries[] {
|
|
46
55
|
const curve = data.billsCurve;
|
|
47
56
|
return [{ id: "today", label: "Latest", ...curve }, ...curve.comparisons.map((ghost) => ({ id: ghost.period, label: ghost.period, ...ghost }))]
|
|
@@ -17,7 +17,7 @@ import { useResearchCloudSession } from "../shared/research-cloud-session";
|
|
|
17
17
|
import { getCachedHongKongMoneyMarkets, getCachedMoneyMarkets, loadHongKongMoneyMarkets, loadMoneyMarkets } from "./client";
|
|
18
18
|
import { moneyMarketReport, moneyMarketsHeadless } from "./headless";
|
|
19
19
|
import { reportFooterSegment } from "../shared/source-footer";
|
|
20
|
-
import { isHongKongTab, MONEY_MARKET_TABS, moneyMarketAxis, moneyMarketChange,
|
|
20
|
+
import { isHongKongTab, MONEY_MARKET_TABS, moneyMarketAxis, moneyMarketChange, moneyMarketBoardNotices, moneyMarketCurves, moneyMarketObservations, moneyMarketRateChange, moneyMarketRowNote, moneyMarketRows, moneyMarketValue } from "./model";
|
|
21
21
|
|
|
22
22
|
const TABS = MONEY_MARKET_TABS.map(({ value, label }) => ({ value, label }));
|
|
23
23
|
const PANELS = [{ id: "main" }];
|
|
@@ -147,7 +147,8 @@ export function MoneyMarketsPane({ width, height, focused }: PaneProps) {
|
|
|
147
147
|
useAutoRefresh(active.updatedAt, active.load);
|
|
148
148
|
usePaneRefreshKey(() => active.reload(), { focused });
|
|
149
149
|
usePaneNoticeFooter({ registrationId: "money-markets:notices", focused,
|
|
150
|
-
|
|
150
|
+
// The board's own; a rate with no figure or an old one says so on its row (`rowNote`).
|
|
151
|
+
notices: [...(!hongKong && data ? moneyMarketBoardNotices(data) : []),
|
|
151
152
|
...(active.data?.refreshError ? [active.data.refreshError] : [])] });
|
|
152
153
|
usePaneStatusLinkFooter({ registrationId: "money-markets", focused, loading: active.loading, error: active.error,
|
|
153
154
|
url: selected?.observation.sourceUrl ?? null, showOpenHint: true,
|
|
@@ -161,7 +162,7 @@ export function MoneyMarketsPane({ width, height, focused }: PaneProps) {
|
|
|
161
162
|
empty={!active.loading && !active.error && !shown} subject={hongKong ? "Hong Kong money markets" : "money markets"}>
|
|
162
163
|
{shown ? <MarketBoardStack rows={rows} width={width} height={bodyHeight} focused={focused}
|
|
163
164
|
selectedId={selectedRow?.id ?? null} onSelectedIdChange={setSelectedId} openId={openId} onOpenIdChange={setOpenId}
|
|
164
|
-
changeLabel="Δ OBS" renderDetail={(row) => <ObservationDetail row={row.observation} width={width} height={Math.max(5, bodyHeight - 2)} focused={focused} />}
|
|
165
|
+
changeLabel="Δ OBS" rowNote={(row) => moneyMarketRowNote(row.observation)} renderDetail={(row) => <ObservationDetail row={row.observation} width={width} height={Math.max(5, bodyHeight - 2)} focused={focused} />}
|
|
165
166
|
rootBefore={({ columns }) => <ChartTableHeader width={width} height={bodyHeight} figures={figures} chart={chart}
|
|
166
167
|
tableRows={rows.length} tableColumns={columns} />} /> : null}
|
|
167
168
|
</PaneStatusBody>
|
|
@@ -5,7 +5,7 @@ import type { NewsAccess } from "../../../../../news/types";
|
|
|
5
5
|
import { t, tf } from "../../../../../i18n";
|
|
6
6
|
import { useAppLanguage } from "../../../../../i18n/react";
|
|
7
7
|
import { useCloudAccessFooter } from "../../../shared/cloud-upgrade";
|
|
8
|
-
import {
|
|
8
|
+
import { cloudNewsFreshness } from "../../../shared/report-freshness";
|
|
9
9
|
import { CLOUD_NEWS_DELAY_HOURS } from "../../../../../api-client/plan-access";
|
|
10
10
|
import { usePaneStatusLinkFooter } from "../../../../../components/layout/pane/status-footer";
|
|
11
11
|
import { useRemoteUiNode } from "../../../../../remote/semantic-tree";
|
|
@@ -69,16 +69,11 @@ export function useNewsArticleFooter({
|
|
|
69
69
|
const realtime = newsFeedRealtime(feedAccess, access.hasProAccess);
|
|
70
70
|
const storyPastDelay = publishedBeforeNewsDelay(article);
|
|
71
71
|
|
|
72
|
-
// A report or capture
|
|
73
|
-
// list by its newest story, named so it is not read as the time now.
|
|
72
|
+
// A report or capture dates the list by its newest story, named so it is not read as the time now.
|
|
74
73
|
useRemoteUiNode({
|
|
75
74
|
role: "report-freshness",
|
|
76
75
|
label: "News freshness",
|
|
77
|
-
getMetadata: () => (realtime
|
|
78
|
-
? { status: "live", asOfLabel: NEWEST_STORY }
|
|
79
|
-
: realtime === false
|
|
80
|
-
? { status: "delayed", delayMinutes: CLOUD_NEWS_DELAY_HOURS * 60, asOfLabel: NEWEST_STORY }
|
|
81
|
-
: { status: "not-a-feed", basis: "published stories", asOfLabel: NEWEST_STORY }),
|
|
76
|
+
getMetadata: () => ({ ...cloudNewsFreshness(realtime) }),
|
|
82
77
|
});
|
|
83
78
|
|
|
84
79
|
const accessInfo = useMemo<PaneFooterSegment[]>(() => {
|
|
@@ -89,6 +89,9 @@ const tradeDropOrder = (strategy: ScreenFamily) => strategyFamilyDef(strategy).n
|
|
|
89
89
|
? ["maxGain", "breakEven", "rank", "maxLoss", "earnings", "spread"]
|
|
90
90
|
: ["maxLoss", "breakEven", "rank", "maxGain", "earnings", "spread"];
|
|
91
91
|
|
|
92
|
+
/** The cells a name's state takes (`no price`, `no chain`, `no trade`). */
|
|
93
|
+
const STATE_WIDTH = 8;
|
|
94
|
+
|
|
92
95
|
const DELTA_OPTIONS = ["0.10", "0.15", "0.20", "0.25", "0.30", "0.35", "0.40", "0.50"];
|
|
93
96
|
const WING_OPTIONS = ["0.05", "0.10", "0.15", "0.20", "0.25", "0.30", "0.35", "0.40"];
|
|
94
97
|
const DAYS_OPTIONS = ["7", "14", "21", "30", "45", "60", "90"];
|
|
@@ -189,10 +192,10 @@ export function CspScreenPane({ width, height, focused }: PaneProps) {
|
|
|
189
192
|
const [selected, setSelected] = useState<string | null>(null);
|
|
190
193
|
const screen = data?.screen;
|
|
191
194
|
const rankedBy = strategy === "csp" ? undefined : strategyRankedBy(strategy);
|
|
195
|
+
// What concerns one name is on its row (rowState, rowNote); the footer's notes are the screen's.
|
|
192
196
|
const notices = [criteria.error, data ? null : resource.error,
|
|
193
197
|
leftOut.length ? `Ranks the first ${CSP_SCREEN_LIMIT} symbols; ${leftOut.length} left out: ${leftOut.join(", ")}` : null,
|
|
194
198
|
...(screen?.ivRankError ? [`IV rank unavailable: ${screen.ivRankError}`] : []),
|
|
195
|
-
...(screen?.rows ?? []).flatMap((row) => row.note ? [`${row.symbol}: ${row.note}`] : []),
|
|
196
199
|
...(screen ? cspScreenNotes(screen, rankedBy).slice(1) : [])].filter((value): value is string => !!value);
|
|
197
200
|
usePaneNoticeFooter({ registrationId: "csp-screen-notices", notices, focused });
|
|
198
201
|
// The bar names the delta and the expiry; the footer says only what changes.
|
|
@@ -219,7 +222,12 @@ export function CspScreenPane({ width, height, focused }: PaneProps) {
|
|
|
219
222
|
resource.reload();
|
|
220
223
|
event.preventDefault?.(); event.stopPropagation?.(); return true;
|
|
221
224
|
};
|
|
222
|
-
|
|
225
|
+
/** A name with nothing to rank says why in its first column with room for it, in a few words; the rest of its row stays blank. */
|
|
226
|
+
const stateCell = (row: { source: { state: string | null } }, id: string, stateColumn: string | undefined): DataTableCell | null =>
|
|
227
|
+
row.source.state && id === stateColumn ? { text: row.source.state, color: colors.warning } : null;
|
|
228
|
+
const putCell = (row: ScreenRow, id: string): DataTableCell => {
|
|
229
|
+
const state = row.source.csp ? null : stateCell(row, id, putStateColumn);
|
|
230
|
+
if (state) return state;
|
|
223
231
|
switch (id) {
|
|
224
232
|
case "rank": return { text: row.rank == null ? "" : String(row.rank), color: colors.textDim };
|
|
225
233
|
case "symbol": return { text: row.symbol, color: colors.textBright };
|
|
@@ -239,6 +247,8 @@ export function CspScreenPane({ width, height, focused }: PaneProps) {
|
|
|
239
247
|
}
|
|
240
248
|
};
|
|
241
249
|
const tradeCell = (row: TradeRow, id: string): DataTableCell => {
|
|
250
|
+
const state = row.source.trade ? null : stateCell(row, id, "trade");
|
|
251
|
+
if (state) return state;
|
|
242
252
|
switch (id) {
|
|
243
253
|
case "rank": return { text: row.rank == null ? "" : String(row.rank), color: colors.textDim };
|
|
244
254
|
case "symbol": return { text: row.symbol, color: colors.textBright };
|
|
@@ -297,11 +307,17 @@ export function CspScreenPane({ width, height, focused }: PaneProps) {
|
|
|
297
307
|
};
|
|
298
308
|
// Whole columns give way, least needed first, so nothing scrolls sideways; a vertical scrollbar takes a cell.
|
|
299
309
|
const putColumns = useMemo(() => dropColumnsToFit(COLUMNS, width - 1, PUT_DROP_ORDER), [width]);
|
|
310
|
+
// The first column past the symbol wide enough for a state's few words.
|
|
311
|
+
const putStateColumn = putColumns.find((column) => column.id !== "rank" && column.id !== "symbol" && (column.width ?? 0) >= STATE_WIDTH)?.id;
|
|
300
312
|
const tradeColumnWidth = tradeWidth(tradeRows);
|
|
301
313
|
const shownTradeColumns = useMemo(() => strategy === "csp" ? [] : dropColumnsToFit(tradeColumns(strategy, tradeColumnWidth), width - 1,
|
|
302
314
|
tradeDropOrder(strategy)), [strategy, tradeColumnWidth, width]);
|
|
303
|
-
const
|
|
304
|
-
const
|
|
315
|
+
const shownRows: Array<ScreenRow | TradeRow> = strategy === "csp" ? putRows : tradeRows;
|
|
316
|
+
const firstSymbol = shownRows[0]?.symbol ?? "";
|
|
317
|
+
const selectedSymbol = selected ?? firstSymbol;
|
|
318
|
+
const selection = { kind: "id" as const, selectedId: selectedSymbol, getId: (row: { symbol: string }) => row.symbol, onChange: (id: string) => setSelected(id) };
|
|
319
|
+
// The selected name's whole reason, under the table: the row has room for its few words only.
|
|
320
|
+
const rowNote = (row: ScreenRow | TradeRow) => row.source.note ? `${row.symbol}: ${row.source.note}` : null;
|
|
305
321
|
return <Box width={width} height={height} flexDirection="column" overflow="hidden">
|
|
306
322
|
{tabStrip}
|
|
307
323
|
<QueryBar width={width} filters={filters} meta={strategy === "csp" ? undefined : STRATEGY_MONEY_UNIT} />
|
|
@@ -309,9 +325,9 @@ export function CspScreenPane({ width, height, focused }: PaneProps) {
|
|
|
309
325
|
error={criteria.error && !ready ? criteria.error : !data ? resource.error : null}>
|
|
310
326
|
{strategy === "csp"
|
|
311
327
|
? <DataTableView<ScreenRow> {...table} columns={putColumns} items={putRows} selection={selection}
|
|
312
|
-
renderCell={(row, column) => putCell(row, column.id)} />
|
|
328
|
+
renderCell={(row, column) => putCell(row, column.id)} rowNote={rowNote} />
|
|
313
329
|
: <DataTableView<TradeRow> {...table} columns={shownTradeColumns} items={tradeRows} selection={selection}
|
|
314
|
-
renderCell={(row, column) => tradeCell(row, column.id)} />}
|
|
330
|
+
renderCell={(row, column) => tradeCell(row, column.id)} rowNote={rowNote} />}
|
|
315
331
|
</PaneStatusBody>
|
|
316
332
|
</Box>;
|
|
317
333
|
}
|