@gloom-sh/terminal 0.20.18 → 0.20.19
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 +1 -1
- package/src/api-client/cot.ts +5 -6
- package/src/api-client/data.ts +11 -1
- package/src/api-client/index.ts +1 -0
- package/src/api-client/request.ts +162 -40
- package/src/api-client/types/news.ts +45 -0
- package/src/api-client/types/world-venues.ts +9 -0
- package/src/app.tsx +4 -2
- package/src/architecture/floating-promise-allowlist.json +1 -1
- package/src/cli/commands/market.ts +53 -17
- package/src/cli/commands/ticker.ts +13 -6
- package/src/cli/context.ts +8 -0
- package/src/cli/desktop-pane-shot-browser.ts +3 -1
- package/src/cli/desktop-pane-shot-view.ts +0 -1
- package/src/cli/desktop-pane-shot.ts +204 -43
- package/src/cli/errors.ts +3 -9
- package/src/cli/exit-codes.ts +1 -1
- package/src/cli/glossary.ts +1 -1
- package/src/cli/help.ts +1 -1
- package/src/cli/history-rows.ts +2 -2
- package/src/cli/index.ts +1 -1
- package/src/cli/listing-arg.ts +87 -23
- package/src/cli/pane-functions/catalog-snapshot.json +17 -6
- package/src/cli/pane-functions/dom.ts +30 -2
- package/src/cli/pane-functions/freshness.ts +23 -4
- package/src/cli/pane-functions/function-help.ts +3 -3
- package/src/cli/pane-functions/headless.ts +9 -1
- package/src/cli/pane-functions/index.ts +77 -10
- package/src/cli/pane-functions/report-notices.ts +10 -0
- package/src/cli/pane-functions/resolver.ts +3 -2
- package/src/cli/pane-functions/screenshot-assessment.ts +10 -5
- package/src/cli/pane-functions/screenshot-data-evidence.ts +7 -15
- package/src/cli/pane-functions/screenshot-payload.ts +24 -10
- package/src/cli/pane-functions/screenshot-render.ts +21 -8
- package/src/cli/pane-functions/screenshot-types.ts +9 -0
- package/src/cli/quote-answer.ts +1 -1
- package/src/cli/result.ts +17 -0
- package/src/cli/scroll-truncation.ts +7 -2
- package/src/cli/ticker-resolution.ts +1 -1
- package/src/cli/unreachable.ts +21 -0
- package/src/components/chart/composite/drawing-store.ts +11 -7
- package/src/components/chart/composite/format.ts +1 -0
- package/src/components/chart/composite/legend.tsx +5 -2
- package/src/components/chart/composite/panel-surface/plot-gestures.ts +9 -2
- package/src/components/chart/composite/panel-surface.tsx +1 -1
- package/src/components/chart/composite/tools.ts +164 -39
- package/src/components/chart-table/header.tsx +2 -2
- package/src/components/chart-table/layout.ts +5 -6
- package/src/components/command-bar/routes/root/runtime.ts +11 -3
- package/src/components/command-bar/routes/ticker-search/results.ts +5 -0
- package/src/components/command-bar/selection-runtime.ts +29 -5
- package/src/components/command-bar/surface/index.tsx +4 -1
- package/src/components/command-bar/workflow/alert.ts +13 -5
- package/src/components/layout/pane/footer/model.ts +10 -2
- package/src/components/layout/pane/status-footer.ts +24 -0
- package/src/components/price-performance.tsx +26 -8
- package/src/components/reader/article-reader.tsx +12 -5
- package/src/components/ui/data-table/opentui/index.tsx +7 -0
- package/src/components/ui/table-layout.ts +32 -1
- package/src/market-data/ah-pair.ts +19 -0
- package/src/market-data/coordinator/entries.ts +6 -4
- package/src/market-data/coordinator/index.ts +14 -3
- package/src/market-data/futures-board.ts +36 -29
- package/src/market-data/futures-contract.ts +37 -1
- package/src/market-data/market/change-basis.ts +9 -0
- package/src/market-data/market/status.ts +40 -4
- package/src/market-data/performance.ts +127 -32
- package/src/market-data/quotes/time.ts +5 -2
- package/src/news/types.ts +28 -0
- package/src/notifications/app-badge.ts +2 -3
- package/src/notifications/app-notifier.ts +5 -0
- package/src/plugins/builtin/alerts/cli.ts +65 -18
- package/src/plugins/builtin/alerts/command.ts +39 -9
- package/src/plugins/builtin/alerts/event-rows.ts +9 -3
- package/src/plugins/builtin/alerts/events-pane.tsx +16 -10
- package/src/plugins/builtin/alerts/headless.ts +12 -6
- package/src/plugins/builtin/alerts/index.tsx +60 -8
- package/src/plugins/builtin/alerts/option-contract.ts +197 -0
- package/src/plugins/builtin/alerts/price.ts +30 -5
- package/src/plugins/builtin/alerts/pro-rules.ts +62 -0
- package/src/plugins/builtin/alerts/research-builder.ts +5 -10
- package/src/plugins/builtin/analytics/account-returns.ts +1 -1
- package/src/plugins/builtin/analytics/pane-model.ts +2 -2
- package/src/plugins/builtin/analytics/risk-client.ts +1 -1
- package/src/plugins/builtin/buildout/company/pane.tsx +4 -14
- package/src/plugins/builtin/catalysts/model.ts +2 -1
- package/src/plugins/builtin/chart-composer/chart-spec.ts +5 -0
- package/src/plugins/builtin/chart-composer/cli-options.ts +5 -3
- package/src/plugins/builtin/chart-composer/headless-schema.ts +14 -10
- package/src/plugins/builtin/chart-composer/headless.ts +2 -0
- package/src/plugins/builtin/chart-composer/index.tsx +17 -5
- package/src/plugins/builtin/chart-composer/pane.tsx +14 -4
- package/src/plugins/builtin/chart-composer/viewport-labels.ts +2 -17
- package/src/plugins/builtin/chat/controller/notifications.ts +1 -0
- package/src/plugins/builtin/chat/index.tsx +0 -1
- package/src/plugins/builtin/commodities-energy/index.tsx +1 -1
- package/src/plugins/builtin/company-kpis/headless.ts +1 -1
- package/src/plugins/builtin/company-kpis/model.ts +21 -9
- package/src/plugins/builtin/congress-trades/model.ts +9 -5
- package/src/plugins/builtin/cot/client.ts +2 -3
- package/src/plugins/builtin/cot/headless.ts +16 -16
- package/src/plugins/builtin/cot/index.tsx +6 -6
- package/src/plugins/builtin/cot/model.ts +25 -5
- package/src/plugins/builtin/cot/pane.tsx +11 -6
- package/src/plugins/builtin/cot/series.ts +11 -8
- package/src/plugins/builtin/cpi/model.ts +15 -4
- package/src/plugins/builtin/cpi/pane.tsx +29 -7
- package/src/plugins/builtin/doe/model.ts +30 -0
- package/src/plugins/builtin/doe/pane.tsx +8 -2
- package/src/plugins/builtin/earnings/board-table.ts +9 -4
- package/src/plugins/builtin/earnings/headless.ts +10 -3
- package/src/plugins/builtin/earnings/history-table.ts +4 -2
- package/src/plugins/builtin/earnings-calls/calendar.tsx +4 -3
- package/src/plugins/builtin/earnings-ripple/pane.tsx +2 -2
- package/src/plugins/builtin/econ/index.tsx +4 -2
- package/src/plugins/builtin/futures/model.ts +14 -1
- package/src/plugins/builtin/futures/series.ts +1 -8
- package/src/plugins/builtin/fx-matrix/index.tsx +2 -2
- package/src/plugins/builtin/insider/detail.tsx +36 -7
- package/src/plugins/builtin/insider/filing-stories.ts +110 -0
- package/src/plugins/builtin/insider/headless.ts +37 -2
- package/src/plugins/builtin/insider/index.tsx +79 -10
- package/src/plugins/builtin/insider/model.ts +43 -5
- package/src/plugins/builtin/ipo-calendar/client.ts +11 -1
- package/src/plugins/builtin/ipo-calendar/model.ts +3 -7
- package/src/plugins/builtin/jobs/headless.ts +2 -1
- package/src/plugins/builtin/jobs/model.ts +6 -0
- package/src/plugins/builtin/jobs/pane.tsx +8 -3
- package/src/plugins/builtin/news/wire/news/detail-view.tsx +118 -10
- package/src/plugins/builtin/news/wire/news/story-evidence.ts +178 -0
- package/src/plugins/builtin/options/analytics.ts +1 -1
- package/src/plugins/builtin/options/view.tsx +18 -11
- package/src/plugins/builtin/options-positioning/model.ts +11 -0
- package/src/plugins/builtin/options-positioning/pane.tsx +22 -1
- package/src/plugins/builtin/options-scenario/client.ts +49 -8
- package/src/plugins/builtin/options-scenario/headless.ts +7 -3
- package/src/plugins/builtin/options-scenario/model.ts +33 -2
- package/src/plugins/builtin/options-scenario/pane.tsx +3 -4
- package/src/plugins/builtin/perps/cascade.ts +4 -3
- package/src/plugins/builtin/perps/markets-section.tsx +5 -2
- package/src/plugins/builtin/perps/model.ts +4 -3
- package/src/plugins/builtin/portfolio-list/table.tsx +3 -2
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +29 -14
- package/src/plugins/builtin/research/event-model.ts +12 -6
- package/src/plugins/builtin/research-search/index.tsx +3 -1
- package/src/plugins/builtin/scanner/denied.tsx +16 -4
- package/src/plugins/builtin/scanner/flow-pane.tsx +1 -1
- package/src/plugins/builtin/scanner/hilo-pane.tsx +1 -1
- package/src/plugins/builtin/sec/filing-display.tsx +14 -2
- package/src/plugins/builtin/sec/headless.ts +42 -4
- package/src/plugins/builtin/sec/index.tsx +21 -1
- package/src/plugins/builtin/sectors/sector-model.ts +1 -1
- package/src/plugins/builtin/shared/earnings-report.ts +32 -3
- package/src/plugins/builtin/shared/options-pro-copy.ts +34 -0
- package/src/plugins/builtin/shared/statement-currency.ts +23 -0
- package/src/plugins/builtin/shared/ticker-surface.ts +1 -1
- package/src/plugins/builtin/supply-chain/pane.tsx +4 -3
- package/src/plugins/builtin/themes/headless.ts +4 -4
- package/src/plugins/builtin/themes/model.ts +11 -8
- package/src/plugins/builtin/themes/pane.tsx +2 -2
- package/src/plugins/builtin/ticker-detail/financials/model.ts +22 -32
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +7 -9
- package/src/plugins/builtin/ticker-detail/headless-schema.ts +2 -0
- package/src/plugins/builtin/ticker-detail/headless.ts +28 -12
- package/src/plugins/builtin/ticker-detail/overview/board-lot.ts +21 -0
- package/src/plugins/builtin/ticker-detail/overview/model.ts +11 -1
- package/src/plugins/builtin/ticker-detail/overview/pane.tsx +4 -0
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +61 -13
- package/src/plugins/builtin/volatility/pane.tsx +3 -3
- package/src/plugins/builtin/world-venue-map/headless.ts +4 -2
- package/src/plugins/builtin/world-venue-map/model.ts +6 -1
- package/src/plugins/builtin/world-venue-map/venue-header.tsx +5 -3
- package/src/plugins/catalog-browser.ts +10 -1
- package/src/renderers/browser/activity.ts +16 -0
- package/src/renderers/browser/app-badge-host.ts +14 -0
- package/src/renderers/browser/main.tsx +5 -0
- package/src/renderers/browser/notifications.ts +103 -0
- package/src/renderers/browser/ui-host.tsx +4 -0
- package/src/renderers/dom/data-table/index.tsx +27 -4
- package/src/renderers/electrobun/view/http-fetch.ts +3 -2
- package/src/sources/gloomberb-cloud/index.ts +8 -6
- package/src/sources/gloomberb-cloud/news.ts +35 -0
- package/src/sources/provider-errors.ts +34 -7
- package/src/sources/provider-router/history.ts +32 -6
- package/src/time-series/base-series.ts +39 -6
- package/src/time-series/chart-seed.ts +2 -2
- package/src/time-series/history-quality.ts +4 -1
- package/src/time-series/hooks.ts +2 -0
- package/src/time-series/price-comparison.ts +17 -23
- package/src/time-series/reporting.ts +1 -1
- package/src/time-series/resolution.ts +13 -0
- package/src/time-series/resolve-context.ts +6 -0
- package/src/time-series/resolve.ts +39 -2
- package/src/time-series/types.ts +2 -1
- package/src/types/financials.ts +9 -1
- package/src/types/headless.ts +1 -0
- package/src/types/issuer-listings.ts +2 -0
- package/src/types/plugin-notifications.ts +3 -0
- package/src/types/price-history.ts +6 -4
- package/src/ui/host.tsx +2 -0
- package/src/utils/exchange-announcements.ts +7 -2
- package/src/utils/fundamentals.ts +40 -0
- package/src/utils/network-failure.ts +2 -0
- package/src/utils/price-history-integrity.ts +9 -1
|
@@ -28,9 +28,12 @@ export interface FuturesContract {
|
|
|
28
28
|
/** Lists a contract for every calendar month. */
|
|
29
29
|
everyMonth?: true;
|
|
30
30
|
/**
|
|
31
|
-
* What a price counts
|
|
32
|
-
*
|
|
33
|
-
*
|
|
31
|
+
* What a price counts when the server's contract terms are not at hand: a
|
|
32
|
+
* terms read that failed, or a root the server sends none for. Dutch TTF gas
|
|
33
|
+
* quotes in euros per MWh, which a bare "EUR" does not say, live cattle in US
|
|
34
|
+
* cents per pound, where the server's "USX" does not, and copper in USD / lb,
|
|
35
|
+
* not a bare USD. Worded as the server's terms word it (checked 2026-11-17),
|
|
36
|
+
* which win when they come.
|
|
34
37
|
*/
|
|
35
38
|
unit?: string;
|
|
36
39
|
/**
|
|
@@ -110,40 +113,44 @@ export const FUTURES_CONTRACTS: FuturesContract[] = [
|
|
|
110
113
|
{ symbol: "ZB=F", code: "ZB", name: "30-Year T-Bond", sector: "rates", venue: "CBT", bareCode: true },
|
|
111
114
|
{ symbol: "UB=F", code: "UB", name: "Ultra T-Bond", sector: "rates", venue: "CBT", bareCode: true },
|
|
112
115
|
|
|
113
|
-
{ symbol: "CL=F", code: "CL", name: "WTI Crude Oil", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.01, aliases: ["oil"] },
|
|
116
|
+
{ symbol: "CL=F", code: "CL", name: "WTI Crude Oil", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.01, unit: "USD / barrel", aliases: ["oil"] },
|
|
114
117
|
// NYMEX's Brent, cash-settled to the ICE Brent futures settlement; ICE's own contract (B) is not carried.
|
|
115
|
-
{ symbol: "BZ=F", code: "BZ", name: "Brent Crude Oil Last Day Financial", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.01 },
|
|
116
|
-
{ symbol: "NG=F", code: "NG", name: "Natural Gas", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.001, aliases: ["natgas", "nat gas"] },
|
|
118
|
+
{ symbol: "BZ=F", code: "BZ", name: "Brent Crude Oil Last Day Financial", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.01, unit: "USD / barrel" },
|
|
119
|
+
{ symbol: "NG=F", code: "NG", name: "Natural Gas", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.001, unit: "USD / MMBtu", aliases: ["natgas", "nat gas"] },
|
|
117
120
|
// Quoted in euros per MWh.
|
|
118
121
|
{ symbol: "TTF=F", code: "TTF", name: "Dutch TTF Gas", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.001, unit: "EUR / MWh", bareCode: true },
|
|
119
|
-
{ symbol: "RB=F", code: "RB", name: "RBOB Gasoline", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.0001 },
|
|
120
|
-
{ symbol: "HO=F", code: "HO", name: "Heating Oil", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.0001 },
|
|
122
|
+
{ symbol: "RB=F", code: "RB", name: "RBOB Gasoline", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.0001, unit: "USD / gallon" },
|
|
123
|
+
{ symbol: "HO=F", code: "HO", name: "Heating Oil", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.0001, unit: "USD / gallon" },
|
|
121
124
|
// Cash settled on the CL and NG final settlements.
|
|
122
|
-
{ symbol: "QM=F", code: "QM", name: "E-Mini Crude Oil", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.025, bareCode: true },
|
|
123
|
-
{ symbol: "MCL=F", code: "MCL", name: "Micro WTI Crude Oil", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.01 },
|
|
124
|
-
{ symbol: "QG=F", code: "QG", name: "E-Mini Natural Gas", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.005, bareCode: true },
|
|
125
|
-
{ symbol: "MNG=F", code: "MNG", name: "Micro Henry Hub Natural Gas", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.001 },
|
|
126
|
-
{ symbol: "HH=F", code: "HH", name: "Henry Hub Last Day Financial", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.001 },
|
|
127
|
-
|
|
128
|
-
{ symbol: "GC=F", code: "GC", name: "Gold", sector: "metals", venue: "CMX", tick: 0.1 },
|
|
129
|
-
{ symbol: "SI=F", code: "SI", name: "Silver", sector: "metals", venue: "CMX", tick: 0.005 },
|
|
130
|
-
{ symbol: "HG=F", code: "HG", name: "Copper", sector: "metals", venue: "CMX", tick: 0.0005 },
|
|
125
|
+
{ symbol: "QM=F", code: "QM", name: "E-Mini Crude Oil", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.025, unit: "USD / barrel", bareCode: true },
|
|
126
|
+
{ symbol: "MCL=F", code: "MCL", name: "Micro WTI Crude Oil", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.01, unit: "USD / barrel" },
|
|
127
|
+
{ symbol: "QG=F", code: "QG", name: "E-Mini Natural Gas", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.005, unit: "USD / MMBtu", bareCode: true },
|
|
128
|
+
{ symbol: "MNG=F", code: "MNG", name: "Micro Henry Hub Natural Gas", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.001, unit: "USD / MMBtu" },
|
|
129
|
+
{ symbol: "HH=F", code: "HH", name: "Henry Hub Last Day Financial", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.001, unit: "USD / MMBtu" },
|
|
130
|
+
|
|
131
|
+
{ symbol: "GC=F", code: "GC", name: "Gold", sector: "metals", venue: "CMX", tick: 0.1, unit: "USD / troy oz" },
|
|
132
|
+
{ symbol: "SI=F", code: "SI", name: "Silver", sector: "metals", venue: "CMX", tick: 0.005, unit: "USD / troy oz" },
|
|
133
|
+
{ symbol: "HG=F", code: "HG", name: "Copper", sector: "metals", venue: "CMX", tick: 0.0005, unit: "USD / lb" },
|
|
134
|
+
// COMEX's micro metals, each settled daily at its full-size contract's settlement for the month.
|
|
135
|
+
{ symbol: "MGC=F", code: "MGC", name: "Micro Gold", sector: "metals", venue: "CMX", tick: 0.1, unit: "USD / troy oz" },
|
|
136
|
+
{ symbol: "SIL=F", code: "SIL", name: "Micro Silver", sector: "metals", venue: "CMX", tick: 0.005, unit: "USD / troy oz" },
|
|
137
|
+
{ symbol: "MHG=F", code: "MHG", name: "Micro Copper", sector: "metals", venue: "CMX", tick: 0.0005, unit: "USD / lb" },
|
|
131
138
|
{ symbol: "ALI=F", code: "ALI", name: "Aluminum", sector: "metals", venue: "CMX", tick: 0.25, unit: "USD / metric ton" },
|
|
132
|
-
{ symbol: "PL=F", code: "PL", name: "Platinum", sector: "metals", venue: "NYM", tick: 0.1 },
|
|
133
|
-
{ symbol: "PA=F", code: "PA", name: "Palladium", sector: "metals", venue: "NYM", tick: 0.1 },
|
|
139
|
+
{ symbol: "PL=F", code: "PL", name: "Platinum", sector: "metals", venue: "NYM", tick: 0.1, unit: "USD / troy oz" },
|
|
140
|
+
{ symbol: "PA=F", code: "PA", name: "Palladium", sector: "metals", venue: "NYM", tick: 0.1, unit: "USD / troy oz" },
|
|
134
141
|
|
|
135
142
|
// Most grains and softs quote in US cents (cocoa, soybean meal and lumber in
|
|
136
143
|
// dollars); a tick is in the quote's own units.
|
|
137
|
-
{ symbol: "ZC=F", code: "ZC", name: "Corn", sector: "agriculture", venue: "CBT", tick: 0.25 },
|
|
138
|
-
{ symbol: "ZS=F", code: "ZS", name: "Soybeans", sector: "agriculture", venue: "CBT", tick: 0.25 },
|
|
139
|
-
{ symbol: "ZM=F", code: "ZM", name: "Soybean Meal", sector: "agriculture", venue: "CBT", tick: 0.1 },
|
|
140
|
-
{ symbol: "ZL=F", code: "ZL", name: "Soybean Oil", sector: "agriculture", venue: "CBT", tick: 0.01, bareCode: true },
|
|
141
|
-
{ symbol: "ZW=F", code: "ZW", name: "Chicago SRW Wheat", sector: "agriculture", venue: "CBT", tick: 0.25, bareCode: true },
|
|
142
|
-
{ symbol: "KE=F", code: "KE", name: "KC HRW Wheat", sector: "agriculture", venue: "CBT", tick: 0.25 },
|
|
143
|
-
{ symbol: "KC=F", code: "KC", name: "Coffee", sector: "agriculture", venue: "NYB", tick: 0.05 },
|
|
144
|
-
{ symbol: "SB=F", code: "SB", name: "Sugar #11", sector: "agriculture", venue: "NYB", tick: 0.01 },
|
|
145
|
-
{ symbol: "CC=F", code: "CC", name: "Cocoa", sector: "agriculture", venue: "NYB", tick: 1 },
|
|
146
|
-
{ symbol: "CT=F", code: "CT", name: "Cotton #2", sector: "agriculture", venue: "NYB", tick: 0.01, bareCode: true },
|
|
144
|
+
{ symbol: "ZC=F", code: "ZC", name: "Corn", sector: "agriculture", venue: "CBT", tick: 0.25, unit: "US cents / bushel" },
|
|
145
|
+
{ symbol: "ZS=F", code: "ZS", name: "Soybeans", sector: "agriculture", venue: "CBT", tick: 0.25, unit: "US cents / bushel" },
|
|
146
|
+
{ symbol: "ZM=F", code: "ZM", name: "Soybean Meal", sector: "agriculture", venue: "CBT", tick: 0.1, unit: "USD / short ton" },
|
|
147
|
+
{ symbol: "ZL=F", code: "ZL", name: "Soybean Oil", sector: "agriculture", venue: "CBT", tick: 0.01, unit: "US cents / lb", bareCode: true },
|
|
148
|
+
{ symbol: "ZW=F", code: "ZW", name: "Chicago SRW Wheat", sector: "agriculture", venue: "CBT", tick: 0.25, unit: "US cents / bushel", bareCode: true },
|
|
149
|
+
{ symbol: "KE=F", code: "KE", name: "KC HRW Wheat", sector: "agriculture", venue: "CBT", tick: 0.25, unit: "US cents / bushel" },
|
|
150
|
+
{ symbol: "KC=F", code: "KC", name: "Coffee", sector: "agriculture", venue: "NYB", tick: 0.05, unit: "US cents / lb" },
|
|
151
|
+
{ symbol: "SB=F", code: "SB", name: "Sugar #11", sector: "agriculture", venue: "NYB", tick: 0.01, unit: "US cents / lb" },
|
|
152
|
+
{ symbol: "CC=F", code: "CC", name: "Cocoa", sector: "agriculture", venue: "NYB", tick: 1, unit: "USD / metric ton" },
|
|
153
|
+
{ symbol: "CT=F", code: "CT", name: "Cotton #2", sector: "agriculture", venue: "NYB", tick: 0.01, unit: "US cents / lb", bareCode: true },
|
|
147
154
|
{ symbol: "OJ=F", code: "OJ", name: "Orange Juice", sector: "agriculture", venue: "NYB", tick: 0.05, unit: "US cents / lb", bareCode: true },
|
|
148
155
|
{ symbol: "LBR=F", code: "LBR", name: "Lumber", sector: "agriculture", venue: "CME", tick: 0.5, unit: "USD / 1,000 board ft", bareCode: true },
|
|
149
156
|
|
|
@@ -5,6 +5,7 @@ import { classifyInstrumentType } from "../tickers/instrument-kind";
|
|
|
5
5
|
import type { Quote } from "../types/financials";
|
|
6
6
|
import { parsePublicTickerKey } from "../utils/exchanges";
|
|
7
7
|
import { logFailure } from "../utils/log-failure";
|
|
8
|
+
import { createPluginCache, savedCopyForTransientFailure } from "../data/plugin-cache";
|
|
8
9
|
import { futuresBoardContract, futuresContractByCode, type FuturesContract } from "./futures-board";
|
|
9
10
|
import { formatMarketPrice, formatMarketPriceWithCurrency, quoteFormatOptions, withCurrencyMinorDigits } from "./market/format";
|
|
10
11
|
import { previousPublishedSession } from "./market/freshness";
|
|
@@ -463,6 +464,37 @@ export function validateFuturesContractTerms(data: FuturesContractTermsPayload):
|
|
|
463
464
|
return invalid.length ? { ...data, ...Object.fromEntries(invalid.map(([key]) => [key, null])) } : data;
|
|
464
465
|
}
|
|
465
466
|
|
|
467
|
+
/**
|
|
468
|
+
* A futures symbol's terms as last read, kept where the profile keeps saved
|
|
469
|
+
* copies once a command or the app attaches it. Every read asks the service
|
|
470
|
+
* again (a contract rolls, its settlement moves each session); a read the
|
|
471
|
+
* service could not answer is answered from the copy, which a command dates
|
|
472
|
+
* as saved (`servedFromSavedCopy`). Offline, DES GC=F and `quote GC=F` kept
|
|
473
|
+
* the saved price but lost the settle, the Contract block and the unit.
|
|
474
|
+
*/
|
|
475
|
+
const savedTerms = createPluginCache<FuturesContractTermsPayload>({
|
|
476
|
+
kind: "futures-contract-terms",
|
|
477
|
+
source: "gloom-cloud",
|
|
478
|
+
policy: { staleMs: 0, expireMs: 14 * 86_400_000 },
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
/** Where the terms read are saved for a later read the service cannot answer: a command's profile, or the app's. */
|
|
482
|
+
export const attachFuturesTermsPersistence = savedTerms.attach;
|
|
483
|
+
|
|
484
|
+
const savedTermsKey = (symbol: string) => parsePublicTickerKey(symbol).symbol.trim().toUpperCase();
|
|
485
|
+
|
|
486
|
+
/** Keeps terms read on another path (a capture's page asking through its proxy) as `loadFuturesContractTerms` keeps its own. */
|
|
487
|
+
export function rememberFuturesContractTerms(symbol: string, terms: FuturesContractTermsPayload): void {
|
|
488
|
+
void savedTerms.load(savedTermsKey(symbol), async () => validateFuturesContractTerms(terms), { force: true })
|
|
489
|
+
.catch(logFailure("market-data.futures-contract", "Saving futures contract terms failed"));
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/** The terms saved for a symbol, and when (ms), however old; null when none were. */
|
|
493
|
+
export function savedFuturesContractTerms(symbol: string): { terms: FuturesContractTermsPayload; savedAt: number } | null {
|
|
494
|
+
const saved = savedTerms.get(savedTermsKey(symbol), { allowExpired: true });
|
|
495
|
+
return saved ? { terms: saved.data, savedAt: saved.fetchedAt } : null;
|
|
496
|
+
}
|
|
497
|
+
|
|
466
498
|
/** A futures symbol's contract, terms and latest confirmed settlement; throws when the server has none for it. */
|
|
467
499
|
export async function loadFuturesContractTerms(
|
|
468
500
|
symbol: string,
|
|
@@ -471,7 +503,11 @@ export async function loadFuturesContractTerms(
|
|
|
471
503
|
options: { batch?: boolean } = {},
|
|
472
504
|
): Promise<FuturesContractTermsPayload> {
|
|
473
505
|
// The terms are the contract's wherever it is listed: GC=F:CMX asks for GC=F.
|
|
474
|
-
|
|
506
|
+
const read = async () => validateFuturesContractTerms(await client.getCloudFuturesContract(parsePublicTickerKey(symbol).symbol, options));
|
|
507
|
+
// A board's rows, read in batches every minute, and a caller's own client are not kept: one symbol's read is.
|
|
508
|
+
if (options.batch || client !== apiClient) return read();
|
|
509
|
+
// A failure asking again may get past (no connection, a timeout) is answered from the saved copy; a refusal is not.
|
|
510
|
+
return savedCopyForTransientFailure(await savedTerms.load(savedTermsKey(symbol), read, { force: true })).data;
|
|
475
511
|
}
|
|
476
512
|
|
|
477
513
|
/**
|
|
@@ -380,6 +380,15 @@ function sessionDay(date: string, now: number): string {
|
|
|
380
380
|
return formatUtcDayTime({ time: Date.parse(`${date}T00:00:00Z`), dateOnly: true }, now);
|
|
381
381
|
}
|
|
382
382
|
|
|
383
|
+
/**
|
|
384
|
+
* The close a headline price is, by its session's day: "Tue 17 Nov close",
|
|
385
|
+
* worded as the close a move is from ("vs Mon 16 Nov close"), so a report that
|
|
386
|
+
* shows an after-hours print beside it dates the two apart (headlineCloseDate).
|
|
387
|
+
*/
|
|
388
|
+
export function closeDayLabel(date: string, now = Date.now()): string {
|
|
389
|
+
return `${sessionDay(date, now)} close`;
|
|
390
|
+
}
|
|
391
|
+
|
|
383
392
|
/**
|
|
384
393
|
* The words a change line ends with, the same on every surface: "vs Fri 16
|
|
385
394
|
* Oct close", "vs Fri 16 Oct settle", "vs prev close", "since 00:00 UTC",
|
|
@@ -487,12 +487,23 @@ function preMarketCloseAwaitingPrint(quote: Quote | null | undefined): { date: s
|
|
|
487
487
|
|
|
488
488
|
/**
|
|
489
489
|
* When the price a quote's headline shows was observed: the regular close a
|
|
490
|
-
* pre-market with no trade yet still stands at (preMarketCloseAwaitingPrint)
|
|
491
|
-
*
|
|
492
|
-
*
|
|
490
|
+
* pre-market with no trade yet still stands at (preMarketCloseAwaitingPrint);
|
|
491
|
+
* a completed session's close stamped after the venue closed, with no
|
|
492
|
+
* extended print beside it, at that close (regularSessionCloseOn), as `fn
|
|
493
|
+
* ADR` and `fx` date it (GGAL.BA's 4,857.50 read 20:59 UTC in `quote` and
|
|
494
|
+
* 20:10 in `fn ADR`, its close on BYMA's calendar); otherwise the quote's last
|
|
495
|
+
* update. What an Updated cell and a report's as-of date the quote by.
|
|
493
496
|
*/
|
|
494
497
|
export function quoteHeadlineTime(quote: Quote): number {
|
|
495
|
-
|
|
498
|
+
const awaiting = preMarketCloseAwaitingPrint(quote);
|
|
499
|
+
if (awaiting) return awaiting.closedAt;
|
|
500
|
+
// A closed market's quote only: in a pre-market or after-hours session the last update can be a print.
|
|
501
|
+
const date = quote.marketState === "CLOSED" && !quote.delisting ? regularSessionDisplayDate(quote) : null;
|
|
502
|
+
if (date && Number.isFinite(quote.lastUpdated) && !getExtendedSessionDisplay(quote)) {
|
|
503
|
+
const closedAt = regularSessionCloseOn(quote.listingExchangeName || quote.exchangeName, date);
|
|
504
|
+
if (closedAt != null && quote.lastUpdated > closedAt) return closedAt;
|
|
505
|
+
}
|
|
506
|
+
return quote.lastUpdated;
|
|
496
507
|
}
|
|
497
508
|
|
|
498
509
|
/**
|
|
@@ -532,6 +543,31 @@ export function regularSessionDisplayDate(quote: Quote | null | undefined): stri
|
|
|
532
543
|
return completedRegularSession(quote)?.date ?? quote.changeSessionDate ?? null;
|
|
533
544
|
}
|
|
534
545
|
|
|
546
|
+
/**
|
|
547
|
+
* The exchange-local day of the close a quote's headline holds at once its
|
|
548
|
+
* regular session is over (and in the pre-market while it still shows the last
|
|
549
|
+
* close), so a report that prints an extended print beside it dates each: the
|
|
550
|
+
* close by its day, the print by its time (extendedPrintTime). Null while the
|
|
551
|
+
* session trades, for a listing that no longer trades, and when the quote does
|
|
552
|
+
* not say which day the close is.
|
|
553
|
+
*/
|
|
554
|
+
export function headlineCloseDate(quote: Quote | null | undefined): string | null {
|
|
555
|
+
if (!quote || quote.delisting || completedRegularClose(quote) == null) return null;
|
|
556
|
+
const date = regularSessionDisplayDate(quote);
|
|
557
|
+
return date && /^\d{4}-\d{2}-\d{2}$/.test(date) ? date : null;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* When the pre-market, after-hours or overnight print getExtendedSessionDisplay
|
|
562
|
+
* shows was observed: the quote's last update, which that print is (the close
|
|
563
|
+
* beside it holds at its own day, headlineCloseDate). Null without an extended
|
|
564
|
+
* print or a time.
|
|
565
|
+
*/
|
|
566
|
+
export function extendedPrintTime(quote: Quote | null | undefined): number | null {
|
|
567
|
+
if (!quote || !getExtendedSessionDisplay(quote)) return null;
|
|
568
|
+
return Number.isFinite(quote.lastUpdated) && quote.lastUpdated > 0 ? quote.lastUpdated : null;
|
|
569
|
+
}
|
|
570
|
+
|
|
535
571
|
/**
|
|
536
572
|
* getRegularSessionDisplay once the regular session is over (and in the
|
|
537
573
|
* pre-market, while the quote carries the last session's close and move), null
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { PricePoint, Quote } from "../types/financials";
|
|
2
|
-
import { pricePointCloseCopied, pricePointIntegrity } from "../utils/price-history-integrity";
|
|
2
|
+
import { CONTRADICTORY_PRICES, pricePointCloseCopied, pricePointIntegrity } from "../utils/price-history-integrity";
|
|
3
3
|
import { calendarMonthsBefore } from "../utils/calendar-date";
|
|
4
|
-
import {
|
|
4
|
+
import { formatShortDate } from "../utils/datetime-format";
|
|
5
|
+
import { barCloseDay, barSessionDay, isReturnPeriod, periodBaseDay, periodBaseIndex } from "./market/period-return";
|
|
6
|
+
import { getRegularSessionDisplay, headlineCloseDate } from "./market/status";
|
|
5
7
|
|
|
6
8
|
export interface PriceReturnHorizon {
|
|
7
9
|
id: string;
|
|
@@ -15,6 +17,30 @@ export interface PriceReturnField {
|
|
|
15
17
|
label: string;
|
|
16
18
|
value: number | null;
|
|
17
19
|
unavailableReason?: "inconsistent-ohlc";
|
|
20
|
+
/** With `inconsistent-ohlc`: the session day of the end bar (the base or the latest) whose prices contradict each other. */
|
|
21
|
+
inconsistentDay?: string;
|
|
22
|
+
/** The day of the close the return is measured from, `YYYY-MM-DD`: the last close on or before the period's start date. */
|
|
23
|
+
baseDay?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const DAILY_WINDOW_LEAD_DAYS = 21;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The daily closes a Price Return strip is measured on: five years and the
|
|
30
|
+
* three weeks before them, so 5Y has the close on its start date (a "5Y"
|
|
31
|
+
* range starts the day after it), to the end of today in UTC, so a day keeps
|
|
32
|
+
* one request.
|
|
33
|
+
*/
|
|
34
|
+
export function priceReturnDailyWindow(now = Date.now()): { start: Date; end: Date } {
|
|
35
|
+
const today = new Date(Math.floor(now / 86_400_000) * 86_400_000);
|
|
36
|
+
const start = new Date(Date.UTC(today.getUTCFullYear() - 5, today.getUTCMonth(), today.getUTCDate() - DAILY_WINDOW_LEAD_DAYS));
|
|
37
|
+
return { start, end: new Date(today.getTime() + 86_400_000) };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** The price a strip's returns run to, and the session day it is from. */
|
|
41
|
+
export interface PriceReturnEnd {
|
|
42
|
+
day: string;
|
|
43
|
+
close: number;
|
|
18
44
|
}
|
|
19
45
|
|
|
20
46
|
export const PRICE_RETURN_HORIZONS: PriceReturnHorizon[] = [
|
|
@@ -100,14 +126,32 @@ function isInconsistent(point: PricePoint): boolean {
|
|
|
100
126
|
return inconsistent;
|
|
101
127
|
}
|
|
102
128
|
|
|
129
|
+
/**
|
|
130
|
+
* The price a quote's returns run to: its headline, the regular session's
|
|
131
|
+
* price, which stops at the close, never an after-hours or pre-market print
|
|
132
|
+
* (GGAL's 1Y ran to the 29.08 after-hours print beside its 28.53 close). Dated
|
|
133
|
+
* by the session that close is from, or while it trades by the quote's time
|
|
134
|
+
* on the venue's clock. Null without a price.
|
|
135
|
+
*/
|
|
136
|
+
export function headlinePriceReturnEnd(quote: Quote | null | undefined, venue?: string): PriceReturnEnd | null {
|
|
137
|
+
const close = getRegularSessionDisplay(quote)?.price;
|
|
138
|
+
if (!quote || close == null || !Number.isFinite(close)) return null;
|
|
139
|
+
// A time that is no date (a source's unknown timestamp) dates nothing.
|
|
140
|
+
const timed = Number.isFinite(new Date(quote.lastUpdated).getTime());
|
|
141
|
+
const day = headlineCloseDate(quote) ?? (timed ? barSessionDay(quote.lastUpdated, venue) : null);
|
|
142
|
+
return day ? { day, close } : null;
|
|
143
|
+
}
|
|
144
|
+
|
|
103
145
|
export function appendQuoteToPriceReturnHistory(
|
|
104
146
|
points: readonly PricePoint[],
|
|
105
|
-
quote:
|
|
147
|
+
quote: Quote | null | undefined,
|
|
106
148
|
): readonly PricePoint[] {
|
|
107
149
|
const history = normalizePriceReturnHistory(points);
|
|
108
150
|
if (!quote || !Number.isFinite(quote.price) || !Number.isFinite(quote.lastUpdated)) {
|
|
109
151
|
return history;
|
|
110
152
|
}
|
|
153
|
+
// The headline price, never an extended-hours print.
|
|
154
|
+
const price = getRegularSessionDisplay(quote)?.price ?? quote.price;
|
|
111
155
|
|
|
112
156
|
const quoteDate = new Date(quote.lastUpdated);
|
|
113
157
|
if (!Number.isFinite(quoteDate.getTime())) return history;
|
|
@@ -119,7 +163,7 @@ export function appendQuoteToPriceReturnHistory(
|
|
|
119
163
|
...history,
|
|
120
164
|
{
|
|
121
165
|
date: quoteDate,
|
|
122
|
-
close:
|
|
166
|
+
close: price,
|
|
123
167
|
},
|
|
124
168
|
];
|
|
125
169
|
normalizedArrays.add(withQuote);
|
|
@@ -139,59 +183,110 @@ export function computePriceReturnForHorizon(
|
|
|
139
183
|
horizon: PriceReturnHorizon,
|
|
140
184
|
venue?: string,
|
|
141
185
|
): number | null {
|
|
142
|
-
return
|
|
186
|
+
return buildPriceReturnFields(points, venue, [horizon])[0]?.value ?? null;
|
|
143
187
|
}
|
|
144
188
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
)
|
|
150
|
-
|
|
151
|
-
|
|
189
|
+
const DAY_MS = 86_400_000;
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* The bar size of a history read as returns: weekly or monthly bars close on
|
|
193
|
+
* the last day of their period (barCloseDay), which a period's base is held
|
|
194
|
+
* against, not the Monday they are dated by. Undefined for daily bars, and for
|
|
195
|
+
* a short or irregular history, which is read by its dates.
|
|
196
|
+
*/
|
|
197
|
+
function barInterval(history: readonly PricePoint[]): "1wk" | "1mo" | undefined {
|
|
198
|
+
if (history.length < 4) return undefined;
|
|
199
|
+
const gaps = history.slice(1).map((point, index) => (point.date.getTime() - history[index]!.date.getTime()) / DAY_MS);
|
|
200
|
+
// Most bars a week or a month apart, a holiday's week or a quote appended to them aside; a sparse history is read as dated.
|
|
201
|
+
const share = (low: number, high: number) => gaps.filter((gap) => gap >= low && gap <= high).length / gaps.length;
|
|
202
|
+
return share(5, 9) >= 0.8 ? "1wk" : share(26, 33) >= 0.8 ? "1mo" : undefined;
|
|
152
203
|
}
|
|
153
204
|
|
|
154
|
-
/**
|
|
205
|
+
/**
|
|
206
|
+
* `history` normalized, `days` the day each bar's close is from. A period
|
|
207
|
+
* runs from the last close on or before its start date (periodBaseDay of the
|
|
208
|
+
* end's day, as every period return is measured) to `end`, the headline's
|
|
209
|
+
* price when given, else the newest close. No gap limit: the overview's
|
|
210
|
+
* history can be sparse, and its base is whatever close it holds on or
|
|
211
|
+
* before then.
|
|
212
|
+
*/
|
|
155
213
|
function priceReturnFromHistory(
|
|
156
214
|
history: readonly PricePoint[],
|
|
157
215
|
days: readonly string[],
|
|
158
216
|
horizon: PriceReturnHorizon,
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
|
|
217
|
+
end: PriceReturnEnd | null,
|
|
218
|
+
): Pick<PriceReturnField, "value" | "unavailableReason" | "inconsistentDay" | "baseDay"> {
|
|
219
|
+
const inconsistentAt = (index: number) => ({ value: null, unavailableReason: "inconsistent-ohlc" as const, inconsistentDay: days[index]! });
|
|
220
|
+
const last = history.at(-1);
|
|
221
|
+
const final = end ?? (last ? { day: days.at(-1)!, close: last.close } : null);
|
|
222
|
+
if (!final || history.length < (end ? 1 : 2)) {
|
|
223
|
+
const index = history.findIndex(isInconsistent);
|
|
224
|
+
return index < 0 ? { value: null } : inconsistentAt(index);
|
|
225
|
+
}
|
|
166
226
|
// The close on or before the same date a horizon earlier, as every period return is measured. No gap
|
|
167
227
|
// limit: the overview's history can be sparse, and its base is whatever close it holds on or before then.
|
|
168
228
|
// Each bar and the quote by its session day: a JPX bar stamped 00:00 JST, or a quote after a New York close, is not the UTC date's.
|
|
169
|
-
const baseDay = horizonBaseDay(
|
|
170
|
-
|
|
229
|
+
const baseDay = horizonBaseDay(final.day, horizon);
|
|
230
|
+
// The end's own close is never its base.
|
|
231
|
+
const before = end ? days.length : days.length - 1;
|
|
232
|
+
const baseIndex = periodBaseIndex(days.slice(0, before), baseDay, Number.POSITIVE_INFINITY);
|
|
171
233
|
const baseline = baseIndex < 0 ? null : history[baseIndex]!;
|
|
172
|
-
const cutoff = new Date(`${baseDay}T00:00:00Z`);
|
|
173
234
|
|
|
174
|
-
//
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
235
|
+
// A price return reads two closes, the base's and the end's. A bar between them whose prices contradict each
|
|
236
|
+
// other changes neither, so only an end bar's contradiction leaves the return blank (as the sector board reads its
|
|
237
|
+
// returns): 3698:HKEX's 3Y and 5Y read blank for one bad bar inside the five years before. A headline price given
|
|
238
|
+
// as the end is no bar.
|
|
239
|
+
if (!end && isInconsistent(last!)) return inconsistentAt(history.length - 1);
|
|
240
|
+
if (baseline && isInconsistent(baseline)) return inconsistentAt(baseIndex);
|
|
179
241
|
if (!baseline || !Number.isFinite(baseline.close) || baseline.close === 0) return { value: null };
|
|
180
|
-
if (!Number.isFinite(
|
|
181
|
-
return { value: (
|
|
242
|
+
if (!Number.isFinite(final.close)) return { value: null };
|
|
243
|
+
return { value: (final.close - baseline.close) / baseline.close, baseDay: days[baseIndex]! };
|
|
182
244
|
}
|
|
183
245
|
|
|
246
|
+
/** "1M", "1M and 3M", "1M, 3M and 1Y". */
|
|
247
|
+
function listed(items: readonly string[]): string {
|
|
248
|
+
return items.length <= 1 ? items.join("") : `${items.slice(0, -1).join(", ")} and ${items.at(-1)}`;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* "3Y and 5Y returns left blank: contradictory prices on 16 Jan 2025.": the returns shown blank because the bar one is
|
|
253
|
+
* measured from or to has contradictory prices, with those bars' days; undefined when none is. A bad bar no shown
|
|
254
|
+
* return reads is not mentioned: it changes no figure the overview shows.
|
|
255
|
+
*/
|
|
256
|
+
export function priceReturnIntegrityNotice(fields: readonly PriceReturnField[]): string | undefined {
|
|
257
|
+
const blank = fields.filter((field) => field.unavailableReason === "inconsistent-ohlc");
|
|
258
|
+
if (blank.length === 0) return undefined;
|
|
259
|
+
const days = [...new Set(blank.flatMap((field) => field.inconsistentDay ? [field.inconsistentDay] : []))].sort();
|
|
260
|
+
const on = days.length > 0 ? ` on ${listed(days.map((day) => formatShortDate(`${day}T00:00:00Z`, { utc: true })))}` : "";
|
|
261
|
+
return `${listed(blank.map((field) => field.label))} ${blank.length === 1 ? "return" : "returns"} left blank: ${CONTRADICTORY_PRICES}${on}.`;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Each horizon's return over `points`, from the close on or before its start
|
|
266
|
+
* date to `end` (headlinePriceReturnEnd), else to the newest close. Daily
|
|
267
|
+
* bars give each base the close of that day; weekly or monthly ones the last
|
|
268
|
+
* close of a period ending on or before it. Each field names its base close's
|
|
269
|
+
* day.
|
|
270
|
+
*/
|
|
184
271
|
export function buildPriceReturnFields(
|
|
185
272
|
points: readonly PricePoint[],
|
|
186
273
|
venue?: string,
|
|
187
274
|
horizons: readonly PriceReturnHorizon[] = PRICE_RETURN_HORIZONS,
|
|
275
|
+
end?: PriceReturnEnd | null,
|
|
188
276
|
): PriceReturnField[] {
|
|
189
277
|
// Normalized and dated once for every horizon.
|
|
190
278
|
const history = normalizePriceReturnHistory(points);
|
|
191
|
-
const
|
|
279
|
+
const sessions = sessionDays(history, venue);
|
|
280
|
+
const interval = barInterval(history);
|
|
281
|
+
const days = interval ? sessions.map((day) => barCloseDay(day, interval, venue)) : sessions;
|
|
282
|
+
// A headline older than the bars (a quote that stopped while history went on) is not the end: the newest close is.
|
|
283
|
+
// Held against the newest bar's session, not the day its period closes: a weekly bar dated Monday 9 Nov closes on
|
|
284
|
+
// Friday 13 Nov, after Wednesday's headline, which is still newer than the bar's Monday.
|
|
285
|
+
const lastSession = sessions.at(-1);
|
|
286
|
+
const final = end && (lastSession === undefined || end.day >= lastSession) ? end : null;
|
|
192
287
|
return horizons.map((horizon) => ({
|
|
193
288
|
id: horizon.id,
|
|
194
289
|
label: horizon.label,
|
|
195
|
-
...priceReturnFromHistory(history, days, horizon),
|
|
290
|
+
...priceReturnFromHistory(history, days, horizon, final),
|
|
196
291
|
}));
|
|
197
292
|
}
|
|
@@ -40,8 +40,11 @@ function quoteFeedWord(quote: Quote): string | null {
|
|
|
40
40
|
return `${Math.round(delayedFeedLagMs(exchange) / 60_000)} min delayed`;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
/**
|
|
44
|
-
|
|
43
|
+
/**
|
|
44
|
+
* `08:09 UTC` on today's UTC date, `Thu 08:09 UTC` within the week, `Thu 29 Oct
|
|
45
|
+
* 08:09 UTC` before it: when a card's price, or an extended print, was observed.
|
|
46
|
+
*/
|
|
47
|
+
export function asOfClock(time: number, now = Date.now()): string {
|
|
45
48
|
const iso = new Date(time).toISOString();
|
|
46
49
|
if (iso.slice(0, 10) === new Date(now).toISOString().slice(0, 10)) return `${iso.slice(11, 16)} UTC`;
|
|
47
50
|
return `${now - time < WEEK_MS ? formatUtcWeekdayTime(time) : formatUtcDayTime({ time, dateOnly: false }, now)} UTC`;
|
package/src/news/types.ts
CHANGED
|
@@ -23,6 +23,32 @@ export interface NewsStoryItem {
|
|
|
23
23
|
hasArticleText?: boolean;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* A Form 4 a story about insiders trading reports: one filing's lines of the
|
|
28
|
+
* side the story reports, by an insider it names, dated in the period it names,
|
|
29
|
+
* summed as filed.
|
|
30
|
+
*/
|
|
31
|
+
export interface NewsInsiderFiling {
|
|
32
|
+
accession: string;
|
|
33
|
+
form: string;
|
|
34
|
+
/** YYYY-MM-DD. */
|
|
35
|
+
filedOn: string;
|
|
36
|
+
issuerName: string | null;
|
|
37
|
+
ticker: string | null;
|
|
38
|
+
/** The reporting owner as filed: "STEVENS MARK A". */
|
|
39
|
+
insider: string;
|
|
40
|
+
title: string | null;
|
|
41
|
+
side: "sale" | "purchase";
|
|
42
|
+
firstTradeDate: string;
|
|
43
|
+
lastTradeDate: string;
|
|
44
|
+
lines: number;
|
|
45
|
+
shares: number;
|
|
46
|
+
value: number;
|
|
47
|
+
weightedPrice: number;
|
|
48
|
+
rule10b51: boolean | null;
|
|
49
|
+
url: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
26
52
|
export interface NewsArticle {
|
|
27
53
|
id: string;
|
|
28
54
|
title: string;
|
|
@@ -44,6 +70,8 @@ export interface NewsArticle {
|
|
|
44
70
|
items?: NewsStoryItem[];
|
|
45
71
|
/** The routine notices the story stands for in a company's feed (a buy-back's daily notices), its own included. */
|
|
46
72
|
routine?: NewsRoutineNotices;
|
|
73
|
+
/** A story about insiders trading: the Form 4s it reports, as Gloom Cloud matched them. */
|
|
74
|
+
insiderFilings?: NewsInsiderFiling[];
|
|
47
75
|
/**
|
|
48
76
|
* The text this story was found by, when it stands in for a coin pair's feed
|
|
49
77
|
* no story is filed under: the stories that mention "bitcoin" for BTC-USD.
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The badge on the
|
|
3
|
-
* show one
|
|
4
|
-
* terminal and the web app have none, so nothing is set up for them.
|
|
2
|
+
* The unread badge on the macOS Dock icon or the browser tab. Hosts that
|
|
3
|
+
* cannot show one do not install a sink.
|
|
5
4
|
*/
|
|
6
5
|
export interface AppBadgeHost {
|
|
7
6
|
/** `""` clears the badge; otherwise the label from {@link appBadgeLabel}. */
|
|
@@ -41,6 +41,7 @@ interface CreateAppNotifierOptions {
|
|
|
41
41
|
isAppActive: () => boolean;
|
|
42
42
|
renderToast: (notification: AppNotificationRequest) => void;
|
|
43
43
|
desktop?: DesktopNotificationSink | null;
|
|
44
|
+
notifyInBackground?: (notification: AppNotificationRequest) => boolean;
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
function escapeAppleScriptString(value: string): string {
|
|
@@ -263,6 +264,7 @@ export function createAppNotifier({
|
|
|
263
264
|
isAppActive,
|
|
264
265
|
renderToast,
|
|
265
266
|
desktop = typeof Bun !== "undefined" ? createDesktopNotifier() : null,
|
|
267
|
+
notifyInBackground,
|
|
266
268
|
}: CreateAppNotifierOptions): AppNotifier {
|
|
267
269
|
return {
|
|
268
270
|
notify(request) {
|
|
@@ -298,6 +300,9 @@ export function createAppNotifier({
|
|
|
298
300
|
) {
|
|
299
301
|
desktopRequested = desktop ? desktop.notify(notification) !== false : false;
|
|
300
302
|
}
|
|
303
|
+
if (!appActive && notifyInBackground && (notification.browser || logged)) {
|
|
304
|
+
desktopRequested = notifyInBackground(notification) || desktopRequested;
|
|
305
|
+
}
|
|
301
306
|
|
|
302
307
|
return {
|
|
303
308
|
toastVisible: appActive && toastRendered,
|