@gloom-sh/terminal 0.20.20 → 0.20.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -1
- package/src/api-client/data.ts +1 -1
- package/src/api-client/equity-screener.ts +17 -0
- package/src/api-client/futures-curve.ts +5 -0
- package/src/api-client/market-discovery.ts +8 -0
- package/src/api-client/members.ts +2 -0
- package/src/api-client/paths.ts +3 -0
- package/src/api-client/perps.ts +20 -0
- package/src/api-client/request.ts +53 -7
- package/src/api-client/types/filings-and-calls.ts +2 -0
- package/src/app/pane-runtime/plugin-bindings.ts +6 -4
- package/src/app/pro-welcome/model.ts +15 -11
- package/src/app/pro-welcome/row.tsx +3 -3
- package/src/app/pro-welcome/use-pro-welcome.ts +2 -2
- package/src/app/runtime/startup.ts +3 -2
- package/src/app.tsx +3 -2
- package/src/capabilities/asset-data-inputs.ts +5 -0
- package/src/capabilities/factories.ts +8 -3
- package/src/capabilities/registry.ts +1 -0
- package/src/capabilities/types.ts +1 -0
- package/src/cli/commands/market.ts +68 -35
- package/src/cli/commands/options-chain.ts +2 -2
- package/src/cli/commands/overview.ts +10 -9
- package/src/cli/commands/ticker.ts +19 -4
- package/src/cli/desktop-pane-shot.ts +11 -3
- package/src/cli/export-source.ts +35 -2
- package/src/cli/glossary.ts +3 -2
- package/src/cli/helpers.ts +2 -1
- package/src/cli/history-demergers.ts +41 -10
- package/src/cli/history-rows.ts +3 -1
- package/src/cli/known-gaps.ts +21 -7
- package/src/cli/listing-arg.ts +22 -11
- package/src/cli/pane-functions/capabilities.ts +4 -9
- package/src/cli/pane-functions/catalog-snapshot.json +29 -29
- package/src/cli/pane-functions/catalog.ts +1 -18
- package/src/cli/pane-functions/data.ts +8 -4
- package/src/cli/pane-functions/financial-ratio-shot.ts +20 -5
- package/src/cli/pane-functions/freshness.ts +57 -12
- package/src/cli/pane-functions/function-help.ts +2 -2
- package/src/cli/pane-functions/headless.ts +6 -0
- package/src/cli/pane-functions/index.ts +11 -4
- package/src/cli/pane-functions/market-session.ts +25 -0
- package/src/cli/pane-functions/report-notices.ts +10 -0
- package/src/cli/pane-functions/resolver.ts +75 -3
- package/src/cli/pane-functions/screenshot-bridge.ts +1 -0
- package/src/cli/pane-functions/screenshot-data-evidence.ts +1 -0
- package/src/cli/pane-functions/screenshot-payload.ts +38 -5
- package/src/cli/pane-functions/screenshot-render.ts +20 -7
- package/src/cli/perpetual-contract.ts +14 -1
- package/src/cli/report-tables.ts +11 -2
- package/src/cli/result.ts +6 -1
- package/src/components/chart-table/layout.ts +8 -4
- package/src/components/command-bar/list/model.ts +2 -0
- package/src/components/command-bar/pane-templates/items.ts +5 -25
- package/src/components/command-bar/panel/index.tsx +7 -4
- package/src/components/command-bar/routes/root/provider-search.ts +4 -4
- package/src/components/command-bar/routes/root/results.ts +6 -2
- package/src/components/command-bar/routes/ticker-search/results.ts +19 -0
- package/src/components/command-bar/routes/ticker-search/route.ts +3 -3
- package/src/components/command-bar/routes/ticker-search/title.ts +23 -0
- package/src/components/command-bar/routing/list-state.ts +17 -5
- package/src/components/command-bar/selection-runtime.ts +3 -2
- package/src/components/command-bar/surface/index.tsx +2 -0
- package/src/components/command-bar/workflow/alert.ts +6 -4
- package/src/components/command-bar/workflow/collection-actions.ts +2 -1
- package/src/components/layout/pane/footer/index.tsx +1 -0
- package/src/components/layout/pane/footer/model.ts +20 -7
- package/src/components/layout/pane/title.ts +11 -2
- package/src/components/price-selector-dialog.tsx +8 -4
- package/src/components/ticker/badge/list.tsx +4 -3
- package/src/components/ticker/list-table-view.tsx +12 -1
- package/src/components/ui/query-bar.tsx +20 -14
- package/src/data/cached-query.ts +20 -4
- package/src/data/news-pane-snapshots.ts +2 -1
- package/src/data/plugin-cache.ts +5 -1
- package/src/data/saved-copies.ts +68 -2
- package/src/docs/snapshot.json +65 -14
- package/src/docs/topics.ts +11 -9
- package/src/i18n/es.ts +1 -0
- package/src/i18n/ja.ts +1 -0
- package/src/i18n/ko.ts +1 -0
- package/src/i18n/zh-cn.ts +1 -0
- package/src/i18n/zh-tw.ts +1 -0
- package/src/market-data/coordinator/index.ts +25 -5
- package/src/market-data/depositary-pair.ts +27 -10
- package/src/market-data/futures-roll-returns.ts +54 -7
- package/src/market-data/fx-closes.ts +14 -0
- package/src/market-data/market/futures-product-hours.ts +113 -0
- package/src/market-data/market/futures-week.ts +2 -0
- package/src/market-data/market/globex-day.ts +9 -2
- package/src/market-data/market/status.ts +32 -25
- package/src/market-data/market/venue-session.ts +18 -0
- package/src/market-data/options-alternatives.ts +49 -7
- package/src/market-data/perpetual-open-interest.ts +41 -0
- package/src/market-data/quotes/contributions.ts +4 -2
- package/src/market-data/quotes/export-identity.ts +11 -3
- package/src/market-data/quotes/freshness.ts +3 -2
- package/src/market-data/quotes/resolution.ts +9 -2
- package/src/market-data/quotes/tick-range.ts +22 -1
- package/src/market-data/quotes/time.ts +34 -4
- package/src/market-data/split-terms.ts +3 -2
- package/src/news/aggregator.ts +1 -0
- package/src/news/news-model.ts +12 -2
- package/src/news/types.ts +15 -0
- package/src/plugins/builtin/alerts/alert-engine.ts +2 -0
- package/src/plugins/builtin/alerts/cli-forms.ts +3 -2
- package/src/plugins/builtin/alerts/cli-move.ts +5 -2
- package/src/plugins/builtin/alerts/cli.ts +50 -25
- package/src/plugins/builtin/alerts/command.ts +51 -3
- package/src/plugins/builtin/alerts/event-rows.ts +1 -1
- package/src/plugins/builtin/alerts/events-pane.tsx +1 -1
- package/src/plugins/builtin/alerts/format.ts +67 -8
- package/src/plugins/builtin/alerts/headless.ts +22 -6
- package/src/plugins/builtin/alerts/index.tsx +26 -25
- package/src/plugins/builtin/alerts/move-checks.ts +1 -0
- package/src/plugins/builtin/alerts/pane.tsx +15 -6
- package/src/plugins/builtin/alerts/pro-rules.ts +9 -4
- package/src/plugins/builtin/alerts/quotes.ts +10 -5
- package/src/plugins/builtin/alerts/session.ts +28 -0
- package/src/plugins/builtin/alerts/types.ts +1 -0
- package/src/plugins/builtin/analytics/pane-model.ts +2 -1
- package/src/plugins/builtin/analytics/risk-model.ts +2 -2
- package/src/plugins/builtin/attention/headless.ts +2 -2
- package/src/plugins/builtin/attention/model.ts +7 -2
- package/src/plugins/builtin/attention/pane.tsx +2 -1
- package/src/plugins/builtin/awards/headless.ts +1 -1
- package/src/plugins/builtin/broker-trading/ticket.tsx +13 -5
- package/src/plugins/builtin/buildout/detail/company.tsx +0 -1
- package/src/plugins/builtin/buildout/detail/ui.tsx +7 -5
- package/src/plugins/builtin/buildout/model/normalizers.ts +0 -1
- package/src/plugins/builtin/buildout/model/types.ts +0 -1
- package/src/plugins/builtin/buildout/pane/index.tsx +9 -0
- package/src/plugins/builtin/buildout/pane/status.tsx +11 -0
- package/src/plugins/builtin/catalysts/headless.ts +1 -1
- package/src/plugins/builtin/chart-composer/headless.ts +14 -6
- package/src/plugins/builtin/chart-composer/pane.tsx +2 -1
- package/src/plugins/builtin/chart-composer/session-history.ts +14 -2
- package/src/plugins/builtin/chat/controller/index.ts +5 -3
- package/src/plugins/builtin/chat/controller/session-runtime.ts +18 -8
- package/src/plugins/builtin/chat/index.tsx +1 -1
- package/src/plugins/builtin/cloud/auth-actions.tsx +4 -2
- package/src/plugins/builtin/cloud/mcp-connect/dialog.tsx +4 -1
- package/src/plugins/builtin/cloud/thesis/ticker-tab.tsx +2 -1
- package/src/plugins/builtin/company-attention/headless.ts +2 -1
- package/src/plugins/builtin/company-kpis/headless.ts +1 -1
- package/src/plugins/builtin/correlation/headless.ts +3 -3
- package/src/plugins/builtin/correlation/history.ts +1 -0
- package/src/plugins/builtin/correlation/index.tsx +7 -5
- package/src/plugins/builtin/correlation/matrix/selection.ts +21 -3
- package/src/plugins/builtin/correlation/relationship/model.ts +5 -0
- package/src/plugins/builtin/correlation/relationship/pane.tsx +3 -2
- package/src/plugins/builtin/correlation/relationship/view-model.ts +3 -2
- package/src/plugins/builtin/credit-documents/headless.ts +1 -1
- package/src/plugins/builtin/dividend-yield/client.ts +81 -10
- package/src/plugins/builtin/dividend-yield/headless.ts +21 -10
- package/src/plugins/builtin/dividend-yield/model.ts +1 -1
- package/src/plugins/builtin/dividend-yield/pane.tsx +9 -5
- package/src/plugins/builtin/dividend-yield/ranking.ts +15 -5
- package/src/plugins/builtin/dividend-yield/reference-price.ts +3 -0
- package/src/plugins/builtin/dividend-yield/types.ts +12 -0
- package/src/plugins/builtin/dividend-yield/view.ts +30 -7
- package/src/plugins/builtin/doe/headless.ts +1 -1
- package/src/plugins/builtin/doe/pane.tsx +16 -7
- package/src/plugins/builtin/earnings-calls/data.ts +8 -5
- package/src/plugins/builtin/earnings-ripple/headless.ts +1 -1
- package/src/plugins/builtin/econ/calendar-model.ts +1 -1
- package/src/plugins/builtin/econ/index.tsx +26 -18
- package/src/plugins/builtin/equity-screener/client.ts +1 -1
- package/src/plugins/builtin/equity-screener/headless.ts +149 -31
- package/src/plugins/builtin/equity-screener/live.ts +23 -5
- package/src/plugins/builtin/equity-screener/model.ts +27 -12
- package/src/plugins/builtin/equity-screener/pane.tsx +5 -5
- package/src/plugins/builtin/exposure/headless.ts +1 -1
- package/src/plugins/builtin/exposure/holdings.ts +2 -2
- package/src/plugins/builtin/futures/index.tsx +29 -1
- package/src/plugins/builtin/futures/model.ts +93 -10
- package/src/plugins/builtin/futures/returns.ts +54 -1
- package/src/plugins/builtin/futures/table.tsx +14 -2
- package/src/plugins/builtin/futures/use-front-returns.ts +20 -3
- package/src/plugins/builtin/futures-curve/client.ts +1 -1
- package/src/plugins/builtin/futures-curve/headless.ts +9 -3
- package/src/plugins/builtin/futures-curve/model.ts +19 -5
- package/src/plugins/builtin/futures-curve/pane.tsx +12 -6
- package/src/plugins/builtin/gpu/headless.ts +1 -1
- package/src/plugins/builtin/gpu/model.ts +1 -1
- package/src/plugins/builtin/help/function-index.ts +16 -8
- package/src/plugins/builtin/help/functions-table.tsx +6 -4
- package/src/plugins/builtin/help/shortcut-model.ts +7 -2
- package/src/plugins/builtin/holders/headless.ts +16 -5
- package/src/plugins/builtin/holders/pane.tsx +43 -5
- package/src/plugins/builtin/insider/client.ts +118 -11
- package/src/plugins/builtin/insider/filing-stories.ts +36 -20
- package/src/plugins/builtin/insider/issuer.ts +5 -2
- package/src/plugins/builtin/iv-history/headless.ts +2 -0
- package/src/plugins/builtin/macro-day/client.ts +2 -3
- package/src/plugins/builtin/macro-day/comparison.ts +58 -0
- package/src/plugins/builtin/macro-day/headless.ts +47 -3
- package/src/plugins/builtin/macro-day/index.tsx +32 -9
- package/src/plugins/builtin/macro-day/model.ts +1 -1
- package/src/plugins/builtin/macro-day/pane.tsx +99 -12
- package/src/plugins/builtin/market-heatmap/index.tsx +2 -2
- package/src/plugins/builtin/market-movers/footer.ts +29 -3
- package/src/plugins/builtin/market-movers/headless.ts +12 -5
- package/src/plugins/builtin/market-movers/index.tsx +3 -3
- package/src/plugins/builtin/market-movers/session-body.tsx +6 -3
- package/src/plugins/builtin/market-valuation/detail.tsx +3 -3
- package/src/plugins/builtin/market-valuation/headless.ts +6 -6
- package/src/plugins/builtin/market-valuation/pane.tsx +2 -3
- package/src/plugins/builtin/market-valuation/view.ts +6 -8
- package/src/plugins/builtin/members/client.ts +9 -2
- package/src/plugins/builtin/members/headless.ts +8 -10
- package/src/plugins/builtin/members/model.ts +29 -17
- package/src/plugins/builtin/members/pane.tsx +10 -12
- package/src/plugins/builtin/money-markets/headless.ts +1 -1
- package/src/plugins/builtin/news/headless.ts +4 -0
- package/src/plugins/builtin/news/index.tsx +3 -1
- package/src/plugins/builtin/news/wire/industry-pane.tsx +2 -1
- package/src/plugins/builtin/news/wire/news/preset-pane.tsx +1 -1
- package/src/plugins/builtin/news/wire/persisted-articles.ts +8 -4
- package/src/plugins/builtin/notes/headless.ts +7 -0
- package/src/plugins/builtin/notes/index.tsx +1 -1
- package/src/plugins/builtin/notes/quick-notes-pane.tsx +18 -2
- package/src/plugins/builtin/options/view.tsx +7 -6
- package/src/plugins/builtin/options-positioning/headless.ts +4 -4
- package/src/plugins/builtin/options-positioning/pane.tsx +7 -3
- package/src/plugins/builtin/options-scenario/client.ts +20 -4
- package/src/plugins/builtin/options-scenario/headless.ts +1 -1
- package/src/plugins/builtin/pe-band/client.ts +5 -9
- package/src/plugins/builtin/pe-band/headless.ts +11 -13
- package/src/plugins/builtin/pe-band/model.ts +39 -60
- package/src/plugins/builtin/pe-band/pane.tsx +14 -15
- package/src/plugins/builtin/perps/equity-row.tsx +3 -1
- package/src/plugins/builtin/perps/freshness.ts +16 -9
- package/src/plugins/builtin/perps/headless.ts +4 -1
- package/src/plugins/builtin/perps/markets-section.tsx +16 -10
- package/src/plugins/builtin/perps/model.ts +33 -2
- package/src/plugins/builtin/perps/pane.tsx +3 -2
- package/src/plugins/builtin/perps/status-line.ts +12 -3
- package/src/plugins/builtin/perps/venue-markets.ts +38 -0
- package/src/plugins/builtin/plugin-marketplace/pane.tsx +4 -3
- package/src/plugins/builtin/portfolio-list/cell-version.ts +1 -1
- package/src/plugins/builtin/portfolio-list/cli/render.ts +46 -7
- package/src/plugins/builtin/portfolio-list/headless.ts +31 -8
- package/src/plugins/builtin/portfolio-list/settings.ts +3 -0
- package/src/plugins/builtin/portfolio-list/table.tsx +7 -1
- package/src/plugins/builtin/power/headless.ts +1 -1
- package/src/plugins/builtin/realized-vol/headless.ts +1 -1
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +27 -13
- package/src/plugins/builtin/scanner/feed.ts +7 -4
- package/src/plugins/builtin/scanner/flow-pane.tsx +8 -4
- package/src/plugins/builtin/scanner/headless.ts +57 -26
- package/src/plugins/builtin/scanner/hilo-pane.tsx +6 -3
- package/src/plugins/builtin/scanner/lock-note.ts +3 -2
- package/src/plugins/builtin/scanner/us-session.ts +9 -0
- package/src/plugins/builtin/seasonality/client.ts +46 -10
- package/src/plugins/builtin/seasonality/headless.ts +29 -11
- package/src/plugins/builtin/seasonality/model.ts +101 -24
- package/src/plugins/builtin/seasonality/pane.tsx +10 -6
- package/src/plugins/builtin/sec/filing-content.ts +13 -0
- package/src/plugins/builtin/sec/index.tsx +16 -11
- package/src/plugins/builtin/sectors/client.ts +27 -5
- package/src/plugins/builtin/sectors/headless.ts +2 -1
- package/src/plugins/builtin/sectors/index.tsx +22 -10
- package/src/plugins/builtin/shared/cloud-resource.ts +3 -3
- package/src/plugins/builtin/shared/extended-print.ts +38 -0
- package/src/plugins/builtin/shared/pro-feature-wall.tsx +1 -1
- package/src/plugins/builtin/shared/report-freshness.ts +7 -3
- package/src/plugins/builtin/shared/scanner-capture.ts +16 -3
- package/src/plugins/builtin/shared/ticker-company.ts +17 -8
- package/src/plugins/builtin/shared/use-quote-board.ts +11 -4
- package/src/plugins/builtin/social-mentions/client.ts +7 -3
- package/src/plugins/builtin/social-mentions/outliers.tsx +9 -2
- package/src/plugins/builtin/thirteenf/api.ts +24 -3
- package/src/plugins/builtin/thirteenf/data.ts +21 -8
- package/src/plugins/builtin/thirteenf/headless.ts +7 -3
- package/src/plugins/builtin/thirteenf/signals-pane.tsx +10 -3
- package/src/plugins/builtin/thirteenf/signals.ts +22 -1
- package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +4 -2
- package/src/plugins/builtin/ticker-detail/financials/model.ts +7 -0
- package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +15 -6
- package/src/plugins/builtin/ticker-detail/financials/ratios.ts +5 -4
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +14 -5
- package/src/plugins/builtin/ticker-detail/headless.ts +32 -26
- package/src/plugins/builtin/ticker-detail/index.tsx +1 -1
- package/src/plugins/builtin/ticker-detail/overview/components.tsx +8 -3
- package/src/plugins/builtin/ticker-detail/overview/model.ts +28 -5
- package/src/plugins/builtin/ticker-detail/overview/pane.tsx +14 -1
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +9 -8
- package/src/plugins/builtin/ticker-detail/pane.tsx +16 -9
- package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +41 -23
- package/src/plugins/builtin/ticker-detail/quote-monitor/rows.ts +30 -13
- package/src/plugins/builtin/ticker-detail/settings.ts +9 -2
- package/src/plugins/builtin/time-sales/headless.ts +49 -13
- package/src/plugins/builtin/time-sales/model.ts +2 -2
- package/src/plugins/builtin/time-sales/window.ts +84 -10
- package/src/plugins/builtin/vol-surface/charts.tsx +4 -2
- package/src/plugins/builtin/vol-surface/events.ts +12 -5
- package/src/plugins/builtin/vol-surface/headless.ts +1 -1
- package/src/plugins/builtin/vol-surface/pane.tsx +15 -7
- package/src/plugins/builtin/world-indices/footer.ts +1 -1
- package/src/plugins/builtin/world-venue-map/chokepoint-report.ts +3 -1
- package/src/plugins/builtin/world-venue-map/headless.ts +27 -13
- package/src/plugins/builtin/yield-curve/client.ts +3 -1
- package/src/plugins/duplicates.ts +60 -0
- package/src/plugins/loader.ts +12 -3
- package/src/plugins/marketplace/model.ts +10 -1
- package/src/portfolio/column-values.ts +52 -5
- package/src/react/async-resource.ts +8 -7
- package/src/renderers/browser/bundled-plugins.ts +2 -1
- package/src/renderers/dom/build-assets.ts +20 -0
- package/src/renderers/dom/data-table/index.tsx +36 -2
- package/src/renderers/dom/es2023-array-methods.ts +57 -0
- package/src/renderers/dom/host/surface-fit.ts +64 -13
- package/src/renderers/dom/styles.css +6 -1
- package/src/renderers/electrobun/bun/external-plugins.ts +16 -6
- package/src/renderers/electrobun/shared/protocol.ts +2 -0
- package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +31 -7
- package/src/renderers/electrobun/view/cli-pane-shot-frame.tsx +15 -8
- package/src/renderers/electrobun/view/external-plugins.ts +1 -0
- package/src/renderers/electrobun/view/remote/asset-data-client.ts +1 -0
- package/src/series/types.ts +1 -0
- package/src/sources/gloomberb-cloud/fred-attribution.ts +6 -5
- package/src/sources/gloomberb-cloud/index.ts +42 -5
- package/src/sources/gloomberb-cloud/news.ts +15 -2
- package/src/sources/gloomberb-cloud/normalizers.ts +9 -0
- package/src/sources/history-result.ts +2 -1
- package/src/sources/history-retention.ts +14 -2
- package/src/sources/listing-symbols.ts +1 -1
- package/src/sources/provider-router/cache.ts +32 -3
- package/src/sources/provider-router/cached-routes.ts +25 -0
- package/src/sources/provider-router/connection-health.ts +1 -0
- package/src/sources/provider-router/history.ts +2 -2
- package/src/sources/provider-router/index.ts +14 -0
- package/src/sources/provider-router/sec-filings-page.ts +25 -0
- package/src/sources/sec-edgar/content.ts +67 -36
- package/src/tickers/listing-fate.ts +28 -0
- package/src/tickers/search/home-listing.ts +3 -0
- package/src/tickers/search/index-root-lead.ts +40 -0
- package/src/tickers/terminal-codes.ts +7 -4
- package/src/time-series/base-series.ts +17 -8
- package/src/time-series/fundamentals/historical-valuation.ts +2 -2
- package/src/time-series/fundamentals/series.ts +15 -12
- package/src/time-series/history-acquisition.ts +2 -0
- package/src/time-series/market.ts +3 -1
- package/src/time-series/price-comparison.ts +3 -1
- package/src/time-series/resolve-context.ts +8 -0
- package/src/time-series/resolve.ts +50 -10
- package/src/time-series/types.ts +1 -0
- package/src/time-series/use-chart-resolution.ts +2 -2
- package/src/time-series/valuation-currency.ts +40 -12
- package/src/types/data-provider.ts +30 -1
- package/src/types/financials.ts +23 -0
- package/src/types/headless.ts +23 -0
- package/src/types/instrument.ts +1 -0
- package/src/utils/crypto-pair.ts +16 -0
- package/src/utils/exchange-announcements.ts +2 -1
- package/src/utils/exchange-notation.generated.ts +58 -1
- package/src/utils/exchanges.ts +43 -1
- package/src/utils/format.ts +37 -2
- package/src/utils/function-search.ts +38 -0
- package/src/utils/fuzzy-search.ts +10 -6
- package/src/utils/option-choice.ts +15 -0
- package/src/utils/price-history.ts +15 -1
- package/src/utils/reason-codes.ts +6 -3
- package/src/utils/trailing-dividend.ts +241 -28
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DataProvider } from "../../../types/data-provider";
|
|
1
|
+
import type { DataProvider, SecFilingItem } from "../../../types/data-provider";
|
|
2
2
|
import { parseInsiderFiling, type ParsedInsiderFiling } from "./model";
|
|
3
3
|
import { isInsiderForm } from "./insider-data";
|
|
4
4
|
import { filesAsForeignPrivateIssuer } from "./issuer";
|
|
@@ -10,6 +10,14 @@ const SEC_FILING_SCAN_LIMIT = 20_000;
|
|
|
10
10
|
/** The company's own filings `fn INS` reads by default, and `insider` sums up as it does. */
|
|
11
11
|
export const INSIDER_REPORT_FILINGS = 20;
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Form 4 filings asked for at a time, the most `fn INS` reads: a company whose
|
|
15
|
+
* Form 4s are its own is read from one page, and every limit shares it.
|
|
16
|
+
*/
|
|
17
|
+
const FORM4_PAGE = 100;
|
|
18
|
+
/** Form 4, which the service's filter matches with its amendment 4/A. */
|
|
19
|
+
const INSIDER_FORMS = ["4"] as const;
|
|
20
|
+
|
|
13
21
|
export interface InsiderFilingsLoad {
|
|
14
22
|
/** The rows of the company's own Form 4 filings, newest first. */
|
|
15
23
|
parsed: ParsedInsiderFiling[];
|
|
@@ -30,24 +38,106 @@ function throwIfAborted(signal: AbortSignal | undefined): void {
|
|
|
30
38
|
*/
|
|
31
39
|
const CONTENT_READS_AT_ONCE = 4;
|
|
32
40
|
|
|
41
|
+
/** What the company files as, which only matters once none of its Form 4s is its own. */
|
|
42
|
+
interface InsiderIssuer {
|
|
43
|
+
foreignPrivateIssuer: boolean;
|
|
44
|
+
noFilings: boolean;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** The company's Form 4s as they are listed, newest first, read further on demand. */
|
|
48
|
+
interface Form4Listing {
|
|
49
|
+
/** The Form 4s listed so far. */
|
|
50
|
+
forms: SecFilingItem[];
|
|
51
|
+
/** Lists the next ones into `forms`; false when the list holds no more. */
|
|
52
|
+
more(): Promise<boolean>;
|
|
53
|
+
issuer(): Promise<InsiderIssuer>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const issuerOf = (filings: ReadonlyArray<Pick<SecFilingItem, "form"> & { filingDate: Date | string }>): InsiderIssuer => ({
|
|
57
|
+
foreignPrivateIssuer: filesAsForeignPrivateIssuer(filings),
|
|
58
|
+
noFilings: filings.length === 0,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
/** The company's whole list, filtered here: a source with no page of one form (`getSecFilingsPage`). */
|
|
62
|
+
async function wholeListForm4s(provider: DataProvider, symbol: string, exchange: string): Promise<Form4Listing> {
|
|
63
|
+
if (!provider.getSecFilings) throw new Error("Insider filing data unavailable");
|
|
64
|
+
const filings = await provider.getSecFilings(symbol, SEC_FILING_SCAN_LIMIT, exchange);
|
|
65
|
+
return {
|
|
66
|
+
forms: filings.filter((filing) => isInsiderForm(filing.form)),
|
|
67
|
+
more: async () => false,
|
|
68
|
+
issuer: async () => issuerOf(filings),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Pages of the company's Form 4s, picked by the source: PG's list is some
|
|
74
|
+
* 6,000 filings of every form, read whole to keep its Form 4s. The first page
|
|
75
|
+
* says what else the list holds by form (`newestByForm`), which tells a
|
|
76
|
+
* foreign private issuer and a company with no filings at all; a source that
|
|
77
|
+
* does not say has its whole list read for it, and only then.
|
|
78
|
+
*/
|
|
79
|
+
async function pagedForm4s(provider: DataProvider, symbol: string, exchange: string): Promise<Form4Listing> {
|
|
80
|
+
const read = (offset: number) => provider.getSecFilingsPage!(symbol, { forms: INSIDER_FORMS, limit: FORM4_PAGE, offset }, exchange);
|
|
81
|
+
const first = await read(0);
|
|
82
|
+
let last = first;
|
|
83
|
+
let offset = 0;
|
|
84
|
+
// A source that predates the filter lists every form: the Form 4s among them are kept, the pages read on.
|
|
85
|
+
const forms = first.filings.filter((filing) => isInsiderForm(filing.form));
|
|
86
|
+
return {
|
|
87
|
+
forms,
|
|
88
|
+
async more() {
|
|
89
|
+
if (!last.hasMore || last.filings.length === 0) return false;
|
|
90
|
+
// A next page that is not past this one would answer the same filings again, and again: the list ends here.
|
|
91
|
+
if (!Number.isSafeInteger(last.nextOffset) || last.nextOffset <= offset) return false;
|
|
92
|
+
offset = last.nextOffset;
|
|
93
|
+
last = await read(offset);
|
|
94
|
+
forms.push(...last.filings.filter((filing) => isInsiderForm(filing.form)));
|
|
95
|
+
return last.filings.length > 0;
|
|
96
|
+
},
|
|
97
|
+
async issuer() {
|
|
98
|
+
if (first.newestByForm) {
|
|
99
|
+
return issuerOf(Object.entries(first.newestByForm).map(([form, filingDate]) => ({ form, filingDate })));
|
|
100
|
+
}
|
|
101
|
+
return (await wholeListForm4s(provider, symbol, exchange)).issuer();
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const bareCik = (cik: string | null | undefined) => cik?.trim().replace(/^0+/, "") ?? "";
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* A Form 4 the service already read for the list and found to be about
|
|
110
|
+
* another issuer's shares: one the company filed as an owner (Berkshire's of
|
|
111
|
+
* Occidental), which INS leaves out, so its document is never read.
|
|
112
|
+
*/
|
|
113
|
+
function summarizedAsOtherIssuer(filing: SecFilingItem): boolean {
|
|
114
|
+
const issuer = bareCik(filing.form4?.issuerCik);
|
|
115
|
+
const company = bareCik(filing.cik);
|
|
116
|
+
return /^\d+$/.test(issuer) && /^\d+$/.test(company) && issuer !== company;
|
|
117
|
+
}
|
|
118
|
+
|
|
33
119
|
/**
|
|
34
120
|
* Reads the company's Form 4 filings newest first until `limit` of them are
|
|
35
121
|
* its own, up to four documents at a time ahead of the one being looked at
|
|
36
122
|
* and never more than are still wanted (one at a time, `insider OXY` took
|
|
37
|
-
* 6-8 s for its 20). A form it filed as an
|
|
38
|
-
*
|
|
39
|
-
* those is read to the end before it can say
|
|
123
|
+
* 6-8 s for its 20). A form it filed as an owner of another company's shares
|
|
124
|
+
* is left out: unread when the list's summary names that company, else read
|
|
125
|
+
* and dropped, so a list of only those is read to the end before it can say
|
|
126
|
+
* there are none.
|
|
40
127
|
*/
|
|
41
128
|
export async function loadParsedInsiderFilings(
|
|
42
129
|
provider: DataProvider,
|
|
43
130
|
symbol: string,
|
|
44
131
|
options: { limit: number; exchange?: string; signal?: AbortSignal },
|
|
45
132
|
): Promise<InsiderFilingsLoad> {
|
|
46
|
-
if (!provider.getSecFilings) throw new Error("Insider filing data unavailable");
|
|
133
|
+
if (!provider.getSecFilings && !provider.getSecFilingsPage) throw new Error("Insider filing data unavailable");
|
|
47
134
|
if (!provider.getSecFilingContent) throw new Error("Insider filing content unavailable");
|
|
48
135
|
const readContent = provider.getSecFilingContent.bind(provider);
|
|
49
|
-
const
|
|
50
|
-
const
|
|
136
|
+
const exchange = options.exchange ?? "";
|
|
137
|
+
const listing = provider.getSecFilingsPage
|
|
138
|
+
? await pagedForm4s(provider, symbol, exchange)
|
|
139
|
+
: await wholeListForm4s(provider, symbol, exchange);
|
|
140
|
+
const { forms } = listing;
|
|
51
141
|
const reads: Array<Promise<{ content: string | null } | null>> = [];
|
|
52
142
|
const read = (index: number) => reads[index] ??= readContent(forms[index]!).then(
|
|
53
143
|
(content) => ({ content }),
|
|
@@ -59,12 +149,19 @@ export async function loadParsedInsiderFilings(
|
|
|
59
149
|
|
|
60
150
|
const parsed: ParsedInsiderFiling[] = [];
|
|
61
151
|
let own = 0;
|
|
62
|
-
for (let index = 0;
|
|
152
|
+
for (let index = 0; own < options.limit; index += 1) {
|
|
153
|
+
throwIfAborted(options.signal);
|
|
154
|
+
if (index >= forms.length && !await listMore(listing, index)) break;
|
|
63
155
|
throwIfAborted(options.signal);
|
|
156
|
+
const filing = forms[index]!;
|
|
157
|
+
if (summarizedAsOtherIssuer(filing)) continue;
|
|
64
158
|
// Never more in flight than filings still wanted: each read is at most one of them.
|
|
65
159
|
const window = Math.min(CONTENT_READS_AT_ONCE, options.limit - own);
|
|
66
|
-
for (let ahead = index; ahead <
|
|
67
|
-
|
|
160
|
+
for (let ahead = index, queued = 0; ahead < forms.length && queued < window; ahead += 1) {
|
|
161
|
+
if (summarizedAsOtherIssuer(forms[ahead]!)) continue;
|
|
162
|
+
read(ahead);
|
|
163
|
+
queued += 1;
|
|
164
|
+
}
|
|
68
165
|
const result = await read(index);
|
|
69
166
|
throwIfAborted(options.signal);
|
|
70
167
|
if (!result) {
|
|
@@ -77,5 +174,15 @@ export async function loadParsedInsiderFilings(
|
|
|
77
174
|
parsed.push(...entries);
|
|
78
175
|
own += 1;
|
|
79
176
|
}
|
|
80
|
-
|
|
177
|
+
// A company with a Form 4 of its own has filings and files them as a domestic issuer.
|
|
178
|
+
if (own > 0) return { parsed, foreignPrivateIssuer: false, noFilings: false };
|
|
179
|
+
return { parsed, ...await listing.issuer() };
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** Lists on until the list holds a Form 4 at `index`; false once it has no more. */
|
|
183
|
+
async function listMore(listing: Form4Listing, index: number): Promise<boolean> {
|
|
184
|
+
while (index >= listing.forms.length) {
|
|
185
|
+
if (!await listing.more()) return false;
|
|
186
|
+
}
|
|
187
|
+
return true;
|
|
81
188
|
}
|
|
@@ -26,6 +26,12 @@ type StoriesClient = Pick<typeof apiClient, "getCloudInsiderFilingStories">;
|
|
|
26
26
|
const ACCESSION = /^\d{10}-\d{2}-\d{6}$/;
|
|
27
27
|
/** As many filings as Gloom Cloud reads in one request; a longer list is asked in several. */
|
|
28
28
|
const BATCH = 20;
|
|
29
|
+
/**
|
|
30
|
+
* Batches asked at once: a report of 100 filings asks its five requests in
|
|
31
|
+
* three round trips instead of five, and holds no more than two of the few
|
|
32
|
+
* lookups a server works on at a time.
|
|
33
|
+
*/
|
|
34
|
+
const BATCHES_AT_ONCE = 2;
|
|
29
35
|
/** A filing's stories, by accession, for a few minutes: an INS or SEC pane asks again as its rows redraw. */
|
|
30
36
|
const cache = createTtlCache<FilingStory[]>({ ttlMs: 5 * 60_000, maxEntries: 500 });
|
|
31
37
|
|
|
@@ -40,10 +46,12 @@ function storiesOf(item: CloudInsiderFilingStoriesResponse["items"][number]): Fi
|
|
|
40
46
|
/**
|
|
41
47
|
* The stories reporting each filing, by accession number, from a short-lived
|
|
42
48
|
* cache where it has them. A filing Gloom Cloud could not be asked about is
|
|
43
|
-
* left out of the map: no stories said is not "none".
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
49
|
+
* left out of the map: no stories said is not "none". The batches are asked
|
|
50
|
+
* BATCHES_AT_ONCE at a time, in the list's order. A batch that fails (a server
|
|
51
|
+
* without the lookup, a session it refuses, a rate or capacity limit) ends
|
|
52
|
+
* the asking without an error: no batch is asked after it, the batches
|
|
53
|
+
* answered beside or before it are kept, and the rows that would have named
|
|
54
|
+
* stories name none.
|
|
47
55
|
*/
|
|
48
56
|
export async function loadFilingStories(
|
|
49
57
|
accessions: readonly string[],
|
|
@@ -58,23 +66,31 @@ export async function loadFilingStories(
|
|
|
58
66
|
if (hit) result.set(accession, hit);
|
|
59
67
|
else wanted.push(accession);
|
|
60
68
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
const batches: string[][] = [];
|
|
70
|
+
for (let start = 0; start < wanted.length; start += BATCH) batches.push(wanted.slice(start, start + BATCH));
|
|
71
|
+
let next = 0;
|
|
72
|
+
let refused = false;
|
|
73
|
+
const askInTurn = async () => {
|
|
74
|
+
while (!refused && next < batches.length) {
|
|
75
|
+
const batch = batches[next++]!;
|
|
76
|
+
let response: CloudInsiderFilingStoriesResponse;
|
|
77
|
+
try {
|
|
78
|
+
response = await client.getCloudInsiderFilingStories(batch);
|
|
79
|
+
} catch (error) {
|
|
80
|
+
// The next batch would meet the same refusal: stop, keeping what was answered.
|
|
81
|
+
if (!refused) logFailure("insider.filing-stories", "Read the stories reporting filings failed")(error);
|
|
82
|
+
refused = true;
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
for (const item of response.items ?? []) {
|
|
86
|
+
if (!batch.includes(item.accession)) continue;
|
|
87
|
+
const stories = storiesOf(item);
|
|
88
|
+
cache.set(item.accession, stories);
|
|
89
|
+
result.set(item.accession, stories);
|
|
90
|
+
}
|
|
70
91
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const stories = storiesOf(item);
|
|
74
|
-
cache.set(item.accession, stories);
|
|
75
|
-
result.set(item.accession, stories);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
92
|
+
};
|
|
93
|
+
await Promise.all(Array.from({ length: Math.min(BATCHES_AT_ONCE, batches.length) }, askInTurn));
|
|
78
94
|
return result;
|
|
79
95
|
}
|
|
80
96
|
|
|
@@ -21,7 +21,10 @@ export function isOtherIssuerFiling(filing: SecFilingItem, content: string | nul
|
|
|
21
21
|
const FOREIGN_PRIVATE_ISSUER_FORM = /^(?:20-F|40-F|6-K)(?:\/A)?$/i;
|
|
22
22
|
const DOMESTIC_REPORT_FORM = /^(?:10-KT?|10-QT?|8-K)(?:\/A)?$/i;
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
/** A filing as far as the issuer's kind goes: its form and day (a Date, or YYYY-MM-DD as a list's summary dates it). */
|
|
25
|
+
type FiledForm = Pick<SecFilingItem, "form"> & { filingDate: Date | string };
|
|
26
|
+
|
|
27
|
+
function newestFiled(filings: readonly FiledForm[], form: RegExp): number {
|
|
25
28
|
let newest = Number.NEGATIVE_INFINITY;
|
|
26
29
|
for (const filing of filings) {
|
|
27
30
|
if (!form.test(filing.form.trim())) continue;
|
|
@@ -36,7 +39,7 @@ function newestFiled(filings: readonly SecFilingItem[], form: RegExp): number {
|
|
|
36
39
|
* 20-F, 40-F or 6-K rather than a 10-K, 10-Q or 8-K. Such an issuer's insiders
|
|
37
40
|
* file no Form 4, so its list holds only the forms it filed as an owner.
|
|
38
41
|
*/
|
|
39
|
-
export function filesAsForeignPrivateIssuer(filings: readonly
|
|
42
|
+
export function filesAsForeignPrivateIssuer(filings: readonly FiledForm[]): boolean {
|
|
40
43
|
const foreign = newestFiled(filings, FOREIGN_PRIVATE_ISSUER_FORM);
|
|
41
44
|
return Number.isFinite(foreign) && foreign > newestFiled(filings, DOMESTIC_REPORT_FORM);
|
|
42
45
|
}
|
|
@@ -28,6 +28,7 @@ export const ivHistoryHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
|
28
28
|
shape: "bundle", argument: { kind: "ticker", description: "US option underlying" },
|
|
29
29
|
usListingsOnly: "Implied volatility history",
|
|
30
30
|
refuseSymbol: fxVolatilityRefusal("HIVG"),
|
|
31
|
+
readsSymbolFate: true,
|
|
31
32
|
freshness: { status: "not-a-feed", basis: "daily implied volatility", cadence: "daily", observedKey: "date", oldest: null },
|
|
32
33
|
describe: (args) => `HIVG ${args.symbols[0] ?? ""}`,
|
|
33
34
|
discovery: { aliases: ["HIVG"], suggestFor: IMPLIED_VOL_WORDS, screenshotReadiness: "live-dom", dataRequirements: ["Cloud stored implied volatility", "Daily price history"],
|
|
@@ -176,6 +177,7 @@ export const ivScreenHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
|
176
177
|
argument: { kind: "symbol-list", optional: true, maximum: VCA_LIMIT, description: "US option underlyings; defaults to index and sector ETFs." },
|
|
177
178
|
usListingsOnly: "Implied volatility",
|
|
178
179
|
refuseSymbol: fxVolatilityRefusal("VCA"),
|
|
180
|
+
readsSymbolFate: true,
|
|
179
181
|
options: [{ key: "preset", type: "enum", values: [{ value: "etfs" }, { value: "megacaps" }], defaultValue: "etfs", description: "Preset when no symbols are given" }],
|
|
180
182
|
describe: "Volatility rich/cheap",
|
|
181
183
|
// The pane names its universe `scope`; symbols typed open their own (custom), which a preset does not replace.
|
|
@@ -137,10 +137,9 @@ export async function loadMacroDayEarnings(
|
|
|
137
137
|
load: typeof loadEarningsHistory = loadEarningsHistory,
|
|
138
138
|
): Promise<MacroDayEarnings> {
|
|
139
139
|
if (request.signal?.aborted) throw abortError(CANCELLED);
|
|
140
|
-
|
|
140
|
+
const symbol = parsePublicTickerKey(request.instrument.symbol.trim()).symbol.toUpperCase();
|
|
141
|
+
if (symbol.startsWith("^") || isNonUsVenue(request.instrument)) return { reports: [], stale: false, error: null };
|
|
141
142
|
try {
|
|
142
|
-
// Earnings are keyed by the bare US symbol; a listing key ("CRWV:XNAS") drops its exchange.
|
|
143
|
-
const symbol = parsePublicTickerKey(request.instrument.symbol.trim()).symbol.toUpperCase();
|
|
144
143
|
const resource = await abortable(load(symbol, request.forceRefresh, EARNINGS_REPORT_LIMIT), request.signal, CANCELLED);
|
|
145
144
|
return { reports: resource.payload.reports.map((report) => ({ date: report.date, timing: report.timing, reactionSession: report.realized?.afterSession ?? null })),
|
|
146
145
|
stale: resource.stale, error: null };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { apiClient } from "../../../api-client";
|
|
2
|
+
import { fredSeriesArgument } from "../../../series/fred-argument";
|
|
3
|
+
import type { DataProvider } from "../../../types/data-provider";
|
|
4
|
+
import type { InstrumentRef } from "../../../market-data/request-types";
|
|
5
|
+
import { parsePublicTickerKey } from "../../../utils/exchanges";
|
|
6
|
+
import { loadMacroDayEarnings, loadMacroDayHistory, loadMacroDaySeriesHistory, macroDayEarningsNotice } from "./client";
|
|
7
|
+
import { macroDayMoveBasis, projectMacroDays, type MacroDayEvent, type MacroDayModel } from "./model";
|
|
8
|
+
import type { MacroReleaseList } from "./releases";
|
|
9
|
+
|
|
10
|
+
export const MAX_MACRO_DAY_SYMBOLS = 4;
|
|
11
|
+
export const MACRO_DAY_DAILY_BASIS = "Daily close-to-close; next available session if the release day did not trade.";
|
|
12
|
+
export const macroDayKey = ({ kind, date }: MacroDayEvent) => `${kind}:${date}`;
|
|
13
|
+
|
|
14
|
+
export async function loadMacroDayTarget(symbol: string, instrument: () => InstrumentRef | Promise<InstrumentRef>, options: {
|
|
15
|
+
forceRefresh?: boolean;
|
|
16
|
+
signal?: AbortSignal;
|
|
17
|
+
marketData?: DataProvider;
|
|
18
|
+
apiClient?: Pick<typeof apiClient, "getCloudFredSeries">;
|
|
19
|
+
}) {
|
|
20
|
+
const seriesId = fredSeriesArgument(symbol);
|
|
21
|
+
if (seriesId) {
|
|
22
|
+
const history = await loadMacroDaySeriesHistory({ ...options, seriesId }, options.apiClient);
|
|
23
|
+
return { ...history, symbol, basis: history.rate ? "yield" as const : "return" as const, earnings: [], earningsNotice: null };
|
|
24
|
+
}
|
|
25
|
+
const target = await instrument();
|
|
26
|
+
const request = { ...options, instrument: target };
|
|
27
|
+
const [history, earnings] = await Promise.all([loadMacroDayHistory(request, options.marketData), loadMacroDayEarnings(request)]);
|
|
28
|
+
return { ...history, symbol, basis: macroDayMoveBasis(parsePublicTickerKey(target.symbol).symbol), stale: history.stale || earnings.stale,
|
|
29
|
+
earnings: earnings.reports, earningsNotice: macroDayEarningsNotice(earnings) };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function projectMacroDayTargets(targets: readonly Awaited<ReturnType<typeof loadMacroDayTarget>>[], releases: MacroReleaseList, lookbackYears: number) {
|
|
33
|
+
return targets.map(({ symbol, basis, history, earnings }) => projectMacroDays(history, {
|
|
34
|
+
symbol, basis, releases: releases.releases, coveredThrough: releases.coveredThrough, earnings, lookbackYears,
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface MacroDayComparisonRow extends MacroDayEvent {
|
|
39
|
+
moves: ReadonlyMap<string, MacroDayEvent>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function compareMacroDays(models: readonly MacroDayModel[]): MacroDayComparisonRow[] {
|
|
43
|
+
const days = new Map<string, MacroDayEvent & { moves: Map<string, MacroDayEvent> }>();
|
|
44
|
+
for (const model of models) {
|
|
45
|
+
for (const event of model.events) {
|
|
46
|
+
const key = macroDayKey(event);
|
|
47
|
+
let day = days.get(key);
|
|
48
|
+
if (!day) {
|
|
49
|
+
day = { ...event, session: event.date, earnings: false, moves: new Map() };
|
|
50
|
+
days.set(key, day);
|
|
51
|
+
}
|
|
52
|
+
day.moves.set(model.symbol, event);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return [...days.values()].sort((left, right) => right.date.localeCompare(left.date) || left.kind.localeCompare(right.kind));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const macroDayComparisonHeader = (model: MacroDayModel) => `${model.symbol} ${model.basis === "yield" ? "bp" : "%"}`;
|
|
@@ -3,6 +3,8 @@ import type { HeadlessPaneDefinition } from "../../../types/plugin";
|
|
|
3
3
|
import { resolveHeadlessInstrument } from "../shared/headless-market-data";
|
|
4
4
|
import { loadMacroDayEarnings, loadMacroDayHistory, loadMacroDaySeriesHistory, loadMacroReleases, macroDayEarningsNotice, type MacroDayEarnings } from "./client";
|
|
5
5
|
import { fredSeriesArgument } from "../../../series/fred-argument";
|
|
6
|
+
import type { HeadlessPaneContext, HeadlessPaneLoadArgs } from "../../../types/headless";
|
|
7
|
+
import { compareMacroDays, loadMacroDayTarget, MACRO_DAY_DAILY_BASIS, macroDayComparisonHeader, MAX_MACRO_DAY_SYMBOLS, projectMacroDayTargets } from "./comparison";
|
|
6
8
|
import { formatMacroDayMove, macroDayEventLabel, macroDayReleaseName, macroDayStats, macroFigureGapNotices, macroSurpriseBasisLabel,
|
|
7
9
|
macroSurpriseExclusionNote, macroSurpriseOf, matchesSurprise, projectMacroDays, type MacroDayEvent, type MacroDayStats } from "./model";
|
|
8
10
|
import { MACRO_EVENT_KINDS, MACRO_EVENT_LABELS, MACRO_RELEASE_SOURCES, MACRO_SURPRISE_LABELS, MACRO_SURPRISES, staleMacroReleasesNotice,
|
|
@@ -13,8 +15,49 @@ const percent = (value: unknown) => typeof value !== "number" ? MISSING_VALUE :
|
|
|
13
15
|
const multiple = (value: unknown) => typeof value === "number" ? `${value.toFixed(2)}x` : MISSING_VALUE;
|
|
14
16
|
const share = (value: unknown) => typeof value === "number" ? `${Math.round(value * 100)}%` : MISSING_VALUE;
|
|
15
17
|
|
|
18
|
+
async function loadComparison(args: HeadlessPaneLoadArgs, ctx: HeadlessPaneContext) {
|
|
19
|
+
const [releases, targets] = await Promise.all([loadMacroReleases(), Promise.all(args.symbols.map((symbol) => loadMacroDayTarget(
|
|
20
|
+
symbol, () => resolveHeadlessInstrument(ctx, symbol), { signal: ctx.signal, marketData: ctx.marketData, apiClient: ctx.apiClient },
|
|
21
|
+
)))]);
|
|
22
|
+
ctx.signal.throwIfAborted();
|
|
23
|
+
const models = projectMacroDayTargets(targets, releases, Number(args.options.lookbackYears) || 5);
|
|
24
|
+
const release = String(args.options.release ?? "all");
|
|
25
|
+
const surprise = String(args.options.surprise ?? "all") as MacroSurprise | "all";
|
|
26
|
+
const scoped = compareMacroDays(models).filter((event) => release === "all" || event.kind === release);
|
|
27
|
+
const days = scoped.filter((event) => matchesSurprise(event, surprise));
|
|
28
|
+
const errors = targets.flatMap((target) => target.error ? [`${target.symbol}: ${target.error}`] : []);
|
|
29
|
+
const unavailableSymbols = models.flatMap((model) => model.events.length ? [] : [model.symbol]);
|
|
30
|
+
const notes = [MACRO_DAY_DAILY_BASIS, staleMacroReleasesNotice(releases), macroSurpriseExclusionNote(scoped, surprise),
|
|
31
|
+
...(days.some((day) => [...day.moves.values()].some((move) => move.earnings)) ? ["* Also an earnings reaction session for this instrument."] : []),
|
|
32
|
+
...targets.map((target) => target.earningsNotice ? `${target.symbol}: ${target.earningsNotice}` : null),
|
|
33
|
+
...macroFigureGapNotices(days),
|
|
34
|
+
].filter((note): note is string => !!note);
|
|
35
|
+
return {
|
|
36
|
+
sections: [{ title: "Release-day moves", columns: [
|
|
37
|
+
{ key: "date", header: "Date" }, { key: "release", header: "Release" },
|
|
38
|
+
...models.map((model) => ({ key: model.symbol, header: macroDayComparisonHeader(model),
|
|
39
|
+
textFormat: (value: unknown, row: Record<string, unknown>) => typeof value === "number"
|
|
40
|
+
? `${formatMacroDayMove(value / 100, model.basis, { unit: false })}${row[`${model.symbol} earnings`] ? "*" : ""}` : MISSING_VALUE })),
|
|
41
|
+
{ key: "actual", header: "Actual" }, { key: "forecast", header: "Forecast" }, { key: "prior", header: "Prior" },
|
|
42
|
+
{ key: "surprise", header: "Surprise" },
|
|
43
|
+
], rows: days.map((day) => ({ date: day.date, release: macroDayEventLabel(day), kind: day.kind,
|
|
44
|
+
actual: day.figures?.actual ?? null, forecast: day.figures?.forecast ?? null, prior: day.figures?.prior ?? null,
|
|
45
|
+
surprise: macroSurpriseOf(day.figures),
|
|
46
|
+
...Object.fromEntries(models.flatMap(({ symbol }) => {
|
|
47
|
+
const move = day.moves.get(symbol);
|
|
48
|
+
return [[symbol, move ? move.move * 100 : null], [`${symbol} session`, move?.session ?? null], [`${symbol} earnings`, move?.earnings ?? null]];
|
|
49
|
+
})),
|
|
50
|
+
})) }],
|
|
51
|
+
complete: !unavailableSymbols.length && !errors.length && !staleMacroReleasesNotice(releases) && targets.every((target) => !target.stale),
|
|
52
|
+
unavailableSymbols, errors, notes,
|
|
53
|
+
metadata: { basis: MACRO_DAY_DAILY_BASIS, unitBySymbol: Object.fromEntries(models.map(({ symbol, basis }) => [symbol, basis === "yield" ? "bp" : "%"])),
|
|
54
|
+
releasesThrough: releases.coveredThrough, methodology: "docs/research-data.md#macro-day-reaction" },
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
16
58
|
export const macroDayHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
17
|
-
shape: "bundle", argument: { kind: "
|
|
59
|
+
shape: "bundle", argument: { kind: "tickers", minimum: 1, maximum: MAX_MACRO_DAY_SYMBOLS,
|
|
60
|
+
description: `Up to ${MAX_MACRO_DAY_SYMBOLS} comma-separated tickers or FRED series`, examples: ["SPY,UUP,^TNX,GLD", "FRED:T10Y2Y"] },
|
|
18
61
|
usListingsOnly: "Macro release day data",
|
|
19
62
|
// Daily closes in the US session, which a line over the counter has as a listed one does.
|
|
20
63
|
usListingsOtc: true,
|
|
@@ -22,9 +65,9 @@ export const macroDayHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
|
22
65
|
fredSeriesArgument: true,
|
|
23
66
|
// Dated by the release list (releasesThrough) as much as by the closes, so no session schedule applies.
|
|
24
67
|
freshness: { status: "not-a-feed", basis: "release-day study on daily closes" },
|
|
25
|
-
describe: (args) => `MDAY ${args.symbols
|
|
68
|
+
describe: (args) => `MDAY ${args.symbols.join(", ")}`,
|
|
26
69
|
discovery: { screenshotReadiness: "live-dom", limitations: [
|
|
27
|
-
|
|
70
|
+
`Compare up to ${MAX_MACRO_DAY_SYMBOLS} US listings or FRED series side by side. ${MACRO_DAY_DAILY_BASIS} Moves are in bp for yields and rates, % otherwise.`,
|
|
28
71
|
"Published CPI, jobs and FOMC days, and from Gloom Cloud Brazil's IPCA days, the ECB's decision days (every Governing Council monetary policy meeting) and the BoJ's (each monetary policy meeting's Tokyo day, from 2026); sessions after the list's last covered day (releasesThrough) are left out.",
|
|
29
72
|
"Actual, forecast and prior for the days Gloom Cloud has them (the US headlines from its kept economic calendar, under either feed's title; an FOMC day's are the federal funds target range and whether it held or moved, an ECB day's the deposit facility rate, a BoJ day's its policy rate; IPCA from the central bank's SGS series); --surprise keeps the days that came in hot, cool or in line with the forecast.",
|
|
30
73
|
"A CPI day the calendar lists without its year-on-year actual takes one computed from the CPI index against a year earlier, labelled computed; where none can be (October 2026, as the October 2025 index was never published), its surprise is read from core CPI m/m, else CPI m/m, and named so (hot (core m/m)).",
|
|
@@ -41,6 +84,7 @@ export const macroDayHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
|
41
84
|
{ key: "lookbackYears", type: "integer", minimum: 1, maximum: 5, defaultValue: 5, description: "Years of daily closes" },
|
|
42
85
|
],
|
|
43
86
|
async load(args, ctx) {
|
|
87
|
+
if (args.symbols.length > 1) return loadComparison(args, ctx);
|
|
44
88
|
// FRED:T10Y2Y is a series, read from FRED: it has no earnings, and a rate or spread moves by its level.
|
|
45
89
|
const seriesId = fredSeriesArgument(args.symbols[0]!);
|
|
46
90
|
const instrument = seriesId ? null : await resolveHeadlessInstrument(ctx, args.symbols[0]!);
|
|
@@ -1,25 +1,48 @@
|
|
|
1
1
|
import type { PluginModule } from "../plugin-module";
|
|
2
|
-
import {
|
|
2
|
+
import { fredSeriesArgument } from "../../../series/fred-argument";
|
|
3
|
+
import { parseTickerListInput } from "../../../tickers/list";
|
|
4
|
+
import { buildTickerSurfaceInstanceId, createTickerSurfacePaneTemplate } from "../shared/ticker-surface";
|
|
3
5
|
import { macroReleaseCache } from "./client";
|
|
6
|
+
import { MAX_MACRO_DAY_SYMBOLS } from "./comparison";
|
|
4
7
|
import { macroDayHeadless } from "./headless";
|
|
5
8
|
import { LOOKBACK_OPTIONS, MacroDayPane } from "./pane";
|
|
6
9
|
|
|
10
|
+
const singleTemplate = createTickerSurfacePaneTemplate({
|
|
11
|
+
id: "macro-day-pane", paneId: "macro-day", label: "Macro-Day Reaction",
|
|
12
|
+
description: `Compare up to ${MAX_MACRO_DAY_SYMBOLS} tickers or FRED series side by side on CPI, jobs and central-bank release days, close to close. With one ticker, see how those moves compare to a normal day.`,
|
|
13
|
+
keywords: ["mday", "macro day", "cpi day", "fomc day", "jobs day", "jobs report", "nfp", "payrolls", "nonfarm", "event study", "release reaction", "ipca",
|
|
14
|
+
"hot cpi", "cpi surprise", "release surprise"],
|
|
15
|
+
shortcut: "MDAY", publicShare: true,
|
|
16
|
+
});
|
|
17
|
+
|
|
7
18
|
export const macroDayModule: PluginModule = {
|
|
8
19
|
panes: [{
|
|
9
20
|
id: "macro-day", name: "Macro-Day Reaction", icon: "M", component: MacroDayPane,
|
|
10
|
-
defaultPosition: "right", shareItem: { ticker: true }, tickerFollower:
|
|
21
|
+
defaultPosition: "right", shareItem: { ticker: true }, tickerFollower: (pane) => !pane.params?.symbols,
|
|
22
|
+
defaultMode: "floating", defaultFloatingSize: { width: 76, height: 26 },
|
|
11
23
|
tableExport: true,
|
|
12
24
|
settings: { title: "Macro-Day Reaction Settings", fields: [
|
|
13
25
|
{ key: "lookbackYears", label: "Lookback", type: "select", options: LOOKBACK_OPTIONS },
|
|
14
26
|
] },
|
|
15
27
|
}],
|
|
16
|
-
paneTemplates: [{
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
28
|
+
paneTemplates: [{
|
|
29
|
+
...singleTemplate,
|
|
30
|
+
shortcut: { prefix: "MDAY", argKind: "ticker-list", argPlaceholder: "tickers", openWithoutArg: true,
|
|
31
|
+
keepArgToken: (token) => !!fredSeriesArgument(token) },
|
|
32
|
+
canCreate: (context, options) => !!(options?.symbols?.length || options?.arg?.trim() || options?.symbol || context.activeTicker),
|
|
33
|
+
createInstance: (context, options) => {
|
|
34
|
+
const input = options?.symbols?.length ? options.symbols.join(",") : options?.arg || options?.symbol || context.activeTicker;
|
|
35
|
+
if (!input) return null;
|
|
36
|
+
const symbols = parseTickerListInput(input, MAX_MACRO_DAY_SYMBOLS);
|
|
37
|
+
if (symbols.length === 1 && !fredSeriesArgument(symbols[0]!)) {
|
|
38
|
+
return singleTemplate.createInstance?.(context, { ...options, symbol: symbols[0] }) ?? null;
|
|
39
|
+
}
|
|
40
|
+
const list = symbols.join(",");
|
|
41
|
+
return { instanceId: buildTickerSurfaceInstanceId("macro-day", list), title: `MDAY ${symbols.join(", ")}`,
|
|
42
|
+
binding: { kind: "none" }, placement: "floating", params: { symbols: list } };
|
|
43
|
+
},
|
|
44
|
+
headless: macroDayHeadless,
|
|
45
|
+
}],
|
|
23
46
|
setup(ctx) { macroReleaseCache.attach(ctx.persistence); },
|
|
24
47
|
dispose() { macroReleaseCache.reset(); },
|
|
25
48
|
};
|
|
@@ -29,7 +29,7 @@ export interface MacroDayEarningsReport {
|
|
|
29
29
|
export type MacroDayMoveBasis = "return" | "yield";
|
|
30
30
|
|
|
31
31
|
/** A Treasury yield index moves by its level: 5.24 to 5.28 is +4bp, not +0.76%. */
|
|
32
|
-
const macroDayMoveBasis = (symbol: string): MacroDayMoveBasis => isYieldIndexSymbol(symbol) ? "yield" : "return";
|
|
32
|
+
export const macroDayMoveBasis = (symbol: string): MacroDayMoveBasis => isYieldIndexSymbol(symbol) ? "yield" : "return";
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* A move as it reads: a return in percent (`+0.76%`), a yield's change in
|