gloomberb 0.19.5 → 0.19.6
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/patches/@opentui%2Fcore@0.3.2.patch +86 -25
- package/src/api-client/equity-screener.ts +23 -0
- package/src/app/pane-runtime/index.tsx +2 -0
- package/src/app/pane-runtime/plugin-bindings.ts +10 -1
- package/src/app.tsx +63 -16
- package/src/cli/commands/market.ts +149 -10
- package/src/cli/commands/search.ts +21 -3
- package/src/cli/commands/ticker.ts +74 -33
- package/src/cli/glossary.ts +3 -3
- package/src/cli/known-gaps.ts +8 -0
- package/src/cli/listing-arg.ts +12 -0
- package/src/cli/pane-functions/capabilities.ts +2 -0
- package/src/cli/pane-functions/catalog.ts +22 -4
- package/src/cli/pane-functions/function-help.ts +8 -5
- package/src/cli/pane-functions/headless.ts +4 -3
- package/src/cli/pane-functions/resolver.ts +75 -2
- package/src/cli/quote-answer.ts +9 -0
- package/src/cli/symbol-list.ts +54 -2
- package/src/cli/symbol-rows.ts +14 -2
- package/src/cli/ticker-resolution.ts +89 -20
- package/src/components/chart/composite/axis-overlays.tsx +60 -27
- package/src/components/chart/composite/composite-chart.tsx +118 -63
- package/src/components/chart/composite/cursor-source.ts +111 -0
- package/src/components/chart/composite/format.ts +168 -6
- package/src/components/chart/composite/legend.tsx +8 -4
- package/src/components/chart/composite/panel-labels.ts +20 -1
- package/src/components/chart/composite/panel-surface.tsx +201 -92
- package/src/components/chart/composite/price-axis-labels.tsx +92 -46
- package/src/components/chart/composite/price-series.ts +31 -8
- package/src/components/chart/composite/scene.ts +154 -59
- package/src/components/chart/composite/series-axis-tags.tsx +4 -2
- package/src/components/chart/composite/time-axis.ts +13 -5
- package/src/components/chart/composite/time-scale.ts +211 -56
- package/src/components/chart/composite/types.ts +11 -1
- package/src/components/chart/composite/use-composite-chart-keyboard.ts +32 -12
- package/src/components/chart/curve/curve-surface.tsx +5 -2
- package/src/components/chart/curve/model.ts +4 -1
- package/src/components/chart/native/use-bitmap-metrics.ts +81 -0
- package/src/components/chart/static/series.ts +3 -0
- package/src/components/command-bar/commands/collection-list.ts +81 -0
- package/src/components/command-bar/commands/direct/index.ts +6 -0
- package/src/components/command-bar/commands/registry.ts +8 -0
- package/src/components/command-bar/layout-items/current-layout.ts +22 -1
- package/src/components/command-bar/layout-items/focused-pane.ts +22 -1
- package/src/components/command-bar/pane-templates/items.ts +19 -3
- package/src/components/command-bar/pane-templates/workflow.ts +5 -0
- package/src/components/command-bar/routes/root/results.ts +23 -3
- package/src/components/command-bar/routes/root/selection.ts +4 -2
- package/src/components/command-bar/routes/root/shortcut-feedback.ts +1 -1
- package/src/components/command-bar/routes/root/shortcut-items.ts +3 -4
- package/src/components/command-bar/routes/root/shortcuts.ts +58 -14
- package/src/components/command-bar/routes/root/ticker-first.ts +32 -0
- package/src/components/command-bar/surface/environment.ts +2 -0
- package/src/components/command-bar/view-model.ts +7 -0
- package/src/components/command-bar/workflow/ops.ts +2 -1
- package/src/components/command-bar/workflow/tickers.ts +20 -0
- package/src/components/layout/shell/menu.ts +15 -1
- package/src/components/layout/shell/pane/actions.ts +4 -0
- package/src/components/layout/shell/ticker-link-menu.ts +12 -3
- package/src/components/layout/status-bar.tsx +20 -0
- package/src/components/onboarding/onboarding-keyboard.ts +5 -1
- package/src/components/onboarding/onboarding-wizard.tsx +15 -4
- package/src/components/onboarding/portfolio-step/positions-panel.tsx +8 -5
- package/src/components/onboarding/use-onboarding-progress.ts +20 -1
- package/src/components/price-sparkline/view.tsx +14 -6
- package/src/components/ticker/badge/index.tsx +8 -4
- package/src/components/ticker/badge/list.tsx +23 -7
- package/src/components/ui/column-grid.tsx +8 -2
- package/src/components/ui/data-table/opentui/model.ts +4 -1
- package/src/components/ui/tabs.tsx +5 -2
- package/src/core/state/app/layout.ts +18 -3
- package/src/core/state/app/state.ts +2 -0
- package/src/core/state/app/types.ts +5 -0
- package/src/data/config/layout.ts +3 -0
- package/src/data/config/store/normalize.ts +39 -4
- package/src/i18n/es.ts +10 -0
- package/src/i18n/ja.ts +10 -0
- package/src/i18n/ko.ts +10 -0
- package/src/i18n/zh-cn.ts +10 -0
- package/src/i18n/zh-tw.ts +10 -0
- package/src/layout/pane-manager/floating-placement.ts +7 -4
- package/src/layout/pane-manager/floating.ts +5 -2
- package/src/market-data/bond-funds.ts +19 -0
- package/src/market-data/futures-contract.ts +14 -3
- package/src/market-data/market/freshness.ts +18 -0
- package/src/market-data/market/status.ts +15 -2
- package/src/plugins/builtin/bond-calculator/headless.ts +2 -1
- package/src/plugins/builtin/bond-calculator/index.tsx +1 -1
- package/src/plugins/builtin/bond-calculator/model.ts +14 -5
- package/src/plugins/builtin/bond-calculator/pane.tsx +1 -1
- package/src/plugins/builtin/buildout/cells.tsx +25 -45
- package/src/plugins/builtin/buildout/detail/company.tsx +3 -3
- package/src/plugins/builtin/buildout/detail/index.tsx +1 -1
- package/src/plugins/builtin/buildout/detail/intel.tsx +4 -7
- package/src/plugins/builtin/buildout/detail/site.tsx +4 -4
- package/src/plugins/builtin/buildout/detail/ui.tsx +39 -38
- package/src/plugins/builtin/buildout/format.ts +23 -1
- package/src/plugins/builtin/buildout/model/types.ts +1 -0
- package/src/plugins/builtin/buildout/pane/index.tsx +2 -8
- package/src/plugins/builtin/buildout/table-model.ts +12 -4
- package/src/plugins/builtin/cds/headless.ts +1 -0
- package/src/plugins/builtin/cds/index.tsx +1 -1
- package/src/plugins/builtin/cloud/plugin.tsx +2 -0
- package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +28 -3
- package/src/plugins/builtin/correlation/headless.ts +3 -2
- package/src/plugins/builtin/crypto-board/pane.tsx +5 -4
- package/src/plugins/builtin/debt-maturities/headless.ts +11 -2
- package/src/plugins/builtin/debt-maturities/model.ts +66 -0
- package/src/plugins/builtin/debt-maturities/pane.tsx +23 -4
- package/src/plugins/builtin/earnings-ripple/pane.tsx +1 -1
- package/src/plugins/builtin/econ/calendar-model.ts +28 -6
- package/src/plugins/builtin/equity-screener/client.ts +1 -1
- package/src/plugins/builtin/equity-screener/criterion-editor.tsx +4 -16
- package/src/plugins/builtin/equity-screener/headless.ts +4 -2
- package/src/plugins/builtin/equity-screener/ideas.ts +67 -3
- package/src/plugins/builtin/equity-screener/model.ts +180 -12
- package/src/plugins/builtin/equity-screener/pane.tsx +52 -12
- package/src/plugins/builtin/equity-screener/screen-check.ts +7 -4
- package/src/plugins/builtin/equity-screener/watchlist.ts +33 -0
- package/src/plugins/builtin/futures-curve/client.ts +19 -0
- package/src/plugins/builtin/futures-curve/headless.ts +52 -13
- package/src/plugins/builtin/futures-curve/index.tsx +1 -1
- package/src/plugins/builtin/futures-curve/model.ts +77 -6
- package/src/plugins/builtin/futures-curve/pane.tsx +19 -3
- package/src/plugins/builtin/macro-day/client.ts +41 -0
- package/src/plugins/builtin/macro-day/headless.ts +19 -9
- package/src/plugins/builtin/macro-day/model.ts +3 -1
- package/src/plugins/builtin/market-movers/index.tsx +4 -3
- package/src/plugins/builtin/mna/distress/headless.ts +1 -0
- package/src/plugins/builtin/perps/pane.tsx +3 -1
- package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +17 -0
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +2 -1
- package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +2 -1
- package/src/plugins/builtin/rate-path/headless.ts +24 -10
- package/src/plugins/builtin/research/event-model.ts +10 -3
- package/src/plugins/builtin/research/events-headless.ts +20 -2
- package/src/plugins/builtin/sec/fund-facts.ts +17 -1
- package/src/plugins/builtin/sec/index.tsx +1 -1
- package/src/plugins/builtin/shared/members-menu.tsx +103 -38
- package/src/plugins/builtin/short-interest/publications-model.ts +22 -1
- package/src/plugins/builtin/short-interest/publications-pane.tsx +13 -4
- package/src/plugins/builtin/short-interest/watch-model.ts +1 -1
- package/src/plugins/builtin/time-sales/pane.tsx +3 -2
- package/src/plugins/builtin/trace-bonds/client.ts +7 -4
- package/src/plugins/builtin/trace-bonds/index.tsx +1 -1
- package/src/plugins/builtin/volatility/client.ts +6 -1
- package/src/plugins/builtin/volatility/headless.ts +0 -1
- package/src/plugins/builtin/yield-curve/curves.ts +15 -0
- package/src/plugins/builtin/yield-curve/headless.ts +6 -1
- package/src/plugins/builtin/yield-curve/index.tsx +5 -8
- package/src/plugins/host-modules.ts +22 -3
- package/src/plugins/host-smoke.ts +6 -3
- package/src/portfolio/collection-name.ts +19 -0
- package/src/renderers/browser/http-proxy-transport.ts +78 -8
- package/src/renderers/cloudflare/http-proxy.ts +13 -2
- package/src/renderers/cloudflare/proxy-session.ts +47 -24
- package/src/renderers/cloudflare/worker.ts +15 -2
- package/src/renderers/desktop/geometry.ts +279 -0
- package/src/renderers/desktop/screen-setup.ts +246 -0
- package/src/renderers/desktop/sequential-window-host.ts +179 -0
- package/src/renderers/desktop/test-utils.ts +71 -0
- package/src/renderers/desktop/window-controller.ts +433 -0
- package/src/renderers/desktop/window-host.ts +70 -0
- package/src/renderers/desktop/window-layouts.ts +630 -0
- package/src/renderers/dom/data-frames.ts +15 -4
- package/src/renderers/electrobun/bun/application-menu/click.ts +1 -0
- package/src/renderers/electrobun/bun/application-menu/index.ts +4 -1
- package/src/renderers/electrobun/bun/desktop/backend-requests.ts +19 -8
- package/src/renderers/electrobun/bun/desktop/backend.ts +320 -19
- package/src/renderers/electrobun/bun/desktop/detached-windows.ts +83 -61
- package/src/renderers/electrobun/bun/desktop/host-requests.ts +4 -14
- package/src/renderers/electrobun/bun/desktop/initialization.ts +30 -11
- package/src/renderers/electrobun/bun/desktop/screen-setup-file.ts +55 -0
- package/src/renderers/electrobun/bun/desktop/state-broadcaster.ts +44 -8
- package/src/renderers/electrobun/bun/desktop/workspace/index.ts +298 -97
- package/src/renderers/electrobun/bun/desktop/workspace/requests.ts +44 -6
- package/src/renderers/electrobun/bun/index.ts +4 -97
- package/src/renderers/electrobun/bun/window/electrobun-window-host.ts +306 -0
- package/src/renderers/electrobun/bun/window/focus.ts +0 -25
- package/src/renderers/electrobun/bun/window/remembered-frame.ts +4 -82
- package/src/renderers/electrobun/shared/protocol.ts +44 -2
- package/src/renderers/electrobun/view/backend-rpc.ts +15 -0
- package/src/renderers/electrobun/view/desktop/window/bridge.ts +63 -3
- package/src/renderers/electrobun/view/main.tsx +13 -7
- package/src/series/fred-argument.ts +17 -0
- package/src/sources/provider-router/financial-routes.ts +7 -1
- package/src/state/app/context/index.tsx +16 -2
- package/src/state/desktop-windows.ts +63 -0
- package/src/sync/other-window-tabs.ts +62 -0
- package/src/tickers/company-name-listing.ts +23 -3
- package/src/tickers/listing-fate.ts +147 -1
- package/src/tickers/terminal-codes.ts +5 -0
- package/src/time-series/types.ts +6 -0
- package/src/types/config.ts +10 -1
- package/src/types/desktop-window.ts +71 -2
- package/src/types/financials.ts +4 -0
- package/src/types/headless.ts +19 -0
- package/src/types/plugin.ts +6 -0
- package/src/ui/index.tsx +14 -13
- package/src/ui/same-props.ts +58 -0
- package/src/utils/cli-output.ts +33 -4
- package/src/utils/format.ts +7 -2
- package/src/utils/futures-generic.ts +12 -0
- package/src/utils/http-proxy-upstream.ts +6 -2
- package/src/utils/plugin-proxy-hosts.json +0 -4
- package/src/utils/plugin-proxy-hosts.ts +22 -0
- package/src/utils/sec-filings.ts +7 -1
|
@@ -258,7 +258,7 @@ import {
|
|
|
258
258
|
type ListingIdentity,
|
|
259
259
|
} from "../listing-arg";
|
|
260
260
|
import { currencyNameMiss, currencyNameStop } from "../currency-name-hint";
|
|
261
|
-
import { bareListingNote, listingFateNotes, noLongerTradingNote, SUCCESSOR_CHANGE_WAIT_MS, tradingListing } from "../../tickers/listing-fate";
|
|
261
|
+
import { bareListingNote, listingFateNotes, loadNoQuoteLastTraded, noLongerTradingNote, noQuoteLastTraded, noQuoteLastTradeNote, SUCCESSOR_CHANGE_WAIT_MS, tradingListing, usVenueOf } from "../../tickers/listing-fate";
|
|
262
262
|
import { isYieldIndexSymbol } from "../../tickers/index-roots";
|
|
263
263
|
import {
|
|
264
264
|
analyzeTaxEquivalent, distributionBasis, loadTreasuryTenors, parseTaxRates, TAX_RATE_HELP_OPTIONS, taxEquivalentJson, type TaxRates,
|
|
@@ -389,10 +389,22 @@ type FinancialsCliData = TickerFinancials & {
|
|
|
389
389
|
providerId: string | null;
|
|
390
390
|
};
|
|
391
391
|
|
|
392
|
+
/**
|
|
393
|
+
* A range as typed, in any case and as other tools spell it: `1mo`, `1m` and
|
|
394
|
+
* `1 month` are 1M, `1wk` 1W, `5yr` 5Y, `max` ALL.
|
|
395
|
+
*/
|
|
396
|
+
export function readHistoryRange(value: string): HistoryRange | null {
|
|
397
|
+
const typed = value.trim().toUpperCase().replace(/\s+/g, "");
|
|
398
|
+
if (typed === "MAX") return "ALL";
|
|
399
|
+
const spelled = /^(\d+)(D|DAYS?|W|WKS?|WEEKS?|M|MOS?|MONTHS?|Y|YRS?|YEARS?)$/.exec(typed);
|
|
400
|
+
const range = (spelled ? `${spelled[1]}${spelled[2]![0]}` : typed) as HistoryRange;
|
|
401
|
+
return VALID_RANGES.has(range) ? range : null;
|
|
402
|
+
}
|
|
403
|
+
|
|
392
404
|
function parseRange(value: string | undefined, ctx: Parameters<CliCommandDef["execute"]>[1]): HistoryRange {
|
|
393
|
-
const range = (value ?? "1Y")
|
|
394
|
-
if (!
|
|
395
|
-
return range
|
|
405
|
+
const range = readHistoryRange(value ?? "1Y");
|
|
406
|
+
if (!range) ctx.fail(`Unknown range "${value}".`, `Use one of ${HISTORY_RANGES.join(", ")}.`);
|
|
407
|
+
return range!;
|
|
396
408
|
}
|
|
397
409
|
|
|
398
410
|
function parseNewsFeed(value: string | undefined): NewsQuery["feed"] | undefined {
|
|
@@ -1083,6 +1095,13 @@ async function runQuote(rawArgs: string[], ctx: Parameters<CliCommandDef["execut
|
|
|
1083
1095
|
}));
|
|
1084
1096
|
const tickerChanges = symbolChanges.map(({ change }) => change);
|
|
1085
1097
|
const formerIssuers = symbolChanges.map(({ formerIssuer }) => formerIssuer);
|
|
1098
|
+
// A symbol with no quote whose bars stopped over a month ago says when it last traded, in place of why no quote
|
|
1099
|
+
// came: no longer listed on the service's record (FLAT, a retired ETN), else no trades since. Each costs a history
|
|
1100
|
+
// read, so a long list says only why.
|
|
1101
|
+
const lastTraded = await Promise.all(answers.map(({ result, listing }) => !result.quote && !isNetworkFailure(result.error)
|
|
1102
|
+
&& answers.length <= MAX_CHOICE_LOOKUPS ? loadNoQuoteLastTraded(listing.request, market.dataProvider, now) : null));
|
|
1103
|
+
const endedNotes = answers.map(({ listing }, index) => lastTraded[index] ? `${noQuoteLastTradeNote(listing.symbol, lastTraded[index]!)}.` : null);
|
|
1104
|
+
if (symbols.length === 1 && endedNotes[0]) ctx.fail(endedNotes[0], quoteChangeLine(tickerChanges[0], formerIssuers[0]) || undefined);
|
|
1086
1105
|
const failed = answers[0]?.failure;
|
|
1087
1106
|
if (symbols.length === 1 && failed) {
|
|
1088
1107
|
ctx.fail(failed.message, [quoteChangeLine(tickerChanges[0], formerIssuers[0]), failed.details].filter(Boolean).join("\n") || undefined);
|
|
@@ -1123,6 +1142,8 @@ async function runQuote(rawArgs: string[], ctx: Parameters<CliCommandDef["execut
|
|
|
1123
1142
|
...yieldIndexFields(result),
|
|
1124
1143
|
...tickerChanges[index] ? { tickerChange: tickerChanges[index] } : {},
|
|
1125
1144
|
...formerIssuers[index] ? { formerIssuer: formerIssuers[index] } : {},
|
|
1145
|
+
// The day it last traded, and whether the service's record says it no longer trades (else only old bars say it).
|
|
1146
|
+
...lastTraded[index] ? { lastTraded: lastTraded[index]!.date, noLongerListed: lastTraded[index]!.recorded } : {},
|
|
1126
1147
|
}));
|
|
1127
1148
|
const notes = [
|
|
1128
1149
|
...list?.notes ?? [],
|
|
@@ -1150,8 +1171,9 @@ async function runQuote(rawArgs: string[], ctx: Parameters<CliCommandDef["execut
|
|
|
1150
1171
|
const pair = listingDepositaryPair({ quote: row.quote });
|
|
1151
1172
|
return pair ? [`${row.target.symbol}: ${depositaryPairText(pair, isReceiptSide({ quote: row.quote }))}.`] : [];
|
|
1152
1173
|
}),
|
|
1174
|
+
...endedNotes.flatMap((note) => note ?? []),
|
|
1153
1175
|
// A cell shows only "unavailable", and an exported row only its status, so stderr names each failure; the JSON rows carry each reason.
|
|
1154
|
-
...ctx.cliOptions.format !== "json" ? quoteNotes(data) : [],
|
|
1176
|
+
...ctx.cliOptions.format !== "json" ? quoteNotes(data.filter((_row, index) => !endedNotes[index])) : [],
|
|
1155
1177
|
];
|
|
1156
1178
|
const columns = commandName === "compare" ? compareColumns() : quoteColumns();
|
|
1157
1179
|
const basisNotes = changeBasisNotes(data, now);
|
|
@@ -1428,7 +1450,7 @@ async function loadListingHistory(
|
|
|
1428
1450
|
const quoted = quoteAnswer.then((answer) => answer.quote);
|
|
1429
1451
|
const fate = lookups ? listingFateLoader(listing, market, quoted, { successor: true }) : null;
|
|
1430
1452
|
const request = { command: historyCommand(ask), noun: "history", ...(fate ? { fate } : {}) };
|
|
1431
|
-
const [
|
|
1453
|
+
const [answered, quote] = await Promise.all([
|
|
1432
1454
|
loadForListing(listing, market, ctx, load, (loaded) => loaded.points.length === 0, request)
|
|
1433
1455
|
.catch((error) => failHistory(error, listing.key, ctx)),
|
|
1434
1456
|
quoted,
|
|
@@ -1436,6 +1458,9 @@ async function loadListingHistory(
|
|
|
1436
1458
|
// A bare symbol several companies list is never served from the one the data service picked, in a range or a window:
|
|
1437
1459
|
// it asks for an exchange as `quote` does, and in a list that is the symbol's row alone.
|
|
1438
1460
|
await failUnchosenListing(listing, market, ctx, request, (await quoteAnswer).error);
|
|
1461
|
+
const loaded = quote || window ? answered : await stoppedUsListingHistory(listing, market, loadRange, context, answered);
|
|
1462
|
+
// With no quote and no bar in over a month, when the listing last traded is said first.
|
|
1463
|
+
const lastTraded = quote || window ? null : noQuoteLastTraded(loaded);
|
|
1439
1464
|
const { resolution } = loaded;
|
|
1440
1465
|
// While the session trades the day's bar is the quote's, whatever range the history was cut for (withSessionBar).
|
|
1441
1466
|
// A window that ended before today has no session in progress.
|
|
@@ -1500,6 +1525,7 @@ async function loadListingHistory(
|
|
|
1500
1525
|
const coverage = window ? historyCoverageNotice(loaded.coverageStart, Date.parse(`${window.from}T00:00:00Z`), loaded.coverageNote)
|
|
1501
1526
|
: range === "YTD" ? null : historyCoverageWarning(range, loaded);
|
|
1502
1527
|
const notes = [
|
|
1528
|
+
...lastTraded ? [`${noQuoteLastTradeNote(listing.symbol, lastTraded)}.`] : [],
|
|
1503
1529
|
// A window the source has no bar in (a typo, a weekend, a listing that had not started) is said, not an empty table alone.
|
|
1504
1530
|
...data.length === 0 ? [emptyHistoryNote(listing.key, ask)] : [],
|
|
1505
1531
|
// FB's bars are the fund listed there now; META's from 2021 are from when it was FB.
|
|
@@ -1521,6 +1547,29 @@ async function loadListingHistory(
|
|
|
1521
1547
|
};
|
|
1522
1548
|
}
|
|
1523
1549
|
|
|
1550
|
+
/**
|
|
1551
|
+
* A bare symbol with no quote whose US listing stopped trading is that
|
|
1552
|
+
* listing's history: a source can answer the bare symbol with a listing
|
|
1553
|
+
* abroad that took it (STPP's bars from 2026 are a UCITS fund's, the iPath
|
|
1554
|
+
* steepener's ended in 2020). The bars as answered otherwise.
|
|
1555
|
+
*/
|
|
1556
|
+
async function stoppedUsListingHistory(
|
|
1557
|
+
listing: CliListing,
|
|
1558
|
+
market: MarketContext,
|
|
1559
|
+
range: TimeRange,
|
|
1560
|
+
context: { cacheMode: "refresh" | "default" },
|
|
1561
|
+
answered: PriceHistoryResult,
|
|
1562
|
+
): Promise<PriceHistoryResult> {
|
|
1563
|
+
if (listing.request.exchange || answered.delisting || !market.dataProvider.getPriceHistoryWithMetadata) return answered;
|
|
1564
|
+
const venue = await usVenueOf(listing.request.symbol, market.dataProvider);
|
|
1565
|
+
// Asked afresh: a copy saved for the bare symbol (the listing abroad's bars) can otherwise answer for the venue.
|
|
1566
|
+
const own = await market.dataProvider.getPriceHistoryWithMetadata(listing.request.symbol, venue, range, { ...context, cacheMode: "refresh" })
|
|
1567
|
+
.catch(logFailure("cli.commands-market", "Read a stopped US listing's history failed", null));
|
|
1568
|
+
const ended = own ? noQuoteLastTraded(own) : null;
|
|
1569
|
+
const newest = answered.points.at(-1)?.date;
|
|
1570
|
+
return own && ended && own.points.length > 0 && (!newest || new Date(newest).toISOString().slice(0, 10) > ended.date) ? own : answered;
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1524
1573
|
/**
|
|
1525
1574
|
* A continuous future's history is the front month's, not the contract its
|
|
1526
1575
|
* quote names now: NG=F's rows from before the roll are November's under a
|
|
@@ -1690,27 +1739,115 @@ async function runHistory(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
|
|
|
1690
1739
|
/** A symbol of a list: its bars, or why it has none. */
|
|
1691
1740
|
type ListedHistory = { symbol: string; history: ListingHistory } | { symbol: string; error: string };
|
|
1692
1741
|
|
|
1742
|
+
/** Minutes in an intraday bar size; null for daily and longer bars. */
|
|
1743
|
+
const INTRADAY_BAR_MINUTES: Partial<Record<NonNullable<HistoryRow["interval"]>, number>> = {
|
|
1744
|
+
"1m": 1, "5m": 5, "15m": 15, "30m": 30, "45m": 45, "1h": 60,
|
|
1745
|
+
};
|
|
1746
|
+
|
|
1747
|
+
/** The index of the latest of ascending `times` at or before `time`, or -1. */
|
|
1748
|
+
function latestAtOrBefore(times: readonly number[], time: number): number {
|
|
1749
|
+
let low = 0;
|
|
1750
|
+
let high = times.length - 1;
|
|
1751
|
+
let found = -1;
|
|
1752
|
+
while (low <= high) {
|
|
1753
|
+
const middle = (low + high) >> 1;
|
|
1754
|
+
if (times[middle]! <= time) {
|
|
1755
|
+
found = middle;
|
|
1756
|
+
low = middle + 1;
|
|
1757
|
+
} else high = middle - 1;
|
|
1758
|
+
}
|
|
1759
|
+
return found;
|
|
1760
|
+
}
|
|
1761
|
+
|
|
1762
|
+
/**
|
|
1763
|
+
* Where each symbol's intraday bars go in `--wide`. Bars are listed as they
|
|
1764
|
+
* come unless one symbol's bar starts inside another's (an hour stamped on
|
|
1765
|
+
* the half hour beside one stamped on the hour, 30m bars beside 1h ones):
|
|
1766
|
+
* then every bar is set under the bar it starts in of the coarsest symbol,
|
|
1767
|
+
* the one with most bars where several share that size, which keeps its own
|
|
1768
|
+
* stamps. A bar no such bar covers keeps its own. Null when nothing moves:
|
|
1769
|
+
* daily bars, and intraday ones stamped alike, as US stocks' hours all start
|
|
1770
|
+
* at :30.
|
|
1771
|
+
*/
|
|
1772
|
+
function wideBarSlots(histories: readonly ListingHistory[]): {
|
|
1773
|
+
anchor: number;
|
|
1774
|
+
slot: (series: number, row: number) => string;
|
|
1775
|
+
} | null {
|
|
1776
|
+
const minutes = histories.map((history) => history.interval ? INTRADAY_BAR_MINUTES[history.interval] : undefined);
|
|
1777
|
+
if (histories.length < 2 || minutes.some((value) => value == null)) return null;
|
|
1778
|
+
const times = histories.map((history) => history.data.map((row) => Date.parse(row.date)));
|
|
1779
|
+
if (times.some((series) => series.some((time) => !Number.isFinite(time)))) return null;
|
|
1780
|
+
const inside = (series: number, time: number) => {
|
|
1781
|
+
const at = latestAtOrBefore(times[series]!, time);
|
|
1782
|
+
return at >= 0 && times[series]![at]! < time && time < times[series]![at]! + minutes[series]! * 60_000;
|
|
1783
|
+
};
|
|
1784
|
+
// A live last bar can be stamped at the latest trade inside its slot, so only the others say where a symbol's bars start.
|
|
1785
|
+
const crossed = times.some((series, index) => series.slice(0, -1).some((time) =>
|
|
1786
|
+
times.some((_, other) => other !== index && inside(other, time))));
|
|
1787
|
+
if (!crossed) return null;
|
|
1788
|
+
const coarsest = Math.max(...minutes as number[]);
|
|
1789
|
+
const anchor = histories.reduce((best, history, index) => minutes[index] === coarsest
|
|
1790
|
+
&& (best < 0 || history.data.length > histories[best]!.data.length) ? index : best, -1);
|
|
1791
|
+
const size = coarsest * 60_000;
|
|
1792
|
+
return {
|
|
1793
|
+
anchor,
|
|
1794
|
+
slot: (series, row) => {
|
|
1795
|
+
const own = histories[series]!.data[row]!.date;
|
|
1796
|
+
if (series === anchor) return own;
|
|
1797
|
+
const time = times[series]![row]!;
|
|
1798
|
+
const at = latestAtOrBefore(times[anchor]!, time);
|
|
1799
|
+
return at >= 0 && time < times[anchor]![at]! + size ? histories[anchor]!.data[at]!.date : own;
|
|
1800
|
+
},
|
|
1801
|
+
};
|
|
1802
|
+
}
|
|
1803
|
+
|
|
1804
|
+
/** The symbols as a list: `A`, `A and B`, `A, B and C`. */
|
|
1805
|
+
function listedKeys(keys: readonly string[]): string {
|
|
1806
|
+
return keys.length < 2 ? keys.join("") : `${keys.slice(0, -1).join(", ")} and ${keys.at(-1)}`;
|
|
1807
|
+
}
|
|
1808
|
+
|
|
1693
1809
|
/**
|
|
1694
1810
|
* `history USDJPY=X USDCHF=X EURCHF=X --wide`: one row a date and one close
|
|
1695
1811
|
* column a symbol, its unit in the header (`USDJPY=X close (JPY per USD)`),
|
|
1696
1812
|
* as a spreadsheet sets several series side by side. A symbol with no bar on
|
|
1697
|
-
* a date (another market's holiday) leaves its cell blank.
|
|
1698
|
-
*
|
|
1813
|
+
* a date (another market's holiday) leaves its cell blank. Intraday bars
|
|
1814
|
+
* that do not line up are set under the bar they start in (`wideBarSlots`):
|
|
1815
|
+
* where a symbol has several in one row, the row's close is the last one's,
|
|
1816
|
+
* the slot's close. `notes` names the symbols whose bars moved and those
|
|
1817
|
+
* whose bars were merged. `interval` is the bars' size when every symbol came
|
|
1818
|
+
* in one, else null.
|
|
1699
1819
|
*/
|
|
1700
1820
|
function wideHistoryTable(served: readonly ListingHistory[]): {
|
|
1701
1821
|
rows: Array<Record<string, string | number | null>>;
|
|
1702
1822
|
columns: CliResultColumn[];
|
|
1703
1823
|
interval: string | null;
|
|
1824
|
+
notes: string[];
|
|
1704
1825
|
} {
|
|
1705
1826
|
const histories = served.filter((history, index) => served.findIndex((other) => other.listing.key === history.listing.key) === index);
|
|
1706
1827
|
const key = (history: ListingHistory) => `close:${history.listing.key}`;
|
|
1707
|
-
const
|
|
1708
|
-
const
|
|
1828
|
+
const slots = wideBarSlots(histories);
|
|
1829
|
+
const slotOf = histories.map((history, series) => history.data.map((row, index) => slots?.slot(series, index) ?? row.date));
|
|
1830
|
+
const closes = histories.map((history, series) => new Map(history.data.map((row, index) => [slotOf[series]![index]!, row.close] as const)));
|
|
1831
|
+
const dates = [...new Set(closes.flatMap((bySlot) => [...bySlot.keys()]))].sort();
|
|
1709
1832
|
const rows = dates.map((date) => Object.fromEntries([
|
|
1710
1833
|
["date", date],
|
|
1711
1834
|
...histories.map((history, index) => [key(history), closes[index]!.get(date) ?? null] as const),
|
|
1712
1835
|
]));
|
|
1713
1836
|
const intervals = new Set(histories.map((history) => history.interval));
|
|
1837
|
+
const notes: string[] = [];
|
|
1838
|
+
if (slots) {
|
|
1839
|
+
const anchor = histories[slots.anchor]!;
|
|
1840
|
+
const under = `under the ${anchor.listing.key} ${anchor.interval} bar they start in`;
|
|
1841
|
+
const moved: string[] = [];
|
|
1842
|
+
histories.forEach((history, series) => {
|
|
1843
|
+
const rowsOf = new Set(slotOf[series]);
|
|
1844
|
+
if (rowsOf.size < history.data.length) {
|
|
1845
|
+
notes.push(`${history.listing.key}'s ${history.interval} bars are merged ${under}, ${history.data.length} bars into ${rowsOf.size} rows: a row's close is its last bar's.`);
|
|
1846
|
+
// The last bar can be stamped at the latest trade inside its slot; the others say where a symbol's bars start.
|
|
1847
|
+
} else if (history.data.slice(0, -1).some((row, index) => slotOf[series]![index] !== row.date)) moved.push(history.listing.key);
|
|
1848
|
+
});
|
|
1849
|
+
if (moved.length) notes.unshift(`${listedKeys(moved)} bars are listed ${under}.`);
|
|
1850
|
+
}
|
|
1714
1851
|
return {
|
|
1715
1852
|
rows,
|
|
1716
1853
|
columns: [
|
|
@@ -1725,6 +1862,7 @@ function wideHistoryTable(served: readonly ListingHistory[]): {
|
|
|
1725
1862
|
}),
|
|
1726
1863
|
],
|
|
1727
1864
|
interval: intervals.size === 1 ? [...intervals][0] ?? null : null,
|
|
1865
|
+
notes,
|
|
1728
1866
|
};
|
|
1729
1867
|
}
|
|
1730
1868
|
|
|
@@ -1801,6 +1939,7 @@ async function runHistoryList(
|
|
|
1801
1939
|
} : { symbol: entry.symbol, error: entry.error });
|
|
1802
1940
|
if (wide) {
|
|
1803
1941
|
const table = wideHistoryTable(served);
|
|
1942
|
+
notes.push(...table.notes);
|
|
1804
1943
|
ctx.printResult({
|
|
1805
1944
|
data: table.rows,
|
|
1806
1945
|
metadata: {
|
|
@@ -21,8 +21,8 @@ import {
|
|
|
21
21
|
type TickerSearchCandidate,
|
|
22
22
|
} from "../../tickers/search";
|
|
23
23
|
import { initMarketData, withMarketData } from "../context";
|
|
24
|
-
import { listingChangeLine, loadListingFate } from "../../tickers/listing-fate";
|
|
25
|
-
import { formatMarketPriceWithCurrency, quoteFormatOptions } from "../../market-data/market/format";
|
|
24
|
+
import { listingChangeLine, loadListingFate, loadNoQuoteEnding, noLongerListedNote, noQuoteLastTradeNote, type NoQuoteEnding } from "../../tickers/listing-fate";
|
|
25
|
+
import { formatMarketPriceWithCurrency, quoteFormatOptions, withCurrencyMinorDigits } from "../../market-data/market/format";
|
|
26
26
|
import { formerIssuerLine, startTickerChangeLookup, type TickerChangeLookup } from "../../tickers/ticker-changes";
|
|
27
27
|
import { fail, failRetryable, failWithError, isCliFailure, unreachableError } from "../errors";
|
|
28
28
|
import { isProviderBusy, SEARCH_BUSY_CODE, SEARCH_BUSY_MESSAGE } from "../../sources/provider-errors";
|
|
@@ -180,9 +180,25 @@ async function searchFate(
|
|
|
180
180
|
quote: Quote | null,
|
|
181
181
|
dataProvider: DataProvider,
|
|
182
182
|
changes: TickerChangeLookup,
|
|
183
|
+
/** The symbol's last bars when it has no quote (loadNoQuoteEnding), read beside the search. */
|
|
184
|
+
noQuoteEnding: Promise<NoQuoteEnding | null> = Promise.resolve(null),
|
|
183
185
|
): Promise<SearchFate> {
|
|
184
186
|
const fate = await loadListingFate({ symbol }, dataProvider, { quote, changes });
|
|
185
187
|
const unlisted = !candidates.some((candidate) => candidate.symbol.toUpperCase() === symbol);
|
|
188
|
+
// No quote at all (a retired ETN): a listed row the service marks ended says when, and one search no longer lists is
|
|
189
|
+
// listed with its last day and close, from its US line's last bars, when the service's record says it ended. Bars
|
|
190
|
+
// alone that stopped over a month ago say only that it has not traded since.
|
|
191
|
+
if (!quote) {
|
|
192
|
+
const ended = candidates.find((candidate) => candidate.symbol.toUpperCase() === symbol && candidate.result?.delisting)?.result?.delisting;
|
|
193
|
+
if (ended) return { stopped: null, notes: [`${noLongerListedNote(symbol, ended.lastTradeDate)}.`] };
|
|
194
|
+
const ending = unlisted ? await noQuoteEnding : null;
|
|
195
|
+
if (ending && !ending.recorded) return { stopped: null, notes: [`${noQuoteLastTradeNote(symbol, ending)}.`] };
|
|
196
|
+
if (ending) {
|
|
197
|
+
const note = noLongerListedNote(symbol, ending.date);
|
|
198
|
+
return { stopped: { symbol, name: fate.change?.issuer || null, lastTraded: ending.date,
|
|
199
|
+
lastPrice: ending.lastClose == null ? "—" : formatMarketPriceWithCurrency(ending.lastClose, "USD", withCurrencyMinorDigits({}, "USD")), note }, notes: [] };
|
|
200
|
+
}
|
|
201
|
+
}
|
|
186
202
|
const stopped = unlisted && quote && fate.endedOn && fate.note
|
|
187
203
|
? {
|
|
188
204
|
symbol,
|
|
@@ -667,13 +683,15 @@ export async function search(query: string, dependencies: SearchCommandDependenc
|
|
|
667
683
|
const savedExchange = tickers.find((ticker) => ticker.metadata.ticker.toUpperCase() === symbol)?.metadata.exchange ?? "";
|
|
668
684
|
const quote = bare ? loadSearchedQuote(symbol, savedExchange, dataProvider) : null;
|
|
669
685
|
const changes = bare ? startTickerChangeLookup(dataProvider, symbol) : null;
|
|
686
|
+
// With no quote, its US line's last bars, to list a retired symbol (STPP) with its last day.
|
|
687
|
+
const ending = quote?.then((quoted) => quoted ? null : loadNoQuoteEnding({ symbol }, dataProvider));
|
|
670
688
|
const candidates = await searchCandidatesForCli({
|
|
671
689
|
query: index?.symbol ?? trimmedQuery,
|
|
672
690
|
tickers,
|
|
673
691
|
dataProvider,
|
|
674
692
|
...quote ? { quote } : {},
|
|
675
693
|
}).catch((error: unknown) => failTickerLookup(error, trimmedQuery, !dependencies.printResult));
|
|
676
|
-
const fate = quote && changes ? await searchFate(symbol, candidates, await quote, dataProvider, changes) : NO_SEARCH_FATE;
|
|
694
|
+
const fate = quote && changes ? await searchFate(symbol, candidates, await quote, dataProvider, changes, ending) : NO_SEARCH_FATE;
|
|
677
695
|
|
|
678
696
|
const series = findCatalogSeries(dependencies.plugins ?? [], trimmedQuery, "names");
|
|
679
697
|
const bank = searchedCentralBank(trimmedQuery);
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
renderSection,
|
|
26
26
|
renderStats,
|
|
27
27
|
wrapText,
|
|
28
|
+
wrapToTerminal,
|
|
28
29
|
type CliStatEntry,
|
|
29
30
|
} from "../../utils/cli-output";
|
|
30
31
|
import {
|
|
@@ -81,8 +82,8 @@ import {
|
|
|
81
82
|
coinListingNotes, failIfNotTraded, failMovedSymbol, ListingArgError, listingChoiceNotes, listingFateLoader, listingIdentity, loadBareVenues,
|
|
82
83
|
resolveCliListing, type CliListing, type ListingDataRequest,
|
|
83
84
|
} from "../listing-arg";
|
|
84
|
-
import { movedAwayChange } from "../../tickers/ticker-changes";
|
|
85
|
-
import { listingChangeLine } from "../../tickers/listing-fate";
|
|
85
|
+
import { isUsSymbolVenue, movedAwayChange } from "../../tickers/ticker-changes";
|
|
86
|
+
import { listingChangeLine, loadNoQuoteLastTraded, noQuoteLastTradeNote, otherListingProfile, otherListingProfileNote } from "../../tickers/listing-fate";
|
|
86
87
|
import { companyMemberships, loadCompanyMemberships, type CompanyMemberships, type ListMembership } from "../issuer-membership";
|
|
87
88
|
import { isNotATickerMessage } from "../not-a-ticker";
|
|
88
89
|
import { sharesOutstandingInReceipts } from "../../utils/depositary-receipt";
|
|
@@ -99,7 +100,7 @@ import { loadOfferingFilings, loadStatementFilings, resultsReleaseText, statemen
|
|
|
99
100
|
import type { BankFiguresPayload } from "../../api-client/bank-figures";
|
|
100
101
|
import { bankSection } from "../bank-section";
|
|
101
102
|
import type { FundBondFacts, FundFactsPayload } from "../../api-client/fund-facts";
|
|
102
|
-
import { bondFigures, NOT_SEC_YIELD } from "../../market-data/bond-funds";
|
|
103
|
+
import { bondFigures, durationDv01PerShare, formatDv01PerShare, NOT_SEC_YIELD } from "../../market-data/bond-funds";
|
|
103
104
|
import { readFundFacts } from "../../market-data/fund-facts";
|
|
104
105
|
import { taxEquivalentLines, type TaxEquivalentAnalysis } from "../../market-data/tax-equivalent";
|
|
105
106
|
import { isRoundTheClockCoin } from "../../utils/crypto-pair";
|
|
@@ -646,7 +647,11 @@ function reportedDividendYield(
|
|
|
646
647
|
* was last paid; a trailing one the twelve months it covers. A yield of no
|
|
647
648
|
* stated basis is the figure alone.
|
|
648
649
|
*/
|
|
649
|
-
function forwardYieldFigure(
|
|
650
|
+
function forwardYieldFigure(
|
|
651
|
+
fundamentals: TickerFinancials["fundamentals"],
|
|
652
|
+
distributions: DividendDistributions | null,
|
|
653
|
+
bond: FundBondFacts | null = null,
|
|
654
|
+
): MetricFigure {
|
|
650
655
|
const lapse = forwardYieldLapse(fundamentals, distributions);
|
|
651
656
|
if (lapse) return { text: noCurrentDividend(lapse), value: null };
|
|
652
657
|
const figure = percentFigure(reportedDividendYield(fundamentals, distributions), formatFractionPercentCell);
|
|
@@ -654,7 +659,9 @@ function forwardYieldFigure(fundamentals: TickerFinancials["fundamentals"], dist
|
|
|
654
659
|
const basis = fundamentals.dividendYieldBasis === "forward"
|
|
655
660
|
? forwardDividendBasis(fundamentals.exDividendDate, { declared: distributions?.rows, currency: distributions?.currency })
|
|
656
661
|
: fundamentals.dividendYieldBasis === "trailing" ? TRAILING_DIVIDEND_BASIS : null;
|
|
657
|
-
|
|
662
|
+
// A bond fund's says first that it is not the SEC yield on the next line, which its label keeps short.
|
|
663
|
+
const said = [bond ? NOT_SEC_YIELD : null, basis].filter(Boolean).join("; ");
|
|
664
|
+
return said ? { ...figure, text: `${figure.text} (${said})` } : figure;
|
|
658
665
|
}
|
|
659
666
|
|
|
660
667
|
/**
|
|
@@ -673,13 +680,12 @@ export function exportedDividendFundamentals<T extends object & Pick<NonNullable
|
|
|
673
680
|
}
|
|
674
681
|
|
|
675
682
|
/**
|
|
676
|
-
* `Dividend Yield (forward)`, or for a bond fund `Distribution Yield
|
|
677
|
-
*
|
|
678
|
-
* after it) is not.
|
|
683
|
+
* `Dividend Yield (forward)`, or for a bond fund `Distribution Yield
|
|
684
|
+
* (forward)`: the cash it paid, annualized, which its value says its SEC
|
|
685
|
+
* yield (the line after it) is not.
|
|
679
686
|
*/
|
|
680
687
|
function dividendYieldLabel(basis: string | undefined, bond: FundBondFacts | null): string {
|
|
681
|
-
|
|
682
|
-
return `Dividend Yield${basis ? ` (${basis})` : ""}`;
|
|
688
|
+
return `${bond ? "Distribution" : "Dividend"} Yield${basis ? ` (${basis})` : ""}`;
|
|
683
689
|
}
|
|
684
690
|
|
|
685
691
|
/** The labels a bond fund's sponsor figures print under, after its distribution yield. */
|
|
@@ -687,16 +693,21 @@ const BOND_METRIC_LABELS = { secYield: "30-Day SEC Yield", yieldToWorst: "Yield
|
|
|
687
693
|
|
|
688
694
|
/**
|
|
689
695
|
* A bond fund's 30-day SEC yield, yield to worst and duration as its sponsor
|
|
690
|
-
* publishes them, each dated: `4.04% (as of 2026-10-15)
|
|
696
|
+
* publishes them, each dated: `4.04% (as of 2026-10-15)`, then the DV01 per
|
|
697
|
+
* share its duration gives at the regular session price.
|
|
691
698
|
*/
|
|
692
|
-
function bondFundMetrics(bond: FundBondFacts | null): FundamentalsMetric[] {
|
|
699
|
+
function bondFundMetrics(bond: FundBondFacts | null, price: number | null): FundamentalsMetric[] {
|
|
693
700
|
if (!bond) return [];
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
701
|
+
const dv01 = durationDv01PerShare(price, bond);
|
|
702
|
+
return [
|
|
703
|
+
...bondFigures(bond).map((figure) => ({
|
|
704
|
+
label: figure.key === "duration" ? figure.label : BOND_METRIC_LABELS[figure.key],
|
|
705
|
+
text: `${figure.text}${figure.date ? ` (as of ${figure.date})` : ""}`,
|
|
706
|
+
value: figure.value,
|
|
707
|
+
unit: figure.key === "duration" ? "years" : "%",
|
|
708
|
+
})),
|
|
709
|
+
...dv01 == null ? [] : [{ label: "DV01", text: `${formatDv01PerShare(dv01)} (from duration)`, value: dv01, unit: "USD per bp" }],
|
|
710
|
+
];
|
|
700
711
|
}
|
|
701
712
|
|
|
702
713
|
/** Whether a metric is a yield line, which `valuation` keeps beside the multiples. */
|
|
@@ -757,9 +768,9 @@ function fundamentalsMetrics(
|
|
|
757
768
|
{ label: "EPS (TTM)", ...reportedMoney(fundamentals?.eps, fundamentals?.epsCurrency?.trim() || reportingCurrency, true, codes) },
|
|
758
769
|
{
|
|
759
770
|
label: dividendYieldLabel(fundamentals?.dividendYieldBasis, bond),
|
|
760
|
-
...forwardYieldFigure(fundamentals, distributions),
|
|
771
|
+
...forwardYieldFigure(fundamentals, distributions, bond),
|
|
761
772
|
},
|
|
762
|
-
...bondFundMetrics(bond),
|
|
773
|
+
...bondFundMetrics(bond, regularSessionValuationPrice(quote)),
|
|
763
774
|
{ label: "Revenue (TTM)", ...reportedMoney(fundamentals?.revenue, reportingCurrency) },
|
|
764
775
|
{ label: "Net Income (TTM)", ...reportedMoney(fundamentals?.netIncome, reportingCurrency) },
|
|
765
776
|
{ label: "Operating Cash Flow (TTM)", ...reportedMoney(fundamentals?.operatingCashFlow, reportingCurrency) },
|
|
@@ -813,6 +824,14 @@ function floatAndShortInterestMetrics(
|
|
|
813
824
|
];
|
|
814
825
|
}
|
|
815
826
|
|
|
827
|
+
/** Rows a company's earnings and accounts fill: a fund's report never shows them, whatever a provider sends for it. */
|
|
828
|
+
const STOCK_ONLY_METRICS = new Set(["Enterprise Value", "P/E (TTM)", "Forward P/E", "PEG", "EPS (TTM)", "Revenue (TTM)", "Net Income (TTM)",
|
|
829
|
+
"Operating Cash Flow (TTM)", "Free Cash Flow (TTM)", "Operating Margin", "Profit Margin", "Revenue Growth", "Last Quarter Growth"]);
|
|
830
|
+
|
|
831
|
+
function withoutStockRows<T extends { label: string }>(metrics: T[], fund: boolean): T[] {
|
|
832
|
+
return fund ? metrics.filter((metric) => !STOCK_ONLY_METRICS.has(metric.label)) : metrics;
|
|
833
|
+
}
|
|
834
|
+
|
|
816
835
|
function metricLines(metrics: readonly FundamentalsMetric[]): Array<[string, string]> {
|
|
817
836
|
return metrics.filter((metric) => !metric.exportOnly).map((metric) => [metric.label, metric.text]);
|
|
818
837
|
}
|
|
@@ -963,8 +982,9 @@ function fundamentalsReportMetrics(snapshot: FundamentalsReportData, view: "fund
|
|
|
963
982
|
const marketCap: MetricFigure = capitalization
|
|
964
983
|
? { text: `${formatCompact(capitalization.value)} ${capitalization.currency}`, value: capitalization.value, unit: capitalization.currency }
|
|
965
984
|
: { text: "—" };
|
|
966
|
-
const metrics = fundamentalsMetrics(quote, fundamentals, financials.profile, marketCap, computeTickerPriceReturns(financials),
|
|
967
|
-
undefined, snapshot.distributions ?? null, snapshot.bondFund ?? null, snapshot.currencyCodes === true)
|
|
985
|
+
const metrics = withoutStockRows(fundamentalsMetrics(quote, fundamentals, financials.profile, marketCap, computeTickerPriceReturns(financials),
|
|
986
|
+
fundamentalsCurrency(financials), undefined, snapshot.distributions ?? null, snapshot.bondFund ?? null, snapshot.currencyCodes === true),
|
|
987
|
+
resolveTickerInstrumentKind(null, financials) === "fund");
|
|
968
988
|
if (view === "fundamentals") {
|
|
969
989
|
return [...metrics, ...floatAndShortInterestMetrics(quote, fundamentals, financials.profile)]
|
|
970
990
|
.filter((metric) => metric.text !== "—");
|
|
@@ -988,10 +1008,11 @@ export function renderFundamentalsReport(
|
|
|
988
1008
|
const symbol = quote?.symbol ?? financials.symbol;
|
|
989
1009
|
const name = quote?.name && quote.name !== symbol ? ` ${cliStyles.bold(quote.name)}` : "";
|
|
990
1010
|
const lines = [`${cliStyles.accent(symbol)}${name}`];
|
|
1011
|
+
const isFund = resolveTickerInstrumentKind(null, financials) === "fund";
|
|
991
1012
|
const profileParts = [
|
|
992
1013
|
financials.exchange ? exchangeLabel(financials.exchange) : undefined,
|
|
993
|
-
profile?.sector ? `Sector ${profile.sector}` : undefined,
|
|
994
|
-
profile?.industry ? `Industry ${profile.industry}` : undefined,
|
|
1014
|
+
!isFund && profile?.sector ? `Sector ${profile.sector}` : undefined,
|
|
1015
|
+
!isFund && profile?.industry ? `Industry ${profile.industry}` : undefined,
|
|
995
1016
|
].filter((part): part is string => !!part);
|
|
996
1017
|
if (profileParts.length > 0) lines.push(cliStyles.muted(profileParts.join(METADATA_SEPARATOR)));
|
|
997
1018
|
|
|
@@ -1016,7 +1037,8 @@ export function renderFundamentalsReport(
|
|
|
1016
1037
|
}
|
|
1017
1038
|
appendDescription(lines, profile);
|
|
1018
1039
|
}
|
|
1019
|
-
|
|
1040
|
+
// A line wider than the terminal (a heading's venue and state, a note) wraps at it, as the stat blocks do.
|
|
1041
|
+
return lines.map(wrapToTerminal).join("\n");
|
|
1020
1042
|
}
|
|
1021
1043
|
|
|
1022
1044
|
/** What the Bank section reads from the rest of the report: the newest statement period, and the annual report form. */
|
|
@@ -1193,10 +1215,12 @@ export async function buildTickerReport({
|
|
|
1193
1215
|
const instrumentType = instrumentTypeLabel(quote?.instrumentType?.trim()
|
|
1194
1216
|
|| financials.quoteMetadata?.instrumentType?.trim()
|
|
1195
1217
|
|| tickerFile?.metadata.assetCategory, name, { detail: true });
|
|
1218
|
+
// A fund has no sector or industry of its own, nor the earnings rows below.
|
|
1219
|
+
const isFund = resolveTickerInstrumentKind(tickerFile, financials) === "fund";
|
|
1196
1220
|
const metadataParts = [
|
|
1197
1221
|
instrumentType ? `Type ${instrumentType}` : undefined,
|
|
1198
|
-
(tickerFile?.metadata.sector || profile?.sector) ? `Sector ${tickerFile?.metadata.sector || profile?.sector}` : undefined,
|
|
1199
|
-
(tickerFile?.metadata.industry || profile?.industry) ? `Industry ${tickerFile?.metadata.industry || profile?.industry}` : undefined,
|
|
1222
|
+
!isFund && (tickerFile?.metadata.sector || profile?.sector) ? `Sector ${tickerFile?.metadata.sector || profile?.sector}` : undefined,
|
|
1223
|
+
!isFund && (tickerFile?.metadata.industry || profile?.industry) ? `Industry ${tickerFile?.metadata.industry || profile?.industry}` : undefined,
|
|
1200
1224
|
].filter((part): part is string => !!part);
|
|
1201
1225
|
if (metadataParts.length > 0) {
|
|
1202
1226
|
lines.push(cliStyles.muted(metadataParts.join(METADATA_SEPARATOR)));
|
|
@@ -1304,8 +1328,8 @@ export async function buildTickerReport({
|
|
|
1304
1328
|
|
|
1305
1329
|
// A listing of the last year may have no statements yet: its IPO says how recent it is.
|
|
1306
1330
|
const listing = { listedSince: ipo ? ipo.deal.listingDate ?? ipo.deal.firstDay?.session ?? null : null };
|
|
1307
|
-
const metrics = fundamentalsMetrics(quote, priced.fundamentals, profile, { text: marketCapText }, priceReturns,
|
|
1308
|
-
{ text: enterpriseValueText }, distributions, bondFund, codes);
|
|
1331
|
+
const metrics = withoutStockRows(fundamentalsMetrics(quote, priced.fundamentals, profile, { text: marketCapText }, priceReturns,
|
|
1332
|
+
fundamentalsCurrency(financials, listing), { text: enterpriseValueText }, distributions, bondFund, codes), isFund);
|
|
1309
1333
|
const reportedCurrency = financials.financialCurrency?.trim();
|
|
1310
1334
|
const statements = [...financials.annualStatements, ...financials.quarterlyStatements];
|
|
1311
1335
|
const fallbackCurrency = reportedCurrency && statements.every((row) => !row.currency?.trim() || row.currency.trim() === reportedCurrency)
|
|
@@ -1384,7 +1408,8 @@ export async function buildTickerReport({
|
|
|
1384
1408
|
|
|
1385
1409
|
await appendTickerPositions(lines, tickerFile, quote, config, toBase, rates);
|
|
1386
1410
|
|
|
1387
|
-
|
|
1411
|
+
// A line wider than the terminal (a heading's venue and state, a note) wraps at it, as the stat blocks do.
|
|
1412
|
+
return lines.map(wrapToTerminal).join("\n");
|
|
1388
1413
|
}
|
|
1389
1414
|
|
|
1390
1415
|
function buildTickerStructuredData({
|
|
@@ -1531,6 +1556,11 @@ function depositaryPairJson(financials: TickerFinancials) {
|
|
|
1531
1556
|
return { depositaryPair: { ...pair, side: receipt ? "receipt" : "home", text: depositaryPairText(pair, receipt) } };
|
|
1532
1557
|
}
|
|
1533
1558
|
|
|
1559
|
+
/** The research a stopped listing shows when what came under its symbol is another listing's: its quote data alone. */
|
|
1560
|
+
function withoutResearch(financials: TickerFinancials): TickerFinancials {
|
|
1561
|
+
return { ...financials, profile: undefined, fundamentals: undefined, annualStatements: [], quarterlyStatements: [] };
|
|
1562
|
+
}
|
|
1563
|
+
|
|
1534
1564
|
const QUOTE_UNAVAILABLE = "Quote unavailable.";
|
|
1535
1565
|
|
|
1536
1566
|
/** Asks for the quote the report lacks once more, for the reason the data service gave when it had none. */
|
|
@@ -1676,7 +1706,17 @@ export async function ticker(symbol: string, dependencies: TickerCommandDependen
|
|
|
1676
1706
|
|
|
1677
1707
|
// The quote is the feed in this report; without one, the fundamentals date it.
|
|
1678
1708
|
const freshness = quote ? quotesFreshness([quote]) : fundamentalsFreshness(resolvedFinancials);
|
|
1679
|
-
|
|
1709
|
+
// A listing with no quote and no bar in over a month stopped trading: the line under its name says when.
|
|
1710
|
+
const lastTraded = quote ? null : await loadNoQuoteLastTraded({ symbol: requestSymbol, exchange }, dataProvider);
|
|
1711
|
+
// The profile under its symbol is another listing's only on evidence: another issuer's name, or one abroad.
|
|
1712
|
+
const otherProfile = lastTraded ? otherListingProfile(resolvedFinancials.profile, {
|
|
1713
|
+
usLine: isUsSymbolVenue(exchange),
|
|
1714
|
+
issuerNames: [tickerFile?.metadata.name, researchFate.change?.issuer, researchFate.formerIssuer?.name],
|
|
1715
|
+
}) : null;
|
|
1716
|
+
const quoteNote = lastTraded
|
|
1717
|
+
? [`${noQuoteLastTradeNote(requestSymbol, lastTraded)}.`, otherProfile ? otherListingProfileNote(requestSymbol, otherProfile) : null]
|
|
1718
|
+
.filter(Boolean).join("\n")
|
|
1719
|
+
: quote ? undefined : await quoteUnavailableNote(dataProvider, requestSymbol, exchange);
|
|
1680
1720
|
// A bare coin ticker read as another listing says where the coin is, as `quote` does: from the quote, else from the saved listing.
|
|
1681
1721
|
const successor = listingChangeLine(researchFate);
|
|
1682
1722
|
const choiceNotes = [
|
|
@@ -1687,8 +1727,9 @@ export async function ticker(symbol: string, dependencies: TickerCommandDependen
|
|
|
1687
1727
|
];
|
|
1688
1728
|
const listingNote = choiceNotes.join("\n") || undefined;
|
|
1689
1729
|
const memberships = await membershipsLoad;
|
|
1690
|
-
// A converted TTM block at the rate the rest of the report converts at, the one `fx` reports.
|
|
1691
|
-
|
|
1730
|
+
// A converted TTM block at the rate the rest of the report converts at, the one `fx` reports. A listing that
|
|
1731
|
+
// stopped trading shows none of the profile and figures another listing under its symbol was served with.
|
|
1732
|
+
const shownFinancials = await atReportTtmRate(otherProfile ? withoutResearch(resolvedFinancials) : resolvedFinancials, toBase);
|
|
1692
1733
|
if (dependencies.printResult) {
|
|
1693
1734
|
const newsNote = recentNews[0]?.searchedFor ? coinNewsFallbackNotice(requestSymbol, recentNews[0].searchedFor) : null;
|
|
1694
1735
|
const warnings = [...choiceNotes, quoteNote, newsNote].filter((note): note is string => !!note);
|
package/src/cli/glossary.ts
CHANGED
|
@@ -605,10 +605,10 @@ export const GLOSSARY: readonly GlossaryEntry[] = [
|
|
|
605
605
|
},
|
|
606
606
|
{
|
|
607
607
|
// SIW's Setup column prints these two words.
|
|
608
|
-
term: "Crowded", aliases: ["crowded short", "crowded shorts", "crowded trade", "crowded, rising", "crowded rising", "setup"], functions: ["SIW"],
|
|
609
|
-
shown: ["Crowded", "Crowded,
|
|
608
|
+
term: "Crowded", aliases: ["crowded short", "crowded shorts", "crowded trade", "crowded, rising", "crowded rising", "crowded, price rising", "px up", "setup"], functions: ["SIW"],
|
|
609
|
+
shown: ["Crowded", "Crowded, px up"],
|
|
610
610
|
definition: "SIW's flag for a heavily shorted name: at least 10% of the float short, or five or more days to cover with at least 5% of the float short "
|
|
611
|
-
+ "(days to cover alone when the float is unknown). Crowded,
|
|
611
|
+
+ "(days to cover alone when the float is unknown). Crowded, px up adds a share price up over the month (px is the price, not the short interest, which can be falling). A fixed threshold, not a squeeze forecast.",
|
|
612
612
|
},
|
|
613
613
|
{
|
|
614
614
|
term: "Squeeze", aliases: ["short squeeze", "squeezes", "short covering"], functions: ["SIW"], shown: ["Short squeeze watch"],
|
package/src/cli/known-gaps.ts
CHANGED
|
@@ -209,6 +209,14 @@ const TOPIC_POINTERS: ReadonlyArray<{
|
|
|
209
209
|
closest: ReadonlyArray<readonly [code: string, gives: string]>;
|
|
210
210
|
}> = [
|
|
211
211
|
BANK_FIGURES_TOPIC,
|
|
212
|
+
{
|
|
213
|
+
// CRPR's agency ratings are licensed by the agencies; the tape's grade of each bond is the nearest public read.
|
|
214
|
+
topic: "Agency credit ratings and rating history",
|
|
215
|
+
availability: "not carried (the agencies license them)",
|
|
216
|
+
phrases: ["crpr", "agency rating", "agency ratings", "credit rating history", "credit ratings history", "rating agency",
|
|
217
|
+
"rating agencies", "moody's rating", "moodys rating", "fitch rating"],
|
|
218
|
+
closest: [["TRACE", "each bond's grade, investment grade or high yield: gloom fn TRACE <ticker>"], ["CRD", "spreads by rating"]],
|
|
219
|
+
},
|
|
212
220
|
{
|
|
213
221
|
topic: "defense budget",
|
|
214
222
|
phrases: ["defense budget", "defence budget", "defense spending", "defence spending", "dod", "department of defense",
|
package/src/cli/listing-arg.ts
CHANGED
|
@@ -45,6 +45,7 @@ import { bareFuturesCode, futuresContractByCode } from "../market-data/futures-b
|
|
|
45
45
|
import { classifyInstrumentType, kindFromListingSyntax } from "../tickers/instrument-kind";
|
|
46
46
|
import type { InstrumentOfKind } from "../tickers/instrument-coverage";
|
|
47
47
|
import { brokerIndexCode, brokerIndexReadAs } from "./index-roots";
|
|
48
|
+
import { continuousAliasGeneric } from "../utils/futures-generic";
|
|
48
49
|
import {
|
|
49
50
|
bloombergCodeOf,
|
|
50
51
|
bloombergMarketHint,
|
|
@@ -62,6 +63,7 @@ import { listingAbroadVenue } from "../utils/sec";
|
|
|
62
63
|
import { savedAbroadForBareSymbol, savedUsListingOf } from "../tickers/search/bare-symbol";
|
|
63
64
|
import { listingSuffixCandidate, listingSuffixVenue, tickerHasListingSuffix } from "../sources/listing-symbols";
|
|
64
65
|
import { coinElsewhereNote, notTheCoinNote } from "./commands/crypto-hints";
|
|
66
|
+
import { fredSeriesArgument, fredSeriesNotListing } from "../series/fred-argument";
|
|
65
67
|
|
|
66
68
|
/** The `--exchange` option of every command that takes a ticker. */
|
|
67
69
|
export const EXCHANGE_OPTION = {
|
|
@@ -178,6 +180,10 @@ function parseCleanListingArg(
|
|
|
178
180
|
// VIX.X and $VIX.X, a broker's code for an index, are its own symbol ^VIX; $VIX is read in `resolveCliListing`.
|
|
179
181
|
const index = option ? null : brokerIndexCode(raw);
|
|
180
182
|
if (index && !index.bare) return { symbol: index.symbol, exchange: "", key: index.symbol, readAs: brokerIndexReadAs(index) };
|
|
183
|
+
// VX=F, the continuous symbol VIX futures do not have, is the front generic VX1.
|
|
184
|
+
const generic = option ? null : continuousAliasGeneric(raw);
|
|
185
|
+
// It says so, as a name read as a bare symbol does: VX1 is not what was typed.
|
|
186
|
+
if (generic) return { symbol: generic, exchange: "", key: generic, readAs: `Read ${raw.trim().toUpperCase()} as ${generic}, the front VIX future.`, readFromName: true };
|
|
181
187
|
// A perpetual's market id (binance:BZUSDT, as PERP names it) is its listing on that venue (BZUSDT:BINANCE).
|
|
182
188
|
let typed = (typedPerpetualListing(raw)?.key ?? raw).trim().replace(/^\$/, "").toUpperCase();
|
|
183
189
|
// `SAN:` asks which listing; with --exchange it has its answer.
|
|
@@ -1208,6 +1214,12 @@ export async function resolveCliListing(
|
|
|
1208
1214
|
): Promise<CliListing> {
|
|
1209
1215
|
// "JPM US Equity" is Bloomberg's code for JPM; "Putnam US Equity", whose root is no US ticker, is a name.
|
|
1210
1216
|
const typed = stripStrayEdges(raw).text || raw;
|
|
1217
|
+
// FRED:T10Y2Y is the series the catalog prints, never the symbol FRED on a venue called T10Y2Y.
|
|
1218
|
+
const fred = exchangeOption?.trim() ? null : fredSeriesArgument(typed);
|
|
1219
|
+
if (fred) {
|
|
1220
|
+
const { message, details } = fredSeriesNotListing(fred);
|
|
1221
|
+
throw new ListingArgError(message, details);
|
|
1222
|
+
}
|
|
1211
1223
|
const read = await readTerminalCodeArg(deps.dataProvider, typed);
|
|
1212
1224
|
// A company's name, an entry of a comma list (`WHR, Whirlpool Corporation`), is the listing search names for it.
|
|
1213
1225
|
// A name before a legal form ("SAP SE", "SIEMENS AG") is looked up first: SE is also SIX Swiss's market code.
|
|
@@ -21,6 +21,8 @@ export interface PaneFunctionCapability {
|
|
|
21
21
|
aliases: string[];
|
|
22
22
|
/** Words that are no code but ask for this function's data: `fn` and `catalog` answer them with it. */
|
|
23
23
|
suggestFor?: string[];
|
|
24
|
+
/** Words that open the function on one argument (`VX`: CTM VIX). */
|
|
25
|
+
opens?: ReadonlyArray<{ words: readonly string[]; argument: string }>;
|
|
24
26
|
intents: string[];
|
|
25
27
|
outputKind: string;
|
|
26
28
|
reportReadiness: PaneFunctionReadiness;
|