@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
|
@@ -7,6 +7,7 @@ import { TIME_RANGES, type TimeRange } from "../../time-series/range";
|
|
|
7
7
|
import { CHART_RESOLUTION_STEP_MS, isIntradayResolution, RANGE_HISTORY_RESOLUTION } from "../../time-series/resolution";
|
|
8
8
|
import { yearToDateStartIndex } from "../../market-data/market/year-to-date";
|
|
9
9
|
import { barCloseSession } from "../../market-data/market/bar-period";
|
|
10
|
+
import { regularSessionCloseOn } from "../../market-data/market/freshness";
|
|
10
11
|
import type { EarningsEvent, MarketDataRequestContext, QuoteBatchResult, QuoteSubscriptionTarget, SecFilingItem } from "../../types/data-provider";
|
|
11
12
|
import { companyDataNotes, type CompanyFrom } from "../../types/company-from";
|
|
12
13
|
import type { NewsArticle, NewsFeed, NewsQuery } from "../../news/types";
|
|
@@ -148,7 +149,7 @@ import {
|
|
|
148
149
|
import { historyCoverageNotice, WindowBeforeFirstBarError } from "../../sources/history-coverage";
|
|
149
150
|
import { fetchHistoryResult } from "../../sources/history-result";
|
|
150
151
|
import { settleWithin } from "../../utils/async-deadline";
|
|
151
|
-
import { demergerRuns, demergerSuccessor, hasPriceBreak, historyDemergerNote, withDemergerFlags } from "../history-demergers";
|
|
152
|
+
import { demergerRuns, demergerSuccessor, hasPriceBreak, historyDemergerNote, SPLIT_FLAG, withDemergerFlags, withSplitFlags } from "../history-demergers";
|
|
152
153
|
import type { FxInterventionsPayload } from "../../api-client/fx-interventions";
|
|
153
154
|
import {
|
|
154
155
|
fxInterventionLatestNote, fxInterventionPair, fxInterventionWindowNote, loadFxInterventions, type FxInterventionPair,
|
|
@@ -237,7 +238,7 @@ import {
|
|
|
237
238
|
searchNewsStories,
|
|
238
239
|
wordMeansMore,
|
|
239
240
|
} from "./news-search";
|
|
240
|
-
import { displayTimeZone, formatUtcDayTime, formatUtcTime } from "../../utils/utc-time";
|
|
241
|
+
import { displayTimeZone, formatUtcDayTime, formatUtcTime, localTimeSuffix, parseReportTime } from "../../utils/utc-time";
|
|
241
242
|
import { localReportTiming } from "../../utils/report-timing";
|
|
242
243
|
import { DAY_SO_FAR_TEXT, dailyOrLongerBarSize, withSessionBar } from "../../time-series/session-bar";
|
|
243
244
|
import { requestedBarSize } from "../../time-series/bar-spacing";
|
|
@@ -579,7 +580,7 @@ async function readListedSymbols(
|
|
|
579
580
|
const QUOTE_CSV_SECTION = {
|
|
580
581
|
title: "CSV",
|
|
581
582
|
lines: [
|
|
582
|
-
"Last, Chg%, Prev Close and each extended print are plain numbers. Cur is the currency; currency_or_unit is the unit: the currency, a pair's quote currency per base (JPY per USD for USDJPY=X), index points or pct for a yield. A pre-market, after-hours or overnight print's move is in Pre-Market Chg%, After Hours Chg% or Overnight Chg%, and compare's day range in Day Low and Day High, after the columns the export already had.",
|
|
583
|
+
"Last, Chg%, Prev Close and each extended print are plain numbers. Cur is the currency; currency_or_unit is the unit: the currency, a pair's quote currency per base (JPY per USD for USDJPY=X), index points or pct for a yield. A pre-market, after-hours or overnight print's move is in Pre-Market Chg%, After Hours Chg% or Overnight Chg%, and compare's day range in Day Low and Day High, after the columns the export already had. Updated is when Last was observed (a close beside an extended print, at the venue's close), and each print's own time is in Pre-Market Updated, After Hours Updated or Overnight Updated, last of all.",
|
|
583
584
|
"A row with no figure says why in its status column, never NaN; a symbol with no quote is also named on standard error.",
|
|
584
585
|
"A list from --file or standard input has a row for every line, in its order, one that names no listing with its reason in status; its export adds input, the line as typed, and duplicate_of, the input of an earlier row that is the same listing.",
|
|
585
586
|
],
|
|
@@ -660,7 +661,7 @@ const CHANGE_BASIS_EXPORT_COLUMNS = [
|
|
|
660
661
|
*/
|
|
661
662
|
function quoteTextColumns<Column extends { key: string }>(columns: Column[]): Array<Column | typeof CHANGE_BASIS_COLUMN> {
|
|
662
663
|
const exported = new Set([...CHANGE_BASIS_EXPORT_COLUMNS, ...EXTENDED_CHANGE_EXPORT_COLUMNS, ...DAY_RANGE_EXPORT_COLUMNS, CHANGE_BP_EXPORT_COLUMN,
|
|
663
|
-
...LIST_INPUT_EXPORT_COLUMNS].map((column) => column.key));
|
|
664
|
+
...LIST_INPUT_EXPORT_COLUMNS, ...EXTENDED_TIME_EXPORT_COLUMNS].map((column) => column.key));
|
|
664
665
|
const kept = columns.filter((column) => !exported.has(column.key));
|
|
665
666
|
const at = kept.findIndex((column) => column.key === "changePercent") + 1;
|
|
666
667
|
return [...kept.slice(0, at), CHANGE_BASIS_COLUMN, ...kept.slice(at)];
|
|
@@ -721,6 +722,18 @@ const EXTENDED_CHANGE_EXPORT_COLUMNS = EXTENDED_SESSIONS.map((session) => ({
|
|
|
721
722
|
value: (row: QuoteRow) => row.extendedSession === session ? row.extendedChangePercent : null,
|
|
722
723
|
}));
|
|
723
724
|
|
|
725
|
+
/**
|
|
726
|
+
* When each extended print was observed, as Updated dates Last: SHEL:NYSE's
|
|
727
|
+
* after-hours print at 00:04 UTC beside its 21:00 UTC close. Last of all an
|
|
728
|
+
* export's columns, so one read by position stays where it was; the table
|
|
729
|
+
* puts the time beside the print.
|
|
730
|
+
*/
|
|
731
|
+
const EXTENDED_TIME_EXPORT_COLUMNS = EXTENDED_SESSIONS.map((session) => ({
|
|
732
|
+
key: `${extendedKey(session)}UpdatedAt`,
|
|
733
|
+
header: `${EXTENDED_SESSION_LABELS[session]} Updated`,
|
|
734
|
+
value: (row: QuoteRow) => row.extendedSession === session && row.extendedUpdatedAt ? row.extendedUpdatedAt : null,
|
|
735
|
+
}));
|
|
736
|
+
|
|
724
737
|
/**
|
|
725
738
|
* Why an exported quote row's figures are empty, for its status column: the
|
|
726
739
|
* symbol's failure as the warning says it, or the figure it has no value for.
|
|
@@ -786,7 +799,11 @@ const FEED_COLUMNS = [
|
|
|
786
799
|
},
|
|
787
800
|
// A nominal price names the session it is from ("6 Nov close"), not the last print; JSON keeps both.
|
|
788
801
|
{ key: "updatedAt", header: "Updated", shrink: false, stackPriority: 5,
|
|
789
|
-
format: (value: unknown, row: QuoteRow) =>
|
|
802
|
+
format: (value: unknown, row: QuoteRow) => {
|
|
803
|
+
if (row.nominalLabel) return row.nominalLabel;
|
|
804
|
+
const time = typeof value === "string" ? parseReportTime(value) : null;
|
|
805
|
+
return time ? formatUtcDayTime(time) + (time.dateOnly ? "" : ` UTC${localTimeSuffix(time.time)}`) : "";
|
|
806
|
+
} },
|
|
790
807
|
];
|
|
791
808
|
|
|
792
809
|
/**
|
|
@@ -963,6 +980,9 @@ function quoteRows(results: QuoteCliRecord[], now = Date.now()) {
|
|
|
963
980
|
const closeDate = extended && !result.futuresContract && !quote?.nominalPrice && !quote?.dailyClose ? headlineCloseDate(quote) : null;
|
|
964
981
|
const printedAt = closeDate ? extendedPrintTime(quote) : null;
|
|
965
982
|
const closeBesidePrint = closeDate && printedAt != null ? { date: closeDate, printedAt } : null;
|
|
983
|
+
// Last and an extended print are two observations: a close beside a print is dated by the venue's close, the print by its own time.
|
|
984
|
+
const closedAt = closeBesidePrint ? regularSessionCloseOn(quote?.listingExchangeName || quote?.exchangeName, closeBesidePrint.date) : null;
|
|
985
|
+
const extendedAt = extended ? extendedPrintTime(quote) : null;
|
|
966
986
|
return {
|
|
967
987
|
symbol: quoteRowSymbol(result),
|
|
968
988
|
name: quote?.name || result.listing?.name || "",
|
|
@@ -1004,14 +1024,17 @@ function quoteRows(results: QuoteCliRecord[], now = Date.now()) {
|
|
|
1004
1024
|
source: quote?.dataSource ?? quote?.providerId ?? "",
|
|
1005
1025
|
feed: quoteFeedState(quote, now),
|
|
1006
1026
|
...quote?.priceVenue ? { priceVenue: quote.priceVenue } : {},
|
|
1007
|
-
// When the price Last shows was observed: in a pre-market nothing has traded in, the close it stands at
|
|
1008
|
-
|
|
1027
|
+
// When the price Last shows was observed: in a pre-market nothing has traded in, the close it stands at; beside an
|
|
1028
|
+
// extended print, the close it is, the print keeping its own time in its session's Updated column.
|
|
1029
|
+
updatedAt: closedAt != null ? new Date(closedAt).toISOString() : quote?.lastUpdated ? new Date(quoteHeadlineTime(quote)).toISOString() : "",
|
|
1009
1030
|
input: result.input ?? "",
|
|
1010
1031
|
duplicateOf: result.duplicateOf ?? "",
|
|
1011
1032
|
error: result.error ?? "",
|
|
1012
1033
|
// Last, so a row read by position keeps every field where it was.
|
|
1013
1034
|
changeBasis: predates ? "" : basisLabel(result, now),
|
|
1014
1035
|
changeBasisNote: changeBasisNote(rowChangeBasis(result), now) ?? "",
|
|
1036
|
+
// When the extended print was observed, which Updated (Last's time) is not beside a close.
|
|
1037
|
+
extendedUpdatedAt: extendedAt != null ? new Date(extendedAt).toISOString() : "",
|
|
1015
1038
|
// A price nothing traded at names the venue session it is the nominal close of; the quote keeps its last trade.
|
|
1016
1039
|
...quote?.nominalPrice ? { nominalLabel: nominalSessionLabel(quote) ?? undefined } : {},
|
|
1017
1040
|
// A price with no live quote behind it, the close of the latest daily bar, names that session.
|
|
@@ -1045,7 +1068,11 @@ function newsRows(articles: NewsArticle[]) {
|
|
|
1045
1068
|
// Whole, as exports write it; the text table's line under the row (newsRowNote) runs it together.
|
|
1046
1069
|
summary: article.summary ?? null,
|
|
1047
1070
|
source: article.source,
|
|
1071
|
+
// Its first publication; the service's other times for it kept beside it, as sent.
|
|
1048
1072
|
publishedAt: isoDate(article.publishedAt),
|
|
1073
|
+
lastPublishedAt: article.times?.lastPublishedAt ?? null,
|
|
1074
|
+
firstSeenAt: article.times?.firstSeenAt ?? null,
|
|
1075
|
+
lastSeenAt: article.times?.lastSeenAt ?? null,
|
|
1049
1076
|
topic: article.topic,
|
|
1050
1077
|
tickers: article.tickers.join(","),
|
|
1051
1078
|
url: article.url,
|
|
@@ -1464,9 +1491,11 @@ async function runQuote(rawArgs: string[], ctx: Parameters<CliCommandDef["execut
|
|
|
1464
1491
|
const pair = listingDepositaryPair({ quote: row.quote });
|
|
1465
1492
|
if (!pair) return [];
|
|
1466
1493
|
const receiptSide = isReceiptSide({ quote: row.quote });
|
|
1467
|
-
const
|
|
1494
|
+
const receipt = receiptSide ? null : data.find((other) => other !== row && isReceiptSide({ quote: other.quote })
|
|
1468
1495
|
&& listingDepositaryPair({ quote: other.quote })?.receipt === pair.receipt);
|
|
1469
|
-
|
|
1496
|
+
// Each line by its venue, as the table names it (SHEL:LSE, SHEL:NYSE).
|
|
1497
|
+
const receiptVenue = receipt ? receipt.target.exchange || receipt.quote?.listingExchangeName || receipt.quote?.exchangeName : null;
|
|
1498
|
+
return receiptSide || receipt ? [`${row.target.symbol}: ${depositaryPairText(pair, receiptSide, receiptVenue)}.`] : [];
|
|
1470
1499
|
}),
|
|
1471
1500
|
...endedNotes.flatMap((note) => note ?? []),
|
|
1472
1501
|
// A commodity's word read as a security's ticker (WTI is W&T Offshore, GOLD is Gold.com) names the future it may have meant.
|
|
@@ -1481,7 +1510,7 @@ async function runQuote(rawArgs: string[], ctx: Parameters<CliCommandDef["execut
|
|
|
1481
1510
|
];
|
|
1482
1511
|
const holdsYield = data.some((row) => isYieldIndexSymbol(row.target.symbol));
|
|
1483
1512
|
const columns = [...commandName === "compare" ? compareColumns() : quoteColumns(), ...holdsYield ? [CHANGE_BP_EXPORT_COLUMN] : [],
|
|
1484
|
-
...listInputs ? LIST_INPUT_EXPORT_COLUMNS : []];
|
|
1513
|
+
...listInputs ? LIST_INPUT_EXPORT_COLUMNS : [], ...EXTENDED_TIME_EXPORT_COLUMNS];
|
|
1485
1514
|
// An export of a list read from a file or standard input has a row for every line, in its order: one no listing was
|
|
1486
1515
|
// read for says why in its status, as its line on stderr does. The table keeps a row per listing.
|
|
1487
1516
|
const rows = listInputs && ctx.cliOptions.format !== "text"
|
|
@@ -2258,10 +2287,12 @@ async function loadListingHistory(
|
|
|
2258
2287
|
// One read of the listing's corporate actions serves both, asked only for a share or a fund.
|
|
2259
2288
|
const actions = shareActionsReader(market, listing, instrumentType);
|
|
2260
2289
|
const demerged = await listingDemergerFlags(forming?.rows ?? served, actions);
|
|
2261
|
-
|
|
2262
|
-
//
|
|
2263
|
-
|
|
2264
|
-
const
|
|
2290
|
+
// NFLX's bars across its 10-for-1 split are in post-split shares, as META's FB-era bars say they were FB's, and the
|
|
2291
|
+
// bar it took effect in is flagged. A long list skips the read, as it skips the other lookups.
|
|
2292
|
+
const splits = lookups ? await actions.splits() : [];
|
|
2293
|
+
const flaggedSplits = withSplitFlags(demerged.rows, splits);
|
|
2294
|
+
const data = flaggedSplits.rows;
|
|
2295
|
+
const splitNote = historySplitNote(listing.symbol, flaggedSplits.splits);
|
|
2265
2296
|
const interval = data[0]?.interval ?? null;
|
|
2266
2297
|
// Intraday bars print in UTC, as the charts and time and sales label them, not the host zone.
|
|
2267
2298
|
const intraday = data.some((row) => row.date.length > 10);
|
|
@@ -2277,10 +2308,13 @@ async function loadListingHistory(
|
|
|
2277
2308
|
const source = loaded.sourceName ? { source: loaded.sourceName } : {};
|
|
2278
2309
|
// A coin's volume unit, or what an index's volume counts (a day's total, an intraday count).
|
|
2279
2310
|
const volumeNote = historyVolumeNote(volume, interval, historyVolumeBasis(data));
|
|
2280
|
-
// A window that closed before today is the history asked for: no later bar makes it stale.
|
|
2311
|
+
// A window that closed before today is the history asked for: no later bar makes it stale. The line names the days
|
|
2312
|
+
// its bars run over, as the heading does (a window from a Saturday starts at Monday's bar).
|
|
2313
|
+
const [shownFrom, shownTo] = [data[0]?.date.slice(0, 10), data.at(-1)?.date.slice(0, 10)];
|
|
2314
|
+
const shownDays = !window ? "" : shownFrom && shownTo ? shownFrom === shownTo ? shownFrom : `${shownFrom} to ${shownTo}` : priceWindowText(window);
|
|
2281
2315
|
const freshness = withSavedCopy(window && isPastPriceWindow(window) ? rowsFreshness(data, {
|
|
2282
2316
|
...source,
|
|
2283
|
-
status: "not-a-feed", basis: `${interval ? BAR_INTERVAL_LABELS[interval] : "price"} bars, ${
|
|
2317
|
+
status: "not-a-feed", basis: `${interval ? BAR_INTERVAL_LABELS[interval] : "price"} bars, ${shownDays}`, observedKey: "date", oldest: null,
|
|
2284
2318
|
...(volumeNote ? { note: volumeNote } : {}),
|
|
2285
2319
|
}) : rowsFreshness(data, {
|
|
2286
2320
|
...source,
|
|
@@ -2371,23 +2405,16 @@ async function listingDemergerFlags(
|
|
|
2371
2405
|
}
|
|
2372
2406
|
|
|
2373
2407
|
/**
|
|
2374
|
-
* "Splits in range: NFLX 10-for-1 on 2025-11-17; bars before it are split-adjusted.": the splits
|
|
2375
|
-
*
|
|
2376
|
-
*
|
|
2408
|
+
* "Splits in range: NFLX 10-for-1 on 2025-11-17 (flag split); bars before it are split-adjusted.": the splits a bar is
|
|
2409
|
+
* flagged for (withSplitFlags), which the bars run across in post-split shares, whatever bar size holds them. Null
|
|
2410
|
+
* with none.
|
|
2377
2411
|
*/
|
|
2378
|
-
function historySplitNote(symbol: string,
|
|
2379
|
-
|
|
2380
|
-
const
|
|
2381
|
-
|
|
2382
|
-
const
|
|
2383
|
-
|
|
2384
|
-
.sort((left, right) => left.date.localeCompare(right.date))
|
|
2385
|
-
.flatMap((split) => {
|
|
2386
|
-
const terms = splitShareTerms(split);
|
|
2387
|
-
return terms ? [`${terms.split(",")[0]} on ${split.date.slice(0, 10)}`] : [];
|
|
2388
|
-
});
|
|
2389
|
-
if (inside.length === 0) return null;
|
|
2390
|
-
return `Splits in range: ${symbol} ${inside.join(" and ")}; bars before ${inside.length === 1 ? "it" : "each"} are split-adjusted.`;
|
|
2412
|
+
function historySplitNote(symbol: string, flagged: ReadonlyArray<{ split: SplitAction; barBefore: boolean }>): string | null {
|
|
2413
|
+
if (flagged.length === 0) return null;
|
|
2414
|
+
const named = flagged.map(({ split }) => `${splitShareTerms(split)!.split(",")[0]} on ${split.date.slice(0, 10)}`);
|
|
2415
|
+
// A window that opens on the split's bar has no bar before it to adjust.
|
|
2416
|
+
const adjusted = flagged.some(({ barBefore }) => barBefore) ? `; bars before ${named.length === 1 ? "it" : "each"} are split-adjusted` : "";
|
|
2417
|
+
return `Splits in range: ${symbol} ${named.join(" and ")} (flag ${SPLIT_FLAG})${adjusted}.`;
|
|
2391
2418
|
}
|
|
2392
2419
|
|
|
2393
2420
|
/**
|
|
@@ -3296,9 +3323,15 @@ const NEWS_COLUMNS = [
|
|
|
3296
3323
|
{ key: "url", header: "URL", optional: true },
|
|
3297
3324
|
];
|
|
3298
3325
|
|
|
3299
|
-
/**
|
|
3326
|
+
/**
|
|
3327
|
+
* CSV's columns: the text table's, the story's latest publication and when the service first and last saw it,
|
|
3328
|
+
* and how many routine notices a folded row stands for and since when.
|
|
3329
|
+
*/
|
|
3300
3330
|
const NEWS_EXPORT_COLUMNS = [
|
|
3301
3331
|
...NEWS_COLUMNS,
|
|
3332
|
+
{ key: "lastPublishedAt", header: "Last published" },
|
|
3333
|
+
{ key: "firstSeenAt", header: "First seen" },
|
|
3334
|
+
{ key: "lastSeenAt", header: "Last seen" },
|
|
3302
3335
|
{ key: "routineNotices", header: "Routine notices" },
|
|
3303
3336
|
{ key: "routineSince", header: "Routine since" },
|
|
3304
3337
|
];
|
|
@@ -3774,7 +3807,7 @@ async function printExchangeAnnouncements(
|
|
|
3774
3807
|
let failure: string | null = null;
|
|
3775
3808
|
try {
|
|
3776
3809
|
// HKEX's routine returns are left out after the read, so its list is asked for whole: a buyback files one a day.
|
|
3777
|
-
const limit =
|
|
3810
|
+
const limit = publisher === "HKEXnews" && !all ? 100 : Math.min(count, 50);
|
|
3778
3811
|
payload = await apiClient.getCloudExchangeAnnouncements({ symbol: resolved.symbol, exchange: resolved.exchange, limit });
|
|
3779
3812
|
} catch (error) {
|
|
3780
3813
|
failure = `${publisher} announcements unavailable: ${error instanceof Error ? error.message : String(error)}`;
|
|
@@ -5267,7 +5300,7 @@ export const marketDataCliCommands: BuiltinCliCommandDef[] = [
|
|
|
5267
5300
|
},
|
|
5268
5301
|
{
|
|
5269
5302
|
name: "filings",
|
|
5270
|
-
description: "Fetch recent SEC filings; a listing abroad gets its exchange's announcements page, and ASX
|
|
5303
|
+
description: "Fetch recent SEC filings; a listing abroad gets its exchange's announcements page, and ASX, HKEX or SIX listings get the announcements list",
|
|
5271
5304
|
help: {
|
|
5272
5305
|
group: CLI_COMMAND_GROUPS.companyData,
|
|
5273
5306
|
usage: ["filings <symbol> [--count <n>] [--form <form>] [--all]"],
|
|
@@ -249,7 +249,7 @@ export async function loadOptionsChainOpenInterest(symbol: string, chain: Option
|
|
|
249
249
|
* OI as of Fri 9 Oct`, with `, ~ filled from neighbouring strikes` after the IV when a strike has no quote to solve from.
|
|
250
250
|
* An open interest whose date cannot be established says why. A chain its
|
|
251
251
|
* venue marks says whose marks they are: `Deribit marks: IV and greeks at
|
|
252
|
-
* each expiry's forward, rate 0%; $ is the BTC price at the forward · OI
|
|
252
|
+
* each expiry's forward, rate 0%; $ is the BTC price at the forward · OI as of Thu 22 Oct 22:42 UTC`.
|
|
253
253
|
*/
|
|
254
254
|
export function optionsBasisFootnote(basis: OptionsChainBasis, chain?: OptionsChain): string {
|
|
255
255
|
const parts: string[] = [];
|
|
@@ -261,7 +261,7 @@ export function optionsBasisFootnote(basis: OptionsChainBasis, chain?: OptionsCh
|
|
|
261
261
|
const settles = [...chain.calls, ...chain.puts].map((contract) => settlementStampTime(contract.expiration)).find(Boolean);
|
|
262
262
|
if (settles) parts.push(`expiries settle ${settles}`);
|
|
263
263
|
const asOf = chain.asOf ? Date.parse(chain.asOf) : Number.NaN;
|
|
264
|
-
parts.push(Number.isFinite(asOf) ? `OI
|
|
264
|
+
parts.push(Number.isFinite(asOf) ? `OI as of ${formatUtcTime(new Date(asOf).toISOString())}` : openInterestAsOfLabel(basis.openInterest));
|
|
265
265
|
return parts.join(" · ");
|
|
266
266
|
}
|
|
267
267
|
// An adjusted contract delivers something other than 100 shares: the fund's price values none of it.
|
|
@@ -106,7 +106,7 @@ import {
|
|
|
106
106
|
FRED_VINTAGE_NOTE,
|
|
107
107
|
parseFredChange,
|
|
108
108
|
} from "./fred-series";
|
|
109
|
-
import { fredProvenance,
|
|
109
|
+
import { fredProvenance, fredUpdateTime, notOnFredSource } from "../../sources/gloomberb-cloud/fred-attribution";
|
|
110
110
|
import { followsUsBondMarket, usBondMarketClosedNote } from "../../market-data/us-bond-market";
|
|
111
111
|
import { commandWord } from "../../utils/shell-word";
|
|
112
112
|
|
|
@@ -1005,7 +1005,7 @@ async function printFredSeries(ctx: Parameters<CliCommandDef["execute"]>[1], { s
|
|
|
1005
1005
|
const ahead = fredProvenance(rows.filter((row) => row.value != null && row.date === newestDate), seriesId);
|
|
1006
1006
|
// FRED names the series' publisher when Gloom Cloud passes it on, and when it last updated the series.
|
|
1007
1007
|
const publisher = ahead?.publisher ?? fredPublisher(seriesId, data.info?.source);
|
|
1008
|
-
const
|
|
1008
|
+
const fredUpdatedAt = ahead ? null : fredUpdateTime(data.info, newestDate);
|
|
1009
1009
|
// When the newest figure was released: the report is as of then, `Sep 2026, released Tue 20 Oct`.
|
|
1010
1010
|
const releasedOn = ahead ? undefined : data.observations.find((observation) => observation.date === newestDate)?.releasedOn;
|
|
1011
1011
|
const seriesSource = elsewhere ?? fredCitation(seriesId, data.info?.source);
|
|
@@ -1024,7 +1024,8 @@ async function printFredSeries(ctx: Parameters<CliCommandDef["execute"]>[1], { s
|
|
|
1024
1024
|
...(periodicity ? { periodicity } : {}),
|
|
1025
1025
|
...(releasedOn ? { releasedOn } : {}),
|
|
1026
1026
|
...(publisher ? { publisher } : {}),
|
|
1027
|
-
|
|
1027
|
+
publishedAt: ahead?.publishedAt ?? null,
|
|
1028
|
+
...(fredUpdatedAt ? { fredUpdatedAt } : {}),
|
|
1028
1029
|
}),
|
|
1029
1030
|
}, {
|
|
1030
1031
|
dateKey: "date",
|
|
@@ -1087,23 +1088,23 @@ async function runYieldCurve(rawArgs: string[], ctx: Parameters<CliCommandDef["e
|
|
|
1087
1088
|
previousValue: previous?.value ?? null,
|
|
1088
1089
|
changeBasisPoints: latest?.value != null && previous?.value != null ? toBasisPoints(latest.value - previous.value, 1) : null,
|
|
1089
1090
|
latest,
|
|
1090
|
-
|
|
1091
|
+
fredUpdatedAt: latest?.publisher ? null : fredUpdateTime(data.info, latest?.date),
|
|
1091
1092
|
};
|
|
1092
1093
|
})));
|
|
1093
1094
|
// Tenors whose latest yield FRED does not list yet name the Treasury and when it published them.
|
|
1094
1095
|
const ahead = fredProvenance(results.flatMap((row) => row.latest ? [row.latest] : []));
|
|
1095
1096
|
const shown = results.map((row) => row.date).filter(Boolean).sort().at(-1);
|
|
1096
1097
|
const closedDay = shown ? usBondMarketClosedNote(startDate, shown) : null;
|
|
1097
|
-
|
|
1098
|
-
const
|
|
1099
|
-
const publishedAt = ahead ? ahead.publishedAt : published.every((time) => time != null) ? published.sort().at(-1) : null;
|
|
1098
|
+
const updates = results.flatMap((row) => row.fredUpdatedAt ? [row.fredUpdatedAt] : []);
|
|
1099
|
+
const fredUpdatedAt = updates.length === results.length ? updates.sort().at(-1) : null;
|
|
1100
1100
|
ctx.printResult({
|
|
1101
|
-
data: results.map(({
|
|
1101
|
+
data: results.map(({ fredUpdatedAt: _fredUpdatedAt, latest: _latest, ...row }) => row),
|
|
1102
1102
|
metadata: { startDate },
|
|
1103
1103
|
freshness: rowsFreshness(results, {
|
|
1104
1104
|
source: ahead?.source ?? "FRED", status: "not-a-feed", basis: "daily Treasury yields", observedKey: "date",
|
|
1105
1105
|
...(ahead?.publisher ? { publisher: ahead.publisher } : {}),
|
|
1106
|
-
|
|
1106
|
+
publishedAt: ahead?.publishedAt ?? null,
|
|
1107
|
+
...(fredUpdatedAt ? { fredUpdatedAt } : {}),
|
|
1107
1108
|
}),
|
|
1108
1109
|
}, {
|
|
1109
1110
|
exportIdentity: (row) => ({ symbolOrSeries: String(row.seriesId), currencyOrUnit: "pct", interval: "daily" }),
|
|
@@ -47,6 +47,7 @@ import {
|
|
|
47
47
|
quoteHeadlineTime,
|
|
48
48
|
quoteMarketStateLabel,
|
|
49
49
|
} from "../../market-data/market/status";
|
|
50
|
+
import { formatQuoteBookTime, QUOTE_BOOK_UNDATED } from "../../market-data/quotes/time";
|
|
50
51
|
import type { FuturesContractTermsPayload } from "../../api-client/futures-curve";
|
|
51
52
|
import { changeBasisJson, closeDayLabel, futuresQuoteFromSettle, quoteChangeBasis, quotePreviousCloseDate, quoteSettleText } from "../../market-data/market/change-basis";
|
|
52
53
|
import {
|
|
@@ -111,7 +112,7 @@ import { providerMissReason } from "../../sources/provider-errors";
|
|
|
111
112
|
import { exportEntriesTable, reportFooterLines, type CliReportTables } from "../report-tables";
|
|
112
113
|
import type { ReportFreshness } from "../pane-functions/freshness";
|
|
113
114
|
import { fundamentalsFreshness, quotesFreshness } from "../freshness";
|
|
114
|
-
import { distributionHistory, forwardDividendBasis, forwardDividendMayHaveLapsed, lapsedDividend, noCurrentDividend, TRAILING_DIVIDEND_BASIS, type DistributionHistory, type DividendLapse } from "../../utils/forward-dividend";
|
|
115
|
+
import { distributionHistory, forwardDividendBasis, forwardDividendMayHaveLapsed, lapsedDividend, noCurrentDividend, TRAILING_DIVIDEND_BASIS, UNEVEN_REGULAR_PAYMENTS, type DistributionHistory, type DividendLapse } from "../../utils/forward-dividend";
|
|
115
116
|
import { declaredDividends } from "../../utils/declared-dividends";
|
|
116
117
|
import { atLivePriceEarnings, historyTrailingDividendYield, measuresTrailingYield, statedYearRange } from "../../market-data/quotes/live-valuation";
|
|
117
118
|
import { loadOfferingFilings, loadStatementFilings, resultsReleaseText, statementPeriodText, type StatementFilingsReport } from "../statement-filings";
|
|
@@ -219,9 +220,18 @@ function yearRangeText(quote: Quote, options: MarketFormatOptions): string {
|
|
|
219
220
|
return quote.yearRangeBasis === "daily-bars" ? `${text} (daily bars)` : text;
|
|
220
221
|
}
|
|
221
222
|
|
|
223
|
+
/**
|
|
224
|
+
* The book, whose it is out of the regular session, and when it was quoted or
|
|
225
|
+
* that its source sent no time: `(last quote, Sat 00:55 UTC)`, `(quoted 14:31
|
|
226
|
+
* UTC)`, `(after-hours book, not dated)`. Never the trade's day or time.
|
|
227
|
+
*/
|
|
222
228
|
function bidAskText(quote: Quote, options: MarketFormatOptions): string {
|
|
223
229
|
const text = formatBidAsk(quote.bid, quote.ask, quote.bidSize, quote.askSize, quote.currency, options);
|
|
224
|
-
|
|
230
|
+
if (text === "—") return text;
|
|
231
|
+
const session = quoteBookSessionLabel(quote);
|
|
232
|
+
const time = formatQuoteBookTime(quote);
|
|
233
|
+
const when = !time || time === QUOTE_BOOK_UNDATED || session ? time : `quoted ${time}`;
|
|
234
|
+
const label = [session, when].filter(Boolean).join(", ");
|
|
225
235
|
return label ? `${text} ${cliStyles.muted(`(${label})`)}` : text;
|
|
226
236
|
}
|
|
227
237
|
|
|
@@ -772,7 +782,8 @@ function forwardYieldFigure(
|
|
|
772
782
|
const figure = percentFigure(reportedDividendYield(fundamentals, distributions), formatFractionPercentCell);
|
|
773
783
|
if (fundamentals?.dividendYield == null) return figure;
|
|
774
784
|
const basis = fundamentals.dividendYieldBasis === "forward"
|
|
775
|
-
?
|
|
785
|
+
? fundamentals.dividendRateBasis === "uneven-regular-payments" ? UNEVEN_REGULAR_PAYMENTS
|
|
786
|
+
: forwardDividendBasis(fundamentals.exDividendDate, { declared: distributions?.rows, currency: distributions?.currency })
|
|
776
787
|
: fundamentals.dividendYieldBasis === "trailing" ? TRAILING_DIVIDEND_BASIS : null;
|
|
777
788
|
// A bond fund's says first that it is not the SEC yield on the next line, which its label keeps short.
|
|
778
789
|
const said = [bond ? NOT_SEC_YIELD : null, basis].filter(Boolean).join("; ");
|
|
@@ -1679,6 +1690,7 @@ function buildTickerStructuredData({
|
|
|
1679
1690
|
const runway = burnsCash(computedRunway) ? computedRunway : null;
|
|
1680
1691
|
const yieldIndex = isYieldIndexSymbol(quote?.symbol ?? symbol);
|
|
1681
1692
|
const session = getQuoteSessionFields(quote);
|
|
1693
|
+
const printedAt = session.extendedSession && quote ? extendedPrintTime(quote) : null;
|
|
1682
1694
|
return {
|
|
1683
1695
|
symbol,
|
|
1684
1696
|
listing: { symbol: identity.symbol, exchange: identity.exchange || null, name: identity.name },
|
|
@@ -1703,7 +1715,10 @@ function buildTickerStructuredData({
|
|
|
1703
1715
|
marketState: quote.marketState ?? "",
|
|
1704
1716
|
dataSource: quote.dataSource ?? "",
|
|
1705
1717
|
providerId: quote.providerId ?? "",
|
|
1706
|
-
|
|
1718
|
+
// When Last was observed, as the text's Updated reads it: once the session is over, its close, never the print
|
|
1719
|
+
// after it, which `extendedUpdatedAt` dates.
|
|
1720
|
+
lastUpdated: quote.lastUpdated ? new Date(quoteHeadlineTime(quote)).toISOString() : "",
|
|
1721
|
+
extendedUpdatedAt: printedAt == null ? null : new Date(printedAt).toISOString(),
|
|
1707
1722
|
} : null,
|
|
1708
1723
|
quoteMetadata: financials.quoteMetadata,
|
|
1709
1724
|
// The receipt pair the listing is a side of, and which side.
|
|
@@ -19,6 +19,7 @@ import type { DesktopExternalPluginBundle } from "../renderers/electrobun/shared
|
|
|
19
19
|
import type { HttpProxyRequestEnvelope, HttpProxyResponseEnvelope } from "../utils/http-proxy-response";
|
|
20
20
|
import type { PaneAccessGate } from "./pane-functions/access-gate";
|
|
21
21
|
import { countContentFigures } from "./content-figures";
|
|
22
|
+
import { retrievedAtOf, savedCopyAt, savedCopyShownAt } from "../data/saved-copies";
|
|
22
23
|
import { readVisibleKeyValues } from "./visible-key-values";
|
|
23
24
|
import { rowViewportVisibility, scrollTruncationReasons } from "./scroll-truncation";
|
|
24
25
|
import {
|
|
@@ -62,6 +63,7 @@ export interface DesktopPaneShotIntradayHistory {
|
|
|
62
63
|
|
|
63
64
|
export interface DesktopPaneShotPayload {
|
|
64
65
|
config: AppConfig;
|
|
66
|
+
deviceState?: Array<{ pluginId: string; key: string; value: unknown }>;
|
|
65
67
|
/** Identity of the host provider serving bridged market requests. */
|
|
66
68
|
marketDataProviderId?: string;
|
|
67
69
|
paneId: string;
|
|
@@ -92,6 +94,7 @@ export interface DesktopPaneShotPayload {
|
|
|
92
94
|
/** Broker accounts as last synced, by profile, so a broker portfolio shows its equity and cash. */
|
|
93
95
|
brokerAccounts?: Record<string, BrokerAccount[]>;
|
|
94
96
|
financials: Array<[string, TickerFinancials]>;
|
|
97
|
+
valuationFx?: Array<{ currency: string; first: string; asOf: string; closes: Array<[string, number]> }>;
|
|
95
98
|
instrumentFinancials?: SnapshotMarketData["instrumentFinancials"];
|
|
96
99
|
historyVariants?: SnapshotMarketData["historyVariants"];
|
|
97
100
|
intradayHistories: DesktopPaneShotIntradayHistory[];
|
|
@@ -294,6 +297,8 @@ interface ShotStatusLineVariants {
|
|
|
294
297
|
variants: readonly string[];
|
|
295
298
|
dates?: "data" | "quotes" | null;
|
|
296
299
|
dateEvidence?: readonly (readonly string[])[];
|
|
300
|
+
/** The view dates its data in its own footer, which the capture keeps beside the line. */
|
|
301
|
+
ownStatus?: boolean;
|
|
297
302
|
}
|
|
298
303
|
type ShotStatusLine = (rendered: DesktopPaneShotRenderResult) => ShotStatusLineVariants | null | Promise<ShotStatusLineVariants | null>;
|
|
299
304
|
|
|
@@ -557,7 +562,10 @@ async function answerShotMarketCall(
|
|
|
557
562
|
const operation = typeof payload.operation === "string" ? payload.operation : "";
|
|
558
563
|
const args = Array.isArray(payload.args) ? payload.args : [];
|
|
559
564
|
const data = await bridge.marketData(operation, args);
|
|
560
|
-
|
|
565
|
+
// JSON drops the marks of a copy served again: the page is told when it was saved or read, and marks it back.
|
|
566
|
+
const savedAt = savedCopyAt(data) ?? savedCopyShownAt(data);
|
|
567
|
+
const retrievedAt = savedAt == null ? retrievedAtOf(data) : null;
|
|
568
|
+
return Response.json({ ok: true, data, ...(savedAt != null ? { savedAt } : {}), ...(retrievedAt != null ? { retrievedAt } : {}) });
|
|
561
569
|
} catch (error) {
|
|
562
570
|
return Response.json({ ok: false, error: errorMessage(error) });
|
|
563
571
|
}
|
|
@@ -1360,11 +1368,11 @@ function shotStateText(value: { error?: unknown; empty?: unknown } | undefined):
|
|
|
1360
1368
|
}
|
|
1361
1369
|
|
|
1362
1370
|
/** Draws the first variant that fits the pane footer, and returns what it drew. */
|
|
1363
|
-
async function fitShotStatusLine(session: CdpPage, { variants, dates }: ShotStatusLineVariants): Promise<string | null> {
|
|
1371
|
+
async function fitShotStatusLine(session: CdpPage, { variants, dates, ownStatus }: ShotStatusLineVariants): Promise<string | null> {
|
|
1364
1372
|
const result = await session.send("Runtime.evaluate", {
|
|
1365
1373
|
expression: `(() => {
|
|
1366
1374
|
const fit = window.__GLOOM_CLI_SHOT_FIT_STATUS__;
|
|
1367
|
-
return fit ? fit(${JSON.stringify(variants)}, ${JSON.stringify({ dates: dates ?? null })}) : null;
|
|
1375
|
+
return fit ? fit(${JSON.stringify(variants)}, ${JSON.stringify({ dates: dates ?? null, ...(ownStatus ? { ownStatus } : {}) })}) : null;
|
|
1368
1376
|
})()`,
|
|
1369
1377
|
awaitPromise: true,
|
|
1370
1378
|
returnByValue: true,
|
package/src/cli/export-source.ts
CHANGED
|
@@ -28,6 +28,7 @@ export interface ExportSource {
|
|
|
28
28
|
oldestObservationDate?: string;
|
|
29
29
|
/** When the publisher released the data, when the data states it. */
|
|
30
30
|
publicationTime: string | null;
|
|
31
|
+
fredUpdatedAt?: string;
|
|
31
32
|
/** When the data was retrieved for this export: an ISO instant in UTC. */
|
|
32
33
|
retrievalTime: string;
|
|
33
34
|
/** Refreshing the data failed and a copy saved earlier answered: when it was saved, an ISO instant in UTC. */
|
|
@@ -41,7 +42,8 @@ export function exportSource(freshness: ReportFreshness): ExportSource {
|
|
|
41
42
|
// A figure as of its release is still dated by the period it covers; the release is its publication time.
|
|
42
43
|
observationDate: freshness.referencePeriod ?? freshness.asOf,
|
|
43
44
|
...(freshness.oldestObservation ? { oldestObservationDate: freshness.oldestObservation } : {}),
|
|
44
|
-
publicationTime: freshness.publishedAt
|
|
45
|
+
publicationTime: freshness.publishedAt === undefined ? (freshness.referencePeriod ? freshness.asOf : null) : freshness.publishedAt,
|
|
46
|
+
...(freshness.fredUpdatedAt ? { fredUpdatedAt: freshness.fredUpdatedAt } : {}),
|
|
45
47
|
retrievalTime: freshness.retrievedAt,
|
|
46
48
|
...(freshness.savedAt ? { savedTime: freshness.savedAt } : {}),
|
|
47
49
|
};
|
|
@@ -149,6 +151,36 @@ export function exportIdentityFields(freshness: ReportFreshness, identity: Expor
|
|
|
149
151
|
return Object.fromEntries(EXPORT_IDENTITY_COLUMNS.map((column, index) => [column, cells[index] || null]));
|
|
150
152
|
}
|
|
151
153
|
|
|
154
|
+
function observationLine(source: ExportSource): string {
|
|
155
|
+
return `Observation date: ${source.observationDate ?? NOT_PUBLISHED}`;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** What the observation date says of itself when the rows are dated apart. */
|
|
159
|
+
const DATED_APART = " (the newest row's; each row's as_of is its own)";
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Whether an export's rows are dated apart: their `as_of` cells hold more
|
|
163
|
+
* than one time (Hong Kong's close beside New York's).
|
|
164
|
+
*/
|
|
165
|
+
export function rowsDatedApart(asOf: Iterable<string | null | undefined>): boolean {
|
|
166
|
+
return new Set([...asOf].filter((value): value is string => !!value)).size > 1;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* The closing lines of an export whose rows are dated apart: the observation
|
|
171
|
+
* date says it is the newest row's, so where it is repeated beside every row
|
|
172
|
+
* (CSV's `export_notes`) it never reads as that row's own. Tencent's row of
|
|
173
|
+
* `quote 0700:HKEX XYZ:NYSE --csv`, as of its 08:08 UTC close, read
|
|
174
|
+
* `Observation date: 2026-11-21T00:34:00.055Z`. Its date stays first, so a
|
|
175
|
+
* reader of the line still finds it there.
|
|
176
|
+
*/
|
|
177
|
+
export function withRowsDatedApart(lines: readonly string[], freshness: ReportFreshness): string[] {
|
|
178
|
+
const source = exportSource(freshness);
|
|
179
|
+
if (!source.observationDate) return [...lines];
|
|
180
|
+
const line = observationLine(source);
|
|
181
|
+
return lines.map((each) => each === line ? `${line}${DATED_APART}` : each);
|
|
182
|
+
}
|
|
183
|
+
|
|
152
184
|
/**
|
|
153
185
|
* The lines an export ends with: the source line the text report ends with,
|
|
154
186
|
* then the publisher, observation date (the newest; the oldest follows when
|
|
@@ -164,9 +196,10 @@ export function exportSourceLines(freshness: ReportFreshness): string[] {
|
|
|
164
196
|
return [
|
|
165
197
|
formatFreshnessLine(freshness),
|
|
166
198
|
`Publisher: ${stated(source.publisher)}`,
|
|
167
|
-
|
|
199
|
+
observationLine(source),
|
|
168
200
|
...(source.oldestObservationDate ? [`Oldest observation: ${source.oldestObservationDate}`] : []),
|
|
169
201
|
`Publication time: ${stated(source.publicationTime)}`,
|
|
202
|
+
...(source.fredUpdatedAt ? [`FRED updated: ${source.fredUpdatedAt}`] : []),
|
|
170
203
|
`Retrieval time: ${source.retrievalTime}`,
|
|
171
204
|
...(source.savedTime ? [`Saved time: ${source.savedTime}`] : []),
|
|
172
205
|
];
|
package/src/cli/glossary.ts
CHANGED
|
@@ -463,10 +463,11 @@ export const GLOSSARY: readonly GlossaryEntry[] = [
|
|
|
463
463
|
// Portfolio risk (PORT, and MARS, which opens it on its risk view): the factor table's betas and fits, the tail loss,
|
|
464
464
|
// the drawdown, the stress scenarios, concentration.
|
|
465
465
|
{
|
|
466
|
-
term: "Beta", aliases: ["betas", "factor beta", "market beta", "beta to spy", "exposure", "factor exposure"], functions: ["PORT", "MARS"],
|
|
466
|
+
term: "Beta", aliases: ["betas", "factor beta", "market beta", "beta to spy", "exposure", "factor exposure"], functions: ["GR", "PORT", "MARS"],
|
|
467
467
|
shown: ["beta", "Beta"],
|
|
468
468
|
definition: "How far a basket moves with a factor: a beta of 0.54 to SPY means it rose 0.54% on average for each 1% SPY rose. "
|
|
469
|
-
+ "
|
|
469
|
+
+ "DES uses 1 year of daily price returns vs SPY, the default in GR. GR uses the selected window and second ticker. "
|
|
470
|
+
+ "PORT uses 60 daily returns for portfolio factor beta. Read it with R²: a beta from a weak fit says little about an exposure.",
|
|
470
471
|
},
|
|
471
472
|
{
|
|
472
473
|
term: "R²", aliases: ["r-squared", "r squared", "r2", "coefficient of determination", "goodness of fit", "weak fit"], functions: ["PORT", "MARS"],
|
package/src/cli/helpers.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
formatCurrencyCode,
|
|
5
5
|
formatNumber,
|
|
6
6
|
formatPercentRaw,
|
|
7
|
+
formatTradeSize,
|
|
7
8
|
} from "../utils/format";
|
|
8
9
|
import { formatMarketChangeWithCurrency, formatMarketPriceRange, formatMarketPriceWithCurrency, type MarketFormatOptions } from "../market-data/market/format";
|
|
9
10
|
import { changeBasisLabel, changeBasisNote, printPredatesChangeBasis, quoteChangeBasis } from "../market-data/market/change-basis";
|
|
@@ -136,7 +137,7 @@ export function formatBidAsk(
|
|
|
136
137
|
if (bid == null && ask == null) return "—";
|
|
137
138
|
// A zero size is the vendor's placeholder outside the session, not a quoted size.
|
|
138
139
|
const side = (price: number | undefined, size: number | undefined) => price != null
|
|
139
|
-
? `${formatMarketPriceWithCurrency(price, currency, options)}${size ? ` x ${
|
|
140
|
+
? `${formatMarketPriceWithCurrency(price, currency, options)}${size ? ` x ${formatTradeSize(size)}` : ""}`
|
|
140
141
|
: "—";
|
|
141
142
|
return `${side(bid, bidSize)} / ${side(ask, askSize)}`;
|
|
142
143
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import type { DemergerAction } from "../types/financials";
|
|
1
|
+
import type { DemergerAction, SplitAction } from "../types/financials";
|
|
2
|
+
import { splitShareTerms } from "../market-data/split-terms";
|
|
2
3
|
|
|
3
4
|
/** The flag a bar takes when a business was demerged out of the listing at it. */
|
|
4
5
|
export const DEMERGER_FLAG = "demerger";
|
|
6
|
+
/** The flag the bar a split took effect in takes: the first in post-split shares. */
|
|
7
|
+
export const SPLIT_FLAG = "split";
|
|
5
8
|
|
|
6
9
|
/**
|
|
7
10
|
* A close this far below the one before can be a business leaving the line
|
|
@@ -36,25 +39,53 @@ export function demergerSuccessor(action: Pick<DemergerAction, "successor">): st
|
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
/**
|
|
39
|
-
* The bar a
|
|
40
|
-
* next one when the source has none of it), or the week's or
|
|
41
|
-
* that holds it. -1 when the bars do not reach it
|
|
42
|
+
* The bar a corporate action's ex-date falls in: the daily bar of that
|
|
43
|
+
* session (the next one when the source has none of it), or the week's or
|
|
44
|
+
* month's bar that holds it. -1 when the bars do not reach it, or, with
|
|
45
|
+
* `barBefore`, when no bar comes before it (a demerger's fall needs one).
|
|
42
46
|
*/
|
|
43
|
-
function
|
|
47
|
+
function actionBarIndex(rows: readonly DemergerRow[], exDate: string, barBefore: boolean): number {
|
|
44
48
|
const day = (row: DemergerRow) => row.date.slice(0, 10);
|
|
45
49
|
const interval = rows[0]?.interval;
|
|
50
|
+
const first = barBefore ? 1 : 0;
|
|
46
51
|
if (interval === "1wk" || interval === "1mo") {
|
|
47
52
|
const holding = rows.findLastIndex((row) => day(row) <= exDate);
|
|
48
|
-
if (holding
|
|
53
|
+
if (holding < first) return -1;
|
|
49
54
|
// The last bar holds the ex-date only when its week or month runs over it.
|
|
50
55
|
const start = day(rows[holding]!);
|
|
51
56
|
const within = interval === "1mo" ? start.slice(0, 7) === exDate.slice(0, 7)
|
|
52
57
|
: Date.parse(`${exDate}T00:00:00Z`) - Date.parse(`${start}T00:00:00Z`) < 7 * 86_400_000;
|
|
53
58
|
return holding < rows.length - 1 || within ? holding : -1;
|
|
54
59
|
}
|
|
55
|
-
const
|
|
56
|
-
//
|
|
57
|
-
return first > 0 ?
|
|
60
|
+
const index = rows.findIndex((row) => day(row) >= exDate);
|
|
61
|
+
// An ex-date before the first daily bar is not in the rows, however near.
|
|
62
|
+
return index >= first && (index > 0 || day(rows[0]!) === exDate) ? index : -1;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The rows with the bar each split took effect in flagged `split` (FFAI's
|
|
67
|
+
* 1-for-150 reverse on 2026-07-24), as `history` marks it beside the note
|
|
68
|
+
* naming it, and those splits, oldest first, each with whether a bar comes
|
|
69
|
+
* before its own: a weekly or monthly bar holds the split anywhere in its
|
|
70
|
+
* period, the last one too. A factor no share count states is left to the
|
|
71
|
+
* demerger flag.
|
|
72
|
+
*/
|
|
73
|
+
export function withSplitFlags<Row extends DemergerRow>(rows: readonly Row[], splits: readonly SplitAction[]): {
|
|
74
|
+
rows: Row[];
|
|
75
|
+
splits: Array<{ split: SplitAction; barBefore: boolean }>;
|
|
76
|
+
} {
|
|
77
|
+
const marked = [...rows];
|
|
78
|
+
const flagged: Array<{ split: SplitAction; barBefore: boolean }> = [];
|
|
79
|
+
for (const split of [...splits].sort((left, right) => left.date.localeCompare(right.date))) {
|
|
80
|
+
if (!/^\d{4}-\d{2}-\d{2}/.test(split.date) || !splitShareTerms(split)) continue;
|
|
81
|
+
const index = actionBarIndex(marked, split.date.slice(0, 10), false);
|
|
82
|
+
if (index < 0) continue;
|
|
83
|
+
const row = marked[index]!;
|
|
84
|
+
const codes = (row.flag ?? "").split(",").filter(Boolean);
|
|
85
|
+
if (!codes.includes(SPLIT_FLAG)) marked[index] = { ...row, flag: [...codes, SPLIT_FLAG].join(",") };
|
|
86
|
+
flagged.push({ split, barBefore: index > 0 });
|
|
87
|
+
}
|
|
88
|
+
return { rows: marked, splits: flagged };
|
|
58
89
|
}
|
|
59
90
|
|
|
60
91
|
/**
|
|
@@ -66,7 +97,7 @@ export function withDemergerFlags<Row extends DemergerRow>(rows: readonly Row[],
|
|
|
66
97
|
const marked = [...rows];
|
|
67
98
|
const breaks: Array<{ date: string; action: DemergerAction }> = [];
|
|
68
99
|
for (const action of [...demergers].sort((left, right) => left.exDate.localeCompare(right.exDate))) {
|
|
69
|
-
const index =
|
|
100
|
+
const index = actionBarIndex(marked, action.exDate, true);
|
|
70
101
|
if (index < 0) continue;
|
|
71
102
|
const row = marked[index]!;
|
|
72
103
|
const codes = (row.flag ?? "").split(",").filter(Boolean);
|