@gloom-sh/terminal 0.20.5 → 0.20.7

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 (185) hide show
  1. package/README.md +1 -1
  2. package/README.zh-CN.md +1 -1
  3. package/package.json +2 -1
  4. package/src/api-client/data.ts +10 -2
  5. package/src/api-client/fund-facts.ts +20 -4
  6. package/src/api-client/hk-tenders.ts +59 -0
  7. package/src/api-client/index.ts +1 -0
  8. package/src/api-client/socket.ts +4 -4
  9. package/src/api-client/types/econ.ts +20 -2
  10. package/src/app.tsx +18 -13
  11. package/src/architecture/floating-promise-allowlist.json +313 -0
  12. package/src/architecture/shortcut-labels-allowlist.json +1 -0
  13. package/src/cli/commands/market.ts +197 -57
  14. package/src/cli/commands/news-search.ts +22 -7
  15. package/src/cli/commands/overview.ts +12 -6
  16. package/src/cli/commands/search.ts +19 -3
  17. package/src/cli/commands/ticker.ts +3 -1
  18. package/src/cli/desktop-pane-shot.ts +61 -0
  19. package/src/cli/early-command.ts +2 -0
  20. package/src/cli/errors.ts +10 -1
  21. package/src/cli/fx-forward.ts +76 -12
  22. package/src/cli/fx-pair.ts +1 -1
  23. package/src/cli/fx-quote-rate.ts +23 -0
  24. package/src/cli/help.ts +1 -0
  25. package/src/cli/index-roots.ts +5 -4
  26. package/src/cli/index.ts +40 -3
  27. package/src/cli/known-gaps.ts +11 -8
  28. package/src/cli/listing-arg.ts +6 -4
  29. package/src/cli/options.ts +52 -3
  30. package/src/cli/output-file.ts +5 -3
  31. package/src/cli/pane-functions/catalog.ts +15 -0
  32. package/src/cli/pane-functions/dom.ts +4 -4
  33. package/src/cli/pane-functions/freshness.ts +38 -5
  34. package/src/cli/pane-functions/function-help.ts +4 -4
  35. package/src/cli/pane-functions/headless.ts +9 -4
  36. package/src/cli/pane-functions/index.ts +6 -4
  37. package/src/cli/pane-functions/resolver.ts +2 -2
  38. package/src/cli/pane-functions/screenshot-assessment.ts +16 -4
  39. package/src/cli/quote-answer.ts +57 -1
  40. package/src/cli/result.ts +38 -2
  41. package/src/cli/spreadsheet-hint.ts +7 -3
  42. package/src/cli/treasury-yields.ts +5 -3
  43. package/src/components/chart/composite/legend.tsx +40 -2
  44. package/src/components/command-bar/workflow/tickers.ts +2 -2
  45. package/src/components/data-table/view.tsx +9 -2
  46. package/src/components/ui/data-table/opentui/index.tsx +11 -4
  47. package/src/components/ui/data-table/opentui/model.ts +8 -6
  48. package/src/components/ui/data-table/types.ts +6 -1
  49. package/src/components/ui/table-layout.ts +38 -1
  50. package/src/docs/snapshot.json +58 -19
  51. package/src/i18n/es.ts +2 -0
  52. package/src/i18n/ja.ts +2 -0
  53. package/src/i18n/ko.ts +2 -0
  54. package/src/i18n/zh-cn.ts +2 -0
  55. package/src/i18n/zh-tw.ts +2 -0
  56. package/src/market-data/market/change-basis.ts +57 -12
  57. package/src/market-data/market/dated-previous-close.ts +184 -10
  58. package/src/market-data/market/freshness.ts +18 -6
  59. package/src/market-data/market/status.ts +9 -1
  60. package/src/market-data/published-nse-sessions.ts +16 -1
  61. package/src/market-data/quotes/contributions.ts +2 -0
  62. package/src/market-data/quotes/freshness.ts +15 -0
  63. package/src/market-data/quotes/listing-enterprise-value.ts +50 -0
  64. package/src/plugins/builtin/alerts/alert-engine.ts +15 -0
  65. package/src/plugins/builtin/alerts/cli.ts +22 -9
  66. package/src/plugins/builtin/alerts/headless.ts +1 -1
  67. package/src/plugins/builtin/alerts/index.tsx +5 -1
  68. package/src/plugins/builtin/alerts/metric-command.ts +1 -1
  69. package/src/plugins/builtin/alerts/metric-data.ts +15 -2
  70. package/src/plugins/builtin/backtest/headless.ts +1 -1
  71. package/src/plugins/builtin/cds/model.ts +0 -6
  72. package/src/plugins/builtin/chart-composer/formula.ts +16 -3
  73. package/src/plugins/builtin/chart-composer/headless-schema.ts +2 -0
  74. package/src/plugins/builtin/chart-composer/headless.ts +2 -1
  75. package/src/plugins/builtin/chart-composer/presets.ts +1 -0
  76. package/src/plugins/builtin/cloud/askg/pane.tsx +55 -13
  77. package/src/plugins/builtin/credit-boards/cdx-pane.tsx +20 -7
  78. package/src/plugins/builtin/credit-boards/client.ts +8 -0
  79. package/src/plugins/builtin/credit-boards/headless.ts +4 -1
  80. package/src/plugins/builtin/credit-boards/model.ts +58 -4
  81. package/src/plugins/builtin/credit-boards/series.ts +63 -6
  82. package/src/plugins/builtin/credit-boards/sovr-pane.tsx +3 -2
  83. package/src/plugins/builtin/credit-conditions/headless.ts +24 -6
  84. package/src/plugins/builtin/credit-conditions/index.tsx +1 -1
  85. package/src/plugins/builtin/credit-conditions/model.ts +12 -6
  86. package/src/plugins/builtin/credit-conditions/series.ts +2 -1
  87. package/src/plugins/builtin/econ/calendar-model.ts +41 -7
  88. package/src/plugins/builtin/econ/calendar-source.ts +7 -1
  89. package/src/plugins/builtin/econ/index.tsx +41 -8
  90. package/src/plugins/builtin/econ/types.ts +3 -0
  91. package/src/plugins/builtin/fixed-income/index.tsx +2 -0
  92. package/src/plugins/builtin/fx-matrix/index.tsx +44 -14
  93. package/src/plugins/builtin/help/keybindings-editor.tsx +6 -2
  94. package/src/plugins/builtin/holders/fund-holders.ts +22 -1
  95. package/src/plugins/builtin/holders/headless.ts +5 -4
  96. package/src/plugins/builtin/holders/pane.tsx +7 -3
  97. package/src/plugins/builtin/holders/report-header.ts +23 -0
  98. package/src/plugins/builtin/members/client.ts +1 -1
  99. package/src/plugins/builtin/members/headless.ts +2 -0
  100. package/src/plugins/builtin/members/model.ts +10 -8
  101. package/src/plugins/builtin/members/pane.tsx +4 -1
  102. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +5 -2
  103. package/src/plugins/builtin/portfolio-list/cli/render.ts +86 -26
  104. package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +5 -1
  105. package/src/plugins/builtin/portfolio-list/headless.ts +2 -1
  106. package/src/plugins/builtin/portfolio-list/income.ts +46 -22
  107. package/src/plugins/builtin/portfolio-list/pane/data.ts +16 -6
  108. package/src/plugins/builtin/portfolio-list/pane/index.tsx +5 -4
  109. package/src/plugins/builtin/portfolio-list/use-throttled-ticker-order.ts +40 -3
  110. package/src/plugins/builtin/research/headless-schema.ts +4 -3
  111. package/src/plugins/builtin/research/relative-valuation-columns.ts +145 -47
  112. package/src/plugins/builtin/research/relative-valuation-currency.ts +31 -0
  113. package/src/plugins/builtin/research/relative-valuation-headless.ts +25 -8
  114. package/src/plugins/builtin/research/relative-valuation-model.ts +40 -9
  115. package/src/plugins/builtin/research/relative-valuation-pane.tsx +3 -2
  116. package/src/plugins/builtin/research/relative-valuation-peers.ts +2 -2
  117. package/src/plugins/builtin/sec/fund-facts.ts +25 -5
  118. package/src/plugins/builtin/shared/report-freshness.ts +15 -6
  119. package/src/plugins/builtin/supply-chain/model.ts +18 -6
  120. package/src/plugins/builtin/thirteenf/api.ts +47 -4
  121. package/src/plugins/builtin/ticker-detail/data-panes/historical-prices.tsx +8 -7
  122. package/src/plugins/builtin/ticker-detail/data-panes/history-bars.ts +8 -5
  123. package/src/plugins/builtin/ticker-detail/financials/model.ts +6 -2
  124. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +1 -1
  125. package/src/plugins/builtin/ticker-detail/headless.ts +6 -4
  126. package/src/plugins/builtin/treasury-auctions/cache.ts +36 -2
  127. package/src/plugins/builtin/treasury-auctions/headless.ts +42 -4
  128. package/src/plugins/builtin/treasury-auctions/hk-headless.ts +126 -0
  129. package/src/plugins/builtin/treasury-auctions/hk-view.tsx +347 -0
  130. package/src/plugins/builtin/treasury-auctions/hk.ts +363 -0
  131. package/src/plugins/builtin/treasury-auctions/index.tsx +14 -1
  132. package/src/plugins/builtin/treasury-auctions/model.ts +16 -8
  133. package/src/plugins/builtin/treasury-auctions/pane.tsx +45 -21
  134. package/src/portfolio/collection-name.ts +22 -0
  135. package/src/portfolio/column-values.ts +3 -0
  136. package/src/portfolio/valuation-basis.ts +23 -1
  137. package/src/renderers/dom/data-table/frozen-column.ts +3 -1
  138. package/src/renderers/dom/data-table/index.tsx +27 -9
  139. package/src/renderers/dom/data-table/row.tsx +2 -0
  140. package/src/renderers/electrobun/bun/desktop/backend.ts +27 -24
  141. package/src/renderers/electrobun/bun/desktop/detached-windows.ts +3 -3
  142. package/src/renderers/electrobun/bun/desktop/snapshot-commit.ts +77 -0
  143. package/src/renderers/electrobun/shared/protocol.ts +4 -0
  144. package/src/renderers/electrobun/view/backend-rpc.ts +3 -0
  145. package/src/renderers/electrobun/view/desktop/window/bridge.ts +3 -0
  146. package/src/sources/gloomberb-cloud/normalizers.ts +9 -5
  147. package/src/sources/provider-router/cache.ts +3 -1
  148. package/src/state/hooks/quote-streaming.ts +14 -6
  149. package/src/sync/controller.ts +17 -2
  150. package/src/sync/other-window-tabs.ts +32 -1
  151. package/src/sync/react.ts +4 -4
  152. package/src/tickers/instrument-kind.ts +22 -1
  153. package/src/tickers/search/index.ts +5 -0
  154. package/src/tickers/terminal-codes.ts +17 -5
  155. package/src/time-series/bar-spacing.ts +33 -0
  156. package/src/time-series/base-series.ts +21 -3
  157. package/src/time-series/chart-bounds.ts +31 -0
  158. package/src/time-series/field-catalog.ts +17 -0
  159. package/src/time-series/fundamentals/current-valuation.ts +244 -0
  160. package/src/time-series/fundamentals/historical-valuation.ts +99 -0
  161. package/src/time-series/fundamentals/metric-ids.ts +61 -0
  162. package/src/time-series/fundamentals/period-points.ts +104 -0
  163. package/src/time-series/fundamentals/quarterly-ttm.ts +220 -0
  164. package/src/time-series/fundamentals/series.ts +164 -0
  165. package/src/time-series/fundamentals/source-statements.ts +177 -0
  166. package/src/time-series/fundamentals/statement-fields.ts +154 -0
  167. package/src/time-series/fundamentals/statement-merge.ts +124 -0
  168. package/src/time-series/fundamentals/statement.ts +114 -0
  169. package/src/time-series/fundamentals/valuation-multiples.ts +50 -0
  170. package/src/time-series/fundamentals.ts +18 -1275
  171. package/src/time-series/ice-credit.ts +32 -6
  172. package/src/time-series/resolve.ts +9 -5
  173. package/src/time-series/session-bar.ts +78 -9
  174. package/src/time-series/studies/formula.ts +53 -10
  175. package/src/time-series/studies/pair.ts +18 -7
  176. package/src/time-series/studies/units.ts +49 -2
  177. package/src/time-series/types.ts +12 -0
  178. package/src/types/desktop-window.ts +2 -0
  179. package/src/types/financials.ts +15 -0
  180. package/src/types/headless.ts +8 -0
  181. package/src/utils/cli-output.ts +6 -3
  182. package/src/utils/debug-log.ts +29 -0
  183. package/src/utils/ebitda.ts +128 -0
  184. package/src/utils/format.ts +1 -1
  185. package/src/utils/shell-word.ts +13 -0
