@gloom-sh/terminal 0.20.9 → 0.20.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/api-client/auth.ts +6 -0
- package/src/api-client/data.ts +1 -0
- package/src/api-client/earnings.ts +15 -0
- package/src/api-client/index.ts +14 -3
- package/src/api-client/types/account.ts +10 -0
- package/src/api-client/types/billing.ts +10 -0
- package/src/api-client/types/econ.ts +19 -7
- package/src/api-client/types/market.ts +7 -0
- package/src/api-client/types/screener.ts +2 -0
- package/src/cli/commands/market.ts +18 -8
- package/src/cli/commands/overview.ts +26 -7
- package/src/cli/commands/ticker.ts +40 -15
- package/src/cli/desktop-pane-shot.ts +39 -0
- package/src/cli/errors.ts +20 -3
- package/src/cli/fx-pair.ts +11 -2
- package/src/cli/history-rows.ts +34 -3
- package/src/cli/index.ts +1 -1
- package/src/cli/listing-arg.ts +51 -13
- package/src/cli/pane-functions/headless.ts +4 -2
- package/src/cli/pane-functions/index.ts +1 -0
- package/src/cli/pane-functions/resolver.ts +2 -1
- package/src/cli/pane-functions/screenshot-assessment.ts +73 -5
- package/src/cli/pane-functions/screenshot-types.ts +4 -0
- package/src/components/chart/composite/chart-layout.ts +7 -4
- package/src/components/chart/composite/composite-chart.tsx +6 -16
- package/src/components/chart/composite/toolbar.tsx +258 -82
- package/src/components/chart/composite/use-composite-chart-keyboard.ts +5 -6
- package/src/components/command-bar/list/model.ts +13 -0
- package/src/components/command-bar/routes/ticker-search/actions.ts +2 -0
- package/src/components/command-bar/routes/ticker-search/results.ts +15 -8
- package/src/components/command-bar/surface/index.tsx +10 -5
- package/src/components/command-bar/workflow/alert.ts +21 -7
- package/src/components/data-table/table-pane.ts +3 -1
- package/src/components/layout/pane/footer/model.ts +26 -1
- package/src/components/metric-treemap/heat-surface.tsx +2 -1
- package/src/components/metric-treemap/index.tsx +3 -2
- package/src/components/ui/confirm-dialog.tsx +253 -7
- package/src/components/ui/data-table/index.tsx +1 -1
- package/src/components/ui/data-table/types.ts +7 -0
- package/src/components/ui/list-view.tsx +4 -3
- package/src/components/ui/status.tsx +9 -6
- package/src/docs/snapshot.json +36 -0
- package/src/i18n/es.ts +12 -0
- package/src/i18n/ja.ts +12 -0
- package/src/i18n/ko.ts +12 -0
- package/src/i18n/zh-cn.ts +12 -0
- package/src/i18n/zh-tw.ts +12 -0
- package/src/market-data/fx-closes.ts +14 -2
- package/src/market-data/market/change-basis.ts +35 -1
- package/src/market-data/market/status.ts +37 -0
- package/src/market-data/performance.ts +4 -1
- package/src/market-data/quotes/live-valuation.ts +25 -2
- package/src/market-data/realized-volatility.ts +3 -0
- package/src/market-data/us-bond-market.ts +115 -0
- package/src/plugins/builtin/account-management/invite-row.tsx +54 -0
- package/src/plugins/builtin/account-management/keyboard.ts +3 -0
- package/src/plugins/builtin/account-management/model.ts +1 -0
- package/src/plugins/builtin/account-management/pane.tsx +51 -5
- package/src/plugins/builtin/account-management/trial-cancel.ts +32 -7
- package/src/plugins/builtin/cloud/askg/pane-session.ts +94 -0
- package/src/plugins/builtin/cloud/askg/pane.tsx +40 -83
- package/src/plugins/builtin/congress-trades/pane.tsx +8 -2
- package/src/plugins/builtin/correlation/compute.ts +4 -3
- package/src/plugins/builtin/earnings/board-model.ts +33 -0
- package/src/plugins/builtin/earnings/board-table.ts +50 -11
- package/src/plugins/builtin/earnings/board.tsx +29 -13
- package/src/plugins/builtin/earnings/calendar.tsx +15 -3
- package/src/plugins/builtin/earnings/client.ts +4 -1
- package/src/plugins/builtin/earnings/headless.ts +27 -14
- package/src/plugins/builtin/econ/calendar-source.ts +3 -0
- package/src/plugins/builtin/help/index.tsx +1 -1
- package/src/plugins/builtin/ipo-calendar/model.ts +3 -3
- package/src/plugins/builtin/iv-history/headless.ts +12 -10
- package/src/plugins/builtin/macro-day/headless.ts +15 -5
- package/src/plugins/builtin/macro-day/model.ts +17 -4
- package/src/plugins/builtin/macro-day/releases.ts +36 -15
- package/src/plugins/builtin/market-halts/model.ts +3 -2
- package/src/plugins/builtin/market-movers/headless.ts +2 -1
- package/src/plugins/builtin/market-movers/index.tsx +3 -2
- package/src/plugins/builtin/market-movers/model.ts +75 -22
- package/src/plugins/builtin/market-movers/screener.ts +2 -1
- package/src/plugins/builtin/market-movers/table.ts +7 -5
- package/src/plugins/builtin/pe-band/model.ts +4 -0
- package/src/plugins/builtin/portfolio-list/cell-version.ts +4 -4
- package/src/plugins/builtin/portfolio-list/cli/render.ts +9 -4
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +2 -1
- package/src/plugins/builtin/portfolio-list/summary/index.tsx +24 -7
- package/src/plugins/builtin/portfolio-list/summary/totals.ts +40 -11
- package/src/plugins/builtin/portfolio-list/table.tsx +13 -1
- package/src/plugins/builtin/research/analyst-headless.ts +9 -1
- package/src/plugins/builtin/research/analyst-pane.tsx +10 -4
- package/src/plugins/builtin/research/client.ts +25 -1
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +2 -1
- package/src/plugins/builtin/research/event-model.ts +3 -13
- package/src/plugins/builtin/research/event-sources.ts +3 -1
- package/src/plugins/builtin/short-interest/headless.ts +2 -0
- package/src/plugins/builtin/short-interest/publications-headless.ts +2 -0
- package/src/plugins/builtin/short-interest/watch-headless.ts +1 -0
- package/src/plugins/builtin/yield-curve/headless.ts +5 -1
- package/src/plugins/builtin/yield-curve/index.tsx +5 -0
- package/src/portfolio/column-values.ts +47 -14
- package/src/portfolio/return-metrics.ts +4 -2
- package/src/renderers/dom/host/image-surface.tsx +19 -9
- package/src/renderers/dom/host/input.tsx +4 -0
- package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +23 -1
- package/src/sources/gloomberb-cloud/normalizers.ts +2 -0
- package/src/sources/provider-errors.ts +12 -0
- package/src/sources/provider-router/index.ts +12 -4
- package/src/state/pane-session.ts +145 -0
- package/src/tickers/search/home-listing.ts +44 -1
- package/src/tickers/search/index.ts +5 -2
- package/src/tickers/search/ranking.ts +7 -7
- package/src/tickers/us-listing.ts +11 -5
- package/src/time-series/base-series.ts +7 -1
- package/src/time-series/fundamentals/current-valuation.ts +8 -0
- package/src/time-series/fundamentals/series.ts +6 -0
- package/src/time-series/resolve.ts +1 -0
- package/src/types/financials.ts +20 -0
- package/src/types/headless.ts +9 -0
- package/src/ui/host.tsx +2 -0
- package/src/utils/exchanges.ts +13 -8
- package/src/utils/price-earnings.ts +17 -10
- package/src/utils/price-history-integrity.ts +15 -0
- package/src/utils/reason-codes.ts +79 -0
- package/src/utils/share-multiples.cases.json +889 -0
- package/src/utils/share-multiples.ts +254 -0
- package/src/utils/untrusted-text.ts +11 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { TickerFinancials } from "../../../../types/financials";
|
|
2
2
|
import type { TickerRecord } from "../../../../types/ticker";
|
|
3
|
-
import { convertCurrency, formatCompactAmount } from "../../../../utils/format";
|
|
4
|
-
import { getCurrencySymbol } from "../../../../market-data/market/format";
|
|
5
|
-
import { getActiveQuoteDisplay } from "../../../../market-data/market/status";
|
|
6
|
-
import {
|
|
3
|
+
import { convertCurrency, formatCompactAmount, formatNumber } from "../../../../utils/format";
|
|
4
|
+
import { currencyMinorDigits, getCurrencySymbol } from "../../../../market-data/market/format";
|
|
5
|
+
import { extendedPrintSession, getActiveQuoteDisplay, type ExtendedSession } from "../../../../market-data/market/status";
|
|
6
|
+
import { dayMoveBasisLabel, futuresQuoteFromSettle, quoteChangeBasis, type QuoteChangeBasis } from "../../../../market-data/market/change-basis";
|
|
7
7
|
import { isQuoteStaleForCurrentSession } from "../../../../market-data/quotes/freshness";
|
|
8
8
|
import { headlineQuoteDisplay } from "../../../../portfolio/column-values";
|
|
9
9
|
import type { AllocationHolding } from "../../../../portfolio/allocation";
|
|
@@ -48,10 +48,13 @@ export interface PortfolioSummaryTotals {
|
|
|
48
48
|
/**
|
|
49
49
|
* What Day (or a watchlist's Avg Day) is measured from, as each holding's
|
|
50
50
|
* change line says it: "vs Fri 16 Oct close" when they agree, "vs mixed
|
|
51
|
-
* closes" when they do not (an HKEX listing beside a US one)
|
|
52
|
-
*
|
|
51
|
+
* closes" when they do not (an HKEX listing beside a US one), after the
|
|
52
|
+
* session of the extended-hours prints it is valued at, as the rows mark
|
|
53
|
+
* them ("AH vs Tue 10 Nov close"). Absent without a move.
|
|
53
54
|
*/
|
|
54
55
|
dayChangeBasis?: string;
|
|
56
|
+
/** Some holding's day is valued at an extended-hours print, which dayChangeBasis names. */
|
|
57
|
+
dayAtExtendedPrint?: boolean;
|
|
55
58
|
totalCostBasis: number;
|
|
56
59
|
hasPositions: boolean;
|
|
57
60
|
unrealizedPnl: number;
|
|
@@ -77,17 +80,39 @@ function currencyCode(value: string | undefined): string | null {
|
|
|
77
80
|
|
|
78
81
|
export { resolvePortfolioTotalsCurrency } from "../../../../portfolio/totals-currency";
|
|
79
82
|
|
|
83
|
+
/** From here a book's totals read in whole units (1,588), as `portfolio show` prints market values; below it, to the minor unit (101.10). */
|
|
84
|
+
const WHOLE_AMOUNT_FROM = 1_000;
|
|
85
|
+
/** From here they read compact (1.23B), so a header row keeps its other figures. */
|
|
86
|
+
const COMPACT_AMOUNT_FROM = 1_000_000_000;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* An amount with thousands separators: to the currency's minor unit below a
|
|
90
|
+
* thousand (101.10, ¥950), in whole units from there (1,588, -40,000) and
|
|
91
|
+
* compact from a billion (1.23B). A signed amount carries + or -, except one
|
|
92
|
+
* that rounds to zero.
|
|
93
|
+
*/
|
|
94
|
+
function bookAmountText(value: number | undefined, currency: string, signed: boolean): string {
|
|
95
|
+
if (value == null || !Number.isFinite(value)) return formatCompactAmount(value);
|
|
96
|
+
const abs = Math.abs(value);
|
|
97
|
+
if (abs >= COMPACT_AMOUNT_FROM) return formatCompactAmount(value, { signed });
|
|
98
|
+
const minor = currencyMinorDigits(currency);
|
|
99
|
+
const body = formatNumber(abs, Number(abs.toFixed(minor)) >= WHOLE_AMOUNT_FROM ? 0 : minor);
|
|
100
|
+
if (!/[1-9]/.test(body)) return body;
|
|
101
|
+
return `${value < 0 ? "-" : signed ? "+" : ""}${body}`;
|
|
102
|
+
}
|
|
103
|
+
|
|
80
104
|
/**
|
|
81
|
-
* A
|
|
82
|
-
*
|
|
83
|
-
*
|
|
105
|
+
* A total in the portfolio's currency (bookAmountText): never rounded to a
|
|
106
|
+
* hundred, as a compact 1.6k for $1,587.80 was. Bare when both it and the
|
|
107
|
+
* app's base currency are USD, as the pane has always shown it; otherwise it
|
|
108
|
+
* leads with the currency symbol, as prices do: A$108,612, +$600.12.
|
|
84
109
|
*/
|
|
85
110
|
export function formatPortfolioAmount(
|
|
86
111
|
value: number | undefined,
|
|
87
112
|
currency: string,
|
|
88
113
|
{ signed = false, baseCurrency = "USD" }: { signed?: boolean; baseCurrency?: string } = {},
|
|
89
114
|
): string {
|
|
90
|
-
const text =
|
|
115
|
+
const text = bookAmountText(value, currency, signed);
|
|
91
116
|
const bare = currency === "USD" && (currencyCode(baseCurrency) ?? "USD") === "USD";
|
|
92
117
|
if (bare || value == null || !Number.isFinite(value)) return text;
|
|
93
118
|
const sign = text.startsWith("+") || text.startsWith("-") ? text.charAt(0) : "";
|
|
@@ -135,6 +160,8 @@ export function calculatePortfolioSummaryTotals(
|
|
|
135
160
|
let watchlistChangeSum = 0;
|
|
136
161
|
let watchlistCount = 0;
|
|
137
162
|
const dayBases: Array<QuoteChangeBasis | null> = [];
|
|
163
|
+
// The extended session of each price the day is valued at, null for a regular one.
|
|
164
|
+
const dayPrints: Array<ExtendedSession | null> = [];
|
|
138
165
|
const unavailableConversions = new Set<string>();
|
|
139
166
|
let livePriced = true;
|
|
140
167
|
const pricedLots: PricedPortfolioLot[] = [];
|
|
@@ -249,6 +276,7 @@ export function calculatePortfolioSummaryTotals(
|
|
|
249
276
|
session: valuationBasis === "regular-close" ? "regular" : "active",
|
|
250
277
|
terms,
|
|
251
278
|
}));
|
|
279
|
+
dayPrints.push(valuationBasis === "latest-print" ? extendedPrintSession(quote, activeQuote.price) : null);
|
|
252
280
|
}
|
|
253
281
|
} else {
|
|
254
282
|
// A broker mark is not evidence of an unchanged day.
|
|
@@ -269,7 +297,7 @@ export function calculatePortfolioSummaryTotals(
|
|
|
269
297
|
const unrealizedPnl = signedUnrealizedPnl;
|
|
270
298
|
const unrealizedPnlPct = portfolioPnlPercent(unrealizedPnl, totalCostBasis) ?? Number.NaN;
|
|
271
299
|
const avgWatchlistChange = watchlistCount > 0 ? watchlistChangeSum / watchlistCount : 0;
|
|
272
|
-
const dayChangeBasis =
|
|
300
|
+
const dayChangeBasis = dayMoveBasisLabel(dayBases, dayPrints, { marks: true, now });
|
|
273
301
|
|
|
274
302
|
return {
|
|
275
303
|
totalMktValue,
|
|
@@ -287,6 +315,7 @@ export function calculatePortfolioSummaryTotals(
|
|
|
287
315
|
dailyPnl,
|
|
288
316
|
dailyPnlPct,
|
|
289
317
|
...(dayChangeBasis ? { dayChangeBasis } : {}),
|
|
318
|
+
...(dayChangeBasis && dayPrints.some((print) => print != null) ? { dayAtExtendedPrint: true } : {}),
|
|
290
319
|
totalCostBasis,
|
|
291
320
|
hasPositions,
|
|
292
321
|
unrealizedPnl,
|
|
@@ -52,6 +52,9 @@ const GROSS_WEIGHT_LABEL = "GROSS WT";
|
|
|
52
52
|
/** P&L%'s header over a period: each position's P&L as a share of the book at the start. */
|
|
53
53
|
const CONTRIBUTION_LABEL = "CONTRIB";
|
|
54
54
|
|
|
55
|
+
/** What an extended-hours print's session mark adds to LAST: `AH `, `PM ` or `ON `. */
|
|
56
|
+
const SESSION_MARK_WIDTH = 3;
|
|
57
|
+
|
|
55
58
|
/** The widest a futures quantity grows the QTY column: `-12,000 × 5,000 bushels` fits. */
|
|
56
59
|
const MAX_QUANTITY_COLUMN_WIDTH = 24;
|
|
57
60
|
|
|
@@ -282,6 +285,14 @@ export function PortfolioTickerTable({
|
|
|
282
285
|
(widest, ticker) => Math.max(widest, displayWidth(resolveCell(sharesColumn, ticker, tableFinancialsMap.get(ticker.metadata.ticker)).text)),
|
|
283
286
|
sharesColumn.width,
|
|
284
287
|
)) : 0;
|
|
288
|
+
// A book at the latest print marks an extended-hours print in LAST (AH 158.78), so the column grows to fit the mark.
|
|
289
|
+
const priceColumn = columns.find((column) => column.id === "price");
|
|
290
|
+
const priceWidth = useMemo(() => priceColumn && columnContext.valuationBasis === "latest-print"
|
|
291
|
+
? Math.min(priceColumn.width + SESSION_MARK_WIDTH, sortedTickers.reduce(
|
|
292
|
+
(widest, ticker) => Math.max(widest, displayWidth(resolveCell(priceColumn, ticker, tableFinancialsMap.get(ticker.metadata.ticker)).text)),
|
|
293
|
+
priceColumn.width,
|
|
294
|
+
))
|
|
295
|
+
: 0, [columnContext.valuationBasis, priceColumn, resolveCell, sortedTickers, tableFinancialsMap]);
|
|
285
296
|
// The Ticker column grows to its longest symbol, so ETH-USD and BA:LSE show whole beside their market-state dot.
|
|
286
297
|
const tickerWidth = useMemo(() => Math.min(MAX_TICKER_COLUMN_WIDTH, sortedTickers.reduce(
|
|
287
298
|
(widest, ticker) => Math.max(widest, TICKER_DOT_WIDTH + displayWidth(listedSymbol(ticker, tickerDisplayName(ticker), columnContext.homeMarket))),
|
|
@@ -295,13 +306,14 @@ export function PortfolioTickerTable({
|
|
|
295
306
|
? { ...column, label: "QTY", ...(sharesWidth > column.width ? { width: sharesWidth } : {}) }
|
|
296
307
|
: column.id === "weight" && grossWeights ? { ...column, label: GROSS_WEIGHT_LABEL }
|
|
297
308
|
: column.id === "ticker" && tickerWidth > column.width ? { ...column, width: tickerWidth }
|
|
309
|
+
: column.id === "price" && priceWidth > column.width ? { ...column, width: priceWidth }
|
|
298
310
|
: column.id === "pnl_pct" && period ? { ...column, label: CONTRIBUTION_LABEL }
|
|
299
311
|
: pnlLabel !== "P&L" && (column.id === "pnl" || column.id === "pnl_pct") ? {
|
|
300
312
|
...column,
|
|
301
313
|
label: column.id === "pnl_pct" ? pnlLabel.replace("P&L", "%") : pnlLabel,
|
|
302
314
|
} : column).map((column) => BOOK_CURRENCY_COLUMN_IDS.has(column.id) ? bookCurrencyColumn(column, capCurrency) : column)
|
|
303
315
|
.map((column) => hasFrontReference && column.id === noteColumnId ? { ...column, flexGrow: 1 } : column),
|
|
304
|
-
[capCurrency, columns, grossWeights, hasFrontReference, hasNonShareQuantity, noteColumnId, period, pnlLabel, sharesWidth, tickerWidth]);
|
|
316
|
+
[capCurrency, columns, grossWeights, hasFrontReference, hasNonShareQuantity, noteColumnId, period, pnlLabel, priceWidth, sharesWidth, tickerWidth]);
|
|
305
317
|
// Read again as the rows' data moves, from the cells the rows show; the columns change only when what is hidden does.
|
|
306
318
|
// The company columns hidden last time, per list, stay hidden while a row added since settles.
|
|
307
319
|
const hiddenCompanyRef = useRef<{ list: string | undefined; ids: ReadonlySet<string> }>({ list: undefined, ids: new Set() });
|
|
@@ -9,7 +9,7 @@ import type {
|
|
|
9
9
|
import type { AnalystResearchData, Quote } from "../../../types/financials";
|
|
10
10
|
import { logFailure } from "../../../utils/log-failure";
|
|
11
11
|
import { formatPercent } from "../../../utils/format";
|
|
12
|
-
import { loadAnalystResearch } from "./client";
|
|
12
|
+
import { hasAnalystCoverage, loadAnalystResearch, noAnalystCoverageText } from "./client";
|
|
13
13
|
import {
|
|
14
14
|
analystReferenceMetadata,
|
|
15
15
|
analystTargetCurrency,
|
|
@@ -185,6 +185,14 @@ export function createAnalystResearchHeadless(
|
|
|
185
185
|
dependencies.loadData(symbol, args, ctx),
|
|
186
186
|
dependencies.loadQuote?.(symbol, ctx) ?? Promise.resolve(null),
|
|
187
187
|
]);
|
|
188
|
+
// A listing no analyst covers has nothing to sum up or list: the report says so once.
|
|
189
|
+
if (!hasAnalystCoverage(data)) {
|
|
190
|
+
return {
|
|
191
|
+
sections: [{ title: "Recent analyst actions", columns: RATING_COLUMNS, rows: [] }],
|
|
192
|
+
empty: noAnalystCoverageText(data.symbol || symbol),
|
|
193
|
+
metadata: { symbol: data.symbol || symbol, name: data.name ?? null },
|
|
194
|
+
};
|
|
195
|
+
}
|
|
188
196
|
const { upside, reference } = analystUpside(data, quote);
|
|
189
197
|
const currency = analystTargetCurrency(data);
|
|
190
198
|
const ratings = sortRatingRows(data.ratings, {
|
|
@@ -27,7 +27,7 @@ import { handleRefreshKey, useClampSelectedIndex } from "../../../components/dat
|
|
|
27
27
|
import { SignInWall } from "../cloud/auth-actions";
|
|
28
28
|
import { isCloudSessionRequired, useResearchCloudSession } from "../shared/research-cloud-session";
|
|
29
29
|
import { useBoundTicker as useSymbolBinding, useTickerRequest } from "../shared/ticker-request";
|
|
30
|
-
import { loadAnalystResearch } from "./client";
|
|
30
|
+
import { hasAnalystCoverage, loadAnalystResearch, noAnalystCoverageText } from "./client";
|
|
31
31
|
import {
|
|
32
32
|
DEFAULT_RATING_SORT,
|
|
33
33
|
analystReferencePrice,
|
|
@@ -109,7 +109,7 @@ function AnalystHeader({ data, history, series, currency, width, height, tableRo
|
|
|
109
109
|
const consensusLabel = !nativePaneChrome && width < 44 ? "Cons." : "Consensus";
|
|
110
110
|
const split = ratingSplit(data);
|
|
111
111
|
// The table body already reports loading, error, and empty states.
|
|
112
|
-
const figures: StatItem[] = data ? [
|
|
112
|
+
const figures: StatItem[] = hasAnalystCoverage(data) ? [
|
|
113
113
|
{ id: "target", label: consensusLabel, value: formatAnalystPrice(target?.average, currency) },
|
|
114
114
|
{
|
|
115
115
|
id: "upside",
|
|
@@ -194,6 +194,10 @@ export function AnalystResearchView({ focused, width, height }: { focused: boole
|
|
|
194
194
|
}, [dataProvider, cloudSession.requestKey]);
|
|
195
195
|
const { data, loading, error, reload } = useTickerRequest<AnalystResearchData>(loader, symbol, exchange);
|
|
196
196
|
const authWall = !data && isCloudSessionRequired(error);
|
|
197
|
+
// A listing no analyst covers loads as research with nothing in it: the body says so, the footer has nothing to add.
|
|
198
|
+
const noCoverage = !!data && !hasAnalystCoverage(data);
|
|
199
|
+
// A failure with nothing loaded is the body's to say; one behind data on screen (a refresh), the footer's.
|
|
200
|
+
const failedEmpty = !!symbol && !data && !loading && !!error && !authWall;
|
|
197
201
|
const rows = useMemo(() => sortRatingRows(data?.ratings ?? [], sortPreference), [data?.ratings, sortPreference]);
|
|
198
202
|
const ratingCurrency = analystTargetCurrency(data);
|
|
199
203
|
const columns = useMemo(
|
|
@@ -278,9 +282,9 @@ export function AnalystResearchView({ focused, width, height }: { focused: boole
|
|
|
278
282
|
const selectedRow = rows.length > 0 ? rows[selectedIdx] : undefined;
|
|
279
283
|
const footer = (
|
|
280
284
|
<AnalystFooter
|
|
281
|
-
data={authWall ? null : data}
|
|
285
|
+
data={authWall || noCoverage ? null : data}
|
|
282
286
|
loading={loading}
|
|
283
|
-
error={authWall ? null : error}
|
|
287
|
+
error={authWall || failedEmpty ? null : error}
|
|
284
288
|
width={width}
|
|
285
289
|
binding={binding}
|
|
286
290
|
focused={focused}
|
|
@@ -332,6 +336,8 @@ export function AnalystResearchView({ focused, width, height }: { focused: boole
|
|
|
332
336
|
getItemKey={(row, index) => `${row.date}:${row.firm}:${index}`}
|
|
333
337
|
renderCell={renderCell}
|
|
334
338
|
selectedTextOverridesCellColor
|
|
339
|
+
status={noCoverage ? { empty: true, emptyTitle: noAnalystCoverageText(symbol ?? data?.symbol ?? "") }
|
|
340
|
+
: failedEmpty && error ? { error, subject: "Analyst research" } : undefined}
|
|
335
341
|
emptyStateTitle={loading ? "Loading analyst data..." : error ?? "No analyst data"}
|
|
336
342
|
/>
|
|
337
343
|
</>
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
+
import { isNoDataAnswer } from "../../../sources/provider-errors";
|
|
2
|
+
import { hasAnalystResearchValue } from "../../../sources/provider-router/financials";
|
|
1
3
|
import type { DataProvider, MarketDataRequestContext } from "../../../types/data-provider";
|
|
2
4
|
import type { AnalystResearchData } from "../../../types/financials";
|
|
3
5
|
|
|
6
|
+
/**
|
|
7
|
+
* The listing's analyst research. A listing no analyst covers (CENN) is
|
|
8
|
+
* answered with research that holds nothing, which `hasAnalystCoverage`
|
|
9
|
+
* reads, not with a failure: the service answered it has nothing for a
|
|
10
|
+
* symbol it knows. A symbol it does not know, and a source that did not
|
|
11
|
+
* answer, still fail.
|
|
12
|
+
*/
|
|
4
13
|
export async function loadAnalystResearch(
|
|
5
14
|
provider: DataProvider,
|
|
6
15
|
symbol: string,
|
|
@@ -8,5 +17,20 @@ export async function loadAnalystResearch(
|
|
|
8
17
|
context?: MarketDataRequestContext,
|
|
9
18
|
): Promise<AnalystResearchData> {
|
|
10
19
|
if (!provider.getAnalystResearch) throw new Error("Analyst data unavailable");
|
|
11
|
-
|
|
20
|
+
try {
|
|
21
|
+
return await provider.getAnalystResearch(symbol, exchange, context);
|
|
22
|
+
} catch (error) {
|
|
23
|
+
if (!isNoDataAnswer(error)) throw error;
|
|
24
|
+
return { symbol, recommendations: [], ratings: [], earningsEstimates: [], revenueEstimates: [] };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Whether any analyst covers the listing: a target, a rating mix, an action or an estimate. */
|
|
29
|
+
export function hasAnalystCoverage(data: AnalystResearchData | null | undefined): boolean {
|
|
30
|
+
return !!data && hasAnalystResearchValue(data);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** What a pane or a report says for a listing no analyst covers. */
|
|
34
|
+
export function noAnalystCoverageText(symbol: string): string {
|
|
35
|
+
return `No analyst coverage for ${symbol}.`;
|
|
12
36
|
}
|
|
@@ -27,6 +27,7 @@ import { useResolvedEntryValue, useSecFilingDocuments, useSecFilingsQuery } from
|
|
|
27
27
|
import { instrumentFromTicker } from "../../../market-data/request-types";
|
|
28
28
|
import { usePaneTicker } from "../../../state/app/context";
|
|
29
29
|
import { mayBeUsEquityTicker } from "../../../utils/sec";
|
|
30
|
+
import { loadAnalystResearch } from "./client";
|
|
30
31
|
import { useAssetData, usePluginPaneState } from "../../runtime";
|
|
31
32
|
import { handleRefreshKey } from "../../../components/data-table/table-pane";
|
|
32
33
|
import { SignInWall } from "../cloud/auth-actions";
|
|
@@ -469,7 +470,7 @@ export function CorporateActionsView({
|
|
|
469
470
|
}, [dataProvider, cloudSession.requestKey]);
|
|
470
471
|
const analystLoader = useCallback(async (nextSymbol: string, nextExchange: string, forceRefresh: boolean) => {
|
|
471
472
|
if (!dataProvider?.getAnalystResearch) return null;
|
|
472
|
-
return dataProvider
|
|
473
|
+
return loadAnalystResearch(dataProvider, nextSymbol, nextExchange, forceRefresh ? { cacheMode: "refresh" } : undefined);
|
|
473
474
|
}, [dataProvider, cloudSession.requestKey]);
|
|
474
475
|
// The earnings calendar's next report, which the rows are resolved against as `earnings` and ERN read it.
|
|
475
476
|
const calendarLoader = useCallback((nextSymbol: string, _exchange: string, forceRefresh: boolean) => (
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
import { computeTTM } from "../ticker-detail/financials/aggregation";
|
|
17
17
|
import { classifyInstrumentType } from "../../../tickers/instrument-kind";
|
|
18
18
|
import { declaredDividends } from "../../../utils/declared-dividends";
|
|
19
|
+
import { isReasonCode, readableStatus } from "../../../utils/reason-codes";
|
|
19
20
|
import { fundamentalsEpsCurrency, SERVED_TRAILING_EPS } from "../../../utils/fundamentals";
|
|
20
21
|
import {
|
|
21
22
|
earningsDateStatus,
|
|
@@ -497,7 +498,7 @@ export function eventSourceNotice(state: EventSourceState): EventSourceNotice |
|
|
|
497
498
|
.filter(([section, status]) => status === "unavailable" && (state.variant !== "earnings-estimates" || section === "earnings"))
|
|
498
499
|
.map(([section]) => section);
|
|
499
500
|
// Sections and estimates that a source failed to give share one line: "Unavailable: earnings, analyst estimates (the source did not answer)".
|
|
500
|
-
const estimatesCode =
|
|
501
|
+
const estimatesCode = isReasonCode(state.estimatesError);
|
|
501
502
|
const sharedLine = !state.actionsError && unavailableSections.length > 0 && estimatesCode;
|
|
502
503
|
|
|
503
504
|
if (state.actionsError) {
|
|
@@ -530,23 +531,12 @@ export function eventSourceNotice(state: EventSourceState): EventSourceNotice |
|
|
|
530
531
|
};
|
|
531
532
|
}
|
|
532
533
|
|
|
533
|
-
/** A data service's reason code (UPSTREAM_ERROR) rather than words. */
|
|
534
|
-
const REASON_CODE = /^[A-Z][A-Z0-9_]+$/;
|
|
535
|
-
|
|
536
534
|
/**
|
|
537
535
|
* A source's failure in words: a reason code reads as what happened
|
|
538
536
|
* ("UPSTREAM_ERROR" is "the source did not answer"); a sentence stands.
|
|
539
537
|
*/
|
|
540
538
|
export function sourceErrorText(error: string): string {
|
|
541
|
-
|
|
542
|
-
if (!REASON_CODE.test(text)) return text;
|
|
543
|
-
switch (text) {
|
|
544
|
-
case "TIMEOUT": return "the source timed out";
|
|
545
|
-
case "NOT_FOUND":
|
|
546
|
-
case "NO_DATA": return "the source has none for this symbol";
|
|
547
|
-
case "RATE_LIMITED": return "the source is busy, try again shortly";
|
|
548
|
-
default: return "the source did not answer";
|
|
549
|
-
}
|
|
539
|
+
return readableStatus(error.trim());
|
|
550
540
|
}
|
|
551
541
|
|
|
552
542
|
function hasCorporateActionRows(data: CorporateActionsData): boolean {
|
|
@@ -5,6 +5,7 @@ import type {
|
|
|
5
5
|
TickerFinancials,
|
|
6
6
|
} from "../../../types/financials";
|
|
7
7
|
import { formatEventMetric } from "./event-model";
|
|
8
|
+
import { loadAnalystResearch } from "./client";
|
|
8
9
|
import { formatPercent, formatPercentRaw } from "../../../utils/format";
|
|
9
10
|
import { loadEarningsCalendar } from "../earnings/data/cache";
|
|
10
11
|
import { calendarEventOf, newYorkDay, withResolvedEarnings } from "../shared/earnings-calendar";
|
|
@@ -74,7 +75,8 @@ function settledError(result: PromiseSettledResult<unknown>): string | null {
|
|
|
74
75
|
export async function loadEventSources(provider: DataProvider, symbol: string, today = newYorkDay()): Promise<EventSources> {
|
|
75
76
|
const [actions, estimates, financials, calendar] = await Promise.allSettled([
|
|
76
77
|
provider.getCorporateActions?.(symbol, "") ?? null,
|
|
77
|
-
|
|
78
|
+
// A listing no analyst covers answers with no estimates, not a failure.
|
|
79
|
+
provider.getAnalystResearch ? loadAnalystResearch(provider, symbol, "") : null,
|
|
78
80
|
provider.getTickerFinancials(symbol, ""),
|
|
79
81
|
loadEarningsCalendar(provider, [symbol]),
|
|
80
82
|
]);
|
|
@@ -9,6 +9,8 @@ export function publicationHeadless(kind: PublicationKind): HeadlessPaneDefiniti
|
|
|
9
9
|
shape: "bundle", options: [],
|
|
10
10
|
argument: { kind: "ticker", description: "US equity ticker.", placeholder: "ticker" },
|
|
11
11
|
usListingsOnly: fails ? "SEC fails to deliver" : "FINRA weekly off-exchange volume",
|
|
12
|
+
// Both report OTC securities: a receipt over the counter (TCEHY) has its fails and its weekly volume.
|
|
13
|
+
usListingsOtc: true,
|
|
12
14
|
freshness: { source: fails ? "SEC" : "FINRA", status: "not-a-feed", basis: fails ? "settlement-date outstanding fails" : "published off-exchange volume",
|
|
13
15
|
schedule: fails ? "published twice monthly" : "published weekly with a delay", observedKey: "date", oldest: null },
|
|
14
16
|
discovery: {
|
|
@@ -14,6 +14,7 @@ export const shortWatchHeadless: HeadlessPaneDefinition<"rows"> = {
|
|
|
14
14
|
freshness: { source: "FINRA", status: "not-a-feed", basis: "twice-monthly settlement", observedKey: "settlementDate", maxAgeMinutes: 30 * 24 * 60 },
|
|
15
15
|
argument: { kind: "symbol-list", maximum: SHORT_WATCH_LIMIT, description: "US tickers; the pane defaults to your portfolios and watchlists." },
|
|
16
16
|
usListingsOnly: "FINRA short interest",
|
|
17
|
+
usListingsOtc: true,
|
|
17
18
|
failsWithoutData: true,
|
|
18
19
|
options: [],
|
|
19
20
|
describe: "Short squeeze watch",
|
|
@@ -17,6 +17,7 @@ import { fetchSwapCurve, loadSavedCurve, loadSavedWorldRows } from "./client";
|
|
|
17
17
|
import { savedCopyMark } from "../../../data/saved-copies";
|
|
18
18
|
import { formatSwapBp, selectedSwapTenor } from "./swaps-model";
|
|
19
19
|
import { logFailure } from "../../../utils/log-failure";
|
|
20
|
+
import { usBondMarketClosedNote } from "../../../market-data/us-bond-market";
|
|
20
21
|
|
|
21
22
|
const percent = (value: unknown) => value == null ? "-" : `${Number(value).toFixed(2)}%`;
|
|
22
23
|
/** A move already in basis points: `+3bp`, `-1bp`, `0bp`. */
|
|
@@ -237,6 +238,9 @@ export function createYieldCurveHeadless(
|
|
|
237
238
|
: data.seriesSource ? data.seriesSource
|
|
238
239
|
: data.seriesSource === null ? "FRED" : CURVE_PUBLISHERS[curve];
|
|
239
240
|
const cutoff = curveCutoff(curve);
|
|
241
|
+
// A US curve asked for a day the bond market was shut says so, and which day it shows (Veterans Day shows the day before).
|
|
242
|
+
const closed = requestedDate && session && CURVE_MARKETS[curve] === "US" ? usBondMarketClosedNote(requestedDate, session) : null;
|
|
243
|
+
const notes = [...(ranked ? [RANK_NOTE] : []), ...(closed ? [closed] : [])];
|
|
240
244
|
return {
|
|
241
245
|
// A stored curve cites its publisher. FRED's fallback cites info.source, not that publisher.
|
|
242
246
|
// A Treasury curve names when in the day it was taken, beside its date.
|
|
@@ -244,7 +248,7 @@ export function createYieldCurveHeadless(
|
|
|
244
248
|
...(cutoff ? { schedule: cutoff } : {}),
|
|
245
249
|
...(requestedDate ? { basis: "historical curve" } : { basis: "daily curve", cadence: "daily" }) },
|
|
246
250
|
...(comparePoints ? { columns: compareColumns(compareAsOf) } : ranked ? { columns: RANKED_COLUMNS } : {}),
|
|
247
|
-
...(
|
|
251
|
+
...(notes.length ? { notes } : {}),
|
|
248
252
|
// The spreads the pane shows over its table, each with its day move and where it sits in the last year.
|
|
249
253
|
...(spreads.length ? { textSections: [{ title: "Spreads", entries: spreads.map((figure) => {
|
|
250
254
|
const text = curveSpreadText(figure);
|
|
@@ -40,6 +40,7 @@ import { SwapsTab } from "./swaps";
|
|
|
40
40
|
import {
|
|
41
41
|
cachedCurve, cachedWorldRows, curveViewCache, loadSavedCurve, loadSavedWorldRows, swapCurveCache, worldCurvesCache,
|
|
42
42
|
} from "./client";
|
|
43
|
+
import { usBondMarketClosedNote } from "../../../market-data/us-bond-market";
|
|
43
44
|
|
|
44
45
|
type GcTab = "curve" | "world" | "swaps";
|
|
45
46
|
const TABS = [{ label: "Curve", value: "curve" }, { label: "World", value: "world" }, { label: "Swaps", value: "swaps" }];
|
|
@@ -260,9 +261,13 @@ function CurveTab({ curve, onCurveChange, focused, width, height }: {
|
|
|
260
261
|
// Both look-backs share one request per tenor, so they usually fail together.
|
|
261
262
|
const lookbackFailures = [...new Set((fredLookbacks ?? []).flatMap((lookback) => lookback.points ? [] : [lookback.error]))]
|
|
262
263
|
.map((message) => `${andList((fredLookbacks ?? []).filter((lookback) => lookback.error === message).map((lookback) => lookback.id))} look-back unavailable: ${message}`);
|
|
264
|
+
// A Treasury curve asked for a day the bond market was shut (Veterans Day) says so, and which day it shows.
|
|
265
|
+
const closedDay = requestedDate && asOf && (curve === "us" || curve === "us-real" || curve === "us-breakeven")
|
|
266
|
+
? usBondMarketClosedNote(requestedDate, asOf) : null;
|
|
263
267
|
usePaneNoticeFooter({
|
|
264
268
|
registrationId: "yield-curve:notices",
|
|
265
269
|
notices: [
|
|
270
|
+
closedDay ? `${closedDay}.` : null,
|
|
266
271
|
!asOf && points.some((point) => point.yield != null) ? "The tenors carry mixed or unknown observation dates, so the curve is not one session." : null,
|
|
267
272
|
missingTenors.length ? `Unavailable tenors: ${missingTenors.join(", ")}.` : null,
|
|
268
273
|
points.some((point) => point.stale) ? "Some tenors are cached values because their refresh failed." : null,
|
|
@@ -25,6 +25,8 @@ import {
|
|
|
25
25
|
type MarketFormatOptions,
|
|
26
26
|
} from "../market-data/market/format";
|
|
27
27
|
import {
|
|
28
|
+
EXTENDED_SESSION_MARKS,
|
|
29
|
+
extendedPrintSession,
|
|
28
30
|
getActiveQuoteDisplay,
|
|
29
31
|
getCompletedRegularSessionDisplay,
|
|
30
32
|
getExtendedSessionDisplay,
|
|
@@ -33,6 +35,7 @@ import {
|
|
|
33
35
|
marketStateDot,
|
|
34
36
|
quoteDotMarketState,
|
|
35
37
|
type ActiveQuoteDisplay,
|
|
38
|
+
type SessionPriceDisplay,
|
|
36
39
|
} from "../market-data/market/status";
|
|
37
40
|
import { formatOptionTicker } from "../utils/options";
|
|
38
41
|
import { distributionHistory, forwardYieldMayHaveLapsed, lapsedDividend } from "../utils/forward-dividend";
|
|
@@ -119,7 +122,12 @@ export interface ColumnContext {
|
|
|
119
122
|
fxDayMoves?: ReadonlyMap<string, number>;
|
|
120
123
|
/** Clock for quote age (per second while shown) and day-based columns. */
|
|
121
124
|
now: number;
|
|
122
|
-
/**
|
|
125
|
+
/**
|
|
126
|
+
* What market values, P&L, weights and the day's move are priced at, and
|
|
127
|
+
* LAST, CHG and CHG% show with it (rowHeadlineDisplay). Absent, as in a
|
|
128
|
+
* list that values nothing (a watchlist), the values are at the latest print
|
|
129
|
+
* and LAST is the regular session's, as `quote` heads it.
|
|
130
|
+
*/
|
|
123
131
|
valuationBasis?: PortfolioValuationBasis;
|
|
124
132
|
/**
|
|
125
133
|
* What a portfolio's weights divide by (allocationWeightBase): its priced
|
|
@@ -344,15 +352,15 @@ function tradedQuoteDisplay(
|
|
|
344
352
|
}
|
|
345
353
|
|
|
346
354
|
/**
|
|
347
|
-
*
|
|
348
|
-
*
|
|
349
|
-
* move, frozen, because the EXT%
|
|
350
|
-
* from that close. Until the close,
|
|
351
|
-
* pre-market quote without it, venues
|
|
352
|
-
* as above.
|
|
353
|
-
*
|
|
354
|
-
*
|
|
355
|
-
*
|
|
355
|
+
* The regular session's price and move, as `quote` heads Last: once the
|
|
356
|
+
* session is over, and in the pre-market while the quote carries the last
|
|
357
|
+
* session's close and move, that close and its move, frozen, because the EXT%
|
|
358
|
+
* column carries the extended print measured from that close. Until the close,
|
|
359
|
+
* and wherever no close is reported (a pre-market quote without it, venues
|
|
360
|
+
* without extended hours), the traded price as above. A watchlist's LAST and
|
|
361
|
+
* CHG% (its Avg Day averages this CHG%), and a book's valued at the regular
|
|
362
|
+
* close, which is this price; a book valued at the latest print shows that
|
|
363
|
+
* print instead (rowHeadlineDisplay).
|
|
356
364
|
*/
|
|
357
365
|
export function headlineQuoteDisplay(
|
|
358
366
|
traded: ActiveQuoteDisplay | null,
|
|
@@ -361,6 +369,26 @@ export function headlineQuoteDisplay(
|
|
|
361
369
|
return traded ? getCompletedRegularSessionDisplay(quote) ?? traded : null;
|
|
362
370
|
}
|
|
363
371
|
|
|
372
|
+
/**
|
|
373
|
+
* LAST, CHG and CHG% of a row: the price its figures use, so LAST times the
|
|
374
|
+
* shares is MKT VAL and CHG times them is DAY. In a book valued at the latest
|
|
375
|
+
* print, that print and its move from the close DAY measures from, naming its
|
|
376
|
+
* session when it is a pre-market, after-hours or overnight trade (`AH
|
|
377
|
+
* 158.78`); an option shows its trade, valued at its mark. A book at the
|
|
378
|
+
* regular close, and a list that values nothing (no `valuationBasis`, a
|
|
379
|
+
* watchlist), show the regular session as `quote` heads it
|
|
380
|
+
* (headlineQuoteDisplay), with the extended print in EXT%.
|
|
381
|
+
*/
|
|
382
|
+
function rowHeadlineDisplay(
|
|
383
|
+
traded: ActiveQuoteDisplay | null,
|
|
384
|
+
quote: TickerFinancials["quote"],
|
|
385
|
+
ctx: Pick<ColumnContext, "valuationBasis">,
|
|
386
|
+
): SessionPriceDisplay | null {
|
|
387
|
+
if (ctx.valuationBasis !== "latest-print" || !traded) return headlineQuoteDisplay(traded, quote);
|
|
388
|
+
const session = extendedPrintSession(quote, traded.price);
|
|
389
|
+
return session ? { ...traded, session } : traded;
|
|
390
|
+
}
|
|
391
|
+
|
|
364
392
|
/** CHG% as shown: the headline's, else the quote's own when no position price is usable. */
|
|
365
393
|
function headlineChangePercent(
|
|
366
394
|
headline: ActiveQuoteDisplay | null,
|
|
@@ -546,7 +574,7 @@ export function getColumnValue(
|
|
|
546
574
|
const liveQuote = getPortfolioQuoteDisplay(positionMetrics, quote);
|
|
547
575
|
const activeQuote = getPortfolioValuationDisplay(positionMetrics, quote, ctx.valuationBasis, futures?.settlement);
|
|
548
576
|
const displayQuote = tradedQuoteDisplay(positionMetrics, liveQuote, quote);
|
|
549
|
-
const headlineQuote = settledHeadline(positionMetrics, ctx, futures) ??
|
|
577
|
+
const headlineQuote: SessionPriceDisplay | null = settledHeadline(positionMetrics, ctx, futures) ?? rowHeadlineDisplay(displayQuote, quote, ctx);
|
|
550
578
|
const { positionCurrency, totalShares, totalCost, totalCostUnits, totalPriceUnits, multiplierHint, brokerMarkPrice } = positionMetrics;
|
|
551
579
|
|
|
552
580
|
const toBaseQuote = (value: number) =>
|
|
@@ -598,8 +626,13 @@ export function getColumnValue(
|
|
|
598
626
|
return { text: compactText(ticker.metadata.industry || financials?.profile?.industry) };
|
|
599
627
|
case "tags":
|
|
600
628
|
return { text: ticker.metadata.tags.length > 0 ? ticker.metadata.tags.join(",") : "—" };
|
|
601
|
-
case "price":
|
|
602
|
-
|
|
629
|
+
case "price": {
|
|
630
|
+
const cell = resolvePortfolioPriceValue(headlineQuote, brokerMarkPrice, headlineQuote ? currentQuoteOptions : markOptions, col.width, quote?.marketState);
|
|
631
|
+
// An extended-hours print says which session it is from, before it so the digits stay aligned: AH 158.78.
|
|
632
|
+
// The table widens the column to fit; an export keeps the price.
|
|
633
|
+
const session = headlineQuote?.session;
|
|
634
|
+
return session ? { ...cell, text: `${EXTENDED_SESSION_MARKS[session]} ${cell.text}`, value: headlineQuote.price } : cell;
|
|
635
|
+
}
|
|
603
636
|
case "change":
|
|
604
637
|
if (!headlineQuote) return { text: "—" };
|
|
605
638
|
// A listing that no longer trades has no day's move: its last session's is years old.
|
|
@@ -832,7 +865,7 @@ export function getSortValue(
|
|
|
832
865
|
const liveQuote = getPortfolioQuoteDisplay(positionMetrics, quote);
|
|
833
866
|
const activeQuote = getPortfolioValuationDisplay(positionMetrics, quote, ctx.valuationBasis, futures?.settlement);
|
|
834
867
|
const displayQuote = tradedQuoteDisplay(positionMetrics, liveQuote, quote);
|
|
835
|
-
const headlineQuote = settledHeadline(positionMetrics, ctx, futures) ??
|
|
868
|
+
const headlineQuote = settledHeadline(positionMetrics, ctx, futures) ?? rowHeadlineDisplay(displayQuote, quote, ctx);
|
|
836
869
|
const { positionCurrency, totalShares, totalCost, totalCostUnits, totalPriceUnits, brokerMarkPrice } = positionMetrics;
|
|
837
870
|
|
|
838
871
|
const toBaseQuote = (value: number) =>
|
|
@@ -3,7 +3,7 @@ import type { TickerRecord } from "../types/ticker";
|
|
|
3
3
|
import type { BrokerAccount } from "../types/trading";
|
|
4
4
|
import { isDepositaryReceiptCategory, normalizeAssetCategory } from "../utils/asset-category";
|
|
5
5
|
import { getPricePointTimestamp } from "../utils/price-history";
|
|
6
|
-
import { mergePriceHistoryIntegrity, pricePointIntegrity, type PriceHistoryIntegrity } from "../utils/price-history-integrity";
|
|
6
|
+
import { mergePriceHistoryIntegrity, pricePointCloseCopied, pricePointIntegrity, type PriceHistoryIntegrity } from "../utils/price-history-integrity";
|
|
7
7
|
|
|
8
8
|
export interface DatedReturn {
|
|
9
9
|
startDateKey: string;
|
|
@@ -107,7 +107,9 @@ export function resolveDatedReturns(history: PricePoint[]): ReturnHistoryResult
|
|
|
107
107
|
const byTimestamp = new Map<number, PricePoint>();
|
|
108
108
|
for (const point of history) {
|
|
109
109
|
const timestamp = getPricePointTimestamp(point);
|
|
110
|
-
|
|
110
|
+
// A pair's close its source copied from the open, which nothing rebuilt, is no day's close: the return runs across
|
|
111
|
+
// it from the close before, as across a holiday.
|
|
112
|
+
if (Number.isFinite(timestamp) && !pricePointCloseCopied(point)) byTimestamp.set(timestamp, point);
|
|
111
113
|
}
|
|
112
114
|
const reported = [...byTimestamp].map(([timestamp, point]) => ({ timestamp, point }));
|
|
113
115
|
const issues = reported.map(({ point }) => pricePointIntegrity(point))
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @jsxImportSource react */
|
|
2
|
-
import { useState, type CSSProperties, type ReactNode } from "react";
|
|
2
|
+
import { useLayoutEffect, useRef, useState, type CSSProperties, type ReactNode } from "react";
|
|
3
3
|
import type { ImageSurfaceProps } from "../../../ui/host";
|
|
4
4
|
import { cleanDomProps, commonStyle } from "./style";
|
|
5
5
|
|
|
@@ -11,8 +11,6 @@ type ImageStatus = "loading" | "loaded" | "failed";
|
|
|
11
11
|
* empty box while it asks again.
|
|
12
12
|
*/
|
|
13
13
|
const failedImages = new Set<string>();
|
|
14
|
-
/** Images that loaded this session: a row scrolled back into view draws its picture on its first frame, not its stand-in. */
|
|
15
|
-
const loadedImages = new Set<string>();
|
|
16
14
|
const IMAGES_KEPT = 2_000;
|
|
17
15
|
|
|
18
16
|
function remember(images: Set<string>, src: string): void {
|
|
@@ -20,9 +18,17 @@ function remember(images: Set<string>, src: string): void {
|
|
|
20
18
|
images.add(src);
|
|
21
19
|
}
|
|
22
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Every new image element starts loading, even for a picture that loaded
|
|
23
|
+
* before: what counts is whether this element has it to draw. One the
|
|
24
|
+
* browser still holds is complete at once, so a row scrolled back into view
|
|
25
|
+
* draws it on its first frame (see the layout effect); one it has to fetch
|
|
26
|
+
* again keeps the stand-in until it arrives. A loaded status carried over
|
|
27
|
+
* from another element drew the white plate behind an image not yet there,
|
|
28
|
+
* a blank white square in the desktop app for as long as the fetch took.
|
|
29
|
+
*/
|
|
23
30
|
function initialStatus(src: string): ImageStatus {
|
|
24
|
-
|
|
25
|
-
return loadedImages.has(src) ? "loaded" : "loading";
|
|
31
|
+
return failedImages.has(src) ? "failed" : "loading";
|
|
26
32
|
}
|
|
27
33
|
|
|
28
34
|
/**
|
|
@@ -37,6 +43,12 @@ export function WebImageSurface({ children, src, alt = "", objectFit = "contain"
|
|
|
37
43
|
// Keyed by the address it describes, so a row that takes another logo starts that one's own load.
|
|
38
44
|
const [known, setKnown] = useState<{ src: string; status: ImageStatus }>(() => ({ src: imageSrc, status: initialStatus(imageSrc) }));
|
|
39
45
|
const status = known.src === imageSrc ? known.status : initialStatus(imageSrc);
|
|
46
|
+
const imageRef = useRef<HTMLImageElement | null>(null);
|
|
47
|
+
// Before the frame is painted: a picture the browser already holds is drawn at once, not after its stand-in.
|
|
48
|
+
useLayoutEffect(() => {
|
|
49
|
+
const image = imageRef.current;
|
|
50
|
+
if (status === "loading" && image?.complete && image.naturalWidth > 0) setKnown({ src: imageSrc, status: "loaded" });
|
|
51
|
+
}, [imageSrc, status]);
|
|
40
52
|
const baseStyle = commonStyle(props);
|
|
41
53
|
const waiting = fallbackWhileLoading && status === "loading";
|
|
42
54
|
return (
|
|
@@ -53,13 +65,11 @@ export function WebImageSurface({ children, src, alt = "", objectFit = "contain"
|
|
|
53
65
|
<>
|
|
54
66
|
<img
|
|
55
67
|
key={imageSrc}
|
|
68
|
+
ref={imageRef}
|
|
56
69
|
src={imageSrc}
|
|
57
70
|
alt={alt}
|
|
58
71
|
draggable={false}
|
|
59
|
-
onLoad={() => {
|
|
60
|
-
remember(loadedImages, imageSrc);
|
|
61
|
-
setKnown({ src: imageSrc, status: "loaded" });
|
|
62
|
-
}}
|
|
72
|
+
onLoad={() => setKnown({ src: imageSrc, status: "loaded" })}
|
|
63
73
|
onError={() => {
|
|
64
74
|
remember(failedImages, imageSrc);
|
|
65
75
|
setKnown({ src: imageSrc, status: "failed" });
|
|
@@ -328,6 +328,10 @@ function useWebEditable<T extends HTMLInputElement | HTMLTextAreaElement>(
|
|
|
328
328
|
setCursorOffset: applyCursorOffset,
|
|
329
329
|
focus: () => elementRef.current?.focus(),
|
|
330
330
|
blur: () => elementRef.current?.blur(),
|
|
331
|
+
get focused() {
|
|
332
|
+
const element = elementRef.current;
|
|
333
|
+
return element != null && element.ownerDocument.activeElement === element;
|
|
334
|
+
},
|
|
331
335
|
};
|
|
332
336
|
|
|
333
337
|
const elementProps = {
|