gloomberb 0.19.4 → 0.19.5
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 +3 -1
- package/src/cli/commands/command-utils.ts +4 -0
- package/src/cli/commands/market.ts +119 -27
- package/src/cli/commands/search.ts +1 -1
- package/src/cli/commands/ticker.ts +10 -6
- package/src/cli/currency-name-hint.ts +60 -0
- package/src/cli/history-rows.ts +18 -1
- package/src/cli/known-gaps.ts +17 -2
- package/src/cli/not-a-ticker.ts +5 -3
- package/src/cli/pane-functions/catalog.ts +9 -1
- package/src/cli/pane-functions/headless.ts +7 -3
- package/src/cli/pane-functions/market-session.ts +6 -7
- package/src/cli/series-search.ts +4 -5
- package/src/components/chart/composite/panel-bitmap.ts +28 -2
- package/src/components/chart/composite/time-axis.ts +17 -2
- package/src/components/layout/shell/active-drag.ts +38 -7
- package/src/components/layout/shell/drag/magnets.ts +106 -0
- package/src/components/layout/window-controls.tsx +96 -35
- package/src/components/layout/window-fullscreen.ts +20 -0
- package/src/components/quote-flash.ts +36 -32
- package/src/market-data/coordinator/events.ts +17 -1
- package/src/market-data/frame-scheduler.ts +47 -10
- package/src/market-data/frame-wake.ts +74 -0
- package/src/market-data/futures-board.ts +7 -6
- package/src/market-data/hooks.tsx +12 -3
- package/src/market-data/performance.ts +78 -9
- package/src/market-data/request-types.ts +6 -3
- package/src/plugins/builtin/alerts/cli.ts +2 -1
- package/src/plugins/builtin/analytics/risk-evidence.ts +1 -0
- package/src/plugins/builtin/attention/evidence.ts +1 -1
- package/src/plugins/builtin/awards/client.ts +1 -1
- package/src/plugins/builtin/awards/evidence.ts +1 -1
- package/src/plugins/builtin/awards/pane.tsx +2 -1
- package/src/plugins/builtin/bond-calculator/math.ts +1 -1
- package/src/plugins/builtin/broker-manager/footer.ts +3 -2
- package/src/plugins/builtin/broker-manager/index.tsx +2 -1
- package/src/plugins/builtin/broker-manager/keyboard.ts +2 -1
- package/src/plugins/builtin/catalysts/evidence.ts +1 -1
- package/src/plugins/builtin/catalysts/pane.tsx +2 -1
- package/src/plugins/builtin/chart-composer/headless.ts +40 -1
- package/src/plugins/builtin/cloud-tweets/table.tsx +3 -2
- package/src/plugins/builtin/comment-letters/client.ts +2 -1
- package/src/plugins/builtin/company-kpis/client.ts +1 -1
- package/src/plugins/builtin/company-kpis/pane.tsx +2 -1
- package/src/plugins/builtin/company-kpis/screenshot-evidence.ts +3 -2
- package/src/plugins/builtin/cot/headless.ts +9 -3
- package/src/plugins/builtin/cot/model.ts +44 -3
- package/src/plugins/builtin/credit-documents/client.ts +1 -1
- package/src/plugins/builtin/credit-documents/evidence.ts +1 -1
- package/src/plugins/builtin/credit-documents/pane.tsx +2 -1
- package/src/plugins/builtin/earnings-calls/pane.tsx +1 -1
- package/src/plugins/builtin/earnings-ripple/index.tsx +6 -1
- package/src/plugins/builtin/econ/calendar-model.ts +2 -0
- package/src/plugins/builtin/econ/fred-catalog.ts +5 -5
- package/src/plugins/builtin/econ/print-watch.ts +3 -1
- package/src/plugins/builtin/futures/series.ts +16 -1
- package/src/plugins/builtin/fx-matrix/headless.ts +4 -2
- package/src/plugins/builtin/fx-matrix/index.tsx +37 -3
- package/src/plugins/builtin/fx-matrix/pairs.ts +15 -0
- package/src/plugins/builtin/gpu/headless.ts +2 -1
- package/src/plugins/builtin/help/function-card.tsx +2 -1
- package/src/plugins/builtin/help/index.tsx +2 -1
- package/src/plugins/builtin/insider/display.ts +45 -6
- package/src/plugins/builtin/ipo-calendar/model.ts +2 -0
- package/src/plugins/builtin/iv-history/client.ts +2 -1
- package/src/plugins/builtin/iv-history/headless.ts +2 -1
- package/src/plugins/builtin/jobs/pages.ts +4 -4
- package/src/plugins/builtin/kelly-sizer/headless.ts +2 -1
- package/src/plugins/builtin/market-heatmap/index.tsx +2 -1
- package/src/plugins/builtin/members/client.ts +1 -1
- package/src/plugins/builtin/mna/distress/client.ts +1 -0
- package/src/plugins/builtin/mna/pane.tsx +4 -1
- package/src/plugins/builtin/options/market-reference.ts +1 -1
- package/src/plugins/builtin/options/open-interest-as-of.ts +3 -1
- package/src/plugins/builtin/options/view.tsx +2 -1
- package/src/plugins/builtin/options-calculator/evidence.ts +1 -1
- package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +1 -1
- package/src/plugins/builtin/options-scenario/csp-screen.ts +8 -4
- package/src/plugins/builtin/options-scenario/csp.ts +28 -9
- package/src/plugins/builtin/options-scenario/evidence.ts +5 -4
- package/src/plugins/builtin/options-scenario/pane.tsx +2 -1
- package/src/plugins/builtin/perps/client.ts +1 -1
- package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +2 -1
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +7 -3
- package/src/plugins/builtin/portfolio-list/use-throttled-memo.ts +10 -19
- package/src/plugins/builtin/research/analyst-model.ts +1 -0
- package/src/plugins/builtin/research/equity-diagnostic-pane.tsx +2 -1
- package/src/plugins/builtin/research/index.tsx +1 -0
- package/src/plugins/builtin/research/relative-valuation-currency.ts +1 -1
- package/src/plugins/builtin/research/relative-valuation-peers.ts +2 -1
- package/src/plugins/builtin/research-search/command-bar-search.ts +3 -1
- package/src/plugins/builtin/research-search/snippet.ts +1 -0
- package/src/plugins/builtin/revenue-breakdown/client.ts +3 -2
- package/src/plugins/builtin/seasonality/headless.ts +2 -1
- package/src/plugins/builtin/sec/command-bar-search.ts +3 -2
- package/src/plugins/builtin/sec/index.tsx +7 -4
- package/src/plugins/builtin/sec/row-summaries.ts +28 -12
- package/src/plugins/builtin/short-interest/watch-client.ts +2 -1
- package/src/plugins/builtin/social-mentions/client.ts +2 -1
- package/src/plugins/builtin/supply-chain/client.ts +1 -1
- package/src/plugins/builtin/supply-chain/evidence.ts +1 -1
- package/src/plugins/builtin/supply-chain/graph-pane.tsx +2 -1
- package/src/plugins/builtin/supply-chain/pane.tsx +2 -1
- package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +1 -1
- package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +24 -4
- package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +1 -1
- package/src/plugins/builtin/time-sales/client.ts +1 -0
- package/src/plugins/builtin/vol-surface/client.ts +2 -1
- package/src/plugins/builtin/yield-curve/headless.ts +3 -1
- package/src/portfolio/column-values.ts +76 -10
- package/src/renderers/dom/host/box.tsx +204 -176
- package/src/renderers/dom/host/style.ts +49 -20
- package/src/renderers/dom/host/text.tsx +3 -2
- package/src/renderers/electrobun/bun/desktop/backend.ts +2 -0
- package/src/renderers/electrobun/bun/desktop/host-requests.ts +25 -1
- package/src/renderers/electrobun/bun/desktop/relaunch.ts +9 -1
- package/src/renderers/electrobun/bun/desktop/windows-script.ts +9 -6
- package/src/renderers/electrobun/bun/window/windows-native.ts +26 -1
- package/src/renderers/electrobun/shared/protocol.ts +6 -0
- package/src/renderers/electrobun/view/ui-host.tsx +7 -0
- package/src/renderers/electrobun/view/window-fullscreen.ts +10 -3
- package/src/sources/provider-router/index.ts +7 -1
- package/src/time-series/price-units.ts +11 -0
- package/src/ui/host.tsx +2 -0
- package/src/utils/currency-names.ts +20 -0
- package/src/utils/currency-pair.ts +6 -0
- package/src/utils/exchange-rate-snapshot.ts +20 -2
- package/src/utils/fx-market-hours.ts +43 -0
|
@@ -19,6 +19,7 @@ import { KeybindingsEditor } from "./keybindings-editor";
|
|
|
19
19
|
import { ShortcutTable, type ShortcutTableEntry } from "./shortcut-table";
|
|
20
20
|
import { resolveCommandShortcuts, resolveWindowTemplates } from "./shortcut-model";
|
|
21
21
|
import { badgeColumnWidth } from "./table-cells";
|
|
22
|
+
import { logFailure } from "../../../utils/log-failure";
|
|
22
23
|
|
|
23
24
|
const HELP_TABS = [
|
|
24
25
|
{ label: "Basics", value: "basics" },
|
|
@@ -93,7 +94,7 @@ function HelpPane({ focused, width, height }: PaneProps) {
|
|
|
93
94
|
.then((next) => {
|
|
94
95
|
if (live) setPricing(next);
|
|
95
96
|
})
|
|
96
|
-
.catch((
|
|
97
|
+
.catch(logFailure("help", "Load Cloud pricing for help failed"));
|
|
97
98
|
return () => {
|
|
98
99
|
live = false;
|
|
99
100
|
};
|
|
@@ -46,16 +46,23 @@ function nameWord(word: string): string {
|
|
|
46
46
|
return word.split(/([-'\u2019])/).map((part) => /^[-'\u2019]$/.test(part) ? part : capitalizeWord(part)).join("");
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
/** A person's words split from the suffixes that follow the name ("JR", "III"). */
|
|
50
|
+
function splitPersonName(name: string): { words: string[]; suffixes: string[] } {
|
|
51
|
+
const parts = name.replace(/,/g, " ").split(/\s+/).filter(Boolean);
|
|
51
52
|
const suffixes: string[] = [];
|
|
52
|
-
const
|
|
53
|
-
|
|
53
|
+
const words: string[] = [];
|
|
54
|
+
parts.forEach((word, index) => {
|
|
54
55
|
const suffix = index > 0 ? PERSON_SUFFIXES[word.replace(/\./g, "").toUpperCase()] : undefined;
|
|
55
56
|
if (suffix) suffixes.push(suffix);
|
|
56
|
-
else
|
|
57
|
+
else words.push(word);
|
|
57
58
|
});
|
|
58
|
-
|
|
59
|
+
return { words, suffixes };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** `filing` reads "LAST FIRST MIDDLE", as an SEC filing conforms an owner; `natural` is already first-name-first. */
|
|
63
|
+
function formatPersonName(name: string, order: "filing" | "natural" = "filing"): string {
|
|
64
|
+
const { words: rest, suffixes } = splitPersonName(name);
|
|
65
|
+
if (order === "natural" || rest.length < 2) return [...rest.map(nameWord), ...suffixes].join(" ");
|
|
59
66
|
// SEC filings conform the reporting owner to "LAST FIRST MIDDLE".
|
|
60
67
|
let surnameLength = 1;
|
|
61
68
|
while (surnameLength < rest.length - 1 && SURNAME_PARTICLES.has(rest[surnameLength - 1]!.toLocaleLowerCase())) surnameLength += 1;
|
|
@@ -78,6 +85,38 @@ export function formatInsiderName(name: string): string {
|
|
|
78
85
|
.join("; ");
|
|
79
86
|
}
|
|
80
87
|
|
|
88
|
+
/** A name's words without initials, suffixes or case, in a fixed order: two spellings of one person share it. */
|
|
89
|
+
function nameKey(name: string): string {
|
|
90
|
+
return splitPersonName(name).words
|
|
91
|
+
.map((word) => word.replace(/[.,]+$/, "").toLocaleLowerCase())
|
|
92
|
+
.filter((word) => word.length > 1)
|
|
93
|
+
.sort()
|
|
94
|
+
.join(" ");
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* A name typed freely on a form, such as the seller on a Form 144, which is
|
|
99
|
+
* as often "KEVAN PAREKH" as it is "COOK TIMOTHY D". A person already known
|
|
100
|
+
* from an insider form (`knownNames`, as those forms file them) is written as
|
|
101
|
+
* the Insider table writes them; a comma after the first word, or a trailing
|
|
102
|
+
* initial, marks filing order; any other name is taken as first-name-first
|
|
103
|
+
* and only has its case fixed.
|
|
104
|
+
*/
|
|
105
|
+
export function formatFreeformPersonName(name: string, knownNames: readonly string[] = []): string {
|
|
106
|
+
return name.split(";").map((part) => part.trim()).filter(Boolean)
|
|
107
|
+
.map((part) => {
|
|
108
|
+
if (isEntityName(part)) return part;
|
|
109
|
+
const key = nameKey(part);
|
|
110
|
+
const known = key ? knownNames.find((candidate) => nameKey(candidate) === key) : undefined;
|
|
111
|
+
if (known) return formatInsiderName(known);
|
|
112
|
+
const { words } = splitPersonName(part);
|
|
113
|
+
// "Cook, Timothy" and "COOK TIMOTHY D" put the surname first.
|
|
114
|
+
const surnameFirst = /^[^\s,]+,/.test(part) || (words.length > 1 && isInitial(words[words.length - 1]!));
|
|
115
|
+
return formatPersonName(part, surnameFirst ? "filing" : "natural");
|
|
116
|
+
})
|
|
117
|
+
.join("; ");
|
|
118
|
+
}
|
|
119
|
+
|
|
81
120
|
interface RoleRank {
|
|
82
121
|
label: string;
|
|
83
122
|
rank: number;
|
|
@@ -55,6 +55,7 @@ function venueToday(timeZone: string, now = new Date()): string {
|
|
|
55
55
|
try {
|
|
56
56
|
format = new Intl.DateTimeFormat("en-US", { timeZone, year: "numeric", month: "2-digit", day: "2-digit" });
|
|
57
57
|
} catch {
|
|
58
|
+
// Intentional ignore: a zone this runtime does not know reads the board at the local date.
|
|
58
59
|
format = null;
|
|
59
60
|
}
|
|
60
61
|
venueDays.set(timeZone, format);
|
|
@@ -145,6 +146,7 @@ function countryName(code: string): string {
|
|
|
145
146
|
regionNames ??= new Intl.DisplayNames(["en"], { type: "region" });
|
|
146
147
|
name = regionNames.of(code) ?? "";
|
|
147
148
|
} catch {
|
|
149
|
+
// Intentional ignore: a region the runtime cannot name leaves the search without a country name.
|
|
148
150
|
name = "";
|
|
149
151
|
}
|
|
150
152
|
countryNames.set(code, name);
|
|
@@ -7,6 +7,7 @@ import type { DataProvider } from "../../../types/data-provider";
|
|
|
7
7
|
import type { PricePoint } from "../../../types/financials";
|
|
8
8
|
import { realizedVolatilityCadenceIssue, rollingRealizedVolatility } from "../shared/volatility";
|
|
9
9
|
import { NO_FATE, type ListingFate } from "../../../tickers/listing-fate";
|
|
10
|
+
import { logFailure } from "../../../utils/log-failure";
|
|
10
11
|
|
|
11
12
|
export type IvMethod = "quote-mid" | "trade-close";
|
|
12
13
|
/**
|
|
@@ -244,7 +245,7 @@ async function loadRealizedVolatilities(
|
|
|
244
245
|
try {
|
|
245
246
|
const entry = await dependencies.loadChart({ instrument, bufferRange: "1Y", granularity: "resolution", resolution: "1d" });
|
|
246
247
|
value = screenHv(resolveEntryValue(entry) ?? [], window);
|
|
247
|
-
} catch { value = null; }
|
|
248
|
+
} catch (error) { value = logFailure("iv-history.client", "Load screen price history failed", null)(error); }
|
|
248
249
|
result.set(instrument.symbol, value);
|
|
249
250
|
options.onValue?.(instrument.symbol, value);
|
|
250
251
|
}
|
|
@@ -17,6 +17,7 @@ import { zonedDateKey } from "../../../utils/zoned-date-time";
|
|
|
17
17
|
import { listingFateNotes, listingFateReport, loadListingFate, MovedSymbolError } from "../../../tickers/listing-fate";
|
|
18
18
|
import { startTickerChangeLookup } from "../../../tickers/ticker-changes";
|
|
19
19
|
import { fxVolatilityRefusal } from "../../../market-data/options-alternatives";
|
|
20
|
+
import { logFailure } from "../../../utils/log-failure";
|
|
20
21
|
|
|
21
22
|
const METHODOLOGY = "docs/research-data.md#implied-volatility-history";
|
|
22
23
|
const percent = (value: unknown) => typeof value === "number" ? formatVol(value) : "--";
|
|
@@ -50,7 +51,7 @@ export const ivHistoryHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
|
50
51
|
// What became of the symbol, as `quote` reads it, looked up beside the figures: FB's are the fund listed
|
|
51
52
|
// there now, TWTR stopped trading, and HFC, which became DINO, has none of its own.
|
|
52
53
|
const changes = startTickerChangeLookup(ctx.marketData, instrument.symbol, instrument.exchange);
|
|
53
|
-
const quote = ctx.marketData.getQuote(instrument.symbol, instrument.exchange ?? "").catch((
|
|
54
|
+
const quote = ctx.marketData.getQuote(instrument.symbol, instrument.exchange ?? "").catch(logFailure("iv-history.headless", "Load IV history quote failed", null));
|
|
54
55
|
const [payload, prices, releases] = await Promise.all([
|
|
55
56
|
loadIvHistory(instrument.symbol, { signal: ctx.signal }, ctx.apiClient),
|
|
56
57
|
loadRealizedVolatilityHistory({ instrument, signal: ctx.signal }, createRealizedVolatilityDependencies(ctx.marketData)),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useCallback, useRef, useState } from "react";
|
|
2
|
+
import { logFailure } from "../../../utils/log-failure";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Pages appended past what the first response carried. Keyed on the first
|
|
@@ -35,10 +36,9 @@ export function useAppendedPages<T>(
|
|
|
35
36
|
return { key, items: [...base, ...items], nextOffset: offset + items.length, exhausted: items.length === 0 };
|
|
36
37
|
});
|
|
37
38
|
})
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
})
|
|
39
|
+
// The rows already loaded stay; only the next page failed, and a
|
|
40
|
+
// later scroll asks again.
|
|
41
|
+
.catch(logFailure("jobs.pages", "Load more job postings failed"))
|
|
42
42
|
.finally(() => {
|
|
43
43
|
if (inFlight.current === key) inFlight.current = null;
|
|
44
44
|
setLoadingMore(false);
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
type KellyHistoryInputs,
|
|
17
17
|
} from "./history";
|
|
18
18
|
import { formatPct, formatSignedPct } from "./view";
|
|
19
|
+
import { logFailure } from "../../../utils/log-failure";
|
|
19
20
|
|
|
20
21
|
/** The fractions of full Kelly a report sizes, largest first. */
|
|
21
22
|
const KELLY_FRACTIONS = [
|
|
@@ -77,7 +78,7 @@ export const kellyHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
|
77
78
|
// coordinator every chart reads daily closes from (the History tab's request, cache included).
|
|
78
79
|
const [entry, quote] = await Promise.all([
|
|
79
80
|
new MarketDataCoordinator(ctx.marketData).loadChart(kellyHistoryRequest({ symbol, exchange }, years), { forceRefresh: ctx.refresh }),
|
|
80
|
-
ctx.marketData.getQuote(symbol, exchange, ctx.refresh ? { cacheMode: "refresh" } : undefined).catch((
|
|
81
|
+
ctx.marketData.getQuote(symbol, exchange, ctx.refresh ? { cacheMode: "refresh" } : undefined).catch(logFailure("kelly-sizer.headless", "Load Kelly sizing quote failed", null)),
|
|
81
82
|
]);
|
|
82
83
|
const history = clipPriceHistoryToRange(resolveEntryValue(entry) ?? [], range);
|
|
83
84
|
ctx.signal.throwIfAborted();
|
|
@@ -101,6 +101,7 @@ import {
|
|
|
101
101
|
overlayScreenerQuoteEntries,
|
|
102
102
|
resolveScreenerQuoteFeedStatus,
|
|
103
103
|
} from "../../../market-data/quotes/screener-live-quotes";
|
|
104
|
+
import { logFailure } from "../../../utils/log-failure";
|
|
104
105
|
|
|
105
106
|
const NO_ASSETS: HeatmapBoardAsset[] = [];
|
|
106
107
|
const NO_TARGETS: QuoteSubscriptionTarget[] = [];
|
|
@@ -144,7 +145,7 @@ function loadCollectionSnapshots(
|
|
|
144
145
|
const instrument = instrumentFromTicker(ticker, ticker.metadata.ticker, instrumentOptions);
|
|
145
146
|
return instrument ? [instrument] : [];
|
|
146
147
|
});
|
|
147
|
-
if (instruments.length > 0) void coordinator.loadSnapshotsBatch(instruments, { forceRefresh }).catch((
|
|
148
|
+
if (instruments.length > 0) void coordinator.loadSnapshotsBatch(instruments, { forceRefresh }).catch(logFailure("market-heatmap", "Load heatmap collection snapshots failed"));
|
|
148
149
|
}
|
|
149
150
|
|
|
150
151
|
function formatMoneyCompact(value: number | null | undefined, currency: string): string {
|
|
@@ -39,7 +39,7 @@ async function fetchPayload<T>(fetcher: () => Promise<T>, validate: (data: T) =>
|
|
|
39
39
|
async function fetchFundPayload<T>(fund: string, fetcher: () => Promise<T>, validate: (data: T) => T, client: Client, unavailable = UNAVAILABLE) {
|
|
40
40
|
try { return validate(await fetcher()); } catch (error) {
|
|
41
41
|
if (error instanceof ApiRequestError && error.status === 404) {
|
|
42
|
-
const funds = await fetchFunds(client).then((payload) => payload.funds, () => []);
|
|
42
|
+
const funds = await fetchFunds(client).then((payload) => payload.funds, () => { /* Intentional ignore: an unreadable covered list leaves the server's own message. */ return []; });
|
|
43
43
|
if (funds.length && !coveredFund(funds, fund)) throw new Error(notCoveredMessage(fund, funds));
|
|
44
44
|
}
|
|
45
45
|
throw unavailableOnServer(error, unavailable);
|
|
@@ -48,6 +48,7 @@ const isWebUrl = (value: unknown): value is string => {
|
|
|
48
48
|
const url = new URL(value);
|
|
49
49
|
return url.protocol === "https:" || url.protocol === "http:";
|
|
50
50
|
} catch {
|
|
51
|
+
// Intentional ignore: malformed URLs fail this web link field validator.
|
|
51
52
|
return false;
|
|
52
53
|
}
|
|
53
54
|
};
|
|
@@ -53,6 +53,7 @@ import {
|
|
|
53
53
|
stageLabel,
|
|
54
54
|
termsLabel,
|
|
55
55
|
} from "./model";
|
|
56
|
+
import { logFailure } from "../../../utils/log-failure";
|
|
56
57
|
|
|
57
58
|
const STATUS_OPTIONS: { value: MnaStatusFilter; label: string }[] = [
|
|
58
59
|
{ value: "pending", label: "Pending" },
|
|
@@ -238,7 +239,9 @@ function MnaDealsView({ focused, width, height, symbol }: {
|
|
|
238
239
|
.then((page) => {
|
|
239
240
|
if (pageRequest.current === request) setPaged({ owner: first, payload: appendMnaDeals(data, page) });
|
|
240
241
|
})
|
|
241
|
-
.catch(() => {
|
|
242
|
+
.catch((error) => {
|
|
243
|
+
if (!request.signal.aborted) logFailure("mna.pane", "Load more M&A deals failed")(error);
|
|
244
|
+
})
|
|
242
245
|
.finally(() => {
|
|
243
246
|
if (pageRequest.current === request) setLoadingMore(false);
|
|
244
247
|
});
|
|
@@ -25,7 +25,7 @@ export function optionMarketReference(value: unknown): OptionMarketReference | u
|
|
|
25
25
|
|
|
26
26
|
export function parseOptionMarketReference(value: string | undefined): OptionMarketReference | undefined {
|
|
27
27
|
if (!value) return undefined;
|
|
28
|
-
try { return optionMarketReference(JSON.parse(value)); } catch { return undefined; }
|
|
28
|
+
try { return optionMarketReference(JSON.parse(value)); } catch { /* Intentional ignore: a market reference that does not parse opens the contract without one. */ return undefined; }
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
function timestamp(milliseconds: number | undefined): string | null {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { OptionsChain } from "../../../types/financials";
|
|
2
2
|
import { formatCalendarDay } from "./model-spot";
|
|
3
3
|
import { loadOpenInterest, type OpenInterestPayload, type OptionsPositioningApi } from "../options-positioning/client";
|
|
4
|
+
import { logFailure } from "../../../utils/log-failure";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* The session a chain's open interest is counted at
|
|
@@ -63,7 +64,8 @@ export async function loadListedOpenInterest(
|
|
|
63
64
|
try {
|
|
64
65
|
const listed = await loadOpenInterest(symbol, expiry, { signal: options.signal ?? AbortSignal.timeout(LISTED_TIMEOUT_MS) }, options.api);
|
|
65
66
|
return listed.expiry === expiry ? listed : null;
|
|
66
|
-
} catch {
|
|
67
|
+
} catch (error) {
|
|
68
|
+
logFailure("options.open-interest-as-of", "Load listed open interest failed")(error);
|
|
67
69
|
return null;
|
|
68
70
|
}
|
|
69
71
|
}
|
|
@@ -97,6 +97,7 @@ import {
|
|
|
97
97
|
strikeWindowShortLabel,
|
|
98
98
|
strikeWindowValue,
|
|
99
99
|
} from "./strike-window";
|
|
100
|
+
import { logFailure } from "../../../utils/log-failure";
|
|
100
101
|
|
|
101
102
|
/** The summary strip and analytics recompute from live quotes at most this often. */
|
|
102
103
|
const OPTIONS_SUMMARY_THROTTLE_MS = 1_000;
|
|
@@ -675,7 +676,7 @@ export function OptionsView({ width, height, focused, nestedInTabs = false, ivRa
|
|
|
675
676
|
void dialog.alert({
|
|
676
677
|
closeOnClickOutside: true,
|
|
677
678
|
content: (ctx: AlertContext) => <AnalyticsAsOfDialog {...ctx} rows={rows} />,
|
|
678
|
-
}).catch((
|
|
679
|
+
}).catch(logFailure("options.view", "Open analytics as-of dialog failed"));
|
|
679
680
|
}, [dialog, enrichment]);
|
|
680
681
|
usePaneFooter("options-enrichment", () => ({ info: [
|
|
681
682
|
...(enrichmentState.loading ? [{ id: "enrichment-loading", parts: [{ text: "loading analytics", tone: "muted" as const }] }] : []),
|
|
@@ -153,7 +153,7 @@ export function readCalculatorEvidence(value: unknown): CalculatorEvidence | nul
|
|
|
153
153
|
expected = valueOption(draft);
|
|
154
154
|
implied = solveImpliedVolatility(draft, draft.marketPrice);
|
|
155
155
|
}
|
|
156
|
-
} catch { return null; }
|
|
156
|
+
} catch { /* Intentional ignore: inputs the valuation rejects cannot prove the captured values, so the evidence is rejected. */ return null; }
|
|
157
157
|
if (!validValuation(expected) || metrics.some((key) => !sameNumber(evidence.valuation![key], expected[key]))
|
|
158
158
|
|| evidence.implied.note !== implied.note || (implied.volatility === null ? evidence.implied.volatility !== null
|
|
159
159
|
: evidence.implied.volatility === null || !sameNumber(evidence.implied.volatility, implied.volatility))
|
|
@@ -135,7 +135,7 @@ export function CspScreenPane({ width, height, focused }: PaneProps) {
|
|
|
135
135
|
const { createPaneFromTemplate } = usePluginAppActions();
|
|
136
136
|
const assetData = useAssetData();
|
|
137
137
|
const strategy = useMemo((): StrategyFamily => {
|
|
138
|
-
try { return readStrategyFamily(strategySetting); } catch { return "csp"; }
|
|
138
|
+
try { return readStrategyFamily(strategySetting); } catch { /* Intentional ignore: an unknown saved strategy opens the cash-secured put screen. */ return "csp"; }
|
|
139
139
|
}, [strategySetting]);
|
|
140
140
|
const family = strategyFamilyDef(strategy);
|
|
141
141
|
// Each strategy opens at its own deltas; the names and the expiry carry over.
|
|
@@ -9,7 +9,7 @@ import { zonedDateKey } from "../../../utils/zoned-date-time";
|
|
|
9
9
|
import { ivRankReason, loadIvScreen, type ImpliedVolatilityApi, type IvScreenRow } from "../iv-history/client";
|
|
10
10
|
import { quoteObservation } from "../shared/report-freshness";
|
|
11
11
|
import { loadScenarioMarket, scenarioPositionFromSettings, scenarioSpotBasis, type ScenarioLoaderDependencies, type ScenarioMarketSnapshot } from "./client";
|
|
12
|
-
import { cashSecuredPut, loadNextEarningsDates, type CashSecuredPut } from "./csp";
|
|
12
|
+
import { cashSecuredPut, EARNINGS_CALENDAR_UNAVAILABLE, loadNextEarningsDates, type CashSecuredPut } from "./csp";
|
|
13
13
|
import { seededLegQuotes } from "./hedge";
|
|
14
14
|
import { scenarioValue } from "./model";
|
|
15
15
|
|
|
@@ -252,7 +252,7 @@ export async function screenNames<T>(
|
|
|
252
252
|
const rank = ivRow?.iv30?.rank;
|
|
253
253
|
const ivRank = rank != null && Number.isFinite(rank) ? rank : null;
|
|
254
254
|
try {
|
|
255
|
-
const screened = await screen(instrument, earnings.get(symbol) ?? null, scenario);
|
|
255
|
+
const screened = await screen(instrument, earnings === EARNINGS_CALENDAR_UNAVAILABLE ? earnings : earnings.get(symbol) ?? null, scenario);
|
|
256
256
|
markets.push(screened.market);
|
|
257
257
|
if (ivRank == null && !ivRanks.error) {
|
|
258
258
|
const reason = ivRankReason(ivRow);
|
|
@@ -289,10 +289,14 @@ export function cspScreenCriteriaText(criteria: CspScreenCriteria, now: number):
|
|
|
289
289
|
+ (criteria.expiration == null ? ` (${criteria.days} days)` : "");
|
|
290
290
|
}
|
|
291
291
|
|
|
292
|
-
/**
|
|
292
|
+
/**
|
|
293
|
+
* `before 2026-11-04`, `after 2027-01-19`, `unknown`: whether the next report falls before the put (or a trade's first leg)
|
|
294
|
+
* expires, and its date; `unavailable` when the earnings calendar could not be read.
|
|
295
|
+
*/
|
|
293
296
|
export function cspEarningsText(csp: Pick<CashSecuredPut, "earnings"> | null): string {
|
|
294
297
|
if (!csp) return "--";
|
|
295
|
-
const { beforeExpiry, date } = csp.earnings;
|
|
298
|
+
const { beforeExpiry, date, unavailable } = csp.earnings;
|
|
299
|
+
if (unavailable) return "unavailable";
|
|
296
300
|
return beforeExpiry == null ? "unknown" : `${beforeExpiry ? "before" : "after"} ${date}`;
|
|
297
301
|
}
|
|
298
302
|
|
|
@@ -7,6 +7,7 @@ import { newYorkDay, resolveListingEvents, upcomingReportDate } from "../shared/
|
|
|
7
7
|
import { parsePublicTickerKey } from "../../../utils/exchanges";
|
|
8
8
|
import { formatHedgePrice } from "./hedge";
|
|
9
9
|
import { amountUnit, exportPercent, UNKNOWN_CURRENCY, type ScenarioPosition } from "./model";
|
|
10
|
+
import { logFailure } from "../../../utils/log-failure";
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* A cash-secured put (docs/research-data.md#cash-secured-put): one short put
|
|
@@ -25,7 +26,7 @@ import { amountUnit, exportPercent, UNKNOWN_CURRENCY, type ScenarioPosition } fr
|
|
|
25
26
|
* - break-even = strike - entry price
|
|
26
27
|
* - days to expiry = calendar days from the valuation date in New York to the expiry date
|
|
27
28
|
* - earnings before expiry: yes when the next report is on or before the expiry date,
|
|
28
|
-
* no when it is after, unknown when the calendar has no upcoming date
|
|
29
|
+
* no when it is after, unknown when the calendar has no upcoming date or could not be read
|
|
29
30
|
*/
|
|
30
31
|
export interface CashSecuredPut {
|
|
31
32
|
currency: string;
|
|
@@ -77,8 +78,17 @@ export interface CspEarnings {
|
|
|
77
78
|
date: string | null;
|
|
78
79
|
/** Null is unknown: no upcoming date to compare. */
|
|
79
80
|
beforeExpiry: boolean | null;
|
|
81
|
+
/** The earnings calendar could not be read, so there may be a date it did not give. */
|
|
82
|
+
unavailable?: true;
|
|
80
83
|
}
|
|
81
84
|
|
|
85
|
+
/**
|
|
86
|
+
* What `loadNextEarningsDate` answers when the earnings calendar could not be
|
|
87
|
+
* read, in place of a date. Unlike null (no date published) it is reported as
|
|
88
|
+
* unavailable. A string, so a capture can keep it in the pane's settings.
|
|
89
|
+
*/
|
|
90
|
+
export const EARNINGS_CALENDAR_UNAVAILABLE = "calendar-unavailable";
|
|
91
|
+
|
|
82
92
|
const DAY_MS = 86_400_000;
|
|
83
93
|
const newYorkDate = new Intl.DateTimeFormat("en-CA", { timeZone: "America/New_York", year: "numeric", month: "2-digit", day: "2-digit" });
|
|
84
94
|
|
|
@@ -94,8 +104,9 @@ export function calendarDaysToExpiry(asOf: number, expiry: string): { valuationD
|
|
|
94
104
|
daysToExpiry: Math.max(0, Math.round((Date.parse(`${expiry}T00:00:00Z`) - Date.parse(`${valuationDate}T00:00:00Z`)) / DAY_MS)) };
|
|
95
105
|
}
|
|
96
106
|
|
|
97
|
-
/** Whether the next report falls before the put expires; unknown without an upcoming date. */
|
|
107
|
+
/** Whether the next report falls before the put expires; unknown without an upcoming date or a calendar to read one from. */
|
|
98
108
|
export function earningsBeforeExpiry(earningsDate: string | null | undefined, valuationDate: string, expiry: string): CspEarnings {
|
|
109
|
+
if (earningsDate === EARNINGS_CALENDAR_UNAVAILABLE) return { date: null, beforeExpiry: null, unavailable: true };
|
|
99
110
|
if (!earningsDate || !/^\d{4}-\d{2}-\d{2}$/.test(earningsDate) || earningsDate < valuationDate) return { date: null, beforeExpiry: null };
|
|
100
111
|
return { date: earningsDate, beforeExpiry: earningsDate <= expiry };
|
|
101
112
|
}
|
|
@@ -146,19 +157,25 @@ export function cashSecuredPut(
|
|
|
146
157
|
/**
|
|
147
158
|
* The next report date, YYYY-MM-DD, as every earnings surface resolves it
|
|
148
159
|
* (shared/earnings-calendar): the calendar's, or once that date has passed
|
|
149
|
-
* the next one on record; null when there is none
|
|
150
|
-
* read.
|
|
160
|
+
* the next one on record; null when there is none, and
|
|
161
|
+
* EARNINGS_CALENDAR_UNAVAILABLE when the calendar cannot be read.
|
|
151
162
|
*/
|
|
152
163
|
export async function loadNextEarningsDate(provider: DataProvider | null | undefined, symbol: string, today = newYorkDay()): Promise<string | null> {
|
|
153
|
-
|
|
164
|
+
const dates = await loadNextEarningsDates(provider, [symbol], today);
|
|
165
|
+
return dates === EARNINGS_CALENDAR_UNAVAILABLE ? dates : dates.get(symbol.trim().toUpperCase()) ?? null;
|
|
154
166
|
}
|
|
155
167
|
|
|
156
|
-
/**
|
|
168
|
+
/**
|
|
169
|
+
* The next report date of each symbol, by its upper-case symbol, from one
|
|
170
|
+
* calendar request; a symbol with none is left out. EARNINGS_CALENDAR_UNAVAILABLE
|
|
171
|
+
* when the calendar cannot be read.
|
|
172
|
+
*/
|
|
157
173
|
export async function loadNextEarningsDates(
|
|
158
174
|
provider: DataProvider | null | undefined, symbols: readonly string[], today = newYorkDay(),
|
|
159
|
-
): Promise<Map<string, string
|
|
175
|
+
): Promise<Map<string, string> | typeof EARNINGS_CALENDAR_UNAVAILABLE> {
|
|
160
176
|
const keys = [...new Set(symbols.map((symbol) => symbol.trim().toUpperCase()))];
|
|
161
|
-
const result = await loadEarningsCalendar(provider, keys).catch((
|
|
177
|
+
const result = await loadEarningsCalendar(provider, keys).catch(logFailure("options-scenario.csp", "Load earnings calendar for cash-secured puts failed", null));
|
|
178
|
+
if (provider && !result) return EARNINGS_CALENDAR_UNAVAILABLE;
|
|
162
179
|
if (!provider || !result?.events.length) return new Map();
|
|
163
180
|
const listings = keys.map((key) => {
|
|
164
181
|
const listing = parsePublicTickerKey(key);
|
|
@@ -184,6 +201,7 @@ function otmText(csp: CashSecuredPut): string {
|
|
|
184
201
|
}
|
|
185
202
|
|
|
186
203
|
function earningsText(earnings: CspEarnings): string {
|
|
204
|
+
if (earnings.unavailable) return "unknown (earnings calendar unavailable)";
|
|
187
205
|
if (earnings.beforeExpiry == null) return "unknown (no upcoming date published)";
|
|
188
206
|
return `${earnings.beforeExpiry ? "yes" : "no"} (next report ${earnings.date})`;
|
|
189
207
|
}
|
|
@@ -249,6 +267,7 @@ export function cspStatItems(csp: CashSecuredPut): StatItem[] {
|
|
|
249
267
|
{ id: "csp-break-even", label: "Break-even", value: formatHedgePrice(csp.breakEven), detail: "per share" },
|
|
250
268
|
{ id: "csp-days", label: "DTE", value: String(csp.daysToExpiry), detail: csp.expiry },
|
|
251
269
|
{ id: "csp-earnings", label: "Earnings", value: earnings.beforeExpiry == null ? "unknown" : earnings.beforeExpiry ? "before expiry" : "after expiry",
|
|
252
|
-
detail: earnings.
|
|
270
|
+
detail: earnings.unavailable ? "calendar unavailable" : earnings.date ?? "no date",
|
|
271
|
+
tone: earnings.beforeExpiry || earnings.unavailable ? "warning" : undefined },
|
|
253
272
|
];
|
|
254
273
|
}
|
|
@@ -3,6 +3,7 @@ import { useRemoteUiNode } from "../../../remote/semantic-tree";
|
|
|
3
3
|
import type { TickerFinancials } from "../../../types/financials";
|
|
4
4
|
import { parsePublicTickerKey } from "../../../utils/exchanges";
|
|
5
5
|
import { buildScenario, type ScenarioControls, type ScenarioModel, type ScenarioPosition } from "./model";
|
|
6
|
+
import { EARNINGS_CALENDAR_UNAVAILABLE } from "./csp";
|
|
6
7
|
import { isRecord, isStringArray } from "../../../utils/guards";
|
|
7
8
|
|
|
8
9
|
export interface ScenarioEvidenceInput {
|
|
@@ -56,7 +57,7 @@ export function readScenarioEvidence(value: unknown): ScenarioEvidence | null {
|
|
|
56
57
|
|| !isRecord(value.scenario) || !isStringArray(value.scenario.warnings)) return null;
|
|
57
58
|
const scenario = value.scenario as unknown as ScenarioModel;
|
|
58
59
|
let expected: ScenarioModel;
|
|
59
|
-
try { expected = buildScenario(scenario.position, scenario.controls); } catch { return null; }
|
|
60
|
+
try { expected = buildScenario(scenario.position, scenario.controls); } catch { /* Intentional ignore: a scenario that cannot be repriced is rejected as evidence by returning null. */ return null; }
|
|
60
61
|
if (value.symbol !== expected.position.symbol) return null;
|
|
61
62
|
// A clamped requested date can add a warning to the original model. Its
|
|
62
63
|
// normalized controls reproduce the values, while retaining that warning.
|
|
@@ -83,7 +84,7 @@ export const scenarioScreenshotEvidence: PaneScreenshotEvidenceHook<ScenarioEvid
|
|
|
83
84
|
controls?: ScenarioControls | null;
|
|
84
85
|
market?: unknown;
|
|
85
86
|
inputSource?: string;
|
|
86
|
-
csp?: { earnings: { date: string | null } };
|
|
87
|
+
csp?: { earnings: { date: string | null; unavailable?: true } };
|
|
87
88
|
} | undefined;
|
|
88
89
|
const position = metadata?.position;
|
|
89
90
|
const controls = metadata?.controls;
|
|
@@ -97,8 +98,8 @@ export const scenarioScreenshotEvidence: PaneScreenshotEvidenceHook<ScenarioEvid
|
|
|
97
98
|
scenarioSnapshot: metadata?.scenario ?? null,
|
|
98
99
|
scenarioMarketSnapshot: metadata?.market ?? null,
|
|
99
100
|
scenarioSnapshotErrors: loaded.result.errors ?? [],
|
|
100
|
-
// A cash-secured put shows the earnings date the report read, not another lookup's.
|
|
101
|
-
...(metadata?.csp ? { scenarioEarningsDate: metadata.csp.earnings.date } : {}),
|
|
101
|
+
// A cash-secured put shows the earnings date the report read, or that it could not read one, not another lookup's.
|
|
102
|
+
...(metadata?.csp ? { scenarioEarningsDate: metadata.csp.earnings.unavailable ? EARNINGS_CALENDAR_UNAVAILABLE : metadata.csp.earnings.date } : {}),
|
|
102
103
|
...(position ? { seedPosition: position } : {}),
|
|
103
104
|
...(controls ? { date: new Date(controls.date).toISOString(), volShift: controls.volShift * 100,
|
|
104
105
|
spotRange: controls.spotRange * 100 } : {}),
|
|
@@ -41,6 +41,7 @@ import { useScenarioEvidence } from "./evidence";
|
|
|
41
41
|
import { hedgeStatItems, scenarioHedgeBudget, seededLegQuotes, type HedgeQuote } from "./hedge";
|
|
42
42
|
import { isLiveOptionExpiry, readOptionExpiration } from "../../../utils/option-expiry";
|
|
43
43
|
import { parsePublicTickerKey } from "../../../utils/exchanges";
|
|
44
|
+
import { logFailure } from "../../../utils/log-failure";
|
|
44
45
|
|
|
45
46
|
const EMPTY_ERRORS: string[] = [];
|
|
46
47
|
const TABS = [{ value: "payoff", label: "Payoff" }, { value: "grid", label: "P&L grid" }, { value: "legs", label: "Legs" }];
|
|
@@ -225,7 +226,7 @@ export function OptionsScenarioPane({ width, height, focused }: PaneProps) {
|
|
|
225
226
|
const choices = saved.filter((entry) => entry.position.symbol === underlying && (!exchange || entry.position.exchange === exchange));
|
|
226
227
|
if (!choices.length) { notify({ body: "No saved strategies for this ticker." }); return; }
|
|
227
228
|
const id = await dialog.prompt<string>({ content: (ctx: PromptContext<string>) => <ChoiceDialog {...ctx} title="Load strategy"
|
|
228
|
-
choices={choices.map((entry) => ({ id: entry.id, label: entry.name, detail: dateLabel(entry.position.asOf) }))} /> }).catch((
|
|
229
|
+
choices={choices.map((entry) => ({ id: entry.id, label: entry.name, detail: dateLabel(entry.position.asOf) }))} /> }).catch(logFailure("options-scenario.pane", "Open saved strategy choices failed", ""));
|
|
229
230
|
const selected = choices.find((entry) => entry.id === id);
|
|
230
231
|
// A saved strategy opens at its saved spot, date and vols; following the market is an explicit choice.
|
|
231
232
|
if (selected) { setPosition(selected.position); setControls(selected.controls); setFollow(false); setLocalError(null); }
|
|
@@ -261,7 +261,7 @@ export async function nearestPerpMarkets(input: string, client: Pick<typeof apiC
|
|
|
261
261
|
const rows = (await client.getCloudPerpsBoard({ search: text })).rows.filter((row) => !row.delisted
|
|
262
262
|
&& `${row.symbol} ${row.baseAsset} ${row.displayName}`.toUpperCase().includes(text));
|
|
263
263
|
if (rows.length) return rows;
|
|
264
|
-
} catch { return []; }
|
|
264
|
+
} catch { /* Intentional ignore: a board that cannot be read suggests nothing, so the caller keeps its own examples. */ return []; }
|
|
265
265
|
}
|
|
266
266
|
return [];
|
|
267
267
|
}));
|
|
@@ -47,9 +47,10 @@ function requireWatchlistArgs(
|
|
|
47
47
|
// A pasted list in the place of the name is a list, not a watchlist that is missing.
|
|
48
48
|
const pasted = misplacedSymbolList(args, file, { noun: "watchlist", verb, collections: config.watchlists, usage });
|
|
49
49
|
if (pasted) ctx.fail(pasted.message, pasted.details);
|
|
50
|
+
// The watchlist goes first: `watchlist add USDJPY=X USDCHF=X` read USDJPY=X as its name, so the form is said too.
|
|
50
51
|
ctx.fail(
|
|
51
52
|
`Watchlist "${args[0]}" was not found.`,
|
|
52
|
-
config.watchlists.length > 0 ? `Watchlists: ${config.watchlists.map((entry) => entry.name).join(", ")}` :
|
|
53
|
+
[config.watchlists.length > 0 ? `Watchlists: ${config.watchlists.map((entry) => entry.name).join(", ")}` : "", usage].filter(Boolean).join("\n"),
|
|
53
54
|
);
|
|
54
55
|
}
|
|
55
56
|
return { watchlist: match.collection, rest: match.rest };
|
|
@@ -103,6 +103,7 @@ import { perpetualDisplaySymbol, perpetualListing, perpetualVenueName } from "..
|
|
|
103
103
|
import { useColumnClock } from "../use-column-clock";
|
|
104
104
|
import { liveMarketCapitalization } from "../../../../market-data/quotes/live-valuation";
|
|
105
105
|
import { hasUnknownOptionMultiplier } from "../../../../portfolio/position-metrics";
|
|
106
|
+
import { sharePositionMetrics } from "../../../../portfolio/column-values";
|
|
106
107
|
import { withFuturesContractSizes } from "../../../../portfolio/futures-positions";
|
|
107
108
|
import { withPurchaseDateCostFx } from "../../../../portfolio/cost-fx";
|
|
108
109
|
import { usePortfolioFuturesTerms } from "./futures-terms";
|
|
@@ -124,6 +125,8 @@ const ALLOCATION_COLUMN_IDS = new Set(["weight", "drift", "trade", "trade_value"
|
|
|
124
125
|
const FOOTER_TOTALS_THROTTLE_MS = 250;
|
|
125
126
|
const WEIGHT_TOTAL_THROTTLE_MS = 1_000;
|
|
126
127
|
const DAY_MS = 86_400_000;
|
|
128
|
+
/** One fallback for every render: a fresh `{}` would read as a changed value each time. */
|
|
129
|
+
const NO_COLLECTION_SORTS: Record<string, CollectionSortPreference> = {};
|
|
127
130
|
|
|
128
131
|
export function PortfolioListPane({ focused, width, height }: PaneProps) {
|
|
129
132
|
const activateTicker = useTickerSourceActivate();
|
|
@@ -139,7 +142,7 @@ export function PortfolioListPane({ focused, width, height }: PaneProps) {
|
|
|
139
142
|
|
|
140
143
|
const [currentCollectionId, setCurrentCollectionId] = usePaneStateValue<string>("collectionId", paneCollection.collectionId ?? "");
|
|
141
144
|
const [committedCursorSymbol, setCommittedCursorSymbol] = usePaneStateValue<string | null>("cursorSymbol", null);
|
|
142
|
-
const [collectionSorts, setCollectionSorts] = usePaneStateValue<Record<string, CollectionSortPreference>>("collectionSorts",
|
|
145
|
+
const [collectionSorts, setCollectionSorts] = usePaneStateValue<Record<string, CollectionSortPreference>>("collectionSorts", NO_COLLECTION_SORTS);
|
|
143
146
|
const [cashDrawerExpanded, setCashDrawerExpanded] = usePaneStateValue<boolean>("cashDrawerExpanded", false);
|
|
144
147
|
const [, setViewMode] = usePaneSettingValue<PortfolioViewMode>("viewMode", "table");
|
|
145
148
|
|
|
@@ -322,11 +325,12 @@ export function PortfolioListPane({ focused, width, height }: PaneProps) {
|
|
|
322
325
|
totalsCurrency,
|
|
323
326
|
valuationBasis,
|
|
324
327
|
]);
|
|
325
|
-
|
|
328
|
+
// Cells and sort keys share each row's position figures: the clock does not move them.
|
|
329
|
+
const columnContext: ColumnContext = useMemo(() => sharePositionMetrics({ ...baseColumnContext, now }, baseColumnContext), [baseColumnContext, now]);
|
|
326
330
|
// The order only follows the per-second clock when sorting by quote age;
|
|
327
331
|
// day-based columns read the day, which the day's start stands for.
|
|
328
332
|
const sortNow = activeSort.columnId === "latency" ? now : Math.floor(now / DAY_MS) * DAY_MS;
|
|
329
|
-
const sortContext: ColumnContext = useMemo(() => ({ ...baseColumnContext, now: sortNow }), [baseColumnContext, sortNow]);
|
|
333
|
+
const sortContext: ColumnContext = useMemo(() => sharePositionMetrics({ ...baseColumnContext, now: sortNow }, baseColumnContext), [baseColumnContext, sortNow]);
|
|
330
334
|
|
|
331
335
|
const candidateSortedTickers = useMemo(
|
|
332
336
|
() => sortTickers(tickers, financialsMap, activeSort, sortContext, columns),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { useEffect,
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
import { useDataFrameWake } from "../../../market-data/frame-wake";
|
|
2
3
|
|
|
3
4
|
function sameDeps(left: readonly unknown[], right: readonly unknown[]): boolean {
|
|
4
5
|
return left.length === right.length && left.every((value, index) => Object.is(value, right[index]));
|
|
@@ -8,7 +9,7 @@ interface ThrottledMemoState<T> {
|
|
|
8
9
|
value: T;
|
|
9
10
|
throttledDeps: readonly unknown[];
|
|
10
11
|
immediateDeps: readonly unknown[];
|
|
11
|
-
/**
|
|
12
|
+
/** When it last recomputed, on the market data clock (monotonic, so a wall-clock step cannot stall it). */
|
|
12
13
|
at: number;
|
|
13
14
|
}
|
|
14
15
|
|
|
@@ -16,7 +17,8 @@ interface ThrottledMemoState<T> {
|
|
|
16
17
|
* useMemo whose recomputation for `throttledDeps` (quote-driven inputs) runs at
|
|
17
18
|
* most once per interval, during a render that is happening anyway. A change
|
|
18
19
|
* to `immediateDeps` (collection, currency, rates) recomputes at once. When the
|
|
19
|
-
* input stops changing inside the interval, one trailing render catches up
|
|
20
|
+
* input stops changing inside the interval, one trailing render catches up, in
|
|
21
|
+
* a market data frame, so it shares a commit with the quotes that frame brings.
|
|
20
22
|
*/
|
|
21
23
|
export function useThrottledMemo<T>(
|
|
22
24
|
compute: () => T,
|
|
@@ -25,13 +27,10 @@ export function useThrottledMemo<T>(
|
|
|
25
27
|
intervalMs: number,
|
|
26
28
|
): T {
|
|
27
29
|
const stateRef = useRef<ThrottledMemoState<T> | null>(null);
|
|
28
|
-
const
|
|
29
|
-
const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
30
|
-
const [, forceRender] = useReducer((count: number) => count + 1, 0);
|
|
31
|
-
latestThrottledDepsRef.current = throttledDeps;
|
|
30
|
+
const clock = useDataFrameWake();
|
|
32
31
|
|
|
33
32
|
const state = stateRef.current;
|
|
34
|
-
const now =
|
|
33
|
+
const now = clock.now();
|
|
35
34
|
let pending = false;
|
|
36
35
|
if (!state || !sameDeps(state.immediateDeps, immediateDeps) || now - state.at >= intervalMs) {
|
|
37
36
|
if (!state || !sameDeps(state.immediateDeps, immediateDeps) || !sameDeps(state.throttledDeps, throttledDeps)) {
|
|
@@ -42,18 +41,10 @@ export function useThrottledMemo<T>(
|
|
|
42
41
|
}
|
|
43
42
|
|
|
44
43
|
useEffect(() => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
timerRef.current = null;
|
|
49
|
-
const current = stateRef.current;
|
|
50
|
-
if (current && !sameDeps(current.throttledDeps, latestThrottledDepsRef.current)) forceRender();
|
|
51
|
-
}, wait);
|
|
44
|
+
// A render that caught up in the meantime (an input changed) drops the trailing one.
|
|
45
|
+
if (pending) clock.wakeAt(stateRef.current!.at + intervalMs);
|
|
46
|
+
else clock.cancel();
|
|
52
47
|
});
|
|
53
48
|
|
|
54
|
-
useEffect(() => () => {
|
|
55
|
-
if (timerRef.current) clearTimeout(timerRef.current);
|
|
56
|
-
}, []);
|
|
57
|
-
|
|
58
49
|
return stateRef.current!.value;
|
|
59
50
|
}
|
|
@@ -293,6 +293,7 @@ export function ratingReasonSource(reason: NonNullable<AnalystRatingRecord["reas
|
|
|
293
293
|
try {
|
|
294
294
|
return new URL(reason.url).hostname.replace(/^www\./, "");
|
|
295
295
|
} catch {
|
|
296
|
+
// Intentional ignore: a malformed link has no site to name, so it reads as source.
|
|
296
297
|
return "source";
|
|
297
298
|
}
|
|
298
299
|
}
|