@@ -1,6 +1,7 @@
1
1
  import { logFailure } from "../../../../utils/log-failure";
2
2
  import { createBaseConverter, type BaseConversion } from "../../../../cli/base-converter";
3
3
  import { quotedFxPair } from "../../../../utils/currency-pair";
4
+ import { commandWord } from "../../../../utils/shell-word";
4
5
  import { formatFxRate } from "../../../../cli/fx-pair";
5
6
  import { savedListingName } from "../../../../cli/listing-arg";
6
7
  import { currentListingName } from "../../../../tickers/listing-name";
@@ -22,6 +23,7 @@ import {
22
23
  getPortfolioValuationTime,
23
24
  valuationBasisLabel,
24
25
  valuationTimeIso,
26
+ valuesAtNominalPrice,
25
27
  valuesAtSettlement,
26
28
  type PortfolioValuationBasis,
27
29
  } from "../../../../portfolio/valuation-basis";
@@ -54,7 +56,7 @@ import type { DataProvider } from "../../../../types/data-provider";
54
56
  import type { CliCommandContext } from "../../../../types/plugin";
55
57
  import type { MarketContext } from "../../../../cli/types";
56
58
  import type { Portfolio, TickerPosition, TickerRecord } from "../../../../types/ticker";
57
- import type { TickerFinancials } from "../../../../types/financials";
59
+ import type { Quote, TickerFinancials } from "../../../../types/financials";
58
60
  import type { TickerInstrumentKind } from "../../../../types/instrument";
