@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
|
@@ -3,6 +3,7 @@ import type { PricePoint } from "../../../types/financials";
|
|
|
3
3
|
import { zonedDateTimeParts } from "../../../utils/zoned-date-time";
|
|
4
4
|
import { toBasisPoints } from "../../../utils/basis-points";
|
|
5
5
|
import { isYieldIndexSymbol } from "../../../tickers/index-roots";
|
|
6
|
+
import { pricePointCloseCopied } from "../../../utils/price-history-integrity";
|
|
6
7
|
import { MACRO_EVENT_KINDS, MACRO_EVENT_LABELS, US_MACRO_EVENT_KINDS, type MacroEventKind, type MacroRelease, type MacroReleaseFigures,
|
|
7
8
|
type MacroSurprise } from "./releases";
|
|
8
9
|
|
|
@@ -107,10 +108,18 @@ export const macroDayEventLabel = (event: Pick<MacroDayEvent, "kind" | "earnings
|
|
|
107
108
|
export const macroDayReleaseName = (event: Pick<MacroDayEvent, "kind" | "earnings">) =>
|
|
108
109
|
event.earnings ? `${MACRO_EVENT_LABELS[event.kind]} (earnings)` : MACRO_EVENT_LABELS[event.kind];
|
|
109
110
|
|
|
110
|
-
/**
|
|
111
|
+
/**
|
|
112
|
+
* One line for each release day the economic calendar covers that has no
|
|
113
|
+
* figures, or no actual, saying why, and for each whose actual is computed
|
|
114
|
+
* (a CPI's year-on-year change from the index), saying how.
|
|
115
|
+
*/
|
|
111
116
|
export const macroFigureGapNotices = (events: readonly Pick<MacroDayEvent, "kind" | "date" | "figures" | "figuresMissing">[]) =>
|
|
112
|
-
events.
|
|
113
|
-
|
|
117
|
+
events.flatMap((event) => {
|
|
118
|
+
const label = `${event.date} ${MACRO_EVENT_LABELS[event.kind]}`;
|
|
119
|
+
if (!event.figures) return event.figuresMissing ? [`${label} has no figures: ${event.figuresMissing}.`] : [];
|
|
120
|
+
if (event.figures.computed) return [`${label} actual is ${event.figures.computed}.`];
|
|
121
|
+
return event.figures.actualMissing ? [`${label} has no actual: ${event.figures.actualMissing}.`] : [];
|
|
122
|
+
});
|
|
114
123
|
|
|
115
124
|
/** What a row adds to its release's name: a policy decision's move, and the earnings marker. */
|
|
116
125
|
export const macroDayEventNote = (event: Pick<MacroDayEvent, "earnings" | "figures">) =>
|
|
@@ -191,17 +200,20 @@ export function projectMacroDays(history: readonly PricePoint[], options: {
|
|
|
191
200
|
const { coveredThrough } = options;
|
|
192
201
|
const basis = options.basis ?? macroDayMoveBasis(options.symbol);
|
|
193
202
|
const byDate = new Map<string, number>();
|
|
203
|
+
// A pair's sessions whose close the source copied from the open, which nothing rebuilt: no move into or out of them is a day's.
|
|
204
|
+
const copied = new Set<string>();
|
|
194
205
|
for (const point of history) {
|
|
195
206
|
const time = new Date(point.date).getTime();
|
|
196
207
|
// A yield can sit at zero or below it; a price cannot.
|
|
197
208
|
if (!Number.isFinite(time) || !Number.isFinite(point.close) || (basis === "return" && point.close <= 0)) continue;
|
|
198
209
|
byDate.set(sessionDate(time), point.close);
|
|
210
|
+
if (pricePointCloseCopied(point)) copied.add(sessionDate(time));
|
|
199
211
|
}
|
|
200
212
|
const sessions = [...byDate.keys()].sort();
|
|
201
213
|
const last = sessions.at(-1) ?? null;
|
|
202
214
|
const empty = (): MacroDayStats => stats([], null);
|
|
203
215
|
const kinds = MACRO_EVENT_KINDS.filter((kind) => US_KINDS.has(kind) || options.releases.some((release) => release.kind === kind));
|
|
204
|
-
if (!last) return { symbol: options.symbol, basis, events: [], kinds, byKind: { cpi: empty(), jobs: empty(), fomc: empty(), ipca: empty() },
|
|
216
|
+
if (!last) return { symbol: options.symbol, basis, events: [], kinds, byKind: { cpi: empty(), jobs: empty(), fomc: empty(), ipca: empty(), ecb: empty() },
|
|
205
217
|
allEvents: empty(), earnings: empty(), normal: empty(), start: null, asOf: null };
|
|
206
218
|
|
|
207
219
|
// Sessions after the published lists end may be unlisted release days, so they are left out of both sides.
|
|
@@ -217,6 +229,7 @@ export function projectMacroDays(history: readonly PricePoint[], options: {
|
|
|
217
229
|
for (let index = 1; index < sessions.length; index++) {
|
|
218
230
|
const date = sessions[index]!, previous = sessions[index - 1]!;
|
|
219
231
|
if (date <= start || date > end || dayNumber(date) - dayNumber(previous) > MAX_SESSION_GAP_DAYS) continue;
|
|
232
|
+
if (copied.has(date) || copied.has(previous)) continue;
|
|
220
233
|
moves.set(date, basis === "yield" ? byDate.get(date)! - byDate.get(previous)! : byDate.get(date)! / byDate.get(previous)! - 1);
|
|
221
234
|
}
|
|
222
235
|
|
|
@@ -1,26 +1,35 @@
|
|
|
1
1
|
// Published release days, not a rule engine: the dates each release came
|
|
2
2
|
// out, read from the publishers' own archives. A release cancelled or moved (the
|
|
3
3
|
// 2025 shutdown) is as published, and a scheduled date is not a release day
|
|
4
|
-
// until it is out. Dates are New York calendar days. Brazil's IPCA days
|
|
5
|
-
// from Gloom Cloud only; the list the app ships with
|
|
4
|
+
// until it is out. Dates are New York calendar days. Brazil's IPCA days and the
|
|
5
|
+
// ECB's decision days come from Gloom Cloud only; the list the app ships with
|
|
6
|
+
// has the US releases.
|
|
6
7
|
import { zonedDateKey } from "../../../utils/zoned-date-time";
|
|
7
8
|
import { MACRO_RELEASE_TABLE } from "./release-table";
|
|
8
9
|
|
|
9
10
|
/** The US releases the bundled list carries, and the ones HIVG reads around. */
|
|
10
11
|
export type UsMacroEventKind = "cpi" | "jobs" | "fomc";
|
|
11
|
-
export type MacroEventKind = UsMacroEventKind | "ipca";
|
|
12
|
+
export type MacroEventKind = UsMacroEventKind | "ipca" | "ecb";
|
|
12
13
|
|
|
13
14
|
export const US_MACRO_EVENT_KINDS: readonly UsMacroEventKind[] = ["cpi", "jobs", "fomc"];
|
|
14
|
-
|
|
15
|
+
/** The releases Gloom Cloud alone lists: Brazil's IPCA and the ECB's decisions. */
|
|
16
|
+
const SERVED_MACRO_EVENT_KINDS = ["ipca", "ecb"] as const satisfies readonly MacroEventKind[];
|
|
17
|
+
export const MACRO_EVENT_KINDS: readonly MacroEventKind[] = [...US_MACRO_EVENT_KINDS, ...SERVED_MACRO_EVENT_KINDS];
|
|
18
|
+
/** The releases HIVG reads around: the US ones and the ECB's decisions. */
|
|
19
|
+
export const IV_EVENT_KINDS: readonly MacroEventKind[] = [...US_MACRO_EVENT_KINDS, "ecb"];
|
|
15
20
|
|
|
16
|
-
export const MACRO_EVENT_LABELS: Record<MacroEventKind, string> = { cpi: "CPI", jobs: "Jobs", fomc: "FOMC", ipca: "IPCA" };
|
|
21
|
+
export const MACRO_EVENT_LABELS: Record<MacroEventKind, string> = { cpi: "CPI", jobs: "Jobs", fomc: "FOMC", ipca: "IPCA", ecb: "ECB" };
|
|
17
22
|
|
|
18
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* BLS news release archives for CPI and the Employment Situation, the Federal Reserve's meeting calendar, IBGE's
|
|
25
|
+
* calendar, the ECB's monetary policy decisions.
|
|
26
|
+
*/
|
|
19
27
|
export const MACRO_RELEASE_SOURCES: Record<MacroEventKind, string> = {
|
|
20
28
|
cpi: "https://www.bls.gov/bls/news-release/cpi.htm",
|
|
21
29
|
jobs: "https://www.bls.gov/bls/news-release/empsit.htm",
|
|
22
30
|
fomc: "https://www.federalreserve.gov/monetarypolicy/fomccalendars.htm",
|
|
23
31
|
ipca: "https://www.ibge.gov.br/calendario-indicadores-novoportal.html",
|
|
32
|
+
ecb: "https://www.ecb.europa.eu/press/govcdec/mopo/html/index.en.html",
|
|
24
33
|
};
|
|
25
34
|
|
|
26
35
|
/** A list more than this many days behind today says so: a release day may be missing from its end. */
|
|
@@ -41,6 +50,10 @@ export interface MacroReleaseFigures {
|
|
|
41
50
|
surprise: MacroSurprise | null;
|
|
42
51
|
/** A policy decision's move: "held", "cut 25bp", "raised 50bp". */
|
|
43
52
|
decision?: string;
|
|
53
|
+
/** How the actual was computed where the calendar lists none: a CPI's year-on-year change from the index. */
|
|
54
|
+
computed?: string;
|
|
55
|
+
/** Why a day with a consensus or a prior has no actual, where it cannot be computed either. */
|
|
56
|
+
actualMissing?: string;
|
|
44
57
|
}
|
|
45
58
|
|
|
46
59
|
export interface MacroRelease {
|
|
@@ -56,8 +69,10 @@ export interface MacroReleaseList {
|
|
|
56
69
|
releases: MacroRelease[];
|
|
57
70
|
/** The last day the list is complete for: later sessions are left out, release day or not. */
|
|
58
71
|
coveredThrough: string;
|
|
59
|
-
/** The first day Gloom Cloud's economic calendar covers:
|
|
72
|
+
/** The first day Gloom Cloud's economic calendar covers: days before it have no figures. */
|
|
60
73
|
figuresFrom?: string;
|
|
74
|
+
/** The ECB's next decision, which Gloom Cloud lists ahead. */
|
|
75
|
+
scheduled?: { ecb?: string };
|
|
61
76
|
}
|
|
62
77
|
|
|
63
78
|
const DAY_MS = 86_400_000;
|
|
@@ -81,14 +96,17 @@ function servedFigures(value: unknown): MacroReleaseFigures | undefined {
|
|
|
81
96
|
if (!event) return undefined;
|
|
82
97
|
const surprise = MACRO_SURPRISES.find((candidate) => candidate === figures?.surprise) ?? null;
|
|
83
98
|
const decision = text(figures?.decision);
|
|
99
|
+
const computed = text(figures?.computed);
|
|
100
|
+
const actualMissing = text(figures?.actualMissing);
|
|
84
101
|
return { event, actual: text(figures?.actual), forecast: text(figures?.forecast), prior: text(figures?.prior), surprise,
|
|
85
|
-
...(decision ? { decision } : {}) };
|
|
102
|
+
...(decision ? { decision } : {}), ...(computed ? { computed } : {}), ...(actualMissing ? { actualMissing } : {}) };
|
|
86
103
|
}
|
|
87
104
|
|
|
88
105
|
/**
|
|
89
106
|
* The served list extends the floor past its end; the floor keeps its own
|
|
90
|
-
* days up to there. IPCA, which the floor does not
|
|
91
|
-
* through its end, and left out when the server
|
|
107
|
+
* days up to there. IPCA and the ECB's decisions, which the floor does not
|
|
108
|
+
* carry, are the served list's through its end, and left out when the server
|
|
109
|
+
* lists none. Every day, the
|
|
92
110
|
* floor's included, takes the figures the server has for it, or the reason it
|
|
93
111
|
* gives for having none, whether or not the served list reaches past the
|
|
94
112
|
* floor's end; US days before its economic calendar (`figuresFrom`) have none.
|
|
@@ -97,7 +115,7 @@ function servedFigures(value: unknown): MacroReleaseFigures | undefined {
|
|
|
97
115
|
export function mergeMacroReleases(floor: MacroReleaseList, served: unknown): MacroReleaseList {
|
|
98
116
|
const payload = served as { coveredThrough?: unknown; releases?: Partial<Record<MacroEventKind, unknown>>;
|
|
99
117
|
figures?: Partial<Record<MacroEventKind, Record<string, unknown>>>; figuresFrom?: unknown;
|
|
100
|
-
figureGaps?: Partial<Record<MacroEventKind, Record<string, unknown
|
|
118
|
+
figureGaps?: Partial<Record<MacroEventKind, Record<string, unknown>>>; scheduled?: { ecb?: unknown } } | null;
|
|
101
119
|
const servedThrough = payload?.coveredThrough;
|
|
102
120
|
if (!isDate(servedThrough)) return floor;
|
|
103
121
|
// The list is complete through the later of the two ends; a served list that stops short of the floor's adds figures only.
|
|
@@ -110,18 +128,21 @@ export function mergeMacroReleases(floor: MacroReleaseList, served: unknown): Ma
|
|
|
110
128
|
if (date > floor.coveredThrough && date <= servedThrough) later.push({ kind, date });
|
|
111
129
|
}
|
|
112
130
|
}
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
131
|
+
for (const kind of SERVED_MACRO_EVENT_KINDS) {
|
|
132
|
+
const dates = payload?.releases?.[kind];
|
|
133
|
+
if (!Array.isArray(dates) || !dates.every(isDate)) continue;
|
|
134
|
+
for (const date of new Set(dates)) if (date <= servedThrough) later.push({ kind, date });
|
|
116
135
|
}
|
|
117
136
|
const figuresFrom = isDate(payload?.figuresFrom) ? payload.figuresFrom : null;
|
|
137
|
+
const nextEcb = isDate(payload?.scheduled?.ecb) ? payload.scheduled.ecb : null;
|
|
118
138
|
const figuresOf = (release: MacroRelease): MacroRelease => {
|
|
119
139
|
const figures = servedFigures(payload?.figures?.[release.kind]?.[release.date]);
|
|
120
140
|
if (figures) return { ...release, figures };
|
|
121
141
|
const missing = text(payload?.figureGaps?.[release.kind]?.[release.date]);
|
|
122
142
|
return missing ? { ...release, figuresMissing: missing } : release;
|
|
123
143
|
};
|
|
124
|
-
return { releases: [...floor.releases, ...later].map(figuresOf).sort(byDate), coveredThrough, ...(figuresFrom ? { figuresFrom } : {})
|
|
144
|
+
return { releases: [...floor.releases, ...later].map(figuresOf).sort(byDate), coveredThrough, ...(figuresFrom ? { figuresFrom } : {}),
|
|
145
|
+
...(nextEcb ? { scheduled: { ecb: nextEcb } } : {}) };
|
|
125
146
|
}
|
|
126
147
|
|
|
127
148
|
/** Whole days from the list's last covered day to today in New York. */
|
|
@@ -281,8 +281,9 @@ const HALT_COLUMNS: readonly HaltColumn[] = [
|
|
|
281
281
|
{ id: "date", label: "DATE ET", width: 9, align: "left" },
|
|
282
282
|
{ id: "age", label: "AGE", width: 6, align: "right" },
|
|
283
283
|
{ id: "halted", label: "HALT ET", width: 9, align: "left" },
|
|
284
|
-
|
|
285
|
-
{ id: "
|
|
284
|
+
// Set when quoting and trading resume: a halt still in force has neither.
|
|
285
|
+
{ id: "quote", label: "QUOTE ET", width: 11, align: "left", mayBeBlank: true },
|
|
286
|
+
{ id: "trade", label: "TRADE ET", width: 11, align: "left", mayBeBlank: true },
|
|
286
287
|
{ id: "duration", label: "HALTED FOR", width: 12, align: "right" },
|
|
287
288
|
{ id: "status", label: "STATUS", width: 8, align: "left" },
|
|
288
289
|
];
|
|
@@ -172,7 +172,8 @@ export function createMarketMoversHeadless(
|
|
|
172
172
|
const ranked = createRows(result.quotes);
|
|
173
173
|
// Last and Change % are the regular session; an extended print is a column of its own.
|
|
174
174
|
const extendedSessions = moverExtendedSessions(ranked);
|
|
175
|
-
|
|
175
|
+
// closedSession only tells the live overlay which session the row's volume is.
|
|
176
|
+
const rows = ranked.map(({ extended, closedSession: _closedSession, ...row }) => ({
|
|
176
177
|
...row,
|
|
177
178
|
extendedSession: extended?.session ?? null,
|
|
178
179
|
extendedPrice: extended?.price ?? null,
|
|
@@ -205,9 +205,10 @@ function ScreenerMoversBody({ activeTab, focused, width, summaryQuotes, liveStre
|
|
|
205
205
|
const rankedRows = useMemo(() => createRows(resolvedQuotes), [resolvedQuotes]);
|
|
206
206
|
// A pre-market or after-hours column only while a row has such a print.
|
|
207
207
|
const extendedSessionsKey = moverExtendedSessions(rankedRows).join(",");
|
|
208
|
+
const trending = activeTab === "trending";
|
|
208
209
|
const columns = useMemo(
|
|
209
|
-
() => buildMarketMoverColumns(width, extendedSessionsKey ? extendedSessionsKey.split(",") as ExtendedSession[] : [], { float: minFloat != null }),
|
|
210
|
-
[extendedSessionsKey, minFloat, width],
|
|
210
|
+
() => buildMarketMoverColumns(width, extendedSessionsKey ? extendedSessionsKey.split(",") as ExtendedSession[] : [], { float: minFloat != null, trending }),
|
|
211
|
+
[extendedSessionsKey, minFloat, trending, width],
|
|
211
212
|
);
|
|
212
213
|
const rows = useMemo(() => sortRows(rankedRows, sortPreference), [rankedRows, sortPreference]);
|
|
213
214
|
const selectedIdx = selectedSymbol
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { resolveCurrencyUnit } from "../../../utils/currency-units";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
getRegularSessionQuoteDisplay,
|
|
4
|
+
overlayScreenerQuoteEntries,
|
|
5
|
+
} from "../../../market-data/quotes/screener-live-quotes";
|
|
3
6
|
import {
|
|
4
7
|
getExtendedSessionDisplay,
|
|
5
8
|
getRegularSessionDisplay,
|
|
@@ -56,9 +59,15 @@ export type MarketMoverColumn = DataTableColumn & { id: MarketMoverColumnId };
|
|
|
56
59
|
/**
|
|
57
60
|
* A list row. Price and change are the regular session's, as `ticker` reads
|
|
58
61
|
* them; a row whose quote has a pre-market or after-hours print carries it in
|
|
59
|
-
* `extended`, measured from that session's close.
|
|
62
|
+
* `extended`, measured from that session's close. `closedSession` is set
|
|
63
|
+
* while they are a completed session's close and move (that session's New
|
|
64
|
+
* York date, null when the quote cannot date it), so the volume beside them
|
|
65
|
+
* is known to be that session's too.
|
|
60
66
|
*/
|
|
61
|
-
export type MoverQuote = ScreenerQuote & {
|
|
67
|
+
export type MoverQuote = ScreenerQuote & {
|
|
68
|
+
extended?: ExtendedSessionDisplay | null;
|
|
69
|
+
closedSession?: string | null;
|
|
70
|
+
};
|
|
62
71
|
export type MarketMoverRow = MoverQuote & { rank: number };
|
|
63
72
|
|
|
64
73
|
export interface MarketMoverSortPreference {
|
|
@@ -249,6 +258,12 @@ function moverExtended(quote: Quote): ExtendedSessionDisplay | null {
|
|
|
249
258
|
return extended && isFiniteNumber(extended.price) ? extended : null;
|
|
250
259
|
}
|
|
251
260
|
|
|
261
|
+
/** The completed regular session a quote's headline is, as the live overlay reads it; undefined while it is the live session's. */
|
|
262
|
+
function closedSessionOf(quote: Quote): string | null | undefined {
|
|
263
|
+
const display = getRegularSessionQuoteDisplay(quote);
|
|
264
|
+
return display?.completed ? display.closedSession : undefined;
|
|
265
|
+
}
|
|
266
|
+
|
|
252
267
|
/**
|
|
253
268
|
* A listed row as `ticker` reads its quote: Last and Chg% are the regular
|
|
254
269
|
* session's close and move, and a pre-market or after-hours print is its
|
|
@@ -275,12 +290,20 @@ export function moverRegularSession({ sessions, ...row }: ScreenerQuote): MoverQ
|
|
|
275
290
|
change: screenerNumber(headline.change),
|
|
276
291
|
changePercent: screenerNumber(headline.changePercent),
|
|
277
292
|
extended: moverExtended(quote),
|
|
293
|
+
...closedSessionField(quote),
|
|
278
294
|
};
|
|
279
295
|
}
|
|
280
296
|
|
|
297
|
+
function closedSessionField(quote: Quote): Pick<MoverQuote, "closedSession"> {
|
|
298
|
+
const closedSession = closedSessionOf(quote);
|
|
299
|
+
return closedSession === undefined ? {} : { closedSession };
|
|
300
|
+
}
|
|
301
|
+
|
|
281
302
|
/**
|
|
282
303
|
* A trending row from its quote: Last and Chg% are the regular session, as
|
|
283
304
|
* `ticker` reads it, and a pre-market or after-hours print rides beside them.
|
|
305
|
+
* The quote gives its 52-week range; it has no average volume or market cap,
|
|
306
|
+
* so the list shows no columns for them (buildMarketMoverColumns).
|
|
284
307
|
*/
|
|
285
308
|
export function screenerQuoteFromQuote(symbol: string, quote: Quote): MoverQuote {
|
|
286
309
|
const headline = getRegularSessionDisplay(quote)!;
|
|
@@ -295,14 +318,15 @@ export function screenerQuoteFromQuote(symbol: string, quote: Quote): MoverQuote
|
|
|
295
318
|
volumeRatio: null,
|
|
296
319
|
marketCap: undefined,
|
|
297
320
|
currency: quote.currency ?? "",
|
|
298
|
-
fiftyTwoWeekHigh: undefined,
|
|
299
|
-
fiftyTwoWeekLow: undefined,
|
|
321
|
+
fiftyTwoWeekHigh: screenerNumber(quote.high52w) ?? undefined,
|
|
322
|
+
fiftyTwoWeekLow: screenerNumber(quote.low52w) ?? undefined,
|
|
300
323
|
dayHigh: undefined,
|
|
301
324
|
dayLow: undefined,
|
|
302
325
|
exchange: quote.listingExchangeName ?? quote.exchangeName ?? "",
|
|
303
326
|
lastUpdated: quote.lastUpdated,
|
|
304
327
|
previousClose: screenerNumber(quote.previousClose) ?? undefined,
|
|
305
328
|
extended: moverExtended(quote),
|
|
329
|
+
...closedSessionField(quote),
|
|
306
330
|
};
|
|
307
331
|
}
|
|
308
332
|
|
|
@@ -334,11 +358,29 @@ export function formatMoverPrice(price: number | null, currency: string, referen
|
|
|
334
358
|
/** Keyed by the overlaid row, which the shared overlay keeps while its quote holds. */
|
|
335
359
|
const convertedOverlays = new WeakMap<ScreenerQuote, MoverQuote>();
|
|
336
360
|
|
|
361
|
+
/**
|
|
362
|
+
* The volume beside a quote's completed regular session on a list row: the
|
|
363
|
+
* list's, the volume of the session the row was listed in, while the quote
|
|
364
|
+
* reads that same session, as the quote's own volume is by then often the
|
|
365
|
+
* next day's (none in the pre-market); the quote's otherwise.
|
|
366
|
+
*/
|
|
367
|
+
function completedSessionVolume(original: MoverQuote, closedSession: string | null, quote: Quote): number | null {
|
|
368
|
+
const quoted = screenerVolume(quote.volume);
|
|
369
|
+
const sameSession = original.closedSession !== undefined
|
|
370
|
+
&& (original.closedSession == null || closedSession == null || original.closedSession === closedSession);
|
|
371
|
+
return sameSession ? original.volume ?? quoted : quoted;
|
|
372
|
+
}
|
|
373
|
+
|
|
337
374
|
/**
|
|
338
375
|
* Live quotes on the list's rows, which keep the list's order. Price and
|
|
339
376
|
* change are the regular session's, as `ticker` reads them, so after the
|
|
340
377
|
* close they hold at it and a pre-market or after-hours print is the row's
|
|
341
|
-
* `extended
|
|
378
|
+
* `extended`, and the volume beside that close stays the session's. A row
|
|
379
|
+
* listed as a completed session's close keeps the list's price, move, volume
|
|
380
|
+
* and extended print, taking only the quote's name, while its quote cannot
|
|
381
|
+
* name the close it follows: its own figures would read a pre-market or
|
|
382
|
+
* after-hours print as the day's move, beside rows ranked by the last
|
|
383
|
+
* session's. Range endpoints and the previous close belong to the original
|
|
342
384
|
* screener price denomination.
|
|
343
385
|
*/
|
|
344
386
|
export function overlayMarketMoverQuotes(
|
|
@@ -350,23 +392,34 @@ export function overlayMarketMoverQuotes(
|
|
|
350
392
|
if (row === original) return row;
|
|
351
393
|
const cached = convertedOverlays.get(row);
|
|
352
394
|
if (cached) return cached;
|
|
353
|
-
const convert = (value: number | undefined) => convertScreenerPriceUnit(value, original.currency, row.currency);
|
|
354
395
|
const quote = resolveEntryData(entries.get(buildQuoteKey({ symbol: row.symbol, exchange: row.exchange })));
|
|
355
|
-
const
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
...
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
396
|
+
const regular = quote ? getRegularSessionQuoteDisplay(quote) : null;
|
|
397
|
+
let converted: MoverQuote;
|
|
398
|
+
if (quote && !regular && original.closedSession !== undefined) {
|
|
399
|
+
converted = { ...original, name: row.name };
|
|
400
|
+
} else {
|
|
401
|
+
const convert = (value: number | undefined) => convertScreenerPriceUnit(value, original.currency, row.currency);
|
|
402
|
+
const headline = regular ?? (quote ? getRegularSessionDisplay(quote) : null);
|
|
403
|
+
const { closedSession: _listed, ...overlaid } = row;
|
|
404
|
+
converted = {
|
|
405
|
+
...overlaid,
|
|
406
|
+
...(quote && headline ? {
|
|
407
|
+
price: headline.price,
|
|
408
|
+
change: isFiniteNumber(headline.change) ? headline.change : null,
|
|
409
|
+
changePercent: isFiniteNumber(headline.changePercent) ? headline.changePercent : null,
|
|
410
|
+
extended: moverExtended(quote),
|
|
411
|
+
} : {}),
|
|
412
|
+
...(quote && regular?.completed ? {
|
|
413
|
+
closedSession: regular.closedSession,
|
|
414
|
+
volume: completedSessionVolume(original, regular.closedSession, quote),
|
|
415
|
+
} : {}),
|
|
416
|
+
fiftyTwoWeekLow: convert(original.fiftyTwoWeekLow),
|
|
417
|
+
fiftyTwoWeekHigh: convert(original.fiftyTwoWeekHigh),
|
|
418
|
+
dayLow: convert(original.dayLow),
|
|
419
|
+
dayHigh: convert(original.dayHigh),
|
|
420
|
+
previousClose: row.previousClose ?? convert(original.previousClose),
|
|
421
|
+
};
|
|
422
|
+
}
|
|
370
423
|
convertedOverlays.set(row, converted);
|
|
371
424
|
return converted;
|
|
372
425
|
});
|
|
@@ -350,7 +350,8 @@ function mergeCloudScreenerItem(
|
|
|
350
350
|
volume: screenerVolume(item.volume),
|
|
351
351
|
avgVolume,
|
|
352
352
|
volumeRatio: screenerVolumeRatio(screenerVolume(item.volume), avgVolume),
|
|
353
|
-
|
|
353
|
+
// The live list's own size, else the delayed list's: before the open that list can be short.
|
|
354
|
+
marketCap: screenerVolume(item.marketCap) ?? metadata?.marketCap,
|
|
354
355
|
currency,
|
|
355
356
|
fiftyTwoWeekHigh: screenerNumber(item.high52w) ?? metadataPrice(metadata?.fiftyTwoWeekHigh),
|
|
356
357
|
fiftyTwoWeekLow: screenerNumber(item.low52w) ?? metadataPrice(metadata?.fiftyTwoWeekLow),
|
|
@@ -33,12 +33,13 @@ const EXTENDED_MIN_NAME_WIDTH = 12;
|
|
|
33
33
|
* The list's columns at `width`. A pre-market or after-hours column follows
|
|
34
34
|
* CHG% for each session in `extendedSessions`, and FLOAT ends the row while a
|
|
35
35
|
* minimum float is set (`float`); to make room for them a narrow pane gives up
|
|
36
|
-
* MCAP, then 52W%, before it cuts the names short.
|
|
36
|
+
* MCAP, then 52W%, before it cuts the names short. Trending's rows are quotes,
|
|
37
|
+
* which carry no average volume or market cap: it has no V/AVG or MCAP.
|
|
37
38
|
*/
|
|
38
39
|
export function buildMarketMoverColumns(
|
|
39
40
|
width: number,
|
|
40
41
|
extendedSessions: readonly ExtendedSession[] = [],
|
|
41
|
-
options: { float?: boolean } = {},
|
|
42
|
+
options: { float?: boolean; trending?: boolean } = {},
|
|
42
43
|
): MarketMoverColumn[] {
|
|
43
44
|
const lead: MarketMoverColumn[] = [
|
|
44
45
|
{ id: "rank", label: "#", width: 3, align: "left" },
|
|
@@ -57,9 +58,9 @@ export function buildMarketMoverColumns(
|
|
|
57
58
|
];
|
|
58
59
|
const trailing: MarketMoverColumn[] = [
|
|
59
60
|
{ id: "volume", label: "VOL", width: 8, align: "right" },
|
|
60
|
-
{ id: "volumeRatio", label: "V/AVG", width: 6, align: "right" },
|
|
61
|
+
...(options.trending ? [] : [{ id: "volumeRatio" as const, label: "V/AVG", width: 6, align: "right" as const }]),
|
|
61
62
|
{ id: "range", label: "52W%", width: 6, align: "right" },
|
|
62
|
-
{ id: "marketCap", label: "MCAP", width: 8, align: "right" },
|
|
63
|
+
...(options.trending ? [] : [{ id: "marketCap" as const, label: "MCAP", width: 8, align: "right" as const }]),
|
|
63
64
|
...(options.float ? [{ id: "floatShares" as const, label: "FLOAT", width: 7, align: "right" as const }] : []),
|
|
64
65
|
];
|
|
65
66
|
// Measured the way the table draws them (a header and its sort mark widen a
|
|
@@ -67,7 +68,8 @@ export function buildMarketMoverColumns(
|
|
|
67
68
|
const nameRoom = () => width - getTableWidth([...lead, ...quote, ...trailing]) - 1;
|
|
68
69
|
for (const id of ["marketCap", "range"] as const) {
|
|
69
70
|
if ((extendedSessions.length === 0 && !options.float) || nameRoom() >= EXTENDED_MIN_NAME_WIDTH) break;
|
|
70
|
-
trailing.
|
|
71
|
+
const at = trailing.findIndex((column) => column.id === id);
|
|
72
|
+
if (at >= 0) trailing.splice(at, 1);
|
|
71
73
|
}
|
|
72
74
|
return [...lead, { id: "name", label: "NAME", width: Math.max(6, nameRoom()), align: "left" }, ...quote, ...trailing];
|
|
73
75
|
}
|
|
@@ -6,6 +6,7 @@ import { STALE_TRAILING_EPS_MS, trailingEpsSteps as sharedTrailingEpsSteps, type
|
|
|
6
6
|
import { createValuationCurrencyContext } from "../../../time-series/valuation-currency";
|
|
7
7
|
import type { FinancialStatement, PricePoint, TickerFinancials } from "../../../types/financials";
|
|
8
8
|
import { resolveCurrencyUnit } from "../../../utils/currency-units";
|
|
9
|
+
import { notTheShare } from "../../../utils/share-multiples";
|
|
9
10
|
import { datedByReport, type ReportDate } from "./report-dates";
|
|
10
11
|
|
|
11
12
|
export type { EpsStep };
|
|
@@ -209,6 +210,9 @@ export function projectPeBand(
|
|
|
209
210
|
const empty: PeBandModel = { symbol: options.symbol, currency, weeks: [], rows: [], multiples: [], current: null, range: null, sample: null, bandCeiling: null,
|
|
210
211
|
undated: 0, unavailable: 0, conversion: null, error: null, notice: null };
|
|
211
212
|
if (!financials) return { ...empty, error: "Fundamentals unavailable." };
|
|
213
|
+
// A warrant's, a right's, a unit's or an unratioed receipt's price over its company's EPS is no P/E at any date.
|
|
214
|
+
const share = notTheShare(financials);
|
|
215
|
+
if (share) return { ...empty, error: `No P/E: ${share}.` };
|
|
212
216
|
const allSteps = trailingEpsSteps(financials, options.reports);
|
|
213
217
|
const latest = allSteps.findLast((step) => step.eps != null);
|
|
214
218
|
if (!latest) return { ...empty, error: "No trailing EPS on record." };
|
|
@@ -20,9 +20,9 @@ const FX_COLUMN_IDS = new Set([
|
|
|
20
20
|
]);
|
|
21
21
|
/** Columns that divide by the portfolio's total. */
|
|
22
22
|
const ALLOCATION_COLUMN_IDS = new Set(["weight", "drift", "trade", "trade_value"]);
|
|
23
|
-
/** Columns read at the price the pane values at: the latest print or the regular close. */
|
|
23
|
+
/** Columns read at the price the pane values at: the latest print or the regular close, and LAST shows it. */
|
|
24
24
|
const VALUATION_COLUMN_IDS = new Set([
|
|
25
|
-
"mkt_value", "weight", "drift", "trade", "trade_value", "day_pnl", "pnl", "pnl_pct", "as_of",
|
|
25
|
+
"price", "change", "change_pct", "mkt_value", "weight", "drift", "trade", "trade_value", "day_pnl", "pnl", "pnl_pct", "as_of",
|
|
26
26
|
]);
|
|
27
27
|
// DIV% reads the corporate actions to measure a trailing yield and to tell a dividend that stopped, which a day can change.
|
|
28
28
|
const SUPPLEMENTAL_COLUMN_IDS = new Set(["target", "target_pct", "rating", "ex_div", "next_earn", "dividend_yield"]);
|
|
@@ -30,7 +30,7 @@ const DAY_CLOCK_COLUMN_IDS = new Set(["held", "ex_div", "next_earn", "as_of", "d
|
|
|
30
30
|
export const PERPETUAL_COLUMN_IDS: ReadonlySet<string> = new Set(["perp_premium", "perp_funding"]);
|
|
31
31
|
/** Columns a future's contract size or settlement moves: its quantity, its value, and at the close its Last. */
|
|
32
32
|
const FUTURES_TERMS_COLUMN_IDS = new Set([
|
|
33
|
-
...VALUATION_COLUMN_IDS, "shares", "cost_basis", "avg_cost",
|
|
33
|
+
...VALUATION_COLUMN_IDS, "shares", "cost_basis", "avg_cost",
|
|
34
34
|
]);
|
|
35
35
|
|
|
36
36
|
const exchangeRateVersions = new WeakMap<ReadonlyMap<string, number>, string>();
|
|
@@ -63,7 +63,7 @@ export function columnContextVersion(columnId: string, ctx: ColumnContext): stri
|
|
|
63
63
|
let version = `${ctx.activeTab ?? ""}|${ctx.baseCurrency}`;
|
|
64
64
|
if (FX_COLUMN_IDS.has(columnId)) version += `|${exchangeRatesVersion(ctx.exchangeRates)}`;
|
|
65
65
|
if (ALLOCATION_COLUMN_IDS.has(columnId)) version += `|${ctx.portfolioWeightBase ?? 0}`;
|
|
66
|
-
if (VALUATION_COLUMN_IDS.has(columnId)) version += `|${ctx.valuationBasis ?? "
|
|
66
|
+
if (VALUATION_COLUMN_IDS.has(columnId)) version += `|${ctx.valuationBasis ?? ""}`;
|
|
67
67
|
if (ALLOCATION_COLUMN_IDS.has(columnId) || columnId === "target_weight") version += `|${targetsVersion(ctx.portfolioTargets)}`;
|
|
68
68
|
if (SUPPLEMENTAL_COLUMN_IDS.has(columnId)) version += `|${ctx.supplementalVersion ?? 0}`;
|
|
69
69
|
if (PERPETUAL_COLUMN_IDS.has(columnId)) version += `|${ctx.perpetualsVersion ?? 0}`;
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
import { formatCompact, formatPercentRaw } from "../../../../utils/format";
|
|
17
17
|
import { currencyPriceMinDigits, formatMarketCostWithCurrency, formatMarketPrice, formatMarketPriceWithCurrency, formatMarketQuantity, quoteFormatOptions } from "../../../../market-data/market/format";
|
|
18
18
|
import { resolvePriceBasis } from "../../../../market-data/market/price-basis";
|
|
19
|
-
import {
|
|
19
|
+
import { dayMoveBasisLabel, futuresQuoteFromSettle, quoteChangeBasis, type QuoteChangeBasis } from "../../../../market-data/market/change-basis";
|
|
20
20
|
import { getPortfolioPositionMetrics, lotCostAtTodaysRate, lotCostFxRate, resolvePortfolioMarketValue, resolvePortfolioPositionPnl } from "../../../../portfolio/position-metrics";
|
|
21
21
|
import {
|
|
22
22
|
getPortfolioValuationDisplay,
|
|
@@ -44,6 +44,7 @@ import { resolvePortfolioTotalsCurrency } from "../summary/totals";
|
|
|
44
44
|
import {
|
|
45
45
|
EXTENDED_SESSION_LABELS,
|
|
46
46
|
exchangeShortName,
|
|
47
|
+
extendedPrintSession,
|
|
47
48
|
getActiveQuoteDisplay,
|
|
48
49
|
getCompletedRegularSessionDisplay,
|
|
49
50
|
getExtendedSessionDisplay,
|
|
@@ -643,7 +644,8 @@ async function positionDayMove(
|
|
|
643
644
|
* portfolio's currency, and that move against their value at the close
|
|
644
645
|
* before, with what it is measured from as the pane's Day says it ("vs Fri 16
|
|
645
646
|
* Oct close", "vs mixed closes"): at the latest print, the move of that print,
|
|
646
|
-
* a pre-market or after-hours one included
|
|
647
|
+
* a pre-market or after-hours one included, which the basis names ("after
|
|
648
|
+
* hours vs Tue 10 Nov close"); at the close, the regular
|
|
647
649
|
* session's. A listing that no longer trades counts as no move and names no
|
|
648
650
|
* basis. Null when any priced holding's move is unknown, as the pane's Day is.
|
|
649
651
|
*/
|
|
@@ -655,6 +657,7 @@ export function portfolioDayMove(
|
|
|
655
657
|
let previousValue = 0;
|
|
656
658
|
let fx = 0;
|
|
657
659
|
const bases: Array<QuoteChangeBasis | null> = [];
|
|
660
|
+
const prints: Array<ExtendedSession | null> = [];
|
|
658
661
|
const session = valuation.basis === "regular-close" ? "regular" : "active";
|
|
659
662
|
for (const entry of valuation.positions) {
|
|
660
663
|
if (!entry.position) continue;
|
|
@@ -662,12 +665,14 @@ export function portfolioDayMove(
|
|
|
662
665
|
change += entry.dayMove.change;
|
|
663
666
|
previousValue += entry.dayMove.previousValue;
|
|
664
667
|
fx += entry.dayMove.fx;
|
|
665
|
-
if (
|
|
668
|
+
if (entry.quote?.delisting) continue;
|
|
669
|
+
bases.push(quoteChangeBasis(entry.quote, { session, terms: entry.futures }));
|
|
670
|
+
prints.push(session === "active" ? extendedPrintSession(entry.quote, entry.valuation.valuationPrice) : null);
|
|
666
671
|
}
|
|
667
672
|
return {
|
|
668
673
|
change,
|
|
669
674
|
changePercent: previousValue !== 0 ? (change / previousValue) * 100 : null,
|
|
670
|
-
basis:
|
|
675
|
+
basis: dayMoveBasisLabel(bases, prints, { now }),
|
|
671
676
|
fx,
|
|
672
677
|
};
|
|
673
678
|
}
|
|
@@ -347,7 +347,8 @@ export function PortfolioListPane({ focused, width, height }: PaneProps) {
|
|
|
347
347
|
baseCurrency: totalsCurrency,
|
|
348
348
|
exchangeRates,
|
|
349
349
|
fxDayMoves,
|
|
350
|
-
|
|
350
|
+
// A watchlist values nothing: its LAST is the regular session's, as `quote` heads it.
|
|
351
|
+
...(isPortfolioTab ? { valuationBasis } : {}),
|
|
351
352
|
portfolioWeightBase,
|
|
352
353
|
portfolioWeightBasis,
|
|
353
354
|
portfolioTargets,
|
|
@@ -42,6 +42,11 @@ export interface PortfolioSummarySegment {
|
|
|
42
42
|
bold?: boolean;
|
|
43
43
|
}>;
|
|
44
44
|
length: number;
|
|
45
|
+
/**
|
|
46
|
+
* What the segment reads when it ends the row, the next one having no room:
|
|
47
|
+
* Val with its basis note, which the Day after it says otherwise.
|
|
48
|
+
*/
|
|
49
|
+
alone?: PortfolioSummarySegment;
|
|
45
50
|
}
|
|
46
51
|
|
|
47
52
|
export interface PortfolioSummaryAccountState {
|
|
@@ -110,6 +115,10 @@ export function fitSummarySegments(candidates: PortfolioSummarySegment[], widthB
|
|
|
110
115
|
fitted.push(segment);
|
|
111
116
|
used = nextUsed;
|
|
112
117
|
}
|
|
118
|
+
const last = fitted.at(-1);
|
|
119
|
+
if (last?.alone && fitted.length < candidates.length && used - last.length + last.alone.length <= widthBudget) {
|
|
120
|
+
fitted[fitted.length - 1] = last.alone;
|
|
121
|
+
}
|
|
113
122
|
return fitted;
|
|
114
123
|
}
|
|
115
124
|
|
|
@@ -319,14 +328,17 @@ export function buildPortfolioSummarySegments({
|
|
|
319
328
|
}
|
|
320
329
|
|
|
321
330
|
// Which price the value uses goes with it, so a narrow row never shows one without the other.
|
|
322
|
-
|
|
331
|
+
const dayNamesBasis = !accountMetrics.brokerDay && Number.isFinite(accountMetrics.dailyPnl);
|
|
332
|
+
const valParts: PortfolioSummarySegment["parts"] = [
|
|
323
333
|
{ text: broker || totals.hasShorts ? "Gross" : "Val", tone: "label" },
|
|
324
334
|
{ text: money(totalMarketValue), tone: "value", bold: true },
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
]));
|
|
335
|
+
];
|
|
336
|
+
const noted = valuationBasis ? createSummarySegment("val", [...valParts, {
|
|
337
|
+
text: valuationBasis === "regular-close" && totals.hasFutures ? PRICED_AT_SETTLE_TEXT : PRICED_AT_TEXT[valuationBasis],
|
|
338
|
+
tone: "muted",
|
|
339
|
+
}]) : createSummarySegment("val", valParts);
|
|
340
|
+
candidates.push(noted);
|
|
341
|
+
const valIndex = candidates.length - 1;
|
|
330
342
|
|
|
331
343
|
if (totals.hasShorts && totals.netMktValue != null) {
|
|
332
344
|
candidates.push(createSummarySegment("net-value", [
|
|
@@ -364,8 +376,13 @@ export function buildPortfolioSummarySegments({
|
|
|
364
376
|
{ text: money(accountMetrics.dailyPnl, true), tone: "value", color: priceColor(accountMetrics.dailyPnl), bold: true },
|
|
365
377
|
{ text: `(${formatPercentRaw(accountMetrics.dailyPnlPct)}${holdingsOnly ? " ex cash" : ""})`, tone: "muted", color: shownPriceColor(accountMetrics.dailyPnlPct, 2) },
|
|
366
378
|
// The broker's own day is from its account's close, not the quotes': it names none.
|
|
367
|
-
...(
|
|
379
|
+
...(dayNamesBasis ? dayBasisPart(totals) : []),
|
|
368
380
|
]));
|
|
381
|
+
// Right after Val, a Day that names its extended-hours print ("AH vs Tue 10 Nov close") says what the value is
|
|
382
|
+
// priced at: Val leaves its note to it, and keeps it on a row with no room for the Day.
|
|
383
|
+
if (valuationBasis === "latest-print" && totals.dayAtExtendedPrint && dayNamesBasis && valIndex === candidates.length - 2) {
|
|
384
|
+
candidates[valIndex] = { ...createSummarySegment("val", valParts), alone: noted };
|
|
385
|
+
}
|
|
369
386
|
if (!period) candidates.push(createSummarySegment("pnl", [
|
|
370
387
|
{ text: !Number.isFinite(account?.unrealizedPnl)
|
|
371
388
|
&& totals.unrealizedPnlBasis === "broker-snapshot" ? "Broker P&L"
|