@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
package/src/data/saved-copies.ts
CHANGED
|
@@ -41,11 +41,11 @@ export function servedFromSavedCopy<T>(value: T, savedAt: number): T {
|
|
|
41
41
|
return (Array.isArray(value) ? value.map((item) => mark(item, savedAt)) : mark(value, savedAt)) as T;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
export function markSavedCopy<T extends object>(value: T, savedAt: number): T {
|
|
44
|
+
export function markSavedCopy<T extends object>(value: T, savedAt: number, enumerable = false): T {
|
|
45
45
|
if (Array.isArray(value) && Number.isFinite(savedAt)) {
|
|
46
46
|
return Object.defineProperty(value.slice(), SAVED_AT, { value: savedAt }) as T;
|
|
47
47
|
}
|
|
48
|
-
return Number.isFinite(savedAt) ? mark(value, savedAt,
|
|
48
|
+
return Number.isFinite(savedAt) ? mark(value, savedAt, enumerable) : value;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
/** A quote answered from a copy saved at `savedAt` (ms) after its refresh failed: marked, in a command and in the app. */
|
|
@@ -128,6 +128,7 @@ export function savedCopyShownAt(shown: unknown): number | null {
|
|
|
128
128
|
|
|
129
129
|
/** Runs one command, whose output `savedCopyShownAt` then searches for saved copies. */
|
|
130
130
|
export async function collectSavedCopies<T>(run: () => Promise<T>): Promise<T> {
|
|
131
|
+
if (collecting === 0) served.length = 0;
|
|
131
132
|
collecting += 1;
|
|
132
133
|
try {
|
|
133
134
|
return await run();
|
|
@@ -135,3 +136,68 @@ export async function collectSavedCopies<T>(run: () => Promise<T>): Promise<T> {
|
|
|
135
136
|
collecting -= 1;
|
|
136
137
|
}
|
|
137
138
|
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Copies of a dataset read earlier, served again without asking its source:
|
|
142
|
+
* a holder list or a filing list inside its cache time, or one a failed
|
|
143
|
+
* refresh fell back to. Such data has no time of its own to be dated by, so
|
|
144
|
+
* when it was read is its date: a report built from it was not retrieved when
|
|
145
|
+
* the command ran but when the copy was saved, and a pane that shows it says
|
|
146
|
+
* so. Rows are often rebuilt field by field from such a read (INS's trades
|
|
147
|
+
* from a filing list), which no mark survives, so a command also keeps a
|
|
148
|
+
* ledger of every copy it was served (`servedCopiesAt`), and its closing line
|
|
149
|
+
* is dated by the oldest. Quotes and price history are not in it: they carry
|
|
150
|
+
* their own observation times, which date them.
|
|
151
|
+
*/
|
|
152
|
+
const RETRIEVED_AT = Symbol("gloomberb.retrievedAt");
|
|
153
|
+
|
|
154
|
+
type Stamped = { [RETRIEVED_AT]?: number };
|
|
155
|
+
|
|
156
|
+
const served: Array<{ at: number; refreshFailed: boolean }> = [];
|
|
157
|
+
/** The stamped form of each served value, so a copy read twice is one object, as it was unstamped. */
|
|
158
|
+
const stamped = new WeakMap<object, { at: number; value: object }>();
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* `value` stamped with the time the copy it comes from was read from its
|
|
162
|
+
* source (`at`, ms), not stamped again when it already says. The stamp is a
|
|
163
|
+
* symbol that is neither enumerable nor written by JSON, so the value's
|
|
164
|
+
* fields are untouched.
|
|
165
|
+
*/
|
|
166
|
+
export function stampRetrievedAt<T>(value: T, at: number): T {
|
|
167
|
+
if (!value || typeof value !== "object" || !Number.isFinite(at)) return value;
|
|
168
|
+
if ((value as Stamped)[RETRIEVED_AT] === at) return value;
|
|
169
|
+
const known = stamped.get(value);
|
|
170
|
+
if (known?.at === at) return known.value as T;
|
|
171
|
+
const copy = Array.isArray(value) ? value.slice() : { ...value };
|
|
172
|
+
Object.defineProperty(copy, RETRIEVED_AT, { value: at });
|
|
173
|
+
stamped.set(value, { at, value: copy });
|
|
174
|
+
return copy as T;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** When the copy `value` comes from was read from its source, if it was served from one; null when it was read just now. */
|
|
178
|
+
export function retrievedAtOf(value: unknown): number | null {
|
|
179
|
+
const at = value && typeof value === "object" ? (value as Stamped)[RETRIEVED_AT] : undefined;
|
|
180
|
+
return typeof at === "number" ? at : null;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** Notes, while a command runs, a dataset copy it was served (see `RETRIEVED_AT`); `refreshFailed` when a failed refresh fell back to it. */
|
|
184
|
+
export function noteServedCopy(at: number, refreshFailed: boolean): void {
|
|
185
|
+
if (collecting === 0 || !Number.isFinite(at)) return;
|
|
186
|
+
served.push({ at, refreshFailed });
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* The oldest dataset copy the running command was served (`retrievedAt`) and
|
|
191
|
+
* the oldest of those a failed refresh fell back to (`savedAt`), ms; null
|
|
192
|
+
* where there is none, and both null outside a command.
|
|
193
|
+
*/
|
|
194
|
+
export function servedCopiesAt(): { retrievedAt: number | null; savedAt: number | null } {
|
|
195
|
+
if (collecting === 0) return { retrievedAt: null, savedAt: null };
|
|
196
|
+
let retrievedAt: number | null = null;
|
|
197
|
+
let savedAt: number | null = null;
|
|
198
|
+
for (const { at, refreshFailed } of served) {
|
|
199
|
+
retrievedAt = Math.min(retrievedAt ?? at, at);
|
|
200
|
+
if (refreshFailed) savedAt = Math.min(savedAt ?? at, at);
|
|
201
|
+
}
|
|
202
|
+
return { retrievedAt, savedAt };
|
|
203
|
+
}
|
package/src/docs/snapshot.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"format": 1,
|
|
3
3
|
"site": "https://gloom.sh",
|
|
4
|
-
"updatedAt": "2026-11-
|
|
4
|
+
"updatedAt": "2026-11-20",
|
|
5
5
|
"categories": [
|
|
6
6
|
{
|
|
7
7
|
"id": "research",
|
|
@@ -1628,7 +1628,7 @@
|
|
|
1628
1628
|
"code": "BR",
|
|
1629
1629
|
"name": "Brokers",
|
|
1630
1630
|
"description": "Broker connections",
|
|
1631
|
-
"detail": "Broker profiles, account sync, and connection status.
|
|
1631
|
+
"detail": "Broker profiles, account sync, and connection status. SnapTrade is built in and connects the brokerages it supports; IBKR, Public, Robinhood and SimpleFIN are plugins you install first.",
|
|
1632
1632
|
"category": "cloud",
|
|
1633
1633
|
"lesson": "/academy/terminal-and-workspace/your-workspace/account-and-brokers"
|
|
1634
1634
|
},
|
|
@@ -1813,7 +1813,7 @@
|
|
|
1813
1813
|
"desktop",
|
|
1814
1814
|
"tui"
|
|
1815
1815
|
],
|
|
1816
|
-
"updatedAt": "2026-11-
|
|
1816
|
+
"updatedAt": "2026-11-20",
|
|
1817
1817
|
"blocks": [
|
|
1818
1818
|
{
|
|
1819
1819
|
"type": "heading",
|
|
@@ -1875,6 +1875,10 @@
|
|
|
1875
1875
|
],
|
|
1876
1876
|
"ordered": true
|
|
1877
1877
|
},
|
|
1878
|
+
{
|
|
1879
|
+
"type": "paragraph",
|
|
1880
|
+
"text": "With Smart App Control on, Windows blocks the installer and cannot be told to run it: use the browser version at [term.gloom.sh](https://term.gloom.sh) instead."
|
|
1881
|
+
},
|
|
1878
1882
|
{
|
|
1879
1883
|
"type": "paragraph",
|
|
1880
1884
|
"text": "Terminal only, in PowerShell:"
|
|
@@ -1901,7 +1905,7 @@
|
|
|
1901
1905
|
"**cmd.exe:** run `chcp 65001` so long dashes, `€` and `·` show, and quote an index symbol (`gloom quote \"^SPX\"`): cmd drops a bare `^`. See [CLI](/docs/cli-functions).",
|
|
1902
1906
|
"**Data:** `%USERPROFILE%\\.gloomberb`, printed by `gloom version`. `GLOOMBERB_HOME` moves it.",
|
|
1903
1907
|
"**Exports:** save an export with `--output` (`gloom fn RV NVDA,AMD,ASML:AMS --csv --output rv.csv`), which writes UTF-8 without a byte-order mark; a `>` redirect in Windows PowerShell 5.1 writes UTF-16. See [CLI](/docs/cli-functions).",
|
|
1904
|
-
"**Git and Bun:** Bun ships with the app; Git does not. Some official plugins (TV, Substack, Interactive Brokers, IBKR Gateway, Public, Robinhood, SimpleFIN, Polls, Prediction Markets, BYOK AI) install from GitHub and need [Git for Windows](https://git-scm.com/download/win). Without it Gloom starts without them, says so, and `gloom doctor` names them.",
|
|
1908
|
+
"**Git and Bun:** Bun ships with the app; Git does not. Some official plugins (TV, Substack, Interactive Brokers, IBKR Gateway, Public, Robinhood, SimpleFIN, Polls, Prediction Markets, BYOK AI) install from GitHub and need [Git for Windows](https://git-scm.com/download/win). Without it Gloom starts without them, says so, and `gloom doctor` names them. SnapTrade, which connects the brokerages it supports, is built in and needs no Git.",
|
|
1905
1909
|
"**Versions:** Windows 11 x64 is tested. ARM PCs run the x64 build through Windows' emulation: the desktop app is checked to open and stay open on Windows 11 on Arm, nothing more. Windows 10 is untested."
|
|
1906
1910
|
]
|
|
1907
1911
|
}
|
|
@@ -2391,6 +2395,10 @@
|
|
|
2391
2395
|
"type": "paragraph",
|
|
2392
2396
|
"text": "CLI reports and screenshots end with the same facts in one dated line: `Fri 9 Oct close · 15 min delayed · markets closed until Mon`, or `Sat 10 Oct 00:15 UTC · 12 h delayed` for news. See [CLI](/docs/cli-functions)."
|
|
2393
2397
|
},
|
|
2398
|
+
{
|
|
2399
|
+
"type": "paragraph",
|
|
2400
|
+
"text": "A bid and ask are dated by when they were quoted, not by the last trade: a fund's book can be quoted after hours while its last trade is from the close. Where the source gives no quote time they say `not dated`. `DES`, `gloom ticker`, the order ticket and the price picker show it beside the book, and a portfolio or watchlist can add the `BOOK UTC` column."
|
|
2401
|
+
},
|
|
2394
2402
|
{
|
|
2395
2403
|
"type": "paragraph",
|
|
2396
2404
|
"text": "Plugins add commands, panes and data to the same model. See [Plugins](/docs/plugins)."
|
|
@@ -2922,6 +2930,7 @@
|
|
|
2922
2930
|
"BUY",
|
|
2923
2931
|
"SELL",
|
|
2924
2932
|
"Aries",
|
|
2933
|
+
"SnapTrade",
|
|
2925
2934
|
"Interactive Brokers",
|
|
2926
2935
|
"simulation",
|
|
2927
2936
|
"spreads",
|
|
@@ -2930,7 +2939,7 @@
|
|
|
2930
2939
|
"OCO",
|
|
2931
2940
|
"trailing stop"
|
|
2932
2941
|
],
|
|
2933
|
-
"updatedAt": "2026-
|
|
2942
|
+
"updatedAt": "2026-11-20",
|
|
2934
2943
|
"blocks": [
|
|
2935
2944
|
{
|
|
2936
2945
|
"type": "image",
|
|
@@ -2950,6 +2959,10 @@
|
|
|
2950
2959
|
"Trades through"
|
|
2951
2960
|
],
|
|
2952
2961
|
"rows": [
|
|
2962
|
+
[
|
|
2963
|
+
"[SnapTrade](https://snaptrade.com)",
|
|
2964
|
+
"This ticket, for stocks and ETFs at the brokerages SnapTrade supports, where the brokerage and your SnapTrade link allow trading"
|
|
2965
|
+
],
|
|
2953
2966
|
[
|
|
2954
2967
|
"[Aries](/plugins/aries)",
|
|
2955
2968
|
"This ticket, for stocks, ETFs, options and spreads"
|
|
@@ -2962,7 +2975,20 @@
|
|
|
2962
2975
|
},
|
|
2963
2976
|
{
|
|
2964
2977
|
"type": "paragraph",
|
|
2965
|
-
"text": "
|
|
2978
|
+
"text": "All of them need the desktop app or the terminal. SnapTrade is built in, with no plugin to install. To connect it:"
|
|
2979
|
+
},
|
|
2980
|
+
{
|
|
2981
|
+
"type": "list",
|
|
2982
|
+
"items": [
|
|
2983
|
+
"Link your brokerages in your free SnapTrade account at [dashboard.snaptrade.com](https://dashboard.snaptrade.com).",
|
|
2984
|
+
"Open Brokers (`BR`), add **SnapTrade**, sign in to Gloom if asked, then sign in with SnapTrade in the browser and allow trading.",
|
|
2985
|
+
"Turn on **Enable trading** in the ticket or in Brokers."
|
|
2986
|
+
],
|
|
2987
|
+
"ordered": true
|
|
2988
|
+
},
|
|
2989
|
+
{
|
|
2990
|
+
"type": "paragraph",
|
|
2991
|
+
"text": "To connect Aries:"
|
|
2966
2992
|
},
|
|
2967
2993
|
{
|
|
2968
2994
|
"type": "list",
|
|
@@ -2993,11 +3019,11 @@
|
|
|
2993
3019
|
},
|
|
2994
3020
|
{
|
|
2995
3021
|
"type": "paragraph",
|
|
2996
|
-
"text": "Aries
|
|
3022
|
+
"text": "Aries and SnapTrade take market, limit, stop and stop limit (`1` to `4`). Aries also takes spreads at a net debit or credit."
|
|
2997
3023
|
},
|
|
2998
3024
|
{
|
|
2999
3025
|
"type": "paragraph",
|
|
3000
|
-
"text": "Take profit / stop loss, OCO pairs and trailing stops show only for a broker that runs them, which Aries does
|
|
3026
|
+
"text": "Take profit / stop loss, OCO pairs and trailing stops show only for a broker that runs them, which neither Aries nor SnapTrade does."
|
|
3001
3027
|
},
|
|
3002
3028
|
{
|
|
3003
3029
|
"type": "heading",
|
|
@@ -3115,6 +3141,7 @@
|
|
|
3115
3141
|
"type": "list",
|
|
3116
3142
|
"items": [
|
|
3117
3143
|
"Aries takes Day, Good til cancelled, Immediate or cancel, Fill or kill, At the opening and At the close for stocks, plus extended hours on live accounts. Options and spreads take Day or Good til cancelled.",
|
|
3144
|
+
"SnapTrade takes stock and ETF orders in whole shares, Day or Good til cancelled, in the regular session. A link made read-only in your SnapTrade account takes no orders, and a brokerage that gives no preview through SnapTrade says so in review.",
|
|
3118
3145
|
"Selling more than you hold is refused: Aries takes no short sales.",
|
|
3119
3146
|
"One-click simulation orders still get a preview, and a warning brings the review back.",
|
|
3120
3147
|
"Cancelling asks first, and the order can still fill before the broker confirms.",
|
|
@@ -3169,6 +3196,10 @@
|
|
|
3169
3196
|
"`SA AAPL above 250`",
|
|
3170
3197
|
"Adds a price alert from the command bar"
|
|
3171
3198
|
],
|
|
3199
|
+
[
|
|
3200
|
+
"`SA EWJ/ACWI above 0.60`",
|
|
3201
|
+
"Adds a ratio alert: two listings joined by a slash are read as their ratio. A share class or currency pair written with a slash (`BRK/B`, `EUR/USD`) stays one listing"
|
|
3202
|
+
],
|
|
3172
3203
|
[
|
|
3173
3204
|
"`gloom alerts add ...`",
|
|
3174
3205
|
"Adds any alert from the shell; `gloom help alerts` lists every form"
|
|
@@ -3279,6 +3310,10 @@
|
|
|
3279
3310
|
{
|
|
3280
3311
|
"type": "paragraph",
|
|
3281
3312
|
"text": "**History** in `ALRT`, and `gloom fn ALRT --tab history`, lists the alerts that went off on this device, newest first, with the figure and the quote behind each, beside the alerts you created, re-armed or deleted."
|
|
3313
|
+
},
|
|
3314
|
+
{
|
|
3315
|
+
"type": "paragraph",
|
|
3316
|
+
"text": "**Levels** dates each rule's last quote to the minute in UTC (**Quote (UTC)**, with the delayed clock for a 15-minute delayed quote, or the close a daily rule read), and when the rule was created (**Since (UTC)**). The detail below gives the quote's time to the second."
|
|
3282
3317
|
}
|
|
3283
3318
|
]
|
|
3284
3319
|
},
|
|
@@ -3401,7 +3436,7 @@
|
|
|
3401
3436
|
"troubleshooting",
|
|
3402
3437
|
"diagnostics"
|
|
3403
3438
|
],
|
|
3404
|
-
"updatedAt": "2026-11-
|
|
3439
|
+
"updatedAt": "2026-11-20",
|
|
3405
3440
|
"blocks": [
|
|
3406
3441
|
{
|
|
3407
3442
|
"type": "heading",
|
|
@@ -3558,6 +3593,7 @@
|
|
|
3558
3593
|
"items": [
|
|
3559
3594
|
"`BR` checks the connection before `IBKR`.",
|
|
3560
3595
|
"Interactive Brokers: Flex errors are listed in [IBKR Flex Query setup](/answers/ibkr-flex-query-setup); a Gateway that logs out is covered in [the daily restart and the Sunday login](/answers/ib-gateway-daily-restart-sunday-login).",
|
|
3596
|
+
"SnapTrade: a brokerage that is missing, disconnected or read-only is fixed in your SnapTrade account at [dashboard.snaptrade.com](https://dashboard.snaptrade.com); then press `s` in `BR` to sync. If `BR` says to sign in, press `c`.",
|
|
3561
3597
|
"Cloud login and broker authorization are separate.",
|
|
3562
3598
|
"Market data, account sync, and order authorization can fail independently.",
|
|
3563
3599
|
"Review the account and the order preview before submitting. Never test with a real order."
|
|
@@ -6269,8 +6305,8 @@
|
|
|
6269
6305
|
"type": "list",
|
|
6270
6306
|
"items": [
|
|
6271
6307
|
"An option only the text report reads, such as `--limit`, fails `shot` with exit 1 and names the `fn` command that reads it.",
|
|
6272
|
-
"`shot` saves its PNG, prints a Reason line and exits 0 when the pane drew an error, was
|
|
6273
|
-
"`shot --strict` exits 2 in those cases
|
|
6308
|
+
"`shot` saves its PNG, prints a Reason line and exits 0 when the pane drew an error, was still loading, was behind an access gate or drew a column with no value in any row. A pane that drew nothing but its empty state exits 1, as `fn` does for an empty report, and still saves the PNG.",
|
|
6309
|
+
"`shot --strict` exits 2 in all those cases, prints the Reason and saves no PNG, leaving any file already at `--output` as it was.",
|
|
6274
6310
|
"A name nothing opens (`fn volsurf SPY`) lists up to five functions closest by name, keyword and description, and how to search the catalog.",
|
|
6275
6311
|
"`shot` lays out 720 to 2400 wide and 360 to 1800 tall, drawing the PNG at twice that. Other sizes are clamped, with a warning."
|
|
6276
6312
|
]
|
|
@@ -6347,11 +6383,21 @@
|
|
|
6347
6383
|
},
|
|
6348
6384
|
{
|
|
6349
6385
|
"type": "paragraph",
|
|
6350
|
-
"text": "`alerts list --csv` keeps its first eight columns in their original order, and adds
|
|
6386
|
+
"text": "`alerts list --csv` keeps its first eight columns in their original order, and adds the rest after them:"
|
|
6351
6387
|
},
|
|
6352
6388
|
{
|
|
6353
6389
|
"type": "code",
|
|
6354
|
-
"code": "id,kind,target,trigger,eventDate,status,lastCheckedPrice,triggeredAt,createdAt,listing,currency,lastReading,lastReadingAt"
|
|
6390
|
+
"code": "id,kind,target,trigger,eventDate,status,lastCheckedPrice,triggeredAt,createdAt,listing,currency,lastReading,lastReadingAt,session,comparatorReading,benchmarkListing"
|
|
6391
|
+
},
|
|
6392
|
+
{
|
|
6393
|
+
"type": "list",
|
|
6394
|
+
"items": [
|
|
6395
|
+
"`triggeredAt` and `createdAt` are ISO 8601 in UTC, to the second (`2026-11-20T21:04:05Z`), as is `lastReadingAt`, the time of the quote or close the last reading was taken from.",
|
|
6396
|
+
"`session` is the session a rule reads: regular hours only for a valuation or daily technical rule, which reads the regular session's price or close.",
|
|
6397
|
+
"`comparatorReading` is what a moving-average rule's last reading was measured against, with its unit and close: the slow average of a crossover (`59.73 USD on the 2026-11-20 close`), the average a close is compared with.",
|
|
6398
|
+
"`benchmarkListing` is the benchmark of a ratio or relative-strength rule, as `ACWI:NASDAQ`.",
|
|
6399
|
+
"A ratio has no currency, so its `currency` is empty."
|
|
6400
|
+
]
|
|
6355
6401
|
},
|
|
6356
6402
|
{
|
|
6357
6403
|
"type": "heading",
|
|
@@ -6794,7 +6840,7 @@
|
|
|
6794
6840
|
"terminal",
|
|
6795
6841
|
"remote control"
|
|
6796
6842
|
],
|
|
6797
|
-
"updatedAt": "2026-11-
|
|
6843
|
+
"updatedAt": "2026-11-20",
|
|
6798
6844
|
"blocks": [
|
|
6799
6845
|
{
|
|
6800
6846
|
"type": "paragraph",
|
|
@@ -7393,6 +7439,11 @@
|
|
|
7393
7439
|
"Robinhood",
|
|
7394
7440
|
"`robinhood.*`: accounts and equity positions",
|
|
7395
7441
|
"None"
|
|
7442
|
+
],
|
|
7443
|
+
[
|
|
7444
|
+
"SnapTrade",
|
|
7445
|
+
"`portfolio.*` only: accounts and positions of the brokerages linked there",
|
|
7446
|
+
"None"
|
|
7396
7447
|
]
|
|
7397
7448
|
]
|
|
7398
7449
|
},
|
package/src/docs/topics.ts
CHANGED
|
@@ -122,13 +122,15 @@ export interface DocsEntry {
|
|
|
122
122
|
keywords: string;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
const
|
|
125
|
+
const START_HERE = "Start here";
|
|
126
126
|
/** The function list is the index; its page would only repeat it. */
|
|
127
127
|
const INDEX_PAGES_SKIPPED = new Set(["functions"]);
|
|
128
128
|
|
|
129
129
|
/**
|
|
130
130
|
* Every entry in reading order: start-here pages, then functions by task,
|
|
131
|
-
* then the other guides
|
|
131
|
+
* then the other guides grouped as the site lists them (the order the feed's
|
|
132
|
+
* pages arrive in, so a regrouping on the site needs no app release), then the
|
|
133
|
+
* Academy by chapter.
|
|
132
134
|
*/
|
|
133
135
|
export function docsEntries(feed: DocsFeed): DocsEntry[] {
|
|
134
136
|
const pages = feed.pages
|
|
@@ -144,13 +146,13 @@ export function docsEntries(feed: DocsFeed): DocsEntry[] {
|
|
|
144
146
|
keywords: page.tags.join(" "),
|
|
145
147
|
};
|
|
146
148
|
});
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
const startHere = pages.filter((entry) => entry.section ===
|
|
152
|
-
const guides = pages.filter((entry) => entry.section !==
|
|
153
|
-
.sort((left, right) =>
|
|
149
|
+
const groupRank = new Map([[START_HERE, 0]]);
|
|
150
|
+
for (const entry of pages) {
|
|
151
|
+
if (!groupRank.has(entry.section)) groupRank.set(entry.section, groupRank.size);
|
|
152
|
+
}
|
|
153
|
+
const startHere = pages.filter((entry) => entry.section === START_HERE);
|
|
154
|
+
const guides = pages.filter((entry) => entry.section !== START_HERE)
|
|
155
|
+
.sort((left, right) => groupRank.get(left.section)! - groupRank.get(right.section)!);
|
|
154
156
|
const categoryTitle = new Map(feed.categories.map((category) => [category.id, category.title]));
|
|
155
157
|
const categoryRank = new Map(feed.categories.map((category, index) => [category.id, index]));
|
|
156
158
|
const functions = feed.functions
|
package/src/i18n/es.ts
CHANGED
package/src/i18n/ja.ts
CHANGED
package/src/i18n/ko.ts
CHANGED
package/src/i18n/zh-cn.ts
CHANGED
package/src/i18n/zh-tw.ts
CHANGED
|
@@ -176,6 +176,12 @@ export interface StreamTickFollow {
|
|
|
176
176
|
dispose(): void;
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
+
/** A chain that is one slice of `expiration`: it holds contracts, every one of them expiring then. */
|
|
180
|
+
function isOptionsSliceOf(chain: OptionsChain | null | undefined, expiration: number): boolean {
|
|
181
|
+
const contracts = chain ? [...chain.calls, ...chain.puts] : [];
|
|
182
|
+
return contracts.length > 0 && contracts.every((contract) => contract.expiration === expiration);
|
|
183
|
+
}
|
|
184
|
+
|
|
179
185
|
export class MarketDataCoordinator {
|
|
180
186
|
private readonly events: MarketDataCoordinatorEvents;
|
|
181
187
|
private readonly inFlight = new Map<string, Promise<unknown>>();
|
|
@@ -815,16 +821,19 @@ export class MarketDataCoordinator {
|
|
|
815
821
|
if (request.expirationDate != null && !options.forceRefresh) {
|
|
816
822
|
const defaultKey = buildOptionsKey({ instrument: request.instrument });
|
|
817
823
|
// A concurrent OMON catalogue request already contains one actual slice.
|
|
818
|
-
// Wait for its identity before requesting the same expiry again.
|
|
824
|
+
// Wait for its identity before requesting the same expiry again. A
|
|
825
|
+
// stored catalogue read again in the background is that request too:
|
|
826
|
+
// a long-lived app's OMON opens on its saved copy, and asking for the
|
|
827
|
+
// expiry beside it built the chain twice. Another expiry than the
|
|
828
|
+
// stored slice's is read beside that refresh, not after it.
|
|
819
829
|
await (this.optionsLoads.get(`${defaultKey}|refresh`) ?? this.optionsLoads.get(defaultKey));
|
|
830
|
+
if (isOptionsSliceOf(this.optionsStore.get(defaultKey).data, request.expirationDate)) await this.backgroundRefresh(defaultKey);
|
|
820
831
|
const catalogue = this.optionsStore.get(defaultKey);
|
|
821
|
-
const contracts = catalogue.data ? [...catalogue.data.calls, ...catalogue.data.puts] : [];
|
|
822
832
|
const now = Date.now();
|
|
823
833
|
const fresh = (entry: QueryEntry<OptionsChain>) => hasFreshReadyEntry(entry, OPTIONS_CACHE_TTL_MS, now)
|
|
824
834
|
&& !entry.error && (entry.staleAt == null || entry.staleAt > now);
|
|
825
|
-
if (fresh(catalogue) &&
|
|
826
|
-
&& catalogue.data!.expirationDates.includes(request.expirationDate)
|
|
827
|
-
&& contracts.every((contract) => contract.expiration === request.expirationDate)) {
|
|
835
|
+
if (fresh(catalogue) && isOptionsSliceOf(catalogue.data, request.expirationDate)
|
|
836
|
+
&& catalogue.data!.expirationDates.includes(request.expirationDate)) {
|
|
828
837
|
const current = this.optionsStore.get(key);
|
|
829
838
|
const currentNewer = current.fetchedAt != null && (current.fetchedAt > (catalogue.fetchedAt ?? 0)
|
|
830
839
|
|| (current.fetchedAt === catalogue.fetchedAt && (current.responseSequence ?? 0) >= (catalogue.responseSequence ?? 0)));
|
|
@@ -905,6 +914,17 @@ export class MarketDataCoordinator {
|
|
|
905
914
|
});
|
|
906
915
|
}
|
|
907
916
|
|
|
917
|
+
/** Settles with the background refresh of the stored copy under `key`, when one is running; whatever it answers. */
|
|
918
|
+
private async backgroundRefresh(key: string): Promise<void> {
|
|
919
|
+
const query = this.cachedQueries.get(key)?.query;
|
|
920
|
+
// A load while one runs joins it: no request of its own.
|
|
921
|
+
if (query?.getSnapshot().loading) {
|
|
922
|
+
await query.load().catch(() => {
|
|
923
|
+
// Intentional ignore: a refresh that failed leaves its error on the entry, which the caller reads.
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
|
|
908
928
|
/** QueryStore is only a renderer projection here; the provider owns age and refreshes. */
|
|
909
929
|
private loadCachedQuery<K extends CachedAssetMethod>(
|
|
910
930
|
method: K,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CedearRatio, DepositaryPair, Fundamentals, Quote } from "../types/financials";
|
|
2
|
-
import { canonicalExchange, parsePublicTickerKey } from "../utils/exchanges";
|
|
2
|
+
import { canonicalExchange, displayTickerKey, parsePublicTickerKey } from "../utils/exchanges";
|
|
3
|
+
import { listingSuffixCandidate } from "../sources/listing-symbols";
|
|
3
4
|
import { formatNumber } from "../utils/format";
|
|
4
5
|
import { formatUtcDayTime } from "../utils/utc-time";
|
|
5
6
|
import { heldCurrencyUnit } from "../utils/currency-units";
|
|
@@ -66,20 +67,36 @@ export function cedearRatioText(ratio: CedearRatio): string {
|
|
|
66
67
|
return `${ratioCount(ratio.receipts)} ${ratio.listing} = ${ratioCount(ratio.shares)} ${ratio.company.trim()} share${ratio.shares === 1 ? "" : "s"}`;
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
/**
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
/**
|
|
71
|
+
* A line of a pair as every other listing is named: a served home line by its
|
|
72
|
+
* venue (SHEL.L is SHEL:LSE, GGAL.BA GGAL:BYMA), the US receipt by the venue
|
|
73
|
+
* `exchange` says it trades on where that is known (SHEL:NYSE), else bare, as
|
|
74
|
+
* a US listing's key is.
|
|
75
|
+
*/
|
|
76
|
+
export function pairListingKey(line: string, exchange?: string | null): string {
|
|
77
|
+
const suffixed = listingSuffixCandidate(line);
|
|
78
|
+
if (suffixed) return `${suffixed.symbol}:${suffixed.exchange}`;
|
|
79
|
+
if (parsePublicTickerKey(line).exchange) return displayTickerKey(line);
|
|
80
|
+
const venue = canonicalExchange(exchange ?? "");
|
|
81
|
+
return venue ? `${line}:${venue}` : line;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** What a home line says of its receipt: `1 GGAL:NYSE ADR = 10 of these shares`, and `1 of these shares` for one. */
|
|
85
|
+
function homeLineRatioText(pair: DepositaryPair, receiptExchange?: string | null): string {
|
|
86
|
+
return `1 ${pairListingKey(pair.receipt, receiptExchange)} ADR = ${ratioCount(pair.ratio)} of these shares`;
|
|
72
87
|
}
|
|
73
88
|
|
|
74
89
|
/**
|
|
75
90
|
* The ratio as a listing's report states it, from its side of the pair:
|
|
76
|
-
* `1 ADR = 10 ordinary shares of GGAL
|
|
77
|
-
* shares of PETR4
|
|
78
|
-
* on a home line
|
|
91
|
+
* `1 ADR = 10 ordinary shares of GGAL:BYMA` on the receipt (`2 preferred
|
|
92
|
+
* shares of PETR4:B3`, homeShareClass), `1 GGAL:NYSE ADR = 10 of these
|
|
93
|
+
* shares` on a home line, the receipt named by its venue where
|
|
94
|
+
* `receiptExchange` gives it (pairListingKey).
|
|
79
95
|
*/
|
|
80
|
-
export function depositaryPairText(pair: DepositaryPair, receiptSide: boolean): string {
|
|
81
|
-
if (!receiptSide) return homeLineRatioText(pair);
|
|
82
|
-
|
|
96
|
+
export function depositaryPairText(pair: DepositaryPair, receiptSide: boolean, receiptExchange?: string | null): string {
|
|
97
|
+
if (!receiptSide) return homeLineRatioText(pair, receiptExchange);
|
|
98
|
+
const lines = pair.ordinary.map((line) => pairListingKey(line));
|
|
99
|
+
return `${adrRatioText(pair.ratio, lines[0]) ?? `1 ADR = ${ratioCount(pair.ratio)}`} of ${lines.join(" / ")}`;
|
|
83
100
|
}
|
|
84
101
|
|
|
85
102
|
/** A price as the comparison reads it, with when it was observed. */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PricePoint } from "../types/financials";
|
|
2
2
|
import { getPricePointTimestamp } from "../utils/price-history";
|
|
3
3
|
import { pricePointOpenWithheld } from "../utils/price-history-integrity";
|
|
4
|
+
import { getPublishedUsEquityCalendarDay } from "./published-us-sessions";
|
|
4
5
|
|
|
5
6
|
/** What a return-based function says once about a continuous future's series (rollAdjustedHistory). */
|
|
6
7
|
export const ROLLS_BACK_ADJUSTED = "rolls back-adjusted";
|
|
@@ -62,7 +63,10 @@ const DAY_MS = 86_400_000;
|
|
|
62
63
|
type LastTradeRule =
|
|
63
64
|
| { kind: "month-start"; sessions: number }
|
|
64
65
|
| { kind: "before-25th"; sessions: number }
|
|
65
|
-
| { kind: "month-end"; monthsBefore: number }
|
|
66
|
+
| { kind: "month-end"; monthsBefore: number }
|
|
67
|
+
| { kind: "quarterly-index" };
|
|
68
|
+
|
|
69
|
+
const QUARTERLY_INDEX = { kind: "quarterly-index" } as const;
|
|
66
70
|
|
|
67
71
|
const LAST_TRADE_RULES: Readonly<Record<string, LastTradeRule>> = {
|
|
68
72
|
NG: { kind: "month-start", sessions: 3 },
|
|
@@ -73,6 +77,14 @@ const LAST_TRADE_RULES: Readonly<Record<string, LastTradeRule>> = {
|
|
|
73
77
|
HO: { kind: "month-end", monthsBefore: 1 },
|
|
74
78
|
RB: { kind: "month-end", monthsBefore: 1 },
|
|
75
79
|
BZ: { kind: "month-end", monthsBefore: 2 },
|
|
80
|
+
ES: QUARTERLY_INDEX,
|
|
81
|
+
NQ: QUARTERLY_INDEX,
|
|
82
|
+
YM: QUARTERLY_INDEX,
|
|
83
|
+
RTY: QUARTERLY_INDEX,
|
|
84
|
+
MES: QUARTERLY_INDEX,
|
|
85
|
+
MNQ: QUARTERLY_INDEX,
|
|
86
|
+
MYM: QUARTERLY_INDEX,
|
|
87
|
+
M2K: QUARTERLY_INDEX,
|
|
76
88
|
};
|
|
77
89
|
|
|
78
90
|
/** The root of a continuous future's symbol (NG of NG=F), or null for anything else. */
|
|
@@ -91,6 +103,19 @@ const monthDay = (index: number, day: number) =>
|
|
|
91
103
|
const contractCode = (root: string, delivery: number) =>
|
|
92
104
|
`${root}${MONTH_CODES[delivery % 12]}${String(Math.floor(delivery / 12) % 100).padStart(2, "0")}`;
|
|
93
105
|
|
|
106
|
+
function indexExpiry(month: number): string {
|
|
107
|
+
const weekday = new Date(`${monthDay(month, 15)}T00:00:00Z`).getUTCDay();
|
|
108
|
+
let day = 15 + (5 - weekday + 7) % 7;
|
|
109
|
+
while (getPublishedUsEquityCalendarDay("NYSE", monthDay(month, day)) === "closed") day--;
|
|
110
|
+
return monthDay(month, day);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function indexDelivery(day: string): number {
|
|
114
|
+
const month = monthIndex(day);
|
|
115
|
+
const delivery = month + 2 - month % 3;
|
|
116
|
+
return day <= indexExpiry(delivery) ? delivery : delivery + 3;
|
|
117
|
+
}
|
|
118
|
+
|
|
94
119
|
/** The index of the first of the ascending `days` on or after `day`; `days.length` when none is. */
|
|
95
120
|
function firstOnOrAfter(days: readonly string[], day: string): number {
|
|
96
121
|
let low = 0, high = days.length;
|
|
@@ -111,6 +136,15 @@ function firstOnOrAfter(days: readonly string[], day: string): number {
|
|
|
111
136
|
function calendarRolls(root: string, rule: LastTradeRule, days: readonly string[]): Array<{ index: number; from: string; to: string }> {
|
|
112
137
|
if (days.length < 2) return [];
|
|
113
138
|
const rolls: Array<{ index: number; from: string; to: string }> = [];
|
|
139
|
+
if (rule.kind === "quarterly-index") {
|
|
140
|
+
let held = indexDelivery(days[0]!);
|
|
141
|
+
for (let index = 1; index < days.length; index++) {
|
|
142
|
+
const next = indexDelivery(days[index]!);
|
|
143
|
+
if (next !== held) rolls.push({ index, from: contractCode(root, held), to: contractCode(root, next) });
|
|
144
|
+
held = next;
|
|
145
|
+
}
|
|
146
|
+
return rolls;
|
|
147
|
+
}
|
|
114
148
|
for (let month = monthIndex(days[0]!); month <= monthIndex(days.at(-1)!); month++) {
|
|
115
149
|
// The month the last trade falls in, and the delivery month of the contract that stops.
|
|
116
150
|
let last: number;
|
|
@@ -168,23 +202,36 @@ export function rollAdjustedHistory(points: readonly PricePoint[], symbol: strin
|
|
|
168
202
|
const asServed = (): RollAdjustedHistory => ({ points: [...points], rolls: [], note: null });
|
|
169
203
|
const root = continuousRoot(symbol);
|
|
170
204
|
if (!root) return asServed();
|
|
171
|
-
|
|
205
|
+
let timed = points.map((point) => ({ point, time: getPricePointTimestamp(point) }));
|
|
172
206
|
if (timed.some(({ time }) => !Number.isFinite(time))) return asServed();
|
|
173
207
|
timed.sort((left, right) => left.time - right.time);
|
|
174
208
|
if (!dailyBars(timed.map(({ time }) => time))) return asServed();
|
|
209
|
+
const rule = LAST_TRADE_RULES[root];
|
|
210
|
+
const initialLength = timed.length;
|
|
211
|
+
const firstNamedBar = timed.findIndex(({ point }) => !!point.contract);
|
|
212
|
+
const isoDay = (time: number) => new Date(time).toISOString().slice(0, 10);
|
|
213
|
+
if (rule?.kind === "quarterly-index") {
|
|
214
|
+
timed = timed.filter(({ time }, index) => {
|
|
215
|
+
if (firstNamedBar >= 0 && index >= firstNamedBar) return true;
|
|
216
|
+
const day = isoDay(time);
|
|
217
|
+
const month = monthIndex(day);
|
|
218
|
+
return month % 3 !== 2 || day !== indexExpiry(month);
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
const omittedExpiry = timed.length < initialLength;
|
|
175
222
|
const sorted = timed.map(({ point }) => point);
|
|
176
|
-
const days = timed.map(({ time }) =>
|
|
223
|
+
const days = timed.map(({ time }) => isoDay(time));
|
|
177
224
|
|
|
178
225
|
const firstNamed = sorted.findIndex((point) => !!point.contract);
|
|
179
226
|
const unnamedEnd = firstNamed < 0 ? sorted.length : firstNamed;
|
|
180
227
|
const found: Array<{ index: number; from: string; to: string; source: ReturnRoll["source"] }> = [];
|
|
181
|
-
const rule = LAST_TRADE_RULES[root];
|
|
182
228
|
if (rule && unnamedEnd > 0) {
|
|
183
229
|
const calendar = calendarRolls(root, rule, days);
|
|
184
230
|
for (const roll of calendar) if (roll.index < unnamedEnd) found.push({ ...roll, source: "calendar" });
|
|
185
231
|
// The bars may start naming a contract other than the one the calendar holds then: the series rolled there.
|
|
186
|
-
const held =
|
|
187
|
-
|
|
232
|
+
const held = rule.kind === "quarterly-index" && firstNamed > 0
|
|
233
|
+
? contractCode(root, indexDelivery(days[firstNamed - 1]!))
|
|
234
|
+
: calendar.filter((roll) => roll.index < unnamedEnd).at(-1)?.to ?? calendar.find((roll) => roll.index >= unnamedEnd)?.from;
|
|
188
235
|
const named = sorted[firstNamed]?.contract;
|
|
189
236
|
if (firstNamed > 0 && held && named && held !== named) found.push({ index: firstNamed, from: held, to: named, source: "bars" });
|
|
190
237
|
}
|
|
@@ -222,5 +269,5 @@ export function rollAdjustedHistory(points: readonly PricePoint[], symbol: strin
|
|
|
222
269
|
}
|
|
223
270
|
const note = rule || firstNamed === 0 ? ROLLS_BACK_ADJUSTED
|
|
224
271
|
: firstNamed > 0 ? `${ROLLS_BACK_ADJUSTED} from ${days[firstNamed]}` : ROLLS_LEFT_AS_TRADED;
|
|
225
|
-
return { points: adjusted, rolls, note };
|
|
272
|
+
return { points: adjusted, rolls, note: omittedExpiry ? `${note}; expiry settlements omitted` : note };
|
|
226
273
|
}
|
|
@@ -74,6 +74,20 @@ export function fxCloseOnOrBefore(fx: FxCloses, date: string): { date: string; r
|
|
|
74
74
|
return null;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
export function crossFxCloseOnOrBefore(
|
|
78
|
+
histories: ReadonlyMap<string, FxCloses>, from: string, to: string, date: string,
|
|
79
|
+
): { date: string; rate: number } | null {
|
|
80
|
+
if (from === to || !isDay(date)) return null;
|
|
81
|
+
const end = Date.parse(date);
|
|
82
|
+
for (let back = 0; back <= FX_MAX_AGE_DAYS; back++) {
|
|
83
|
+
const day = isoDay(end - back * DAY_MS);
|
|
84
|
+
const fromRate = from === "USD" ? 1 : histories.get(from)?.closes.get(day);
|
|
85
|
+
const toRate = to === "USD" ? 1 : histories.get(to)?.closes.get(day);
|
|
86
|
+
if (fromRate && toRate) return { date: day, rate: fromRate / toRate };
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
|
|
77
91
|
/** Reads a pair's daily bars: `apiClient` in the app, a fake in tests. */
|
|
78
92
|
export interface FxHistoryClient {
|
|
79
93
|
getCloudHistory(symbol: string, exchange: string, params: CloudHistoryParams): Promise<CloudMarketResponse<CloudPricePointPayload[]>>;
|