gloomberb 0.20.0 → 0.20.1

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.
Files changed (86) hide show
  1. package/package.json +1 -1
  2. package/patches/electrobun-devkit@2.0.5.patch +268 -8
  3. package/src/api-client/crypto-markets.ts +20 -2
  4. package/src/api-client/fund-facts.ts +23 -1
  5. package/src/api-client/types/filings-and-calls.ts +6 -0
  6. package/src/app/runtime/plugin-seed.ts +119 -0
  7. package/src/app/runtime/startup.ts +45 -9
  8. package/src/app.tsx +1 -0
  9. package/src/cli/board-coins.ts +38 -5
  10. package/src/cli/commands/crypto-hints.ts +8 -1
  11. package/src/cli/commands/market.ts +29 -26
  12. package/src/cli/commands/overview.ts +13 -6
  13. package/src/cli/commands/ticker.ts +61 -14
  14. package/src/cli/company-name-hint.ts +19 -0
  15. package/src/cli/entry.ts +10 -4
  16. package/src/cli/glossary.ts +25 -0
  17. package/src/cli/helpers.ts +4 -2
  18. package/src/cli/not-a-ticker.ts +26 -1
  19. package/src/cli/pane-functions/freshness.ts +45 -29
  20. package/src/cli/pane-functions/market-session.ts +14 -5
  21. package/src/cli/restore-plugins.ts +164 -51
  22. package/src/components/chart-table/header.tsx +10 -1
  23. package/src/components/chart-table/layout.ts +14 -5
  24. package/src/components/command-bar/panel/index.tsx +13 -0
  25. package/src/components/command-bar/panel/layout.ts +7 -0
  26. package/src/components/command-bar/panel/runtime.ts +1 -0
  27. package/src/components/command-bar/panel/types.ts +2 -0
  28. package/src/i18n/es.ts +3 -0
  29. package/src/i18n/ja.ts +3 -0
  30. package/src/i18n/ko.ts +3 -0
  31. package/src/i18n/zh-cn.ts +3 -0
  32. package/src/i18n/zh-tw.ts +3 -0
  33. package/src/market-data/fund-facts.ts +7 -1
  34. package/src/market-data/market/change-basis.ts +20 -0
  35. package/src/market-data/market/format.ts +62 -2
  36. package/src/market-data/market/futures-week.ts +3 -1
  37. package/src/plugins/builtin/chart-composer/headless.ts +57 -17
  38. package/src/plugins/builtin/chart-composer/session-range.ts +82 -3
  39. package/src/plugins/builtin/correlation/compute.ts +8 -2
  40. package/src/plugins/builtin/correlation/headless.ts +10 -9
  41. package/src/plugins/builtin/correlation/history.ts +30 -0
  42. package/src/plugins/builtin/correlation/matrix/model.ts +10 -10
  43. package/src/plugins/builtin/correlation/relationship/model.ts +3 -6
  44. package/src/plugins/builtin/correlation/relationship/pane.tsx +1 -2
  45. package/src/plugins/builtin/crypto-board/client.ts +6 -1
  46. package/src/plugins/builtin/crypto-board/defi-view.tsx +12 -1
  47. package/src/plugins/builtin/crypto-board/defi.ts +44 -7
  48. package/src/plugins/builtin/crypto-board/headless.ts +83 -12
  49. package/src/plugins/builtin/crypto-board/model.ts +30 -6
  50. package/src/plugins/builtin/crypto-board/pane.tsx +13 -2
  51. package/src/plugins/builtin/perps/headless.ts +8 -2
  52. package/src/plugins/builtin/risk-factors/index.tsx +2 -28
  53. package/src/plugins/builtin/risk-factors/lock-note.ts +58 -0
  54. package/src/plugins/builtin/risk-factors/pane.tsx +10 -3
  55. package/src/plugins/builtin/scanner/hilo-model.ts +4 -3
  56. package/src/plugins/builtin/sec/fund-facts.ts +45 -11
  57. package/src/plugins/builtin/sec/headless.ts +30 -1
  58. package/src/plugins/builtin/sec/index.tsx +26 -5
  59. package/src/plugins/builtin/shared/pro-lock-note.ts +5 -1
  60. package/src/plugins/builtin/ticker-detail/overview/model.ts +14 -6
  61. package/src/plugins/builtin/time-sales/headless.ts +23 -7
  62. package/src/plugins/builtin/time-sales/index.tsx +2 -2
  63. package/src/plugins/extracted-plugins.ts +49 -24
  64. package/src/plugins/installer.ts +220 -31
  65. package/src/plugins/running-installs.ts +34 -0
  66. package/src/plugins/seed-progress.ts +72 -0
  67. package/src/renderers/electrobun/bun/desktop/backend.ts +14 -0
  68. package/src/renderers/electrobun/bun/desktop/host-requests.ts +14 -7
  69. package/src/renderers/electrobun/bun/desktop/initialization.ts +24 -14
  70. package/src/renderers/electrobun/bun/index.ts +5 -0
  71. package/src/renderers/electrobun/bun/window/context-menu-thread.ts +84 -0
  72. package/src/renderers/electrobun/bun/window/native-call-thread.ts +224 -0
  73. package/src/renderers/electrobun/bun/window/native-timing.ts +10 -0
  74. package/src/renderers/electrobun/bun/window/script-for-webview.ts +15 -0
  75. package/src/renderers/electrobun/bun/window/webview-script-thread.ts +82 -0
  76. package/src/renderers/electrobun/shared/protocol.ts +13 -2
  77. package/src/renderers/electrobun/view/backend-rpc.ts +7 -0
  78. package/src/renderers/electrobun/view/cli-pane-shot-frame.tsx +1 -1
  79. package/src/renderers/electrobun/view/main.tsx +4 -3
  80. package/src/renderers/opentui/start.tsx +3 -0
  81. package/src/telemetry/stall-reports.ts +21 -4
  82. package/src/utils/main-thread-stall.ts +21 -5
  83. package/src/utils/perf-marks.ts +88 -9
  84. package/src/utils/reported-money.ts +9 -2
  85. package/src/utils/sec.ts +34 -3
  86. package/src/plugins/seed-notice.ts +0 -20
