@gloom-sh/terminal 0.20.20 → 0.20.21
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/api-client/data.ts +1 -1
- package/src/api-client/equity-screener.ts +17 -0
- package/src/api-client/futures-curve.ts +5 -0
- package/src/api-client/market-discovery.ts +8 -0
- package/src/api-client/members.ts +2 -0
- package/src/api-client/paths.ts +3 -0
- package/src/api-client/perps.ts +20 -0
- package/src/api-client/request.ts +53 -7
- package/src/api-client/types/filings-and-calls.ts +2 -0
- package/src/app/pane-runtime/plugin-bindings.ts +6 -4
- package/src/app/pro-welcome/model.ts +15 -11
- package/src/app/pro-welcome/row.tsx +3 -3
- package/src/app/pro-welcome/use-pro-welcome.ts +2 -2
- package/src/app/runtime/startup.ts +3 -2
- package/src/app.tsx +3 -2
- package/src/capabilities/asset-data-inputs.ts +5 -0
- package/src/capabilities/factories.ts +8 -3
- package/src/capabilities/registry.ts +1 -0
- package/src/capabilities/types.ts +1 -0
- package/src/cli/commands/market.ts +68 -35
- package/src/cli/commands/options-chain.ts +2 -2
- package/src/cli/commands/overview.ts +10 -9
- package/src/cli/commands/ticker.ts +19 -4
- package/src/cli/desktop-pane-shot.ts +11 -3
- package/src/cli/export-source.ts +35 -2
- package/src/cli/glossary.ts +3 -2
- package/src/cli/helpers.ts +2 -1
- package/src/cli/history-demergers.ts +41 -10
- package/src/cli/history-rows.ts +3 -1
- package/src/cli/known-gaps.ts +21 -7
- package/src/cli/listing-arg.ts +22 -11
- package/src/cli/pane-functions/capabilities.ts +4 -9
- package/src/cli/pane-functions/catalog-snapshot.json +29 -29
- package/src/cli/pane-functions/catalog.ts +1 -18
- package/src/cli/pane-functions/data.ts +8 -4
- package/src/cli/pane-functions/financial-ratio-shot.ts +20 -5
- package/src/cli/pane-functions/freshness.ts +57 -12
- package/src/cli/pane-functions/function-help.ts +2 -2
- package/src/cli/pane-functions/headless.ts +6 -0
- package/src/cli/pane-functions/index.ts +11 -4
- package/src/cli/pane-functions/market-session.ts +25 -0
- package/src/cli/pane-functions/report-notices.ts +10 -0
- package/src/cli/pane-functions/resolver.ts +75 -3
- package/src/cli/pane-functions/screenshot-bridge.ts +1 -0
- package/src/cli/pane-functions/screenshot-data-evidence.ts +1 -0
- package/src/cli/pane-functions/screenshot-payload.ts +38 -5
- package/src/cli/pane-functions/screenshot-render.ts +20 -7
- package/src/cli/perpetual-contract.ts +14 -1
- package/src/cli/report-tables.ts +11 -2
- package/src/cli/result.ts +6 -1
- package/src/components/chart-table/layout.ts +8 -4
- package/src/components/command-bar/list/model.ts +2 -0
- package/src/components/command-bar/pane-templates/items.ts +5 -25
- package/src/components/command-bar/panel/index.tsx +7 -4
- package/src/components/command-bar/routes/root/provider-search.ts +4 -4
- package/src/components/command-bar/routes/root/results.ts +6 -2
- package/src/components/command-bar/routes/ticker-search/results.ts +19 -0
- package/src/components/command-bar/routes/ticker-search/route.ts +3 -3
- package/src/components/command-bar/routes/ticker-search/title.ts +23 -0
- package/src/components/command-bar/routing/list-state.ts +17 -5
- package/src/components/command-bar/selection-runtime.ts +3 -2
- package/src/components/command-bar/surface/index.tsx +2 -0
- package/src/components/command-bar/workflow/alert.ts +6 -4
- package/src/components/command-bar/workflow/collection-actions.ts +2 -1
- package/src/components/layout/pane/footer/index.tsx +1 -0
- package/src/components/layout/pane/footer/model.ts +20 -7
- package/src/components/layout/pane/title.ts +11 -2
- package/src/components/price-selector-dialog.tsx +8 -4
- package/src/components/ticker/badge/list.tsx +4 -3
- package/src/components/ticker/list-table-view.tsx +12 -1
- package/src/components/ui/query-bar.tsx +20 -14
- package/src/data/cached-query.ts +20 -4
- package/src/data/news-pane-snapshots.ts +2 -1
- package/src/data/plugin-cache.ts +5 -1
- package/src/data/saved-copies.ts +68 -2
- package/src/docs/snapshot.json +65 -14
- package/src/docs/topics.ts +11 -9
- package/src/i18n/es.ts +1 -0
- package/src/i18n/ja.ts +1 -0
- package/src/i18n/ko.ts +1 -0
- package/src/i18n/zh-cn.ts +1 -0
- package/src/i18n/zh-tw.ts +1 -0
- package/src/market-data/coordinator/index.ts +25 -5
- package/src/market-data/depositary-pair.ts +27 -10
- package/src/market-data/futures-roll-returns.ts +54 -7
- package/src/market-data/fx-closes.ts +14 -0
- package/src/market-data/market/futures-product-hours.ts +113 -0
- package/src/market-data/market/futures-week.ts +2 -0
- package/src/market-data/market/globex-day.ts +9 -2
- package/src/market-data/market/status.ts +32 -25
- package/src/market-data/market/venue-session.ts +18 -0
- package/src/market-data/options-alternatives.ts +49 -7
- package/src/market-data/perpetual-open-interest.ts +41 -0
- package/src/market-data/quotes/contributions.ts +4 -2
- package/src/market-data/quotes/export-identity.ts +11 -3
- package/src/market-data/quotes/freshness.ts +3 -2
- package/src/market-data/quotes/resolution.ts +9 -2
- package/src/market-data/quotes/tick-range.ts +22 -1
- package/src/market-data/quotes/time.ts +34 -4
- package/src/market-data/split-terms.ts +3 -2
- package/src/news/aggregator.ts +1 -0
- package/src/news/news-model.ts +12 -2
- package/src/news/types.ts +15 -0
- package/src/plugins/builtin/alerts/alert-engine.ts +2 -0
- package/src/plugins/builtin/alerts/cli-forms.ts +3 -2
- package/src/plugins/builtin/alerts/cli-move.ts +5 -2
- package/src/plugins/builtin/alerts/cli.ts +50 -25
- package/src/plugins/builtin/alerts/command.ts +51 -3
- package/src/plugins/builtin/alerts/event-rows.ts +1 -1
- package/src/plugins/builtin/alerts/events-pane.tsx +1 -1
- package/src/plugins/builtin/alerts/format.ts +67 -8
- package/src/plugins/builtin/alerts/headless.ts +22 -6
- package/src/plugins/builtin/alerts/index.tsx +26 -25
- package/src/plugins/builtin/alerts/move-checks.ts +1 -0
- package/src/plugins/builtin/alerts/pane.tsx +15 -6
- package/src/plugins/builtin/alerts/pro-rules.ts +9 -4
- package/src/plugins/builtin/alerts/quotes.ts +10 -5
- package/src/plugins/builtin/alerts/session.ts +28 -0
- package/src/plugins/builtin/alerts/types.ts +1 -0
- package/src/plugins/builtin/analytics/pane-model.ts +2 -1
- package/src/plugins/builtin/analytics/risk-model.ts +2 -2
- package/src/plugins/builtin/attention/headless.ts +2 -2
- package/src/plugins/builtin/attention/model.ts +7 -2
- package/src/plugins/builtin/attention/pane.tsx +2 -1
- package/src/plugins/builtin/awards/headless.ts +1 -1
- package/src/plugins/builtin/broker-trading/ticket.tsx +13 -5
- package/src/plugins/builtin/buildout/detail/company.tsx +0 -1
- package/src/plugins/builtin/buildout/detail/ui.tsx +7 -5
- package/src/plugins/builtin/buildout/model/normalizers.ts +0 -1
- package/src/plugins/builtin/buildout/model/types.ts +0 -1
- package/src/plugins/builtin/buildout/pane/index.tsx +9 -0
- package/src/plugins/builtin/buildout/pane/status.tsx +11 -0
- package/src/plugins/builtin/catalysts/headless.ts +1 -1
- package/src/plugins/builtin/chart-composer/headless.ts +14 -6
- package/src/plugins/builtin/chart-composer/pane.tsx +2 -1
- package/src/plugins/builtin/chart-composer/session-history.ts +14 -2
- package/src/plugins/builtin/chat/controller/index.ts +5 -3
- package/src/plugins/builtin/chat/controller/session-runtime.ts +18 -8
- package/src/plugins/builtin/chat/index.tsx +1 -1
- package/src/plugins/builtin/cloud/auth-actions.tsx +4 -2
- package/src/plugins/builtin/cloud/mcp-connect/dialog.tsx +4 -1
- package/src/plugins/builtin/cloud/thesis/ticker-tab.tsx +2 -1
- package/src/plugins/builtin/company-attention/headless.ts +2 -1
- package/src/plugins/builtin/company-kpis/headless.ts +1 -1
- package/src/plugins/builtin/correlation/headless.ts +3 -3
- package/src/plugins/builtin/correlation/history.ts +1 -0
- package/src/plugins/builtin/correlation/index.tsx +7 -5
- package/src/plugins/builtin/correlation/matrix/selection.ts +21 -3
- package/src/plugins/builtin/correlation/relationship/model.ts +5 -0
- package/src/plugins/builtin/correlation/relationship/pane.tsx +3 -2
- package/src/plugins/builtin/correlation/relationship/view-model.ts +3 -2
- package/src/plugins/builtin/credit-documents/headless.ts +1 -1
- package/src/plugins/builtin/dividend-yield/client.ts +81 -10
- package/src/plugins/builtin/dividend-yield/headless.ts +21 -10
- package/src/plugins/builtin/dividend-yield/model.ts +1 -1
- package/src/plugins/builtin/dividend-yield/pane.tsx +9 -5
- package/src/plugins/builtin/dividend-yield/ranking.ts +15 -5
- package/src/plugins/builtin/dividend-yield/reference-price.ts +3 -0
- package/src/plugins/builtin/dividend-yield/types.ts +12 -0
- package/src/plugins/builtin/dividend-yield/view.ts +30 -7
- package/src/plugins/builtin/doe/headless.ts +1 -1
- package/src/plugins/builtin/doe/pane.tsx +16 -7
- package/src/plugins/builtin/earnings-calls/data.ts +8 -5
- package/src/plugins/builtin/earnings-ripple/headless.ts +1 -1
- package/src/plugins/builtin/econ/calendar-model.ts +1 -1
- package/src/plugins/builtin/econ/index.tsx +26 -18
- package/src/plugins/builtin/equity-screener/client.ts +1 -1
- package/src/plugins/builtin/equity-screener/headless.ts +149 -31
- package/src/plugins/builtin/equity-screener/live.ts +23 -5
- package/src/plugins/builtin/equity-screener/model.ts +27 -12
- package/src/plugins/builtin/equity-screener/pane.tsx +5 -5
- package/src/plugins/builtin/exposure/headless.ts +1 -1
- package/src/plugins/builtin/exposure/holdings.ts +2 -2
- package/src/plugins/builtin/futures/index.tsx +29 -1
- package/src/plugins/builtin/futures/model.ts +93 -10
- package/src/plugins/builtin/futures/returns.ts +54 -1
- package/src/plugins/builtin/futures/table.tsx +14 -2
- package/src/plugins/builtin/futures/use-front-returns.ts +20 -3
- package/src/plugins/builtin/futures-curve/client.ts +1 -1
- package/src/plugins/builtin/futures-curve/headless.ts +9 -3
- package/src/plugins/builtin/futures-curve/model.ts +19 -5
- package/src/plugins/builtin/futures-curve/pane.tsx +12 -6
- package/src/plugins/builtin/gpu/headless.ts +1 -1
- package/src/plugins/builtin/gpu/model.ts +1 -1
- package/src/plugins/builtin/help/function-index.ts +16 -8
- package/src/plugins/builtin/help/functions-table.tsx +6 -4
- package/src/plugins/builtin/help/shortcut-model.ts +7 -2
- package/src/plugins/builtin/holders/headless.ts +16 -5
- package/src/plugins/builtin/holders/pane.tsx +43 -5
- package/src/plugins/builtin/insider/client.ts +118 -11
- package/src/plugins/builtin/insider/filing-stories.ts +36 -20
- package/src/plugins/builtin/insider/issuer.ts +5 -2
- package/src/plugins/builtin/iv-history/headless.ts +2 -0
- package/src/plugins/builtin/macro-day/client.ts +2 -3
- package/src/plugins/builtin/macro-day/comparison.ts +58 -0
- package/src/plugins/builtin/macro-day/headless.ts +47 -3
- package/src/plugins/builtin/macro-day/index.tsx +32 -9
- package/src/plugins/builtin/macro-day/model.ts +1 -1
- package/src/plugins/builtin/macro-day/pane.tsx +99 -12
- package/src/plugins/builtin/market-heatmap/index.tsx +2 -2
- package/src/plugins/builtin/market-movers/footer.ts +29 -3
- package/src/plugins/builtin/market-movers/headless.ts +12 -5
- package/src/plugins/builtin/market-movers/index.tsx +3 -3
- package/src/plugins/builtin/market-movers/session-body.tsx +6 -3
- package/src/plugins/builtin/market-valuation/detail.tsx +3 -3
- package/src/plugins/builtin/market-valuation/headless.ts +6 -6
- package/src/plugins/builtin/market-valuation/pane.tsx +2 -3
- package/src/plugins/builtin/market-valuation/view.ts +6 -8
- package/src/plugins/builtin/members/client.ts +9 -2
- package/src/plugins/builtin/members/headless.ts +8 -10
- package/src/plugins/builtin/members/model.ts +29 -17
- package/src/plugins/builtin/members/pane.tsx +10 -12
- package/src/plugins/builtin/money-markets/headless.ts +1 -1
- package/src/plugins/builtin/news/headless.ts +4 -0
- package/src/plugins/builtin/news/index.tsx +3 -1
- package/src/plugins/builtin/news/wire/industry-pane.tsx +2 -1
- package/src/plugins/builtin/news/wire/news/preset-pane.tsx +1 -1
- package/src/plugins/builtin/news/wire/persisted-articles.ts +8 -4
- package/src/plugins/builtin/notes/headless.ts +7 -0
- package/src/plugins/builtin/notes/index.tsx +1 -1
- package/src/plugins/builtin/notes/quick-notes-pane.tsx +18 -2
- package/src/plugins/builtin/options/view.tsx +7 -6
- package/src/plugins/builtin/options-positioning/headless.ts +4 -4
- package/src/plugins/builtin/options-positioning/pane.tsx +7 -3
- package/src/plugins/builtin/options-scenario/client.ts +20 -4
- package/src/plugins/builtin/options-scenario/headless.ts +1 -1
- package/src/plugins/builtin/pe-band/client.ts +5 -9
- package/src/plugins/builtin/pe-band/headless.ts +11 -13
- package/src/plugins/builtin/pe-band/model.ts +39 -60
- package/src/plugins/builtin/pe-band/pane.tsx +14 -15
- package/src/plugins/builtin/perps/equity-row.tsx +3 -1
- package/src/plugins/builtin/perps/freshness.ts +16 -9
- package/src/plugins/builtin/perps/headless.ts +4 -1
- package/src/plugins/builtin/perps/markets-section.tsx +16 -10
- package/src/plugins/builtin/perps/model.ts +33 -2
- package/src/plugins/builtin/perps/pane.tsx +3 -2
- package/src/plugins/builtin/perps/status-line.ts +12 -3
- package/src/plugins/builtin/perps/venue-markets.ts +38 -0
- package/src/plugins/builtin/plugin-marketplace/pane.tsx +4 -3
- package/src/plugins/builtin/portfolio-list/cell-version.ts +1 -1
- package/src/plugins/builtin/portfolio-list/cli/render.ts +46 -7
- package/src/plugins/builtin/portfolio-list/headless.ts +31 -8
- package/src/plugins/builtin/portfolio-list/settings.ts +3 -0
- package/src/plugins/builtin/portfolio-list/table.tsx +7 -1
- package/src/plugins/builtin/power/headless.ts +1 -1
- package/src/plugins/builtin/realized-vol/headless.ts +1 -1
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +27 -13
- package/src/plugins/builtin/scanner/feed.ts +7 -4
- package/src/plugins/builtin/scanner/flow-pane.tsx +8 -4
- package/src/plugins/builtin/scanner/headless.ts +57 -26
- package/src/plugins/builtin/scanner/hilo-pane.tsx +6 -3
- package/src/plugins/builtin/scanner/lock-note.ts +3 -2
- package/src/plugins/builtin/scanner/us-session.ts +9 -0
- package/src/plugins/builtin/seasonality/client.ts +46 -10
- package/src/plugins/builtin/seasonality/headless.ts +29 -11
- package/src/plugins/builtin/seasonality/model.ts +101 -24
- package/src/plugins/builtin/seasonality/pane.tsx +10 -6
- package/src/plugins/builtin/sec/filing-content.ts +13 -0
- package/src/plugins/builtin/sec/index.tsx +16 -11
- package/src/plugins/builtin/sectors/client.ts +27 -5
- package/src/plugins/builtin/sectors/headless.ts +2 -1
- package/src/plugins/builtin/sectors/index.tsx +22 -10
- package/src/plugins/builtin/shared/cloud-resource.ts +3 -3
- package/src/plugins/builtin/shared/extended-print.ts +38 -0
- package/src/plugins/builtin/shared/pro-feature-wall.tsx +1 -1
- package/src/plugins/builtin/shared/report-freshness.ts +7 -3
- package/src/plugins/builtin/shared/scanner-capture.ts +16 -3
- package/src/plugins/builtin/shared/ticker-company.ts +17 -8
- package/src/plugins/builtin/shared/use-quote-board.ts +11 -4
- package/src/plugins/builtin/social-mentions/client.ts +7 -3
- package/src/plugins/builtin/social-mentions/outliers.tsx +9 -2
- package/src/plugins/builtin/thirteenf/api.ts +24 -3
- package/src/plugins/builtin/thirteenf/data.ts +21 -8
- package/src/plugins/builtin/thirteenf/headless.ts +7 -3
- package/src/plugins/builtin/thirteenf/signals-pane.tsx +10 -3
- package/src/plugins/builtin/thirteenf/signals.ts +22 -1
- package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +4 -2
- package/src/plugins/builtin/ticker-detail/financials/model.ts +7 -0
- package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +15 -6
- package/src/plugins/builtin/ticker-detail/financials/ratios.ts +5 -4
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +14 -5
- package/src/plugins/builtin/ticker-detail/headless.ts +32 -26
- package/src/plugins/builtin/ticker-detail/index.tsx +1 -1
- package/src/plugins/builtin/ticker-detail/overview/components.tsx +8 -3
- package/src/plugins/builtin/ticker-detail/overview/model.ts +28 -5
- package/src/plugins/builtin/ticker-detail/overview/pane.tsx +14 -1
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +9 -8
- package/src/plugins/builtin/ticker-detail/pane.tsx +16 -9
- package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +41 -23
- package/src/plugins/builtin/ticker-detail/quote-monitor/rows.ts +30 -13
- package/src/plugins/builtin/ticker-detail/settings.ts +9 -2
- package/src/plugins/builtin/time-sales/headless.ts +49 -13
- package/src/plugins/builtin/time-sales/model.ts +2 -2
- package/src/plugins/builtin/time-sales/window.ts +84 -10
- package/src/plugins/builtin/vol-surface/charts.tsx +4 -2
- package/src/plugins/builtin/vol-surface/events.ts +12 -5
- package/src/plugins/builtin/vol-surface/headless.ts +1 -1
- package/src/plugins/builtin/vol-surface/pane.tsx +15 -7
- package/src/plugins/builtin/world-indices/footer.ts +1 -1
- package/src/plugins/builtin/world-venue-map/chokepoint-report.ts +3 -1
- package/src/plugins/builtin/world-venue-map/headless.ts +27 -13
- package/src/plugins/builtin/yield-curve/client.ts +3 -1
- package/src/plugins/duplicates.ts +60 -0
- package/src/plugins/loader.ts +12 -3
- package/src/plugins/marketplace/model.ts +10 -1
- package/src/portfolio/column-values.ts +52 -5
- package/src/react/async-resource.ts +8 -7
- package/src/renderers/browser/bundled-plugins.ts +2 -1
- package/src/renderers/dom/build-assets.ts +20 -0
- package/src/renderers/dom/data-table/index.tsx +36 -2
- package/src/renderers/dom/es2023-array-methods.ts +57 -0
- package/src/renderers/dom/host/surface-fit.ts +64 -13
- package/src/renderers/dom/styles.css +6 -1
- package/src/renderers/electrobun/bun/external-plugins.ts +16 -6
- package/src/renderers/electrobun/shared/protocol.ts +2 -0
- package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +31 -7
- package/src/renderers/electrobun/view/cli-pane-shot-frame.tsx +15 -8
- package/src/renderers/electrobun/view/external-plugins.ts +1 -0
- package/src/renderers/electrobun/view/remote/asset-data-client.ts +1 -0
- package/src/series/types.ts +1 -0
- package/src/sources/gloomberb-cloud/fred-attribution.ts +6 -5
- package/src/sources/gloomberb-cloud/index.ts +42 -5
- package/src/sources/gloomberb-cloud/news.ts +15 -2
- package/src/sources/gloomberb-cloud/normalizers.ts +9 -0
- package/src/sources/history-result.ts +2 -1
- package/src/sources/history-retention.ts +14 -2
- package/src/sources/listing-symbols.ts +1 -1
- package/src/sources/provider-router/cache.ts +32 -3
- package/src/sources/provider-router/cached-routes.ts +25 -0
- package/src/sources/provider-router/connection-health.ts +1 -0
- package/src/sources/provider-router/history.ts +2 -2
- package/src/sources/provider-router/index.ts +14 -0
- package/src/sources/provider-router/sec-filings-page.ts +25 -0
- package/src/sources/sec-edgar/content.ts +67 -36
- package/src/tickers/listing-fate.ts +28 -0
- package/src/tickers/search/home-listing.ts +3 -0
- package/src/tickers/search/index-root-lead.ts +40 -0
- package/src/tickers/terminal-codes.ts +7 -4
- package/src/time-series/base-series.ts +17 -8
- package/src/time-series/fundamentals/historical-valuation.ts +2 -2
- package/src/time-series/fundamentals/series.ts +15 -12
- package/src/time-series/history-acquisition.ts +2 -0
- package/src/time-series/market.ts +3 -1
- package/src/time-series/price-comparison.ts +3 -1
- package/src/time-series/resolve-context.ts +8 -0
- package/src/time-series/resolve.ts +50 -10
- package/src/time-series/types.ts +1 -0
- package/src/time-series/use-chart-resolution.ts +2 -2
- package/src/time-series/valuation-currency.ts +40 -12
- package/src/types/data-provider.ts +30 -1
- package/src/types/financials.ts +23 -0
- package/src/types/headless.ts +23 -0
- package/src/types/instrument.ts +1 -0
- package/src/utils/crypto-pair.ts +16 -0
- package/src/utils/exchange-announcements.ts +2 -1
- package/src/utils/exchange-notation.generated.ts +58 -1
- package/src/utils/exchanges.ts +43 -1
- package/src/utils/format.ts +37 -2
- package/src/utils/function-search.ts +38 -0
- package/src/utils/fuzzy-search.ts +10 -6
- package/src/utils/option-choice.ts +15 -0
- package/src/utils/price-history.ts +15 -1
- package/src/utils/reason-codes.ts +6 -3
- package/src/utils/trailing-dividend.ts +241 -28
|
@@ -18,8 +18,19 @@ export type DistributionCadence = "monthly" | "quarterly" | "semi-annual" | "ann
|
|
|
18
18
|
export interface CashDistribution {
|
|
19
19
|
exDate: Date;
|
|
20
20
|
amount: number;
|
|
21
|
+
/**
|
|
22
|
+
* The issuer's own dividend announcement form says it is a special (Gloom
|
|
23
|
+
* Cloud's `parts` of an HKEX row): it counts in the trailing year, and is no
|
|
24
|
+
* period of the payer's year nor a payment the forward rate reads.
|
|
25
|
+
*/
|
|
26
|
+
special?: true;
|
|
27
|
+
/** The issuer's own form says what it is, regular or special: a day of such payments is never read as a one-off by its size. */
|
|
28
|
+
formTyped?: true;
|
|
21
29
|
}
|
|
22
30
|
|
|
31
|
+
/** Whether a payment is a special its issuer's form types (CashDistribution.special). */
|
|
32
|
+
const typedSpecial = (payment: { special?: true }) => payment.special === true;
|
|
33
|
+
|
|
23
34
|
const REGULAR_CADENCE: Partial<Record<DistributionCadence, { perYear: number; halfPeriodDays: number }>> = {
|
|
24
35
|
monthly: { perYear: 12, halfPeriodDays: 15 },
|
|
25
36
|
quarterly: { perYear: 4, halfPeriodDays: 45 },
|
|
@@ -41,16 +52,22 @@ export const LATE_GRACE_DAYS = [...new Set(Object.values(REGULAR_CADENCE)
|
|
|
41
52
|
*/
|
|
42
53
|
export const CADENCE_GRACE_DAYS = MAX_LATE_GRACE_DAYS;
|
|
43
54
|
|
|
44
|
-
/**
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
55
|
+
/** A day recurs when one within this many days of a year before paid within RECURRING_BAND of it. */
|
|
56
|
+
const SAME_SLOT_DAYS = 45;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Days after an ex-date at which it is judged off-cycle when nothing was paid
|
|
60
|
+
* in its slot a year on (offCycleTimes): a year and SAME_SLOT_DAYS.
|
|
61
|
+
*/
|
|
62
|
+
export const OFF_CYCLE_DAYS = 365.25 + SAME_SLOT_DAYS;
|
|
63
|
+
|
|
64
|
+
/** Cadence of ex-dates (times, oldest first) in the two years ending at `asOf`. */
|
|
65
|
+
function cadenceOf(times: readonly number[], asOf: Date): DistributionCadence | null {
|
|
66
|
+
const cutoff = calendarMonthsBefore(asOf, 24).getTime();
|
|
50
67
|
// Old suspensions or a former schedule must not redefine a fund's recent cadence.
|
|
51
|
-
let dates =
|
|
68
|
+
let dates = times.filter((time) => time > cutoff);
|
|
52
69
|
// A single ex-date in two years: the one before it, if only days past them, says the cadence.
|
|
53
|
-
if (dates.length === 1) dates =
|
|
70
|
+
if (dates.length === 1) dates = times.filter((time) => time > cutoff - CADENCE_GRACE_DAYS * DAY);
|
|
54
71
|
if (dates.length < 2) return null;
|
|
55
72
|
const avgGapDays = (dates.at(-1)! - dates[0]!) / (dates.length - 1) / DAY;
|
|
56
73
|
if (Math.abs(avgGapDays - 30) < 8) return "monthly";
|
|
@@ -60,6 +77,58 @@ export function inferCadence(payments: readonly Pick<CashDistribution, "exDate">
|
|
|
60
77
|
return "irregular";
|
|
61
78
|
}
|
|
62
79
|
|
|
80
|
+
/**
|
|
81
|
+
* The ex-dates (times, oldest first) that recur in no slot of the payer's
|
|
82
|
+
* year: none was paid within SAME_SLOT_DAYS of a year before one, nor of a
|
|
83
|
+
* year after it, and that year after has passed by `asOf` (OFF_CYCLE_DAYS).
|
|
84
|
+
* Each ex-date pairs with at most one a year before and one a year after, the
|
|
85
|
+
* closest pairs first, so an extra beside a regular one does not share its
|
|
86
|
+
* counterpart. WH Group (0288) pays an interim each August or September and a
|
|
87
|
+
* final each May; its HK$0.30 special of 6 October 2025 recurred in no slot,
|
|
88
|
+
* and counted as a period it read the two years to 23 Nov 2026 as quarterly.
|
|
89
|
+
* Gloom Cloud reads the cadence by the same rule (uneven-regular-payments).
|
|
90
|
+
*/
|
|
91
|
+
function offCycleTimes(times: readonly number[], asOf: Date): Set<number> {
|
|
92
|
+
const at = asOf.getTime();
|
|
93
|
+
// inferCadence's two years and its month further back, and a year and a slot before those for their pairs.
|
|
94
|
+
const read = times.filter((time) => time > at - (731 + CADENCE_GRACE_DAYS + OFF_CYCLE_DAYS) * DAY);
|
|
95
|
+
const pairs: { earlier: number; later: number; distance: number }[] = [];
|
|
96
|
+
for (const [index, earlier] of read.entries()) {
|
|
97
|
+
for (const later of read.slice(index + 1)) {
|
|
98
|
+
const distance = Math.abs((later - earlier) / DAY - 365.25);
|
|
99
|
+
if (distance <= SAME_SLOT_DAYS) pairs.push({ earlier, later, distance });
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const hasLater = new Set<number>();
|
|
103
|
+
const hasEarlier = new Set<number>();
|
|
104
|
+
for (const pair of pairs.sort((left, right) => left.distance - right.distance)) {
|
|
105
|
+
if (hasLater.has(pair.earlier) || hasEarlier.has(pair.later)) continue;
|
|
106
|
+
hasLater.add(pair.earlier);
|
|
107
|
+
hasEarlier.add(pair.later);
|
|
108
|
+
}
|
|
109
|
+
return new Set(read.filter((time) => !hasLater.has(time) && !hasEarlier.has(time) && time + OFF_CYCLE_DAYS * DAY < at));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Cadence of ex-dates in the two years ending at `asOf`, ignoring later
|
|
114
|
+
* payments, read without those that recurred in no slot of the payer's year
|
|
115
|
+
* (offCycleTimes) where the rest show a regular cadence and the twelve months
|
|
116
|
+
* to `asOf` hold no more ex-dates than it pays: an extra is never a period.
|
|
117
|
+
* Where they show none (a history with a hole, the slots of a schedule that
|
|
118
|
+
* moved), or the year paid more often (Ambev's December, June and September),
|
|
119
|
+
* every ex-date is read.
|
|
120
|
+
*/
|
|
121
|
+
export function inferCadence(payments: readonly Pick<CashDistribution, "exDate" | "special">[], asOf: Date): DistributionCadence | null {
|
|
122
|
+
// A special its issuer's form types is no period.
|
|
123
|
+
const times = [...new Set(payments.filter((payment) => payment.exDate <= asOf && !typedSpecial(payment)).map((payment) => payment.exDate.getTime()))]
|
|
124
|
+
.sort((a, b) => a - b);
|
|
125
|
+
const offCycle = offCycleTimes(times, asOf);
|
|
126
|
+
const regular = offCycle.size ? cadenceOf(times.filter((time) => !offCycle.has(time)), asOf) : null;
|
|
127
|
+
const perYear = regular ? REGULAR_CADENCE[regular]?.perYear : undefined;
|
|
128
|
+
const yearStart = calendarMonthsBefore(asOf, 12).getTime();
|
|
129
|
+
return perYear && times.filter((time) => time > yearStart).length <= perYear ? regular : cadenceOf(times, asOf);
|
|
130
|
+
}
|
|
131
|
+
|
|
63
132
|
/**
|
|
64
133
|
* The payments trailing twelve-month cash is made of as known at `asOf`, one
|
|
65
134
|
* per regular period, and how many a year the issuer's cadence pays (null
|
|
@@ -72,12 +141,14 @@ export function inferCadence(payments: readonly Pick<CashDistribution, "exDate">
|
|
|
72
141
|
* payment just past one year is kept while its counterpart is briefly late and
|
|
73
142
|
* the window holds fewer than one year of payments. Irregular cash uses the
|
|
74
143
|
* plain window, so special distributions are neither dropped nor extended.
|
|
144
|
+
* `stated` is a cadence read for the payer elsewhere (statedCadence).
|
|
75
145
|
*/
|
|
76
|
-
export function trailingPayments<Payment extends CashDistribution>(payments: readonly Payment[], asOf: Date): { counted: Payment[]; perYear: number | null; cadence: DistributionCadence | null } {
|
|
77
|
-
|
|
146
|
+
export function trailingPayments<Payment extends CashDistribution>(payments: readonly Payment[], asOf: Date, stated?: DistributionCadence | null): { counted: Payment[]; perYear: number | null; cadence: DistributionCadence | null } {
|
|
147
|
+
// A special its issuer's form types is no period (trailingCashAt counts it in its year).
|
|
148
|
+
const known = payments.filter((payment) => payment.exDate <= asOf && Number.isFinite(payment.amount) && payment.amount > 0 && !typedSpecial(payment))
|
|
78
149
|
.sort((a, b) => a.exDate.getTime() - b.exDate.getTime());
|
|
79
150
|
const cutoff = calendarMonthsBefore(asOf, 12);
|
|
80
|
-
const cadence = inferCadence(known, asOf);
|
|
151
|
+
const cadence = stated ?? inferCadence(known, asOf);
|
|
81
152
|
const regular = cadence ? REGULAR_CADENCE[cadence] : undefined;
|
|
82
153
|
if (!regular) return { counted: known.filter((payment) => payment.exDate > cutoff), perYear: null, cadence };
|
|
83
154
|
|
|
@@ -109,9 +180,25 @@ export function trailingPayments<Payment extends CashDistribution>(payments: rea
|
|
|
109
180
|
return { counted: [...counted, ...late], perYear: regular.perYear, cadence };
|
|
110
181
|
}
|
|
111
182
|
|
|
112
|
-
/**
|
|
183
|
+
/**
|
|
184
|
+
* Trailing twelve-month cash as known at `asOf` (trailingPayments), with the
|
|
185
|
+
* specials the issuer's forms type that went ex in the twelve months
|
|
186
|
+
* (trailingSpecialCash) counted whole.
|
|
187
|
+
*/
|
|
113
188
|
export function trailingCashAt<Payment extends CashDistribution>(payments: readonly Payment[], asOf: Date): number {
|
|
114
|
-
return trailingPayments(payments, asOf).counted.reduce((sum, payment) => sum + payment.amount,
|
|
189
|
+
return trailingPayments(payments, asOf).counted.reduce((sum, payment) => sum + payment.amount, trailingSpecialCash(payments, asOf));
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* The specials the issuer's own forms type (CashDistribution.special) that
|
|
194
|
+
* went ex in the twelve months to `asOf`, summed: what the trailing year
|
|
195
|
+
* holds beside its regular payments. Stella's (1836) HK$0.56 of 19 May 2026,
|
|
196
|
+
* paid beside its HK$0.37 final.
|
|
197
|
+
*/
|
|
198
|
+
export function trailingSpecialCash(payments: readonly CashDistribution[], asOf: Date): number {
|
|
199
|
+
const cutoff = calendarMonthsBefore(asOf, 12);
|
|
200
|
+
return payments.filter((payment) => typedSpecial(payment) && payment.exDate > cutoff && payment.exDate <= asOf
|
|
201
|
+
&& Number.isFinite(payment.amount) && payment.amount > 0).reduce((sum, payment) => sum + payment.amount, 0);
|
|
115
202
|
}
|
|
116
203
|
|
|
117
204
|
/** How many payments trailing cash counts against how many a year the issuer's cadence pays. */
|
|
@@ -126,49 +213,174 @@ export interface TrailingPayments {
|
|
|
126
213
|
* its cadence pays in a year: a hole in the history (ECC's monthly July to
|
|
127
214
|
* September 2026 distributions), a missed or late payment, or a fund under a
|
|
128
215
|
* year old. Null for a full year, an irregular payer and an issuer with no
|
|
129
|
-
* cadence, whose trailing cash is the plain window.
|
|
216
|
+
* cadence, whose trailing cash is the plain window. `stated` is a cadence read
|
|
217
|
+
* for the payer elsewhere (statedCadence).
|
|
130
218
|
*/
|
|
131
|
-
export function trailingPaymentShortfall(payments: readonly CashDistribution[], asOf: Date): TrailingPayments | null {
|
|
132
|
-
const { counted, perYear, cadence } = trailingPayments(payments, asOf);
|
|
219
|
+
export function trailingPaymentShortfall(payments: readonly CashDistribution[], asOf: Date, stated?: DistributionCadence | null): TrailingPayments | null {
|
|
220
|
+
const { counted, perYear, cadence } = trailingPayments(payments, asOf, stated);
|
|
133
221
|
return perYear != null && cadence && counted.length < perYear ? { counted: counted.length, expected: perYear, cadence } : null;
|
|
134
222
|
}
|
|
135
223
|
|
|
136
224
|
/** Over this ratio between a regular payer's largest and smallest payment of a year, no one payment stands for the year. */
|
|
137
225
|
const UNEVEN_PAYMENT_RATIO = 1.5;
|
|
138
226
|
|
|
227
|
+
/** A stated rate annualizes a payment when it is that payment times its cadence's count within this share. */
|
|
228
|
+
const STATED_TOLERANCE = 0.02;
|
|
229
|
+
const STATED_CADENCES = [["annual", 1], ["semi-annual", 2], ["quarterly", 4], ["monthly", 12]] as const;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* The cadence of a young history, its only two ex-dates in the two years to
|
|
233
|
+
* `asOf`, as a stated forward rate reads it (`stated`: the annual rate and the
|
|
234
|
+
* ex-date of the payment it annualizes): the count it annualizes that payment
|
|
235
|
+
* (or the latest) by, within 2%, or two a year where it is the two payments
|
|
236
|
+
* summed. Two ex-dates show one gap, and an interim four months after a final
|
|
237
|
+
* reads as quarterly: CNGR's H line (2579) paid its 2025 final in June 2026
|
|
238
|
+
* and its 2026 interim in September, 107 days apart. Gloom Cloud serves its
|
|
239
|
+
* rate at the frequency the issuer's Shenzhen line shows, twice the HK$0.44
|
|
240
|
+
* interim. Null for a history with fewer, more or older ex-dates, and for a
|
|
241
|
+
* rate that reads no cadence: inferCadence's gap stands.
|
|
242
|
+
*/
|
|
243
|
+
export function statedCadence(payments: readonly CashDistribution[], asOf: Date,
|
|
244
|
+
stated: { annualRate: number; exDate: Date | null } | null): DistributionCadence | null {
|
|
245
|
+
if (!stated || !Number.isFinite(stated.annualRate) || !(stated.annualRate > 0)) return null;
|
|
246
|
+
const paid = payments.filter((payment) => payment.exDate <= asOf && Number.isFinite(payment.amount) && payment.amount > 0 && !typedSpecial(payment));
|
|
247
|
+
const cutoff = calendarMonthsBefore(asOf, 24);
|
|
248
|
+
if (paid.some((payment) => payment.exDate <= cutoff)) return null;
|
|
249
|
+
const days = [...new Set(paid.map((payment) => payment.exDate.getTime()))].sort((a, b) => a - b);
|
|
250
|
+
if (days.length !== 2) return null;
|
|
251
|
+
const amountOn = (day: number) => paid.filter((payment) => payment.exDate.getTime() === day).reduce((sum, payment) => sum + payment.amount, 0);
|
|
252
|
+
const annualizes = (amount: number, count: number) => Math.abs(stated.annualRate / (amount * count) - 1) <= STATED_TOLERANCE;
|
|
253
|
+
const dated = stated.exDate && days.includes(stated.exDate.getTime()) ? stated.exDate.getTime() : days[1]!;
|
|
254
|
+
const cadence = STATED_CADENCES.find(([, count]) => annualizes(amountOn(dated), count));
|
|
255
|
+
if (cadence) return cadence[0];
|
|
256
|
+
return annualizes(amountOn(days[0]!) + amountOn(days[1]!), 1) ? "semi-annual" : null;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/** Over this ratio, a payer's two payments of a year that differ the same way a year before are uneven too. */
|
|
260
|
+
const RECURRING_UNEVEN_RATIO = 1.15;
|
|
261
|
+
|
|
139
262
|
/**
|
|
140
263
|
* A regular payer's payments of the trailing year when they differ widely:
|
|
141
264
|
* exactly as many as its cadence pays, the largest more than 1.5 times the
|
|
142
265
|
* smallest (HSBC's final beside its interims, AstraZeneca's interim beside its
|
|
143
|
-
* final)
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
266
|
+
* final), or a two-a-year payer's interim and final sized apart the same way
|
|
267
|
+
* each year (recurringUneven: Far East Horizon's). Their total is the year's
|
|
268
|
+
* cash, where the latest one annualized is not (HSBA's interim read as 2.17% a
|
|
269
|
+
* year beside the 4.08% it paid). Null for an even year, one with a hole or an
|
|
270
|
+
* extra payment, an annual payer and an irregular one, and for a year that
|
|
271
|
+
* changed level once and kept it (steppedPayments): a cut or a raise is a new
|
|
272
|
+
* rate, not interims beside a final. `next` is the annual rate of a
|
|
273
|
+
* distribution declared after the year's payments, as the stated forward rate
|
|
274
|
+
* annualizes it. `latest` is the newest payment's ex-date. A one-off special
|
|
275
|
+
* is no regular payment (regularPayments).
|
|
151
276
|
*/
|
|
152
277
|
export function unevenRegularPayments(payments: readonly CashDistribution[], asOf: Date, next?: { exDate: Date; annualRate: number } | null): { total: number; latest: Date } | null {
|
|
153
|
-
const
|
|
278
|
+
const regular = regularPayments(payments, asOf);
|
|
279
|
+
const { counted, perYear } = trailingPayments(regular, asOf);
|
|
154
280
|
if (perYear == null || perYear < 2 || counted.length !== perYear) return null;
|
|
155
281
|
const ordered = [...counted].sort((left, right) => left.exDate.getTime() - right.exDate.getTime());
|
|
156
282
|
const amounts = ordered.map((payment) => payment.amount);
|
|
157
|
-
if (Math.max(...amounts) <= UNEVEN_PAYMENT_RATIO * Math.min(...amounts)) return null;
|
|
283
|
+
if (Math.max(...amounts) <= UNEVEN_PAYMENT_RATIO * Math.min(...amounts) && !recurringUneven(ordered, regular)) return null;
|
|
158
284
|
const latest = ordered.at(-1)!.exDate;
|
|
159
285
|
const declared = next && next.exDate > latest && Number.isFinite(next.annualRate) && next.annualRate > 0 ? next.annualRate / perYear : null;
|
|
160
|
-
if (steppedPayments(ordered,
|
|
286
|
+
if (steppedPayments(ordered, regular, declared)) return null;
|
|
161
287
|
return {
|
|
162
288
|
total: atSourcePrecision(amounts.reduce((sum, amount) => sum + amount, 0)),
|
|
163
289
|
latest,
|
|
164
290
|
};
|
|
165
291
|
}
|
|
166
292
|
|
|
293
|
+
/** A day this many times the median of the days in the REGULAR_LOOKBACK_DAYS before it is a one-off, unless it recurs. */
|
|
294
|
+
const SPECIAL_MULTIPLE = 3;
|
|
295
|
+
const REGULAR_LOOKBACK_DAYS = 400;
|
|
296
|
+
/** A day recurs when one within SAME_SLOT_DAYS of a year before paid within RECURRING_BAND of it. */
|
|
297
|
+
const RECURRING_BAND = [2 / 3, 1.5] as const;
|
|
298
|
+
/** Rows of one ex-date this close in amount are one row stated twice, not two distributions. */
|
|
299
|
+
const SAME_AMOUNT_SHARE = 1e-6;
|
|
300
|
+
|
|
301
|
+
const median = (values: readonly number[]) => {
|
|
302
|
+
const sorted = [...values].sort((left, right) => left - right);
|
|
303
|
+
const middle = Math.floor(sorted.length / 2);
|
|
304
|
+
return sorted.length % 2 ? sorted[middle]! : (sorted[middle - 1]! + sorted[middle]!) / 2;
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* The regular distributions paid by `asOf`, one per ex-date (its rows summed,
|
|
309
|
+
* one stated twice counted once), oldest first, without one-offs: a day three
|
|
310
|
+
* times the median of the days in the 400 before it that paid nothing like it
|
|
311
|
+
* a year before. HSBC's final, four and a half times its interims, recurs each
|
|
312
|
+
* March: it is regular. A special its issuer's form types is none, and a day
|
|
313
|
+
* the forms type is never read as a one-off by its size: Stella's (1836)
|
|
314
|
+
* HK$0.37 final of 19 May 2026 is regular beside its HK$0.56 special. Gloom
|
|
315
|
+
* Cloud serves the forward rate by the same rule (its uneven-regular-payments),
|
|
316
|
+
* so DES and DVD agree; keep the two in step.
|
|
317
|
+
*/
|
|
318
|
+
function regularPayments(payments: readonly CashDistribution[], asOf: Date): CashDistribution[] {
|
|
319
|
+
const byDay = new Map<number, number[]>();
|
|
320
|
+
const typedDays = new Set<number>();
|
|
321
|
+
for (const payment of payments) {
|
|
322
|
+
if (payment.exDate > asOf || !Number.isFinite(payment.amount) || !(payment.amount > 0) || typedSpecial(payment)) continue;
|
|
323
|
+
const day = payment.exDate.getTime();
|
|
324
|
+
byDay.set(day, [...byDay.get(day) ?? [], payment.amount]);
|
|
325
|
+
if (payment.formTyped) typedDays.add(day);
|
|
326
|
+
}
|
|
327
|
+
const days = [...byDay].sort(([left], [right]) => left - right).map(([day, amounts]) => {
|
|
328
|
+
const distinct = [...amounts].sort((left, right) => left - right)
|
|
329
|
+
.filter((amount, index, sorted) => index === 0 || amount - sorted[index - 1]! > SAME_AMOUNT_SHARE * amount);
|
|
330
|
+
return { exDate: new Date(day), amount: distinct.reduce((sum, amount) => sum + amount, 0) };
|
|
331
|
+
});
|
|
332
|
+
const dayOf = (payment: CashDistribution) => payment.exDate.getTime() / DAY;
|
|
333
|
+
const recurs = (payment: CashDistribution) => {
|
|
334
|
+
const slot = days.filter((other) => Math.abs(dayOf(other) - (dayOf(payment) - 365.25)) <= SAME_SLOT_DAYS)
|
|
335
|
+
.reduce((sum, other) => sum + other.amount, 0);
|
|
336
|
+
const ratio = payment.amount / slot;
|
|
337
|
+
return slot > 0 && ratio >= RECURRING_BAND[0] && ratio <= RECURRING_BAND[1];
|
|
338
|
+
};
|
|
339
|
+
return days.filter((payment, index) => {
|
|
340
|
+
if (typedDays.has(payment.exDate.getTime())) return true;
|
|
341
|
+
const before = days.slice(0, index).filter((other) => dayOf(payment) - dayOf(other) <= REGULAR_LOOKBACK_DAYS);
|
|
342
|
+
return !(before.length >= 1 && payment.amount >= SPECIAL_MULTIPLE * median(before.map((other) => other.amount)) && !recurs(payment));
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
|
|
167
346
|
/** No payment of `amounts` over 1.5 times another: one level. */
|
|
168
347
|
function evenAmounts(amounts: readonly number[]): boolean {
|
|
169
348
|
return Math.max(...amounts) <= UNEVEN_PAYMENT_RATIO * Math.min(...amounts);
|
|
170
349
|
}
|
|
171
350
|
|
|
351
|
+
/**
|
|
352
|
+
* A two-a-year payer's year (oldest first) whose payments differ by over
|
|
353
|
+
* RECURRING_UNEVEN_RATIO, and whose payments a year before (`history`, the
|
|
354
|
+
* closest to each one's anniversary within half a period) differed the same
|
|
355
|
+
* way: the same one larger, by over that ratio too, the four of them rising
|
|
356
|
+
* and falling. An interim and a final the payer sizes apart each year, not a
|
|
357
|
+
* run of raises or cuts: Far East Horizon (3360) paid HK$0.30 in April 2025
|
|
358
|
+
* and HK$0.25 in September, then HK$0.31 in June 2026 and HK$0.25 in
|
|
359
|
+
* September; its HK$0.25 annualized read 10.0% at HK$4.995 on 23 Nov 2026,
|
|
360
|
+
* beside the 11.2% the year paid.
|
|
361
|
+
*/
|
|
362
|
+
function recurringUneven(year: readonly CashDistribution[], history: readonly CashDistribution[]): boolean {
|
|
363
|
+
const differs = ([first, second]: readonly CashDistribution[]) =>
|
|
364
|
+
Math.max(first!.amount, second!.amount) > RECURRING_UNEVEN_RATIO * Math.min(first!.amount, second!.amount)
|
|
365
|
+
? first!.amount > second!.amount : null;
|
|
366
|
+
if (year.length !== 2) return false;
|
|
367
|
+
const larger = differs(year);
|
|
368
|
+
if (larger === null) return false;
|
|
369
|
+
const halfPeriod = REGULAR_CADENCE["semi-annual"]!.halfPeriodDays * DAY;
|
|
370
|
+
const [first, second] = year.map((payment) => {
|
|
371
|
+
const anniversary = new Date(payment.exDate);
|
|
372
|
+
anniversary.setUTCFullYear(anniversary.getUTCFullYear() - 1);
|
|
373
|
+
const distance = (earlier: CashDistribution) => Math.abs(earlier.exDate.getTime() - anniversary.getTime());
|
|
374
|
+
return history.filter((earlier) => earlier.exDate < year[0]!.exDate && distance(earlier) <= halfPeriod)
|
|
375
|
+
.sort((left, right) => distance(left) - distance(right))[0];
|
|
376
|
+
});
|
|
377
|
+
if (!first || !second || first.exDate >= second.exDate || differs([first, second]) !== larger) return false;
|
|
378
|
+
// Sized apart, the four rise and fall: four that only rise are raises (Ibiden's 5, 7.5, 7.5 and 10 yen).
|
|
379
|
+
const amounts = [first, second, ...year].map((payment) => payment.amount);
|
|
380
|
+
const steps = amounts.slice(1).map((amount, index) => amount - amounts[index]!);
|
|
381
|
+
return steps.some((step) => step > 0) && steps.some((step) => step < 0);
|
|
382
|
+
}
|
|
383
|
+
|
|
172
384
|
/**
|
|
173
385
|
* A year's payments (`year`, oldest first) that changed level once and kept
|
|
174
386
|
* it: every one before the change at one level, every one after at another,
|
|
@@ -207,7 +419,8 @@ function steppedPayments(year: readonly CashDistribution[], history: readonly Ca
|
|
|
207
419
|
* is every year), with at least one of those years in the history.
|
|
208
420
|
*/
|
|
209
421
|
export function combinedPaymentTimes(payments: readonly CashDistribution[]): Set<number> {
|
|
210
|
-
|
|
422
|
+
// A row its issuer's forms split is told apart by them, not guessed.
|
|
423
|
+
const paid = payments.filter((payment) => Number.isFinite(payment.amount) && payment.amount > 0 && !payment.formTyped)
|
|
211
424
|
.sort((left, right) => left.exDate.getTime() - right.exDate.getTime());
|
|
212
425
|
const combined = new Set<number>();
|
|
213
426
|
for (let index = 1; index < paid.length - 1; index += 1) {
|