@gloom-sh/terminal 0.20.21 → 0.20.23
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 +4 -3
- package/patches/electrobun-devkit@2.0.5.patch +169 -3
- package/src/account/heard-from-question.tsx +6 -4
- package/src/account/heard-from.ts +3 -4
- package/src/api-client/buybacks.ts +108 -0
- package/src/api-client/data.ts +213 -1
- package/src/api-client/dilution.ts +183 -0
- package/src/api-client/earnings.ts +2 -2
- package/src/api-client/equity-screener.ts +7 -0
- package/src/api-client/exchange-announcements.ts +16 -5
- package/src/api-client/exchange-short-balances.ts +24 -0
- package/src/api-client/heard-from.ts +5 -7
- package/src/api-client/hk-cbbc.ts +134 -0
- package/src/api-client/hk-ccass.ts +233 -0
- package/src/api-client/index.ts +55 -3
- package/src/api-client/jpx-short-positions.ts +24 -0
- package/src/api-client/market-discovery.ts +34 -6
- package/src/api-client/members.ts +5 -0
- package/src/api-client/ownership-disclosures.ts +68 -0
- package/src/api-client/paths.ts +2 -2
- package/src/api-client/request.ts +39 -10
- package/src/api-client/revenue-breakdown.ts +6 -2
- package/src/api-client/sfc-short-positions.ts +19 -0
- package/src/api-client/supply-chain.ts +22 -0
- package/src/api-client/taiwan-revenue.ts +134 -0
- package/src/api-client/types/jobs.ts +1 -0
- package/src/api-client/types/ticker-data.ts +3 -1
- package/src/api-client/types/world-venues.ts +1 -0
- package/src/app/language-observer.tsx +6 -1
- package/src/app/pane-runtime/plugin-bindings.ts +9 -4
- package/src/app/runtime/plugin-bindings.ts +20 -2
- package/src/architecture/core-builtin-allowlist.json +2 -2
- package/src/architecture/dom-cell-metrics-allowlist.json +2 -2
- package/src/architecture/dom-text-cuts-allowlist.json +2 -2
- package/src/architecture/floating-promise-allowlist.json +2 -2
- package/src/architecture/pane-tabs-allowlist.json +3 -0
- package/src/brokers/account-cache.ts +2 -1
- package/src/brokers/account-choice.ts +121 -0
- package/src/brokers/broker-portfolio-sync.ts +30 -5
- package/src/brokers/profile-form.ts +3 -0
- package/src/brokers/signed-in/adapter.ts +16 -5
- package/src/brokers/sync-broker-instance.ts +27 -3
- package/src/capabilities/asset-data-inputs.ts +8 -0
- package/src/capabilities/factories.ts +4 -0
- package/src/cli/commands/market.ts +141 -76
- package/src/cli/commands/news-search.ts +12 -0
- package/src/cli/commands/options-chain.ts +9 -3
- package/src/cli/commands/options-leaps.ts +55 -30
- package/src/cli/commands/overview.ts +20 -23
- package/src/cli/commands/search.ts +2 -1
- package/src/cli/commands/ticker.ts +17 -18
- package/src/cli/csv-export.ts +9 -5
- package/src/cli/desktop-pane-shot-browser.ts +143 -53
- package/src/cli/desktop-pane-shot.ts +50 -64
- package/src/cli/export-source.ts +9 -4
- package/src/cli/history-demergers.ts +134 -11
- package/src/cli/history-rows.ts +47 -7
- package/src/cli/listing-arg.ts +45 -18
- package/src/cli/pane-functions/catalog-snapshot.json +26 -22
- package/src/cli/pane-functions/catalog.ts +6 -2
- package/src/cli/pane-functions/data.ts +3 -1
- package/src/cli/pane-functions/dom.ts +8 -5
- package/src/cli/pane-functions/freshness.ts +6 -1
- package/src/cli/pane-functions/function-help.ts +32 -2
- package/src/cli/pane-functions/headless.ts +79 -27
- package/src/cli/pane-functions/index.ts +2 -1
- package/src/cli/pane-functions/market-session.ts +13 -3
- package/src/cli/pane-functions/resolver.ts +4 -1
- package/src/cli/pane-functions/screenshot-assessment.ts +26 -10
- package/src/cli/pane-functions/screenshot-bridge.ts +4 -1
- package/src/cli/pane-functions/screenshot-data-evidence.ts +11 -5
- package/src/cli/pane-functions/screenshot-payload.ts +21 -3
- package/src/cli/pane-functions/screenshot-render.ts +2 -0
- package/src/cli/pane-functions/ticker-question.ts +52 -47
- package/src/cli/rendered-table-rows.ts +75 -0
- package/src/cli/report-tables.ts +7 -1
- package/src/cli/result.ts +9 -2
- package/src/cli/symbol-list.ts +52 -14
- package/src/cli/ticker-resolution.ts +133 -38
- package/src/cli/visible-key-values.ts +3 -2
- package/src/components/chart/composite/composite-chart.tsx +12 -0
- package/src/components/chart/composite/format.ts +14 -1
- package/src/components/chart/composite/panel-surface/panel-cursor.tsx +37 -14
- package/src/components/chart/composite/panel-surface.tsx +1 -0
- package/src/components/chart/composite/text-renderer.ts +104 -44
- package/src/components/chart/composite/types.ts +18 -0
- package/src/components/chart/composite/use-composite-chart-keyboard.ts +38 -15
- package/src/components/chart/curve/model.ts +4 -1
- package/src/components/chart-table/header.tsx +11 -5
- package/src/components/chart-table/selection.ts +20 -1
- package/src/components/command-bar/routes/root/start-here.ts +1 -1
- package/src/components/command-bar/routes/ticker-search/results.ts +2 -1
- package/src/components/data-table/export.ts +3 -1
- package/src/components/data-table/sections.ts +12 -1
- package/src/components/data-table/view.tsx +52 -8
- package/src/components/feed-data-table/stack-view.tsx +88 -5
- package/src/components/index.ts +3 -3
- package/src/components/layout/floating-pane.tsx +5 -2
- package/src/components/layout/pane/header.tsx +33 -32
- package/src/components/layout/pane/index.tsx +6 -2
- package/src/components/layout/pane/link-note.ts +12 -0
- package/src/components/layout/pane/title.ts +1 -3
- package/src/components/market-board/index.tsx +8 -11
- package/src/components/reader/reader-text.tsx +25 -2
- package/src/components/ticker/badge/index.tsx +9 -4
- package/src/components/ticker/badge/list.tsx +3 -1
- package/src/components/ticker/list-table-view.tsx +4 -0
- package/src/components/ui/data-table/column-fit.ts +129 -0
- package/src/components/ui/data-table/display-columns.ts +28 -9
- package/src/components/ui/data-table/index.tsx +64 -16
- package/src/components/ui/data-table/muted-row.tsx +47 -0
- package/src/components/ui/data-table/opentui/index.tsx +47 -11
- package/src/components/ui/data-table/spill.ts +36 -0
- package/src/components/ui/data-table/types.ts +113 -6
- package/src/components/ui/data-table/use-column-order.ts +11 -0
- package/src/components/ui/data-table/visible-range.ts +9 -1
- package/src/components/ui/day-cell.ts +30 -0
- package/src/components/ui/icon.tsx +50 -3
- package/src/components/ui/index.ts +3 -1
- package/src/components/ui/list-view.tsx +2 -2
- package/src/components/ui/prose.tsx +3 -1
- package/src/components/ui/table-layout.ts +220 -6
- package/src/components/ui/terminal-hover-label.tsx +49 -0
- package/src/components/use-pinned-moment.ts +222 -13
- package/src/core/state/app/layout.ts +7 -2
- package/src/core/state/app/state.ts +17 -4
- package/src/core/state/app/types.ts +2 -1
- package/src/data/config/store/legacy-tabs.ts +51 -0
- package/src/data/config/store/node.ts +2 -2
- package/src/data/config/store/normalize.ts +11 -5
- package/src/data/config/store/shared-file.ts +8 -7
- package/src/data/config/store/shared-layout.ts +146 -0
- package/src/data/sqlite/access.ts +90 -12
- package/src/data/sqlite/checkpointer.ts +75 -12
- package/src/data/sqlite/database.ts +18 -1
- package/src/data/sqlite/retry.ts +1 -1
- package/src/docs/load.ts +5 -2
- package/src/docs/snapshot.json +1862 -4456
- package/src/i18n/es.ts +109 -0
- package/src/i18n/index.ts +74 -4
- package/src/i18n/ja.ts +109 -0
- package/src/i18n/ko.ts +109 -0
- package/src/i18n/react.ts +10 -2
- package/src/i18n/zh-cn.ts +109 -0
- package/src/i18n/zh-tw.ts +109 -0
- package/src/layout/pane-manager/dock-normalization.ts +61 -0
- package/src/market-data/ah-pair.ts +7 -2
- package/src/market-data/fund-actions.ts +21 -0
- package/src/market-data/market/freshness.ts +39 -35
- package/src/market-data/market/globex-day.ts +14 -0
- package/src/market-data/market/split-price-basis.ts +55 -0
- package/src/market-data/market/status.ts +2 -4
- package/src/market-data/price-adjustments.ts +115 -0
- package/src/market-data/published-us-sessions.ts +3 -2
- package/src/market-data/quotes/balance-sheet-rate.ts +6 -2
- package/src/market-data/quotes/day-range.ts +24 -9
- package/src/market-data/quotes/freshness.ts +4 -3
- package/src/market-data/quotes/live-valuation.ts +4 -2
- package/src/market-data/quotes/metadata.ts +48 -5
- package/src/market-data/quotes/regular-session-valuation.ts +18 -1
- package/src/market-data/quotes/resolution.ts +18 -29
- package/src/market-data/quotes/time.ts +138 -14
- package/src/news/query-presets.ts +6 -4
- package/src/plugins/builtin/alerts/cli-forms.ts +3 -0
- package/src/plugins/builtin/alerts/cli.ts +19 -7
- package/src/plugins/builtin/alerts/events-pane.tsx +1 -0
- package/src/plugins/builtin/alerts/format.ts +22 -10
- package/src/plugins/builtin/alerts/headless.ts +7 -4
- package/src/plugins/builtin/alerts/history-pane.tsx +93 -36
- package/src/plugins/builtin/alerts/history-rows.ts +24 -1
- package/src/plugins/builtin/alerts/index.tsx +8 -10
- package/src/plugins/builtin/alerts/metric-data.ts +24 -6
- package/src/plugins/builtin/alerts/pane.tsx +9 -0
- package/src/plugins/builtin/alerts/pro-rules.ts +1 -0
- package/src/plugins/builtin/alerts/research-builder.ts +6 -2
- package/src/plugins/builtin/alerts/research-rules.ts +12 -0
- package/src/plugins/builtin/alerts/types.ts +1 -0
- package/src/plugins/builtin/awards/detail.tsx +5 -4
- package/src/plugins/builtin/awards/headless.ts +13 -4
- package/src/plugins/builtin/awards/model.ts +36 -1
- package/src/plugins/builtin/awards/pane.tsx +29 -9
- package/src/plugins/builtin/backtest/pane.tsx +4 -2
- package/src/plugins/builtin/bond-calculator/pane.tsx +2 -1
- package/src/plugins/builtin/broker-manager/detail.tsx +67 -4
- package/src/plugins/builtin/broker-manager/index.tsx +35 -4
- package/src/plugins/builtin/broker-manager/keyboard.ts +10 -0
- package/src/plugins/builtin/broker-manager/pane-actions.tsx +35 -2
- package/src/plugins/builtin/broker-trading/orders.tsx +14 -5
- package/src/plugins/builtin/broker-trading/ticket.tsx +1 -0
- package/src/plugins/builtin/buildout/format.ts +3 -1
- package/src/plugins/builtin/buybacks/client.ts +48 -0
- package/src/plugins/builtin/buybacks/index.tsx +22 -0
- package/src/plugins/builtin/buybacks/model.ts +151 -0
- package/src/plugins/builtin/buybacks/pane.tsx +140 -0
- package/src/plugins/builtin/buybacks/series.ts +36 -0
- package/src/plugins/builtin/catalysts/detail.tsx +14 -8
- package/src/plugins/builtin/catalysts/evidence.ts +11 -3
- package/src/plugins/builtin/catalysts/headless.ts +51 -8
- package/src/plugins/builtin/catalysts/kinds.ts +413 -0
- package/src/plugins/builtin/catalysts/model.ts +61 -18
- package/src/plugins/builtin/catalysts/pane.tsx +85 -19
- package/src/plugins/builtin/cds/client.ts +9 -2
- package/src/plugins/builtin/cds/headless.ts +25 -10
- package/src/plugins/builtin/cds/model.ts +37 -12
- package/src/plugins/builtin/cds/pane.tsx +18 -10
- package/src/plugins/builtin/chart-composer/chart-spec-edit.ts +68 -7
- package/src/plugins/builtin/chart-composer/chart-title.ts +114 -0
- package/src/plugins/builtin/chart-composer/cli-options.ts +1 -1
- package/src/plugins/builtin/chart-composer/headless.ts +13 -1
- package/src/plugins/builtin/chart-composer/index.tsx +2 -68
- package/src/plugins/builtin/chart-composer/leverage-overlay.ts +2 -4
- package/src/plugins/builtin/chart-composer/pane.tsx +11 -3
- package/src/plugins/builtin/chart-composer/presets.ts +1 -1
- package/src/plugins/builtin/chat/attachments/desktop.tsx +46 -12
- package/src/plugins/builtin/chat/channels.ts +5 -2
- package/src/plugins/builtin/chat/content/composer-runtime.ts +64 -65
- package/src/plugins/builtin/chat/content/footer.tsx +17 -7
- package/src/plugins/builtin/chat/content/index.tsx +108 -36
- package/src/plugins/builtin/chat/content/new-dm-dialog.tsx +21 -8
- package/src/plugins/builtin/chat/content/selection-runtime.ts +16 -0
- package/src/plugins/builtin/chat/content/shortcuts.ts +3 -0
- package/src/plugins/builtin/chat/content/snapshot.ts +37 -13
- package/src/plugins/builtin/chat/content/transcript.tsx +12 -0
- package/src/plugins/builtin/chat/content/types.ts +2 -0
- package/src/plugins/builtin/chat/controller/channels.ts +15 -15
- package/src/plugins/builtin/chat/controller/draft-sync.ts +13 -7
- package/src/plugins/builtin/chat/controller/index.ts +140 -34
- package/src/plugins/builtin/chat/controller/lifecycle.ts +8 -12
- package/src/plugins/builtin/chat/controller/persistence.ts +32 -4
- package/src/plugins/builtin/chat/controller/send.ts +41 -17
- package/src/plugins/builtin/chat/controller/session-runtime.ts +28 -27
- package/src/plugins/builtin/chat/controller/state.ts +21 -8
- package/src/plugins/builtin/chat/controller/storage.ts +41 -4
- package/src/plugins/builtin/chat/controller/view.ts +6 -3
- package/src/plugins/builtin/chat/index.tsx +1 -1
- package/src/plugins/builtin/chat/layout.ts +8 -1
- package/src/plugins/builtin/chat/message/desktop.tsx +15 -11
- package/src/plugins/builtin/chat/message/header.tsx +112 -30
- package/src/plugins/builtin/chat/message/reactions.tsx +10 -11
- package/src/plugins/builtin/chat/message/render-state.ts +4 -2
- package/src/plugins/builtin/chat/message/terminal.tsx +13 -15
- package/src/plugins/builtin/chat/message/types.ts +5 -0
- package/src/plugins/builtin/chat/pane-requests.ts +8 -4
- package/src/plugins/builtin/clinical-trials/model.ts +2 -2
- package/src/plugins/builtin/clinical-trials/pane.tsx +3 -3
- package/src/plugins/builtin/cloud/askg/pane.tsx +60 -50
- package/src/plugins/builtin/cloud/auth-actions.tsx +2 -1
- package/src/plugins/builtin/cloud-tweets/table.tsx +25 -2
- package/src/plugins/builtin/comment-letters/pane.tsx +4 -2
- package/src/plugins/builtin/commodity-balances/headless.ts +2 -1
- package/src/plugins/builtin/company-attention/building-model.ts +3 -4
- package/src/plugins/builtin/company-attention/building.tsx +2 -0
- package/src/plugins/builtin/company-attention/headless.ts +2 -2
- package/src/plugins/builtin/company-attention/model.ts +2 -0
- package/src/plugins/builtin/company-attention/moves-model.ts +2 -1
- package/src/plugins/builtin/company-attention/moves.tsx +2 -0
- package/src/plugins/builtin/company-attention/pane.tsx +17 -3
- package/src/plugins/builtin/company-attention/signals-model.ts +3 -4
- package/src/plugins/builtin/company-attention/signals.tsx +5 -0
- package/src/plugins/builtin/company-kpis/headless.ts +26 -10
- package/src/plugins/builtin/company-kpis/model.ts +58 -10
- package/src/plugins/builtin/company-kpis/pane.tsx +36 -19
- package/src/plugins/builtin/company-kpis/taiwan-monthly-model.ts +99 -0
- package/src/plugins/builtin/company-kpis/taiwan-monthly-view.tsx +327 -0
- package/src/plugins/builtin/composite/ownership-browser.ts +28 -0
- package/src/plugins/builtin/composite/ownership.ts +5 -1
- package/src/plugins/builtin/congress-trades/detail.tsx +44 -8
- package/src/plugins/builtin/congress-trades/headless.ts +15 -11
- package/src/plugins/builtin/congress-trades/model.ts +104 -11
- package/src/plugins/builtin/congress-trades/pane.tsx +11 -6
- package/src/plugins/builtin/congress-trades/table.tsx +17 -10
- package/src/plugins/builtin/congress-trades/use-feed.ts +13 -2
- package/src/plugins/builtin/correlation/compute.ts +6 -1
- package/src/plugins/builtin/correlation/headless.ts +2 -2
- package/src/plugins/builtin/correlation/relationship/pane.tsx +11 -8
- package/src/plugins/builtin/correlation/relationship/view-model.ts +1 -19
- package/src/plugins/builtin/cot/headless.ts +1 -1
- package/src/plugins/builtin/cot/pane.tsx +7 -2
- package/src/plugins/builtin/cpi/headless.ts +2 -1
- package/src/plugins/builtin/credit-conditions/headless.ts +2 -1
- package/src/plugins/builtin/credit-documents/detail.tsx +2 -1
- package/src/plugins/builtin/credit-documents/export.ts +18 -12
- package/src/plugins/builtin/credit-documents/model.ts +106 -25
- package/src/plugins/builtin/credit-documents/pane.tsx +9 -5
- package/src/plugins/builtin/crypto-board/defi-view.tsx +2 -1
- package/src/plugins/builtin/crypto-board/defi.ts +5 -4
- package/src/plugins/builtin/crypto-board/headless.ts +7 -2
- package/src/plugins/builtin/crypto-board/model.ts +6 -4
- package/src/plugins/builtin/crypto-board/pane.tsx +2 -1
- package/src/plugins/builtin/crypto-board/supply.ts +4 -3
- package/src/plugins/builtin/crypto-etf-flows/headless.ts +15 -8
- package/src/plugins/builtin/crypto-etf-flows/pane.tsx +6 -5
- package/src/plugins/builtin/custom-view/loader.ts +95 -34
- package/src/plugins/builtin/custom-view/pane.tsx +31 -41
- package/src/plugins/builtin/custom-view/table.ts +201 -0
- package/src/plugins/builtin/debt-maturities/headless.ts +56 -38
- package/src/plugins/builtin/debt-maturities/model.ts +2 -1
- package/src/plugins/builtin/debt-maturities/pane.tsx +24 -22
- package/src/plugins/builtin/dilution/index.tsx +74 -0
- package/src/plugins/builtin/dilution/model.ts +159 -0
- package/src/plugins/builtin/dilution/pane.tsx +592 -0
- package/src/plugins/builtin/dividend-yield/client.ts +14 -17
- package/src/plugins/builtin/dividend-yield/headless.ts +24 -16
- package/src/plugins/builtin/dividend-yield/index.tsx +2 -1
- package/src/plugins/builtin/dividend-yield/model.ts +52 -10
- package/src/plugins/builtin/dividend-yield/pane.tsx +89 -17
- package/src/plugins/builtin/dividend-yield/ranking-view.tsx +6 -2
- package/src/plugins/builtin/dividend-yield/ranking.ts +7 -3
- package/src/plugins/builtin/dividend-yield/types.ts +2 -3
- package/src/plugins/builtin/dividend-yield/view.ts +58 -12
- package/src/plugins/builtin/docs/index.tsx +1 -1
- package/src/plugins/builtin/docs/pane.tsx +7 -3
- package/src/plugins/builtin/docs/use-docs.ts +2 -1
- package/src/plugins/builtin/earnings/board-model.ts +19 -6
- package/src/plugins/builtin/earnings/board-table.ts +64 -48
- package/src/plugins/builtin/earnings/board.tsx +93 -51
- package/src/plugins/builtin/earnings/headless.ts +71 -12
- package/src/plugins/builtin/earnings/history-model.ts +28 -15
- package/src/plugins/builtin/earnings/history.tsx +1 -1
- package/src/plugins/builtin/earnings-calls/calendar.tsx +23 -10
- package/src/plugins/builtin/earnings-calls/format.ts +34 -0
- package/src/plugins/builtin/earnings-calls/headless.ts +5 -4
- package/src/plugins/builtin/earnings-calls/pane.tsx +22 -17
- package/src/plugins/builtin/earnings-calls/transcript-view.tsx +14 -12
- package/src/plugins/builtin/earnings-ripple/pane.tsx +4 -3
- package/src/plugins/builtin/econ/calendar-model.ts +207 -3
- package/src/plugins/builtin/econ/columns.ts +132 -0
- package/src/plugins/builtin/econ/index.tsx +27 -79
- package/src/plugins/builtin/econ-statistics/detail.tsx +2 -2
- package/src/plugins/builtin/econ-statistics/headless.ts +10 -5
- package/src/plugins/builtin/econ-statistics/pane.tsx +6 -3
- package/src/plugins/builtin/econ-statistics/view.ts +15 -4
- package/src/plugins/builtin/equity-screener/client.ts +1 -1
- package/src/plugins/builtin/equity-screener/model.ts +12 -3
- package/src/plugins/builtin/estimate-revisions/headless.ts +23 -2
- package/src/plugins/builtin/estimate-revisions/model.ts +63 -13
- package/src/plugins/builtin/estimate-revisions/pane.tsx +228 -225
- package/src/plugins/builtin/estimate-revisions/sorting.ts +8 -16
- package/src/plugins/builtin/exposure/drivers.ts +5 -2
- package/src/plugins/builtin/exposure/headless.ts +6 -3
- package/src/plugins/builtin/exposure/model.ts +2 -1
- package/src/plugins/builtin/exposure/pane.tsx +16 -7
- package/src/plugins/builtin/fear-greed/format.ts +7 -7
- package/src/plugins/builtin/fear-greed/pane.tsx +21 -7
- package/src/plugins/builtin/futures-curve/headless.ts +14 -9
- package/src/plugins/builtin/futures-curve/model.ts +12 -4
- package/src/plugins/builtin/futures-curve/pane.tsx +18 -15
- package/src/plugins/builtin/fx-matrix/headless.ts +3 -2
- package/src/plugins/builtin/gpu/headless.ts +10 -4
- package/src/plugins/builtin/holders/beneficial-model.ts +1 -1
- package/src/plugins/builtin/holders/beneficial-view.tsx +3 -2
- package/src/plugins/builtin/holders/ccass-market-pane.tsx +363 -0
- package/src/plugins/builtin/holders/ccass-view.tsx +323 -0
- package/src/plugins/builtin/holders/disclosures-view.tsx +66 -0
- package/src/plugins/builtin/holders/disclosures.ts +47 -0
- package/src/plugins/builtin/holders/headless.ts +9 -2
- package/src/plugins/builtin/holders/index.tsx +75 -1
- package/src/plugins/builtin/holders/pane.tsx +37 -10
- package/src/plugins/builtin/holders/report-rows.ts +2 -0
- package/src/plugins/builtin/holders/table-model.ts +14 -6
- package/src/plugins/builtin/holders/types.ts +2 -2
- package/src/plugins/builtin/insider/activity-chart.ts +141 -0
- package/src/plugins/builtin/insider/headless.ts +2 -1
- package/src/plugins/builtin/insider/index.tsx +74 -12
- package/src/plugins/builtin/insider/signals-cells.tsx +15 -8
- package/src/plugins/builtin/insider/signals.tsx +6 -5
- package/src/plugins/builtin/insider/table-model.ts +17 -17
- package/src/plugins/builtin/insider/table.tsx +18 -10
- package/src/plugins/builtin/ipo-calendar/headless.ts +55 -11
- package/src/plugins/builtin/ipo-calendar/listing-ipo.ts +31 -4
- package/src/plugins/builtin/ipo-calendar/model.ts +238 -48
- package/src/plugins/builtin/ipo-calendar/pane.tsx +91 -25
- package/src/plugins/builtin/iv-history/client.ts +17 -8
- package/src/plugins/builtin/iv-history/format.ts +23 -12
- package/src/plugins/builtin/iv-history/headless.ts +9 -5
- package/src/plugins/builtin/iv-history/model.ts +15 -13
- package/src/plugins/builtin/iv-history/pane.tsx +5 -2
- package/src/plugins/builtin/iv-history/screen-pane.tsx +46 -24
- package/src/plugins/builtin/jobs/headless.ts +4 -3
- package/src/plugins/builtin/jobs/pane.tsx +6 -5
- package/src/plugins/builtin/jodi/headless.ts +15 -2
- package/src/plugins/builtin/jodi/model.ts +46 -5
- package/src/plugins/builtin/jodi/pane.tsx +17 -13
- package/src/plugins/builtin/kelly-sizer/headless.ts +11 -4
- package/src/plugins/builtin/kelly-sizer/pane.tsx +19 -9
- package/src/plugins/builtin/kelly-sizer/sections.tsx +2 -1
- package/src/plugins/builtin/kelly-sizer/units.ts +26 -0
- package/src/plugins/builtin/macro-day/pane.tsx +12 -5
- package/src/plugins/builtin/market-halts/model.ts +10 -8
- package/src/plugins/builtin/market-halts/pane.tsx +15 -3
- package/src/plugins/builtin/market-heatmap/data.ts +17 -2
- package/src/plugins/builtin/market-heatmap/headless.ts +56 -6
- package/src/plugins/builtin/market-heatmap/index.tsx +55 -1
- package/src/plugins/builtin/market-heatmap/model.ts +27 -1
- package/src/plugins/builtin/market-movers/model.ts +7 -1
- package/src/plugins/builtin/market-movers/session-table.ts +1 -0
- package/src/plugins/builtin/market-movers/session.ts +1 -1
- package/src/plugins/builtin/market-movers/table.ts +1 -1
- package/src/plugins/builtin/members/headless.ts +13 -5
- package/src/plugins/builtin/members/model.ts +35 -1
- package/src/plugins/builtin/members/pane.tsx +16 -8
- package/src/plugins/builtin/mna/distress/detail.tsx +7 -6
- package/src/plugins/builtin/mna/distress/model.ts +7 -7
- package/src/plugins/builtin/mna/distress/pane.tsx +8 -7
- package/src/plugins/builtin/mna/headless.ts +40 -7
- package/src/plugins/builtin/mna/model.ts +66 -6
- package/src/plugins/builtin/mna/pane.tsx +118 -60
- package/src/plugins/builtin/news/wire/industry-pane.tsx +1 -0
- package/src/plugins/builtin/news/wire/news/row.ts +5 -12
- package/src/plugins/builtin/news/wire/news/table.tsx +46 -44
- package/src/plugins/builtin/notes/index.tsx +2 -1
- package/src/plugins/builtin/openfda/model.ts +1 -1
- package/src/plugins/builtin/openfda/pane.tsx +37 -9
- package/src/plugins/builtin/options/analytics.ts +30 -6
- package/src/plugins/builtin/options/calc-seed.ts +38 -3
- package/src/plugins/builtin/options/footer.ts +18 -1
- package/src/plugins/builtin/options/live-quotes.ts +21 -6
- package/src/plugins/builtin/options/open-interest-as-of.ts +5 -0
- package/src/plugins/builtin/options/quote-context.tsx +21 -8
- package/src/plugins/builtin/options/table.ts +17 -2
- package/src/plugins/builtin/options/view.tsx +97 -46
- package/src/plugins/builtin/options-calculator/model.ts +65 -3
- package/src/plugins/builtin/options-calculator/pane.tsx +11 -3
- package/src/plugins/builtin/options-calculator/valuation.ts +33 -0
- package/src/plugins/builtin/options-positioning/cbbc-model.ts +160 -0
- package/src/plugins/builtin/options-positioning/cbbc-view.tsx +453 -0
- package/src/plugins/builtin/options-positioning/index.tsx +22 -1
- package/src/plugins/builtin/options-positioning/pane.tsx +16 -1
- package/src/plugins/builtin/options-scenario/charts.tsx +2 -1
- package/src/plugins/builtin/options-scenario/csp-screen-headless.ts +5 -5
- package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +11 -14
- package/src/plugins/builtin/options-scenario/csp-screen.ts +9 -1
- package/src/plugins/builtin/options-scenario/headless.ts +3 -3
- package/src/plugins/builtin/options-scenario/index.tsx +1 -1
- package/src/plugins/builtin/options-scenario/model.ts +7 -0
- package/src/plugins/builtin/options-scenario/pane.tsx +24 -14
- package/src/plugins/builtin/pe-band/headless.ts +1 -1
- package/src/plugins/builtin/pe-band/model.ts +41 -18
- package/src/plugins/builtin/pe-band/pane.tsx +8 -6
- package/src/plugins/builtin/perps/cascade-tabs.tsx +2 -1
- package/src/plugins/builtin/perps/cascade.ts +4 -3
- package/src/plugins/builtin/perps/equity-row.tsx +4 -6
- package/src/plugins/builtin/perps/headless.ts +19 -12
- package/src/plugins/builtin/perps/markets-section.tsx +19 -15
- package/src/plugins/builtin/perps/model.ts +14 -5
- package/src/plugins/builtin/portfolio-list/cached-account.ts +3 -1
- package/src/plugins/builtin/portfolio-list/cli/import-positions.ts +6 -18
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +1 -1
- package/src/plugins/builtin/portfolio-list/pane/purchase-date-fx.ts +1 -1
- package/src/plugins/builtin/portfolio-list/positions-import/index.tsx +1 -1
- package/src/plugins/builtin/portfolio-list/positions-import/lookup.ts +28 -57
- package/src/plugins/builtin/portfolio-list/settings.ts +4 -3
- package/src/plugins/builtin/portfolio-list/table.tsx +19 -2
- package/src/plugins/builtin/power/client.ts +2 -2
- package/src/plugins/builtin/power/detail.tsx +11 -8
- package/src/plugins/builtin/power/gas-model.ts +2 -1
- package/src/plugins/builtin/power/gas.tsx +3 -2
- package/src/plugins/builtin/power/headless.ts +4 -1
- package/src/plugins/builtin/power/model.ts +19 -0
- package/src/plugins/builtin/power/pane.tsx +5 -4
- package/src/plugins/builtin/power/prices-headless.ts +4 -3
- package/src/plugins/builtin/power/prices.tsx +7 -6
- package/src/plugins/builtin/primary-dealers/headless.ts +1 -1
- package/src/plugins/builtin/primary-dealers/model.ts +2 -1
- package/src/plugins/builtin/rate-path/headless.ts +5 -2
- package/src/plugins/builtin/rate-path/pane.tsx +13 -10
- package/src/plugins/builtin/realized-vol/fx-proxy.ts +7 -8
- package/src/plugins/builtin/realized-vol/headless.ts +3 -4
- package/src/plugins/builtin/realized-vol/pane.tsx +5 -4
- package/src/plugins/builtin/relative-rotation/headless.ts +2 -1
- package/src/plugins/builtin/research/analyst-model.ts +1 -1
- package/src/plugins/builtin/research/analyst-pane.tsx +2 -1
- package/src/plugins/builtin/research/earnings-estimates-pane.tsx +262 -0
- package/src/plugins/builtin/research/event-charts.ts +322 -0
- package/src/plugins/builtin/research/event-data.ts +140 -0
- package/src/plugins/builtin/research/event-detail.tsx +442 -0
- package/src/plugins/builtin/research/event-model.ts +338 -39
- package/src/plugins/builtin/research/event-sources.ts +58 -8
- package/src/plugins/builtin/research/event-views.tsx +397 -0
- package/src/plugins/builtin/research/events-headless.ts +60 -4
- package/src/plugins/builtin/research/headless-schema.ts +2 -2
- package/src/plugins/builtin/research/headless.ts +84 -7
- package/src/plugins/builtin/research/index.tsx +19 -17
- package/src/plugins/builtin/research/relative-valuation-columns.ts +39 -14
- package/src/plugins/builtin/research/relative-valuation-headless.ts +9 -5
- package/src/plugins/builtin/research/relative-valuation-model.ts +23 -8
- package/src/plugins/builtin/research/relative-valuation-pane.tsx +10 -0
- package/src/plugins/builtin/revenue-breakdown/client.ts +9 -4
- package/src/plugins/builtin/revenue-breakdown/headless.ts +1 -1
- package/src/plugins/builtin/revenue-breakdown/index.tsx +2 -1
- package/src/plugins/builtin/revenue-breakdown/model.ts +2 -0
- package/src/plugins/builtin/revenue-breakdown/pane.tsx +10 -0
- package/src/plugins/builtin/risk-factors/pane.tsx +14 -9
- package/src/plugins/builtin/scanner/flow-pane.tsx +10 -0
- package/src/plugins/builtin/scanner/headless.ts +2 -0
- package/src/plugins/builtin/scanner/lock-note.ts +5 -9
- package/src/plugins/builtin/sec/exchange-filings.ts +69 -0
- package/src/plugins/builtin/sec/fund-facts.ts +10 -8
- package/src/plugins/builtin/sec/headless.ts +60 -8
- package/src/plugins/builtin/sec/index.tsx +169 -61
- package/src/plugins/builtin/sec/model.ts +10 -4
- package/src/plugins/builtin/sec/row-summaries.ts +1 -0
- package/src/plugins/builtin/series-inventory.ts +4 -0
- package/src/plugins/builtin/shared/beat-miss-chart.ts +66 -0
- package/src/plugins/builtin/shared/day-entries.ts +41 -0
- package/src/plugins/builtin/shared/earnings-calendar.ts +80 -53
- package/src/plugins/builtin/shared/earnings-report.ts +53 -15
- package/src/plugins/builtin/shared/history-span.ts +2 -1
- package/src/plugins/builtin/shared/locked-rows.tsx +1 -1
- package/src/plugins/builtin/shared/pro-lock-note.ts +8 -12
- package/src/plugins/builtin/shared/report-freshness.ts +4 -1
- package/src/plugins/builtin/shared/ticker-request.ts +4 -2
- package/src/plugins/builtin/shared/volatility/live-session.ts +6 -7
- package/src/plugins/builtin/shared/volatility/option-snapshot.ts +30 -0
- package/src/plugins/builtin/shared/volatility/quote-session.ts +49 -0
- package/src/plugins/builtin/short-interest/exchange-balances.ts +76 -0
- package/src/plugins/builtin/short-interest/exchange-positions-pane.tsx +55 -0
- package/src/plugins/builtin/short-interest/headless.ts +15 -2
- package/src/plugins/builtin/short-interest/index.tsx +7 -3
- package/src/plugins/builtin/short-interest/jpx.ts +38 -0
- package/src/plugins/builtin/short-interest/model.ts +3 -2
- package/src/plugins/builtin/short-interest/pane.tsx +4 -3
- package/src/plugins/builtin/short-interest/publications-model.ts +73 -2
- package/src/plugins/builtin/short-interest/publications-pane.tsx +16 -4
- package/src/plugins/builtin/short-interest/sfc.ts +40 -0
- package/src/plugins/builtin/short-interest/surface.tsx +16 -2
- package/src/plugins/builtin/short-volume/headless.ts +18 -3
- package/src/plugins/builtin/short-volume/model.ts +6 -1
- package/src/plugins/builtin/short-volume/pane.tsx +8 -7
- package/src/plugins/builtin/short-volume/sgx.ts +23 -0
- package/src/plugins/builtin/social-mentions/outliers-model.ts +2 -1
- package/src/plugins/builtin/social-mentions/pane.tsx +10 -8
- package/src/plugins/builtin/supply-chain/client.ts +10 -2
- package/src/plugins/builtin/supply-chain/directories.ts +18 -0
- package/src/plugins/builtin/supply-chain/evidence.ts +12 -4
- package/src/plugins/builtin/supply-chain/headless.ts +20 -7
- package/src/plugins/builtin/supply-chain/pane.tsx +40 -11
- package/src/plugins/builtin/thirteenf/api.ts +299 -31
- package/src/plugins/builtin/thirteenf/data.ts +126 -32
- package/src/plugins/builtin/thirteenf/format.ts +4 -6
- package/src/plugins/builtin/thirteenf/headless.ts +68 -29
- package/src/plugins/builtin/thirteenf/model.ts +24 -11
- package/src/plugins/builtin/thirteenf/overlap-pane.tsx +16 -8
- package/src/plugins/builtin/thirteenf/pane.tsx +45 -22
- package/src/plugins/builtin/thirteenf/report-notes.ts +52 -2
- package/src/plugins/builtin/thirteenf/session-scope.ts +57 -0
- package/src/plugins/builtin/thirteenf/signals-pane.tsx +17 -4
- package/src/plugins/builtin/thirteenf/split-history.ts +119 -0
- package/src/plugins/builtin/thirteenf/table.ts +6 -6
- package/src/plugins/builtin/thirteenf/types.ts +17 -1
- package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +11 -0
- package/src/plugins/builtin/ticker-detail/data-panes/historical-prices.tsx +12 -8
- package/src/plugins/builtin/ticker-detail/data-panes/history-bars.ts +5 -4
- package/src/plugins/builtin/ticker-detail/data-panes/returns-model.ts +7 -0
- package/src/plugins/builtin/ticker-detail/data-panes/returns-pane.tsx +12 -5
- package/src/plugins/builtin/ticker-detail/financials/aggregation.ts +35 -5
- package/src/plugins/builtin/ticker-detail/financials/exchange-table.tsx +61 -0
- package/src/plugins/builtin/ticker-detail/financials/model.ts +210 -43
- package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +69 -8
- package/src/plugins/builtin/ticker-detail/financials/ratios.ts +64 -10
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +132 -68
- package/src/plugins/builtin/ticker-detail/headless.ts +37 -13
- package/src/plugins/builtin/ticker-detail/overview/components.tsx +75 -14
- package/src/plugins/builtin/ticker-detail/overview/model.ts +87 -35
- package/src/plugins/builtin/ticker-detail/overview/pane.tsx +14 -8
- package/src/plugins/builtin/ticker-detail/overview/types.ts +2 -0
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +50 -17
- package/src/plugins/builtin/ticker-detail/pane.tsx +5 -3
- package/src/plugins/builtin/ticker-detail/research-groups.ts +15 -2
- package/src/plugins/builtin/ticker-detail/research-tabs.ts +2 -1
- package/src/plugins/builtin/time-sales/headless.ts +3 -3
- package/src/plugins/builtin/time-sales/model.ts +16 -9
- package/src/plugins/builtin/time-sales/pane.tsx +27 -24
- package/src/plugins/builtin/trace-bonds/pane.tsx +3 -2
- package/src/plugins/builtin/treasury-auctions/cache.ts +44 -19
- package/src/plugins/builtin/treasury-auctions/client.ts +9 -4
- package/src/plugins/builtin/treasury-daily/client.ts +43 -9
- package/src/plugins/builtin/treasury-daily/pane.tsx +48 -27
- package/src/plugins/builtin/treasury-daily/resource.ts +33 -0
- package/src/plugins/builtin/vol-surface/charts.tsx +3 -1
- package/src/plugins/builtin/vol-surface/events.ts +8 -5
- package/src/plugins/builtin/vol-surface/evidence.ts +2 -2
- package/src/plugins/builtin/vol-surface/headless.ts +46 -28
- package/src/plugins/builtin/vol-surface/heat-grid.tsx +2 -1
- package/src/plugins/builtin/vol-surface/model.ts +34 -9
- package/src/plugins/builtin/vol-surface/pane.tsx +35 -67
- package/src/plugins/builtin/vol-surface/quote-coverage.ts +68 -0
- package/src/plugins/builtin/vol-surface/tables.ts +57 -6
- package/src/plugins/builtin/volatility/charts.tsx +7 -3
- package/src/plugins/builtin/volatility/headless.ts +5 -5
- package/src/plugins/builtin/volatility/pane.tsx +8 -5
- package/src/plugins/builtin/world-indices/headless.ts +5 -3
- package/src/plugins/builtin/world-venue-map/headless.ts +15 -1
- package/src/plugins/builtin/world-venue-map/layered-pane.tsx +5 -3
- package/src/plugins/builtin/world-venue-map/pane.tsx +4 -3
- package/src/plugins/builtin/world-venue-map/venue-exceptions.ts +72 -0
- package/src/plugins/builtin/world-venue-map/venue-header.tsx +20 -11
- package/src/plugins/builtin/yield-curve/headless.ts +4 -2
- package/src/plugins/builtin/yield-curve/index.tsx +4 -3
- package/src/plugins/catalog-browser.ts +3 -34
- package/src/plugins/marketplace/feed.ts +3 -2
- package/src/plugins/registry/contributions.ts +37 -10
- package/src/plugins/registry/index.ts +2 -1
- package/src/portfolio/column-values.ts +8 -9
- package/src/portfolio/positions-import/parse.ts +14 -6
- package/src/portfolio/positions-import/plan.ts +3 -2
- package/src/public/__snapshots__/public-api.test.ts.snap +5 -0
- package/src/public/i18n.ts +3 -2
- package/src/react/async-resource.ts +3 -1
- package/src/renderers/dom/css.d.ts +1 -0
- package/src/renderers/dom/data-table/index.tsx +100 -8
- package/src/renderers/dom/data-table/row.tsx +40 -4
- package/src/renderers/dom/desktop/icons.tsx +147 -3
- package/src/renderers/dom/desktop/popover.tsx +2 -2
- package/src/renderers/dom/host/media-surface.tsx +204 -45
- package/src/renderers/dom/host/tabs.tsx +1 -0
- package/src/renderers/dom/styles.css +14 -2
- package/src/renderers/electrobun/bun/desktop/backend.ts +14 -1
- package/src/renderers/electrobun/bun/desktop/rpc-timing.ts +9 -3
- package/src/renderers/electrobun/shared/protocol.ts +2 -0
- package/src/renderers/electrobun/view/backend-rpc.ts +5 -2
- package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +7 -1
- package/src/renderers/electrobun/view/remote/asset-data-client.ts +2 -0
- package/src/renderers/electrobun/view/rpc-timeout.ts +44 -3
- package/src/sources/gloomberb-cloud/batched-lookups.ts +12 -1
- package/src/sources/gloomberb-cloud/index.ts +44 -10
- package/src/sources/gloomberb-cloud/normalizers.ts +8 -2
- package/src/sources/listing-symbols.ts +7 -1
- package/src/sources/provider-router/cache.ts +5 -4
- package/src/sources/provider-router/financials.ts +44 -22
- package/src/sources/provider-router/index.ts +9 -1
- package/src/state/app/context/index.tsx +12 -4
- package/src/state/app/tab-cursor.ts +47 -6
- package/src/sync/broker-instances.ts +63 -11
- package/src/sync/config-merge.ts +1 -1
- package/src/sync/sanitize.ts +2 -0
- package/src/telemetry/stall-clocks.ts +3 -0
- package/src/telemetry/stall-reports.ts +12 -3
- package/src/telemetry/windows-process-activity.ts +41 -0
- package/src/telemetry/windows-time.ts +32 -0
- package/src/test-support/cloud-api.ts +34 -0
- package/src/test-support/scoped-earnings.ts +24 -0
- package/src/test-support/strict-table-capture.tsx +83 -0
- package/src/tickers/search/index.ts +23 -7
- package/src/tickers/terminal-codes.ts +1 -6
- package/src/time-series/alignment.ts +14 -4
- package/src/time-series/base-series.ts +5 -4
- package/src/time-series/chart-data.ts +2 -0
- package/src/time-series/chart-seed.ts +3 -1
- package/src/time-series/daily-valuation.ts +13 -6
- package/src/time-series/filed-trailing-eps.ts +16 -3
- package/src/time-series/fundamentals/current-valuation.ts +30 -5
- package/src/time-series/fundamentals/historical-valuation.ts +20 -0
- package/src/time-series/fundamentals/history-link.ts +25 -0
- package/src/time-series/fundamentals/quarterly-ttm.ts +50 -5
- package/src/time-series/fundamentals/series.ts +13 -1
- package/src/time-series/market.ts +30 -4
- package/src/time-series/price-comparison.ts +39 -60
- package/src/time-series/resolve.ts +18 -11
- package/src/time-series/spec.ts +2 -1
- package/src/time-series/studies/formula.ts +4 -2
- package/src/time-series/studies/indicators.ts +2 -0
- package/src/time-series/studies/pair.ts +4 -2
- package/src/time-series/studies/shared.ts +1 -0
- package/src/time-series/types.ts +2 -1
- package/src/time-series/use-chart-resolution.ts +32 -14
- package/src/time-series/valuation-currency.ts +2 -0
- package/src/types/config.ts +13 -61
- package/src/types/data-provider.ts +8 -0
- package/src/types/financials.ts +94 -15
- package/src/types/headless.ts +30 -0
- package/src/types/plugin-context.ts +8 -1
- package/src/ui/dialog-context.ts +8 -0
- package/src/utils/crypto-pair.ts +10 -0
- package/src/utils/datetime-format.ts +23 -1
- package/src/utils/day-format.ts +104 -0
- package/src/utils/declared-dividends.ts +12 -2
- package/src/utils/exchange-announcements.ts +38 -12
- package/src/utils/exchange-notation.generated.ts +3 -1
- package/src/utils/exchanges.ts +2 -1
- package/src/utils/financial-statements.ts +40 -46
- package/src/utils/format.ts +39 -12
- package/src/utils/forward-dividend.ts +2 -1
- package/src/utils/fundamentals.ts +1 -0
- package/src/utils/main-thread-stall.ts +9 -1
- package/src/utils/rpc-timeout-error.ts +36 -11
- package/src/utils/sec.ts +3 -1
- package/src/utils/share-multiples.ts +1 -1
- package/src/utils/stall-process-activity.ts +70 -0
- package/src/utils/statement-scope.ts +103 -0
- package/src/utils/trailing-dividend.ts +47 -0
- package/src/utils/trailing-eps.ts +1 -1
- package/src/utils/zoned-date-time.ts +1 -0
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +0 -771
|
@@ -18,6 +18,7 @@ export function dailyValuationHistory(
|
|
|
18
18
|
history: readonly PricePoint[],
|
|
19
19
|
bases: readonly DailyValuationBasis[],
|
|
20
20
|
exchange?: string,
|
|
21
|
+
closesKnownBy?: number,
|
|
21
22
|
): TimeSeriesPoint[] {
|
|
22
23
|
const byDate = new Map<number, PricePoint[]>();
|
|
23
24
|
for (const bar of history) {
|
|
@@ -33,22 +34,28 @@ export function dailyValuationHistory(
|
|
|
33
34
|
let next = 0;
|
|
34
35
|
let active: DailyValuationBasis | undefined;
|
|
35
36
|
const points: TimeSeriesPoint[] = [];
|
|
36
|
-
|
|
37
|
+
const closes = [...byDate].flatMap(([time, bars]) => {
|
|
37
38
|
// Daily bars name their session at midnight. A timed report belongs to
|
|
38
39
|
// that close only if it was already public, including on early closes.
|
|
39
40
|
const day = new Date(time).toISOString().slice(0, 10);
|
|
40
|
-
const closeTime = regularSessionCloseOn(exchange, day) ?? time
|
|
41
|
+
const closeTime = closesKnownBy === undefined ? regularSessionCloseOn(exchange, day) ?? time
|
|
42
|
+
: time % 86_400_000 === 0 ? regularSessionCloseOn(exchange, day) : time;
|
|
43
|
+
return closeTime === null ? [] : [{ time, bars, closeTime, pointTime: closesKnownBy === undefined ? time : closeTime }];
|
|
44
|
+
});
|
|
45
|
+
for (const { time, bars, closeTime, pointTime } of closes.sort((left, right) => left.pointTime - right.pointTime || left.time - right.time)) {
|
|
46
|
+
if (closesKnownBy !== undefined && closeTime > closesKnownBy) continue;
|
|
41
47
|
while (next < releases.length && effectiveTime(releases[next]!) <= closeTime) {
|
|
42
48
|
const release = releases[next++]!;
|
|
43
49
|
if (!active || release.observedAt >= active.observedAt) active = release;
|
|
44
50
|
}
|
|
45
|
-
const
|
|
46
|
-
const
|
|
51
|
+
const observedAt = new Date(time);
|
|
52
|
+
const date = pointTime === time ? observedAt : new Date(pointTime);
|
|
53
|
+
const price = valuationPriceAtOrBefore(bars, observedAt.toISOString());
|
|
47
54
|
const value = active && price?.price != null ? active.atPrice(price.price) : null;
|
|
48
55
|
points.push({
|
|
49
56
|
date,
|
|
50
|
-
observedAt
|
|
51
|
-
availableAt: active?.availableAt ? new Date(active.availableAt) : undefined,
|
|
57
|
+
observedAt,
|
|
58
|
+
availableAt: active?.availableAt ? new Date(closesKnownBy === undefined ? active.availableAt : closeTime) : undefined,
|
|
52
59
|
value: value !== null && Number.isFinite(value) ? value : null,
|
|
53
60
|
periodLabel: active?.periodLabel,
|
|
54
61
|
provenance: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Fundamentals, FinancialStatement, TickerFinancials } from "../types/financials";
|
|
2
2
|
import { resolveCurrencyUnit } from "../utils/currency-units";
|
|
3
|
-
import {
|
|
3
|
+
import { dateScopedEarnings, listingOwnsSeries, priceScopedEarnings } from "../utils/statement-scope";
|
|
4
|
+
import { areNearbyFinancialPeriodEnds, financialAvailabilityTime, statementFieldAvailability } from "../utils/financial-statements";
|
|
4
5
|
import { extractFundamentalSeries, knownWhenFiled } from "./fundamentals";
|
|
5
6
|
import type { SecuritySeriesSource, TimeSeriesPoint } from "./types";
|
|
6
7
|
|
|
@@ -49,6 +50,12 @@ export function trailingEpsSteps(
|
|
|
49
50
|
financials: TickerFinancials,
|
|
50
51
|
known: (row: FinancialStatement) => FinancialStatement = knownWhenFiled,
|
|
51
52
|
): EpsStep[] {
|
|
53
|
+
if (!listingOwnsSeries(financials)) return [];
|
|
54
|
+
if (financials.statementScope) {
|
|
55
|
+
const earnings = financials.fundamentals?.scopedEarnings;
|
|
56
|
+
return earnings?.epsAvailableAt ? [{ periodEnd: earnings.periodEnd, basis: "ttm", knownAt: new Date(financialAvailabilityTime(earnings.epsAvailableAt)), dated: true,
|
|
57
|
+
eps: earnings.eps, currency: earnings.currency }] : [];
|
|
58
|
+
}
|
|
52
59
|
const adjusted = { ...financials, quarterlyStatements: financials.quarterlyStatements.map(known),
|
|
53
60
|
annualStatements: financials.annualStatements.map(known) };
|
|
54
61
|
const toStep = (basis: EpsStep["basis"]) => (point: TimeSeriesPoint): EpsStep => ({
|
|
@@ -79,7 +86,7 @@ interface FiledTrailingEps {
|
|
|
79
86
|
*/
|
|
80
87
|
const SERVED_EPS_RATIO_LIMIT = 1.5;
|
|
81
88
|
|
|
82
|
-
type TrailingEpsInputs = Pick<TickerFinancials, "quote" | "fundamentals" | "annualStatements" | "quarterlyStatements" | "financialCurrency">;
|
|
89
|
+
type TrailingEpsInputs = Pick<TickerFinancials, "quote" | "fundamentals" | "annualStatements" | "quarterlyStatements" | "financialCurrency" | "statementScope">;
|
|
83
90
|
|
|
84
91
|
const isReceipt = (financials: TrailingEpsInputs) => !!(
|
|
85
92
|
financials.quote?.isDepositaryReceipt || financials.fundamentals?.isDepositaryReceipt
|
|
@@ -106,6 +113,7 @@ const rowKey = (row: FinancialStatement) => [
|
|
|
106
113
|
/** The trailing EPS step for the last period on record, null when that period gives none. */
|
|
107
114
|
function latestStep(financials: TrailingEpsInputs): LatestStep {
|
|
108
115
|
const rows = [...financials.quarterlyStatements, ...financials.annualStatements];
|
|
116
|
+
if (!listingOwnsSeries(financials)) return null;
|
|
109
117
|
const latest = rows.map((row) => row.date).filter((date) => Number.isFinite(Date.parse(date))).sort().at(-1);
|
|
110
118
|
if (!latest) return null;
|
|
111
119
|
const recent = (row: FinancialStatement) => Date.parse(latest) - Date.parse(row.date) <= LATEST_WINDOW_MS;
|
|
@@ -113,7 +121,7 @@ function latestStep(financials: TrailingEpsInputs): LatestStep {
|
|
|
113
121
|
const annualStatements = financials.annualStatements.filter(recent);
|
|
114
122
|
const key = [financials.financialCurrency ?? "", quarterlyStatements.map(rowKey).join(";"), annualStatements.map(rowKey).join(";")].join("#");
|
|
115
123
|
if (latestSteps.has(key)) return latestSteps.get(key)!;
|
|
116
|
-
const found = trailingEpsSteps({ financialCurrency: financials.financialCurrency, priceHistory: [], quarterlyStatements, annualStatements })
|
|
124
|
+
const found = trailingEpsSteps({ financialCurrency: financials.financialCurrency, statementScope: financials.statementScope, priceHistory: [], quarterlyStatements, annualStatements })
|
|
117
125
|
.find((candidate) => areNearbyFinancialPeriodEnds(candidate.periodEnd, latest));
|
|
118
126
|
const filed = [...quarterlyStatements, ...annualStatements]
|
|
119
127
|
.flatMap((row) => typeof row.eps === "number" ? [statementFieldAvailability(row, "eps")?.slice(0, 10)] : [])
|
|
@@ -175,6 +183,11 @@ const positive = (value: number | null | undefined): value is number => finite(v
|
|
|
175
183
|
export function withFiledTrailingEps<T extends TrailingEpsInputs>(financials: T, now = Date.now()): T {
|
|
176
184
|
const fundamentals = financials.fundamentals;
|
|
177
185
|
if (!fundamentals) return financials;
|
|
186
|
+
if (financials.statementScope) {
|
|
187
|
+
const scopedEarnings = dateScopedEarnings(financials, fundamentals.scopedEarnings);
|
|
188
|
+
const quote = financials.quote;
|
|
189
|
+
return { ...financials, fundamentals: priceScopedEarnings({ ...fundamentals, scopedEarnings }, quote?.price, quote, quote?.lastUpdated, now) };
|
|
190
|
+
}
|
|
178
191
|
const filed = filedTrailingEps(financials, now);
|
|
179
192
|
if (!filed) {
|
|
180
193
|
const served = finite(fundamentals.eps) || finite(fundamentals.trailingPE);
|
|
@@ -9,6 +9,7 @@ import { liveForwardPE, liveTrailingPE } from "../../market-data/quotes/live-val
|
|
|
9
9
|
import { listingEnterpriseValue } from "../../market-data/quotes/listing-enterprise-value";
|
|
10
10
|
import { BANK_OR_INSURER_EBITDA, isBankOrInsurerIndustry } from "../../utils/ebitda";
|
|
11
11
|
import { comparablePriceEarnings } from "../../utils/price-earnings";
|
|
12
|
+
import { listingOwnsSeries } from "../../utils/statement-scope";
|
|
12
13
|
import { buildTtmStatements, deriveQuarterlyStatements } from "./quarterly-ttm";
|
|
13
14
|
import { sourceStatements, valuationStatements } from "./source-statements";
|
|
14
15
|
import { type InternalStatement, validDate } from "./statement";
|
|
@@ -114,6 +115,11 @@ function currentDerivedValuation(
|
|
|
114
115
|
if (!quoteDate || !isFiniteNumber(quote?.price) || quote.price <= 0) return null;
|
|
115
116
|
const current = currentValuationPrice(quote);
|
|
116
117
|
if (!current) return null;
|
|
118
|
+
if (metric === "trailingPE" && financials.statementScope) {
|
|
119
|
+
const earnings = financials.fundamentals?.scopedEarnings;
|
|
120
|
+
const statement = earnings && [...financials.quarterlyStatements, ...financials.annualStatements].find(row => row.date === earnings.periodEnd);
|
|
121
|
+
return statement ? { value: servedTrailingPE(financials), date: current.date, statement } : null;
|
|
122
|
+
}
|
|
117
123
|
const quoteTime = quoteDate.getTime();
|
|
118
124
|
// Select the latest known period first. Missing inputs, a loss or incompatible
|
|
119
125
|
// currency cannot make an older period's denominator current again.
|
|
@@ -178,15 +184,33 @@ export function currentDerivedValuationPoint(
|
|
|
178
184
|
* it is not meaningful (`notMeaningful`, GE's N/M); null where GE draws no
|
|
179
185
|
* current point and has no reason for it.
|
|
180
186
|
*/
|
|
187
|
+
const ANNUAL_EBITDA_MAX_AGE_MS = 550 * 86_400_000;
|
|
188
|
+
|
|
181
189
|
export function currentTrailingValuation(
|
|
182
190
|
financials: TickerFinancials,
|
|
183
191
|
metric: "evEbitda" | "evSales",
|
|
184
|
-
): { value: number | null; notMeaningful?: string; periodEnd: string; statement: FinancialStatement } | null {
|
|
192
|
+
): { value: number | null; notMeaningful?: string; periodEnd: string; statement: FinancialStatement; annual?: true } | null {
|
|
193
|
+
if (!listingOwnsSeries(financials)) return null;
|
|
185
194
|
const current = currentValuation(financials, "ttm", metric);
|
|
186
|
-
if (
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
195
|
+
if (current) {
|
|
196
|
+
const dated = { periodEnd: current.statement.date.slice(0, 10), statement: current.statement };
|
|
197
|
+
if (current.value !== null) return { value: current.value, ...dated };
|
|
198
|
+
const notMeaningful = metric === "evEbitda" ? ebitdaNotMeaningful(financials, current.statement) : undefined;
|
|
199
|
+
if (notMeaningful) return { value: null, notMeaningful, ...dated };
|
|
200
|
+
}
|
|
201
|
+
// HK/CN issuers often omit D&A in Q1/Q3 reports: fall back to the latest
|
|
202
|
+
// fiscal year (within 550 days of the quote) when trailing quarters lack it.
|
|
203
|
+
if (metric !== "evEbitda") return null;
|
|
204
|
+
const quoteTime = validDate(financials.quote?.lastUpdated)?.getTime();
|
|
205
|
+
if (!quoteTime) return null;
|
|
206
|
+
const annualStatements = sourceStatements(financials, "annual", metric).statements;
|
|
207
|
+
const annual = currentDerivedValuation(financials, annualStatements, metric, createValuationCurrencyContext(financials));
|
|
208
|
+
if (!annual) return null;
|
|
209
|
+
const annualTime = Date.parse(annual.statement.date);
|
|
210
|
+
if (!Number.isFinite(annualTime) || quoteTime - annualTime > ANNUAL_EBITDA_MAX_AGE_MS) return null;
|
|
211
|
+
const dated = { periodEnd: annual.statement.date.slice(0, 10), statement: annual.statement, annual: true as const };
|
|
212
|
+
if (annual.value !== null) return { value: annual.value, ...dated };
|
|
213
|
+
const notMeaningful = ebitdaNotMeaningful(financials, annual.statement);
|
|
190
214
|
return notMeaningful ? { value: null, notMeaningful, ...dated } : null;
|
|
191
215
|
}
|
|
192
216
|
|
|
@@ -229,6 +253,7 @@ export function valuationNotMeaningful(financials: TickerFinancials, source: Sec
|
|
|
229
253
|
* its year): the latest one, or null when the latest window is incomplete.
|
|
230
254
|
*/
|
|
231
255
|
export function latestTrailingStatement(financials: TickerFinancials): FinancialStatement | null {
|
|
256
|
+
if (!listingOwnsSeries(financials)) return null;
|
|
232
257
|
const selected = sourceStatements(financials, "ttm");
|
|
233
258
|
return selected.statements.at(-1) ?? null;
|
|
234
259
|
}
|
|
@@ -31,6 +31,12 @@ export function historicalValuation(
|
|
|
31
31
|
|
|
32
32
|
export function dailyStatementValuation(financials: TickerFinancials, metric: string, exchange?: string,
|
|
33
33
|
currencies = createValuationCurrencyContext(financials)): TimeSeriesPoint[] {
|
|
34
|
+
if (metric === "trailingPE" && financials.statementScope) {
|
|
35
|
+
const earnings = financials.fundamentals?.scopedEarnings;
|
|
36
|
+
if (!earnings?.epsAvailableAt || !earnings.priced || financials.fundamentals?.notMeaningful?.trailingPE || !(earnings.eps > 0) || earnings.currency !== financials.quote?.currency) return [];
|
|
37
|
+
return dailyValuationHistory(financials.priceHistory, [{ availableAt: earnings.epsAvailableAt, observedAt: new Date(earnings.periodEnd),
|
|
38
|
+
atPrice: price => price / earnings.eps }], financials.quote.listingExchangeName || financials.quote.exchangeName || exchange, Date.now());
|
|
39
|
+
}
|
|
34
40
|
const earningsMetric = metric === "pegRatio" ? "trailingPE" : metric;
|
|
35
41
|
const selected = sourceStatements(financials, "daily", earningsMetric, exchange);
|
|
36
42
|
const yearEndMonth = fiscalYearEndMonth(financials.annualStatements);
|
|
@@ -84,10 +90,24 @@ export function dailyStatementValuation(financials: TickerFinancials, metric: st
|
|
|
84
90
|
return points.some((point) => point.value !== null) ? points : [];
|
|
85
91
|
}
|
|
86
92
|
|
|
93
|
+
export function scopedPeriodPE(financials: TickerFinancials, source: SecuritySeriesSource): TimeSeriesPoint | null {
|
|
94
|
+
const earnings = financials.fundamentals?.scopedEarnings;
|
|
95
|
+
if (!earnings) return null;
|
|
96
|
+
const yearEnd = financials.annualStatements.some(row => row.date === earnings.periodEnd);
|
|
97
|
+
if (source.period === "annual" && !yearEnd) return null;
|
|
98
|
+
const close = dailyStatementValuation(financials, "trailingPE", source.instrument.exchange).find(point => point.availableAt && point.value !== null);
|
|
99
|
+
if (!close?.availableAt) return null;
|
|
100
|
+
const period = source.period === "annual" || (source.period !== "ttm" && !financials.quarterlyStatements.length && yearEnd) ? "annual" : "ttm";
|
|
101
|
+
const statement = { date: earnings.periodEnd, currency: earnings.currency, eps: earnings.eps, availableAt: close.availableAt.toISOString() };
|
|
102
|
+
const point = pointForStatement(statement, "trailingPE", close.value, period, source.timestampMode, true, fiscalYearEndMonth(financials.annualStatements));
|
|
103
|
+
return point && { ...point, provenance: { ...point.provenance, ...close.provenance } };
|
|
104
|
+
}
|
|
105
|
+
|
|
87
106
|
/** A daily history cannot be dated at all, but the issuer still has reported figures. */
|
|
88
107
|
export function dailyValuationFallbackPeriod(financials: TickerFinancials, source: SecuritySeriesSource): "annual" | "quarterly" | "ttm" | null {
|
|
89
108
|
if (source.period !== "daily") return null;
|
|
90
109
|
const [namespace, metric = ""] = canonicalTimeSeriesFieldId(source.fieldId).split(".");
|
|
110
|
+
if (financials.statementScope && metric === "trailingPE") return null;
|
|
91
111
|
const inputMetric = metric === "pegRatio" ? "trailingPE" : metric;
|
|
92
112
|
if (namespace !== "valuation" || !QUOTE_DERIVED_VALUATION_IDS.has(inputMetric)) return null;
|
|
93
113
|
const daily = sourceStatements(financials, "daily", inputMetric, source.instrument.exchange);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { TickerFinancials } from "../../types/financials";
|
|
2
|
+
import { settleWithin } from "../../utils/async-deadline";
|
|
3
|
+
import { HISTORY_LINK_PERIODS, oldestPeriod } from "../../utils/financial-statements";
|
|
4
|
+
import { logFailure } from "../../utils/log-failure";
|
|
5
|
+
import { extractFundamentalSeries } from "./series";
|
|
6
|
+
|
|
7
|
+
/** Check the exact metric and last 40 periods the linked GF command will show, not just the dates of statement rows. */
|
|
8
|
+
export async function hasEarlierGfRevenue(
|
|
9
|
+
loadExtended: () => Promise<TickerFinancials>,
|
|
10
|
+
period: "annual" | "quarterly",
|
|
11
|
+
dates: readonly string[],
|
|
12
|
+
waitMs = 3_000,
|
|
13
|
+
): Promise<boolean | null> {
|
|
14
|
+
const oldest = oldestPeriod(dates);
|
|
15
|
+
if (!oldest) return null;
|
|
16
|
+
const extended = await settleWithin(Promise.resolve().then(loadExtended)
|
|
17
|
+
.catch(logFailure("financials.history-link", "Reading the extended statement history failed", null)), waitMs);
|
|
18
|
+
if (!extended || extended.statementHistory?.status === "retryable-failure") return null;
|
|
19
|
+
const points = extractFundamentalSeries(extended, {
|
|
20
|
+
kind: "security", instrument: { symbol: "" },
|
|
21
|
+
fieldId: "fundamental.totalRevenue", period, timestampMode: "period-end",
|
|
22
|
+
});
|
|
23
|
+
return points.slice(-HISTORY_LINK_PERIODS).some((point) => point.value !== null && Number.isFinite(point.value)
|
|
24
|
+
&& point.observedAt.toISOString().slice(0, 10) < oldest);
|
|
25
|
+
}
|
|
@@ -79,9 +79,55 @@ function precedingQuarterInputs(
|
|
|
79
79
|
.sort((left, right) => left.time - right.time);
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
/**
|
|
83
|
+
* The three quarters a fiscal fourth quarter's `field` is the year less: the
|
|
84
|
+
* last three before the year's end, each 60 to 120 days after the one before
|
|
85
|
+
* and the year's end as far after the third. Empty when the line lacks one of
|
|
86
|
+
* them, so a missing Q1 never pulls in the December before it.
|
|
87
|
+
*/
|
|
88
|
+
function adjacentPrecedingInputs(
|
|
89
|
+
quarterlyStatements: readonly FinancialStatement[],
|
|
90
|
+
annualStatement: FinancialStatement,
|
|
91
|
+
field: NumericStatementField,
|
|
92
|
+
): PrecedingQuarterInput[] {
|
|
93
|
+
const inputs = precedingQuarterInputs(quarterlyStatements, annualStatement, field);
|
|
94
|
+
if (inputs.length !== 3) return [];
|
|
95
|
+
const times = [...inputs.map((input) => input.time), statementTime(annualStatement)];
|
|
96
|
+
const adjacent = times.every((time, index) => index === 0 || (time - times[index - 1]! >= 60 * DAY_MS && time - times[index - 1]! <= 120 * DAY_MS));
|
|
97
|
+
return adjacent ? inputs : [];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** How far a fourth quarter's own revenue may sit from its year less three quarters and still be that difference. */
|
|
101
|
+
const FOURTH_QUARTER_MATCH = 0.005;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Whether a year and the three adjacent quarters before its end are not one
|
|
105
|
+
* measure: their revenue sums above the year's (above zero), and the fourth
|
|
106
|
+
* quarter states no revenue that is the difference. VYLR's carve-out year of
|
|
107
|
+
* 10.07B came beside nine months of 13.49B on its former parent's scope: no
|
|
108
|
+
* fourth quarter is their difference, in revenue or in any other flow. A year
|
|
109
|
+
* of 90 after quarters of 100 whose fourth quarter reports -10 (a reversal)
|
|
110
|
+
* is one measure, and its missing flows are still the year less the quarters.
|
|
111
|
+
*/
|
|
112
|
+
function quartersOfAnotherMeasure(
|
|
113
|
+
quarterlyStatements: readonly FinancialStatement[],
|
|
114
|
+
annualStatement: FinancialStatement,
|
|
115
|
+
fourthQuarter: FinancialStatement,
|
|
116
|
+
): boolean {
|
|
117
|
+
const year = statementNumber(annualStatement, "totalRevenue");
|
|
118
|
+
if (year === null || !(year > 0)) return false;
|
|
119
|
+
const quarters = adjacentPrecedingInputs(quarterlyStatements, annualStatement, "totalRevenue");
|
|
120
|
+
if (quarters.length !== 3) return false;
|
|
121
|
+
const difference = year - quarters.reduce((sum, quarter) => sum + quarter.value, 0);
|
|
122
|
+
if (difference >= 0) return false;
|
|
123
|
+
const reported = statementNumber(fourthQuarter, "totalRevenue");
|
|
124
|
+
return reported === null || Math.abs(reported - difference) > FOURTH_QUARTER_MATCH * year;
|
|
125
|
+
}
|
|
126
|
+
|
|
82
127
|
/**
|
|
83
128
|
* Completes additive fiscal Q4 flows from the annual total and three reported
|
|
84
|
-
* quarters
|
|
129
|
+
* quarters, never from quarters of another measure than the year
|
|
130
|
+
* (quartersOfAnotherMeasure). EPS and weighted-average shares require reported quarter values;
|
|
85
131
|
* neither is an additive flow. Snapshots come from the annual balance sheet. Derived
|
|
86
132
|
* values become available only after the annual total and every quarterly
|
|
87
133
|
* input used in the derivation are public.
|
|
@@ -97,8 +143,9 @@ export function deriveQuarterlyStatements(
|
|
|
97
143
|
let target: InternalStatement = byDate.get(annualStatement.date) ?? { date: annualStatement.date, currency: annualStatement.currency };
|
|
98
144
|
if (target.currency !== annualStatement.currency) continue;
|
|
99
145
|
let changed = false;
|
|
146
|
+
const comparable = !quartersOfAnotherMeasure(mergedQuarterly, annualStatement, target);
|
|
100
147
|
|
|
101
|
-
for (const field of QUARTERLY_FLOW_FIELDS) {
|
|
148
|
+
for (const field of comparable ? QUARTERLY_FLOW_FIELDS : []) {
|
|
102
149
|
// A line unavailable for the fourth quarter stays a gap: the full year
|
|
103
150
|
// minus the other quarters would recreate the value a source withheld.
|
|
104
151
|
if (hasStatementGap(target, field) || mergedQuarterly.some((statement) => (
|
|
@@ -107,10 +154,8 @@ export function deriveQuarterlyStatements(
|
|
|
107
154
|
if (statementNumber(target, field) !== null) continue;
|
|
108
155
|
const annualValue = statementNumber(annualStatement, field);
|
|
109
156
|
if (annualValue === null) continue;
|
|
110
|
-
const previousInputs =
|
|
157
|
+
const previousInputs = adjacentPrecedingInputs(mergedQuarterly, annualStatement, field);
|
|
111
158
|
if (previousInputs.length !== 3) continue;
|
|
112
|
-
const inputTimes = [...previousInputs.map((input) => input.time), statementTime(annualStatement)];
|
|
113
|
-
if (inputTimes.some((time, index) => index > 0 && (time - inputTimes[index - 1]! < 60 * DAY_MS || time - inputTimes[index - 1]! > 120 * DAY_MS))) continue;
|
|
114
159
|
const derived = annualValue - previousInputs.reduce((sum, input) => sum + input.value, 0);
|
|
115
160
|
if (!Number.isFinite(derived)) continue;
|
|
116
161
|
const availableAt = completeAvailability([
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Extracts a fundamental or valuation series from a ticker's financials, with the warnings and issues that explain it.
|
|
2
2
|
import type { TickerFinancials } from "../../types/financials";
|
|
3
|
+
import { listingOwnsSeries } from "../../utils/statement-scope";
|
|
3
4
|
import { fiscalYearEndMonth } from "../../utils/fiscal-period";
|
|
4
5
|
import { canonicalTimeSeriesFieldId, getTimeSeriesField } from "../field-catalog";
|
|
5
6
|
import { dailyForwardPeHistory, forwardPeHistory, realizedNtmPeHistory } from "../forward-valuation";
|
|
@@ -10,7 +11,7 @@ import type { SecuritySeriesSource, TimeSeriesPoint } from "../types";
|
|
|
10
11
|
import { isBankOrInsurerIndustry } from "../../utils/ebitda";
|
|
11
12
|
import { notTheShare } from "../../utils/share-multiples";
|
|
12
13
|
import { currentDerivedValuationPoint, currentValuationStatements, providerCurrentValuationPoint } from "./current-valuation";
|
|
13
|
-
import { dailyStatementValuation, dailyValuationFallbackPeriod, historicalValuation } from "./historical-valuation";
|
|
14
|
+
import { dailyStatementValuation, dailyValuationFallbackPeriod, historicalValuation, scopedPeriodPE } from "./historical-valuation";
|
|
14
15
|
import { FUNDAMENTAL_IDS, QUOTE_DERIVED_VALUATION_IDS, VALUATION_IDS, valuationSeriesUsesLiveQuote } from "./metric-ids";
|
|
15
16
|
import { dedupeFundamentalPeriods, pointForStatement } from "./period-points";
|
|
16
17
|
import { sourceStatements } from "./source-statements";
|
|
@@ -54,6 +55,7 @@ export function extractFundamentalSeries(
|
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
if (namespace !== "valuation" || !VALUATION_IDS.has(metric)) return [];
|
|
58
|
+
if (metric !== "forwardPE" && !listingOwnsSeries(financials)) return [];
|
|
57
59
|
// A warrant's, a right's, a unit's or an unratioed receipt's price over its company's EPS is no P/E at any date.
|
|
58
60
|
if (SHARE_PRICE_EARNINGS.has(metric) && notTheShare(financials)) return [];
|
|
59
61
|
// A bank's or an insurer's EBITDA measures nothing: its EV/EBITDA is N/M throughout (valuationNotMeaningful).
|
|
@@ -83,6 +85,12 @@ export function extractFundamentalSeries(
|
|
|
83
85
|
return current ? [current] : [];
|
|
84
86
|
}
|
|
85
87
|
|
|
88
|
+
if (metric === "trailingPE" && financials.statementScope) {
|
|
89
|
+
const historical = scopedPeriodPE(financials, source);
|
|
90
|
+
const current = currentDerivedValuationPoint(financials, [], metric, currencies);
|
|
91
|
+
return [historical, current].filter((point): point is TimeSeriesPoint => point !== null).sort((left, right) => left.date.getTime() - right.date.getTime());
|
|
92
|
+
}
|
|
93
|
+
|
|
86
94
|
const selected = sourceStatements(financials, source.period, metric);
|
|
87
95
|
const yearEndMonth = fiscalYearEndMonth(financials.annualStatements);
|
|
88
96
|
let hasHistoricalObservation = false;
|
|
@@ -156,6 +164,10 @@ export function valuationPriceIssues(financials: TickerFinancials, source: Secur
|
|
|
156
164
|
return extractFundamentalSeries(financials, source, currencyContext).flatMap((point) => point.provenance?.valuationPriceIssues ?? []);
|
|
157
165
|
}
|
|
158
166
|
if (!valuationSeriesUsesLiveQuote(source.fieldId)) return [];
|
|
167
|
+
if (financials.statementScope && canonicalTimeSeriesFieldId(source.fieldId) === "valuation.trailingPE") {
|
|
168
|
+
const issue = valuationQuoteIssue(financials.quote);
|
|
169
|
+
return [...(issue ? [issue] : []), ...(scopedPeriodPE(financials, source)?.provenance?.valuationPriceIssues ?? [])];
|
|
170
|
+
}
|
|
159
171
|
const currencies = currencyContext ?? createValuationCurrencyContext(financials);
|
|
160
172
|
const metric = canonicalTimeSeriesFieldId(source.fieldId).split(".")[1]!;
|
|
161
173
|
const selected = sourceStatements(financials, source.period, metric);
|
|
@@ -7,8 +7,11 @@ import { canonicalTimeSeriesFieldId, isFundamentalFieldId, isMarketFieldId } fro
|
|
|
7
7
|
import { extractFundamentalSeries } from "./fundamentals";
|
|
8
8
|
import type { ValuationCurrencyContext } from "./valuation-currency";
|
|
9
9
|
import type { ChartSeriesPriceHistoryIntegrity, ResolvedSeries, SecuritySeriesSource, SeriesPeriod, TimeSeriesPoint } from "./types";
|
|
10
|
-
import type
|
|
10
|
+
import { chartBarSizeParts, chartBarSizeStepMs, type ChartBarSize, type ManualChartResolution } from "./resolution";
|
|
11
11
|
import { isFiniteNumber } from "../utils/guards";
|
|
12
|
+
import type { HistorySession } from "../types/price-history";
|
|
13
|
+
import { regularSessionCloseOn } from "../market-data/market/freshness";
|
|
14
|
+
import { zonedDateKey } from "../utils/zoned-date-time";
|
|
12
15
|
|
|
13
16
|
/** Field catalogue frequency is a default, not evidence for acquired bars. */
|
|
14
17
|
export function marketSeriesFrequency(source: SecuritySeriesSource, historyResolution: ManualChartResolution | null | undefined): SeriesPeriod {
|
|
@@ -109,12 +112,19 @@ function aggregatePriceHistory(
|
|
|
109
112
|
export function extractPriceSeries(
|
|
110
113
|
priceHistory: readonly PricePoint[],
|
|
111
114
|
source: SecuritySeriesSource,
|
|
115
|
+
barSize?: ChartBarSize | null,
|
|
116
|
+
session?: HistorySession,
|
|
112
117
|
): TimeSeriesPoint[] {
|
|
113
118
|
const fieldId = canonicalTimeSeriesFieldId(source.fieldId);
|
|
114
119
|
if (!isMarketFieldId(fieldId)) return [];
|
|
115
120
|
const aggregated = aggregatePriceHistory(priceHistory, source.period ?? "auto");
|
|
116
121
|
// A price on its own at the end of intraday bars (a closing auction's price) has no volume of its own, never 0.
|
|
117
122
|
const priceOnly = priceOnlyPoint(aggregated)?.index;
|
|
123
|
+
const size = chartBarSizeParts(barSize);
|
|
124
|
+
const step = barSize && (size?.unit === "m" || size?.unit === "h") && (!source.period || source.period === "auto")
|
|
125
|
+
? chartBarSizeStepMs(barSize) : 0;
|
|
126
|
+
let sessionDay: string | undefined;
|
|
127
|
+
let sessionClose: number | null = null;
|
|
118
128
|
return aggregated.map((point, index) => {
|
|
119
129
|
// A roll is the contract changing from the bar before, which a window's first bar knows from the bars before it.
|
|
120
130
|
const before = index > 0 ? aggregated[index - 1]!.contract : undefined;
|
|
@@ -129,10 +139,25 @@ export function extractPriceSeries(
|
|
|
129
139
|
: fieldId === "market.volume"
|
|
130
140
|
? values.volume
|
|
131
141
|
: values.close;
|
|
142
|
+
const date = new Date(point.date);
|
|
143
|
+
const start = date.getTime();
|
|
144
|
+
let end = start;
|
|
145
|
+
if (step && !point.partial && !point.quoteOnly && !point.sessionClose && index !== priceOnly) {
|
|
146
|
+
end += step;
|
|
147
|
+
if (session) {
|
|
148
|
+
const day = zonedDateKey(start, session.timeZone);
|
|
149
|
+
if (day !== sessionDay) {
|
|
150
|
+
sessionDay = day;
|
|
151
|
+
sessionClose = regularSessionCloseOn(session.exchange, day);
|
|
152
|
+
}
|
|
153
|
+
if (sessionClose != null && sessionClose > start) end = Math.min(end, sessionClose);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
132
156
|
return {
|
|
133
|
-
date
|
|
157
|
+
date,
|
|
134
158
|
observedAt: new Date(point.date),
|
|
135
|
-
availableAt: new Date(
|
|
159
|
+
availableAt: new Date(end),
|
|
160
|
+
...(end !== start ? { barStart: date } : {}),
|
|
136
161
|
value,
|
|
137
162
|
...values,
|
|
138
163
|
// A continuous future's bar names its contract, and the source marks a bar still forming.
|
|
@@ -186,9 +211,10 @@ export function extractSecuritySeries(
|
|
|
186
211
|
financials: TickerFinancials | null,
|
|
187
212
|
source: SecuritySeriesSource,
|
|
188
213
|
currencies?: ValuationCurrencyContext,
|
|
214
|
+
barSize?: ChartBarSize | null,
|
|
189
215
|
): TimeSeriesPoint[] {
|
|
190
216
|
if (!financials) return [];
|
|
191
|
-
if (isMarketFieldId(source.fieldId)) return extractPriceSeries(financials.priceHistory, source);
|
|
217
|
+
if (isMarketFieldId(source.fieldId)) return extractPriceSeries(financials.priceHistory, source, barSize, financials.priceHistorySession);
|
|
192
218
|
if (isFundamentalFieldId(source.fieldId)) return extractFundamentalSeries(financials, source, currencies);
|
|
193
219
|
return [];
|
|
194
220
|
}
|
|
@@ -8,6 +8,7 @@ import { zonedDateTimeParts } from "../utils/zoned-date-time";
|
|
|
8
8
|
import { isCurrencyCode } from "../utils/currency-pair";
|
|
9
9
|
import { priceComparisonCloseTimes } from "./coin-session-close";
|
|
10
10
|
import { barLastSession } from "../market-data/market/bar-period";
|
|
11
|
+
import { priceBasisBreaks, priceBasisFactor } from "../market-data/market/split-price-basis";
|
|
11
12
|
import {
|
|
12
13
|
barCloseDay, isIntradayDailyBar, isReturnPeriod, LATEST_INTRADAY_TEXT, periodBaseDay, periodBaseIndex, periodDayText,
|
|
13
14
|
} from "../market-data/market/period-return";
|
|
@@ -214,66 +215,24 @@ function splitTerms(split: SplitAction): string | null {
|
|
|
214
215
|
return `${to}-for-${from}${to! < from! ? " reverse" : ""}`;
|
|
215
216
|
}
|
|
216
217
|
|
|
217
|
-
/** A close more than this many times the one before it, or less than its fraction, is no day a split-adjusted series moves by. */
|
|
218
|
-
const UNEXPLAINED_JUMP = 5;
|
|
219
|
-
|
|
220
|
-
/** `18.4`, `20`, `5.23`: a jump's factor in three digits. */
|
|
221
|
-
function jumpFactorText(ratio: number): string {
|
|
222
|
-
return String(Number(Math.max(ratio, 1 / ratio).toPrecision(3)));
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Each jump of a leg's closes inside its window: a close over UNEXPLAINED_JUMP
|
|
227
|
-
* times the one before it or under its fraction. "SOXS falls 18.4× on Tue 26
|
|
228
|
-
* May with no split recorded that day", or on a split's own day, "the day of
|
|
229
|
-
* its 1-for-20 reverse split, unadjusted".
|
|
230
|
-
*/
|
|
231
|
-
function legJumps(
|
|
232
|
-
label: string,
|
|
233
|
-
points: ReadonlyArray<{ date: Date; value: number | null }>,
|
|
234
|
-
window: { baseDay: string; endDay: string },
|
|
235
|
-
splits: readonly SplitAction[],
|
|
236
|
-
currentYear: number,
|
|
237
|
-
): string[] {
|
|
238
|
-
const jumps: string[] = [];
|
|
239
|
-
let previous: number | null = null;
|
|
240
|
-
for (const point of points) {
|
|
241
|
-
const value = point.value;
|
|
242
|
-
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) continue;
|
|
243
|
-
const day = point.date.toISOString().slice(0, 10);
|
|
244
|
-
const ratio = previous === null ? 1 : value / previous;
|
|
245
|
-
previous = value;
|
|
246
|
-
if (day <= window.baseDay || day > window.endDay || (ratio <= UNEXPLAINED_JUMP && ratio >= 1 / UNEXPLAINED_JUMP)) continue;
|
|
247
|
-
const split = splits.find((entry) => entry.date.slice(0, 10) === day);
|
|
248
|
-
const terms = split ? splitTerms(split) : null;
|
|
249
|
-
jumps.push(`${label} ${ratio < 1 ? "falls" : "rises"} ${jumpFactorText(ratio)}× on ${periodDayText(day, currentYear)}${
|
|
250
|
-
terms ? `, the day of its ${terms} split, unadjusted` : " with no split recorded that day"}`);
|
|
251
|
-
}
|
|
252
|
-
return jumps;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
218
|
/**
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
* reads its return, not its share price: "Splits in range: SOXS 1-for-20
|
|
260
|
-
* reverse on Thu 5 Mar and 1-for-10 reverse on Wed 15 Jul; returns are
|
|
261
|
-
* split-adjusted." That is said only when no leg's closes jump inside its
|
|
262
|
-
* window (legJumps): a jump is named instead, a split or not, and the returns
|
|
263
|
-
* across it called unreliable. Null when no leg has a split or a jump.
|
|
219
|
+
* Describe recorded splits separately from breaks in the served bars. A split record alone cannot tell
|
|
220
|
+
* which bars are on which basis. Withhold returns only for the legs whose windows cross a break.
|
|
221
|
+
* Null split history is unavailable or not yet read, not a successful empty result.
|
|
264
222
|
*/
|
|
265
|
-
export function
|
|
266
|
-
comparison: Pick<PriceComparison, "legs">,
|
|
267
|
-
legs: ReadonlyArray<{ id: string; label: string; splits: readonly SplitAction[]
|
|
223
|
+
export function comparisonSplitAssessment(
|
|
224
|
+
comparison: Pick<PriceComparison, "legs" | "sourceBounds">,
|
|
225
|
+
legs: ReadonlyArray<{ id: string; label: string; splits: readonly SplitAction[] | null; series?: ResolvedSeries }>,
|
|
268
226
|
now = Date.now(),
|
|
269
|
-
): string | null {
|
|
227
|
+
): { notice: string | null; dropped: NonNullable<PriceComparison["dropped"]> } {
|
|
270
228
|
const currentYear = new Date(now).getUTCFullYear();
|
|
271
229
|
const named: string[] = [];
|
|
272
|
-
const
|
|
273
|
-
for (const { id, label, splits,
|
|
230
|
+
const dropped: NonNullable<PriceComparison["dropped"]> = [];
|
|
231
|
+
for (const { id, label, splits, series } of legs) {
|
|
274
232
|
const window = comparison.legs?.[id];
|
|
275
233
|
if (!window) continue;
|
|
276
|
-
const
|
|
234
|
+
const recordedSplits = splits ?? [];
|
|
235
|
+
const inside = recordedSplits
|
|
277
236
|
.filter((split) => /^\d{4}-\d{2}-\d{2}/.test(split.date) && split.date.slice(0, 10) > window.baseDay && split.date.slice(0, 10) <= window.endDay)
|
|
278
237
|
.sort((left, right) => left.date.localeCompare(right.date))
|
|
279
238
|
.flatMap((split) => {
|
|
@@ -281,12 +240,30 @@ export function comparisonSplitNotice(
|
|
|
281
240
|
return terms ? [`${terms} on ${periodDayText(split.date, currentYear)}`] : [];
|
|
282
241
|
});
|
|
283
242
|
if (inside.length) named.push(`${label} ${listLabels(inside)}`);
|
|
284
|
-
|
|
243
|
+
const bounds = comparison.sourceBounds?.[id];
|
|
244
|
+
if (!series || !bounds) continue;
|
|
245
|
+
const bars = series.points.flatMap((point) => {
|
|
246
|
+
const time = point.date.getTime();
|
|
247
|
+
return time >= bounds.start && time <= bounds.end ? [{ date: observationDate(time, series),
|
|
248
|
+
close: point.close ?? point.value, high: point.high, low: point.low }] : [];
|
|
249
|
+
});
|
|
250
|
+
const breaks = priceBasisBreaks(bars, recordedSplits, { interval: series.historyResolution, venue: legVenue(series),
|
|
251
|
+
includeUnrecorded: true, includeUnrecordedRange: splits === null });
|
|
252
|
+
if (breaks.length) {
|
|
253
|
+
const period = series.historyResolution === "1mo" ? "monthly" : series.historyResolution === "1wk" ? "weekly" : null;
|
|
254
|
+
const descriptions = breaks.map(({ day, ratio, kind, split }) => {
|
|
255
|
+
const move = kind === "close" ? `close ${ratio < 1 ? "falls" : "rises"}` : "high/low range is";
|
|
256
|
+
const evidence = split ? `near the ${periodDayText(split.date.slice(0, 10), currentYear)} split`
|
|
257
|
+
: splits === null ? "with split history unavailable" : "with no split recorded nearby";
|
|
258
|
+
return `${move} ${priceBasisFactor(ratio)}× ${period ? `in the ${period} bar dated` : "on"} ${periodDayText(day, currentYear)} ${evidence}`;
|
|
259
|
+
});
|
|
260
|
+
dropped.push({ seriesId: id, label, reason: `${descriptions.join("; ")}. A consistent price basis cannot be verified` });
|
|
261
|
+
}
|
|
285
262
|
}
|
|
286
263
|
const splitsLine = named.length ? `Splits in range: ${named.join("; ")}` : null;
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
return
|
|
264
|
+
const notice = dropped.length ? [splitsLine && `${splitsLine}.`, ...dropped.map(({ label, reason }) => `${label}: ${reason}; returns withheld.`)]
|
|
265
|
+
.filter(Boolean).join(" ") : splitsLine && `${splitsLine}; returns are split-adjusted.`;
|
|
266
|
+
return { notice, dropped };
|
|
290
267
|
}
|
|
291
268
|
|
|
292
269
|
/**
|
|
@@ -389,7 +366,7 @@ export function resolvePriceComparison(
|
|
|
389
366
|
const sessionDay = (key: string) => (barPeriod ? barLastSession(key, barPeriod, venue, now) : null) ?? key;
|
|
390
367
|
const dayOf = (leg: ComparedLeg, key: string) => calendarBars ? key : observationDate(Number(key), leg.entry);
|
|
391
368
|
const preset = options.preset ?? null;
|
|
392
|
-
const period = !dateWindow && isReturnPeriod(preset) ? preset : null;
|
|
369
|
+
const period = dateWindow?.returnPeriod ?? (!dateWindow && isReturnPeriod(preset) ? preset : null);
|
|
393
370
|
const shared = (keys: (leg: ComparedLeg) => readonly string[]) => {
|
|
394
371
|
const sets = legs.map((leg) => new Set(keys(leg)));
|
|
395
372
|
return legs.length ? keys(legs[0]!).filter((key) => sets.every((set) => set.has(key))) : [];
|
|
@@ -402,7 +379,7 @@ export function resolvePriceComparison(
|
|
|
402
379
|
: sharedWindow.at(-1);
|
|
403
380
|
// Authored dates (`--from 2026-10-19`) measure from the close before the first date, as RETURN does: the last
|
|
404
381
|
// date the legs share before it. Weekly and monthly bars keep the bar the window starts in.
|
|
405
|
-
const authoredFrom = !preset && dateWindow && /^\d{4}-\d{2}-\d{2}$/.test(dateWindow.start) && (resolution === "1d" || !calendarBars)
|
|
382
|
+
const authoredFrom = !preset && !period && dateWindow && /^\d{4}-\d{2}-\d{2}$/.test(dateWindow.start) && (resolution === "1d" || !calendarBars)
|
|
406
383
|
? dateWindow.start : null;
|
|
407
384
|
const firstInWindow = authoredFrom ? legs.map((leg) => leg.window[0]!).sort(order)[0] : undefined;
|
|
408
385
|
const authoredBase = authoredFrom && firstInWindow !== undefined
|
|
@@ -410,7 +387,8 @@ export function resolvePriceComparison(
|
|
|
410
387
|
&& legs.every((leg) => nonzero(leg, key))).at(-1)
|
|
411
388
|
: undefined;
|
|
412
389
|
const sharedStart = authoredBase ?? sharedWindow.find((key) => legs.every((leg) => nonzero(leg, key)));
|
|
413
|
-
const anchor =
|
|
390
|
+
const anchor = dateWindow?.returnPeriod ? dateWindow.end
|
|
391
|
+
: period && sharedEnd !== undefined ? (calendarBars ? sessionDay(sharedEnd) : dayOf(legs[0]!, sharedEnd)) : null;
|
|
414
392
|
const baseDay = anchor && period ? periodBaseDay(anchor, period) : null;
|
|
415
393
|
const closeDay = (leg: ComparedLeg, key: string) => calendarBars && resolution !== "1d" ? barCloseDay(key, resolution, legVenue(leg.entry)) : key;
|
|
416
394
|
// Intraday bars share their times, so their base is the last bar the legs share on or before the base day.
|
|
@@ -516,6 +494,7 @@ export function bufferPriceComparison(
|
|
|
516
494
|
view: { start: number | null; end: number | null },
|
|
517
495
|
): ResolvedSeries {
|
|
518
496
|
if (!comparison?.seriesIds.includes(series.id)) return series;
|
|
497
|
+
if (comparison.dropped?.some((entry) => entry.seriesId === series.id)) return { ...series, points: [] };
|
|
519
498
|
return {
|
|
520
499
|
...series,
|
|
521
500
|
latestChangePercent: undefined,
|