@gloom-sh/terminal 0.20.11 → 0.20.12
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 +2 -1
- package/src/api-client/awards.ts +16 -0
- package/src/api-client/central-bank-rates.ts +5 -0
- package/src/api-client/data.ts +55 -2
- package/src/api-client/index.ts +18 -1
- package/src/api-client/request.ts +86 -3
- package/src/api-client/socket-connection.ts +12 -1
- package/src/api-client/socket.ts +21 -3
- package/src/api-client/supply-chain-graph.ts +4 -2
- package/src/api-client/supply-chain.ts +8 -0
- package/src/api-client/types/econ.ts +10 -7
- package/src/api-client/types/filings-and-calls.ts +8 -0
- package/src/app/global-shortcuts.ts +2 -1
- package/src/app/keybindings/actions.ts +19 -0
- package/src/app/pane-runtime/index.tsx +18 -3
- package/src/app/pane-runtime/layout-placement.ts +63 -0
- package/src/app/pane-runtime/ticker-open-runtime.ts +10 -2
- package/src/capabilities/chart-series.ts +4 -1
- package/src/cli/board-coins.ts +10 -1
- package/src/cli/commands/crypto-hints.ts +3 -2
- package/src/cli/commands/fred-series.ts +0 -54
- package/src/cli/commands/market.ts +209 -31
- package/src/cli/commands/overview.ts +47 -14
- package/src/cli/commands/search.ts +37 -8
- package/src/cli/commands/ticker.ts +15 -4
- package/src/cli/desktop-pane-shot.ts +27 -2
- package/src/cli/fx-quote-rate.ts +1 -1
- package/src/cli/glossary.ts +14 -5
- package/src/cli/history-catalog-series.ts +85 -0
- package/src/cli/index.ts +1 -1
- package/src/cli/list-progress.ts +45 -0
- package/src/cli/listing-arg.ts +71 -7
- package/src/cli/name-entries.ts +8 -4
- package/src/cli/not-a-ticker.ts +2 -2
- package/src/cli/pane-functions/freshness.ts +50 -3
- package/src/cli/pane-functions/index.ts +7 -4
- package/src/cli/pane-functions/market-session.ts +66 -14
- package/src/cli/pane-functions/options.ts +5 -0
- package/src/cli/pane-functions/resolver.ts +9 -2
- package/src/cli/pane-functions/screenshot-assessment.ts +28 -3
- package/src/cli/pane-functions/screenshot-types.ts +6 -0
- package/src/cli/quote-answer.ts +49 -10
- package/src/cli/quote-list-reads.ts +87 -0
- package/src/cli/report-tables.ts +70 -13
- package/src/cli/result.ts +24 -2
- package/src/cli/symbol-list.ts +31 -4
- package/src/cli/terminal-code-hints.ts +83 -0
- package/src/cli/ticker-resolution.ts +2 -1
- package/src/cli/treasury-yields.ts +5 -0
- package/src/components/command-bar/action-runtime.ts +2 -0
- package/src/components/command-bar/routing/launch-request.ts +2 -1
- package/src/components/command-bar/routing/navigation-state.ts +4 -2
- package/src/components/command-bar/workflow/types.ts +6 -0
- package/src/components/layout/detached-pane-shell.tsx +3 -0
- package/src/components/layout/double-escape-close.ts +34 -3
- package/src/components/layout/floating-pane.tsx +10 -4
- package/src/components/layout/pane/cycle-order.ts +66 -2
- package/src/components/layout/pane/header.tsx +140 -31
- package/src/components/layout/pane/sidebar.tsx +13 -5
- package/src/components/layout/pane/status-footer.ts +3 -1
- package/src/components/layout/shell/drag/runtime.ts +5 -0
- package/src/components/layout/shell/index.tsx +25 -0
- package/src/components/layout/shell/menu.ts +9 -0
- package/src/components/layout/shell/pane/actions.ts +36 -0
- package/src/components/layout/shell/pane/management-shortcuts.ts +27 -3
- package/src/components/layout/shell/pane-occlusion.ts +40 -0
- package/src/components/layout/shell/shortcuts.ts +17 -1
- package/src/components/layout/shell/terminal-pointer-runtime.ts +39 -6
- package/src/components/layout/shell/window-mode/index.ts +5 -16
- package/src/components/layout/shell/window-mode/overlays.tsx +3 -1
- package/src/components/market-board/index.tsx +14 -5
- package/src/components/metric-treemap/index.tsx +3 -1
- package/src/components/ui/button.tsx +48 -4
- package/src/components/ui/data-table/opentui/index.tsx +24 -9
- package/src/components/ui/data-table/types.ts +7 -0
- package/src/components/ui/inline-quick-add.tsx +19 -3
- package/src/components/ui/list-view.tsx +11 -5
- package/src/components/ui/query-bar.tsx +16 -1
- package/src/components/ui/selection-fill.ts +39 -0
- package/src/core/state/app/layout-reducer.ts +2 -1
- package/src/core/state/app/pane-choices.ts +68 -0
- package/src/core/state/app/state.ts +14 -6
- package/src/core/state/app/types.ts +8 -0
- package/src/layout/pane-manager/dock-tree.ts +19 -0
- package/src/layout/pane-manager/index.ts +3 -0
- package/src/market-data/market/freshness.ts +33 -0
- package/src/market-data/market/status.ts +5 -1
- package/src/market-data/quotes/contributions.ts +10 -0
- package/src/market-data/quotes/freshness.ts +19 -0
- package/src/market-data/quotes/live-valuation.ts +31 -4
- package/src/market-data/quotes/resolution.ts +4 -0
- package/src/market-data/quotes/time.ts +0 -14
- package/src/plugins/builtin/account-management/index.tsx +1 -0
- package/src/plugins/builtin/awards/detail.tsx +12 -4
- package/src/plugins/builtin/awards/headless.ts +29 -8
- package/src/plugins/builtin/awards/model.ts +36 -2
- package/src/plugins/builtin/awards/pane.tsx +7 -4
- package/src/plugins/builtin/broker-manager/index.tsx +1 -0
- package/src/plugins/builtin/broker-trading/index.tsx +1 -1
- package/src/plugins/builtin/central-bank-rates/headless.ts +6 -6
- package/src/plugins/builtin/central-bank-rates/index.tsx +1 -1
- package/src/plugins/builtin/central-bank-rates/model.ts +21 -3
- package/src/plugins/builtin/central-bank-rates/pane.tsx +15 -5
- package/src/plugins/builtin/chart-composer/headless.ts +5 -1
- package/src/plugins/builtin/chart-composer/pane.tsx +1 -0
- package/src/plugins/builtin/chat/content/handle-prompt.tsx +4 -0
- package/src/plugins/builtin/chat/controller/realtime.ts +17 -1
- package/src/plugins/builtin/chat/message/terminal.tsx +4 -1
- package/src/plugins/builtin/chat/sidebar.tsx +3 -4
- package/src/plugins/builtin/cloud/askg/pane.tsx +4 -0
- package/src/plugins/builtin/cloud/plugin.tsx +1 -0
- package/src/plugins/builtin/cloud/team/module.tsx +1 -0
- package/src/plugins/builtin/cloud/thesis/detail.tsx +9 -4
- package/src/plugins/builtin/commodity-balances/pane.tsx +13 -5
- package/src/plugins/builtin/company-kpis/model.ts +3 -3
- package/src/plugins/builtin/connections/index.ts +1 -0
- package/src/plugins/builtin/credit-boards/cdx-pane.tsx +9 -5
- package/src/plugins/builtin/credit-boards/client.ts +5 -0
- package/src/plugins/builtin/credit-boards/headless.ts +1 -6
- package/src/plugins/builtin/credit-boards/model.ts +0 -6
- package/src/plugins/builtin/credit-boards/series.ts +19 -8
- package/src/plugins/builtin/credit-boards/sovr-pane.tsx +9 -5
- package/src/plugins/builtin/crypto-etf-flows/headless.ts +23 -13
- package/src/plugins/builtin/crypto-etf-flows/pane.tsx +8 -3
- package/src/plugins/builtin/debt-maturities/headless.ts +16 -7
- package/src/plugins/builtin/debt-maturities/model.ts +9 -15
- package/src/plugins/builtin/debt-maturities/pane.tsx +9 -10
- package/src/plugins/builtin/earnings/board-model.ts +33 -4
- package/src/plugins/builtin/earnings/board.tsx +15 -3
- package/src/plugins/builtin/earnings/calendar.tsx +10 -6
- package/src/plugins/builtin/earnings/client.ts +0 -9
- package/src/plugins/builtin/earnings/headless.ts +10 -7
- package/src/plugins/builtin/earnings/history.tsx +21 -14
- package/src/plugins/builtin/earnings-calls/data.ts +24 -4
- package/src/plugins/builtin/earnings-calls/format.ts +23 -5
- package/src/plugins/builtin/earnings-calls/headless.ts +23 -3
- package/src/plugins/builtin/earnings-calls/index.tsx +1 -0
- package/src/plugins/builtin/earnings-calls/model.ts +11 -1
- package/src/plugins/builtin/earnings-calls/pane.tsx +2 -5
- package/src/plugins/builtin/econ/calendar-model.ts +27 -0
- package/src/plugins/builtin/econ/fred-catalog.ts +3 -0
- package/src/plugins/builtin/econ/index.tsx +9 -2
- package/src/plugins/builtin/econ-statistics/headless.ts +3 -1
- package/src/plugins/builtin/econ-statistics/index.tsx +1 -1
- package/src/plugins/builtin/fear-greed/headless.ts +16 -13
- package/src/plugins/builtin/fear-greed/pane.tsx +12 -4
- package/src/plugins/builtin/filing-events/index.tsx +1 -0
- package/src/plugins/builtin/fx-matrix/index.tsx +30 -19
- package/src/plugins/builtin/insider/table.tsx +10 -7
- package/src/plugins/builtin/insider/tickers.tsx +1 -1
- package/src/plugins/builtin/iv-history/headless.ts +9 -8
- package/src/plugins/builtin/jobs/index.tsx +1 -0
- package/src/plugins/builtin/macro-day/headless.ts +3 -3
- package/src/plugins/builtin/macro-day/model.ts +1 -1
- package/src/plugins/builtin/macro-day/releases.ts +25 -16
- package/src/plugins/builtin/market-movers/index.tsx +20 -8
- package/src/plugins/builtin/market-movers/model.ts +5 -0
- package/src/plugins/builtin/market-movers/session-body.tsx +2 -1
- package/src/plugins/builtin/money-markets/headless.ts +12 -2
- package/src/plugins/builtin/money-markets/pane.tsx +10 -1
- package/src/plugins/builtin/options/view.tsx +1 -0
- package/src/plugins/builtin/options-positioning/pane.tsx +1 -1
- package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +4 -31
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +6 -1
- package/src/plugins/builtin/portfolio-list/quick-add/index.tsx +22 -8
- package/src/plugins/builtin/portfolio-list/summary/index.tsx +6 -8
- package/src/plugins/builtin/portfolio-list/table.tsx +10 -1
- package/src/plugins/builtin/realized-vol/headless.ts +28 -2
- package/src/plugins/builtin/risk-factors/index.tsx +1 -0
- package/src/plugins/builtin/shared/source-footer.ts +70 -0
- package/src/plugins/builtin/short-interest/publications-pane.tsx +5 -1
- package/src/plugins/builtin/short-volume/pane.tsx +5 -1
- package/src/plugins/builtin/social-mentions/outliers.tsx +10 -1
- package/src/plugins/builtin/social-mentions/pane.tsx +7 -0
- package/src/plugins/builtin/supply-chain/client.ts +3 -1
- package/src/plugins/builtin/supply-chain/flow.tsx +25 -8
- package/src/plugins/builtin/supply-chain/graph-client.ts +1 -1
- package/src/plugins/builtin/supply-chain/graph-evidence.ts +1 -1
- package/src/plugins/builtin/supply-chain/graph-model.ts +12 -1
- package/src/plugins/builtin/supply-chain/graph-pane.tsx +9 -8
- package/src/plugins/builtin/supply-chain/graph.tsx +12 -6
- package/src/plugins/builtin/supply-chain/headless.ts +13 -7
- package/src/plugins/builtin/supply-chain/model.ts +68 -11
- package/src/plugins/builtin/supply-chain/pane.tsx +9 -6
- package/src/plugins/builtin/supply-chain/row-evidence.tsx +5 -5
- package/src/plugins/builtin/ticker-detail/overview/components.tsx +14 -1
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +2 -0
- package/src/plugins/builtin/ticker-detail/pane.tsx +48 -24
- package/src/plugins/builtin/ticker-detail/quote-footer.ts +5 -0
- package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +6 -3
- package/src/plugins/builtin/treasury-auctions/after.ts +50 -23
- package/src/plugins/builtin/treasury-auctions/cache.ts +23 -5
- package/src/plugins/builtin/treasury-auctions/headless.ts +226 -37
- package/src/plugins/builtin/treasury-auctions/hk-headless.ts +11 -5
- package/src/plugins/builtin/treasury-auctions/hk-view.tsx +27 -25
- package/src/plugins/builtin/treasury-auctions/hk.ts +60 -8
- package/src/plugins/builtin/treasury-auctions/index.tsx +3 -0
- package/src/plugins/builtin/treasury-auctions/keys.ts +27 -0
- package/src/plugins/builtin/treasury-auctions/like.ts +137 -0
- package/src/plugins/builtin/treasury-auctions/model.ts +100 -22
- package/src/plugins/builtin/treasury-auctions/pane.tsx +39 -11
- package/src/plugins/builtin/vol-surface/heat-grid.tsx +4 -2
- package/src/plugins/builtin/vol-surface/pane.tsx +5 -2
- package/src/plugins/runtime/index.tsx +1 -0
- package/src/plugins/runtime/state.ts +20 -0
- package/src/portfolio/column-values.ts +8 -2
- package/src/public/__snapshots__/public-api.test.ts.snap +5 -0
- package/src/public/react.ts +7 -0
- package/src/react/auto-refresh.ts +29 -0
- package/src/renderers/browser/deeplink-bridge.ts +24 -3
- package/src/renderers/dom/desktop/query-bar.tsx +229 -60
- package/src/renderers/dom/host/overflow-fade-px.ts +2 -0
- package/src/renderers/dom/host/overflow-fade.ts +1 -2
- package/src/renderers/dom/styles.css +25 -5
- package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +2 -1
- package/src/series/types.ts +2 -0
- package/src/sources/gloomberb-cloud/fred-attribution.ts +86 -0
- package/src/sources/gloomberb-cloud/index.ts +25 -1
- package/src/sources/gloomberb-cloud/normalizers.ts +22 -3
- package/src/sources/provider-errors.ts +64 -1
- package/src/sources/provider-router/batches.ts +19 -0
- package/src/sources/provider-router/index.ts +7 -1
- package/src/state/app/context/index.tsx +24 -1
- package/src/state/pane-unsent-work.ts +47 -0
- package/src/test-support/shell-pane-keys.tsx +5 -0
- package/src/test-support/telemetry-guard.ts +83 -0
- package/src/test-support/test-env.ts +12 -0
- package/src/theme/colors.ts +17 -1
- package/src/theme/ui-tokens.ts +50 -1
- package/src/tickers/listing-venues.ts +11 -1
- package/src/tickers/search/japanese-names.json +1 -0
- package/src/tickers/search/japanese-names.ts +152 -0
- package/src/tickers/terminal-codes.ts +55 -6
- package/src/time-series/base-series.ts +3 -0
- package/src/types/data-provider.ts +6 -0
- package/src/types/financials.ts +11 -0
- package/src/types/plugin-contributions.ts +7 -0
- package/src/types/plugin-panes.ts +7 -0
- package/src/ui/host.tsx +6 -0
- package/src/utils/double-escape-close.ts +42 -0
- package/src/utils/fx-status.ts +30 -7
- package/src/utils/network-failure.ts +23 -0
|
@@ -44,6 +44,7 @@ import { createPaneCatalog } from "../pane-functions/discovery";
|
|
|
44
44
|
import { buildPaneCatalogEntries, filterPaneCatalogEntries, selectPaneCatalogMatches } from "../pane-functions/catalog";
|
|
45
45
|
import { normalizeSearchText } from "../../tickers/search/ranking";
|
|
46
46
|
import { hasNonLatinLetters } from "../../utils/typed-text";
|
|
47
|
+
import { isKanjiOnlyName, japaneseNameReadAs, readExactJapaneseName, readJapaneseName, type JapaneseNameListing } from "../../tickers/search/japanese-names";
|
|
47
48
|
|
|
48
49
|
interface SearchCommandDependencies {
|
|
49
50
|
initMarketData?: () => Promise<MarketContext>;
|
|
@@ -149,6 +150,22 @@ export async function searchCandidatesForCli({
|
|
|
149
150
|
}
|
|
150
151
|
}
|
|
151
152
|
|
|
153
|
+
/** Each listing a name in Japanese was read as, searched for by its key, in that order and once each. */
|
|
154
|
+
async function japaneseNameCandidates(
|
|
155
|
+
listings: readonly JapaneseNameListing[],
|
|
156
|
+
tickers: TickerRecord[],
|
|
157
|
+
dataProvider: DataProvider,
|
|
158
|
+
): Promise<TickerSearchCandidate[]> {
|
|
159
|
+
const found = await Promise.all(listings.map(({ key }) => searchCandidatesForCli({ query: key, tickers, dataProvider, totalLimit: 1, localLimit: 1 })));
|
|
160
|
+
const seen = new Set<string>();
|
|
161
|
+
return found.flat().filter((candidate) => {
|
|
162
|
+
const key = `${candidate.symbol}:${candidate.result?.exchange ?? candidate.ticker?.metadata.exchange ?? ""}`;
|
|
163
|
+
if (seen.has(key)) return false;
|
|
164
|
+
seen.add(key);
|
|
165
|
+
return true;
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
152
169
|
/** A symbol search does not list whose quote stopped long ago: TWTR, last traded 2022-10-27. */
|
|
153
170
|
interface StoppedListing {
|
|
154
171
|
symbol: string;
|
|
@@ -763,12 +780,24 @@ export async function search(query: string, dependencies: SearchCommandDependenc
|
|
|
763
780
|
const changes = bare ? startTickerChangeLookup(dataProvider, symbol) : null;
|
|
764
781
|
// With no quote, its US line's last bars, to list a retired symbol (STPP) with its last day.
|
|
765
782
|
const ending = quote?.then((quoted) => quoted ? null : loadNoQuoteEnding({ symbol }, dataProvider));
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
dataProvider,
|
|
770
|
-
|
|
771
|
-
|
|
783
|
+
// A name typed in Japanese (トヨタ, ドル円) searches for the listings it names, which are named in Latin letters.
|
|
784
|
+
const japanese = index ? null : await readJapaneseName(trimmedQuery);
|
|
785
|
+
const searched = japanese
|
|
786
|
+
? await japaneseNameCandidates(japanese.listings, tickers, dataProvider).catch((error: unknown) => failTickerLookup(error, trimmedQuery, !dependencies.printResult))
|
|
787
|
+
: await searchCandidatesForCli({
|
|
788
|
+
query: index?.symbol ?? trimmedQuery,
|
|
789
|
+
tickers,
|
|
790
|
+
dataProvider,
|
|
791
|
+
...quote ? { quote } : {},
|
|
792
|
+
}).catch((error: unknown) => failTickerLookup(error, trimmedQuery, !dependencies.printResult));
|
|
793
|
+
// A name in kanji alone is the service's to read first (中電 is CLP in Hong Kong); a Tokyo company's whole name it
|
|
794
|
+
// finds nothing for (中電工) is read from the Tokyo list.
|
|
795
|
+
const exact = searched.length === 0 && !japanese && !index && isKanjiOnlyName(trimmedQuery) ? await readExactJapaneseName(trimmedQuery) : null;
|
|
796
|
+
const candidates = exact
|
|
797
|
+
? await japaneseNameCandidates(exact.listings, tickers, dataProvider).catch((error: unknown) => failTickerLookup(error, trimmedQuery, !dependencies.printResult))
|
|
798
|
+
: searched;
|
|
799
|
+
const reading = japanese ?? exact;
|
|
800
|
+
const readAs = index?.readAs ?? (reading ? japaneseNameReadAs(trimmedQuery, reading) : undefined);
|
|
772
801
|
const fate = quote && changes ? await searchFate(symbol, candidates, await quote, dataProvider, changes, ending) : NO_SEARCH_FATE;
|
|
773
802
|
|
|
774
803
|
const series = findCatalogSeries(dependencies.plugins ?? [], trimmedQuery, "names");
|
|
@@ -781,7 +810,7 @@ export async function search(query: string, dependencies: SearchCommandDependenc
|
|
|
781
810
|
data: [...fate.stopped ? [stoppedListingRow(fate.stopped)] : [], ...searchCandidateRows(candidates)],
|
|
782
811
|
metadata: { query: trimmedQuery, ...(index ? { searched: index.symbol } : {}), ...(series.length ? { series } : {}), ...(functions.length ? { functions } : {}),
|
|
783
812
|
...(bank ? { centralBank: { id: bank.id, name: bank.name, place: bank.place, function: "CBR" } } : {}) },
|
|
784
|
-
warnings:
|
|
813
|
+
warnings: readAs || warnings.length ? [...readAs ? [readAs] : [], ...warnings] : undefined,
|
|
785
814
|
}, {
|
|
786
815
|
columns: [
|
|
787
816
|
{ key: "category", header: "Category" },
|
|
@@ -802,7 +831,7 @@ export async function search(query: string, dependencies: SearchCommandDependenc
|
|
|
802
831
|
series,
|
|
803
832
|
functions,
|
|
804
833
|
fate,
|
|
805
|
-
readAs
|
|
834
|
+
readAs,
|
|
806
835
|
}));
|
|
807
836
|
});
|
|
808
837
|
}
|
|
@@ -106,7 +106,7 @@ import type { ReportFreshness } from "../pane-functions/freshness";
|
|
|
106
106
|
import { fundamentalsFreshness, quotesFreshness } from "../freshness";
|
|
107
107
|
import { distributionHistory, forwardDividendBasis, forwardDividendMayHaveLapsed, lapsedDividend, noCurrentDividend, TRAILING_DIVIDEND_BASIS, type DistributionHistory, type DividendLapse } from "../../utils/forward-dividend";
|
|
108
108
|
import { declaredDividends } from "../../utils/declared-dividends";
|
|
109
|
-
import { atLivePriceEarnings, historyTrailingDividendYield, measuresTrailingYield } from "../../market-data/quotes/live-valuation";
|
|
109
|
+
import { atLivePriceEarnings, historyTrailingDividendYield, measuresTrailingYield, statedYearRange } from "../../market-data/quotes/live-valuation";
|
|
110
110
|
import { loadOfferingFilings, loadStatementFilings, resultsReleaseText, statementPeriodText, type StatementFilingsReport } from "../statement-filings";
|
|
111
111
|
import type { BankFiguresPayload } from "../../api-client/bank-figures";
|
|
112
112
|
import { bankSection } from "../bank-section";
|
|
@@ -200,6 +200,18 @@ function yearRangeOptions(quote: Quote, options: MarketFormatOptions): MarketFor
|
|
|
200
200
|
return { ...stable, fixedFractionDigits: Math.min(stable.fixedFractionDigits, digits) };
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
+
/**
|
|
204
|
+
* The 52-week range, "—" when the quote states none that is one (an index's
|
|
205
|
+
* that repeats its day's range, a bound at 0), and "(daily bars)" after one
|
|
206
|
+
* the service read from the stored daily bars in place of its source's.
|
|
207
|
+
*/
|
|
208
|
+
function yearRangeText(quote: Quote, options: MarketFormatOptions): string {
|
|
209
|
+
const range = statedYearRange(quote);
|
|
210
|
+
if (!range) return "—";
|
|
211
|
+
const text = formatPriceRange(range.low, range.high, quote.currency, yearRangeOptions(quote, options));
|
|
212
|
+
return quote.yearRangeBasis === "daily-bars" ? `${text} (daily bars)` : text;
|
|
213
|
+
}
|
|
214
|
+
|
|
203
215
|
function bidAskText(quote: Quote, options: MarketFormatOptions): string {
|
|
204
216
|
const text = formatBidAsk(quote.bid, quote.ask, quote.bidSize, quote.askSize, quote.currency, options);
|
|
205
217
|
const label = text === "—" ? null : quoteBookSessionLabel(quote);
|
|
@@ -1479,9 +1491,8 @@ export async function buildTickerReport({
|
|
|
1479
1491
|
: "—"],
|
|
1480
1492
|
// The year's high and low come from bars (a continuous future's are float32, 54.97999954): they print at
|
|
1481
1493
|
// the instrument's own decimals, as the Overview's ranges do, never at every digit the bars carry.
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
: "—"],
|
|
1494
|
+
// Only a range that is one (statedYearRange); one read from the stored daily bars says so.
|
|
1495
|
+
["52W Range", yearRangeText(quote, quoteOptions)],
|
|
1485
1496
|
["Bid / Ask", bidAskText(quote, quoteOptions)],
|
|
1486
1497
|
// An index's and a perpetual's 0 means none is counted, not no trades: no Volume row.
|
|
1487
1498
|
["Volume", volume != null ? `${formatNumber(volume, 0)}${volumeCurrency}` : "—"],
|
|
@@ -203,6 +203,12 @@ export interface DesktopPaneShotRenderResult {
|
|
|
203
203
|
* Absent when no state shows, or in a capture that did not read them.
|
|
204
204
|
*/
|
|
205
205
|
stateText?: { error?: string[]; empty?: string[] };
|
|
206
|
+
/**
|
|
207
|
+
* The headers of the table columns the capture cut: drawn past the edge of
|
|
208
|
+
* their table's viewport (a table too wide for the pane scrolls sideways),
|
|
209
|
+
* whole or in part. Absent when none is, or in a capture that did not read them.
|
|
210
|
+
*/
|
|
211
|
+
cutColumns?: string[];
|
|
206
212
|
/** A wall that needs an account, or a Pro lock on part of the pane. */
|
|
207
213
|
accessGate?: PaneAccessGate | null;
|
|
208
214
|
/**
|
|
@@ -870,12 +876,27 @@ async function readRenderedPaneState(session: CdpPage): Promise<DesktopPaneShotR
|
|
|
870
876
|
[...root.querySelectorAll(
|
|
871
877
|
'[data-gloom-scrollbar-x="visible"], [data-gloom-scrollbar-y="visible"], [data-gloom-role="data-table-body-scroll"]',
|
|
872
878
|
)].forEach(markScrollTruncation);
|
|
879
|
+
const cutColumns = [];
|
|
873
880
|
visibleTables
|
|
874
881
|
.forEach((table, tableIndex) => {
|
|
875
882
|
const tableMetadata = semanticTables[tableIndex] && semanticTables[tableIndex].metadata || {};
|
|
876
883
|
const semanticColumns = Array.isArray(tableMetadata.columns) ? tableMetadata.columns : [];
|
|
877
|
-
const
|
|
878
|
-
|
|
884
|
+
const headerCells = [...table.querySelectorAll('[data-gloom-role="data-table-header-cell"]')];
|
|
885
|
+
const headers = headerCells.map((cell) => normalize(cell.innerText || cell.textContent));
|
|
886
|
+
// A column drawn past the edge of the table's viewport, whole or in part, is one the picture cut.
|
|
887
|
+
const scroller = table.querySelector('[data-gloom-role="data-table-body-scroll"]');
|
|
888
|
+
if (scroller instanceof HTMLElement) {
|
|
889
|
+
const box = scroller.getBoundingClientRect();
|
|
890
|
+
const left = Math.max(0, box.left);
|
|
891
|
+
const right = Math.min(window.innerWidth, box.left + scroller.clientWidth);
|
|
892
|
+
headerCells.forEach((cell, cellIndex) => {
|
|
893
|
+
const rect = cell.getBoundingClientRect();
|
|
894
|
+
if (rect.width <= 0 || (rect.left >= left - 1 && rect.right <= right + 1)) return;
|
|
895
|
+
// A centred header is padded with spaces (FA's " FY2024 ").
|
|
896
|
+
const label = normalize((semanticColumns[cellIndex] || {}).label) || headers[cellIndex] || String(cellIndex + 1);
|
|
897
|
+
if (!cutColumns.includes(label)) cutColumns.push(label);
|
|
898
|
+
});
|
|
899
|
+
}
|
|
879
900
|
const rowElements = [...table.querySelectorAll(
|
|
880
901
|
'[data-gloom-role="data-table-row"], [data-gloom-role="data-table-section-header"]',
|
|
881
902
|
)].filter(isVisible);
|
|
@@ -1008,6 +1029,7 @@ async function readRenderedPaneState(session: CdpPage): Promise<DesktopPaneShotR
|
|
|
1008
1029
|
return { ...(error.length ? { error } : {}), ...(empty.length ? { empty } : {}) };
|
|
1009
1030
|
})(),
|
|
1010
1031
|
contentFigures: (${countContentFigures.toString()})(root, isVisible),
|
|
1032
|
+
cutColumns,
|
|
1011
1033
|
// The shared sign-in wall and the Pro lock prompt every gated pane draws.
|
|
1012
1034
|
accessGate: [...root.querySelectorAll('[data-gloom-ui="sign-in-wall"]')].some(isVisible) ? "sign-in"
|
|
1013
1035
|
: [...root.querySelectorAll('[data-gloom-ui="pro-lock"]')].some(isVisible) ? "pro" : "",
|
|
@@ -1037,6 +1059,7 @@ async function readRenderedPaneState(session: CdpPage): Promise<DesktopPaneShotR
|
|
|
1037
1059
|
emptyStateText?: string[];
|
|
1038
1060
|
stateText?: { error?: unknown; empty?: unknown };
|
|
1039
1061
|
contentFigures?: number;
|
|
1062
|
+
cutColumns?: unknown;
|
|
1040
1063
|
accessGate?: string;
|
|
1041
1064
|
rows?: DesktopPaneShotRenderedRow[];
|
|
1042
1065
|
truncated?: boolean;
|
|
@@ -1093,6 +1116,8 @@ async function readRenderedPaneState(session: CdpPage): Promise<DesktopPaneShotR
|
|
|
1093
1116
|
accessGate,
|
|
1094
1117
|
...shotStateText(value?.stateText),
|
|
1095
1118
|
...(typeof value?.contentFigures === "number" ? { contentFigures: value.contentFigures } : {}),
|
|
1119
|
+
...(Array.isArray(value?.cutColumns) && value.cutColumns.length > 0
|
|
1120
|
+
? { cutColumns: value.cutColumns.filter((label): label is string => typeof label === "string" && label.length > 0) } : {}),
|
|
1096
1121
|
semanticUi: Array.isArray(value?.semanticUi) ? value.semanticUi : [],
|
|
1097
1122
|
};
|
|
1098
1123
|
}
|
package/src/cli/fx-quote-rate.ts
CHANGED
|
@@ -43,7 +43,7 @@ export interface FxQuoteRate {
|
|
|
43
43
|
* The front-month future a metal with no spot quote is priced from, in USD per
|
|
44
44
|
* troy ounce: COMEX gold and silver, NYMEX platinum and palladium.
|
|
45
45
|
*/
|
|
46
|
-
const METAL_FRONT_MONTH: Readonly<Record<string, string>> = { XAU: "GC=F", XAG: "SI=F", XPT: "PL=F", XPD: "PA=F" };
|
|
46
|
+
export const METAL_FRONT_MONTH: Readonly<Record<string, string>> = { XAU: "GC=F", XAG: "SI=F", XPT: "PL=F", XPD: "PA=F" };
|
|
47
47
|
|
|
48
48
|
/** "Gold", for the line that says a metal's rate is derived from its future. */
|
|
49
49
|
export const METAL_NAMES: Readonly<Record<string, string>> = { XAU: "Gold", XAG: "Silver", XPT: "Platinum", XPD: "Palladium" };
|
package/src/cli/glossary.ts
CHANGED
|
@@ -28,6 +28,11 @@ export interface GlossaryEntry {
|
|
|
28
28
|
* print in other yields.
|
|
29
29
|
*/
|
|
30
30
|
shownBy?: Readonly<Record<string, readonly string[]>>;
|
|
31
|
+
/**
|
|
32
|
+
* Terms a reader looking this one up wants beside it, by their `term`:
|
|
33
|
+
* looking up when-issued prints the tail it is measured against too.
|
|
34
|
+
*/
|
|
35
|
+
related?: readonly string[];
|
|
31
36
|
/** One or two plain sentences. */
|
|
32
37
|
definition: string;
|
|
33
38
|
}
|
|
@@ -80,7 +85,7 @@ export const GLOSSARY: readonly GlossaryEntry[] = [
|
|
|
80
85
|
},
|
|
81
86
|
{
|
|
82
87
|
term: "When-issued", short: "WI", aliases: ["when issued", "wi yield", "when-issued yield"], functions: ["AUCT"],
|
|
83
|
-
shown: ["when-issued", "When-issued"],
|
|
88
|
+
shown: ["when-issued", "When-issued"], related: ["Tail"],
|
|
84
89
|
definition: "Trading in a Treasury security between its announcement and its issue. The when-issued yield at the auction deadline is what a tail is measured against.",
|
|
85
90
|
},
|
|
86
91
|
{
|
|
@@ -96,9 +101,10 @@ export const GLOSSARY: readonly GlossaryEntry[] = [
|
|
|
96
101
|
+ "The auction's high discount rate is the one its investment rate restates.",
|
|
97
102
|
},
|
|
98
103
|
{
|
|
99
|
-
term: "Auction percentile", aliases: ["b/c percentile", "b/c pctl", "indirect percentile", "dealer percentile"
|
|
100
|
-
|
|
101
|
-
|
|
104
|
+
term: "Auction percentile", aliases: ["b/c percentile", "b/c pctl", "indirect percentile", "dealer percentile", "stop-out percentile", "stop-out pctl"],
|
|
105
|
+
functions: ["AUCT"],
|
|
106
|
+
shown: ["Stop-out pctl", "B/C pctl", "Indirect pctl", "Dealer pctl"],
|
|
107
|
+
definition: "Where an auction's stop-out vs median, bid-to-cover, indirect or dealer share ranks among the previous 24 auctions of the same "
|
|
102
108
|
+ "tenor and type, from 0 (the lowest) to 100 (the highest). Blank with fewer than 12 before it.",
|
|
103
109
|
},
|
|
104
110
|
{
|
|
@@ -1068,7 +1074,10 @@ const wholeWord = (have: string, word: string) => have === word || have === `${w
|
|
|
1068
1074
|
export function lookupGlossary(query: string): GlossaryLookup {
|
|
1069
1075
|
const key = lookupKey(query);
|
|
1070
1076
|
if (!key) return { exact: [], partial: [] };
|
|
1071
|
-
const
|
|
1077
|
+
const named = GLOSSARY.filter((entry) => names(entry).some((name) => lookupKey(name) === key));
|
|
1078
|
+
// A term named comes with the ones it is read beside (when-issued with the tail).
|
|
1079
|
+
const exact = [...new Set([...named, ...named.flatMap((entry) => (entry.related ?? [])
|
|
1080
|
+
.flatMap((term) => GLOSSARY.find((other) => other.term === term) ?? []))])];
|
|
1072
1081
|
const wanted = words(query).filter((word) => word.length >= MIN_PARTIAL_WORD);
|
|
1073
1082
|
if (wanted.length === 0) return { exact, partial: [] };
|
|
1074
1083
|
const others = GLOSSARY.filter((entry) => !exact.includes(entry));
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { GloomPlugin } from "../types/plugin";
|
|
2
|
+
import type { HeadlessSeriesResult } from "../types/headless";
|
|
3
|
+
import type { PriceWindow } from "../utils/price-window";
|
|
4
|
+
import { createPaneCatalog } from "./pane-functions/discovery";
|
|
5
|
+
import { loadResolvedHeadlessPaneModel } from "./pane-functions/headless";
|
|
6
|
+
import { parsePaneFunctionArgsFor, resolvePaneFunction } from "./pane-functions/resolver";
|
|
7
|
+
import type { MarketContext } from "./types";
|
|
8
|
+
import { fredSeriesArgument } from "../series/fred-argument";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A capability's series as `history` takes it beside listings: its source
|
|
12
|
+
* and its series (`CAP:bond-yield:jp-10y`). `CAP:EPA`, with no series, is
|
|
13
|
+
* Capgemini on Euronext Paris.
|
|
14
|
+
*/
|
|
15
|
+
const CAPABILITY_SERIES_ID = /^CAP:([A-Za-z0-9][A-Za-z0-9._~%/-]*):([A-Za-z0-9][A-Za-z0-9._~%:/-]*)$/i;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The id of a catalog series an entry of a list names, its prefix in
|
|
19
|
+
* capitals and the rest as typed; null for a listing. A FRED series is
|
|
20
|
+
* `FRED:<id>` where the id is no venue's code (`fredSeriesArgument`):
|
|
21
|
+
* `FRED:TSXV` is a listing.
|
|
22
|
+
*/
|
|
23
|
+
export function catalogSeriesId(entry: string): string | null {
|
|
24
|
+
const typed = entry.trim();
|
|
25
|
+
const fred = fredSeriesArgument(typed);
|
|
26
|
+
if (fred) return `FRED:${fred}`;
|
|
27
|
+
const capability = CAPABILITY_SERIES_ID.exec(typed);
|
|
28
|
+
// A capability's ids are as their source names them.
|
|
29
|
+
return capability ? `CAP:${capability[1]}:${capability[2]}` : null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** A catalog series' observations as `history --wide` sets them beside listings' closes. */
|
|
33
|
+
export interface CatalogSeriesHistory {
|
|
34
|
+
id: string;
|
|
35
|
+
/** What the series is, as the catalog names it: `Japan 10Y JGB yield`. */
|
|
36
|
+
label: string | null;
|
|
37
|
+
/** The unit of its values: `%`, `index`, `USD bn`. */
|
|
38
|
+
unit: string | null;
|
|
39
|
+
/** One value a date, oldest first, as ISO dates. */
|
|
40
|
+
points: Array<{ date: string; value: number }>;
|
|
41
|
+
/** What its chart said of it: a gap, a revision, a series it stands in for. */
|
|
42
|
+
notes: string[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** The chart's range a history range reads: G has no YTD (the year so far is in its 1Y). */
|
|
46
|
+
type ChartRange = "1D" | "1W" | "1M" | "3M" | "6M" | "1Y" | "5Y" | "ALL";
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* A catalog series' daily values over a history's range or window, read as
|
|
50
|
+
* `gloom fn G <id>` charts it, so a series `history` takes is the one the
|
|
51
|
+
* catalog lists. A window reads the whole series and keeps its dates. Throws
|
|
52
|
+
* with the chart's own reason for one that has no values (an id nothing
|
|
53
|
+
* answers to, a source that failed).
|
|
54
|
+
*/
|
|
55
|
+
export async function loadCatalogSeriesHistory(
|
|
56
|
+
id: string,
|
|
57
|
+
market: MarketContext,
|
|
58
|
+
plugins: GloomPlugin[],
|
|
59
|
+
ask: { range: string; window: PriceWindow | null },
|
|
60
|
+
signal?: AbortSignal,
|
|
61
|
+
): Promise<CatalogSeriesHistory> {
|
|
62
|
+
const range: ChartRange = ask.window ? "ALL" : ask.range === "YTD" ? "1Y" : ask.range as ChartRange;
|
|
63
|
+
const registry = await createPaneCatalog(market, plugins);
|
|
64
|
+
try {
|
|
65
|
+
const parsed = parsePaneFunctionArgsFor(registry, ["G", id, "--range-preset", range]);
|
|
66
|
+
const resolved = await resolvePaneFunction(registry, market, parsed, { seriesSources: plugins });
|
|
67
|
+
const loaded = await loadResolvedHeadlessPaneModel(resolved, market, id, signal ?? new AbortController().signal);
|
|
68
|
+
const result = loaded.result as HeadlessSeriesResult;
|
|
69
|
+
const series = result.series?.[0];
|
|
70
|
+
const yearStart = `${new Date().getUTCFullYear()}-01-01`;
|
|
71
|
+
const inAsk = (date: string) => ask.window ? date >= ask.window.from && date <= ask.window.to : ask.range !== "YTD" || date >= yearStart;
|
|
72
|
+
const points = (series?.points ?? []).flatMap((point) => {
|
|
73
|
+
const value = typeof point.value === "number" ? point.value : null;
|
|
74
|
+
const date = new Date(point.date as string).toISOString().slice(0, 10);
|
|
75
|
+
return value != null && Number.isFinite(value) && inAsk(date) ? [{ date, value }] : [];
|
|
76
|
+
});
|
|
77
|
+
// The chart's reason names the series after its line's label ("zz-10y: CAP:bond-yield:zz-10y is not covered"): said from the id.
|
|
78
|
+
const reason = [...result.errors ?? [], ...result.notes ?? []][0];
|
|
79
|
+
const at = reason?.indexOf(id) ?? -1;
|
|
80
|
+
if (points.length === 0) throw new Error(reason ? at > 0 ? reason.slice(at) : reason : `No values for ${id} in this range.`);
|
|
81
|
+
return { id, label: series?.label ?? null, unit: series?.unit ?? null, points, notes: result.notes ?? [] };
|
|
82
|
+
} finally {
|
|
83
|
+
registry.destroy();
|
|
84
|
+
}
|
|
85
|
+
}
|
package/src/cli/index.ts
CHANGED
|
@@ -226,7 +226,7 @@ export function createCoreCliCommands(
|
|
|
226
226
|
{ flags: "--scale <n>", description: "Text scale from 0.5 to 4 (default 1)" },
|
|
227
227
|
{ flags: "--watermark <label>", description: "Label drawn in the pane title bar" },
|
|
228
228
|
{ flags: "--no-status", description: "Leave out the dated status line (as-of, delay, market hours) drawn in the pane footer" },
|
|
229
|
-
{ flags: "--strict", description: `Exit ${CLI_EXIT_CODES.unusableShot} when the pane is empty, shows an error, is still loading, is access-gated or draws a column blank in every row; the PNG and the Reason line, which names what it saw, are still written` },
|
|
229
|
+
{ flags: "--strict", description: `Exit ${CLI_EXIT_CODES.unusableShot} when the pane is empty, shows an error, is still loading, is access-gated, or draws a column blank in every row; the PNG and the Reason line, which names what it saw, are still written. A column cut at the table's edge is a warning` },
|
|
230
230
|
{ flags: "--<option> <value>", description: "A function setting; gloom catalog <function> lists them" },
|
|
231
231
|
EXCHANGE_OPTION,
|
|
232
232
|
],
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { CliCommandContext } from "../types/plugin";
|
|
2
|
+
import { cliStyles } from "../utils/cli-output";
|
|
3
|
+
|
|
4
|
+
/** A list this slow says how far it has got, so it never looks stuck: first after two seconds, then every five. */
|
|
5
|
+
const PROGRESS_AFTER_MS = 2_000;
|
|
6
|
+
const PROGRESS_EVERY_MS = 5_000;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Lines on standard error while a command works through a list of symbols
|
|
10
|
+
* slowly, worded by `line` from how many are settled, how many there are, and
|
|
11
|
+
* whether a line was printed already: two seconds in, then every five seconds
|
|
12
|
+
* until all are. Nothing for one symbol or a list that is quick, nor with
|
|
13
|
+
* `--quiet`. It is told (0, total) as the list starts and again as each
|
|
14
|
+
* symbol settles; the lines come from a timer, so a list waiting on one slow
|
|
15
|
+
* answer still says so.
|
|
16
|
+
*/
|
|
17
|
+
export function listProgressNotice(
|
|
18
|
+
ctx: Pick<CliCommandContext, "cliOptions">,
|
|
19
|
+
line: (settled: number, total: number, told: boolean) => string,
|
|
20
|
+
{ afterMs = PROGRESS_AFTER_MS, everyMs = PROGRESS_EVERY_MS }: { afterMs?: number; everyMs?: number } = {},
|
|
21
|
+
): (settled: number, total: number) => void {
|
|
22
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
23
|
+
let settled = 0, total = 0, told = false;
|
|
24
|
+
const tell = () => {
|
|
25
|
+
timer = undefined;
|
|
26
|
+
if (settled >= total) return;
|
|
27
|
+
console.error(cliStyles.muted(line(settled, total, told)));
|
|
28
|
+
told = true;
|
|
29
|
+
schedule(everyMs);
|
|
30
|
+
};
|
|
31
|
+
const schedule = (ms: number) => {
|
|
32
|
+
timer = setTimeout(tell, ms);
|
|
33
|
+
// The command's own end, not this line, decides when the process exits.
|
|
34
|
+
(timer as { unref?: () => void }).unref?.();
|
|
35
|
+
};
|
|
36
|
+
return (done, of) => {
|
|
37
|
+
if (ctx.cliOptions.quiet || of < 2) return;
|
|
38
|
+
settled = done;
|
|
39
|
+
total = of;
|
|
40
|
+
if (settled >= total) {
|
|
41
|
+
if (timer) clearTimeout(timer);
|
|
42
|
+
timer = undefined;
|
|
43
|
+
} else if (!timer) schedule(afterMs);
|
|
44
|
+
};
|
|
45
|
+
}
|
package/src/cli/listing-arg.ts
CHANGED
|
@@ -43,7 +43,7 @@ import {
|
|
|
43
43
|
import { withMarketData } from "./scoped-context";
|
|
44
44
|
import { failWithFields } from "./errors";
|
|
45
45
|
import { stripStrayEdges, tickerShapedWord } from "./symbol-args";
|
|
46
|
-
import { isNoProviderMessage, isNoSourceAnswer, isProviderBusy, notATickerSymbol } from "../sources/provider-errors";
|
|
46
|
+
import { isNoProviderMessage, isNoSourceAnswer, isProviderBusy, isRateLimited, isTransientServiceFailure, notATickerSymbol } from "../sources/provider-errors";
|
|
47
47
|
import { dashedCoinPair, exchangeLineCoinListing, isSpotCommodityOrCurrencyPair, MAJOR_COIN_NAMES, TOP_COIN_NAMES } from "../utils/crypto-pair";
|
|
48
48
|
import { boardCoinFor, primeBoardCoins } from "./board-coins";
|
|
49
49
|
import { knownGapMessage, unquotedGapMessage } from "./known-gaps";
|
|
@@ -68,9 +68,12 @@ import {
|
|
|
68
68
|
readTerminalListingCode,
|
|
69
69
|
terminalCodeReadAs,
|
|
70
70
|
unknownBloombergMarket,
|
|
71
|
+
unreadBloombergCode,
|
|
71
72
|
type NearMissListing,
|
|
72
73
|
type TerminalListingCode,
|
|
73
74
|
} from "../tickers/terminal-codes";
|
|
75
|
+
import { unreadBloombergCodeMessage } from "./terminal-code-hints";
|
|
76
|
+
import { isKanjiOnlyName, japaneseNameChoice, japaneseNameReadAs, readExactJapaneseName, readJapaneseName, type JapaneseNameReading } from "../tickers/search/japanese-names";
|
|
74
77
|
import { listingAbroadVenue } from "../utils/sec";
|
|
75
78
|
import { savedAbroadForBareSymbol, savedUsListingOf } from "../tickers/search/bare-symbol";
|
|
76
79
|
import { listingSuffixCandidate, listingSuffixVenue, tickerHasListingSuffix } from "../sources/listing-symbols";
|
|
@@ -713,9 +716,32 @@ export async function usListingsOnlyMessage(
|
|
|
713
716
|
* Aramco in Riyadh): then it asks, and none of the venues is the answer. Null
|
|
714
717
|
* when it named its exchange.
|
|
715
718
|
*/
|
|
716
|
-
|
|
719
|
+
/** How long a bare symbol's venue search that failed for a moment waits before it is asked once more. */
|
|
720
|
+
const VENUE_RETRY_WAIT_MS = 1_000;
|
|
721
|
+
|
|
722
|
+
async function bareListingVenues(
|
|
723
|
+
listing: BareListing,
|
|
724
|
+
deps: ListingDeps,
|
|
725
|
+
/**
|
|
726
|
+
* A search that failed for a reason that says nothing of the symbol is
|
|
727
|
+
* thrown: a list's 8306 read "Not a ticker" when its search was turned
|
|
728
|
+
* away, where alone it asks which exchange. A busy moment is asked once
|
|
729
|
+
* more first; the request limit never is.
|
|
730
|
+
*/
|
|
731
|
+
{ failTransient = false }: { failTransient?: boolean } = {},
|
|
732
|
+
): Promise<BareListingVenues | null> {
|
|
717
733
|
if (listing.exchange) return null;
|
|
718
|
-
const
|
|
734
|
+
const read = () => listingVenues(listing.symbol, deps, { failTransient });
|
|
735
|
+
const venues = await (failTransient
|
|
736
|
+
? read().catch(async (error: unknown) => {
|
|
737
|
+
if (!isTransientServiceFailure(error)) throw error;
|
|
738
|
+
await new Promise((resolve) => setTimeout(resolve, VENUE_RETRY_WAIT_MS));
|
|
739
|
+
return read();
|
|
740
|
+
})
|
|
741
|
+
: read()).catch((error: unknown) => {
|
|
742
|
+
if (failTransient && (isTransientServiceFailure(error) || isRateLimited(error))) throw error;
|
|
743
|
+
return logFailure("cli.listing-arg", "Read listing venues failed", [] as ListingVenue[])(error);
|
|
744
|
+
});
|
|
719
745
|
const savedExchange = canonicalExchange(listing.saved?.metadata.exchange);
|
|
720
746
|
if (!savedExchange && listsSeveralCompanies(listing.symbol, venues)) return { exchange: "", resolved: null, others: venues, choose: true };
|
|
721
747
|
const resolved = venues.find((venue) => venue.exchange === savedExchange) ?? (savedExchange ? null : homeVenue(listing.symbol, venues));
|
|
@@ -888,7 +914,9 @@ export type BareListingQuote =
|
|
|
888
914
|
* A code several companies list (2222) is never answered from one of them: it is
|
|
889
915
|
* that failure, asking which. Null when the symbol named its exchange (a named
|
|
890
916
|
* venue never switches) or search knows no listing of it. It searches, so ask
|
|
891
|
-
* only after a request failed.
|
|
917
|
+
* only after a request failed. A search that fails twice for a reason that
|
|
918
|
+
* says nothing of the symbol (a busy moment, the request limit) is thrown,
|
|
919
|
+
* never read as a symbol no venue lists.
|
|
892
920
|
*/
|
|
893
921
|
export async function quoteBareListing(
|
|
894
922
|
listing: CliListing,
|
|
@@ -896,7 +924,7 @@ export async function quoteBareListing(
|
|
|
896
924
|
request: ListingDataRequest,
|
|
897
925
|
{ refresh = false, datesChangeBasis = false }: { refresh?: boolean; datesChangeBasis?: boolean } = {},
|
|
898
926
|
): Promise<BareListingQuote | null> {
|
|
899
|
-
const venues = await bareListingVenues(listing, deps);
|
|
927
|
+
const venues = await bareListingVenues(listing, deps, { failTransient: true });
|
|
900
928
|
if (!venues) return null;
|
|
901
929
|
if (venues.choose) {
|
|
902
930
|
const other = describeOtherListings(listing, venues, request);
|
|
@@ -1439,6 +1467,14 @@ export async function resolveCliListing(
|
|
|
1439
1467
|
// "iron ore" has no live price: it says so and where the monthly one is, never Kumba Iron Ore's stock.
|
|
1440
1468
|
const unquoted = exchangeOption?.trim() ? null : unquotedGapMessage(typed);
|
|
1441
1469
|
if (unquoted) throw new ListingArgError(unquoted);
|
|
1470
|
+
// "GTJPY10Y Govt" and "VXJ Index" are Bloomberg codes no symbol here is read from: refused with what has them,
|
|
1471
|
+
// never searched for as a name (MOVE Index found another venue's product named after the index).
|
|
1472
|
+
const unreadCode = exchangeOption?.trim() ? null : unreadBloombergCode(typed);
|
|
1473
|
+
if (unreadCode) throw new ListingArgError(unreadBloombergCodeMessage(unreadCode));
|
|
1474
|
+
// A name typed in Japanese (ドル円, トヨタ自動車) is the listing it names, which is named in Latin letters; one several
|
|
1475
|
+
// companies' names start with (トヨタ) asks which. A name in kanji alone is the service's to read first, below.
|
|
1476
|
+
const japanese = exchangeOption?.trim() ? null : await readJapaneseName(typed);
|
|
1477
|
+
if (japanese) return await japaneseNameListing(typed, japanese, deps, options);
|
|
1442
1478
|
// A listing that moved to a new symbol (ELET3, "eletrobras") is the one it trades as now, saying so.
|
|
1443
1479
|
const renamed = exchangeOption?.trim() ? null : renamedListingFor(typed);
|
|
1444
1480
|
if (renamed) {
|
|
@@ -1481,9 +1517,13 @@ export async function resolveCliListing(
|
|
|
1481
1517
|
const hongKong = pair || named || index ? null : await readHongKongShortCode(parsed, deps);
|
|
1482
1518
|
if (hongKong) parsed = hongKong;
|
|
1483
1519
|
// A word no source quotes that names a company (`Naspers`) is its listing, for every command, as `quote` reads it.
|
|
1484
|
-
const
|
|
1485
|
-
|
|
1520
|
+
const askCompany = !(options.companyWord === false || pair || named || index || rooted || hongKong || terminal || dotted);
|
|
1521
|
+
const company = askCompany ? await readBareCompanyName(parsed, typed, deps) : null;
|
|
1486
1522
|
if (company) parsed = company;
|
|
1523
|
+
// A name in kanji alone the service names no company for (中電工; 中電 is CLP in Hong Kong) is a Tokyo company's
|
|
1524
|
+
// whole name, when it is one.
|
|
1525
|
+
const tokyo = askCompany && !company && !exchangeOption?.trim() && isKanjiOnlyName(typed) ? await readExactJapaneseName(typed) : null;
|
|
1526
|
+
if (tokyo) return await japaneseNameListing(typed, tokyo, deps, options);
|
|
1487
1527
|
// A one-letter suffix (7203.T) is read as its venue only when a row saved there says so; the listing's quote may later.
|
|
1488
1528
|
const venueRow = options.listingSuffix && !pair && !named ? await savedSuffixVenue(parsed, deps.store) : null;
|
|
1489
1529
|
if (venueRow) parsed = venueRow;
|
|
@@ -1813,6 +1853,18 @@ function readDollarIndexCode(raw: string, deps: Pick<ListingDeps, "dataProvider"
|
|
|
1813
1853
|
return brokerIndexCode(stripStrayEdges(raw).text || raw)?.bare ? readBrokerIndexCode(raw, deps) : Promise.resolve(null);
|
|
1814
1854
|
}
|
|
1815
1855
|
|
|
1856
|
+
/** The listing a name typed in Japanese reads as, saying so; one that names several companies asks which, with how many. */
|
|
1857
|
+
async function japaneseNameListing(
|
|
1858
|
+
typed: string,
|
|
1859
|
+
reading: JapaneseNameReading,
|
|
1860
|
+
deps: ListingDeps,
|
|
1861
|
+
options: Parameters<typeof resolveCliListing>[3],
|
|
1862
|
+
): Promise<CliListing> {
|
|
1863
|
+
if (reading.total > 1) throw new ListingArgError(japaneseNameChoice(typed, reading));
|
|
1864
|
+
const listing = await resolveCliListing(reading.listings[0]!.key, null, deps, options);
|
|
1865
|
+
return { ...listing, readAs: japaneseNameReadAs(typed, reading), readFromName: true, typed: typed.trim() };
|
|
1866
|
+
}
|
|
1867
|
+
|
|
1816
1868
|
/**
|
|
1817
1869
|
* The listing a company's name typed where a symbol goes stands for
|
|
1818
1870
|
* (`findListingOfCompanyName`), saying which one it was read as; null for a
|
|
@@ -1846,6 +1898,18 @@ const ONE_WORD_NAME = /^\p{L}[\p{L}\p{N}&'’.-]*$/u;
|
|
|
1846
1898
|
* hint, the coin's pair (BTC-USD) or the search that says where it is. Null
|
|
1847
1899
|
* for anything else, and when search names no company or is too busy to say.
|
|
1848
1900
|
*/
|
|
1901
|
+
/**
|
|
1902
|
+
* The Tokyo listing a name in kanji alone is the whole name of (中電工 is
|
|
1903
|
+
* 1941:JPX), for `quote` once the service has named no company for it
|
|
1904
|
+
* (`oneWordCompanyName`): never a name it only starts. Null for any other word.
|
|
1905
|
+
*/
|
|
1906
|
+
export async function tokyoCompanyNameArg(typed: string): Promise<ListingArg | null> {
|
|
1907
|
+
const reading = isKanjiOnlyName(typed) ? await readExactJapaneseName(typed) : null;
|
|
1908
|
+
if (!reading) return null;
|
|
1909
|
+
if (reading.total > 1) throw new ListingArgError(japaneseNameChoice(typed, reading));
|
|
1910
|
+
return { ...parseListingArg(reading.listings[0]!.key), readAs: japaneseNameReadAs(typed, reading), readFromName: true };
|
|
1911
|
+
}
|
|
1912
|
+
|
|
1849
1913
|
export async function oneWordCompanyName(typed: string, deps: Pick<ListingDeps, "dataProvider">): Promise<ListingArg | null> {
|
|
1850
1914
|
const found = await findOneWordCompany(typed, deps);
|
|
1851
1915
|
return found ? companyListingArg(typed, found) : null;
|
package/src/cli/name-entries.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { isNotATickerMessage } from "./not-a-ticker";
|
|
|
7
7
|
import { splitSymbolWords } from "./symbol-args";
|
|
8
8
|
import { isNumberCell } from "./symbol-cells";
|
|
9
9
|
import { isProviderBusy, type ProviderBusyError } from "../sources/provider-errors";
|
|
10
|
-
import { unknownBloombergMarket } from "../tickers/terminal-codes";
|
|
10
|
+
import { unknownBloombergMarket, unreadBloombergCode } from "../tickers/terminal-codes";
|
|
11
11
|
import { renamedListingFor } from "../tickers/renamed-listings";
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -40,7 +40,9 @@ export async function readNameEntryGroups(
|
|
|
40
40
|
// A pasted list's names are searched in batches and their quotes asked together, a few entries at a time: a list
|
|
41
41
|
// of hundreds of names is a few requests, never hundreds at once.
|
|
42
42
|
// A terminal's code abroad (`VOD LN`) is its listing as written: nothing searches for it as a name.
|
|
43
|
-
|
|
43
|
+
// So is a code no symbol is read from (`GTJPY10Y Govt`): its lookup refuses it, never GTJPY10Y and the GOVT fund.
|
|
44
|
+
const names = entries.filter((entry) => isCompanyNameInput(entry) && !unknownBloombergMarket(entry) && !unreadBloombergCode(entry)
|
|
45
|
+
&& !settledTerminalCode(entry));
|
|
44
46
|
const full = source as DataProvider;
|
|
45
47
|
const dataProvider = names.length > 1 && full.searchBatch
|
|
46
48
|
? (await batchedListLookups(full, names.map((name) => ({ searches: companyNameQueries(name), changes: null })))).dataProvider
|
|
@@ -48,7 +50,7 @@ export async function readNameEntryGroups(
|
|
|
48
50
|
const read = await mapWithConcurrency(entries, NAME_LOOKUPS_AT_ONCE, async (entry) => {
|
|
49
51
|
// A terminal's code for a listing ("JPM US Equity", "VOD LN") is one entry, like a company's name, and so is a
|
|
50
52
|
// line written as one whose market code is unknown ("AAPL GP"): its lookup refuses it, never AAPL and GP.
|
|
51
|
-
if (unknownBloombergMarket(entry) || await readTerminalCodeArg(dataProvider, entry)) return [entry];
|
|
53
|
+
if (unknownBloombergMarket(entry) || unreadBloombergCode(entry) || await readTerminalCodeArg(dataProvider, entry)) return [entry];
|
|
52
54
|
if (!isCompanyNameInput(entry)) return splitSymbolWords([entry]);
|
|
53
55
|
const named = await findListingOfCompanyName(dataProvider, entry).catch(busyAsAnswer);
|
|
54
56
|
const busy = isProviderBusy(named);
|
|
@@ -126,7 +128,9 @@ export async function readPhraseArgument(
|
|
|
126
128
|
phrase: string,
|
|
127
129
|
dataProvider: Pick<DataProvider, "search" | "getQuotesBatch">,
|
|
128
130
|
): Promise<PhraseReading> {
|
|
129
|
-
if (unknownBloombergMarket(phrase) || await readTerminalCodeArg(dataProvider, phrase))
|
|
131
|
+
if (unknownBloombergMarket(phrase) || unreadBloombergCode(phrase) || await readTerminalCodeArg(dataProvider, phrase)) {
|
|
132
|
+
return { kind: "symbols", symbols: [phrase] };
|
|
133
|
+
}
|
|
130
134
|
// A renamed company's former name ("Centrais Elétricas Brasileiras") is the listing it trades as now.
|
|
131
135
|
if (renamedListingFor(phrase)) return { kind: "name", name: phrase };
|
|
132
136
|
const words = splitSymbolWords([phrase]);
|
package/src/cli/not-a-ticker.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { renamedListingFor, renamedListingHint } from "../tickers/renamed-listin
|
|
|
4
4
|
import { boardCoinFor } from "./board-coins";
|
|
5
5
|
import { currencyNameHint } from "./currency-name-hint";
|
|
6
6
|
import { splitSymbolArgs, splitSymbolWords } from "./symbol-args";
|
|
7
|
-
import { treasuryYieldHint, treasuryYieldTenor } from "./treasury-yields";
|
|
7
|
+
import { isTreasuryFredSeries, treasuryYieldHint, treasuryYieldTenor } from "./treasury-yields";
|
|
8
8
|
|
|
9
9
|
// "Not a ticker: APPLE." as the router words it; the symbol ends at the sentence's own period.
|
|
10
10
|
// One that already names what to try (a search, a FRED series, a yield, a currency's rate, the pair search offered) is left alone.
|
|
@@ -52,7 +52,7 @@ export function withSearchHints(text: string, args: readonly string[], isFredSer
|
|
|
52
52
|
? named.replace(NOT_A_TICKER_SENTENCE, (sentence, symbol: string) => {
|
|
53
53
|
const typed = typedSymbol(symbol, args);
|
|
54
54
|
const id = typed.toUpperCase();
|
|
55
|
-
if (/^[A-Z0-9]+$/.test(id) && isFredSeries(id)) return `${sentence} Try \`gloom fred ${id}\`.`;
|
|
55
|
+
if (/^[A-Z0-9]+$/.test(id) && (isFredSeries(id) || isTreasuryFredSeries(id))) return `${sentence} Try \`gloom fred ${id}\`.`;
|
|
56
56
|
// A listing that moved to a new symbol (ELET3 is AXIA3) points to it, never to a search for the dead one.
|
|
57
57
|
const renamed = renamedListingFor(typed);
|
|
58
58
|
if (renamed) return `${sentence} ${renamedListingHint(renamed)}`;
|