@gloom-sh/terminal 0.20.3 → 0.20.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/bin/gloom +9 -0
- package/bin/without-bun.cjs +98 -0
- package/package.json +3 -1
- package/src/account/auth-dialog.tsx +17 -0
- package/src/api-client/data.ts +144 -35
- package/src/api-client/fx-interventions.ts +64 -0
- package/src/api-client/index.ts +1 -0
- package/src/api-client/release-summaries.ts +21 -0
- package/src/api-client/types/econ.ts +12 -0
- package/src/api-client/yield-curves.ts +1 -1
- package/src/app/global-shortcuts.ts +4 -1
- package/src/app/keybindings/actions.ts +8 -2
- package/src/app/keybindings/config.ts +2 -1
- package/src/app/keybindings/index.ts +1 -0
- package/src/app/keybindings/labels.ts +6 -1
- package/src/app/keybindings/resolve.ts +23 -4
- package/src/app/keybindings/terminal-keys.ts +35 -0
- package/src/app/pane-runtime/index.tsx +2 -2
- package/src/app/pane-runtime/ticker-open-runtime.ts +274 -67
- package/src/architecture/ui-literals-allowlist.json +1 -1
- package/src/capabilities/chart-series.ts +27 -1
- package/src/cli/commands/keybindings.ts +5 -5
- package/src/cli/commands/market.ts +154 -21
- package/src/cli/commands/news-search.ts +60 -10
- package/src/cli/commands/overview.ts +16 -1
- package/src/cli/commands/plugins.ts +27 -5
- package/src/cli/commands/remote.ts +16 -17
- package/src/cli/commands/system.ts +20 -4
- package/src/cli/commands/ticker.ts +60 -19
- package/src/cli/fx-forward.ts +25 -7
- package/src/cli/glossary.ts +19 -5
- package/src/cli/history-rows.ts +5 -3
- package/src/cli/index.ts +8 -8
- package/src/cli/known-gaps.ts +27 -1
- package/src/cli/listing-arg.ts +11 -1
- package/src/cli/name-entries.ts +5 -1
- package/src/cli/not-a-ticker.ts +4 -0
- package/src/cli/pane-functions/function-help.ts +5 -5
- package/src/cli/report-tables.ts +18 -6
- package/src/cli/result.ts +15 -7
- package/src/cli/types.ts +2 -0
- package/src/components/chart/composite/axis-overlays.tsx +22 -0
- package/src/components/chart/composite/composite-chart.tsx +54 -13
- package/src/components/chart/composite/event-captions.ts +109 -0
- package/src/components/chart/composite/event-guides.ts +74 -0
- package/src/components/chart/composite/rasterizer.ts +2 -0
- package/src/components/chart/composite/text-renderer.ts +2 -0
- package/src/components/chart/composite/types.ts +31 -0
- package/src/components/command-bar/layout-items/focused-pane.ts +5 -5
- package/src/components/command-bar/pane-settings.ts +2 -2
- package/src/components/command-bar/routes/root/provider-search.ts +5 -4
- package/src/components/command-bar/routes/root/results.ts +6 -2
- package/src/components/command-bar/routes/ticker-search/results.ts +51 -0
- package/src/components/command-bar/routes/ticker-search/route.ts +3 -2
- package/src/components/input-search-bar.tsx +9 -2
- package/src/components/layout/detached-pane-shell.tsx +1 -1
- package/src/components/layout/floating-pane.tsx +5 -1
- package/src/components/layout/pane/footer/index.tsx +21 -14
- package/src/components/layout/pane/footer/model.ts +6 -0
- package/src/components/layout/pane/header.tsx +2 -0
- package/src/components/layout/shell/action-menu-overlay.tsx +10 -5
- package/src/components/layout/shell/active-drag.ts +149 -105
- package/src/components/layout/shell/drag/drop-zones.ts +162 -0
- package/src/components/layout/shell/drag/index.ts +47 -218
- package/src/components/layout/shell/drag/live.ts +10 -3
- package/src/components/layout/shell/drag/overlays.tsx +182 -5
- package/src/components/layout/shell/drag/runtime.ts +29 -6
- package/src/components/layout/shell/drag/shared-edges.ts +156 -0
- package/src/components/layout/shell/index.tsx +11 -6
- package/src/components/layout/shell/menu.ts +11 -2
- package/src/components/layout/shell/native/pointer-runtime.ts +25 -0
- package/src/components/layout/shell/native/window-state.ts +2 -2
- package/src/components/layout/shell/pane/capture.ts +4 -1
- package/src/components/layout/shell/pane/layers.tsx +71 -7
- package/src/components/layout/shell/terminal-pointer-runtime.ts +18 -9
- package/src/components/layout/shell/window-mode/index.ts +8 -10
- package/src/components/layout/status-bar.tsx +6 -1
- package/src/components/layout/window-edit/mode.ts +39 -7
- package/src/components/layout/window-edit/presentation.ts +1 -1
- package/src/components/onboarding/first-run-workspace.ts +44 -2
- package/src/components/onboarding/onboarding-frame.tsx +11 -2
- package/src/components/onboarding/onboarding-keyboard.ts +20 -0
- package/src/components/onboarding/onboarding-wizard.tsx +16 -11
- package/src/components/onboarding/portfolio-step/positions-panel.tsx +62 -1
- package/src/components/onboarding/use-onboarding-progress.ts +12 -4
- package/src/components/pane-settings-dialog/desktop.tsx +2 -2
- package/src/components/pane-settings-dialog/tui.tsx +2 -2
- package/src/components/pane-settings-dialog/value.ts +6 -0
- package/src/components/pane-settings-dialog.tsx +3 -3
- package/src/components/reader/detail-reader.tsx +4 -0
- package/src/components/ui/button.tsx +2 -0
- package/src/components/ui/choice-dialog.tsx +1 -0
- package/src/components/ui/data-table/index.tsx +4 -3
- package/src/components/ui/index.ts +1 -1
- package/src/components/ui/list-view.tsx +7 -12
- package/src/components/ui/loading.tsx +10 -3
- package/src/components/ui/menu.tsx +6 -2
- package/src/components/ui/page-stack-view.tsx +3 -0
- package/src/components/ui/pane-link-chip.tsx +269 -54
- package/src/components/ui/query-bar.tsx +2 -1
- package/src/components/ui/quote.ts +14 -1
- package/src/components/ui/tabs.tsx +97 -19
- package/src/core/state/app/layout-reducer.ts +7 -0
- package/src/core/state/app/layout.ts +44 -7
- package/src/core/state/app/state.ts +1 -1
- package/src/core/state/app/types.ts +22 -2
- package/src/data/config/layout.ts +5 -2
- package/src/docs/snapshot.json +54 -13
- package/src/i18n/es.ts +9 -8
- package/src/i18n/ja.ts +9 -8
- package/src/i18n/ko.ts +9 -8
- package/src/i18n/zh-cn.ts +9 -8
- package/src/i18n/zh-tw.ts +9 -8
- package/src/layout/pane-manager/floating-actions.ts +17 -0
- package/src/layout/pane-manager/floating-stack.ts +187 -0
- package/src/layout/pane-manager/floating.ts +4 -2
- package/src/layout/pane-manager/gridlock.ts +5 -1
- package/src/layout/pane-manager/index.ts +11 -0
- package/src/layout/pane-manager/layout-state.ts +10 -3
- package/src/market-data/depositary-pair.ts +5 -3
- package/src/market-data/futures-board.ts +46 -1
- package/src/market-data/futures-contract.ts +12 -3
- package/src/market-data/fx-interventions.ts +270 -0
- package/src/market-data/market/dated-previous-close.ts +94 -15
- package/src/market-data/market/status.ts +17 -1
- package/src/news/news-model.ts +44 -2
- package/src/plugins/builtin/alerts/cli.ts +4 -4
- package/src/plugins/builtin/alerts/format.ts +1 -2
- package/src/plugins/builtin/alerts/headless.ts +1 -2
- package/src/plugins/builtin/alerts/move-checks.ts +12 -6
- package/src/plugins/builtin/alerts/move.ts +30 -9
- package/src/plugins/builtin/alerts/pane.tsx +0 -2
- package/src/plugins/builtin/alerts/storage.ts +4 -2
- package/src/plugins/builtin/alerts/types.ts +12 -0
- package/src/plugins/builtin/analytics/risk-client.ts +10 -4
- package/src/plugins/builtin/analytics/risk-episodes.ts +5 -4
- package/src/plugins/builtin/analytics/risk-headless.ts +4 -2
- package/src/plugins/builtin/analytics/risk-sectors.ts +91 -0
- package/src/plugins/builtin/awards/index.tsx +1 -1
- package/src/plugins/builtin/buildout/index.tsx +1 -0
- package/src/plugins/builtin/catalysts/index.tsx +2 -2
- package/src/plugins/builtin/cds/headless.ts +4 -0
- package/src/plugins/builtin/changelog/index.tsx +292 -101
- package/src/plugins/builtin/changelog/versions.ts +293 -0
- package/src/plugins/builtin/chart-composer/headless.ts +2 -1
- package/src/plugins/builtin/chart-composer/index.tsx +1 -0
- package/src/plugins/builtin/chart-composer/intervention-events.ts +105 -0
- package/src/plugins/builtin/chart-composer/pane.tsx +21 -7
- package/src/plugins/builtin/chat/content/composer.tsx +5 -4
- package/src/plugins/builtin/chat/content/index.tsx +12 -2
- package/src/plugins/builtin/chat/content/layout-metrics.ts +3 -3
- package/src/plugins/builtin/chat/content/open-targets.ts +3 -3
- package/src/plugins/builtin/chat/layout.ts +5 -2
- package/src/plugins/builtin/chat/message/pane-chip.tsx +61 -40
- package/src/plugins/builtin/chat/message/render-state.ts +2 -5
- package/src/plugins/builtin/chat/message/terminal.tsx +13 -15
- package/src/plugins/builtin/chat/pane-links/previews.ts +51 -5
- package/src/plugins/builtin/chat/pane-links/share-card.ts +36 -0
- package/src/plugins/builtin/cloud/askg/attached-pane.tsx +10 -5
- package/src/plugins/builtin/cloud/askg/controller.ts +141 -5
- package/src/plugins/builtin/cloud/askg/executor.ts +113 -4
- package/src/plugins/builtin/cloud/askg/manifest.ts +28 -13
- package/src/plugins/builtin/cloud/askg/model.ts +14 -4
- package/src/plugins/builtin/cloud/askg/pane.tsx +70 -46
- package/src/plugins/builtin/cloud/askg/tool-display.ts +1 -0
- package/src/plugins/builtin/cloud/askg/turn-parts.tsx +70 -0
- package/src/plugins/builtin/cloud/terminal-relay/engine.ts +50 -130
- package/src/plugins/builtin/cloud/terminal-relay/policy.ts +327 -7
- package/src/plugins/builtin/cloud/terminal-relay/prompts.tsx +2 -1
- package/src/plugins/builtin/cloud/terminal-relay/redact.ts +52 -9
- package/src/plugins/builtin/commodities-energy/index.tsx +1 -3
- package/src/plugins/builtin/commodities-energy/view-state.ts +3 -0
- package/src/plugins/builtin/commodity-balances/index.tsx +1 -0
- package/src/plugins/builtin/company-attention/index.tsx +1 -1
- package/src/plugins/builtin/company-kpis/headless.ts +3 -1
- package/src/plugins/builtin/company-kpis/index.tsx +2 -2
- package/src/plugins/builtin/cot/headless.ts +14 -2
- package/src/plugins/builtin/cot/index.tsx +1 -1
- package/src/plugins/builtin/cpi/index.tsx +1 -1
- package/src/plugins/builtin/crypto-board/index.tsx +1 -0
- package/src/plugins/builtin/dividend-yield/index.tsx +1 -0
- package/src/plugins/builtin/doe/index.tsx +1 -1
- package/src/plugins/builtin/earnings/index.tsx +2 -2
- package/src/plugins/builtin/earnings-calls/headless.ts +5 -1
- package/src/plugins/builtin/earnings-calls/index.tsx +1 -0
- package/src/plugins/builtin/econ/calendar-model.ts +74 -1
- package/src/plugins/builtin/econ/fred-catalog.ts +3 -1
- package/src/plugins/builtin/econ/index.tsx +1 -0
- package/src/plugins/builtin/econ-statistics/index.tsx +1 -0
- package/src/plugins/builtin/econ-statistics/pane.tsx +6 -0
- package/src/plugins/builtin/estimate-revisions/index.tsx +1 -0
- package/src/plugins/builtin/executives/index.tsx +1 -0
- package/src/plugins/builtin/filing-events/index.tsx +1 -0
- package/src/plugins/builtin/fixed-income/index.tsx +1 -0
- package/src/plugins/builtin/futures/index.tsx +25 -4
- package/src/plugins/builtin/futures/model.ts +28 -32
- package/src/plugins/builtin/futures/series.ts +4 -3
- package/src/plugins/builtin/futures/table.tsx +16 -9
- package/src/plugins/builtin/futures/use-board-terms.ts +3 -3
- package/src/plugins/builtin/futures-curve/headless.ts +3 -3
- package/src/plugins/builtin/futures-curve/index.tsx +1 -1
- package/src/plugins/builtin/futures-curve/model.ts +18 -0
- package/src/plugins/builtin/gpu/index.tsx +1 -1
- package/src/plugins/builtin/help/functions-table.tsx +1 -1
- package/src/plugins/builtin/help/index.tsx +14 -4
- package/src/plugins/builtin/help/keybindings-editor.tsx +19 -5
- package/src/plugins/builtin/holders/index.tsx +1 -0
- package/src/plugins/builtin/holders/report-header.ts +2 -2
- package/src/plugins/builtin/insider/index.tsx +1 -0
- package/src/plugins/builtin/iv-history/index.tsx +1 -1
- package/src/plugins/builtin/jobs/index.tsx +1 -0
- package/src/plugins/builtin/layout-manager/index.tsx +8 -8
- package/src/plugins/builtin/macro-day/headless.ts +27 -8
- package/src/plugins/builtin/macro-day/index.tsx +1 -1
- package/src/plugins/builtin/macro-day/model.ts +19 -3
- package/src/plugins/builtin/macro-day/pane.tsx +14 -9
- package/src/plugins/builtin/macro-day/releases.ts +25 -7
- package/src/plugins/builtin/market-valuation/index.tsx +1 -0
- package/src/plugins/builtin/market-valuation/pane.tsx +8 -0
- package/src/plugins/builtin/members/index.tsx +1 -1
- package/src/plugins/builtin/mna/index.tsx +1 -0
- package/src/plugins/builtin/news/headless.ts +2 -2
- package/src/plugins/builtin/news/index.tsx +4 -3
- package/src/plugins/builtin/news/wire/index.tsx +5 -1
- package/src/plugins/builtin/news/wire/news/detail-view.tsx +4 -0
- package/src/plugins/builtin/news/wire/news/list-search.ts +5 -2
- package/src/plugins/builtin/options/index.tsx +1 -0
- package/src/plugins/builtin/options-positioning/index.tsx +1 -0
- package/src/plugins/builtin/pe-band/index.tsx +1 -1
- package/src/plugins/builtin/perps/markets-section.tsx +5 -2
- package/src/plugins/builtin/plugin-marketplace/pane.tsx +11 -11
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +25 -0
- package/src/plugins/builtin/portfolio-list/headless.ts +15 -6
- package/src/plugins/builtin/portfolio-list/summary/index.tsx +3 -1
- package/src/plugins/builtin/power/index.tsx +1 -1
- package/src/plugins/builtin/realized-vol/index.tsx +1 -1
- package/src/plugins/builtin/research/event-model.ts +9 -1
- package/src/plugins/builtin/research/event-sources.ts +22 -0
- package/src/plugins/builtin/research/headless.ts +11 -5
- package/src/plugins/builtin/research/index.tsx +4 -0
- package/src/plugins/builtin/research-search/index.tsx +1 -0
- package/src/plugins/builtin/research-search/pane.tsx +8 -0
- package/src/plugins/builtin/revenue-breakdown/index.tsx +1 -0
- package/src/plugins/builtin/reverse-dcf/index.tsx +1 -1
- package/src/plugins/builtin/risk-factors/index.tsx +1 -0
- package/src/plugins/builtin/scanner/headless.ts +52 -13
- package/src/plugins/builtin/seasonality/index.tsx +1 -1
- package/src/plugins/builtin/sec/index.tsx +1 -0
- package/src/plugins/builtin/series-inventory.ts +1 -1
- package/src/plugins/builtin/shared/cloud-upgrade.ts +27 -3
- package/src/plugins/builtin/shared/scanner-capture.ts +11 -3
- package/src/plugins/builtin/shared/series-list-detail.tsx +5 -0
- package/src/plugins/builtin/short-interest/index.tsx +1 -0
- package/src/plugins/builtin/social-mentions/index.tsx +1 -1
- package/src/plugins/builtin/supply-chain/index.tsx +1 -0
- package/src/plugins/builtin/thirteenf/data.ts +43 -10
- package/src/plugins/builtin/thirteenf/headless.ts +55 -11
- package/src/plugins/builtin/thirteenf/model.ts +25 -9
- package/src/plugins/builtin/thirteenf/report-notes.ts +27 -6
- package/src/plugins/builtin/thirteenf/types.ts +2 -0
- package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +1 -1
- package/src/plugins/builtin/ticker-detail/financials/model.ts +12 -0
- package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +3 -3
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +5 -5
- package/src/plugins/builtin/ticker-detail/headless.ts +18 -13
- package/src/plugins/builtin/ticker-detail/index.tsx +4 -0
- package/src/plugins/builtin/ticker-detail/overview/components.tsx +54 -5
- package/src/plugins/builtin/ticker-detail/overview/model.ts +6 -4
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +34 -17
- package/src/plugins/builtin/ticker-detail/pane.tsx +7 -2
- package/src/plugins/builtin/time-sales/client.ts +9 -11
- package/src/plugins/builtin/time-sales/index.tsx +1 -1
- package/src/plugins/builtin/treasury-auctions/after.ts +267 -0
- package/src/plugins/builtin/treasury-auctions/cache.ts +18 -3
- package/src/plugins/builtin/treasury-auctions/client.ts +33 -2
- package/src/plugins/builtin/treasury-auctions/headless.ts +109 -19
- package/src/plugins/builtin/treasury-auctions/index.tsx +14 -4
- package/src/plugins/builtin/treasury-auctions/model.ts +256 -28
- package/src/plugins/builtin/treasury-auctions/pane.tsx +139 -28
- package/src/plugins/builtin/treasury-auctions/treasury-direct.ts +5 -2
- package/src/plugins/builtin/treasury-auctions/types.ts +7 -1
- package/src/plugins/builtin/vol-surface/index.tsx +1 -1
- package/src/plugins/builtin/world-venue-map/index.ts +1 -0
- package/src/plugins/builtin/yield-curve/curves.ts +10 -4
- package/src/plugins/builtin/yield-curve/headless.ts +6 -2
- package/src/plugins/builtin/yield-curve/index.tsx +3 -3
- package/src/plugins/builtin/yield-curve/series.ts +10 -0
- package/src/plugins/builtin/yield-curve/world.ts +3 -1
- package/src/plugins/installer.ts +45 -0
- package/src/portfolio/column-values.ts +2 -1
- package/src/public/__snapshots__/public-api.test.ts.snap +4 -0
- package/src/public/remote.ts +7 -1
- package/src/remote/client.ts +191 -11
- package/src/remote/controller-utils.ts +13 -1
- package/src/remote/controller.ts +88 -26
- package/src/remote/endpoint.ts +24 -0
- package/src/remote/form.ts +59 -4
- package/src/remote/resources.ts +56 -19
- package/src/remote/schema.ts +22 -9
- package/src/remote/secrets.ts +12 -0
- package/src/remote/semantic-helpers.ts +29 -1
- package/src/remote/semantic-tree.tsx +44 -15
- package/src/remote/server.ts +2 -1
- package/src/remote/surface.tsx +192 -0
- package/src/remote/types.ts +5 -0
- package/src/renderers/cloudflare/worker.ts +16 -1
- package/src/renderers/dom/styles.css +40 -6
- package/src/renderers/opentui/host.tsx +6 -0
- package/src/renderers/share/layout-view.tsx +1 -1
- package/src/series/standalone.ts +2 -2
- package/src/shares/api.ts +21 -4
- package/src/shares/item.ts +73 -0
- package/src/shares/pane-item.ts +205 -0
- package/src/shares/pane.ts +4 -0
- package/src/shares/payload.ts +9 -5
- package/src/sources/gloomberb-cloud/news.ts +37 -12
- package/src/state/opening-ticker-panes.ts +47 -0
- package/src/test-support/cli-context.ts +2 -0
- package/src/test-support/preload.ts +4 -1
- package/src/tickers/instrument-kind.ts +23 -3
- package/src/tickers/renamed-listings.ts +105 -0
- package/src/tickers/search/index.ts +103 -16
- package/src/time-series/resolve.ts +2 -2
- package/src/types/config.ts +5 -0
- package/src/types/context-menu.ts +2 -0
- package/src/types/financials.ts +1 -0
- package/src/types/plugin-commands.ts +140 -0
- package/src/types/plugin-context.ts +125 -0
- package/src/types/plugin-contributions.ts +55 -0
- package/src/types/plugin-definition.ts +234 -0
- package/src/types/plugin-notifications.ts +38 -0
- package/src/types/plugin-pane-settings.ts +116 -0
- package/src/types/plugin-pane-templates.ts +160 -0
- package/src/types/plugin-panes.ts +243 -0
- package/src/types/plugin-reports.ts +35 -0
- package/src/types/plugin-shared.ts +14 -0
- package/src/types/plugin-state.ts +71 -0
- package/src/types/plugin.ts +14 -1169
- package/src/ui/index.tsx +14 -3
- package/src/updater/github-releases.ts +23 -0
- package/src/utils/central-banks.ts +86 -1
- package/src/utils/cli-output.ts +22 -9
- package/src/utils/datetime-format.ts +12 -3
- package/src/utils/depositary-receipt.ts +28 -3
- package/src/utils/fundamentals.ts +14 -0
- package/src/utils/max-drawdown.ts +97 -16
- package/src/utils/untrusted-text.ts +29 -0
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
searchThirteenFFunds,
|
|
14
14
|
} from "./api";
|
|
15
15
|
import { isoDateDaysAgo, isoDateToday, isoDateYearsAgo } from "../../../utils/calendar-date";
|
|
16
|
-
import { abortable, withDeadline } from "../../../utils/async-deadline";
|
|
16
|
+
import { abortable, OperationTimeoutError, withDeadline } from "../../../utils/async-deadline";
|
|
17
17
|
import { logFailure } from "../../../utils/log-failure";
|
|
18
18
|
import {
|
|
19
19
|
amendmentKind,
|
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
dedupeLatestForms,
|
|
28
28
|
filingSplitCandidates,
|
|
29
29
|
type FilingQuarterReturn,
|
|
30
|
+
type SplitFactors,
|
|
30
31
|
} from "./model";
|
|
31
32
|
import { mapWithConcurrency } from "../../../utils/concurrency";
|
|
32
33
|
import { describeTickerChange, movedAwayChange, startTickerChangeLookup } from "../../../tickers/ticker-changes";
|
|
@@ -373,6 +374,8 @@ export interface FundPerformanceResult extends BrowserLoadResult {
|
|
|
373
374
|
/** Lines of a filings estimate split between the filings (priced split-adjusted) and those left out; see estimateFilingQuarterReturn. */
|
|
374
375
|
splits?: FilingQuarterReturn["splits"];
|
|
375
376
|
skipped?: FilingQuarterReturn["skipped"];
|
|
377
|
+
/** What the lines left out weighed in the book at the quarter's start, as a fraction. */
|
|
378
|
+
skippedShare?: number;
|
|
376
379
|
/** What EDGAR shows for the quarter after the fund's latest report, when it is behind (loadFundDetail). */
|
|
377
380
|
filingGap?: ThirteenFFilingGap | null;
|
|
378
381
|
/** Why there is no estimate, when there is none. */
|
|
@@ -429,31 +432,60 @@ const SPLIT_LOOKUP_CONCURRENCY = 6;
|
|
|
429
432
|
/** How long one ticker's corporate actions are waited for before its split reads as unconfirmed. */
|
|
430
433
|
const SPLIT_LOOKUP_TIMEOUT_MS = 10_000;
|
|
431
434
|
|
|
435
|
+
/** Which split candidates loadSplitFactors reads. */
|
|
436
|
+
export interface SplitFactorScope {
|
|
437
|
+
/** Only these row ids: a report of a large filer's biggest positions reads theirs, not the hundreds of lines across its book that move like a split. */
|
|
438
|
+
only?: ReadonlySet<string>;
|
|
439
|
+
/**
|
|
440
|
+
* How long the whole pass may take. Lines are read largest first, and one not answered by then reads as
|
|
441
|
+
* unconfirmed, as a lookup past its own timeout does, and is listed in the result's `late`.
|
|
442
|
+
*/
|
|
443
|
+
budgetMs?: number;
|
|
444
|
+
}
|
|
445
|
+
|
|
432
446
|
/**
|
|
433
447
|
* The split factor between a fund's two quarter ends for each of its split
|
|
434
448
|
* candidates (filingSplitCandidates), by row id, for estimateFilingQuarterReturn
|
|
435
449
|
* and the Holdings rows: a few lookups at once, each as the lookup answers it.
|
|
436
450
|
* A line the lookup cannot answer for (no ticker, a failure, no answer in time)
|
|
437
|
-
* is null, unconfirmed
|
|
438
|
-
*
|
|
451
|
+
* is null, unconfirmed; one the budget ran out on is in `late` as well. Only
|
|
452
|
+
* an abort rejects. A fund with no candidates, or without two comparable
|
|
453
|
+
* quarters, makes no lookup.
|
|
439
454
|
*/
|
|
440
|
-
export async function loadSplitFactors(
|
|
455
|
+
export async function loadSplitFactors(
|
|
456
|
+
detail: FundDetailData,
|
|
457
|
+
lookup: SplitFactorLookup,
|
|
458
|
+
signal?: AbortSignal,
|
|
459
|
+
scope: SplitFactorScope = {},
|
|
460
|
+
): Promise<Map<string, number | null> & { late: ReadonlySet<string> }> {
|
|
461
|
+
const late = new Set<string>();
|
|
441
462
|
const period = detail.latestForm?.periodOfReport;
|
|
442
463
|
const previousPeriod = detail.previousForm?.periodOfReport;
|
|
443
|
-
if (!period || !previousPeriod) return new Map();
|
|
444
|
-
|
|
464
|
+
if (!period || !previousPeriod) return Object.assign(new Map<string, number | null>(), { late });
|
|
465
|
+
const candidates = filingSplitCandidates(detail).filter((line) => !scope.only || scope.only.has(line.id));
|
|
466
|
+
const endsAt = scope.budgetMs == null ? Infinity : Date.now() + scope.budgetMs;
|
|
467
|
+
const factors = await mapWithConcurrency(candidates, SPLIT_LOOKUP_CONCURRENCY, async (line) => {
|
|
445
468
|
signal?.throwIfAborted();
|
|
446
469
|
if (!line.ticker) return [line.id, null] as const;
|
|
470
|
+
const left = Math.min(SPLIT_LOOKUP_TIMEOUT_MS, endsAt - Date.now());
|
|
471
|
+
if (left <= 0) {
|
|
472
|
+
late.add(line.id);
|
|
473
|
+
return [line.id, null] as const;
|
|
474
|
+
}
|
|
475
|
+
// A deadline shorter than a lookup's own is the budget's end.
|
|
476
|
+
const budgetEnds = left < SPLIT_LOOKUP_TIMEOUT_MS;
|
|
447
477
|
const factor = await abortable(
|
|
448
|
-
withDeadline(lookup(line.ticker, previousPeriod, period),
|
|
478
|
+
withDeadline(lookup(line.ticker, previousPeriod, period), left, `${line.ticker} split lookup timed out`),
|
|
449
479
|
signal,
|
|
450
480
|
"Split lookup aborted",
|
|
451
481
|
).catch((error: unknown) => {
|
|
452
482
|
if (signal?.aborted) throw error;
|
|
483
|
+
if (budgetEnds && error instanceof OperationTimeoutError) late.add(line.id);
|
|
453
484
|
return null;
|
|
454
485
|
});
|
|
455
486
|
return [line.id, factor] as const;
|
|
456
|
-
})
|
|
487
|
+
});
|
|
488
|
+
return Object.assign(new Map<string, number | null>(factors), { late });
|
|
457
489
|
}
|
|
458
490
|
|
|
459
491
|
/**
|
|
@@ -468,7 +500,7 @@ export async function loadFundPerformance(
|
|
|
468
500
|
cik: string,
|
|
469
501
|
fallbackName: string,
|
|
470
502
|
signal?: AbortSignal,
|
|
471
|
-
options: Pick<Forms13FReadOptions, "forceRefresh" | "onSavedCopy"> & { splitFactor?: SplitFactorLookup } = {},
|
|
503
|
+
options: Pick<Forms13FReadOptions, "forceRefresh" | "onSavedCopy"> & { splitFactor?: SplitFactorLookup; splitBudgetMs?: number } = {},
|
|
472
504
|
): Promise<FundPerformanceResult> {
|
|
473
505
|
const warnings: string[] = [];
|
|
474
506
|
const saved = savedCopies(options.onSavedCopy);
|
|
@@ -490,7 +522,7 @@ export async function loadFundPerformance(
|
|
|
490
522
|
const own = ranked?.find((fund) => fund.cik === detail.cik && fund.periodOfReport === period);
|
|
491
523
|
const ranking = !quarter ? null : !ranked ? "unavailable" : own ? "ranked" : "unranked";
|
|
492
524
|
// A line that moved as across a split is priced by its corporate actions: split-adjusted, as a trade, or left out unread.
|
|
493
|
-
const factors = own?.pnl != null || !options.splitFactor ? new Map
|
|
525
|
+
const factors: SplitFactors = own?.pnl != null || !options.splitFactor ? new Map() : await loadSplitFactors(detail, options.splitFactor, signal, { budgetMs: options.splitBudgetMs });
|
|
494
526
|
const filed = own?.pnl != null ? null : estimateFilingQuarterReturn(detail, factors);
|
|
495
527
|
const estimate = own?.pnl ?? filed?.percent ?? null;
|
|
496
528
|
const basis = own?.pnl != null ? "ranking" : estimate != null ? "filings" : null;
|
|
@@ -520,6 +552,7 @@ export async function loadFundPerformance(
|
|
|
520
552
|
rows: [row], ...(quarter ? { quarter } : {}), ...(period ? { period } : {}), hasMore: false, basis, ranking,
|
|
521
553
|
...(filed?.splits.length ? { splits: filed.splits } : {}),
|
|
522
554
|
...(filed?.skipped.length ? { skipped: filed.skipped } : {}),
|
|
555
|
+
...(filed?.skippedShare != null ? { skippedShare: filed.skippedShare } : {}),
|
|
523
556
|
...(detail.filingGap ? { filingGap: detail.filingGap } : {}),
|
|
524
557
|
...(unavailable ? { unavailable } : {}), ...(warning ? { warning } : {}),
|
|
525
558
|
};
|
|
@@ -72,6 +72,7 @@ import {
|
|
|
72
72
|
sortBrowserRows,
|
|
73
73
|
sortHoldingRows,
|
|
74
74
|
sortTimelineRows,
|
|
75
|
+
type SplitFactors,
|
|
75
76
|
} from "./model";
|
|
76
77
|
import {
|
|
77
78
|
actionLabel,
|
|
@@ -216,8 +217,8 @@ export interface ThirteenFHeadlessDependencies {
|
|
|
216
217
|
args: HeadlessPaneLoadArgs,
|
|
217
218
|
ctx: HeadlessPaneContext,
|
|
218
219
|
): Promise<FundDetailData>;
|
|
219
|
-
/** The split factor of each of a fund's split candidates between its two quarter ends (loadSplitFactors), for its Est P&L. */
|
|
220
|
-
loadSplitFactors?(detail: FundDetailData, ctx: HeadlessPaneContext): Promise<
|
|
220
|
+
/** The split factor of each of a fund's split candidates between its two quarter ends (loadSplitFactors), for its Est P&L; with `only`, of those rows alone. */
|
|
221
|
+
loadSplitFactors?(detail: FundDetailData, ctx: HeadlessPaneContext, only?: ReadonlySet<string>): Promise<SplitFactors>;
|
|
221
222
|
/** What a fund in a search filed for the newest quarter past its deadline, from EDGAR. */
|
|
222
223
|
loadFilingGap?(cik: string, latestPeriod: string | null | undefined, ctx: HeadlessPaneContext): Promise<ThirteenFFilingGap | null>;
|
|
223
224
|
/** 13F filers whose names contain `query`, without their reports. */
|
|
@@ -255,6 +256,16 @@ async function readingSavedCopies<T extends object>(ctx: HeadlessPaneContext, ru
|
|
|
255
256
|
}
|
|
256
257
|
}
|
|
257
258
|
|
|
259
|
+
/**
|
|
260
|
+
* How long a report waits on its split lookups, largest lines first. A large
|
|
261
|
+
* filer off the ranking has a few hundred lines that move like a split (its
|
|
262
|
+
* Est 13F reads them all), and its 200 largest can hold dozens (its Holdings
|
|
263
|
+
* read theirs); read cold, they took 15 to 35 s, past what an Ask Gloom tool
|
|
264
|
+
* call is given. A line not read in time has no Est P&L, is left out of the
|
|
265
|
+
* Est 13F, and is named as one the time ran out on.
|
|
266
|
+
*/
|
|
267
|
+
const SPLIT_LOOKUP_BUDGET_MS = 8_000;
|
|
268
|
+
|
|
258
269
|
const defaultDependencies: Required<ThirteenFHeadlessDependencies> = {
|
|
259
270
|
loadBrowser: (tab, query, limit, _args, ctx) => loadBrowserRows(
|
|
260
271
|
tab,
|
|
@@ -264,15 +275,17 @@ const defaultDependencies: Required<ThirteenFHeadlessDependencies> = {
|
|
|
264
275
|
),
|
|
265
276
|
// An overlap never shows a fund's missed quarter, so it does not ask EDGAR.
|
|
266
277
|
loadDetail: (cik, name, args, ctx) => loadFundDetail(cik, name, ctx.signal, { filingGap: !isOverlapLoad(args), onSavedCopy: noteSavedCopy(ctx) }),
|
|
267
|
-
loadSplitFactors: (detail, ctx) => loadSplitFactors(
|
|
278
|
+
loadSplitFactors: (detail, ctx, only) => loadSplitFactors(
|
|
268
279
|
detail,
|
|
269
280
|
(ticker, after, through) => corporateSplitFactor(ctx.marketData, ticker, after, through),
|
|
270
281
|
ctx.signal,
|
|
282
|
+
{ only, budgetMs: SPLIT_LOOKUP_BUDGET_MS },
|
|
271
283
|
),
|
|
272
284
|
loadFilingGap: (cik, latestPeriod, ctx) => loadFilingGap(cik, latestPeriod, ctx.signal),
|
|
273
285
|
searchFunds: (query, ctx) => searchThirteenFFunds(query, THIRTEENF_MAX_LIMIT, ctx.signal),
|
|
274
286
|
loadPerformance: (cik, name, ctx) => loadFundPerformance(cik, name, ctx.signal, {
|
|
275
287
|
splitFactor: (ticker, after, through) => corporateSplitFactor(ctx.marketData, ticker, after, through),
|
|
288
|
+
splitBudgetMs: SPLIT_LOOKUP_BUDGET_MS,
|
|
276
289
|
onSavedCopy: noteSavedCopy(ctx),
|
|
277
290
|
}),
|
|
278
291
|
loadEtfFunds: async (ctx) => (await fetchFunds(ctx.apiClient)).funds,
|
|
@@ -333,10 +346,24 @@ function browserTab(view: HeadlessThirteenFView, query: string): ThirteenFBrowse
|
|
|
333
346
|
/** What to search by instead, after a search that found no 13F filer. */
|
|
334
347
|
const SEARCH_HINT = 'Search by fund name or CIK, as in fn 13F "Berkshire Hathaway".';
|
|
335
348
|
|
|
349
|
+
/** Legal forms a manager's filed name ends with and nobody says: "Citadel Advisors" is CITADEL ADVISORS LLC. */
|
|
350
|
+
const LEGAL_FORMS = new Set(["llc", "lp", "llp", "lllp", "pllc", "inc", "incorporated", "corp", "corporation", "co", "company", "ltd", "limited", "plc", "sa", "ag", "gmbh", "nv", "bv", "se", "the"]);
|
|
351
|
+
|
|
352
|
+
/** A manager's name as said: lowercase words, without punctuation or a trailing legal form. */
|
|
353
|
+
function spokenName(name: string): string {
|
|
354
|
+
const words = name.toLocaleLowerCase().replace(/\./g, "").split(/[^\p{L}\p{N}&]+/u).filter(Boolean);
|
|
355
|
+
while (words.length > 1 && LEGAL_FORMS.has(words.at(-1)!)) words.pop();
|
|
356
|
+
return words.join(" ");
|
|
357
|
+
}
|
|
358
|
+
|
|
336
359
|
/**
|
|
337
360
|
* The manager a fund name or CIK names: a CIK as given, else the one fund
|
|
338
|
-
* whose name matches exactly,
|
|
339
|
-
* name
|
|
361
|
+
* whose name matches exactly, as said without its legal form, or as the
|
|
362
|
+
* first whole words of its name ("ARK Investment Management" is ARK
|
|
363
|
+
* Investment Management LLC, not Spark Investment Management), else the only
|
|
364
|
+
* match. Several managers that fit are named, those that fit first and the
|
|
365
|
+
* largest books first, for the caller to pick one by CIK. `search` lists
|
|
366
|
+
* funds by name, as the 13F browser does.
|
|
340
367
|
*/
|
|
341
368
|
async function findThirteenFFund(
|
|
342
369
|
query: string,
|
|
@@ -348,13 +375,27 @@ async function findThirteenFFund(
|
|
|
348
375
|
const result = await search(query, 25);
|
|
349
376
|
await result.reportsLoaded;
|
|
350
377
|
const candidates = [...new Map(result.rows.map((row) => [row.cik, row])).values()];
|
|
378
|
+
const said = spokenName(query);
|
|
351
379
|
const exact = candidates.filter((row) => row.name.toLocaleLowerCase() === query.toLocaleLowerCase());
|
|
352
|
-
|
|
353
|
-
const
|
|
354
|
-
|
|
380
|
+
const named = candidates.filter((row) => spokenName(row.name) === said);
|
|
381
|
+
const leading = candidates.filter((row) => spokenName(row.name).startsWith(`${said} `) || spokenName(row.name) === said);
|
|
382
|
+
const only = (rows: typeof candidates) => (rows.length === 1 ? rows[0] : undefined);
|
|
383
|
+
// A word that may be a ticker ("SPY") names a manager only by its exact name, never by "SPY Inc".
|
|
384
|
+
if (exactOnly) {
|
|
385
|
+
const match = only(exact);
|
|
386
|
+
return match ? { cik: match.cik, name: match.name } : null;
|
|
387
|
+
}
|
|
388
|
+
// A name only some funds start with names one of them only when the search listed every fund it matched.
|
|
389
|
+
const complete = !result.hasMore;
|
|
390
|
+
const fund = only(exact) ?? only(named) ?? (complete ? only(leading) : undefined) ?? (candidates.length === 1 && complete ? candidates[0] : undefined);
|
|
355
391
|
if (candidates.length === 0) throw new Error(notFound ?? `No 13F fund found for "${query}". ${SEARCH_HINT}`);
|
|
356
392
|
if (!fund) {
|
|
357
|
-
const
|
|
393
|
+
const fits = new Set(leading);
|
|
394
|
+
const choices = candidates
|
|
395
|
+
.toSorted((left, right) => Number(fits.has(right)) - Number(fits.has(left)) || (right.tableValueTotal ?? -1) - (left.tableValueTotal ?? -1))
|
|
396
|
+
.slice(0, 5)
|
|
397
|
+
.map((row) => `${row.name} (${row.cik}${row.tableValueTotal ? `, ${formatMoneyCompact(row.tableValueTotal)} reported` : ""})`)
|
|
398
|
+
.join("; ");
|
|
358
399
|
throw new Error(`Ambiguous 13F fund "${query}". Use an exact fund name or CIK: ${choices}.`);
|
|
359
400
|
}
|
|
360
401
|
return { cik: fund.cik, name: fund.name };
|
|
@@ -755,8 +796,11 @@ export function createThirteenFHeadless(
|
|
|
755
796
|
};
|
|
756
797
|
}
|
|
757
798
|
// A line that moved as across a split gets its Est P&L from its corporate actions: split-adjusted, as a trade, or none.
|
|
799
|
+
// The rows go largest value first, which no split moves, so only the rows shown have theirs read: a large
|
|
800
|
+
// filer's book holds hundreds of such lines (Citadel's 264 took 27 s), its top 50 a handful.
|
|
801
|
+
const shown = new Set(sortHoldingRows(buildFundHoldingRows(detail), DEFAULT_HOLDING_SORT).slice(0, limit).map((row) => row.id));
|
|
758
802
|
const all = sortHoldingRows(
|
|
759
|
-
buildFundHoldingRows(detail, await dependencies.loadSplitFactors(detail, ctx)),
|
|
803
|
+
buildFundHoldingRows(detail, await dependencies.loadSplitFactors(detail, ctx, shown)),
|
|
760
804
|
DEFAULT_HOLDING_SORT,
|
|
761
805
|
);
|
|
762
806
|
const previousPeriod = detail.previousForm?.periodOfReport ?? null;
|
|
@@ -864,7 +908,7 @@ export function createThirteenFHeadless(
|
|
|
864
908
|
...flagNotices,
|
|
865
909
|
estimated ? `Est 13F: from the ${estimated} filings, the Est P&L of positions held through the quarter over their value at its start${rankingText ? ` (${rankingText})` : ""}` : "",
|
|
866
910
|
performance.splits?.length ? splitAdjustedText(performance.splits) : "",
|
|
867
|
-
performance.skipped?.length ? splitUnreadText(performance.skipped, "Left out of Est 13F") : "",
|
|
911
|
+
performance.skipped?.length ? splitUnreadText(performance.skipped, "Left out of Est 13F", performance.skippedShare) : "",
|
|
868
912
|
performance.unavailable ? `No Est 13F${rankingText ? ` (${rankingText})` : ""}: ${performance.unavailable}` : "",
|
|
869
913
|
...filingGapNotes(performance.period ?? null, performance.filingGap ?? null),
|
|
870
914
|
`Copy this basket: gloom portfolio import --13f ${row.cik}`,
|
|
@@ -434,8 +434,9 @@ interface HoldingLine {
|
|
|
434
434
|
/**
|
|
435
435
|
* Each line's split factor by row id, new shares per old: 1 when its corporate
|
|
436
436
|
* actions show no split between the filings, null when they could not be read.
|
|
437
|
+
* `late` holds the lines left unread because the lookups' time ran out.
|
|
437
438
|
*/
|
|
438
|
-
export type SplitFactors = ReadonlyMap<string, number | null
|
|
439
|
+
export type SplitFactors = ReadonlyMap<string, number | null> & { readonly late?: ReadonlySet<string> };
|
|
439
440
|
|
|
440
441
|
/**
|
|
441
442
|
* The Est P&L of a line held through the quarter, and the value of the shares
|
|
@@ -490,8 +491,13 @@ export interface FilingQuarterReturn {
|
|
|
490
491
|
percent: number | null;
|
|
491
492
|
/** Lines split between the filings, priced on split-adjusted shares, with the new shares per old (10 for 10:1, 0.1 for 1:10). */
|
|
492
493
|
splits: Array<FilingLine & { ratio: number }>;
|
|
493
|
-
/**
|
|
494
|
-
|
|
494
|
+
/**
|
|
495
|
+
* Lines that moved as across a split whose corporate actions could not be read, left out, largest at the
|
|
496
|
+
* quarter's start first; `late` when the lookups' time ran out before them.
|
|
497
|
+
*/
|
|
498
|
+
skipped: Array<FilingLine & { previousValue: number; late?: boolean }>;
|
|
499
|
+
/** What `skipped` weighed in the book at the quarter's start, as a fraction; null when none is left out or the book has no value. */
|
|
500
|
+
skippedShare: number | null;
|
|
495
501
|
}
|
|
496
502
|
|
|
497
503
|
/** The least change in a line's share count that reads as a split: 3:2. */
|
|
@@ -531,7 +537,11 @@ export function formatSplitRatio(ratio: number): string {
|
|
|
531
537
|
* no factor is known.
|
|
532
538
|
*/
|
|
533
539
|
export function filingSplitCandidates(data: FundDetailData): Array<FilingLine & { id: string }> {
|
|
534
|
-
return buildFundHoldingRows(data)
|
|
540
|
+
return buildFundHoldingRows(data)
|
|
541
|
+
.filter((row) => row.splitUnread)
|
|
542
|
+
// Largest at the start of the quarter first: the lines that weigh most on an estimate are read first.
|
|
543
|
+
.sort((a, b) => (b.previousValue ?? 0) - (a.previousValue ?? 0))
|
|
544
|
+
.map((row) => ({ id: row.id, ticker: row.ticker, issuer: row.issuer }));
|
|
535
545
|
}
|
|
536
546
|
|
|
537
547
|
/**
|
|
@@ -551,20 +561,26 @@ export function filingSplitCandidates(data: FundDetailData): Array<FilingLine &
|
|
|
551
561
|
*/
|
|
552
562
|
export function estimateFilingQuarterReturn(data: FundDetailData, splits: SplitFactors = new Map()): FilingQuarterReturn {
|
|
553
563
|
const adjusted: FilingQuarterReturn["splits"] = [];
|
|
554
|
-
const skipped:
|
|
555
|
-
if (!hasComparable13FQuarter(data)) return { percent: null, splits: adjusted, skipped };
|
|
564
|
+
const skipped: FilingQuarterReturn["skipped"] = [];
|
|
565
|
+
if (!hasComparable13FQuarter(data)) return { percent: null, splits: adjusted, skipped, skippedShare: null };
|
|
556
566
|
let pnl = 0;
|
|
557
567
|
let base = 0;
|
|
568
|
+
let book = 0;
|
|
558
569
|
for (const row of buildFundHoldingRows(data)) {
|
|
570
|
+
book += row.previousValue != null && row.previousValue > 0 ? row.previousValue : 0;
|
|
559
571
|
const estimate = estimateHolding(row, splits);
|
|
560
572
|
const line = { ticker: row.ticker, issuer: row.issuer };
|
|
561
|
-
if (estimate.kind === "unread")
|
|
573
|
+
if (estimate.kind === "unread") {
|
|
574
|
+
skipped.push({ ...line, previousValue: row.previousValue ?? 0, ...(splits.late?.has(row.id) ? { late: true } : {}) });
|
|
575
|
+
}
|
|
562
576
|
if (estimate.kind !== "priced") continue;
|
|
563
577
|
if (estimate.ratio !== 1) adjusted.push({ ...line, ratio: estimate.ratio });
|
|
564
578
|
pnl += estimate.pnl;
|
|
565
579
|
base += estimate.base;
|
|
566
580
|
}
|
|
567
|
-
|
|
581
|
+
skipped.sort((left, right) => right.previousValue - left.previousValue);
|
|
582
|
+
const left = skipped.reduce((sum, line) => sum + line.previousValue, 0);
|
|
583
|
+
return { percent: base > 0 ? (pnl / base) * 100 : null, splits: adjusted, skipped, skippedShare: skipped.length && book > 0 ? left / book : null };
|
|
568
584
|
}
|
|
569
585
|
|
|
570
586
|
export function hasComparable13FQuarter(data: FundDetailData): boolean {
|
|
@@ -672,7 +688,7 @@ export function buildFundHoldingRows(data: FundDetailData | null, splits?: Split
|
|
|
672
688
|
valueChange,
|
|
673
689
|
estimatedPnl: estimate.kind === "priced" ? estimate.pnl : null,
|
|
674
690
|
...(ratio !== 1 ? { splitRatio: ratio } : {}),
|
|
675
|
-
...(estimate.kind === "unread" ? { splitUnread: true } : {}),
|
|
691
|
+
...(estimate.kind === "unread" ? { splitUnread: true, ...(splits?.late?.has(id) ? { splitLate: true } : {}) } : {}),
|
|
676
692
|
sharesChange,
|
|
677
693
|
sharesChangePercent,
|
|
678
694
|
action: comparable ? resolveAction(currentHolding, previousHolding, ratio) : "unknown",
|
|
@@ -140,19 +140,40 @@ export function splitAdjustedText(lines: readonly (SplitLine & { ratio: number }
|
|
|
140
140
|
return `${prefix}: ${listedLines(lines, (line) => `${lineName(line)} ${formatSplitRatio(line.ratio)}`)} (split between the filings, as the corporate actions show)`;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
/**
|
|
144
|
-
|
|
145
|
-
|
|
143
|
+
/** Why lines that moved as across a split have no figure: their corporate actions could not be read, or the time to read them ran out. */
|
|
144
|
+
function unreadReason(lines: readonly (SplitLine & { late?: boolean })[]): string {
|
|
145
|
+
const late = lines.filter((line) => line.late).length;
|
|
146
|
+
const failed = lines.length - late;
|
|
147
|
+
if (late === 0) return "the corporate actions could not be read to tell";
|
|
148
|
+
if (failed === 0) return "the report ran out of time before reading their corporate actions";
|
|
149
|
+
return `the report ran out of time before reading the corporate actions of ${count(late)}; those of ${count(failed)} could not be read`;
|
|
146
150
|
}
|
|
147
151
|
|
|
152
|
+
/** "4.2%" of a book, or "under 0.1%". */
|
|
153
|
+
function bookShareText(share: number): string {
|
|
154
|
+
return share < 0.001 ? "under 0.1%" : `${(share * 100).toFixed(1)}%`;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* "No Est P&L: XYZ (shares and value per share moved as across a split, and the corporate actions could not be
|
|
159
|
+
* read to tell)": lines left without a figure, in the order given (largest first), `leftOut` opening it, and with
|
|
160
|
+
* `bookShare` what they weighed in the book at the quarter's start.
|
|
161
|
+
*/
|
|
162
|
+
export function splitUnreadText(lines: readonly (SplitLine & { late?: boolean })[], leftOut: string, bookShare?: number | null): string {
|
|
163
|
+
const share = bookShare != null && bookShare > 0 ? `, ${bookShareText(bookShare)} of the book at the quarter's start` : "";
|
|
164
|
+
return `${leftOut}${share}: ${listedLines(lines, lineName)} (shares and value per share moved as across a split, and ${unreadReason(lines)})`;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
type UnreadRow = SplitLine & { splitUnread?: boolean; splitLate?: boolean };
|
|
168
|
+
|
|
148
169
|
/** The note for the lines of a Holdings table left without an Est P&L because their split could not be confirmed: a data limitation, the pane's notice as well as the report's. */
|
|
149
|
-
export function holdingUnreadNotes(rows: readonly
|
|
150
|
-
const unread = rows.filter((row) => row.splitUnread);
|
|
170
|
+
export function holdingUnreadNotes(rows: readonly UnreadRow[]): string[] {
|
|
171
|
+
const unread = rows.filter((row) => row.splitUnread).map((row) => ({ ...row, late: row.splitLate }));
|
|
151
172
|
return unread.length ? [splitUnreadText(unread, "No Est P&L")] : [];
|
|
152
173
|
}
|
|
153
174
|
|
|
154
175
|
/** What a Holdings report says of its lines that moved as across a split: the ones priced split-adjusted (method, so a report's note only), and the ones left without a figure. */
|
|
155
|
-
export function holdingSplitNotes(rows: readonly (
|
|
176
|
+
export function holdingSplitNotes(rows: readonly (UnreadRow & { splitRatio?: number })[]): string[] {
|
|
156
177
|
const adjusted = rows.flatMap((row) => row.splitRatio ? [{ ...row, ratio: row.splitRatio }] : []);
|
|
157
178
|
return [...(adjusted.length ? [splitAdjustedText(adjusted, "Est P&L split-adjusted")] : []), ...holdingUnreadNotes(rows)];
|
|
158
179
|
}
|
|
@@ -195,6 +195,8 @@ export interface FundHoldingRow {
|
|
|
195
195
|
splitRatio?: number;
|
|
196
196
|
/** The line moved as across a split and its corporate actions could not be read to tell: Est P&L is left empty, not priced as a crash or a surge, and its share change stays as filed. */
|
|
197
197
|
splitUnread?: boolean;
|
|
198
|
+
/** With `splitUnread`: the lookups' time ran out before its corporate actions were read. */
|
|
199
|
+
splitLate?: boolean;
|
|
198
200
|
sharesChange: number | null;
|
|
199
201
|
sharesChangePercent: number | null;
|
|
200
202
|
action: HoldingAction;
|
|
@@ -90,7 +90,7 @@ export function adrPairFigures(comparison: DepositaryPairComparison): AdrPairFig
|
|
|
90
90
|
value: comparison.premiumPercent == null ? "—" : premiumText(comparison.premiumPercent),
|
|
91
91
|
...(comparison.premiumPercent == null ? {} : { detail: "at spot" }),
|
|
92
92
|
},
|
|
93
|
-
{ id: "ratio", label: "Ratio", value: adrRatioText(comparison.ratio) ?? `1:${ratioCount(comparison.ratio)}` },
|
|
93
|
+
{ id: "ratio", label: "Ratio", value: adrRatioText(comparison.ratio, comparison.home.symbol) ?? `1:${ratioCount(comparison.ratio)}` },
|
|
94
94
|
];
|
|
95
95
|
}
|
|
96
96
|
|
|
@@ -99,6 +99,18 @@ export function statementMetricValue(
|
|
|
99
99
|
|
|
100
100
|
export const FINANCIAL_COL_W = 18;
|
|
101
101
|
export const FINANCIAL_LABEL_W = 28;
|
|
102
|
+
const FINANCIAL_LABEL_MIN_W = 12;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The metric column's width in a table `width` cells wide: 28 where a period
|
|
106
|
+
* fits beside it, narrower (down to 12, labels cut with an ellipsis) where it
|
|
107
|
+
* would otherwise take every value off screen, as a 36-column Financials pane
|
|
108
|
+
* once showed nothing but metric names and "more →". The other 6 cells are the
|
|
109
|
+
* pane's padding, the table's, the column gap and the scrollbar.
|
|
110
|
+
*/
|
|
111
|
+
export function financialLabelWidth(width: number): number {
|
|
112
|
+
return Math.max(FINANCIAL_LABEL_MIN_W, Math.min(FINANCIAL_LABEL_W, width - FINANCIAL_COL_W - 6));
|
|
113
|
+
}
|
|
102
114
|
const FINANCIAL_GROWTH_W = 7;
|
|
103
115
|
const FINANCIAL_VALUE_W = FINANCIAL_COL_W - FINANCIAL_GROWTH_W;
|
|
104
116
|
|
|
@@ -12,7 +12,7 @@ import type { PricePoint } from "../../../../types/financials";
|
|
|
12
12
|
import { padTo } from "../../../../utils/format";
|
|
13
13
|
import { useBoundTicker, useTickerRequest } from "../../shared/ticker-request";
|
|
14
14
|
import type { FinancialTableStatement } from "./aggregation";
|
|
15
|
-
import { FINANCIAL_COL_W,
|
|
15
|
+
import { FINANCIAL_COL_W, financialLabelWidth } from "./model";
|
|
16
16
|
import { loadPeriodEndHistory } from "./period-end-history";
|
|
17
17
|
import {
|
|
18
18
|
formatRatioInput,
|
|
@@ -170,6 +170,6 @@ export function RatioTable({
|
|
|
170
170
|
);
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
-
export function ratioMetricColumn(): RatioTableColumn {
|
|
174
|
-
return { id: "metric", kind: "metric", label: "Ratio", width:
|
|
173
|
+
export function ratioMetricColumn(width: number): RatioTableColumn {
|
|
174
|
+
return { id: "metric", kind: "metric", label: "Ratio", width: financialLabelWidth(width), align: "left" };
|
|
175
175
|
}
|
|
@@ -19,7 +19,7 @@ import { padTo } from "../../../../utils/format";
|
|
|
19
19
|
import { filledPeriodsNote, stalePeriodNote } from "../../../../utils/financial-statements";
|
|
20
20
|
import {
|
|
21
21
|
FINANCIAL_COL_W,
|
|
22
|
-
|
|
22
|
+
financialLabelWidth,
|
|
23
23
|
FINANCIAL_SUB_TABS,
|
|
24
24
|
buildFinancialRows,
|
|
25
25
|
canCompareFinancialRow,
|
|
@@ -305,7 +305,7 @@ export function ResolvedFinancialsTab({
|
|
|
305
305
|
id: "metric",
|
|
306
306
|
kind: "metric",
|
|
307
307
|
label: "Metric",
|
|
308
|
-
width:
|
|
308
|
+
width: financialLabelWidth(width),
|
|
309
309
|
align: "left",
|
|
310
310
|
},
|
|
311
311
|
...displayStatements.map((statement, index): FinancialTableColumn => ({
|
|
@@ -323,7 +323,7 @@ export function ResolvedFinancialsTab({
|
|
|
323
323
|
align: "right",
|
|
324
324
|
headerColor: statement.date === "TTM" ? colors.textBright : colors.textDim,
|
|
325
325
|
})),
|
|
326
|
-
], [annualDates, comparisonCurrency, displayStatements, isAnnual, yearEndMonth]);
|
|
326
|
+
], [annualDates, comparisonCurrency, displayStatements, isAnnual, width, yearEndMonth]);
|
|
327
327
|
const { rows, unit } = useMemo(
|
|
328
328
|
() => shareFinancialUnit(buildFinancialRows(subTab.rows, displayStatements, collapsedGroups)),
|
|
329
329
|
[collapsedGroups, displayStatements, subTab.rows],
|
|
@@ -440,9 +440,9 @@ export function ResolvedFinancialsTab({
|
|
|
440
440
|
isValuation, quarterlyStatements, ratioTab, resolvedPeriod, financials?.profile,
|
|
441
441
|
]);
|
|
442
442
|
const ratioColumns = useMemo<RatioTableColumn[]>(() => [
|
|
443
|
-
ratioMetricColumn(),
|
|
443
|
+
ratioMetricColumn(width),
|
|
444
444
|
...columns.flatMap((column, index) => column.kind === "statement" ? [{ ...column, index: index - 1 }] : []),
|
|
445
|
-
], [columns]);
|
|
445
|
+
], [columns, width]);
|
|
446
446
|
|
|
447
447
|
// The Balance Sheet and Liquidity show cash, which an offering filed since the latest balance sheet is not in yet.
|
|
448
448
|
const { symbol: boundSymbol, exchange: boundExchange } = useBoundTicker();
|
|
@@ -45,7 +45,9 @@ import {
|
|
|
45
45
|
quotedPriceDivisor,
|
|
46
46
|
} from "../../../cli/history-rows";
|
|
47
47
|
import { formatUtcTime } from "../../../utils/utc-time";
|
|
48
|
-
import {
|
|
48
|
+
import { closeMoves } from "../../../utils/max-drawdown";
|
|
49
|
+
import { isYieldIndexSymbol } from "../../../tickers/index-roots";
|
|
50
|
+
import { parsePublicTickerKey } from "../../../utils/exchanges";
|
|
49
51
|
import { isPastPriceWindow, loadPriceWindowHistory, priceWindowText, readPriceWindow, type PriceWindow } from "../../../utils/price-window";
|
|
50
52
|
import { historyCoverageNotice } from "../../../sources/history-coverage";
|
|
51
53
|
import { getChartResolutionLabel, isIntradayResolution, RANGE_HISTORY_RESOLUTION, type ManualChartResolution } from "../../../time-series/resolution";
|
|
@@ -111,7 +113,8 @@ export const financialStatementsHeadless: HeadlessPaneDefinition<"rows"> = {
|
|
|
111
113
|
const receiptPeriods = table?.statements.filter(({ shareBasis }) => shareBasis === "depositary_receipt").map(({ date }) => date) ?? [];
|
|
112
114
|
const allReceipts = receiptPeriods.length > 0 && receiptPeriods.length === table?.statements.length;
|
|
113
115
|
const shareBases = new Set(table?.statements.map(({ shareBasis }) => shareBasis ?? null));
|
|
114
|
-
const ratio = adrRatioText(financials.fundamentals?.adrRatio ?? financials.quote?.adrRatio
|
|
116
|
+
const ratio = adrRatioText(financials.fundamentals?.adrRatio ?? financials.quote?.adrRatio,
|
|
117
|
+
(financials.fundamentals?.depositaryPair ?? financials.quote?.depositaryPair)?.ordinary[0]);
|
|
115
118
|
const shareBasisNotice = receiptPeriods.length === 0 || !table?.rows.some(isPerShareFinancialRow) ? null
|
|
116
119
|
: allReceipts
|
|
117
120
|
? `Share counts are in ADRs and EPS is per ADR${ratio ? `; ${ratio}` : ""}.`
|
|
@@ -461,13 +464,12 @@ export const historicalPricesHeadless: HeadlessPaneDefinition<"rows"> = {
|
|
|
461
464
|
...(forming ? { periodToDate: forming } : closedDay ? { asOf: closedDay } : quotedAt ? { asOf: quotedAt } : {}),
|
|
462
465
|
...(dayToDate ? { basis: "daily bars", note: `the newest bar is ${DAY_SO_FAR_TEXT}`, ...(quote ? { asOf: new Date(quote.lastUpdated).toISOString() } : {}) } : {}),
|
|
463
466
|
};
|
|
464
|
-
// The largest fall from a close to a later one in the bars shown, said under the title.
|
|
465
|
-
const drawdown =
|
|
466
|
-
|
|
467
|
-
date: (value) => isDailyOrLongerBar(size) ? value.slice(0, 10) : formatUtcTime(value) }) : null;
|
|
467
|
+
// The largest fall from a close to a later one in the bars shown, said under the title; a yield's in bp, with its largest rise.
|
|
468
|
+
const { drawdown, runUp, lines: moveLines } = closeMoves(shown, drawdownScaleOf(symbol), { basis: `${historyBarSizeWord(size)} closes`,
|
|
469
|
+
price: (value) => formatBarPrice(value, decimals), date: (value) => isDailyOrLongerBar(size) ? value.slice(0, 10) : formatUtcTime(value) });
|
|
468
470
|
// A wick left out of the range is said, though the bar's close still counts.
|
|
469
471
|
const wickNotice = priceHistoryWickNotice(points.filter((point) => pricePointWickFlags(point).length > 0).length);
|
|
470
|
-
const reportNotices = [
|
|
472
|
+
const reportNotices = [...moveLines, notice, wickNotice].filter((line): line is string => line != null);
|
|
471
473
|
return {
|
|
472
474
|
rows: shown,
|
|
473
475
|
columns: historyColumns(size, marked, false, false, decimals),
|
|
@@ -478,7 +480,7 @@ export const historicalPricesHeadless: HeadlessPaneDefinition<"rows"> = {
|
|
|
478
480
|
...(notice ? { complete: false } : {}),
|
|
479
481
|
unavailableSymbols: rows.some((row) => row.close !== null) ? [] : [symbol],
|
|
480
482
|
metadata: { symbol, range: window ? null : range, ...(window ? { requestedWindow: window } : {}), ...(size === "intraday" ? {} : { interval: size }),
|
|
481
|
-
...(allStart ? { sourceStart: allStart } : {}), maxDrawdown: drawdown,
|
|
483
|
+
...(allStart ? { sourceStart: allStart } : {}), maxDrawdown: drawdown, ...(runUp ? { maxRunUp: runUp } : {}),
|
|
482
484
|
...(reportNotices.length ? { notices: reportNotices } : {}) },
|
|
483
485
|
};
|
|
484
486
|
},
|
|
@@ -535,10 +537,9 @@ export const returnsHeadless: HeadlessPaneDefinition<"rows"> = {
|
|
|
535
537
|
const dayToDate = isTodayReturnRow(returns.at(-1), series.resolution, venue, now);
|
|
536
538
|
const rows = forming || dayToDate ? [...unmarked.slice(0, -1), { ...unmarked.at(-1)!, partial: true }] : unmarked;
|
|
537
539
|
const price = (value: unknown) => typeof value === "number" && Number.isFinite(value) ? value.toFixed(decimals) : "-";
|
|
538
|
-
// The largest fall from a close to a later one in the window, said under the title.
|
|
539
|
-
const drawdown =
|
|
540
|
-
|
|
541
|
-
date: (value) => intraday ? formatUtcTime(value) : value.slice(0, 10) }) : null;
|
|
540
|
+
// The largest fall from a close to a later one in the window, said under the title; a yield's in bp, with its largest rise.
|
|
541
|
+
const { drawdown, runUp, lines: moveLines } = closeMoves(unmarked.map((row) => ({ date: row.time, close: row.close })), drawdownScaleOf(symbol),
|
|
542
|
+
{ basis: `${BAR_INTERVAL_LABELS[series.resolution]} closes`, price, date: (value) => intraday ? formatUtcTime(value) : value.slice(0, 10) });
|
|
542
543
|
const figures: HeadlessPaneColumn[] = [
|
|
543
544
|
{ key: "close", header: "Price", align: "right", format: price },
|
|
544
545
|
{ key: "intervalChange", header: "Int $", align: "right", format: price },
|
|
@@ -565,7 +566,7 @@ export const returnsHeadless: HeadlessPaneDefinition<"rows"> = {
|
|
|
565
566
|
const textColumns: HeadlessPaneColumn[] = [timeColumn(true), ...textFigures];
|
|
566
567
|
// An interval the range is too long for is served in the nearest longer bar; say so rather than switch silently.
|
|
567
568
|
const notices = [
|
|
568
|
-
|
|
569
|
+
...moveLines,
|
|
569
570
|
baseDay ? `Totals ${periodBaseText(baseDay, now)}.` : null,
|
|
570
571
|
series.resolution !== requested
|
|
571
572
|
? `${getChartResolutionLabel(requested)} bars do not ${window ? `cover ${priceWindowText(window)}` : `reach back ${range}`}; these are ${getChartResolutionLabel(series.resolution)} bars.`
|
|
@@ -605,8 +606,12 @@ export const returnsHeadless: HeadlessPaneDefinition<"rows"> = {
|
|
|
605
606
|
...(series.lastSession ? { marketClosed: true, lastSession: series.lastSession } : {}),
|
|
606
607
|
basis: "Price returns of bar closes; dividends are not included",
|
|
607
608
|
maxDrawdown: drawdown,
|
|
609
|
+
...(runUp ? { maxRunUp: runUp } : {}),
|
|
608
610
|
...(notices.length ? { notices } : {}),
|
|
609
611
|
},
|
|
610
612
|
};
|
|
611
613
|
},
|
|
612
614
|
};
|
|
615
|
+
|
|
616
|
+
/** A Cboe yield index (^TNX) moves by its level, in bp; anything else by its return. */
|
|
617
|
+
const drawdownScaleOf = (symbol: string) => isYieldIndexSymbol(parsePublicTickerKey(symbol).symbol) ? "yield" as const : "return" as const;
|
|
@@ -45,6 +45,7 @@ export const tickerDetailModule: PluginModule = {
|
|
|
45
45
|
icon: "D",
|
|
46
46
|
get component(): typeof import("./pane").TickerResearchPane { const { TickerResearchPane } = require("./pane"); return TickerResearchPane; },
|
|
47
47
|
defaultPosition: "right",
|
|
48
|
+
shareItem: { ticker: true },
|
|
48
49
|
tickerFollower: true,
|
|
49
50
|
// DES and ADR open this pane; ADR's window is named by its params (the tab it asked for), so settings never say whose a window is.
|
|
50
51
|
identitySettings: [],
|
|
@@ -71,6 +72,7 @@ export const tickerDetailModule: PluginModule = {
|
|
|
71
72
|
get component(): typeof import("./financials/pane").FinancialAnalysisPane { const { FinancialAnalysisPane } = require("./financials/pane"); return FinancialAnalysisPane; },
|
|
72
73
|
headless: financialStatementsHeadless,
|
|
73
74
|
defaultPosition: "right",
|
|
75
|
+
shareItem: { ticker: true },
|
|
74
76
|
tickerFollower: true,
|
|
75
77
|
defaultMode: "floating",
|
|
76
78
|
defaultFloatingSize: { width: 98, height: 30 },
|
|
@@ -100,6 +102,7 @@ export const tickerDetailModule: PluginModule = {
|
|
|
100
102
|
get component(): typeof import("./data-panes/historical-prices").HistoricalPricesPane { const { HistoricalPricesPane } = require("./data-panes/historical-prices"); return HistoricalPricesPane; },
|
|
101
103
|
headless: historicalPricesHeadless,
|
|
102
104
|
defaultPosition: "right",
|
|
105
|
+
shareItem: { ticker: true },
|
|
103
106
|
tickerFollower: true,
|
|
104
107
|
defaultMode: "floating",
|
|
105
108
|
defaultFloatingSize: { width: 92, height: 26 },
|
|
@@ -113,6 +116,7 @@ export const tickerDetailModule: PluginModule = {
|
|
|
113
116
|
get component(): typeof import("./data-panes/returns-pane").ReturnsPane { const { ReturnsPane } = require("./data-panes/returns-pane"); return ReturnsPane; },
|
|
114
117
|
headless: returnsHeadless,
|
|
115
118
|
defaultPosition: "right",
|
|
119
|
+
shareItem: { ticker: true },
|
|
116
120
|
tickerFollower: true,
|
|
117
121
|
defaultMode: "floating",
|
|
118
122
|
defaultFloatingSize: { width: 100, height: 28 },
|