59
61
  import { resolveTickerInstrumentKind } from "../../../../tickers/instrument-kind";
60
62
  import { perpetualListing } from "../../../../tickers/perpetual-listing";
@@ -87,7 +89,7 @@ import {
87
89
  } from "../../../../portfolio/allocation";
88
90
  import { findCachedPortfolioAccount } from "../cached-account";
89
91
  import { importedFromText } from "../imported-from";
90
- import { findNamedCollection } from "../../../../portfolio/collection-name";
92
+ import { findNamedCollection, watchlistMemberSymbol } from "../../../../portfolio/collection-name";
91
93
  import { isoDateToday } from "../../../../utils/calendar-date";
92
94
  import { lastTradeDate } from "../../../../tickers/listing-fate";
93
95
  import type { PriceWindow } from "../../../../utils/price-window";
@@ -194,10 +196,25 @@ export function renderCollectionOverview(config: AppConfig, tickers: TickerRecor
194
196
  ]),
195
197
  ));
196
198
  }
199
+ // Nothing in any of them: the commands that fill one, as `alerts` names the one that adds an alert.
200
+ const empty = [
201
+ ...config.portfolios.map((portfolio) => countCollectionTickers(tickers, "portfolios", portfolio.id)),
202
+ ...config.watchlists.map((watchlist) => countCollectionTickers(tickers, "watchlists", watchlist.id)),
203
+ ].every((count) => count === 0);
204
+ const adds = [
205
+ config.portfolios[0] ? collectionAddCommand("portfolio", config.portfolios[0].name) : null,
206
+ config.watchlists[0] ? collectionAddCommand("watchlist", config.watchlists[0].name) : null,
207
+ ].filter((command): command is string => command != null);
208
+ if (empty && adds.length > 0) blocks.push("", cliStyles.muted(`No tickers yet. Add some with ${adds.join(" or ")}.`));
197
209
 
198
210
  return blocks.join("\n");
199
211
  }
200
212
 
