gloomberb 0.20.3 → 0.20.4
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/account/auth-dialog.tsx +17 -0
- package/src/api-client/data.ts +6 -0
- package/src/api-client/fx-interventions.ts +64 -0
- package/src/api-client/index.ts +1 -0
- package/src/api-client/release-summaries.ts +21 -0
- package/src/app/keybindings/actions.ts +2 -2
- package/src/app/pane-runtime/ticker-open-runtime.ts +245 -66
- package/src/cli/commands/market.ts +77 -1
- package/src/cli/commands/news-search.ts +1 -3
- package/src/cli/commands/plugins.ts +27 -5
- package/src/cli/commands/system.ts +19 -3
- package/src/cli/commands/ticker.ts +60 -19
- package/src/cli/index.ts +8 -8
- package/src/cli/pane-functions/function-help.ts +3 -3
- package/src/cli/report-tables.ts +18 -6
- package/src/cli/result.ts +15 -7
- package/src/cli/types.ts +2 -0
- package/src/components/chart/composite/axis-overlays.tsx +22 -0
- package/src/components/chart/composite/composite-chart.tsx +54 -13
- package/src/components/chart/composite/event-captions.ts +109 -0
- package/src/components/chart/composite/event-guides.ts +74 -0
- package/src/components/chart/composite/rasterizer.ts +2 -0
- package/src/components/chart/composite/text-renderer.ts +2 -0
- package/src/components/chart/composite/types.ts +31 -0
- package/src/components/command-bar/layout-items/focused-pane.ts +5 -5
- package/src/components/command-bar/routes/root/provider-search.ts +5 -4
- package/src/components/command-bar/routes/ticker-search/results.ts +51 -0
- package/src/components/command-bar/routes/ticker-search/route.ts +3 -2
- package/src/components/layout/detached-pane-shell.tsx +1 -1
- package/src/components/layout/floating-pane.tsx +5 -1
- package/src/components/layout/pane/footer/index.tsx +21 -14
- package/src/components/layout/pane/footer/model.ts +6 -0
- package/src/components/layout/shell/action-menu-overlay.tsx +10 -5
- package/src/components/layout/shell/active-drag.ts +149 -105
- package/src/components/layout/shell/drag/drop-zones.ts +162 -0
- package/src/components/layout/shell/drag/index.ts +47 -218
- package/src/components/layout/shell/drag/live.ts +10 -3
- package/src/components/layout/shell/drag/overlays.tsx +182 -5
- package/src/components/layout/shell/drag/runtime.ts +29 -6
- package/src/components/layout/shell/drag/shared-edges.ts +156 -0
- package/src/components/layout/shell/index.tsx +11 -6
- package/src/components/layout/shell/menu.ts +11 -2
- package/src/components/layout/shell/native/pointer-runtime.ts +25 -0
- package/src/components/layout/shell/native/window-state.ts +2 -2
- package/src/components/layout/shell/pane/layers.tsx +71 -7
- package/src/components/layout/shell/terminal-pointer-runtime.ts +18 -9
- package/src/components/layout/shell/window-mode/index.ts +8 -10
- package/src/components/layout/window-edit/mode.ts +39 -7
- package/src/components/layout/window-edit/presentation.ts +1 -1
- package/src/components/onboarding/onboarding-keyboard.ts +4 -0
- package/src/components/onboarding/onboarding-wizard.tsx +8 -3
- package/src/components/ui/button.tsx +2 -0
- package/src/components/ui/choice-dialog.tsx +1 -0
- package/src/components/ui/data-table/index.tsx +4 -3
- package/src/components/ui/list-view.tsx +7 -12
- package/src/components/ui/loading.tsx +10 -3
- package/src/components/ui/menu.tsx +6 -2
- package/src/components/ui/quote.ts +14 -1
- package/src/data/config/layout.ts +5 -2
- package/src/docs/snapshot.json +29 -5
- package/src/i18n/es.ts +9 -8
- package/src/i18n/ja.ts +9 -8
- package/src/i18n/ko.ts +9 -8
- package/src/i18n/zh-cn.ts +9 -8
- package/src/i18n/zh-tw.ts +9 -8
- package/src/layout/pane-manager/floating-actions.ts +17 -0
- package/src/layout/pane-manager/floating-stack.ts +187 -0
- package/src/layout/pane-manager/floating.ts +4 -2
- package/src/layout/pane-manager/gridlock.ts +5 -1
- package/src/layout/pane-manager/index.ts +11 -0
- package/src/layout/pane-manager/layout-state.ts +10 -3
- package/src/market-data/futures-board.ts +46 -1
- package/src/market-data/futures-contract.ts +12 -3
- package/src/market-data/fx-interventions.ts +270 -0
- package/src/news/news-model.ts +44 -2
- package/src/plugins/builtin/alerts/cli.ts +4 -4
- package/src/plugins/builtin/alerts/format.ts +1 -2
- package/src/plugins/builtin/alerts/headless.ts +1 -2
- package/src/plugins/builtin/alerts/move-checks.ts +12 -6
- package/src/plugins/builtin/alerts/move.ts +30 -9
- package/src/plugins/builtin/alerts/pane.tsx +0 -2
- package/src/plugins/builtin/alerts/storage.ts +4 -2
- package/src/plugins/builtin/alerts/types.ts +12 -0
- package/src/plugins/builtin/changelog/index.tsx +292 -101
- package/src/plugins/builtin/changelog/versions.ts +293 -0
- package/src/plugins/builtin/chart-composer/intervention-events.ts +105 -0
- package/src/plugins/builtin/chart-composer/pane.tsx +21 -7
- package/src/plugins/builtin/chat/message/render-state.ts +2 -5
- package/src/plugins/builtin/cloud/askg/attached-pane.tsx +10 -5
- package/src/plugins/builtin/cloud/askg/controller.ts +141 -5
- package/src/plugins/builtin/cloud/askg/executor.ts +113 -4
- package/src/plugins/builtin/cloud/askg/manifest.ts +28 -13
- package/src/plugins/builtin/cloud/askg/model.ts +14 -4
- package/src/plugins/builtin/cloud/askg/pane.tsx +70 -46
- package/src/plugins/builtin/cloud/askg/turn-parts.tsx +70 -0
- package/src/plugins/builtin/cloud/terminal-relay/engine.ts +50 -130
- package/src/plugins/builtin/cloud/terminal-relay/policy.ts +327 -7
- package/src/plugins/builtin/cloud/terminal-relay/prompts.tsx +2 -1
- package/src/plugins/builtin/cloud/terminal-relay/redact.ts +47 -6
- package/src/plugins/builtin/commodities-energy/index.tsx +1 -3
- package/src/plugins/builtin/commodities-energy/view-state.ts +3 -0
- package/src/plugins/builtin/cot/headless.ts +14 -2
- package/src/plugins/builtin/earnings/index.tsx +2 -2
- package/src/plugins/builtin/futures/index.tsx +25 -4
- package/src/plugins/builtin/futures/model.ts +28 -32
- package/src/plugins/builtin/futures/series.ts +4 -3
- package/src/plugins/builtin/futures/table.tsx +16 -9
- package/src/plugins/builtin/futures/use-board-terms.ts +3 -3
- package/src/plugins/builtin/help/index.tsx +3 -3
- package/src/plugins/builtin/help/keybindings-editor.tsx +18 -4
- package/src/plugins/builtin/layout-manager/index.tsx +8 -8
- package/src/plugins/builtin/news/headless.ts +2 -2
- package/src/plugins/builtin/news/index.tsx +3 -3
- package/src/plugins/builtin/perps/markets-section.tsx +5 -2
- package/src/plugins/builtin/plugin-marketplace/pane.tsx +11 -11
- package/src/plugins/builtin/portfolio-list/summary/index.tsx +3 -1
- package/src/plugins/builtin/research/event-model.ts +9 -1
- package/src/plugins/builtin/research/event-sources.ts +22 -0
- package/src/plugins/builtin/research/headless.ts +3 -3
- package/src/plugins/builtin/shared/cloud-upgrade.ts +27 -3
- package/src/plugins/builtin/ticker-detail/overview/components.tsx +54 -5
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +28 -13
- package/src/plugins/builtin/ticker-detail/pane.tsx +7 -2
- package/src/plugins/installer.ts +45 -0
- package/src/remote/resources.ts +12 -1
- package/src/remote/schema.ts +1 -0
- package/src/remote/semantic-helpers.ts +29 -1
- package/src/remote/semantic-tree.tsx +32 -15
- package/src/renderers/cloudflare/worker.ts +16 -1
- package/src/renderers/dom/styles.css +40 -6
- package/src/renderers/share/layout-view.tsx +1 -1
- package/src/sources/gloomberb-cloud/news.ts +35 -12
- package/src/state/opening-ticker-panes.ts +47 -0
- package/src/test-support/cli-context.ts +2 -0
- package/src/test-support/preload.ts +4 -1
- package/src/tickers/instrument-kind.ts +23 -3
- package/src/types/config.ts +5 -0
- package/src/types/context-menu.ts +2 -0
- package/src/types/plugin-commands.ts +140 -0
- package/src/types/plugin-context.ts +125 -0
- package/src/types/plugin-contributions.ts +55 -0
- package/src/types/plugin-definition.ts +234 -0
- package/src/types/plugin-notifications.ts +38 -0
- package/src/types/plugin-pane-settings.ts +114 -0
- package/src/types/plugin-pane-templates.ts +160 -0
- package/src/types/plugin-panes.ts +221 -0
- package/src/types/plugin-reports.ts +35 -0
- package/src/types/plugin-shared.ts +14 -0
- package/src/types/plugin-state.ts +71 -0
- package/src/types/plugin.ts +14 -1169
- package/src/ui/index.tsx +14 -3
- package/src/updater/github-releases.ts +23 -0
- package/src/utils/cli-output.ts +22 -9
|
@@ -129,6 +129,10 @@ import {
|
|
|
129
129
|
import { historyCoverageNotice } from "../../sources/history-coverage";
|
|
130
130
|
import { fetchHistoryResult } from "../../sources/history-result";
|
|
131
131
|
import { settleWithin } from "../../utils/async-deadline";
|
|
132
|
+
import type { FxInterventionsPayload } from "../../api-client/fx-interventions";
|
|
133
|
+
import {
|
|
134
|
+
fxInterventionLatestNote, fxInterventionPair, fxInterventionWindowNote, loadFxInterventions, type FxInterventionPair,
|
|
135
|
+
} from "../../market-data/fx-interventions";
|
|
132
136
|
import { maxDrawdownText } from "../../utils/max-drawdown";
|
|
133
137
|
import { isPastPriceWindow, loadPriceWindowHistory, PRICE_WINDOW_FROM_HELP, PRICE_WINDOW_TO_HELP, priceWindowText, readPriceWindow, type PriceWindow } from "../../utils/price-window";
|
|
134
138
|
import {
|
|
@@ -185,11 +189,11 @@ import { CRYPTO_BOARD_HINT, quoteNotes } from "./crypto-hints";
|
|
|
185
189
|
import { bareFuturesCode, futuresBoardContract, futuresContractByWord } from "../../market-data/futures-board";
|
|
186
190
|
import { commodityNamedIn, commoditySearchName } from "../../market-data/commodity-names";
|
|
187
191
|
import { newsEmptyMessage } from "./news-hints";
|
|
192
|
+
import { METALS_NEWS_TOPIC } from "../../sources/gloomberb-cloud/news";
|
|
188
193
|
import {
|
|
189
194
|
closestStoriesReason,
|
|
190
195
|
commodityNewsRoute,
|
|
191
196
|
commonWordCandidate,
|
|
192
|
-
METALS_NEWS_TOPIC,
|
|
193
197
|
metalCodeNewsRoute,
|
|
194
198
|
type MetalNewsRoute,
|
|
195
199
|
metalNewsHeading,
|
|
@@ -198,6 +202,7 @@ import {
|
|
|
198
202
|
newsSearchHeading,
|
|
199
203
|
newsSearchText,
|
|
200
204
|
newsSearchTextProblem,
|
|
205
|
+
newestFirst,
|
|
201
206
|
noMetalStoriesMessage,
|
|
202
207
|
noStoriesMessage,
|
|
203
208
|
quotedSearchCommand,
|
|
@@ -418,6 +423,16 @@ export function readHistoryRange(value: string): HistoryRange | null {
|
|
|
418
423
|
return VALID_RANGES.has(range) ? range : null;
|
|
419
424
|
}
|
|
420
425
|
|
|
426
|
+
/**
|
|
427
|
+
* The range a symbol's place holds, typed as a count and a unit (`1mo`, `3m`,
|
|
428
|
+
* `5 days`), or null. `history CC=F 1mo` loaded 1MO, a Milan listing, beside
|
|
429
|
+
* cocoa. A bare word stays a symbol: ALL and MAX are listings, and YTD only
|
|
430
|
+
* means a range after --range.
|
|
431
|
+
*/
|
|
432
|
+
function rangeTypedAsSymbol(entry: string): HistoryRange | null {
|
|
433
|
+
return /^\s*\d+\s*[a-z]+\s*$/i.test(entry) ? readHistoryRange(entry) : null;
|
|
434
|
+
}
|
|
435
|
+
|
|
421
436
|
function parseRange(value: string | undefined, ctx: Parameters<CliCommandDef["execute"]>[1]): HistoryRange {
|
|
422
437
|
const range = readHistoryRange(value ?? "1Y");
|
|
423
438
|
if (!range) ctx.fail(`Unknown range "${value}".`, `Use one of ${HISTORY_RANGES.join(", ")}.`);
|
|
@@ -1497,6 +1512,35 @@ function historyCommand({ range, window }: HistoryAsk): string {
|
|
|
1497
1512
|
|
|
1498
1513
|
/** How long `history` waits for a future's contract terms to name its unit before using the catalog's. */
|
|
1499
1514
|
const HISTORY_PRICE_UNIT_WAIT_MS = 1_500;
|
|
1515
|
+
/** How long a yen pair's answer waits for Japan's intervention record, read beside it; the note is left out after. */
|
|
1516
|
+
const INTERVENTION_NOTE_WAIT_MS = 3_000;
|
|
1517
|
+
|
|
1518
|
+
/** Japan's intervention record for a yen pair, read beside its rate or bars; null for any other pair, or none in time. */
|
|
1519
|
+
function loadInterventionsFor(pair: FxInterventionPair | null, market: MarketContext): Promise<FxInterventionsPayload | null> {
|
|
1520
|
+
return pair ? settleWithin((market.fxInterventions ?? (() => loadFxInterventions()))(), INTERVENTION_NOTE_WAIT_MS) : Promise.resolve(null);
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
/** The last day a bar's period covers: a weekly bar's Sunday, a monthly bar's month end, else its own day. */
|
|
1524
|
+
function barPeriodEnd(date: string, interval: string | null | undefined): string {
|
|
1525
|
+
const start = Date.parse(`${date}T00:00:00Z`);
|
|
1526
|
+
if (interval === "1wk") return new Date(start + 6 * 86_400_000).toISOString().slice(0, 10);
|
|
1527
|
+
if (interval !== "1mo") return date;
|
|
1528
|
+
const day = new Date(start);
|
|
1529
|
+
return new Date(Date.UTC(day.getUTCFullYear(), day.getUTCMonth() + 1, 0)).toISOString().slice(0, 10);
|
|
1530
|
+
}
|
|
1531
|
+
|
|
1532
|
+
/** The interventions from the first bar shown to the end of the last one's period. */
|
|
1533
|
+
async function interventionWindowNote(
|
|
1534
|
+
record: Promise<FxInterventionsPayload | null>,
|
|
1535
|
+
pair: FxInterventionPair | null,
|
|
1536
|
+
rows: readonly { date: string; interval?: string | null }[],
|
|
1537
|
+
): Promise<string | null> {
|
|
1538
|
+
const first = rows[0]?.date.slice(0, 10), lastRow = rows.at(-1);
|
|
1539
|
+
const last = lastRow ? barPeriodEnd(lastRow.date.slice(0, 10), lastRow.interval) : undefined;
|
|
1540
|
+
if (!pair || !first || !last) return null;
|
|
1541
|
+
const payload = await record;
|
|
1542
|
+
return payload ? fxInterventionWindowNote(payload, pair, first, last) : null;
|
|
1543
|
+
}
|
|
1500
1544
|
|
|
1501
1545
|
/** How long `history` waits for the daily bars that rebuild contradictory monthly bars before printing them with blanks. */
|
|
1502
1546
|
const MONTHLY_REBUILD_WAIT_MS = 8_000;
|
|
@@ -1558,6 +1602,9 @@ async function loadListingHistory(
|
|
|
1558
1602
|
// A future's prices are in its contract's unit (US cents / bushel), as FUT and G spell it; asked beside the bars.
|
|
1559
1603
|
const priceUnit = isFuturesInstrument(symbol, null) ? settleWithin(loadFuturesPriceUnit(symbol), HISTORY_PRICE_UNIT_WAIT_MS) : Promise.resolve(null);
|
|
1560
1604
|
const quoted = quoteAnswer.then((answer) => answer.quote);
|
|
1605
|
+
// USDJPY=X's bars name Japan's interventions they span.
|
|
1606
|
+
const interventionPair = fxInterventionPair(symbol, exchange);
|
|
1607
|
+
const interventions = loadInterventionsFor(interventionPair, market);
|
|
1561
1608
|
const fate = lookups ? listingFateLoader(listing, market, quoted, { successor: true }) : null;
|
|
1562
1609
|
const request = { command: historyCommand(ask), noun: "history", ...(fate ? { fate } : {}) };
|
|
1563
1610
|
const [answered, quote] = await Promise.all([
|
|
@@ -1660,6 +1707,7 @@ async function loadListingHistory(
|
|
|
1660
1707
|
// NG=F's rows are November's to the 23rd and December's from the 26th: each roll named, and thin bars said.
|
|
1661
1708
|
historyRollNote(listing.symbol, data) ?? [], historyThinNote(data) ?? [],
|
|
1662
1709
|
historyBarStatusNote(forming ? served : data, { tradingDay: venueTradingDay(venue, Date.now()) }) ?? [],
|
|
1710
|
+
await interventionWindowNote(interventions, interventionPair, data) ?? [],
|
|
1663
1711
|
].flat();
|
|
1664
1712
|
return {
|
|
1665
1713
|
listing, identity, unit, data, resolution, interval, intraday, volume, freshness, notes,
|
|
@@ -1800,6 +1848,19 @@ async function runHistory(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
|
|
|
1800
1848
|
const currency = file != null || requestedExchange ? null : currencyNameStop(args, "history");
|
|
1801
1849
|
if (currency) ctx.fail(currency.message, currency.details);
|
|
1802
1850
|
if (wide || file != null || args.includes("-") || uniqueEntries(args).length > 1 || args.some((arg) => /[,;]/.test(arg))) {
|
|
1851
|
+
// `history CC=F 1mo` asks for a month of cocoa, not for cocoa and 1MO: it says which option reads it.
|
|
1852
|
+
const typedRange = rangeOption == null && !window ? args.find((arg) => rangeTypedAsSymbol(arg)) : undefined;
|
|
1853
|
+
if (typedRange) {
|
|
1854
|
+
// The command as typed with the range moved to --range: its other options (--wide, --exchange) and the output
|
|
1855
|
+
// flags read before the command (--csv, --limit) stay.
|
|
1856
|
+
const range = rangeTypedAsSymbol(typedRange)!;
|
|
1857
|
+
const at = rawArgs.indexOf(typedRange);
|
|
1858
|
+
const { format, limit, tail } = ctx.cliOptions;
|
|
1859
|
+
const words = [...rawArgs.filter((_arg, index) => index !== at), "--range", range,
|
|
1860
|
+
...format === "text" ? [] : [`--${format}`], ...limit == null ? [] : ["--limit", String(limit)], ...tail == null ? [] : ["--tail", String(tail)]];
|
|
1861
|
+
const shell = (arg: string) => /[\s"'$`\\!&|;<>()*?#~]/.test(arg) ? `"${arg.replace(/(["\\$`])/g, "\\$1")}"` : arg;
|
|
1862
|
+
ctx.fail(`"${typedRange}" reads as a range, not a symbol: give it as --range ${range}.`, `gloom history ${words.map(shell).join(" ")}`);
|
|
1863
|
+
}
|
|
1803
1864
|
if (backAdjust) ctx.fail("--back-adjust stitches one continuous future, such as ES=F.", `Usage: gloom ${HISTORY_USAGE}`);
|
|
1804
1865
|
return runHistoryList(args, file, requestedExchange, ask, ctx, { wide });
|
|
1805
1866
|
}
|
|
@@ -2557,6 +2618,14 @@ async function runNews(rawArgs: string[], ctx: Parameters<CliCommandDef["execute
|
|
|
2557
2618
|
quoteLoad,
|
|
2558
2619
|
]);
|
|
2559
2620
|
const searchedFor = listing ? articles[0]?.searchedFor : undefined;
|
|
2621
|
+
// A future's feed already searched its commodity's stories when none are filed under it (the pane reads the same
|
|
2622
|
+
// way): they print as they did when this command searched them, newest first under "the commodity KC=F trades".
|
|
2623
|
+
const searchedFuture = listing && searchedFor && !listing.exchange && !feed && isFuturesInstrument(listing.symbol, quote?.instrumentType)
|
|
2624
|
+
? futuresBoardContract(listing.symbol) ?? bareFuturesCode(args[0]) : null;
|
|
2625
|
+
if (searchedFuture && commoditySearchName(searchedFuture) === searchedFor) {
|
|
2626
|
+
await printNewsSearch(searchedFor, newestFirst(articles), { reason: `the commodity ${searchedFuture.symbol} trades`, commodity: false }, ctx);
|
|
2627
|
+
return;
|
|
2628
|
+
}
|
|
2560
2629
|
if (listing && searchedFor) {
|
|
2561
2630
|
await printNewsSearch(searchedFor, articles, { reason: `no stories filed under ${listing.symbol}`, ticker: listing.key }, ctx);
|
|
2562
2631
|
return;
|
|
@@ -3596,6 +3665,10 @@ async function runFx(rawArgs: string[], ctx: Parameters<CliCommandDef["execute"]
|
|
|
3596
3665
|
(payload) => ({ payload }),
|
|
3597
3666
|
(error: unknown) => ({ error: unavailableOnServer(error, "Forwards are not available from Gloom Cloud yet: it serves no short rates.") }),
|
|
3598
3667
|
) : null;
|
|
3668
|
+
// A yen pair's rate names Japan's latest intervention in it; a conversion is about the amount, not the pair.
|
|
3669
|
+
const interventionPair = amount == null && !tenor && currency !== baseCurrency && (currency === "JPY" || baseCurrency === "JPY")
|
|
3670
|
+
? { base: currency, quote: baseCurrency } : null;
|
|
3671
|
+
const interventions = loadInterventionsFor(interventionPair, market);
|
|
3599
3672
|
// The pair's own quote, as `quote` and the FX board read it; a pair with none is crossed through the dollar.
|
|
3600
3673
|
const now = Date.now();
|
|
3601
3674
|
const read = await readFxQuoteRate(currency, baseCurrency, (targets, options) => market.dataProvider.getQuotesBatch(targets, options),
|
|
@@ -3697,6 +3770,9 @@ async function runFx(rawArgs: string[], ctx: Parameters<CliCommandDef["execute"]
|
|
|
3697
3770
|
: [],
|
|
3698
3771
|
...rateNotes,
|
|
3699
3772
|
];
|
|
3773
|
+
const record = await interventions;
|
|
3774
|
+
const interventionNote = record && interventionPair ? fxInterventionLatestNote(record, interventionPair) : null;
|
|
3775
|
+
if (interventionNote) warnings.push(interventionNote);
|
|
3700
3776
|
// The peso's dollar rate is the official one; the market rates Buenos Aires prices imply follow it, each with its inputs.
|
|
3701
3777
|
const peso = isPesoDollarPair(currency, baseCurrency)
|
|
3702
3778
|
? await loadPesoDollarRates((targets) => market.dataProvider.getQuotesBatch(targets, { forceRefresh: ctx.cliOptions.refresh }))
|
|
@@ -77,7 +77,7 @@ export function newsFallbackText(symbol: string): string | null {
|
|
|
77
77
|
* the list is then read by date, which its help promises. A story with no
|
|
78
78
|
* date goes last; equal dates keep the service's order.
|
|
79
79
|
*/
|
|
80
|
-
function newestFirst(articles: readonly NewsArticle[]): NewsArticle[] {
|
|
80
|
+
export function newestFirst(articles: readonly NewsArticle[]): NewsArticle[] {
|
|
81
81
|
const time = (article: NewsArticle) => {
|
|
82
82
|
const at = new Date(article.publishedAt as Date | string | number).getTime();
|
|
83
83
|
return Number.isFinite(at) ? at : -Infinity;
|
|
@@ -123,8 +123,6 @@ export function closestStoriesReason(text: string): string {
|
|
|
123
123
|
return `no story has every word of "${text}"; the closest, most words first`;
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
/** The NI code of the metal markets: prices, futures, bullion and the trusts that hold it, not a miner's releases. */
|
|
127
|
-
export const METALS_NEWS_TOPIC = "metals";
|
|
128
126
|
|
|
129
127
|
/** A metal's market news, for what `news` was given: its name, its future, or its board code. */
|
|
130
128
|
export interface MetalNewsRoute {
|
|
@@ -21,11 +21,12 @@ import {
|
|
|
21
21
|
import { linkHostPackages } from "../../plugins/host-link";
|
|
22
22
|
import {
|
|
23
23
|
installedPluginDirectories,
|
|
24
|
+
installedPluginDirectoriesNamed,
|
|
25
|
+
installedPluginId,
|
|
24
26
|
loadRegistryListings,
|
|
25
27
|
readPluginRemote,
|
|
26
28
|
readPluginRemoteHeads,
|
|
27
29
|
updatePlugin,
|
|
28
|
-
validatePluginDirectoryName,
|
|
29
30
|
type RegistryListing,
|
|
30
31
|
} from "../../plugins/installer";
|
|
31
32
|
import { isReservedBuiltinPluginId } from "../../plugins/ownership";
|
|
@@ -58,8 +59,19 @@ function absorbedNotice(absorbed: AbsorbedPlugin, directory: string | null): str
|
|
|
58
59
|
return directory ? `${built}; remove this copy with "gloom remove ${directory}".` : `${built}.`;
|
|
59
60
|
}
|
|
60
61
|
|
|
62
|
+
/**
|
|
63
|
+
* The folder of the installed plugin a command names, by its id or by its
|
|
64
|
+
* folder; fails when none, or more than one, answers to it.
|
|
65
|
+
*/
|
|
66
|
+
export function installedPluginArg(name: string): string {
|
|
67
|
+
const matches = installedPluginDirectoriesNamed(name);
|
|
68
|
+
if (matches.length > 1) fail(`"${name}" is the id of ${matches.length} installed plugins: ${matches.join(", ")}.`, "Name one by its folder.");
|
|
69
|
+
if (matches.length === 0) fail(`Plugin "${name}" was not found.`, PLUGINS_DIR);
|
|
70
|
+
return matches[0]!;
|
|
71
|
+
}
|
|
72
|
+
|
|
61
73
|
export async function updatePlugins(name?: string) {
|
|
62
|
-
const dirs = name ? [
|
|
74
|
+
const dirs = name ? [installedPluginArg(name)] : installedPluginDirectories();
|
|
63
75
|
|
|
64
76
|
if (dirs.length === 0) {
|
|
65
77
|
console.log(cliStyles.muted("No plugins installed."));
|
|
@@ -197,7 +209,7 @@ function listedHostImports<T>(
|
|
|
197
209
|
* build the desktop and web app need actually compiles.
|
|
198
210
|
*/
|
|
199
211
|
async function doctorPlugin(nameOrPath: string): Promise<PluginDoctorReport> {
|
|
200
|
-
const candidate = nameOrPath.includes("/") || nameOrPath.startsWith(".") ? resolve(nameOrPath) : join(PLUGINS_DIR, nameOrPath);
|
|
212
|
+
const candidate = nameOrPath.includes("/") || nameOrPath.startsWith(".") ? resolve(nameOrPath) : join(PLUGINS_DIR, installedPluginArg(nameOrPath));
|
|
201
213
|
if (!existsSync(candidate)) fail(`Plugin "${nameOrPath}" was not found.`, PLUGINS_DIR);
|
|
202
214
|
const directory = basename(candidate);
|
|
203
215
|
const linked = lstatSync(candidate).isSymbolicLink();
|
|
@@ -272,6 +284,8 @@ async function doctorPlugin(nameOrPath: string): Promise<PluginDoctorReport> {
|
|
|
272
284
|
|
|
273
285
|
if (!plugin.version) add("version", "warn", "No version; the marketplace cannot tell when an update is available.");
|
|
274
286
|
if (isReservedBuiltinPluginId(plugin.id)) add("id", "fail", `"${plugin.id}" is reserved by a built-in module.`);
|
|
287
|
+
// gloom plugins and the plugin directory read gloom.json's; plugin enable takes the export's.
|
|
288
|
+
else if (manifest.id && manifest.id !== plugin.id) add("id", "warn", `gloom.json says "${manifest.id}" and the plugin exports "${plugin.id}": make them the same.`);
|
|
275
289
|
else add("id", "ok", plugin.id);
|
|
276
290
|
|
|
277
291
|
const badTargets = (plugin.targets ?? []).filter((target) => !ALL_PLUGIN_TARGETS.includes(target as PluginTarget));
|
|
@@ -316,6 +330,9 @@ export async function doctorPlugins(nameOrPath?: string): Promise<PluginDoctorRe
|
|
|
316
330
|
}
|
|
317
331
|
|
|
318
332
|
export interface InstalledPluginRow {
|
|
333
|
+
/** What `plugin info|enable|disable` take; every other plugin command takes it too. */
|
|
334
|
+
id: string;
|
|
335
|
+
/** The folder under the plugins directory, which every plugin command also takes. */
|
|
319
336
|
name: string;
|
|
320
337
|
version: string;
|
|
321
338
|
commit: string;
|
|
@@ -361,6 +378,7 @@ async function readInstalledPlugins(options: { check?: boolean }): Promise<Insta
|
|
|
361
378
|
const commit = readPluginCommit(dir);
|
|
362
379
|
const blocked = builtIn ? absorbedNotice(builtIn, name) : linked ? null : checkPluginCompatibility(dir)?.error;
|
|
363
380
|
const row: InstalledPluginRow = {
|
|
381
|
+
id: installedPluginId(name),
|
|
364
382
|
name,
|
|
365
383
|
version,
|
|
366
384
|
commit: linked ? "linked" : commit ? commit.slice(0, 7) : "",
|
|
@@ -383,8 +401,11 @@ async function readInstalledPlugins(options: { check?: boolean }): Promise<Insta
|
|
|
383
401
|
|
|
384
402
|
export async function listPlugins(ctx: CliCommandContext, options: { check?: boolean } = {}) {
|
|
385
403
|
const plugins = await readInstalledPlugins(options);
|
|
404
|
+
// The folder `gloom install` names for the repository, where it is not the id.
|
|
405
|
+
const folders = plugins.some((plugin) => plugin.name !== plugin.id);
|
|
386
406
|
const columns = [
|
|
387
|
-
{ key: "
|
|
407
|
+
{ key: "id", header: "Plugin", shrink: false },
|
|
408
|
+
...(folders ? [{ key: "folder", header: "Folder", value: (row: Record<string, unknown>) => row.name }] : []),
|
|
388
409
|
{ key: "version", header: "Version" },
|
|
389
410
|
{ key: "commit", header: "Commit" },
|
|
390
411
|
...(options.check ? [{ key: "update", header: "Update" }] : []),
|
|
@@ -400,11 +421,12 @@ export async function listPlugins(ctx: CliCommandContext, options: { check?: boo
|
|
|
400
421
|
renderTable(
|
|
401
422
|
columns.map(({ header, shrink }) => ({ header, shrink })),
|
|
402
423
|
rows.map((row) => columns.map(({ key }) => {
|
|
424
|
+
if (key === "folder") return row.name === row.id ? "" : cliStyles.muted(row.name);
|
|
403
425
|
const value = String(row[key as keyof InstalledPluginRow] ?? "");
|
|
404
426
|
return key === "update" && value && value !== "up to date" ? cliStyles.warning(value) : value;
|
|
405
427
|
})),
|
|
406
428
|
),
|
|
407
|
-
...rows.filter((row) => row.blocked).map((row) => cliStyles.warning(`${row.
|
|
429
|
+
...rows.filter((row) => row.blocked).map((row) => cliStyles.warning(`${row.id} is not loaded: ${row.blocked}`)),
|
|
408
430
|
"",
|
|
409
431
|
renderStats([["Directory", cliStyles.muted(PLUGINS_DIR)]]),
|
|
410
432
|
].join("\n");
|
|
@@ -527,10 +527,15 @@ export function createSystemCliCommands(): CliCommandDef[] {
|
|
|
527
527
|
"plugin info <id>",
|
|
528
528
|
"plugin enable <id>",
|
|
529
529
|
"plugin disable <id>",
|
|
530
|
-
"plugin doctor [
|
|
530
|
+
"plugin doctor [id-or-path]",
|
|
531
531
|
"plugin link <path>",
|
|
532
532
|
],
|
|
533
533
|
sections: [{
|
|
534
|
+
title: "Naming a plugin",
|
|
535
|
+
lines: [
|
|
536
|
+
"Every plugin command takes an installed plugin's id or its folder, as gloom plugins lists them.",
|
|
537
|
+
],
|
|
538
|
+
}, {
|
|
534
539
|
title: "Developing a plugin",
|
|
535
540
|
lines: [
|
|
536
541
|
"link puts a symlink to a local checkout in the plugins folder, so edits are live on the next start.",
|
|
@@ -583,19 +588,30 @@ export function createSystemCliCommands(): CliCommandDef[] {
|
|
|
583
588
|
)).length,
|
|
584
589
|
}));
|
|
585
590
|
|
|
591
|
+
// An installed plugin by its folder too: `gloom install` names the
|
|
592
|
+
// folder for the repository (`gloom-hackernews`), and `gloom plugins`
|
|
593
|
+
// shows it beside the id (`hackernews`).
|
|
594
|
+
const pluginId = async (name: string): Promise<string> => {
|
|
595
|
+
if (services.services.pluginRegistry.allPlugins.has(name) || builtinPluginGroupMembers(name)) return name;
|
|
596
|
+
const { installedPluginDirectoriesNamed, installedPluginRegistryId } = await import("../../plugins/installer");
|
|
597
|
+
const [directory, ...others] = installedPluginDirectoriesNamed(name);
|
|
598
|
+
if (!directory || others.length > 0) return name;
|
|
599
|
+
return await installedPluginRegistryId(directory) ?? name;
|
|
600
|
+
};
|
|
601
|
+
|
|
586
602
|
if (action === "list") {
|
|
587
603
|
ctx.printResult({ data: pluginRows() });
|
|
588
604
|
return;
|
|
589
605
|
}
|
|
590
606
|
if (action === "info") {
|
|
591
|
-
const id = requireArg(args[1], "Usage: gloom plugin info <id>", ctx);
|
|
607
|
+
const id = await pluginId(requireArg(args[1], "Usage: gloom plugin info <id>", ctx));
|
|
592
608
|
const row = pluginRows().find((plugin) => plugin.id === id);
|
|
593
609
|
if (!row) ctx.fail(`Plugin "${id}" is not available.`);
|
|
594
610
|
ctx.printResult({ data: row });
|
|
595
611
|
return;
|
|
596
612
|
}
|
|
597
613
|
if (action === "enable" || action === "disable") {
|
|
598
|
-
const id = requireArg(args[1], `Usage: gloom plugin ${action} <id>`, ctx);
|
|
614
|
+
const id = await pluginId(requireArg(args[1], `Usage: gloom plugin ${action} <id>`, ctx));
|
|
599
615
|
// A retired id that now names a group of built-ins switches all of them.
|
|
600
616
|
const targetIds = builtinPluginGroupMembers(id) ?? [id];
|
|
601
617
|
for (const targetId of targetIds) {
|
|
@@ -2,7 +2,8 @@ import { logFailure } from "../../utils/log-failure";
|
|
|
2
2
|
import { formatShortDate, parseDisplayDate } from "../../utils/datetime-format";
|
|
3
3
|
import { formatReportedMoney, REPORTING_CURRENCY_NOT_SOURCED } from "../../utils/reported-money";
|
|
4
4
|
import {
|
|
5
|
-
appTtmRate, BANK_ENTERPRISE_VALUE, computedEnterpriseValueNote, convertedPriceEarningsNote,
|
|
5
|
+
appTtmRate, BANK_ENTERPRISE_VALUE, computedEnterpriseValueNote, convertedPriceEarningsNote, enterpriseValueCheck, enterpriseValueLabel,
|
|
6
|
+
enterpriseValueReconciliationNote,
|
|
6
7
|
epsConversionNote, fundamentalsCurrency, isBankEnterpriseValue, reportedEnterpriseValue, trailingEpsSourceNote, ttmAtAppRate, ttmConversionNote,
|
|
7
8
|
withBankEnterpriseValue,
|
|
8
9
|
} from "../../utils/fundamentals";
|
|
@@ -55,6 +56,7 @@ import { instrumentTypeLabel, resolveTickerInstrumentKind } from "../../tickers/
|
|
|
55
56
|
import { INDEX_POINTS_LABEL, isIndexLevel, reportedQuoteVolume } from "../../market-data/market/index-level";
|
|
56
57
|
import type { SecFilingItem } from "../../types/data-provider";
|
|
57
58
|
import type { NewsArticle } from "../../news/types";
|
|
59
|
+
import { summaryRestatesHeadline } from "../../news/news-model";
|
|
58
60
|
import type { TickerRecord } from "../../types/ticker";
|
|
59
61
|
import type { CliCommandContext } from "../../types/plugin";
|
|
60
62
|
import { getPortfolioPositionMetrics, getPortfolioQuoteDisplay, lotCostFxRate, resolvePortfolioMarketValue, resolvePortfolioPositionPnl } from "../../portfolio/position-metrics";
|
|
@@ -107,7 +109,7 @@ import { readFundFacts } from "../../market-data/fund-facts";
|
|
|
107
109
|
import { taxEquivalentLines, type TaxEquivalentAnalysis } from "../../market-data/tax-equivalent";
|
|
108
110
|
import { isRoundTheClockCoin } from "../../utils/crypto-pair";
|
|
109
111
|
import { ipoDetailNotes, ipoMetricRows, loadTickerIpo, type TickerIpo } from "../../plugins/builtin/ipo-calendar/listing-ipo";
|
|
110
|
-
import {
|
|
112
|
+
import { newsFallbackNotice } from "../../sources/gloomberb-cloud/news";
|
|
111
113
|
|
|
112
114
|
const NEWS_ITEM_LIMIT = 5;
|
|
113
115
|
const SEC_FILING_LIMIT = 5;
|
|
@@ -193,26 +195,48 @@ function cashRunwayText(runway: CashRunway): string {
|
|
|
193
195
|
return [part(quarter, "quarter"), trailing ? part(trailing, "TTM") : `TTM ${runway.trailingGap === "short-history" ? SHORT_RUNWAY_HISTORY : "not reported"}`].filter((text): text is string => !!text).join(" \u00b7 ");
|
|
194
196
|
}
|
|
195
197
|
|
|
196
|
-
|
|
198
|
+
/** The balance sheet lines of a statement: a quarter that ends on the year's closing day shares them with the year. */
|
|
199
|
+
const BALANCE_SHEET_FIELDS = [
|
|
200
|
+
"cashAndCashEquivalents", "cashCashEquivalentsAndShortTermInvestments", "totalAssets", "totalLiabilities", "totalDebt", "totalEquity",
|
|
201
|
+
] as const satisfies ReadonlyArray<keyof FinancialStatement>;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* A statement's lines. Income incl. NCI and Income Common print only where they read differently from Net Income,
|
|
205
|
+
* and `sameDay`, the year a quarter closes with, leaves out the balance sheet lines it already shows with the same
|
|
206
|
+
* figure: the two statements' balance sheets are one, on one date.
|
|
207
|
+
*/
|
|
208
|
+
function buildStatementMetrics(
|
|
209
|
+
statement: FinancialStatement,
|
|
210
|
+
currency?: string,
|
|
211
|
+
codes = false,
|
|
212
|
+
runway?: CashRunway | null,
|
|
213
|
+
sameDay?: FinancialStatement | null,
|
|
214
|
+
): Array<[string, string]> {
|
|
197
215
|
const money = (value: number | undefined, perShare = false) => formatReportedMoney(value, currency, perShare, codes);
|
|
216
|
+
const netIncome = money(statement.netIncome);
|
|
217
|
+
const income = (value: number | undefined) => (value != null && money(value) === netIncome ? "—" : money(value));
|
|
218
|
+
const balance = (field: (typeof BALANCE_SHEET_FIELDS)[number]) => {
|
|
219
|
+
const text = money(statement[field]);
|
|
220
|
+
return sameDay?.date === statement.date && statement[field] != null && money(sameDay[field]) === text ? "—" : text;
|
|
221
|
+
};
|
|
198
222
|
return [
|
|
199
223
|
["Revenue", money(statement.totalRevenue)],
|
|
200
224
|
["Gross Profit", money(statement.grossProfit)],
|
|
201
225
|
["Operating Income", money(statement.operatingIncome)],
|
|
202
|
-
["Net Income",
|
|
203
|
-
["Income incl. NCI",
|
|
204
|
-
["Income Common",
|
|
226
|
+
["Net Income", netIncome],
|
|
227
|
+
["Income incl. NCI", income(statement.netIncomeIncludingNoncontrollingInterests)],
|
|
228
|
+
["Income Common", income(statement.netIncomeCommonStockholders)],
|
|
205
229
|
["EBITDA", money(statement.ebitda)],
|
|
206
230
|
["Operating Cash Flow", money(statement.operatingCashFlow)],
|
|
207
231
|
["Free Cash Flow", money(statement.freeCashFlow)],
|
|
208
|
-
["Cash",
|
|
209
|
-
["Cash + ST Inv",
|
|
232
|
+
["Cash", balance("cashAndCashEquivalents")],
|
|
233
|
+
["Cash + ST Inv", balance("cashCashEquivalentsAndShortTermInvestments")],
|
|
210
234
|
// The latest quarter's only: months of cash at its burn and the trailing year's.
|
|
211
235
|
...runway ? [["Cash Runway", cashRunwayText(runway)] as [string, string]] : [],
|
|
212
|
-
["Total Assets",
|
|
213
|
-
["Total Liabilities",
|
|
214
|
-
["Total Debt",
|
|
215
|
-
["Equity",
|
|
236
|
+
["Total Assets", balance("totalAssets")],
|
|
237
|
+
["Total Liabilities", balance("totalLiabilities")],
|
|
238
|
+
["Total Debt", balance("totalDebt")],
|
|
239
|
+
["Equity", balance("totalEquity")],
|
|
216
240
|
["Diluted EPS", money(statement.eps, true)],
|
|
217
241
|
// Labelled only when the service says the row counts receipts.
|
|
218
242
|
["Diluted Shares", statement.dilutedShares != null && statement.shareBasis === "depositary_receipt"
|
|
@@ -591,6 +615,21 @@ function enterpriseValueFigure(figure: MetricFigure, fundamentals: TickerFinanci
|
|
|
591
615
|
return label === "provider" && figure.text !== "—" ? { ...figure, text: `${figure.text} (provider)` } : figure;
|
|
592
616
|
}
|
|
593
617
|
|
|
618
|
+
/**
|
|
619
|
+
* The fundamentals `ticker` reads its one EV from: where the provider's is more than 5% from market cap + debt - cash,
|
|
620
|
+
* the computed figure in its place, so the overview gives one number and no reconciliation line (`fundamentals` and
|
|
621
|
+
* `valuation` keep both, and JSON keeps the provider's beside its check).
|
|
622
|
+
*/
|
|
623
|
+
function withComputedEnterpriseValue(
|
|
624
|
+
fundamentals: TickerFinancials["fundamentals"],
|
|
625
|
+
currency: string | undefined,
|
|
626
|
+
): TickerFinancials["fundamentals"] {
|
|
627
|
+
const check = enterpriseValueLabel(fundamentals) === "provider" ? enterpriseValueCheck(fundamentals) : undefined;
|
|
628
|
+
if (!fundamentals || !check || !(typeof check.computed === "number" && check.computed > 0)
|
|
629
|
+
|| (currency && check.currency && check.currency !== currency)) return fundamentals;
|
|
630
|
+
return { ...fundamentals, enterpriseValue: check.computed, enterpriseValueCheck: undefined };
|
|
631
|
+
}
|
|
632
|
+
|
|
594
633
|
function percentFigure(fraction: number | null | undefined, format: (value: number) => string): MetricFigure {
|
|
595
634
|
return fraction != null ? { text: format(fraction), value: fraction * 100, unit: "%" } : { text: "—" };
|
|
596
635
|
}
|
|
@@ -1329,8 +1368,9 @@ export async function buildTickerReport({
|
|
|
1329
1368
|
? `${formatCompact(capitalization.value)} ${capitalization.currency}${await inBase(capitalization.value, capitalization.currency)}`
|
|
1330
1369
|
: "—";
|
|
1331
1370
|
// Shown in the same currency as the market cap, so the two can be compared.
|
|
1332
|
-
const enterpriseValue = reportedEnterpriseValue(priced.fundamentals);
|
|
1333
1371
|
const evCurrency = enterpriseValueCurrency(quote, fundamentals);
|
|
1372
|
+
const shownFundamentals = withComputedEnterpriseValue(priced.fundamentals, evCurrency);
|
|
1373
|
+
const enterpriseValue = reportedEnterpriseValue(shownFundamentals);
|
|
1334
1374
|
const enterpriseValueText = `${formatReportedMoney(enterpriseValue, evCurrency)}${enterpriseValue != null && evCurrency
|
|
1335
1375
|
? await inBase(enterpriseValue, evCurrency) : ""}`;
|
|
1336
1376
|
|
|
@@ -1389,7 +1429,7 @@ export async function buildTickerReport({
|
|
|
1389
1429
|
|
|
1390
1430
|
// A listing of the last year may have no statements yet: its IPO says how recent it is.
|
|
1391
1431
|
const listing = { listedSince: ipo ? ipo.deal.listingDate ?? ipo.deal.firstDay?.session ?? null : null };
|
|
1392
|
-
const metrics = withoutStockRows(fundamentalsMetrics(quote,
|
|
1432
|
+
const metrics = withoutStockRows(fundamentalsMetrics(quote, shownFundamentals, profile, { text: marketCapText }, priceReturns,
|
|
1393
1433
|
fundamentalsCurrency(financials, listing), { text: enterpriseValueText }, distributions, bondFund, codes), isFund);
|
|
1394
1434
|
const reportedCurrency = financials.financialCurrency?.trim();
|
|
1395
1435
|
const statements = [...financials.annualStatements, ...financials.quarterlyStatements];
|
|
@@ -1401,7 +1441,7 @@ export async function buildTickerReport({
|
|
|
1401
1441
|
|
|
1402
1442
|
const beforeFundamentals = lines.length;
|
|
1403
1443
|
appendMetricSection(lines, "Fundamentals", metricLines(metrics));
|
|
1404
|
-
for (const note of fundamentalsNotes(priced, metrics, quote?.currency)) lines.push(cliStyles.muted(note));
|
|
1444
|
+
for (const note of fundamentalsNotes({ ...priced, fundamentals: shownFundamentals }, metrics, quote?.currency)) lines.push(cliStyles.muted(note));
|
|
1405
1445
|
// The trailing block beside statements in another currency, when no conversion says why.
|
|
1406
1446
|
const split = metrics.some((metric) => TRAILING_MONEY_METRICS.has(metric.label) && metric.text !== "—")
|
|
1407
1447
|
? ttmCurrencySplitNote(priced.fundamentals, [latestAnnual, latestQuarter].flatMap((row) => row ? [statementCurrency(row)] : []))
|
|
@@ -1431,7 +1471,7 @@ export async function buildTickerReport({
|
|
|
1431
1471
|
if (latestQuarter) {
|
|
1432
1472
|
const runway = cashRunway(financials);
|
|
1433
1473
|
appendMetricSection(lines, `Latest Quarter (${statementPeriodText(latestQuarter.date, statementFilings?.latestQuarter ?? null)})`,
|
|
1434
|
-
buildStatementMetrics(latestQuarter, statementCurrency(latestQuarter), codes, runway));
|
|
1474
|
+
buildStatementMetrics(latestQuarter, statementCurrency(latestQuarter), codes, runway, latestAnnual));
|
|
1435
1475
|
unsourced(latestQuarter);
|
|
1436
1476
|
// How the months are counted, and an offering since the balance sheet that the cash does not include yet.
|
|
1437
1477
|
if (burnsCash(runway)) lines.push(cliStyles.muted(runwayMethod(runway.includesShortTerm)));
|
|
@@ -1454,9 +1494,10 @@ export async function buildTickerReport({
|
|
|
1454
1494
|
return publishedAt ? formatTimestamp(publishedAt.getTime()) : "";
|
|
1455
1495
|
})(),
|
|
1456
1496
|
],
|
|
1457
|
-
|
|
1497
|
+
// A summary that only says the headline again is left out; JSON keeps it.
|
|
1498
|
+
body: item.summary && !summaryRestatesHeadline(item.title, item.summary) ? item.summary : undefined,
|
|
1458
1499
|
link: item.url,
|
|
1459
|
-
})), recentNews[0]?.searchedFor ?
|
|
1500
|
+
})), recentNews[0]?.searchedFor ? newsFallbackNotice(symbol, recentNews[0].searchedFor) : null);
|
|
1460
1501
|
|
|
1461
1502
|
appendFeedSection(lines, "Recent SEC Filings", recentSecFilings.map((filing) => ({
|
|
1462
1503
|
title: (() => {
|
|
@@ -1798,7 +1839,7 @@ export async function ticker(symbol: string, dependencies: TickerCommandDependen
|
|
|
1798
1839
|
// stopped trading shows none of the profile and figures another listing under its symbol was served with.
|
|
1799
1840
|
const shownFinancials = await atReportTtmRate(otherProfile ? withoutResearch(resolvedFinancials) : resolvedFinancials, toBase);
|
|
1800
1841
|
if (dependencies.printResult) {
|
|
1801
|
-
const newsNote = recentNews[0]?.searchedFor ?
|
|
1842
|
+
const newsNote = recentNews[0]?.searchedFor ? newsFallbackNotice(requestSymbol, recentNews[0].searchedFor) : null;
|
|
1802
1843
|
const warnings = [...choiceNotes, quoteNote, newsNote].filter((note): note is string => !!note);
|
|
1803
1844
|
dependencies.printResult({
|
|
1804
1845
|
freshness,
|
package/src/cli/index.ts
CHANGED
|
@@ -37,7 +37,7 @@ import { overviewCliCommands } from "./commands/overview";
|
|
|
37
37
|
import { remoteCliCommand } from "./commands/remote";
|
|
38
38
|
import { createSystemCliCommands } from "./commands/system";
|
|
39
39
|
import { brokerCliCommand, ibkrCliCommand } from "./commands/broker";
|
|
40
|
-
import { listPlugins, updatePlugins } from "./commands/plugins";
|
|
40
|
+
import { installedPluginArg, listPlugins, updatePlugins } from "./commands/plugins";
|
|
41
41
|
import { installListedPlugin, removePlugin } from "../plugins/installer";
|
|
42
42
|
import {
|
|
43
43
|
catalogCommandHits,
|
|
@@ -276,17 +276,17 @@ export function createCoreCliCommands(
|
|
|
276
276
|
},
|
|
277
277
|
{
|
|
278
278
|
name: "update",
|
|
279
|
-
description: "Update installed plugins, or one by
|
|
279
|
+
description: "Update installed plugins, or one by id or folder",
|
|
280
280
|
help: {
|
|
281
281
|
group: CLI_COMMAND_GROUPS.plugins,
|
|
282
|
-
usage: ["update [
|
|
282
|
+
usage: ["update [plugin]"],
|
|
283
283
|
sections: [{
|
|
284
284
|
title: "Updating Gloom itself",
|
|
285
285
|
lines: [
|
|
286
286
|
"The app updates itself from stable releases. config set updates.channel nightly adds the nightly build of main; see gloom help config.",
|
|
287
287
|
],
|
|
288
288
|
}],
|
|
289
|
-
examples: ["update", "update
|
|
289
|
+
examples: ["update", "update tv"],
|
|
290
290
|
},
|
|
291
291
|
execute: async (args) => {
|
|
292
292
|
await updatePlugins(args[0]);
|
|
@@ -298,15 +298,15 @@ export function createCoreCliCommands(
|
|
|
298
298
|
description: "Remove an installed plugin",
|
|
299
299
|
help: {
|
|
300
300
|
group: CLI_COMMAND_GROUPS.plugins,
|
|
301
|
-
usage: ["remove <
|
|
302
|
-
examples: ["remove
|
|
301
|
+
usage: ["remove <plugin>"],
|
|
302
|
+
examples: ["remove tv"],
|
|
303
303
|
},
|
|
304
304
|
execute: async (args) => {
|
|
305
305
|
const name = args[0];
|
|
306
306
|
if (!name) {
|
|
307
|
-
fail("Usage: gloom remove <
|
|
307
|
+
fail("Usage: gloom remove <plugin>");
|
|
308
308
|
}
|
|
309
|
-
await removePlugin(name);
|
|
309
|
+
await removePlugin(installedPluginArg(name));
|
|
310
310
|
},
|
|
311
311
|
},
|
|
312
312
|
apiCliCommand,
|
|
@@ -408,7 +408,7 @@ export const FUNCTION_HELP: Readonly<Record<string, FunctionHelp>> = {
|
|
|
408
408
|
bloomberg: ["CACS"],
|
|
409
409
|
},
|
|
410
410
|
EVTS: {
|
|
411
|
-
summary: "The market
|
|
411
|
+
summary: "The market board: report days with implied and past moves, or a past or coming week or day of them; a ticker highlights its row.",
|
|
412
412
|
usage: ["EVTS", "EVTS NVDA", "gloom fn EVTS --week last", "gloom fn EVTS --date 2026-10-15"],
|
|
413
413
|
keys: [key("t", "icker"), key("e", "stimates"), key("c", "alls"), key("a", "nalysts")],
|
|
414
414
|
data: EARNINGS_DAYS,
|
|
@@ -416,7 +416,7 @@ export const FUNCTION_HELP: Readonly<Record<string, FunctionHelp>> = {
|
|
|
416
416
|
docs: "ERN",
|
|
417
417
|
},
|
|
418
418
|
ERN: {
|
|
419
|
-
summary: "
|
|
419
|
+
summary: "A company's report history with its surprises and moves, or several tickers' next reports. Alone it is the market board EVTS shows.",
|
|
420
420
|
usage: ["ERN", "ERN NVDA, AAPL, MSFT"],
|
|
421
421
|
keys: [key("t", "icker"), key("e", "stimates"), key("c", "alls"), key("a", "nalysts")],
|
|
422
422
|
data: EARNINGS_DAYS,
|
|
@@ -1351,7 +1351,7 @@ export const FUNCTION_HELP: Readonly<Record<string, FunctionHelp>> = {
|
|
|
1351
1351
|
bloomberg: [],
|
|
1352
1352
|
},
|
|
1353
1353
|
LMA: {
|
|
1354
|
-
summary: "Float
|
|
1354
|
+
summary: "Float panes or return them to the layout, swap, remove and save panes and layouts.",
|
|
1355
1355
|
usage: ["LMA", "LMA float"],
|
|
1356
1356
|
keys: [],
|
|
1357
1357
|
data: null,
|
package/src/cli/report-tables.ts
CHANGED
|
@@ -135,16 +135,28 @@ export function float32Shortest(value: number): number | null {
|
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
/**
|
|
138
|
-
* A number without binary floating-point noise (47.350000000000364, 0.0615 * 100
|
|
139
|
-
* as the text view drops it
|
|
140
|
-
*
|
|
138
|
+
* A number without binary floating-point noise (47.350000000000364, 0.0615 * 100,
|
|
139
|
+
* a change of -1.8000000000000114), as the text view drops it and every export
|
|
140
|
+
* writes it, JSON included: twelve significant digits, and on figures of ten
|
|
141
|
+
* thousand or more eight decimals (a coin holding to the satoshi) as far as
|
|
142
|
+
* fifteen significant digits, so an amount in the trillions keeps its cents.
|
|
143
|
+
* Sub-penny prices, FX rates and yields keep every digit a source quotes.
|
|
144
|
+
* Whole numbers stay as they are.
|
|
141
145
|
*/
|
|
142
146
|
export function exportNumber(value: number): number {
|
|
143
|
-
if (Number.
|
|
144
|
-
const
|
|
147
|
+
if (!Number.isFinite(value) || Number.isInteger(value)) return Object.is(value, -0) ? 0 : value;
|
|
148
|
+
const magnitude = Math.floor(Math.log10(Math.abs(value)));
|
|
149
|
+
const rounded = float32Shortest(value) ?? (magnitude < 4
|
|
150
|
+
? Number(value.toPrecision(12))
|
|
151
|
+
: Number(value.toFixed(Math.max(0, Math.min(8, 14 - magnitude)))));
|
|
145
152
|
return Object.is(rounded, -0) ? 0 : rounded;
|
|
146
153
|
}
|
|
147
154
|
|
|
155
|
+
/** `JSON.stringify`'s replacer for what the CLI writes as JSON: every number as `exportNumber` writes it. */
|
|
156
|
+
export function exportJsonValue(_key: string, value: unknown): unknown {
|
|
157
|
+
return typeof value === "number" ? exportNumber(value) : value;
|
|
158
|
+
}
|
|
159
|
+
|
|
148
160
|
function isoInstant(time: number): string {
|
|
149
161
|
return new Date(time).toISOString().replace(".000Z", "Z");
|
|
150
162
|
}
|
|
@@ -706,7 +718,7 @@ export function renderReportNdjson(report: CliReportTables, freshness?: ReportFr
|
|
|
706
718
|
const value = row[index];
|
|
707
719
|
object[column] = value === undefined || value === "" ? null : value;
|
|
708
720
|
});
|
|
709
|
-
return JSON.stringify(object);
|
|
721
|
+
return JSON.stringify(object, exportJsonValue);
|
|
710
722
|
});
|
|
711
723
|
}).join("\n");
|
|
712
724
|
}
|