gloomberb 0.19.6 → 0.20.0
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/LICENSE +0 -4
- package/package.json +6 -5
- package/patches/electrobun-devkit@2.0.5.patch +148 -0
- package/src/api-client/bond-trades.ts +59 -0
- package/src/api-client/data.ts +21 -0
- package/src/api-client/index.ts +2 -0
- package/src/api-client/types/account.ts +86 -0
- package/src/api-client/types/assist.ts +32 -0
- package/src/api-client/types/auth.ts +63 -0
- package/src/api-client/types/billing.ts +54 -0
- package/src/api-client/types/chat.ts +180 -0
- package/src/api-client/types/congress.ts +107 -0
- package/src/api-client/types/credit.ts +110 -0
- package/src/api-client/types/econ.ts +158 -0
- package/src/api-client/types/equity-diagnostic.ts +73 -0
- package/src/api-client/types/filings-and-calls.ts +350 -0
- package/src/api-client/types/index.ts +25 -0
- package/src/api-client/types/jobs.ts +147 -0
- package/src/api-client/types/market.ts +122 -0
- package/src/api-client/types/news.ts +91 -0
- package/src/api-client/types/notes-and-theses.ts +172 -0
- package/src/api-client/types/quotes.ts +28 -0
- package/src/api-client/types/scanners.ts +125 -0
- package/src/api-client/types/screener.ts +65 -0
- package/src/api-client/types/search.ts +107 -0
- package/src/api-client/types/sync.ts +14 -0
- package/src/api-client/types/team-collections.ts +43 -0
- package/src/api-client/types/team-views.ts +32 -0
- package/src/api-client/types/teams.ts +135 -0
- package/src/api-client/types/ticker-data.ts +57 -0
- package/src/api-client/types/tweets.ts +59 -0
- package/src/api-client/types/world-venues.ts +23 -0
- package/src/app/runtime/desktop-deeplink.ts +41 -6
- package/src/app/star-prompt/status-line.tsx +1 -1
- package/src/app.tsx +1 -7
- package/src/architecture/ui-tokens-allowlist.json +0 -8
- package/src/cli/commands/ticker.ts +17 -4
- package/src/cli/desktop-pane-shot-browser.ts +69 -3
- package/src/cli/pane-functions/catalog.ts +3 -1
- package/src/components/chart/composite/use-composite-chart-keyboard.ts +11 -2
- package/src/components/data-table/export.ts +4 -1
- package/src/components/layout/detached-pane-shell.tsx +10 -37
- package/src/components/layout/double-escape-close.ts +90 -0
- package/src/components/layout/header.tsx +3 -2
- package/src/components/layout/market-summary.ts +6 -3
- package/src/components/layout/pane/footer/index.tsx +2 -6
- package/src/components/layout/pane/footer/model.ts +6 -12
- package/src/components/layout/shell/active-drag.ts +53 -11
- package/src/components/layout/shell/drag/magnets.ts +128 -19
- package/src/components/layout/shell/pane/actions.ts +6 -2
- package/src/components/layout/shell/pane/management-shortcuts.ts +13 -51
- package/src/components/layout/status-bar.tsx +4 -78
- package/src/components/layout/status-widget-space.ts +5 -5
- package/src/components/onboarding/portfolio-step/positions-panel.tsx +1 -1
- package/src/components/ui/data-table/index.tsx +5 -1
- package/src/components/ui/data-table/render-cell.ts +19 -0
- package/src/components/ui/delayed-mark.tsx +59 -7
- package/src/components/ui/icon.tsx +1 -8
- package/src/components/ui/menu.tsx +6 -1
- package/src/i18n/es.ts +3 -3
- package/src/i18n/ja.ts +3 -3
- package/src/i18n/ko.ts +3 -3
- package/src/i18n/zh-cn.ts +3 -3
- package/src/i18n/zh-tw.ts +3 -3
- package/src/plugins/builtin/chat/content/composer.tsx +21 -27
- package/src/plugins/builtin/chat/content/index.tsx +31 -3
- package/src/plugins/builtin/chat/content/shortcuts.ts +4 -2
- package/src/plugins/builtin/chat/content/snapshot.ts +0 -3
- package/src/plugins/builtin/cloud/auth-actions.tsx +51 -23
- package/src/plugins/builtin/cloud/trial-offer-status-widget.tsx +3 -3
- package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +32 -25
- package/src/plugins/builtin/congress-trades/model.ts +2 -1
- package/src/plugins/builtin/congress-trades/pane.tsx +3 -0
- package/src/plugins/builtin/custom-view/index.tsx +1 -1
- package/src/plugins/builtin/custom-view/loader.ts +85 -8
- package/src/plugins/builtin/custom-view/view-spec.ts +28 -0
- package/src/plugins/builtin/equity-screener/criterion-editor.tsx +13 -4
- package/src/plugins/builtin/equity-screener/headless.ts +33 -1
- package/src/plugins/builtin/equity-screener/model.ts +58 -15
- package/src/plugins/builtin/equity-screener/pane.tsx +36 -6
- package/src/plugins/builtin/executives/format.ts +5 -4
- package/src/plugins/builtin/executives/pane.tsx +1 -1
- package/src/plugins/builtin/help/index.tsx +55 -1
- package/src/plugins/builtin/insider/model.ts +30 -2
- package/src/plugins/builtin/jobs/model.ts +2 -2
- package/src/plugins/builtin/mna/model.ts +2 -2
- package/src/plugins/builtin/notes/files.ts +2 -0
- package/src/plugins/builtin/notes/owner.tsx +20 -1
- package/src/plugins/builtin/notes/quick-notes-pane.tsx +22 -4
- package/src/plugins/builtin/notes/store.ts +6 -1
- package/src/plugins/builtin/portfolio-list/header.tsx +1 -1
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +29 -25
- package/src/plugins/builtin/series-inventory.ts +1 -0
- package/src/plugins/builtin/shared/earnings-report.ts +7 -2
- package/src/plugins/builtin/shared/use-quote-board.ts +85 -46
- package/src/plugins/builtin/short-interest/headless.ts +1 -1
- package/src/plugins/builtin/short-interest/model.ts +15 -6
- package/src/plugins/builtin/short-interest/types.ts +2 -0
- package/src/plugins/builtin/thirteenf/overlap-pane.tsx +3 -0
- package/src/plugins/builtin/thirteenf/pane.tsx +3 -0
- package/src/plugins/builtin/ticker-detail/overview/model.ts +5 -3
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +4 -4
- package/src/plugins/builtin/trace-bonds/detail.tsx +198 -0
- package/src/plugins/builtin/trace-bonds/headless.ts +62 -4
- package/src/plugins/builtin/trace-bonds/history.ts +155 -0
- package/src/plugins/builtin/trace-bonds/pane.tsx +64 -5
- package/src/plugins/installer.ts +16 -3
- package/src/plugins/plugin-names.ts +11 -2
- package/src/remote/controller.ts +9 -2
- package/src/remote/schema.ts +2 -1
- package/src/renderers/cloudflare/http-proxy.ts +67 -8
- package/src/renderers/cloudflare/proxy-session.ts +1 -1
- package/src/renderers/cloudflare/worker.ts +29 -2
- package/src/renderers/dom/desktop/icons.tsx +0 -2
- package/src/renderers/dom/styles.css +0 -3
- package/src/renderers/electrobun/bun/desktop/install-records.ts +59 -0
- package/src/renderers/electrobun/bun/desktop/installer-folder.ts +208 -592
- package/src/renderers/electrobun/bun/desktop/macos-objc.ts +14 -0
- package/src/renderers/electrobun/bun/desktop/update.ts +1 -1
- package/src/renderers/electrobun/bun/index.ts +19 -13
- package/src/renderers/electrobun/bun/window/create.ts +23 -3
- package/src/renderers/electrobun/bun/window/electrobun-window-host.ts +4 -4
- package/src/renderers/electrobun/bun/window/events.ts +4 -4
- package/src/renderers/electrobun/bun/window/frame.ts +2 -1
- package/src/renderers/electrobun/bun/window/native-min-size.ts +322 -0
- package/src/renderers/electrobun/view/backend-rpc.ts +1 -1
- package/src/sources/gloomberb-cloud/index.ts +5 -7
- package/src/sources/provider-router/batches.ts +18 -3
- package/src/sources/provider-router/financials.ts +18 -4
- package/src/types/data-provider.ts +14 -0
- package/src/types/financials.ts +15 -3
- package/src/types/headless.ts +2 -0
- package/src/utils/double-escape-close.ts +38 -16
- package/src/utils/format.ts +23 -3
- package/src/utils/price-earnings.ts +18 -0
- package/patches/electrobun@1.18.1.patch +0 -633
- package/src/api-client/types.ts +0 -2441
|
@@ -297,6 +297,34 @@ export function parseViewSpecOr(value: unknown): { spec: ViewSpec; result: ViewS
|
|
|
297
297
|
return { spec, result };
|
|
298
298
|
}
|
|
299
299
|
|
|
300
|
+
/** Where a spec names a row key. */
|
|
301
|
+
export type ViewKeyPlace = "column" | "filter" | "sort" | "symbolKey";
|
|
302
|
+
|
|
303
|
+
export interface UnknownViewKey {
|
|
304
|
+
key: string;
|
|
305
|
+
place: ViewKeyPlace;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* The row keys the spec's columns, filters, sort and symbol key name that are
|
|
310
|
+
* not in `known`, once per place, in the spec's order. A key no row carries
|
|
311
|
+
* leaves a column blank, and a filter or sort on it drops or scrambles every row.
|
|
312
|
+
*/
|
|
313
|
+
export function unknownViewKeys(spec: ViewSpec, known: ReadonlySet<string>): UnknownViewKey[] {
|
|
314
|
+
const unknown: UnknownViewKey[] = [];
|
|
315
|
+
const seen = new Set<string>();
|
|
316
|
+
const check = (key: string, place: ViewKeyPlace) => {
|
|
317
|
+
if (known.has(key) || seen.has(`${place}:${key}`)) return;
|
|
318
|
+
seen.add(`${place}:${key}`);
|
|
319
|
+
unknown.push({ key, place });
|
|
320
|
+
};
|
|
321
|
+
for (const column of spec.projection.columns) check(column.key, "column");
|
|
322
|
+
for (const filter of spec.projection.filters) check(filter.key, "filter");
|
|
323
|
+
if (spec.projection.sort) check(spec.projection.sort.by, "sort");
|
|
324
|
+
if (spec.presentation.symbolKey) check(spec.presentation.symbolKey, "symbolKey");
|
|
325
|
+
return unknown;
|
|
326
|
+
}
|
|
327
|
+
|
|
300
328
|
export function serializeViewSpec(spec: ViewSpec): string {
|
|
301
329
|
const result = validateViewSpec(spec);
|
|
302
330
|
if (!result.valid) throw new Error(result.errors.map((entry) => entry.message).join(" "));
|
|
@@ -13,7 +13,7 @@ import type {
|
|
|
13
13
|
ScreenFieldDefinition,
|
|
14
14
|
ScreenOperator,
|
|
15
15
|
} from "../../../api-client/equity-screener";
|
|
16
|
-
import { criterionInputText, criterionValueHint, criterionValueLabel, parseCriterion } from "./model";
|
|
16
|
+
import { criterionInputText, criterionValueHint, criterionValueLabel, parseCriterion, typedListName } from "./model";
|
|
17
17
|
|
|
18
18
|
export function CriterionEditor({
|
|
19
19
|
fields,
|
|
@@ -22,10 +22,14 @@ export function CriterionEditor({
|
|
|
22
22
|
onCancel,
|
|
23
23
|
focused,
|
|
24
24
|
width,
|
|
25
|
+
readWatchlist,
|
|
25
26
|
}: {
|
|
26
27
|
fields: ScreenFieldDefinition[];
|
|
27
28
|
value: ScreenCriterion | null;
|
|
28
|
-
|
|
29
|
+
/** One name typed for the symbol field, read as that watchlist's symbols with the note saying so, or null. */
|
|
30
|
+
readWatchlist?: (typed: string) => { symbols: readonly string[]; note: string } | null;
|
|
31
|
+
/** `note` says how a watchlist's name was read, as `fn EQS` says it. */
|
|
32
|
+
onSave: (criterion: ScreenCriterion, note: string | null) => void;
|
|
29
33
|
onCancel: () => void;
|
|
30
34
|
focused: boolean;
|
|
31
35
|
width: number;
|
|
@@ -52,9 +56,12 @@ export function CriterionEditor({
|
|
|
52
56
|
"save",
|
|
53
57
|
"cancel",
|
|
54
58
|
];
|
|
59
|
+
// A watchlist's name typed for the symbol list: what it reads as, before Save.
|
|
60
|
+
const listName = typedListName(field.id, operator, text);
|
|
61
|
+
const watchlistRead = listName ? readWatchlist?.(listName) ?? null : null;
|
|
55
62
|
const save = () => {
|
|
56
63
|
try {
|
|
57
|
-
onSave(parseCriterion(field, operator, text));
|
|
64
|
+
onSave(parseCriterion(field, operator, text, readWatchlist), watchlistRead?.note ?? null);
|
|
58
65
|
} catch (error) {
|
|
59
66
|
setError(error instanceof Error ? error.message : "Invalid criterion.");
|
|
60
67
|
}
|
|
@@ -142,7 +149,9 @@ export function CriterionEditor({
|
|
|
142
149
|
onSubmit={save}
|
|
143
150
|
/>
|
|
144
151
|
) : null}
|
|
145
|
-
{error ? <Notice tone="negative">{error}</Notice>
|
|
152
|
+
{error ? <Notice tone="negative">{error}</Notice>
|
|
153
|
+
: watchlistRead ? <Notice tone="muted">{watchlistRead.note}</Notice>
|
|
154
|
+
: null}
|
|
146
155
|
<Box flexDirection="row" gap={1}>
|
|
147
156
|
<Button
|
|
148
157
|
label="Save criterion"
|
|
@@ -25,17 +25,21 @@ import {
|
|
|
25
25
|
unmatchedCategoryValues,
|
|
26
26
|
} from "./categories";
|
|
27
27
|
import { REPORT_ROWS } from "../shared/headless-options";
|
|
28
|
+
import { findNamedCollection, readWatchlistArgument } from "../../../portfolio/collection-name";
|
|
28
29
|
import {
|
|
29
30
|
appendScreenPage,
|
|
30
31
|
DEFAULT_SCREEN,
|
|
31
32
|
EXAMPLE_SCREEN_DEFINITION,
|
|
32
33
|
formatScreenMetric,
|
|
34
|
+
WATCHLIST_SCREEN_DEFINITION,
|
|
35
|
+
MAX_SYMBOL_VALUES,
|
|
33
36
|
metricDate,
|
|
34
37
|
parseScreenDefinition,
|
|
35
38
|
screenColumnLabel,
|
|
36
39
|
screenDefinitionSyntax,
|
|
37
40
|
screenCurrencyEmpty,
|
|
38
41
|
screenLabel,
|
|
42
|
+
screenSymbols,
|
|
39
43
|
screenYtdBase,
|
|
40
44
|
withheldMetricNote,
|
|
41
45
|
} from "./model";
|
|
@@ -45,6 +49,30 @@ import type { ScreenDefinition } from "../../../api-client/equity-screener";
|
|
|
45
49
|
const spacedJson = (definition: ScreenDefinition) =>
|
|
46
50
|
JSON.stringify(definition).replace(/([,:])(?=["{[\d-])/g, "$1 ");
|
|
47
51
|
|
|
52
|
+
/**
|
|
53
|
+
* A symbol criterion whose one value names a watchlist (`"value": ["HY3"]`)
|
|
54
|
+
* reads as the watchlist's symbols, at most a screen's 500, with the note
|
|
55
|
+
* that says so; any other criterion is left as it is.
|
|
56
|
+
*/
|
|
57
|
+
async function withWatchlistSymbols(
|
|
58
|
+
definition: ScreenDefinition,
|
|
59
|
+
ctx: Pick<HeadlessPaneContext, "config" | "resolveWatchlist">,
|
|
60
|
+
): Promise<{ definition: ScreenDefinition; notes: string[] }> {
|
|
61
|
+
const notes: string[] = [];
|
|
62
|
+
const criteria = await Promise.all(definition.criteria.map(async (criterion) => {
|
|
63
|
+
if (criterion.field !== "symbol" || criterion.op !== "in" || criterion.value.length !== 1) return criterion;
|
|
64
|
+
const typed = criterion.value[0]!;
|
|
65
|
+
const watchlist = findNamedCollection(ctx.config.watchlists, typed);
|
|
66
|
+
if (!watchlist || !ctx.resolveWatchlist) return criterion;
|
|
67
|
+
const members = screenSymbols(((await ctx.resolveWatchlist(typed)) ?? []).map((ticker) => ticker.metadata.ticker));
|
|
68
|
+
if (members.length === 0) return criterion;
|
|
69
|
+
const read = readWatchlistArgument(typed, watchlist, members, MAX_SYMBOL_VALUES);
|
|
70
|
+
notes.push(read.note);
|
|
71
|
+
return { ...criterion, value: read.symbols };
|
|
72
|
+
}));
|
|
73
|
+
return notes.length ? { definition: { ...definition, criteria }, notes } : { definition, notes };
|
|
74
|
+
}
|
|
75
|
+
|
|
48
76
|
/** The `--definition` value of the catalog's worked example, quoted for a shell. */
|
|
49
77
|
const EXAMPLE_DEFINITION_OPTION = `--definition '${spacedJson(EXAMPLE_SCREEN_DEFINITION)}'`;
|
|
50
78
|
|
|
@@ -207,6 +235,7 @@ export const equityScreenerHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
|
207
235
|
placeholder: "json",
|
|
208
236
|
description: screenDefinitionSyntax(),
|
|
209
237
|
example: EXAMPLE_DEFINITION_OPTION,
|
|
238
|
+
examples: [`--definition '${spacedJson(WATCHLIST_SCREEN_DEFINITION)}'`],
|
|
210
239
|
normalize: (value) => {
|
|
211
240
|
readDefinition(value);
|
|
212
241
|
return value;
|
|
@@ -275,12 +304,15 @@ export const equityScreenerHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
|
275
304
|
definition = matches[0]!.definition;
|
|
276
305
|
savedName = matches[0]!.name;
|
|
277
306
|
}
|
|
307
|
+
const watchlistRead = await withWatchlistSymbols(definition, ctx);
|
|
308
|
+
definition = watchlistRead.definition;
|
|
278
309
|
if (args.options.check) {
|
|
279
310
|
const data = await fetchScreenCheck(definition, String(args.options.check), undefined, ctx.signal, ctx.apiClient);
|
|
280
311
|
return {
|
|
281
312
|
freshness: { asOf: data.snapshot.assembledAt },
|
|
282
313
|
complete: data.status === "available" && data.warnings.length === 0,
|
|
283
314
|
errors: data.warnings,
|
|
315
|
+
...(watchlistRead.notes.length ? { notes: watchlistRead.notes } : {}),
|
|
284
316
|
sections: data.criteria.length === 0 ? [{
|
|
285
317
|
title: data.row ? `${data.row.symbol}:${data.row.exchange}` : data.symbol,
|
|
286
318
|
entries: [{ label: "Result", value: screenCheckSummary(data) }],
|
|
@@ -338,7 +370,7 @@ export const equityScreenerHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
|
338
370
|
const extra = extraScreenColumns(metrics, data.definition.sort.field);
|
|
339
371
|
const states = new Set(rows.map((row) => row.metrics[metric].state));
|
|
340
372
|
const legend = STATE_LEGEND.filter(({ state }) => states.has(state)).map(({ text }) => text);
|
|
341
|
-
const notes = [...kpiGaps, ...legend];
|
|
373
|
+
const notes = [...watchlistRead.notes, ...kpiGaps, ...legend];
|
|
342
374
|
// Payload status also counts ordinary per-field sparsity; only generation
|
|
343
375
|
// warnings are failures, and more pages are not an error.
|
|
344
376
|
return {
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
type ScreenRow,
|
|
27
27
|
} from "../../../api-client/equity-screener";
|
|
28
28
|
import { yearToDateBaseLabel } from "../../../market-data/market/year-to-date";
|
|
29
|
-
import { canonicalExchange } from "../../../utils/exchanges";
|
|
29
|
+
import { canonicalExchange, parsePublicTickerKey } from "../../../utils/exchanges";
|
|
30
30
|
import { LATEST_DISTRIBUTION, TRAILING_DIVIDEND_BASIS } from "../../../utils/forward-dividend";
|
|
31
31
|
import { formatCompact, formatNumber } from "../../../utils/format";
|
|
32
32
|
import { formatPriceEarnings, NOT_MEANINGFUL } from "../../../utils/price-earnings";
|
|
@@ -529,26 +529,52 @@ export const screenLabel = (field: string) =>
|
|
|
529
529
|
field
|
|
530
530
|
.replace(/([A-Z])/g, " $1")
|
|
531
531
|
.replace(/^./, (value) => value.toUpperCase());
|
|
532
|
+
/** A category's `in` alternatives. */
|
|
533
|
+
const MAX_CATEGORY_VALUES = 25;
|
|
534
|
+
/** A list of symbols is a watchlist or a pasted list, so it takes up to 500 names. */
|
|
535
|
+
export const MAX_SYMBOL_VALUES = 500;
|
|
536
|
+
const maxCategoryValues = (field: string) => (field === "symbol" ? MAX_SYMBOL_VALUES : MAX_CATEGORY_VALUES);
|
|
537
|
+
|
|
538
|
+
/** A watchlist's tickers as a screen's symbols: each without its venue (`SAP:XETRA` is SAP), once. */
|
|
539
|
+
export function screenSymbols(tickers: readonly string[]): string[] {
|
|
540
|
+
return [...new Set(tickers.map((ticker) => parsePublicTickerKey(ticker).symbol).filter(Boolean))];
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
/** The one name typed for a symbol list, which may name a watchlist (`HY3`), or null. */
|
|
544
|
+
export function typedListName(fieldId: string, operator: ScreenOperator, text: string): string | null {
|
|
545
|
+
if (fieldId !== "symbol" || operator !== "in") return null;
|
|
546
|
+
const typed = text.split(",").map((value) => value.trim()).filter(Boolean);
|
|
547
|
+
return typed.length === 1 ? typed[0]! : null;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* A criterion as the editor's fields give it. `readWatchlist` reads one name
|
|
552
|
+
* typed for the symbol field as that watchlist's symbols (`HY3`), or null
|
|
553
|
+
* when it names none.
|
|
554
|
+
*/
|
|
532
555
|
export function parseCriterion(
|
|
533
556
|
field: ScreenFieldDefinition,
|
|
534
557
|
operator: ScreenOperator,
|
|
535
558
|
text: string,
|
|
559
|
+
readWatchlist?: (typed: string) => { symbols: readonly string[] } | null,
|
|
536
560
|
): ScreenCriterion {
|
|
537
561
|
if (!field.operators.includes(operator))
|
|
538
562
|
throw new Error("Choose a supported operator for this field.");
|
|
539
563
|
if (operator === "present" || operator === "missing")
|
|
540
564
|
return { field: field.id, op: operator };
|
|
541
565
|
if (field.kind === "category") {
|
|
542
|
-
const
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
if (operator !== "in" || !values.length || values.length >
|
|
551
|
-
throw new Error(
|
|
566
|
+
const typed = text
|
|
567
|
+
.split(",")
|
|
568
|
+
.map((value) => value.trim())
|
|
569
|
+
.filter(Boolean);
|
|
570
|
+
const name = typedListName(field.id, operator, text);
|
|
571
|
+
const listed = name ? readWatchlist?.(name)?.symbols ?? null : null;
|
|
572
|
+
const values = [...new Set(listed ?? typed)];
|
|
573
|
+
const maximum = maxCategoryValues(field.id);
|
|
574
|
+
if (operator !== "in" || !values.length || values.length > maximum || values.some((value) => value.length > 120))
|
|
575
|
+
throw new Error(field.id === "symbol"
|
|
576
|
+
? `Enter a watchlist name or 1-${maximum} comma-separated symbols, up to 120 characters each.`
|
|
577
|
+
: `Enter 1-${maximum} comma-separated values, up to 120 characters each.`);
|
|
552
578
|
return {
|
|
553
579
|
field: field.id as (typeof CATEGORY_FIELDS)[number],
|
|
554
580
|
op: "in",
|
|
@@ -606,6 +632,7 @@ export function criterionValueLabel(field: Pick<ScreenFieldDefinition, "id" | "u
|
|
|
606
632
|
export function criterionValueHint(field: Pick<ScreenFieldDefinition, "id">, operator: ScreenOperator): string {
|
|
607
633
|
if (LETTER_GRADES.has(field.id as NumericField)) return operator === "between" ? "lowest, highest grade, e.g. B, A+" : "grade, e.g. B+";
|
|
608
634
|
if (field.id === "gradeComposite") return operator === "between" ? "minimum, maximum, e.g. 3.5, 5" : "score or label, e.g. 3.5 or Strong";
|
|
635
|
+
if (field.id === "symbol" && operator === "in") return "a watchlist's name or symbols, e.g. AAPL, MSFT";
|
|
609
636
|
return operator === "between" ? "minimum, maximum" : operator === "in" ? "comma-separated values" : "threshold, e.g. 25 or 10B";
|
|
610
637
|
}
|
|
611
638
|
const SCALE: Record<string, number> = { k: 1e3, m: 1e6, b: 1e9, t: 1e12 };
|
|
@@ -619,6 +646,13 @@ export function parseThreshold(text: string): number | null {
|
|
|
619
646
|
const thresholdText = (value: number) =>
|
|
620
647
|
Math.abs(value) >= 1e6 ? formatCompact(value) : String(value);
|
|
621
648
|
|
|
649
|
+
/** A list past a category's length names its first values and counts the rest: a watchlist's 300 symbols do not fill a line. */
|
|
650
|
+
function listText(items: readonly string[]): string {
|
|
651
|
+
return items.length > MAX_CATEGORY_VALUES
|
|
652
|
+
? `${items.slice(0, 8).join(", ")} and ${items.length - 8} more`
|
|
653
|
+
: items.join(", ");
|
|
654
|
+
}
|
|
655
|
+
|
|
622
656
|
export function criterionText(criterion: ScreenCriterion): string {
|
|
623
657
|
const symbols = {
|
|
624
658
|
gte: ">=",
|
|
@@ -643,7 +677,7 @@ export function criterionText(criterion: ScreenCriterion): string {
|
|
|
643
677
|
: criterion.field === "gradeComposite" && typeof criterion.value === "number"
|
|
644
678
|
? ` ${thresholdText(criterion.value)}${COMPOSITE_BANDS.some((band) => band.from === criterion.value && band.from > 1) ? ` (${compositeLabel(criterion.value)})` : ""}`
|
|
645
679
|
: Array.isArray(criterion.value)
|
|
646
|
-
? ` ${criterion.value.map((item) => (typeof item === "number" ? thresholdText(item) : item))
|
|
680
|
+
? ` ${listText(criterion.value.map((item) => (typeof item === "number" ? thresholdText(item) : item)))}`
|
|
647
681
|
: ` ${thresholdText(criterion.value)}`;
|
|
648
682
|
return `${screenLabel(criterion.field)} ${symbols[criterion.op]}${value}`;
|
|
649
683
|
}
|
|
@@ -698,7 +732,8 @@ export function screenDefinitionSyntax(): string {
|
|
|
698
732
|
`${OBSERVED_SUBSET_FIELDS.join(" and ")} take only ${OBSERVED_SUBSET_OPERATORS.join(", ")};`,
|
|
699
733
|
`${MEMBERSHIP_FIELDS.join(" and ")} take only ${MEMBERSHIP_OPERATORS.join(", ")}, eq with 1 for a member or 0;`,
|
|
700
734
|
`the grades (${LETTER_GRADE_FIELDS.join(", ")}) are numbers from 1 (F) to 13 (A+), so B+ or better is gte 10, and gradeComposite runs from 1 to 5 (4.5 and up is Top);`,
|
|
701
|
-
`category fields (${CATEGORY_FIELDS.join(", ")}) take in with an array of 1
|
|
735
|
+
`category fields (${CATEGORY_FIELDS.join(", ")}) take in with an array of 1-${MAX_CATEGORY_VALUES} names, present, missing;`,
|
|
736
|
+
`symbol takes up to ${MAX_SYMBOL_VALUES}, or one watchlist's name, which reads as its symbols.`,
|
|
702
737
|
].join(" ");
|
|
703
738
|
}
|
|
704
739
|
|
|
@@ -714,8 +749,16 @@ export const EXAMPLE_SCREEN_DEFINITION: ScreenDefinition = {
|
|
|
714
749
|
sort: { field: "marketCap", direction: "desc" },
|
|
715
750
|
};
|
|
716
751
|
|
|
752
|
+
/** A screen of one watchlist's names: the name stands for its symbols. */
|
|
753
|
+
export const WATCHLIST_SCREEN_DEFINITION: ScreenDefinition = {
|
|
754
|
+
version: 1,
|
|
755
|
+
currency: "USD",
|
|
756
|
+
criteria: [{ field: "symbol", op: "in", value: ["Watchlist"] }],
|
|
757
|
+
sort: { field: "marketCap", direction: "desc" },
|
|
758
|
+
};
|
|
759
|
+
|
|
717
760
|
const VALUE_SHAPES: Partial<Record<ScreenOperator, string>> = {
|
|
718
|
-
in:
|
|
761
|
+
in: `an array of 1-${MAX_CATEGORY_VALUES} names (symbol: 1-${MAX_SYMBOL_VALUES}, or a watchlist's name), such as ["Gold"]`,
|
|
719
762
|
between: "[min, max] in ascending order, such as [5, 30]",
|
|
720
763
|
};
|
|
721
764
|
|
|
@@ -747,7 +790,7 @@ function checkCriterion(criterion: unknown, index: number): ScreenCriterion {
|
|
|
747
790
|
const value = item.value;
|
|
748
791
|
const shape = VALUE_SHAPES[op] ?? "one number, such as 10000000000";
|
|
749
792
|
const valid = op === "in"
|
|
750
|
-
? Array.isArray(value) && value.length >= 1 && value.length <=
|
|
793
|
+
? Array.isArray(value) && value.length >= 1 && value.length <= maxCategoryValues(field)
|
|
751
794
|
&& value.every((entry) => typeof entry === "string" && entry.trim().length > 0 && entry.length <= 120)
|
|
752
795
|
: op === "between"
|
|
753
796
|
? Array.isArray(value) && value.length === 2 && value.every((entry) => typeof entry === "number" && Number.isFinite(entry))
|
|
@@ -21,12 +21,14 @@ import {
|
|
|
21
21
|
usePaneFooter,
|
|
22
22
|
usePaneNoticeFooter,
|
|
23
23
|
usePaneTabs,
|
|
24
|
+
useRowNotes,
|
|
24
25
|
useTableLoadMore,
|
|
25
26
|
type DataTableColumn,
|
|
26
27
|
type DataTableVisibleRange,
|
|
27
28
|
type SelectControl,
|
|
28
29
|
} from "../../../components";
|
|
29
30
|
import {
|
|
31
|
+
useAppSelector,
|
|
30
32
|
useAsyncResource,
|
|
31
33
|
useAutoRefresh,
|
|
32
34
|
usePaneSettingValue,
|
|
@@ -42,6 +44,7 @@ import {
|
|
|
42
44
|
LETTER_GRADE_FIELDS,
|
|
43
45
|
NUMERIC_FIELDS,
|
|
44
46
|
type NumericField,
|
|
47
|
+
type ScreenCriterion,
|
|
45
48
|
type ScreenDefinition,
|
|
46
49
|
type ScreenField,
|
|
47
50
|
} from "../../../api-client/equity-screener";
|
|
@@ -74,6 +77,7 @@ import {
|
|
|
74
77
|
formatScreenMetric,
|
|
75
78
|
formatScreenValue,
|
|
76
79
|
GRADE_DISPLAY_FIELDS,
|
|
80
|
+
MAX_SYMBOL_VALUES,
|
|
77
81
|
gradeRankText,
|
|
78
82
|
metricDate,
|
|
79
83
|
parseScreenDefinition,
|
|
@@ -87,9 +91,11 @@ import {
|
|
|
87
91
|
screenLabel,
|
|
88
92
|
screenRowId,
|
|
89
93
|
screenSignValue,
|
|
94
|
+
screenSymbols,
|
|
90
95
|
screenYtdBase,
|
|
91
96
|
splitGradeReason,
|
|
92
97
|
} from "./model";
|
|
98
|
+
import { findNamedCollection, readWatchlistArgument } from "../../../portfolio/collection-name";
|
|
93
99
|
import { useScreenResults } from "./results";
|
|
94
100
|
import { screenWatchlistList } from "./watchlist";
|
|
95
101
|
import { unmatchedCategoryText, unmatchedCategoryValues } from "./categories";
|
|
@@ -177,6 +183,8 @@ export function resultColumns(
|
|
|
177
183
|
return fits(named) ? named : build(compact.slice(0, shown), exchange, sector, "compact");
|
|
178
184
|
}
|
|
179
185
|
const loadFields = () => fetchScreenFields();
|
|
186
|
+
const criterionRowId = (row: { id: string }) => row.id;
|
|
187
|
+
const criterionSignature = (row: { criterion: ScreenCriterion }) => JSON.stringify(row.criterion);
|
|
180
188
|
const DETAIL_LABEL_WIDTH = 24;
|
|
181
189
|
/** A long note under a value, wrapped to the detail's width rather than cut: one row per line, the label on the first. */
|
|
182
190
|
function WrappedDetailRows({ label, text, width }: { label: string; text: string; width: number }) {
|
|
@@ -389,6 +397,26 @@ function EquityScreenView({
|
|
|
389
397
|
[currentSaved?.name, data, definition, mode, openId, shownOrder], // eslint-disable-line react-hooks/exhaustive-deps
|
|
390
398
|
);
|
|
391
399
|
useMembersMenu("equity-screener:watchlist", watchlistList);
|
|
400
|
+
// A watchlist's name typed for the symbol field reads as its symbols, as `fn EQS` reads it.
|
|
401
|
+
const watchlists = useAppSelector((state) => state.config.watchlists);
|
|
402
|
+
const tickers = useAppSelector((state) => state.tickers);
|
|
403
|
+
const readWatchlist = useCallback((typed: string) => {
|
|
404
|
+
const watchlist = findNamedCollection(watchlists, typed);
|
|
405
|
+
if (!watchlist) return null;
|
|
406
|
+
const members = screenSymbols([...tickers.values()]
|
|
407
|
+
.filter((ticker) => ticker.metadata.watchlists.includes(watchlist.id))
|
|
408
|
+
.map((ticker) => ticker.metadata.ticker));
|
|
409
|
+
return members.length ? readWatchlistArgument(typed, watchlist, members, MAX_SYMBOL_VALUES) : null;
|
|
410
|
+
}, [tickers, watchlists]);
|
|
411
|
+
// How a saved criterion read a watchlist's name stays on its row until the criterion changes.
|
|
412
|
+
const criterionRows = useMemo(
|
|
413
|
+
() => definition.criteria.map((criterion, index) => ({ id: String(index), criterion })),
|
|
414
|
+
[definition.criteria],
|
|
415
|
+
);
|
|
416
|
+
const criterionNotes = useRowNotes<(typeof criterionRows)[number], string>(criterionRows, {
|
|
417
|
+
key: criterionRowId,
|
|
418
|
+
signature: criterionSignature,
|
|
419
|
+
});
|
|
392
420
|
const selectedSaved =
|
|
393
421
|
saved.data?.find((row) => row.id === savedSelectedId) ?? saved.data?.[0];
|
|
394
422
|
useEffect(() => {
|
|
@@ -857,12 +885,14 @@ function EquityScreenView({
|
|
|
857
885
|
value={editingCriterion ?? null}
|
|
858
886
|
focused={focused}
|
|
859
887
|
width={width}
|
|
888
|
+
readWatchlist={readWatchlist}
|
|
860
889
|
onCancel={() => setEditing(null)}
|
|
861
|
-
onSave={(criterion) => {
|
|
890
|
+
onSave={(criterion, note) => {
|
|
862
891
|
const criteria = [...definition.criteria];
|
|
863
892
|
if (editing < 0) criteria.push(criterion);
|
|
864
893
|
else criteria[editing] = criterion;
|
|
865
894
|
apply({ ...definition, criteria });
|
|
895
|
+
criterionNotes.setNote(String(editing < 0 ? criteria.length - 1 : editing), note);
|
|
866
896
|
setEditing(null);
|
|
867
897
|
}}
|
|
868
898
|
/>
|
|
@@ -908,10 +938,7 @@ function EquityScreenView({
|
|
|
908
938
|
align: "left",
|
|
909
939
|
},
|
|
910
940
|
]}
|
|
911
|
-
items={
|
|
912
|
-
id: String(index),
|
|
913
|
-
criterion,
|
|
914
|
-
}))}
|
|
941
|
+
items={criterionRows}
|
|
915
942
|
focused={focused && editing === null && !saveForm}
|
|
916
943
|
rootWidth={width}
|
|
917
944
|
rootHeight={bodyHeight - 1}
|
|
@@ -923,7 +950,10 @@ function EquityScreenView({
|
|
|
923
950
|
onChange: setSelectedCriterion,
|
|
924
951
|
}}
|
|
925
952
|
onActivate={(row) => setEditing(Number(row.id))}
|
|
926
|
-
renderCell={(row) =>
|
|
953
|
+
renderCell={(row) => {
|
|
954
|
+
const note = criterionNotes.noteFor(row);
|
|
955
|
+
return { text: criterionText(row.criterion), ...(note ? { note } : {}) };
|
|
956
|
+
}}
|
|
927
957
|
sortColumnId={null}
|
|
928
958
|
sortDirection="asc"
|
|
929
959
|
emptyStateTitle="No criteria. All covered equities match."
|
|
@@ -2,13 +2,14 @@ import type { CloudExecutiveRowPayload } from "../../../api-client";
|
|
|
2
2
|
import { formatShortDate } from "../../../utils/datetime-format";
|
|
3
3
|
import { formatPercentRaw } from "../../../utils/format";
|
|
4
4
|
|
|
5
|
-
/** "$36.3M", "$282K", "$50,000". */
|
|
6
|
-
export function formatPay(value: number | null | undefined): string {
|
|
5
|
+
/** "$36.3M", "$282K", "$50,000"; a table column keeps the decimals (`fixedDecimals`), so $12.0M lines up under $36.3M. */
|
|
6
|
+
export function formatPay(value: number | null | undefined, { fixedDecimals = false }: { fixedDecimals?: boolean } = {}): string {
|
|
7
7
|
if (value === null || value === undefined || !Number.isFinite(value))
|
|
8
8
|
return "—";
|
|
9
9
|
const abs = Math.abs(value);
|
|
10
|
-
|
|
11
|
-
if (abs >=
|
|
10
|
+
const trim = (text: string, zeros: RegExp) => fixedDecimals ? text : text.replace(zeros, "");
|
|
11
|
+
if (abs >= 1e9) return `$${trim((value / 1e9).toFixed(2), /\.?0+$/)}B`;
|
|
12
|
+
if (abs >= 1e6) return `$${trim((value / 1e6).toFixed(1), /\.0$/)}M`;
|
|
12
13
|
if (abs >= 1e5) return `$${Math.round(value / 1e3)}K`;
|
|
13
14
|
return `$${Math.round(value).toLocaleString("en-US")}`;
|
|
14
15
|
}
|
|
@@ -116,7 +116,7 @@ function renderOfficerCell(row: CloudExecutiveRowPayload, column: OfficerColumn)
|
|
|
116
116
|
case "name": return { text: row.name, color: colors.textBright };
|
|
117
117
|
case "title": return { text: row.title.replace(/\s+/g, " ").trim(), color: colors.textDim };
|
|
118
118
|
case "equity": return { text: equityShare(row), color: colors.textDim };
|
|
119
|
-
case "total": return { text: formatPay(row.total), color: colors.text, attributes: TextAttributes.BOLD };
|
|
119
|
+
case "total": return { text: formatPay(row.total, { fixedDecimals: true }), color: colors.text, attributes: TextAttributes.BOLD };
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
|
|
@@ -20,6 +20,9 @@ import { ShortcutTable, type ShortcutTableEntry } from "./shortcut-table";
|
|
|
20
20
|
import { resolveCommandShortcuts, resolveWindowTemplates } from "./shortcut-model";
|
|
21
21
|
import { badgeColumnWidth } from "./table-cells";
|
|
22
22
|
import { logFailure } from "../../../utils/log-failure";
|
|
23
|
+
import { VERSION } from "../../../version";
|
|
24
|
+
import { getCurrentPluginTarget } from "../../current-target";
|
|
25
|
+
import { openUrl } from "../../../components/ui/external-link";
|
|
23
26
|
|
|
24
27
|
const HELP_TABS = [
|
|
25
28
|
{ label: "Basics", value: "basics" },
|
|
@@ -32,6 +35,12 @@ const HELP_TABS = [
|
|
|
32
35
|
|
|
33
36
|
type HelpTabId = typeof HELP_TABS[number]["value"];
|
|
34
37
|
const GLOOMBERB_ISSUES_URL = "https://github.com/gloom-sh/gloomberb/issues";
|
|
38
|
+
/**
|
|
39
|
+
* Where the web app sends people who want the installed app. The route picks
|
|
40
|
+
* the installer for the visitor's OS, so one link serves every platform.
|
|
41
|
+
*/
|
|
42
|
+
const DESKTOP_DOWNLOAD_URL = "https://gloom.sh/download/desktop";
|
|
43
|
+
const DESKTOP_DOWNLOAD_DESCRIPTION = "Get Gloom for Mac or Windows";
|
|
35
44
|
|
|
36
45
|
function entry(id: string, badges: string[], description: string): ShortcutTableEntry {
|
|
37
46
|
return { id, badges, description };
|
|
@@ -133,6 +142,14 @@ function HelpPane({ focused, width, height }: PaneProps) {
|
|
|
133
142
|
void rendererHost.openExternal(GLOOMBERB_ISSUES_URL);
|
|
134
143
|
}, [rendererHost]);
|
|
135
144
|
|
|
145
|
+
const openChangelog = useCallback(() => {
|
|
146
|
+
createPaneFromTemplate("changelog-pane", { values: { version: VERSION } });
|
|
147
|
+
}, [createPaneFromTemplate]);
|
|
148
|
+
|
|
149
|
+
const openDesktopDownload = useCallback(() => {
|
|
150
|
+
void rendererHost.openExternal(DESKTOP_DOWNLOAD_URL);
|
|
151
|
+
}, [rendererHost]);
|
|
152
|
+
|
|
136
153
|
// Each tab's actions. `l` moves between tabs, so layout actions take `a`.
|
|
137
154
|
const tabHints = useMemo<PaneHint[]>(() => {
|
|
138
155
|
if (activeTabId === "basics") {
|
|
@@ -198,6 +215,29 @@ function HelpPane({ focused, width, height }: PaneProps) {
|
|
|
198
215
|
].filter((item) => hasCode(item.badges[0]!)),
|
|
199
216
|
}], [hasCode]);
|
|
200
217
|
|
|
218
|
+
// The app's version and, in the browser, the installed app: kept out of the
|
|
219
|
+
// status bar, which holds only what a new visitor needs.
|
|
220
|
+
const aboutRows = useMemo(() => [
|
|
221
|
+
...(hasCode("CHG")
|
|
222
|
+
? [{ ...entry("about-changelog", ["CHG"], tf("What's new in v{version}", { version: VERSION })), run: openChangelog }]
|
|
223
|
+
: []),
|
|
224
|
+
...(getCurrentPluginTarget() === "web"
|
|
225
|
+
? [{ ...entry("about-desktop", [], t(DESKTOP_DOWNLOAD_DESCRIPTION)), run: openDesktopDownload }]
|
|
226
|
+
: []),
|
|
227
|
+
], [hasCode, openChangelog, openDesktopDownload]);
|
|
228
|
+
const aboutSections = useMemo<Array<TableSection<ShortcutTableEntry>>>(
|
|
229
|
+
() => aboutRows.length > 0 ? [{ label: "About", items: aboutRows }] : [],
|
|
230
|
+
[aboutRows],
|
|
231
|
+
);
|
|
232
|
+
// The keyboard reaches them from the pane menu, as it does Try These.
|
|
233
|
+
usePaneMenuItems("help:about", () => activeTabId === "basics"
|
|
234
|
+
? aboutRows.map((row) => ({
|
|
235
|
+
id: row.id,
|
|
236
|
+
label: row.id === "about-desktop" ? t("Download desktop app") : `${row.description} (CHG)`,
|
|
237
|
+
onSelect: row.run,
|
|
238
|
+
}))
|
|
239
|
+
: null, [activeTabId, aboutRows]);
|
|
240
|
+
|
|
201
241
|
const referenceSections = useMemo<Array<TableSection<ShortcutTableEntry>>>(() => [
|
|
202
242
|
{
|
|
203
243
|
label: "Command Bar",
|
|
@@ -371,7 +411,7 @@ function HelpPane({ focused, width, height }: PaneProps) {
|
|
|
371
411
|
</Text>
|
|
372
412
|
|
|
373
413
|
<Box marginTop={1}>
|
|
374
|
-
<ShortcutTable sections={startSections} width={bodyWidth} keyWidth={keyColumnWidth} />
|
|
414
|
+
<ShortcutTable sections={[...startSections, ...aboutSections]} width={bodyWidth} keyWidth={keyColumnWidth} />
|
|
375
415
|
</Box>
|
|
376
416
|
</>
|
|
377
417
|
);
|
|
@@ -420,6 +460,20 @@ function HelpPane({ focused, width, height }: PaneProps) {
|
|
|
420
460
|
}
|
|
421
461
|
|
|
422
462
|
export const helpModule: PluginModule = {
|
|
463
|
+
setup(ctx) {
|
|
464
|
+
// The browser's way to the installed app; the desktop app and the terminal are installed already.
|
|
465
|
+
ctx.registerCommand({
|
|
466
|
+
id: "download-desktop-app",
|
|
467
|
+
label: "Download Desktop App",
|
|
468
|
+
description: DESKTOP_DOWNLOAD_DESCRIPTION,
|
|
469
|
+
keywords: ["desktop", "download", "install", "app", "mac", "macos", "windows"],
|
|
470
|
+
category: "config",
|
|
471
|
+
hidden: () => getCurrentPluginTarget() !== "web",
|
|
472
|
+
execute: () => {
|
|
473
|
+
openUrl(DESKTOP_DOWNLOAD_URL);
|
|
474
|
+
},
|
|
475
|
+
});
|
|
476
|
+
},
|
|
423
477
|
panes: [
|
|
424
478
|
{
|
|
425
479
|
id: "help",
|
|
@@ -118,7 +118,26 @@ export interface InsiderSummaryFigures {
|
|
|
118
118
|
incomplete: boolean;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
/**
|
|
121
|
+
/** Words a filer adds or leaves out without naming another class: "Common Stock" and "Common" are one. */
|
|
122
|
+
const SECURITY_FILLER_WORDS = new Set(["stock", "stocks", "share", "shares"]);
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* One key for every spelling filers give the same class of security: "Common
|
|
126
|
+
* Stock", "Common", "COMMON STOCK, $0.001 PAR VALUE" and "Common Stock, par
|
|
127
|
+
* value $.01 per share" are one class, and so are "Class A Common Stock" and
|
|
128
|
+
* "Common Stock, Class A". Class A and Class B, common and preferred, Series A
|
|
129
|
+
* and Series B stay apart.
|
|
130
|
+
*/
|
|
131
|
+
export function securityClassKey(title: string): string {
|
|
132
|
+
const words = title.toLowerCase()
|
|
133
|
+
// A par or nominal value tail names the same shares: ", par value $0.0001 per share", "$.01 par value".
|
|
134
|
+
.replace(/(?:[$€£]?\s*\d*\.?\d+\s*)?\b(?:par(?:\s+value)?|nominal\s+value|stated\s+value)\b.*$/, " ")
|
|
135
|
+
.split(/[^a-z0-9]+/)
|
|
136
|
+
.filter((word) => word && !SECURITY_FILLER_WORDS.has(word));
|
|
137
|
+
return words.length ? [...new Set(words)].sort().join(" ") : title.trim().toLowerCase();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** Totals of the loaded non-derivative buys and sales in the last 90 days, by class of security and side. */
|
|
122
141
|
export function buildInsiderSummaryFigures(parsed: readonly ParsedInsiderFiling[], now = Date.now(), context: readonly ParsedInsiderFiling[] = parsed): InsiderSummaryFigures | null {
|
|
123
142
|
if (parsed.some(({ isLoading }) => isLoading)) return null;
|
|
124
143
|
const amendments = buildInsiderAmendmentScopes(context);
|
|
@@ -129,6 +148,8 @@ export function buildInsiderSummaryFigures(parsed: readonly ParsedInsiderFiling[
|
|
|
129
148
|
});
|
|
130
149
|
const cutoff = now - NINETY_DAYS_MS;
|
|
131
150
|
const totals = new Map<string, InsiderSideTotal>();
|
|
151
|
+
// Shares under each spelling of a class, so a total is named the way most of its shares were filed.
|
|
152
|
+
const spellings = new Map<string, Map<string, number>>();
|
|
132
153
|
for (const entry of parsed) {
|
|
133
154
|
const { transaction } = entry;
|
|
134
155
|
if (!transaction || transaction.isDerivative || transaction.shares == null || !transaction.securityTitle) continue;
|
|
@@ -136,13 +157,20 @@ export function buildInsiderSummaryFigures(parsed: readonly ParsedInsiderFiling[
|
|
|
136
157
|
if (date == null || !Number.isFinite(date) || date < cutoff || date > now) continue;
|
|
137
158
|
if (transaction.transactionType !== "P" && transaction.transactionType !== "S") continue;
|
|
138
159
|
const security = transaction.securityTitle;
|
|
139
|
-
const key = `${security}:${transaction.transactionType}`;
|
|
160
|
+
const key = `${securityClassKey(security)}:${transaction.transactionType}`;
|
|
140
161
|
const total = totals.get(key) ?? { security, side: transaction.transactionType, shares: 0, value: 0, knownValue: true, unreconciled: false };
|
|
141
162
|
total.unreconciled ||= affectingInsiderAmendments(entry, amendments).length > 0;
|
|
142
163
|
total.shares += transaction.shares;
|
|
143
164
|
total.knownValue &&= transaction.totalValue != null;
|
|
144
165
|
total.value += transaction.totalValue ?? 0;
|
|
145
166
|
totals.set(key, total);
|
|
167
|
+
const filed = spellings.get(key) ?? new Map<string, number>();
|
|
168
|
+
filed.set(security, (filed.get(security) ?? 0) + transaction.shares);
|
|
169
|
+
spellings.set(key, filed);
|
|
170
|
+
}
|
|
171
|
+
for (const [key, total] of totals) {
|
|
172
|
+
const filed = [...spellings.get(key)!];
|
|
173
|
+
total.security = filed.reduce((best, entry) => (entry[1] > best[1] ? entry : best), filed[0]!)[0];
|
|
146
174
|
}
|
|
147
175
|
return { totals: [...totals.values()], incomplete };
|
|
148
176
|
}
|
|
@@ -266,10 +266,10 @@ export function buildMoverRows(movers: readonly CloudJobsMoverPayload[]): MoverR
|
|
|
266
266
|
mover,
|
|
267
267
|
ticker: mover.ticker,
|
|
268
268
|
company: mover.companyName ?? "",
|
|
269
|
-
open: formatCompact(mover.openCount),
|
|
269
|
+
open: formatCompact(mover.openCount, { fixedDecimals: true }),
|
|
270
270
|
change: mover.change30d ? formatChange(mover.change30d) : "",
|
|
271
271
|
changeValue: mover.change30d?.percent ?? mover.change30d?.count ?? null,
|
|
272
|
-
posted30d: mover.posted30d != null ? formatCompact(mover.posted30d) : "",
|
|
272
|
+
posted30d: mover.posted30d != null ? formatCompact(mover.posted30d, { fixedDecimals: true }) : "",
|
|
273
273
|
posted30dValue: mover.posted30d ?? null,
|
|
274
274
|
new7d: mover.new7d > 0 ? String(mover.new7d) : "",
|
|
275
275
|
function: functionLabel(mover.topFunction),
|
|
@@ -21,10 +21,10 @@ export function formatPerShare(amount: number, currency: string | null, maxDigit
|
|
|
21
21
|
return sign ? `${sign}${fixed}` : `${code} ${fixed}`;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
/** A headline amount: "$1.8B", "€420M", "GBP 1.2B". */
|
|
24
|
+
/** A headline amount: "$1.8B", "€420M", "GBP 1.2B"; "$1.80B" in a table column. */
|
|
25
25
|
export function formatDealValue(value: number | null, currency: string | null): string {
|
|
26
26
|
if (value == null || !Number.isFinite(value) || value <= 0) return MISSING;
|
|
27
|
-
const compact = formatCompact(value
|
|
27
|
+
const compact = formatCompact(value);
|
|
28
28
|
const code = currency?.trim().toUpperCase() ?? "";
|
|
29
29
|
if (!code) return compact;
|
|
30
30
|
const sign = CURRENCY_SIGNS[code];
|
|
@@ -5,6 +5,8 @@ export interface QuickNoteEntry {
|
|
|
5
5
|
id: string;
|
|
6
6
|
title: string;
|
|
7
7
|
updatedAt?: number;
|
|
8
|
+
/** Who wrote a cloud note, when the server says; never saved to disk. */
|
|
9
|
+
createdBy?: string | null;
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
/** A stored note: `key` is what `load`/`save` take, not the file path. */
|