213
+ /** `gloom watchlist add Watchlist AAPL MSFT`: the command that adds tickers to a collection, its name quoted for any shell. */
214
+ export function collectionAddCommand(kind: "portfolio" | "watchlist", name: string): string {
215
+ return `gloom ${kind} add ${commandWord(name)} AAPL MSFT`;
216
+ }
217
+
201
218
  export interface ShowCollectionOptions {
202
219
  /** `--explain`: follow the report with what the terms it shows mean, as `fn <function> --explain` does. */
203
220
  explain?: boolean;
@@ -219,8 +236,15 @@ export interface ShowCollectionOptions {
219
236
  cpi?: Parameters<typeof showPeriodPnl>[0]["cpi"];
220
237
  }
221
238
 
222
- export async function showCollection(name: string, ctx: CliCommandContext, options: ShowCollectionOptions = {}) {
223
- await withMarketData(ctx, (context) => showCollectionWithMarketData(name, ctx, context, options));
239
+ /**
240
+ * Prints a portfolio or watchlist. `readsLeftBehind` says reads it stopped
241
+ * waiting for (dividends past their deadline) are still out, which a CLI
242
+ * process need not wait for once the report is out.
243
+ */
244
+ export async function showCollection(name: string, ctx: CliCommandContext, options: ShowCollectionOptions = {}): Promise<{ readsLeftBehind: boolean }> {
245
+ const outcome = { readsLeftBehind: false };
246
+ await withMarketData(ctx, (context) => showCollectionWithMarketData(name, ctx, context, options, outcome));
247
+ return outcome;
224
248
  }
225
249
 
226
250
  /** What `--explain` names a report by when it shows no terms. */
@@ -348,8 +372,12 @@ interface PortfolioValuationFields {
348
372
  valuationPrice: number | null;
349
373
  /** An ISO instant in UTC, or an ISO date for a close whose hour the venue's calendar does not give. */
350
374
  valuationAsOf: string | null;
351
- /** Only on a future valued at its exchange settlement, which `valuationAsOf` dates by its session. */
352
- valuationPriceKind?: "settle";
375
+ /**
376
+ * Only on a future valued at its exchange settlement, which `valuationAsOf`
377
+ * dates by its session, and on a holding at its venue's nominal price,
378
+ * nothing having traded, dated by the session it is that price for.
379
+ */
380
+ valuationPriceKind?: PortfolioValuationPriceKind;
353
381
  }
354
382
 
355
383
  export interface PortfolioValuation {
@@ -483,7 +511,7 @@ export async function valuePortfolioPositions({
483
511
  values.push({ ticker, quote, activeQuote, headline, extended, position: null, metrics: null, pnl: null, dayMove: null, futures: futuresTerms,
484
512
  valuation: { valuationBasis: basis, valuationPrice: known(priced?.price),
485
513
  valuationAsOf: settledHeadline ? futuresTerms!.settlement!.date : valuationTimeIso(getPortfolioValuationTime(quote, basis)),
486
- ...(settledHeadline ? { valuationPriceKind: "settle" as const } : {}) },
514
+ ...(settledHeadline ? { valuationPriceKind: "settle" as const } : valuesAtNominalPrice(quote, null, basis) ? { valuationPriceKind: "nominal" as const } : {}) },
487
515
  row: { symbol: ticker.metadata.ticker, ...listingColumns(ticker, quote), exchange: ticker.metadata.exchange, shares: null, avgCost: null,
488
516
  positionCurrency: null, quotePrice: known(headline?.price), ...quoteMoveColumns(headline), ...extendedQuoteFields(extended), quoteCurrency: quote?.currency ?? null,
489
517
  volume: known(quote?.volume), costBasis: null, marketValue: null, unrealizedPnl: null, baseCurrency: currency } });
@@ -530,7 +558,8 @@ export async function valuePortfolioPositions({
530
558
  holding.marketValue = holding.marketValue == null || marketValue == null ? null : holding.marketValue + marketValue;
531
559
  holding.units += metrics.totalShares;
532
560
  holding.unitPrice ??= valuationQuote ? known(await toBase(valuationQuote.price, quoteCurrency)) : null;
533
- const change = valuationQuote?.change;
561
+ // A listing that no longer trades does not move, as the pane's Day counts it: its last session's change is not today's.
562
+ const change = quote?.delisting ? 0 : valuationQuote?.change;
534
563
  const dayMove = valuationQuote && change != null && Number.isFinite(change)
535
564
  ? { change: await toBase(metrics.totalPriceUnits * change, quoteCurrency),
536
565
  previousValue: await toBase(metrics.grossPriceUnits * (valuationQuote.price - change), quoteCurrency) }
@@ -539,7 +568,8 @@ export async function valuePortfolioPositions({
539
568
  dayMove: dayMove && Number.isFinite(dayMove.change) && Number.isFinite(dayMove.previousValue) ? dayMove : null,
540
569
  valuation: { valuationBasis: basis, valuationPrice: known(valuationQuote?.price),
541
570
  valuationAsOf: valuationTimeIso(getPortfolioValuationTime(quote, basis, metrics, settlement)),
542
- ...(atSettlement && settlement ? { valuationPriceKind: "settle" as const } : {}) },
571
+ ...(atSettlement && settlement ? { valuationPriceKind: "settle" as const }
572
+ : valuesAtNominalPrice(quote, metrics, basis) ? { valuationPriceKind: "nominal" as const } : {}) },
543
573
  row: { symbol: ticker.metadata.ticker, ...listingColumns(ticker, quote), exchange: ticker.metadata.exchange,
544
574
  shares: metrics.totalShares, avgCost: known(position.avgCost), positionCurrency,
545
575
  priceBasis: position.priceBasis ?? null, quantityUnit: metrics.priceBasis === "percent-of-par" ? "face" : null, quotePriceBasis: quote?.priceBasis ?? null,
@@ -548,7 +578,9 @@ export async function valuePortfolioPositions({
548
578
  volume: known(quote?.volume), quoteAsOf: quote ? quoteHeadlineTime(quote) : null,
549
579
  costBasis: known(direction * costBasisBase), marketValue,
550
580
  unrealizedPnl: known(pnl), baseCurrency: currency, dateAcquired: position.dateAcquired ?? null,
551
- pnlBasis: selectedPnl.basis, brokerUnrealizedPnl: known(position.unrealizedPnl), brokerPnlCurrency: positionCurrency, brokerPnlAsOf: null } });
581
+ pnlBasis: selectedPnl.basis, brokerUnrealizedPnl: known(position.unrealizedPnl), brokerPnlCurrency: positionCurrency, brokerPnlAsOf: null,
582
+ // Only at a nominal price: `quoteAsOf` is the last print, older than the session that price is for.
583
+ ...quotePriceKindField(quote) } });
552
584
  }
553
585
  }
554
586
 
@@ -561,22 +593,25 @@ export async function valuePortfolioPositions({
561
593
  * The holdings' move over the day of the prices they are valued at, in the
562
594
  * portfolio's currency, and that move against their value at the close
563
595
  * before, with what it is measured from as the pane's Day says it ("vs Fri 16
564
- * Oct close", "vs mixed closes"). Null when any priced holding's move is
565
- * unknown, as the pane's Day is.
596
+ * Oct close", "vs mixed closes"): at the latest print, the move of that print,
597
+ * a pre-market or after-hours one included; at the close, the regular
598
+ * session's. A listing that no longer trades counts as no move and names no
599
+ * basis. Null when any priced holding's move is unknown, as the pane's Day is.
566
600
  */
567
601
  export function portfolioDayMove(
568
- valuation: Pick<PortfolioValuation, "positions">,
602
+ valuation: Pick<PortfolioValuation, "positions" | "basis">,
569
603
  now = Date.now(),
570
604
  ): { change: number; changePercent: number | null; basis: string | null } | null {
571
605
  let change = 0;
572
606
  let previousValue = 0;
573
607
  const bases: Array<QuoteChangeBasis | null> = [];
608
+ const session = valuation.basis === "regular-close" ? "regular" : "active";
574
609
  for (const entry of valuation.positions) {
575
610
  if (!entry.position) continue;
576
611
  if (!entry.dayMove) return null;
577
612
  change += entry.dayMove.change;
578
613
  previousValue += entry.dayMove.previousValue;
579
- bases.push(quoteChangeBasis(entry.quote, { terms: entry.futures }));
614
+ if (!entry.quote?.delisting) bases.push(quoteChangeBasis(entry.quote, { session, terms: entry.futures }));
580
615
  }
581
616
  return {
582
617
  change,
@@ -749,6 +784,8 @@ function portfolioValuationFreshness(
749
784
  source,
750
785
  observedKey: "valuationAsOf",
751
786
  citeOldest: true,
787
+ // A book across markets names each one's session and open: an HKEX book holding one US fund is not dated by the US day alone.
788
+ datesEachVenue: true,
752
789
  ...(note ? { note: `priced at ${valuationBasisLabel(valuation.basis, { futures: holdsFutures(valuation) })}` } : {}),
753
790
  }, undefined, now);
754
791
  }
@@ -763,12 +800,21 @@ function valuationBasisLine(basis: PortfolioValuationBasis, futures: boolean): s
763
800
  return `Priced at ${valuationBasisLabel(basis, { futures })}`;
764
801
  }
765
802
 
803
+ /** What a row's price is when it is not a print or a close: a future's settlement, or a venue's nominal price. */
804
+ export type PortfolioValuationPriceKind = "settle" | "nominal";
805
+
806
+ /** `quotePriceKind: "nominal"` for a quote at its venue's nominal price (Quote.nominalPrice); nothing for any other. */
807
+ function quotePriceKindField(quote: Quote | null | undefined): { quotePriceKind?: "nominal" } {
808
+ return quote?.nominalPrice ? { quotePriceKind: "nominal" } : {};
809
+ }
810
+
766
811
  /**
767
812
  * An As of cell: when the price a row's value uses is from (`valuationAsOf`),
768
- * in UTC as its header says; a close dated only by its day says so, and a
769
- * future's settlement names its session.
813
+ * in UTC as its header says; a close dated only by its day says so, a
814
+ * future's settlement names its session, and a nominal price the session it
815
+ * is the venue's price for (`Fri 6 Nov nominal`).
770
816
  */
771
- export function valuationTimeText(value: unknown, now = Date.now(), kind?: "settle"): string {
817
+ export function valuationTimeText(value: unknown, now = Date.now(), kind?: PortfolioValuationPriceKind): string {
772
818
  const time = parseReportTime(value);
773
819
  if (!time) return "—";
774
820
  return time.dateOnly ? `${formatUtcDayTime(time, now)} ${kind ?? "close"}` : formatUtcDayTime(time, now);
@@ -792,6 +838,7 @@ async function showCollectionWithMarketData(
792
838
  ctx: CliCommandContext,
793
839
  { config, store, dataProvider, persistence }: MarketContext,
794
840
  { explain = false, basis = "latest-print", drip, dividendDeadlineMs = DIVIDEND_READ_DEADLINE_MS, futuresSources, costFxHistory = apiClient, period, real = false, cpi }: ShowCollectionOptions,
841
+ outcome: { readsLeftBehind: boolean } = { readsLeftBehind: false },
795
842
  ) {
796
843
  const tickers = (await store.loadAllTickers()).sort((left, right) =>
797
844
  left.metadata.ticker.localeCompare(right.metadata.ticker)
@@ -830,7 +877,7 @@ async function showCollectionWithMarketData(
830
877
 
831
878
  if (filtered.length === 0 && !structured && !hasCash) {
832
879
  console.log(cliStyles.bold(displayName));
833
- console.log(cliStyles.muted("No tickers in this collection."));
880
+ console.log(cliStyles.muted(`No tickers in this ${isPortfolio ? "portfolio" : "watchlist"}. Add some with ${collectionAddCommand(isPortfolio ? "portfolio" : "watchlist", displayName)}.`));
834
881
  if (explain) console.log(`\n${renderReportGlossary(EXPLAINED_REPORT, [])}`);
835
882
  return;
836
883
  }
@@ -839,8 +886,15 @@ async function showCollectionWithMarketData(
839
886
 
840
887
  const futuresHeld = filtered.filter((ticker) => isFuturesTicker(ticker)
841
888
  && ticker.metadata.positions.some((position) => position.portfolio === id && position.shares !== 0));
889
+ // A book says what its day's move is from on either basis, so its quotes' previous closes are dated.
890
+ const quotesRead = loadCollectionQuotes(filtered, collection, dataProvider, { datesChangeBasis: isPortfolio });
891
+ // What each holding pays a year is read beside its quote, under one deadline from here.
892
+ const dividendsRead = matchedPortfolio && !period
893
+ ? loadHoldingDividends(filtered.filter((ticker) => ticker.metadata.positions.some((position) => position.portfolio === id && position.shares !== 0)),
894
+ quotesRead, dataProvider, { deadlineMs: dividendDeadlineMs })
895
+ : null;
842
896
  const [quotes, futures, purchaseDateFx] = await Promise.all([
843
- loadCollectionQuotes(filtered, collection, dataProvider, { datesChangeBasis: basis === "regular-close" }),
897
+ quotesRead,
844
898
  isPortfolio ? loadPortfolioFuturesTerms(futuresHeld, {
845
899
  settlement: basis === "regular-close",
846
900
  sources: { history: dailyFuturesHistory(dataProvider), ...futuresSources },
@@ -890,7 +944,8 @@ async function showCollectionWithMarketData(
890
944
  // What each holding pays a year: trailing dividends per share times its shares, in the portfolio's currency.
891
945
  // By symbol: a lot whose cost converts at its purchase date's FX close is valued on a copy of its record.
892
946
  const held = filtered.filter((ticker) => valued.some((entry) => entry.ticker.metadata.ticker === ticker.metadata.ticker && entry.position));
893
- const { dividends } = await loadHoldingDividends(held, quotes, dataProvider, { deadlineMs: dividendDeadlineMs });
947
+ const { dividends, timedOut } = await dividendsRead!;
948
+ outcome.readsLeftBehind = timedOut;
894
949
  // Lots without a position or shares are no lot of income; a row of their own keeps its place with none.
895
950
  const income = await portfolioIncome(valued.map((entry) => ({
896
951
  symbol: entry.position && entry.metrics ? entry.ticker.metadata.ticker : "",
@@ -951,8 +1006,9 @@ async function showCollectionWithMarketData(
951
1006
  };
952
1007
  });
953
1008
  const totalPnlValue = unavailablePnl.size > 0 ? null : totalPnl;
954
- // At the close, the value is Last times the shares, so the day's move from the close before is said beside it.
955
- const dayMove = basis === "regular-close" ? portfolioDayMove(valuation) : null;
1009
+ // The value's move from the closes before, totalled under Chg and said with its base under the table: at the close
1010
+ // that is Last times the shares; at the latest print, an after-hours print included, as Value is.
1011
+ const dayMove = portfolioDayMove(valuation);
956
1012
  const cashExport = cash && allocation.cash ? {
957
1013
  ...cash,
958
1014
  weight: allocation.cash.weight,
@@ -1037,7 +1093,7 @@ async function showCollectionWithMarketData(
1037
1093
  total: allocation.total, cash: cashExport, targetSum: allocation.targetSum,
1038
1094
  // Only on a book that holds a short: its weights are shares of `weightBase`, its gross exposure, not of the total.
1039
1095
  ...(allocation.weightBasis === "gross" ? { weightBasis: allocation.weightBasis, weightBase: allocation.weightBase } : {}),
1040
- ...(basis === "regular-close" ? { dayChange: dayMove?.change ?? null, dayChangePercent: dayMove?.changePercent ?? null, dayChangeBasis: dayMove?.basis ?? null } : {}),
1096
+ dayChange: dayMove?.change ?? null, dayChangePercent: dayMove?.changePercent ?? null, dayChangeBasis: dayMove?.basis ?? null,
1041
1097
  unpricedCount: allocation.unpriced.length, unpricedSymbols: allocation.unpriced,
1042
1098
  totalUnrealizedPnl: totalPnlValue,
1043
1099
  annualIncome: totalIncome, knownAnnualIncome: income.knownIncome, portfolioYield,
@@ -1147,8 +1203,9 @@ async function showCollectionWithMarketData(
1147
1203
  ...allocationCells(cashExport, { unpriced: cashExport.value == null }), ...(showIncome ? ["", ""] : []), "", ""]);
1148
1204
  }
1149
1205
  const total = allocation.total;
1206
+ const totalChange = dayMove?.changePercent != null ? colorBySign(formatPercentRaw(dayMove.changePercent), dayMove.change) : "—";
1150
1207
  rows.push([
1151
- cliStyles.bold("TOTAL"), "", "", ...extendedSessions.map(() => ""), "", "",
1208
+ cliStyles.bold("TOTAL"), "", totalChange, ...extendedSessions.map(() => ""), "", "",
1152
1209
  cliStyles.bold(wholeMoney(total)),
1153
1210
  formatAllocationWeight(totalWeight(allocation)),
1154
1211
  ...(showTargets ? [formatAllocationWeight(allocation.targetSum), "", "", ""] : []),
@@ -1184,7 +1241,7 @@ async function showCollectionWithMarketData(
1184
1241
  rows,
1185
1242
  ));
1186
1243
  console.log("");
1187
- if (basis === "regular-close") console.log(dayMoveLine(dayMove, currency, colorBySign, cliStyles.muted));
1244
+ if (valued.some((entry) => entry.position)) console.log(dayMoveLine(dayMove, currency, colorBySign, cliStyles.muted));
1188
1245
  if (valued.some((entry) => entry.position)) console.log(exposureLine(exposure, currency));
1189
1246
  // The rates the holdings in another currency are valued at, dated, so a stale one is seen beside the value it moves.
1190
1247
  const fxLine = fxRatesLine(toBase.conversions(), { warning: cliStyles.warning });
@@ -1447,7 +1504,8 @@ async function valueWatchlistRows({
1447
1504
  values.push({
1448
1505
  ticker, quote, headline, extended, kind, venue, marketCap, funding, stale, lastTrade,
1449
1506
  row: {
1450
- symbol,
1507
+ // A listing abroad by its venue (ASML:AMS, 2330:TWSE), so a join on the export never meets the US line.
1508
+ symbol: watchlistMemberSymbol(ticker.metadata),
1451
1509
  ...listingColumns(ticker, quote),
1452
1510
  exchange: venue,
1453
1511
  kind,
@@ -1465,6 +1523,8 @@ async function valueWatchlistRows({
1465
1523
  // A stale quote (as the source line counts it) and the exchange-local date it last traded.
1466
1524
  stale,
1467
1525
  lastTradeDate: lastTrade,
1526
+ // Only at a nominal price: `quoteAsOf` is the last print, older than the session that price is for.
1527
+ ...quotePriceKindField(quote),
1468
1528
  // A listing that no longer trades: its status and last session.
1469
1529
  ...quote?.delisting ? { delisting: quote.delisting } : {},
1470
1530
  },
@@ -20,7 +20,7 @@ import {
20
20
  deleteWatchlist as deleteWatchlistConfig,
21
21
  removeTickerFromWatchlist as removeWatchlistMembership,
22
22
  } from "../../../../portfolio/mutations";
23
- import { showCollection } from "./render";
23
+ import { collectionAddCommand, showCollection } from "./render";
24
24
  import { listingFields, misplacedSymbolList, refuseDryRun, takeCollectionName } from "./shared";
25
25
  import { addOneSymbol, addSymbols, FILE_OPTION, listAddLookups, printSymbolRows, progressNotice, removeSymbols, requireSymbolList, retryNotice, shellWord, SYMBOL_LIST_HELP } from "./bulk-symbols";
26
26
  import { readNameEntries } from "../../../../cli/name-entries";
@@ -209,6 +209,10 @@ async function listWatchlists(ctx: CliCommandContext) {
209
209
  String(watchlist.tickerCount),
210
210
  ]),
211
211
  ));
212
+ // Nothing in any of them: the command that fills one, as `alerts` names the one that adds an alert.
213
+ if (rows.every((watchlist) => watchlist.tickerCount === 0)) {
214
+ console.log(cliStyles.muted(`\nNo tickers yet. Add some with ${collectionAddCommand("watchlist", rows[0]!.name)}.`));
215
+ }
212
216
  });
213
217
  }
214
218
 
@@ -115,7 +115,8 @@ const VALUATION_TIME_COLUMN: HeadlessPaneColumn = {
115
115
  key: "valuationAsOf",
116
116
  header: "As of (UTC)",
117
117
  // Exports keep the ISO time.
118
- textFormat: (value, row) => valuationTimeText(value, undefined, row.valuationPriceKind === "settle" ? "settle" : undefined),
118
+ textFormat: (value, row) => valuationTimeText(value, undefined,
119
+ row.valuationPriceKind === "settle" || row.valuationPriceKind === "nominal" ? row.valuationPriceKind : undefined),
119
120
  shrink: false,
120
121
  description: "When the price the row is valued at is from: its print, or the regular close with --close (a future's settlement).",
121
122
  };
@@ -80,21 +80,24 @@ export interface HoldingDividends {
80
80
  /**
81
81
  * The dividends of a portfolio's shares and funds, keyed by ticker: each
82
82
  * holding's cash history through the data provider, so a history read in the
83
- * last hours comes from the cache, measured as DVD measures it. Every read
84
- * shares one deadline; a holding not read by then, or whose read failed, has
85
- * an unknown rate, never a zero.
83
+ * last hours comes from the cache, measured as DVD measures it. The histories
84
+ * need no quote, so they are read beside the quotes (`quotes` may still be
85
+ * coming), and every read shares one deadline from the call; a holding not
86
+ * read by then, or whose read failed, has an unknown rate, never a zero. A
87
+ * listing its quote shows pays nothing (a coin) is left out once it is in.
86
88
  */
87
89
  export async function loadHoldingDividends(
88
90
  tickers: readonly TickerRecord[],
89
- quotes: ReadonlyMap<string, Quote>,
91
+ quotes: ReadonlyMap<string, Quote> | PromiseLike<ReadonlyMap<string, Quote>>,
90
92
  provider: Pick<DataProvider, "getCorporateActions">,
91
93
  { deadlineMs = DIVIDEND_READ_DEADLINE_MS }: { deadlineMs?: number } = {},
92
94
  ): Promise<HoldingDividends> {
93
- const payers = tickers.filter((ticker) => paysDividends(ticker, quotes.get(ticker.metadata.ticker)));
94
95
  const dividends = new Map<string, HoldingDividend>();
95
96
  const getCorporateActions = provider.getCorporateActions?.bind(provider);
96
97
  // A source with no distribution histories at all (a custom provider) has no income to report, as a coin book has none.
97
- if (payers.length === 0 || !getCorporateActions) return { dividends, timedOut: false };
98
+ if (tickers.length === 0 || !getCorporateActions) return { dividends, timedOut: false };
99
+ // Quotes that fail fail the report that asked for them, not this.
100
+ const quoted = Promise.resolve(quotes).then((known) => known, () => new Map<string, Quote>());
98
101
  let timedOut = false;
99
102
  let timer: ReturnType<typeof setTimeout> | undefined;
100
103
  const deadline = new Promise<"deadline">((resolve) => {
@@ -102,26 +105,47 @@ export async function loadHoldingDividends(
102
105
  });
103
106
  const unread = (why: "timed-out" | "sign-in" | "offline" | "failed"): HoldingDividend =>
104
107
  ({ perShare: null, currency: null, price: null, gap: { cause: "unread", why } });
108
+ const started = new Set<TickerRecord>();
109
+ const read = async (ticker: TickerRecord) => {
110
+ if (timedOut) return;
111
+ started.add(ticker);
112
+ const symbol = ticker.metadata.ticker;
113
+ const exchange = ticker.metadata.exchange ?? "";
114
+ const history = Promise.resolve().then(() => getCorporateActions(symbol, exchange));
115
+ history.catch(() => {
116
+ // Intentional ignore: a read left behind at the deadline has no reader; one awaited below reports its own failure.
117
+ });
118
+ const known = await Promise.race([quoted, deadline]);
119
+ if (known === "deadline") return;
120
+ const quote = known.get(symbol);
121
+ if (!paysDividends(ticker, quote)) return;
122
+ // The quote already read prices the cash; nothing asks for it again.
123
+ const source = {
124
+ getCorporateActions: () => history,
125
+ getQuote: async () => { if (!quote) throw new Error("No quote"); return quote; },
126
+ };
127
+ const result = await Promise.race([
128
+ fetchProviderDividendData(source, symbol, regularSessionValuationPrice(quote), exchange, quote?.currency)
129
+ .then(holdingDividend, (error: unknown) => unread(unreadWhy(error))),
130
+ deadline,
131
+ ]);
132
+ if (result !== "deadline") dividends.set(symbol, result);
133
+ };
105
134
  try {
106
- await Promise.race([deadline, mapWithConcurrency(payers, DIVIDEND_CONCURRENCY, async (ticker) => {
107
- const symbol = ticker.metadata.ticker;
108
- if (timedOut) return;
109
- const quote = quotes.get(symbol);
110
- // The quote already read prices the cash; nothing asks for it again.
111
- const source = {
112
- getCorporateActions,
113
- getQuote: async () => { if (!quote) throw new Error("No quote"); return quote; },
114
- };
115
- const read = fetchProviderDividendData(source, symbol, regularSessionValuationPrice(quote), ticker.metadata.exchange ?? "", quote?.currency)
116
- .then(holdingDividend, (error: unknown) => unread(unreadWhy(error)));
117
- const result = await Promise.race([read, deadline]);
118
- if (result !== "deadline") dividends.set(symbol, result);
119
- })]);
135
+ await Promise.race([deadline, (async () => {
136
+ // A listing its record types as a share or fund starts at once; one only its quote types starts once the quotes are in.
137
+ await mapWithConcurrency(tickers.filter((ticker) => paysDividends(ticker, undefined)), DIVIDEND_CONCURRENCY, read);
138
+ const known = await quoted;
139
+ await mapWithConcurrency(tickers.filter((ticker) => !started.has(ticker) && paysDividends(ticker, known.get(ticker.metadata.ticker))),
140
+ DIVIDEND_CONCURRENCY, read);
141
+ })()]);
120
142
  } finally {
121
143
  clearTimeout(timer);
122
144
  }
123
- for (const ticker of payers) {
124
- if (!dividends.has(ticker.metadata.ticker)) dividends.set(ticker.metadata.ticker, unread("timed-out"));
145
+ const known = await quoted;
146
+ for (const ticker of tickers) {
147
+ const symbol = ticker.metadata.ticker;
148
+ if (!dividends.has(symbol) && paysDividends(ticker, known.get(symbol))) dividends.set(symbol, unread("timed-out"));
125
149
  }
126
150
  return { dividends, timedOut };
127
151
  }
@@ -276,17 +276,24 @@ export function getCollectionTickersFromConfig(
276
276
  .sort((left, right) => left.metadata.ticker.localeCompare(right.metadata.ticker));
277
277
  }
278
278
 
279
+ export interface SortedTickers {
280
+ tickers: TickerRecord[];
281
+ /** The rows that have a figure in the sort column; the rest sit last, in their listed order. */
282
+ valued: Set<string>;
283
+ }
284
+
279
285
  export function sortTickers(
280
286
  tickers: TickerRecord[],
281
287
  financialsMap: Map<string, TickerFinancials>,
282
288
  sortPreference: CollectionSortPreference,
283
289
  columnContext: ColumnContext,
284
290
  columns: ColumnConfig[],
285
- ) {
286
- if (!sortPreference.columnId) return tickers;
291
+ ): SortedTickers {
292
+ const valued = new Set<string>();
293
+ if (!sortPreference.columnId) return { tickers, valued };
287
294
 
288
295
  const sortColumn = columns.find((column) => column.id === sortPreference.columnId);
289
- if (!sortColumn) return tickers;
296
+ if (!sortColumn) return { tickers, valued };
290
297
  const sortContextVersion = `${sortColumn.id}|${columnContextVersion(sortColumn.id, columnContext)}`;
291
298
  const sortValues = new Map<string, ReturnType<typeof getSortValue>>();
292
299
  for (const ticker of tickers) {
@@ -294,17 +301,20 @@ export function sortTickers(
294
301
  // Ticker records and financials are replaced, never mutated, so their
295
302
  // identities version a row without walking its positions on every tick.
296
303
  const version = `${sortContextVersion}|${objectVersion(ticker)}|${objectVersion(financials)}`;
297
- sortValues.set(ticker.metadata.ticker, sortValueCache.get(
304
+ const value = sortValueCache.get(
298
305
  `${ticker.metadata.ticker}:${sortColumn.id}`,
299
306
  version,
300
307
  () => getSortValue(sortColumn, ticker, financials, columnContext),
301
- ));
308
+ );
309
+ sortValues.set(ticker.metadata.ticker, value);
310
+ if (value != null && !(typeof value === "number" && !Number.isFinite(value))) valued.add(ticker.metadata.ticker);
302
311
  }
303
312
 
304
- return [...tickers].sort((leftTicker, rightTicker) => {
313
+ const sorted = [...tickers].sort((leftTicker, rightTicker) => {
305
314
  const leftValue = sortValues.get(leftTicker.metadata.ticker) ?? null;
306
315
  const rightValue = sortValues.get(rightTicker.metadata.ticker) ?? null;
307
316
 
308
317
  return compareSortValues(leftValue, rightValue, sortPreference.direction);
309
318
  });
319
+ return { tickers: sorted, valued };
310
320
  }
@@ -358,16 +358,17 @@ export function PortfolioListPane({ focused, width, height }: PaneProps) {
358
358
  const sortNow = activeSort.columnId === "latency" ? now : Math.floor(now / DAY_MS) * DAY_MS;
359
359
  const sortContext: ColumnContext = useMemo(() => sharePositionMetrics({ ...baseColumnContext, now: sortNow }, baseColumnContext), [baseColumnContext, sortNow]);
360
360
 
361
- const candidateSortedTickers = useMemo(
361
+ const candidateSort = useMemo(
362
362
  () => sortTickers(tickers, financialsMap, activeSort, sortContext, columns),
363
363
  [tickers, financialsMap, activeSort, sortContext, columns],
364
364
  );
365
365
  const candidateSymbols = useMemo(
366
- () => candidateSortedTickers.map((ticker) => ticker.metadata.ticker),
367
- [candidateSortedTickers],
366
+ () => candidateSort.tickers.map((ticker) => ticker.metadata.ticker),
367
+ [candidateSort],
368
368
  );
369
369
  const orderResetKey = `${activeCollectionId}|${activeSort.columnId ?? ""}|${activeSort.direction}`;
370
- const orderedSymbols = useThrottledTickerOrder(candidateSymbols, orderResetKey);
370
+ // Rows getting their first figure (the quotes landing after the rows) take their place at once.
371
+ const orderedSymbols = useThrottledTickerOrder(candidateSymbols, orderResetKey, { valuedSymbols: candidateSort.valued });
371
372
  // Keyed on the records, not the re-sorted candidates, so the rows keep their
372
373
  // identity across ticks until the throttled order actually moves.
373
374
  const tickerBySymbol = useMemo(
@@ -12,18 +12,44 @@ function hasSameMembership(left: readonly string[], right: readonly string[]): b
12
12
  return right.every((symbol) => symbols.has(symbol));
13
13
  }
14
14
 
15
+ function hasUnseenSymbol(symbols: ReadonlySet<string> | undefined, seen: ReadonlySet<string>): boolean {
16
+ if (!symbols) return false;
17
+ for (const symbol of symbols) {
18
+ if (!seen.has(symbol)) return true;
19
+ }
20
+ return false;
21
+ }
22
+
23
+ /**
24
+ * The order a table shows while quotes move it. A user's sort change, a row
25
+ * joining or leaving, and a row getting its first figure in the sort column
26
+ * (the list's values arriving after its rows) all apply at once. Rows that
27
+ * already had a figure only reshuffle among themselves once per `throttleMs`,
28
+ * so live ticks do not make the list jump. `valuedSymbols` are the rows that
29
+ * have a figure now; leave it out for an order that has no such arrival.
30
+ */
15
31
  export function useThrottledTickerOrder(
16
32
  candidateSymbols: string[],
17
33
  resetKey: string,
18
- throttleMs = PORTFOLIO_REORDER_THROTTLE_MS,
34
+ { throttleMs = PORTFOLIO_REORDER_THROTTLE_MS, valuedSymbols }: {
35
+ throttleMs?: number;
36
+ valuedSymbols?: ReadonlySet<string>;
37
+ } = {},
19
38
  ): string[] {
20
39
  const [committedSymbols, setCommittedSymbols] = useState(candidateSymbols);
21
40
  const committedRef = useRef(candidateSymbols);
22
41
  const latestCandidateRef = useRef(candidateSymbols);
23
42
  const resetKeyRef = useRef(resetKey);
43
+ // Rows that have had a figure since the last sort or list change: a row that
44
+ // loses it and gets it back is a live flicker, not an arrival.
45
+ const valuedRef = useRef<Set<string> | null>(null);
46
+ if (valuedRef.current === null) valuedRef.current = new Set(valuedSymbols);
24
47
  const lastCommitAtRef = useRef(0);
25
48
  const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
26
49
  const candidateKey = JSON.stringify(candidateSymbols);
50
+ // Whether a row has a figure it has not had before: a quote tick that only
51
+ // moves the rows' values does not wake the effect.
52
+ const hasNewValue = hasUnseenSymbol(valuedSymbols, valuedRef.current);
27
53
 
28
54
  useEffect(() => {
29
55
  latestCandidateRef.current = candidateSymbols;
@@ -32,13 +58,24 @@ export function useThrottledTickerOrder(
32
58
  const membershipChanged = !hasSameMembership(current, candidateSymbols);
33
59
  resetKeyRef.current = resetKey;
34
60
 
61
+ const valued = valuedRef.current!;
62
+ let firstValue = false;
63
+ if (resetChanged) valued.clear();
64
+ if (valuedSymbols) {
65
+ for (const symbol of valuedSymbols) {
66
+ if (valued.has(symbol)) continue;
67
+ valued.add(symbol);
68
+ firstValue = true;
69
+ }
70
+ }
71
+
35
72
  const commit = (nextSymbols: string[]) => {
36
73
  committedRef.current = nextSymbols;
37
74
  lastCommitAtRef.current = Date.now();
38
75
  setCommittedSymbols(nextSymbols);
39
76
  };
40
77
 
41
- if (resetChanged || membershipChanged) {
78
+ if (resetChanged || membershipChanged || firstValue) {
42
79
  if (timerRef.current) clearTimeout(timerRef.current);
43
80
  timerRef.current = null;
44
81
  if (!hasSameOrder(current, candidateSymbols)) commit(candidateSymbols);
@@ -60,7 +97,7 @@ export function useThrottledTickerOrder(
60
97
  const latest = latestCandidateRef.current;
61
98
  if (!hasSameOrder(committedRef.current, latest)) commit(latest);
62
99
  }, remaining);
63
- }, [candidateKey, resetKey, throttleMs]);
100
+ }, [candidateKey, resetKey, throttleMs, hasNewValue]);
64
101
 
65
102
  useEffect(() => () => {
66
103
  if (timerRef.current) clearTimeout(timerRef.current);
@@ -22,8 +22,9 @@ export const paneSchemas = {
22
22
  settingKey: "extraColumns",
23
23
  placeholder: "fields",
24
24
  description: `Report columns to add, in order: ${EXTRA_COLUMN_IDS.join(", ")}. shortInterest is FINRA short interest as a percent of float at the latest settlement, `
25
- + "nextEarnings the next report date on the earnings calendar, target the mean analyst target and the analyst count, grossMargin and evEbitda the screener's stored figures. "
26
- + "Short interest, earnings dates, gross margin and EV/EBITDA cover US listings. CSV and JSON give each cell's source and as-of. The pane keeps its own columns",
25
+ + "nextEarnings the next report date on the earnings calendar, target the mean analyst target and the analyst count, grossMargin the trailing twelve months' gross margin, "
26
+ + "evEbitda the enterprise value over trailing operating income plus D&A, as GE's EV/EBITDA ends. "
27
+ + "Short interest and earnings dates cover US listings. CSV and JSON give each cell's source and as-of. The pane keeps its own columns",
27
28
  example: "--columns shortInterest,nextEarnings,target,grossMargin,evEbitda",
28
29
  normalize: normalizeExtraColumns,
29
30
  },
@@ -32,7 +33,7 @@ export const paneSchemas = {
32
33
  type: "string",
33
34
  settingKey: "capCurrency",
34
35
  placeholder: "ISO code",
35
- description: "Show every market cap in this currency, converted at the app's FX rates; the status line names each rate and its time",
36
+ description: "Show every market cap and analyst target in this currency, converted at the app's FX rates; the status line names each rate and its time",
36
37
  example: "--currency USD",
37
38
  normalize: normalizeCapCurrency,
38
39
  },