package/src/i18n/zh-cn.ts CHANGED
@@ -1146,6 +1146,9 @@ export const zhCN: Record<string, string> = {
1146
1146
  "No figures for {symbol}: its sponsor's site is not one Gloom reads, and the SEC's prospectus and N-PORT data sets list none for it yet.": "暂无 {symbol} 的数据:Gloom 不读取其发起人的网站,SEC 的招募说明书和 N-PORT 数据集中也尚未列出。",
1147
1147
  "est. {range}": "估计 {range}",
1148
1148
  "Shares outstanding": "流通份额",
1149
+ "Management fee": "管理费",
1150
+ "Mgmt Fee": "管理费",
1151
+ "Units per {asset}": "每 {asset} 份额",
1149
1152
  "1M flows": "1个月资金流",
1150
1153
  "Structure": "结构",
1151
1154
  "Closed-end fund": "封闭式基金",
package/src/i18n/zh-tw.ts CHANGED
@@ -1146,6 +1146,9 @@ export const zhTW: Record<string, string> = {
1146
1146
  "No figures for {symbol}: its sponsor's site is not one Gloom reads, and the SEC's prospectus and N-PORT data sets list none for it yet.": "暫無 {symbol} 的數據:Gloom 不讀取其發起人的網站,SEC 的公開說明書與 N-PORT 資料集中也尚未列出。",
1147
1147
  "est. {range}": "估計 {range}",
1148
1148
  "Shares outstanding": "流通單位數",
1149
+ "Management fee": "管理費",
1150
+ "Mgmt Fee": "管理費",
1151
+ "Units per {asset}": "每 {asset} 單位數",
1149
1152
  "1M flows": "1個月資金流",
1150
1153
  "Structure": "結構",
1151
1154
  "Closed-end fund": "封閉式基金",
@@ -30,11 +30,17 @@ const sharesShape = (value: FundFactsPayload["sharesOutstanding"]) => value == n
30
30
  const flowsShape = (value: FundFlows | null | undefined) => value == null
31
31
  || (finite(value.shares) && (value.value === null || finite(value.value)) && typeof value.from === "string" && typeof value.asOf === "string");
32
32
 
33
+ /** Absent for any fund but a spot coin fund abroad; otherwise its coins and the units per coin, dated. */
34
+ const coinHoldingsShape = (value: FundFactsPayload["coinHoldings"]) => value == null
35
+ || ((value.asset === "BTC" || value.asset === "ETH") && finite(value.coins) && finite(value.unitsPerCoin) && value.unitsPerCoin > 0
36
+ && typeof value.asOf === "string" && typeof value.source === "string");
37
+
33
38
  export function validateFundFacts(data: FundFactsPayload): FundFactsPayload {
34
39
  if (!data || typeof data.ticker !== "string" || typeof data.covered !== "boolean"
35
40
  || ![data.expenseRatio, data.nav, data.premiumDiscount, data.netAssets, data.sponsor, data.inception, data.index].every(fact)
36
41
  || !estimateShape(data.nav) || !sharesShape(data.sharesOutstanding) || !flowsShape(data.flows)
37
- || !isBondFactsShape(data.bond) || !leverageShape(data.leverage) || !isMetalHoldingsShape(data.metalHoldings)) {
42
+ || !isBondFactsShape(data.bond) || !leverageShape(data.leverage) || !isMetalHoldingsShape(data.metalHoldings)
43
+ || !coinHoldingsShape(data.coinHoldings) || (data.currency !== undefined && typeof data.currency !== "string")) {
38
44
  throw new Error("Unreadable fund facts response");
39
45
  }
40
46
  return data;
@@ -233,6 +233,26 @@ export function quotePreviousCloseDate(quote: Quote | null | undefined): string
233
233
  return previousSession(quote, sessionDate)?.date ?? null;
234
234
  }
235
235
 
236
+ /**
237
+ * Whether the quote's print is older than what its move is measured from, so
238
+ * the move, labelled as of now, is not one: a coin whose last print is
239
+ * before today's 00:00 UTC (TUSD-USD's 29 Oct print read on 3 Nov, "0.00%
240
+ * since 00:00 UTC"), or a move over 24 hours whose print is older than that.
241
+ * A move from a dated close is measured from the print's own session, so it
242
+ * never is.
243
+ */
244
+ export function printPredatesChangeBasis(
245
+ quote: Pick<Quote, "lastUpdated"> | null | undefined,
246
+ basis: QuoteChangeBasis | null | undefined,
247
+ now = Date.now(),
248
+ ): boolean {
249
+ const printed = quote?.lastUpdated;
250
+ if (!basis || !isFiniteNumber(printed) || printed <= 0 || printed > now) return false;
251
+ if (basis.kind === "utc day") return printed < Math.floor(now / DAY_MS) * DAY_MS;
252
+ if (basis.kind === "24h") return printed < now - DAY_MS;
253
+ return false;
254
+ }
255
+
236
256
  /** `Fri 16 Oct`, with the year when it is not `now`'s. */
237
257
  function sessionDay(date: string, now: number): string {
238
258
  return formatUtcDayTime({ time: Date.parse(`${date}T00:00:00Z`), dateOnly: true }, now);
@@ -16,6 +16,13 @@ export interface AssetDisplayContext {
16
16
  multiplier?: number;
17
17
  priceBasis?: PriceBasis | null;
18
18
  quantityCurrency?: string;
19
+ /**
20
+ * The tick table the listing trades on, when its tick is finer than its
21
+ * currency's minor unit: `hkex-reduced`, the spread table Hong Kong's
22
+ * exchange traded products trade on (0.002 from 1 to 5, 0.005 from 5 to 10),
23
+ * whose prices under 10 print to three decimals (5.325, not 5.33).
24
+ */
25
+ listingTickTable?: "hkex-reduced";
19
26
  }
20
27
 
21
28
  export interface MarketFormatOptions extends AssetDisplayContext {
@@ -34,10 +41,28 @@ export interface MarketFormatOptions extends AssetDisplayContext {
34
41
  referencePrice?: number;
35
42
  }
36
43
 
44
+ /** Hong Kong's exchange traded products (ETFs, leveraged and inverse products) trade on its reduced spread table. */
45
+ const HKEX_REDUCED_SPREAD_TYPES = new Set(["ETF", "ETN", "ETP", "FUND"]);
46
+ const HKEX_VENUES = new Set(["HKEX", "HKG", "HKSE", "SEHK"]);
47
+
48
+ /** The tick table a quote's listing trades on, when its tick is finer than its currency's minor unit (see `listingTickTable`). */
49
+ function quoteListingTickTable(
50
+ quote: Partial<Pick<Quote, "instrumentType" | "exchangeName" | "listingExchangeName">> | null | undefined,
51
+ ): AssetDisplayContext["listingTickTable"] {
52
+ const venue = (quote?.listingExchangeName || quote?.exchangeName || "").trim().toUpperCase();
53
+ return HKEX_VENUES.has(venue) && HKEX_REDUCED_SPREAD_TYPES.has(normalizeType(quote?.instrumentType)) ? "hkex-reduced" : undefined;
54
+ }
55
+
56
+ /** The decimals a listing's tick asks for at a price, beyond its currency's; undefined when the currency's are enough. */
57
+ function listingTickDigits(table: AssetDisplayContext["listingTickTable"], price: number | undefined): number | undefined {
58
+ if (table !== "hkex-reduced" || price === undefined || !Number.isFinite(price)) return undefined;
59
+ return Math.abs(price) < 10 ? 3 : undefined;
60
+ }
61
+
37
62
  /** Current price fields use the quote's source metadata; stored cost/mark
38
63
  * conventions and independent history must not supply its missing basis. */
39
64
  export function quoteFormatOptions(
40
- quote: Pick<Quote, "instrumentType" | "priceBasis" | "providerPriceDivisor"> | null | undefined,
65
+ quote: (Pick<Quote, "instrumentType" | "priceBasis" | "providerPriceDivisor"> & Partial<Pick<Quote, "exchangeName" | "listingExchangeName">>) | null | undefined,
41
66
  fallbackAssetCategory?: string,
42
67
  metadataInstrumentType?: string,
43
68
  ): MarketFormatOptions {
@@ -45,13 +70,34 @@ export function quoteFormatOptions(
45
70
  // never turn a saved bond into a monetary quote or supply a par declaration.
46
71
  const fallback = metadataInstrumentType?.trim().toUpperCase() === "BOND" ? "BOND" : fallbackAssetCategory;
47
72
  const divisor = quote?.providerPriceDivisor;
73
+ const tickTable = quoteListingTickTable(quote);
48
74
  return {
49
75
  assetCategory: quote?.instrumentType?.trim() || fallback,
50
76
  priceBasis: quote?.priceBasis,
51
77
  ...(divisor != null && Number.isFinite(divisor) && divisor > 1 ? { quotedUnitDivisor: divisor } : {}),
78
+ ...(tickTable ? { listingTickTable: tickTable } : {}),
52
79
  };
53
80
  }
54
81
 
82
+ /** A hundredth of a cent, one basis point of a dollar peg: the decimals CRYP prints a stablecoin to. */
83
+ const NEAR_PAR_COIN_PRICE_DIGITS = 4;
84
+
85
+ /**
86
+ * The decimals a coin trading near a dollar prints to, a dollar stablecoin's
87
+ * 0.9989 and 1.0003 and a bond token's 0.9762, whatever digits its source sent
88
+ * (0.99886, 0.97619265): four either side of par, as CRYP prints them, so
89
+ * `quote`, `ticker` and `G` read one price. Undefined for any other price,
90
+ * which keeps its kind's own decimals (a sub-cent coin's eight).
91
+ */
92
+ export function nearParCoinPriceDigits(
93
+ quote: Pick<Quote, "instrumentType" | "currency" | "previousClose" | "price"> | null | undefined,
94
+ ): number | undefined {
95
+ if (!quote || resolveAssetDisplayKind({ assetCategory: quote.instrumentType }) !== "crypto") return undefined;
96
+ if ((quote.currency ?? "USD").trim().toUpperCase() !== "USD") return undefined;
97
+ const reference = [quote.previousClose, quote.price].find((value) => typeof value === "number" && Number.isFinite(value) && value > 0);
98
+ return reference != null && reference >= 0.9 && reference < 1.1 ? NEAR_PAR_COIN_PRICE_DIGITS : undefined;
99
+ }
100
+
55
101
  /** Decimals a sub-unit quote adds in the major unit: two for pence shown in pounds. */
56
102
  function quotedUnitFractionDigits(divisor: number | undefined): number {
57
103
  return divisor != null && Number.isFinite(divisor) && divisor > 1 ? Math.min(3, Math.round(Math.log10(divisor))) : 0;
@@ -368,6 +414,8 @@ export function formatMarketPrice(value: number | undefined, options: MarketForm
368
414
  ? getBasePriceMaxFractionDigits(kind, value, options.currency) + quotedUnitDigits
369
415
  : marketPriceFractionDigitCeiling(reference, options) + quotedUnitDigits;
370
416
  let digits = Math.max(0, Math.min(fixedFractionDigits, maxFractionDigits));
417
+ const tick = kind === "equity" || kind === "other" ? listingTickDigits(options.listingTickTable, reference ?? value) : undefined;
418
+ if (tick !== undefined) digits = Math.max(digits, tick);
371
419
  // A live price keeps its instrument's decimals, but a trade finer than the
372
420
  // session prices showed (a half-yen print after whole-yen closes) is not
373
421
  // rounded to a price that never traded.
@@ -377,9 +425,12 @@ export function formatMarketPrice(value: number | undefined, options: MarketForm
377
425
  ? fitted
378
426
  : scientificPrice(value, options.maxWidth);
379
427
  }
428
+ // A listing whose tick is finer than its currency's minor unit keeps the tick's decimals (an HKEX ETF's 5.325).
429
+ const tick = kind === "equity" || kind === "other" ? listingTickDigits(options.listingTickTable, value) : undefined;
380
430
  const minimumFractionDigits = Math.max(
381
431
  0,
382
432
  Math.min(options.minimumFractionDigits ?? 0, getBasePriceMaxFractionDigits(kind, value, options.currency)),
433
+ tick ?? 0,
383
434
  );
384
435
  const maxFractionDigits = Math.max(
385
436
  getPriceMaxFractionDigits(kind, value, options.priceRange, options.precisionOffset ?? 0, quotedUnitDigits, options.currency),
@@ -443,6 +494,13 @@ export function formatMarketChangeWithCurrency(
443
494
  ...options, minimumFractionDigits: Math.max(2, options.minimumFractionDigits ?? 0),
444
495
  })}`;
445
496
  }
497
+ // A move on a listing whose tick is finer than cents is written to the tick's decimals (+HK$0.030 on an HKEX ETF).
498
+ const tick = listingTickDigits(options.listingTickTable, referencePrice);
499
+ if (tick !== undefined && resolveAssetDisplayKind(options) !== "crypto") {
500
+ const rounded = Math.abs(value) < 0.5 * 10 ** -tick;
501
+ const body = formatMarketPriceWithCurrency(rounded ? 0 : Math.abs(value), currency, { ...options, minimumFractionDigits: tick });
502
+ return rounded ? body : `${value > 0 ? "+" : "-"}${body}`;
503
+ }
446
504
  // Cents hide the whole move of a sub-cent asset (-$0.00 for a SHIB day change).
447
505
  const unitDigits = currencyPriceDigits(currency);
448
506
  const smallestMove = 0.5 / 10 ** unitDigits;
@@ -551,7 +609,9 @@ export function stablePriceFractionDigits(context: StablePriceContext): number {
551
609
  } else if (kind === "equity" || kind === "other") {
552
610
  // A sub-unit price keeps four decimals of the major unit, pence lines
553
611
  // included; above one unit the currency's minor unit (and pence) apply.
554
- digits = below(1) ? 4 : currencyPriceMinDigits(context.currency) + unitDigits;
612
+ // A listing whose tick is finer than its currency's minor unit prints to the tick (an HKEX ETF's 5.325 and 0.676).
613
+ digits = listingTickDigits(context.listingTickTable, reference)
614
+ ?? (below(1) ? 4 : currencyPriceMinDigits(context.currency) + unitDigits);
555
615
  } else if (kind === "cash") {
556
616
  digits = below(10) ? 4 : 2;
557
617
  } else if (kind === "crypto") {
@@ -35,6 +35,8 @@ export interface FuturesWeekendClosure {
35
35
  closedAt: number;
36
36
  /** The Sunday open that ends it, when the venue's contracts all open then or later. */
37
37
  reopensAt?: number;
38
+ /** The zone that open is kept in, beside it. */
39
+ timeZone?: string;
38
40
  /** That open's local date, `YYYY-MM-DD` (always a Sunday). */
39
41
  reopensOn?: string;
40
42
  }
@@ -63,6 +65,6 @@ export function futuresWeekendClosure(exchange: string | undefined, time: number
63
65
  if (time < closedAt || time >= reopensAt) return null;
64
66
  return {
65
67
  closedAt,
66
- ...(venue.reopens ? { reopensAt, reopensOn: new Date((friday + 2) * MS_PER_DAY).toISOString().slice(0, 10) } : {}),
68
+ ...(venue.reopens ? { reopensAt, timeZone: WEEK_ZONE, reopensOn: new Date((friday + 2) * MS_PER_DAY).toISOString().slice(0, 10) } : {}),
67
69
  };
68
70
  }
@@ -23,7 +23,7 @@ import {
23
23
  } from "../../../time-series/resolution";
24
24
  import type { ChartResolution } from "../../../time-series/range";
25
25
  import { intradaySessionDates, intradaySessionTimeZone, loadIntradayWindow, resolveIntradayRequest, type IntradayRequest, type IntradayWindow, type LoadedIntradayWindow } from "./session-history";
26
- import { sessionRangeReport } from "./session-range";
26
+ import { sessionRangeReport, usBarCoverageNotice } from "./session-range";
27
27
  import { createSnapshotDataProvider, snapshotInstrumentKey, type SnapshotMarketData } from "../../../market-data/snapshot-provider";
28
28
  import type { InstrumentRef } from "../../../market-data/request-types";
29
29
  import type { HistorySession } from "../../../types/price-history";
@@ -32,15 +32,16 @@ import { chartQuoteOverrideKeyForTarget, getLiveChartQuoteTargets } from "../../
32
32
  import { createChartSeriesResolver } from "../../../capabilities";
33
33
  import { loadFuturesContractTerms, loadFuturesPriceUnit } from "../../../market-data/futures-contract";
34
34
  import { canonicalExchange, isKnownExchangeCode, isUsListingExchange, parsePublicTickerKey, publicTickerKey } from "../../../utils/exchanges";
35
- import { zonedDateTimeParts } from "../../../utils/zoned-date-time";
35
+ import { zonedDateKey, zonedDateTimeParts } from "../../../utils/zoned-date-time";
36
36
  import { futuresSessionOpenMinute } from "../../../market-data/market/trading-sessions";
37
37
  import { isAlwaysOpenExchange, isRegularSessionTime } from "../../../market-data/market/freshness";
38
38
  import { isRoundTheClockCoin } from "../../../utils/crypto-pair";
39
39
  import { isCurrencyPairListing } from "../../../utils/fx-market-hours";
40
40
  import { cleanFloat32Price, historyPriceDecimals } from "../../../cli/history-rows";
41
+ import { nearParCoinPriceDigits } from "../../../market-data/market/format";
41
42
  import { parseChartSpec } from "./chart-spec";
42
43
  import { paneSchemas } from "./headless-schema";
43
- import { barHistoryFreshness, DAILY_CLOSES, REPORTED_DATA } from "../shared/report-freshness";
44
+ import { barHistoryFreshness, DAILY_CLOSES, quoteObservation, REPORTED_DATA } from "../shared/report-freshness";
44
45
  import type { BarPeriodToDate } from "../../../market-data/market/bar-period";
45
46
  import { closedHistoryBarDay, formingHistoryBar } from "../ticker-detail/data-panes/history-bars";
46
47
  import { inferSeriesFrequency } from "../../../series/csv";
@@ -227,11 +228,14 @@ export async function loadChartPaneModel(
227
228
  source.instrument.symbol,
228
229
  ).map((row) => [row.date, row.growth])) : null;
229
230
  // A formula or a converted price prints at its legs' decimals in text; JSON keeps every digit.
231
+ // A coin's dollar price near par prints to four decimals, as `quote`, `ticker` and CRYP print it.
230
232
  const { valueDecimals, ...reported } = series;
233
+ const textDecimals = valueDecimals ?? (source?.kind === "security" && series.unitGroup === "price:USD"
234
+ ? nearParCoinPriceDigits(financials.get(snapshotInstrumentKey(source.instrument))?.quote) : undefined);
231
235
  return {
232
236
  ...reported,
233
237
  ...name ? { name } : {},
234
- ...valueDecimals !== undefined ? { textDecimals: valueDecimals } : {},
238
+ ...textDecimals !== undefined ? { textDecimals } : {},
235
239
  // A company's reported total (revenue, market cap) reads as 63.33B in the report, as in the legend and the tables.
236
240
  ...series.unitGroup.split(":")[0] === "currency-total" ? { textCompact: true } : {},
237
241
  derived: !ids.has(series.id),
@@ -350,8 +354,9 @@ function chartFreshness(
350
354
  allSeries: readonly HeadlessSeries[],
351
355
  spec: ChartSpec,
352
356
  comparison?: PriceComparison | null,
353
- quoteTimes: ReadonlyMap<string, number> = new Map(),
357
+ quotes: ReadonlyMap<string, Quote> = new Map(),
354
358
  ): HeadlessPaneFreshness {
359
+ const quoteTimes = new Map([...quotes].map(([id, quote]) => [id, quote.lastUpdated] as const));
355
360
  const order = ["1wk", "1mo"];
356
361
  // A leg that failed to load has no bars to date; the ones that loaded say what the chart is.
357
362
  const loaded = allSeries.filter((entry) => entry.points.length > 0);
@@ -382,6 +387,23 @@ function chartFreshness(
382
387
  return { status: "not-a-feed", basis: through ? `${basis} through ${periodDayText(through, new Date().getUTCFullYear())}` : basis,
383
388
  ...(through && closedDay ? { asOf: through } : {}), oldest: null };
384
389
  }
390
+ // Intraday bars of listings whose quotes carry them on are dated as their capture dates them: by those quotes,
391
+ // with their delay and where their markets stand (GIP: `Tue 3 Nov 2026 17:10 UTC · 15 min delayed`).
392
+ // Only a quote of the newest bar's trading date in the venue's zone carries them on: a session of the past
393
+ // (`--session 2026-10-01`, or yesterday's) is not what today's quote carries on.
394
+ const visibleSecurities = visible.filter((entry) => entry.source.kind === "security");
395
+ const carriedOn = (entry: ChartSeriesSpec) => {
396
+ const newest = series.find((item) => item.id === entry.id)?.points.at(-1)?.date;
397
+ const time = newest ? new Date(newest).getTime() : Number.NaN;
398
+ const quoted = quotes.get(entry.id)?.lastUpdated;
399
+ if (!Number.isFinite(time) || quoted == null || !Number.isFinite(quoted) || entry.source.kind !== "security") return false;
400
+ const zone = intradaySessionTimeZone(entry.source.instrument.symbol, entry.source.instrument.exchange);
401
+ return zonedDateKey(quoted, zone) === zonedDateKey(time, zone);
402
+ };
403
+ if (!["1d", "1wk", "1mo"].includes(coarsest!) && visibleSecurities.length === visible.length && visible.length > 0
404
+ && visibleSecurities.every(carriedOn)) {
405
+ return { prices: true, observations: visibleSecurities.map((entry) => ({ ...quoteObservation(quotes.get(entry.id)!) })) };
406
+ }
385
407
  const forming = formingPriceBar(series);
386
408
  // A history: its first bars are not stale data, so the line dates it by the bar still forming alone.
387
409
  if (forming) return { ...barHistoryFreshness(coarsest), periodToDate: forming, oldest: null };
@@ -439,8 +461,8 @@ function newestDailyPoint(series: readonly HeadlessSeries[], closedDay: string |
439
461
  }
440
462
 
441
463
  /** When each security series' listing was last quoted, by series id, from the quotes the chart was read with. */
442
- function chartQuoteTimes(model: Pick<ChartPaneModel, "spec" | "snapshot">): Map<string, number> {
443
- const times = new Map<string, number>();
464
+ function chartQuotes(model: Pick<ChartPaneModel, "spec" | "snapshot">): Map<string, Quote> {
465
+ const quotes = new Map<string, Quote>();
444
466
  for (const entry of model.spec.series) {
445
467
  if (entry.source.kind !== "security") continue;
446
468
  const { instrument } = entry.source;
@@ -449,9 +471,9 @@ function chartQuoteTimes(model: Pick<ChartPaneModel, "spec" | "snapshot">): Map<
449
471
  const data = model.snapshot.financials.find(([candidate]) => candidate === key)?.[1]
450
472
  ?? model.snapshot.instrumentFinancials?.find((item) => snapshotInstrumentKey(item.instrument) === instrumentKey)?.financials;
451
473
  const time = data?.quote?.lastUpdated;
452
- if (typeof time === "number" && Number.isFinite(time)) times.set(entry.id, time);
474
+ if (data?.quote && typeof time === "number" && Number.isFinite(time)) quotes.set(entry.id, data.quote);
453
475
  }
454
- return times;
476
+ return quotes;
455
477
  }
456
478
 
457
479
  /** A series' venue and the day its newest bar starts, as the forming and closed bar checks read them. */
@@ -777,6 +799,15 @@ export function chartHeadless(template: keyof typeof paneSchemas): HeadlessPaneD
777
799
  ...await loadIntradayWindow({ provider: context.marketData, symbol: target.symbol, exchange: target.exchange ?? "", request, context: { brokerId: target.brokerId, brokerInstanceId: target.brokerInstanceId, instrument: target.instrument } }),
778
800
  })));
779
801
  context.signal.throwIfAborted();
802
+ // One quote per listing, read once: it dates the footer as the capture dates the bars, decides a closed session's
803
+ // last bar, and answers the chart's metadata. A captured shot's source can have none.
804
+ await Promise.all(histories.map(async (history) => {
805
+ if (history.quote || !history.points.length || typeof context.marketData.getQuote !== "function") return;
806
+ const quote = await Promise.resolve(context.marketData.getQuote(history.symbol, history.exchange,
807
+ { brokerId: history.target.brokerId, brokerInstanceId: history.target.brokerInstanceId, instrument: history.target.instrument }))
808
+ .catch(logFailure("chart-composer.headless", "Read an intraday chart's quote failed", null));
809
+ if (quote) history.quote = quote;
810
+ }));
780
811
  // Once a session has closed, its last bar ends on the official close (the closing auction's print), as
781
812
  // `history` and CMP give it, not on the last trade before it; until the quote has that close, the footer says so.
782
813
  await Promise.all(histories.map(async (history) => {
@@ -791,11 +822,7 @@ export function chartHeadless(template: keyof typeof paneSchemas): HeadlessPaneD
791
822
  if (history.quote?.marketState === "REGULAR" || (known && isRegularSessionTime(known, now) === true)) return;
792
823
  if (known && !newestClosedSession(history.points, { venue: known, now })) return;
793
824
  // A captured shot's source can have no quotes: its bars are drawn as captured.
794
- const quote = history.quote ?? (typeof context.marketData.getQuote === "function"
795
- ? await Promise.resolve(context.marketData.getQuote(history.symbol, history.exchange,
796
- { brokerId: history.target.brokerId, brokerInstanceId: history.target.brokerInstanceId, instrument: history.target.instrument }))
797
- .catch(logFailure("chart-composer.headless", "Read the official close of an intraday chart failed", null))
798
- : null);
825
+ const quote = history.quote ?? null;
799
826
  const venue = known || quote?.listingExchangeName || quote?.exchangeName || undefined;
800
827
  const newest = newestClosedSession(history.points, { venue, now });
801
828
  const decided = newest ? newestSessionClose(quote, { ...newest, venue }) : null;
@@ -871,8 +898,10 @@ export function chartHeadless(template: keyof typeof paneSchemas): HeadlessPaneD
871
898
  if (template !== "graph-intraday-price-pane") model.series = model.series.map(barsAtSeriesPrecision);
872
899
  if (template === "graph-intraday-price-pane") {
873
900
  model.series = model.series.map(tradedBars);
874
- const regular = regularSessionNotice(intradayHistories.map((window) => ({ ...window, exchange: listingExchange(window.symbol, window.exchange) })));
875
- if (regular) model.metadata = { ...model.metadata, notices: [...(Array.isArray(model.metadata?.notices) ? model.metadata.notices : []), regular] };
901
+ const windows = intradayHistories.map((window) => ({ ...window, exchange: listingExchange(window.symbol, window.exchange) }));
902
+ // What the bars count, and the minutes of the session with no print that sets a price.
903
+ const notices = [regularSessionNotice(windows), usBarCoverageNotice(windows)].filter((notice): notice is string => !!notice);
904
+ if (notices.length) model.metadata = { ...model.metadata, notices: [...(Array.isArray(model.metadata?.notices) ? model.metadata.notices : []), ...notices] };
876
905
  }
877
906
  const dropped = chartResolutionDrop(
878
907
  parsed.viewport.resolution,
@@ -884,7 +913,18 @@ export function chartHeadless(template: keyof typeof paneSchemas): HeadlessPaneD
884
913
  model.warnings = [...model.warnings ?? [], dropped.warning];
885
914
  model.metadata = { ...model.metadata, resolution: dropped.drop };
886
915
  }
887
- model.freshness = chartFreshness(model.series, model.spec, model.chart.priceComparison, chartQuoteTimes(model));
916
+ const quotes = chartQuotes(model);
917
+ // GIP's bars are dated by the quote that carries them on, as its capture dates them: the one its window read.
918
+ if (template === "graph-intraday-price-pane") {
919
+ for (const entry of model.spec.series) {
920
+ if (entry.source.kind !== "security" || quotes.has(entry.id)) continue;
921
+ const { symbol, exchange } = entry.source.instrument;
922
+ const quote = intradayHistories.find((window) => window.quote && window.symbol.toUpperCase() === symbol.toUpperCase()
923
+ && (!exchange || !window.exchange || canonicalExchange(window.exchange) === canonicalExchange(exchange)))?.quote;
924
+ if (quote && Number.isFinite(quote.lastUpdated)) quotes.set(entry.id, quote);
925
+ }
926
+ }
927
+ model.freshness = chartFreshness(model.series, model.spec, model.chart.priceComparison, quotes);
888
928
  if (closingPrintsPending.length) {
889
929
  model.freshness = { ...model.freshness, note: [model.freshness.note, CLOSING_PRINT_PENDING_TEXT].filter(Boolean).join(", ") };
890
930
  }
@@ -2,9 +2,39 @@ import type { HeadlessPaneEntry } from "../../../types/headless";
2
2
  import type { PricePoint } from "../../../types/financials";
3
3
  import { cleanFloat32Price } from "../../../cli/history-rows";
4
4
  import { exportNumber } from "../../../cli/report-tables";
5
- import { publicTickerKey } from "../../../utils/exchanges";
5
+ import { isUsListingExchange, publicTickerKey } from "../../../utils/exchanges";
6
6
  import { formatUtcTime } from "../../../utils/utc-time";
7
7
  import { pricePointWicks } from "../../../utils/price-history-integrity";
8
+ import { futuresSessionOpenMinute } from "../../../market-data/market/trading-sessions";
9
+ import { getPublishedUsEquitySession } from "../../../market-data/published-us-sessions";
10
+ import { zonedDateKey, zonedDateTimeParts } from "../../../utils/zoned-date-time";
11
+
12
+ const NEW_YORK = "America/New_York";
13
+ const REGULAR_OPEN_MINUTE = 9 * 60 + 30;
14
+ const REGULAR_CLOSE_MINUTE = 16 * 60;
15
+
16
+ /** A US stock or fund line, whose day's range `quote` reads from its regular session; not a future on a US venue. */
17
+ function usStockLine(symbol: string, exchange: string): boolean {
18
+ return isUsListingExchange(exchange) && futuresSessionOpenMinute(symbol, exchange) == null;
19
+ }
20
+
21
+ /**
22
+ * The bars that start in a US regular session: from the venue's published
23
+ * open to its close, 13:00 New York on an early close (the day after
24
+ * Thanksgiving, Christmas Eve). A day the calendar does not publish is taken
25
+ * as 09:30 to 16:00.
26
+ */
27
+ function regularSessionBars<T extends Pick<PricePoint, "date">>(points: readonly T[], exchange: string): T[] {
28
+ return points.filter(({ date }) => {
29
+ const time = new Date(date).getTime();
30
+ if (!Number.isFinite(time)) return false;
31
+ const session = getPublishedUsEquitySession(exchange, zonedDateKey(time, NEW_YORK));
32
+ if (session?.kind === "session") return time >= session.open && time < session.close;
33
+ const { hour, minute } = zonedDateTimeParts(time, NEW_YORK);
34
+ const at = hour * 60 + minute;
35
+ return at >= REGULAR_OPEN_MINUTE && at < REGULAR_CLOSE_MINUTE;
36
+ });
37
+ }
8
38
 
9
39
  interface SessionExtreme {
10
40
  price: number;
@@ -49,6 +79,52 @@ interface SessionRangeWindow {
49
79
  quote?: { currency?: string } | null;
50
80
  }
51
81
 
82
+ /**
83
+ * What a US line's intraday bars count and how many of the regular session's
84
+ * spans had no bar: `Bars are of every US venue's prints that set a
85
+ * price; odd lots and special-condition prints count only in volume. 3 of 276
86
+ * minutes had none, so no bar.` Each session is counted from the 09:30 open to
87
+ * its close, or to its newest bar while it trades. Null for another venue.
88
+ */
89
+ export function usBarCoverageNotice(
90
+ windows: ReadonlyArray<SessionRangeWindow & { resolution?: string | null }>,
91
+ now = Date.now(),
92
+ ): string | null {
93
+ const counts = windows.flatMap((window) => {
94
+ const step = barStepMs(window.resolution);
95
+ if (!step || !usStockLine(window.symbol, window.exchange)) return [];
96
+ const bars = regularSessionBars(window.points, window.exchange).map(({ date }) => new Date(date).getTime());
97
+ if (!bars.length) return [];
98
+ let expected = 0;
99
+ let present = 0;
100
+ for (const date of new Set(bars.map((time) => zonedDateKey(time, NEW_YORK)))) {
101
+ const session = getPublishedUsEquitySession(window.exchange, date);
102
+ if (session?.kind !== "session") continue;
103
+ const starts = new Set(bars.filter((time) => time >= session.open && time < session.close));
104
+ // A session still trading is counted to its newest bar: the spans after it have not been served yet.
105
+ const through = now < session.close ? Math.max(...starts) : session.close - step;
106
+ for (let start = session.open; start <= through; start += step) {
107
+ expected++;
108
+ if (starts.has(start)) present++;
109
+ }
110
+ }
111
+ return expected ? [{ listing: publicTickerKey(window.symbol, window.exchange), missing: expected - present, expected, step }] : [];
112
+ });
113
+ if (!counts.length) return null;
114
+ const spans = (step: number, count: number) => step === 60_000 ? (count === 1 ? "minute" : "minutes")
115
+ : step % 3_600_000 === 0 ? `${step / 3_600_000}-hour ${count === 1 ? "span" : "spans"}` : `${step / 60_000}-minute ${count === 1 ? "span" : "spans"}`;
116
+ const each = counts.map(({ listing, missing, expected, step }) =>
117
+ `${counts.length > 1 ? `${listing}: ` : ""}${missing} of ${expected} ${spans(step, expected)} had none, so no bar.`);
118
+ return ["Bars are of every US venue's prints that set a price; odd lots and special-condition prints count only in volume.", ...each].join(" ");
119
+ }
120
+
121
+ /** A bar size as `1m`, `5m` or `1h` in milliseconds; null for a daily or longer one. */
122
+ function barStepMs(resolution: string | null | undefined): number | null {
123
+ const match = /^(\d+)(m|h)$/.exec(resolution ?? "");
124
+ if (!match) return null;
125
+ return Number(match[1]) * (match[2] === "h" ? 3_600_000 : 60_000);
126
+ }
127
+
52
128
  export interface SessionRangeReport {
53
129
  /** For the Statistics section: `USDT-USD:CCC session low 0.99833 at 2026-10-17 11:30 UTC`. */
54
130
  entries: HeadlessPaneEntry[];
@@ -63,10 +139,13 @@ export interface SessionRangeReport {
63
139
  export function sessionRangeReport(windows: readonly SessionRangeWindow[]): SessionRangeReport {
64
140
  const report: SessionRangeReport = { entries: [], ranges: [] };
65
141
  for (const window of windows) {
66
- const range = sessionRange(window.points);
142
+ // A US line's range is its regular session's, the rule `quote` reads the day's low and high by.
143
+ const regular = usStockLine(window.symbol, window.exchange);
144
+ const range = sessionRange(regular ? regularSessionBars(window.points, window.exchange) : window.points);
67
145
  if (!range) continue;
68
146
  const listing = publicTickerKey(window.symbol, window.exchange);
69
- const span = (window.sessionDates?.length ?? 1) > 1 ? "" : "session ";
147
+ const several = (window.sessionDates?.length ?? 1) > 1;
148
+ const span = regular ? (several ? "regular-hours " : "regular-session ") : several ? "" : "session ";
70
149
  const currency = window.quote?.currency?.trim();
71
150
  // As the bars export them: the decimal the feed's float stands for (85.1, not 85.099998).
72
151
  const low = cleanFloat32Price(exportNumber(range.low.price));
@@ -1,5 +1,6 @@
1
1
  import type { PricePoint } from "../../../types/financials";
2
2
  import { getPricePointTimestamp } from "../../../utils/price-history";
3
+ import { pricePointIntegrity } from "../../../utils/price-history-integrity";
3
4
 
4
5
  export interface CorrelationResult {
5
6
  correlation: number | null;
@@ -21,12 +22,17 @@ export interface DailyClose {
21
22
  */
22
23
  export type ChangeBasis = "return" | "difference";
23
24
 
24
- /** Keep the final valid close for each UTC trading date, in chronological order. */
25
+ /**
26
+ * Keep the final valid close for each UTC trading date, in chronological order.
27
+ * A bar whose prices contradict each other (a high under its open) is left out,
28
+ * as `history` leaves it blank: the series has a gap there, and the next return
29
+ * runs from the close before it, as across a holiday.
30
+ */
25
31
  export function dailyCloses(points: readonly PricePoint[]): DailyClose[] {
26
32
  const byDate = new Map<string, number>();
27
33
  for (const point of [...points].sort(comparePricePointsByDate)) {
28
34
  const dateKey = toDateKey(point);
29
- if (!dateKey || !Number.isFinite(point.close) || point.close <= 0) continue;
35
+ if (!dateKey || !Number.isFinite(point.close) || point.close <= 0 || pricePointIntegrity(point)) continue;
30
36
  byDate.set(dateKey, point.close);
31
37
  }
32
38
  return [...byDate].map(([dateKey, close]) => ({ dateKey, close }));
@@ -8,7 +8,7 @@ import { buildCorrelationMatrix, buildCorrelationSeries, buildGeoCorrelationSeri
8
8
  import { geoSeriesToken, loadGeoCorrelationHistory } from "./geo";
9
9
  import { buildRelationshipAnalysis, DEFAULT_RELATIONSHIP_SECOND_SYMBOL } from "./relationship/model";
10
10
  import { paneSchemas } from "./headless-schema";
11
- import { CORRELATION_RETURN_BASIS, GEO_CORRELATION_CHANGE_BASIS, loadCorrelationHistory, unfinishedBarFreshness } from "./history";
11
+ import { CORRELATION_RETURN_BASIS, GEO_CORRELATION_CHANGE_BASIS, loadCorrelationHistory, thinCorrelationNote, unfinishedBarFreshness } from "./history";
12
12
  import type { HeadlessPaneContext } from "../../../types/headless";
13
13
  import type { PricePoint } from "../../../types/financials";
14
14
  import { newestReportTime } from "../../../utils/utc-time";
@@ -70,9 +70,7 @@ export const correlationHeadless: HeadlessPaneDefinition<"rows"> = {
70
70
  if (!unavailableSymbols.length && rows.every((row) => row.correlation == null)) unavailableSymbols.push(...symbols);
71
71
  const unavailablePairs = rows.filter((row) => row.correlation == null).map((row) => ({
72
72
  left: row.left, right: row.right, sampleSize: row.sampleSize,
73
- reason: bySymbol.get(row.left as string)?.status === "invalid" || bySymbol.get(row.right as string)?.status === "invalid"
74
- ? "Inconsistent OHLC history"
75
- : row.sampleSize < 5 ? "Insufficient shared return observations" : "Zero return variance",
73
+ reason: row.sampleSize < 5 ? "Insufficient shared return observations" : "Zero return variance",
76
74
  }));
77
75
  const asOf = newestReportTime(symbols.map((symbol) => bySymbol.get(symbol)?.prices.at(-1)?.dateKey));
78
76
  return {
@@ -80,7 +78,13 @@ export const correlationHeadless: HeadlessPaneDefinition<"rows"> = {
80
78
  rows, unavailableSymbols,
81
79
  errors: [
82
80
  ...loaded.errors,
83
- ...unavailablePairs.map((pair) => `${pair.left}/${pair.right}: ${pair.reason} (${pair.sampleSize} shared observations).`),
81
+ // A thin pair says which side is short of daily bars; a pair with enough returns and no value has no variance.
82
+ ...rows.flatMap((row) => {
83
+ const closes = (symbol: string) => ({ label: symbol, closes: bySymbol.get(symbol)?.prices.length ?? 0 });
84
+ const thin = thinCorrelationNote(closes(row.left), closes(row.right), row.sampleSize, range);
85
+ if (thin) return [`${row.left}/${row.right}: ${thin}.`];
86
+ return row.correlation == null ? [`${row.left}/${row.right}: Zero return variance (${row.sampleSize} shared observations).`] : [];
87
+ }),
84
88
  ],
85
89
  metadata: {
86
90
  range,
@@ -116,8 +120,6 @@ export const relationshipHeadless: HeadlessPaneDefinition<"series"> = {
116
120
  const unavailableSymbols = symbols.filter((symbol) => (histories.get(symbol) ?? []).filter((point) => (
117
121
  Number.isFinite(point.close) && point.close > 0 && Number.isFinite(new Date(point.date).getTime())
118
122
  )).length < 2);
119
- if (analysis.integrity?.left.length) unavailableSymbols.push(symbols[0]!);
120
- if (analysis.integrity?.right.length) unavailableSymbols.push(symbols[1]!);
121
123
  if (!unavailableSymbols.length && !analysis.returns.length) unavailableSymbols.push(...symbols);
122
124
  const correlations = new Map(analysis.correlationPoints.map(({ date, close }) => [date.getTime(), close]));
123
125
  const regression = `${symbols[0]} on ${symbols[1]}`;
@@ -142,8 +144,7 @@ export const relationshipHeadless: HeadlessPaneDefinition<"series"> = {
142
144
  ],
143
145
  freshness: unfinishedBarFreshness([...histories.values()], analysis.aligned.at(-1)?.dateKey) ?? {},
144
146
  unavailableSymbols: [...new Set(unavailableSymbols)],
145
- errors: [...loaded.errors, ...(analysis.unavailableReason ? [analysis.unavailableReason] : []),
146
- ...(analysis.correlationUnavailableReason ? [analysis.correlationUnavailableReason] : [])],
147
+ errors: [...loaded.errors, ...(analysis.correlationUnavailableReason ? [analysis.correlationUnavailableReason] : [])],
147
148
  metadata: {
148
149
  left: symbols[0], right: symbols[1], range, correlationWindow,
149
150
  returnAlignment: CORRELATION_RETURN_BASIS,
@@ -38,6 +38,36 @@ export function unfinishedBarFreshness(
38
38
  return null;
39
39
  }
40
40
 
41
+ /** Below this many shared daily returns a correlation says why it has so few. */
42
+ const CORRELATION_EXPLAINED_RETURNS = 20;
43
+
44
+ interface CorrelationSide {
45
+ label: string;
46
+ /** Daily closes the side has in the range, contradictory bars left out. */
47
+ closes: number;
48
+ }
49
+
50
+ /**
51
+ * Why a pair has fewer than CORRELATION_EXPLAINED_RETURNS shared daily
52
+ * returns: the side with no daily bars in the range, or, when both have bars,
53
+ * how many each has. Null when there are enough.
54
+ */
55
+ export function thinCorrelationNote(left: CorrelationSide, right: CorrelationSide, returns: number, range: string): string | null {
56
+ if (returns >= CORRELATION_EXPLAINED_RETURNS) return null;
57
+ const empty = [...new Set([left, right].filter((side) => side.closes === 0).map((side) => side.label))];
58
+ if (empty.length > 0) return `${empty.join(" and ")} ${empty.length === 1 ? "has" : "have"} no daily bars in the ${range} range`;
59
+ const bars = (count: number) => `${count} daily ${count === 1 ? "bar" : "bars"}`;
60
+ const sides = left.label === right.label ? `${left.label} has ${bars(left.closes)}`
61
+ : `${left.label} has ${bars(left.closes)} and ${right.label} ${bars(right.closes)}`;
62
+ return `${sides} in the ${range} range; ${returns === 0 ? "no" : returns} daily ${returns === 1 ? "return falls" : "returns fall"} between dates both have`;
63
+ }
64
+
65
+ /** "3046:HKEX: 8 of 245 bars have contradictory prices in the source data; left out, as history leaves them blank", or null. */
66
+ export function contradictoryBarsNote(label: string, left: number, total: number): string | null {
67
+ if (left <= 0) return null;
68
+ return `${label}: ${left} of ${total} ${left === 1 && total === 1 ? "bar" : "bars"} ${left === 1 ? "has" : "have"} contradictory prices in the source data; left out, as history leaves them blank`;
69
+ }
70
+
41
71
  export const CORRELATION_RETURN_BASIS = "Local-price close-to-close returns between shared UTC dates; cash distributions and FX conversion are excluded, and exchange closing times may differ.";
42
72
 
43
73
  export const GEO_CORRELATION_CHANGE_BASIS = "Map series (GEO:) use the change in daily value between the same shared UTC dates, because counts such as transits can be zero.";