gloomberb 0.20.13 → 0.20.16
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/patches/@opentui%2Fcore@0.3.2.patch +22 -4
- package/src/account/auth-dialog.tsx +22 -4
- package/src/account/auth-form.tsx +6 -1
- package/src/account/checkout-handoff.tsx +7 -14
- package/src/account/device-signin-dialog.tsx +35 -24
- package/src/api-client/crypto-markets.ts +10 -0
- package/src/api-client/errors.ts +3 -1
- package/src/api-client/index.ts +54 -0
- package/src/api-client/install-experiments.ts +8 -7
- package/src/api-client/money-markets.ts +7 -0
- package/src/api-client/paths.ts +2 -1
- package/src/api-client/product-waitlist.ts +63 -0
- package/src/api-client/request.ts +16 -4
- package/src/api-client/types/billing.ts +45 -0
- package/src/api-client/yearly-plan.ts +132 -0
- package/src/app/global-shortcuts.ts +5 -3
- package/src/app/pane-runtime/index.tsx +2 -2
- package/src/app/pane-runtime/plugin-bindings.ts +3 -1
- package/src/app/pane-runtime/ticker-open-runtime.ts +6 -1
- package/src/app/since-last-visit/keys.ts +26 -0
- package/src/app/since-last-visit/model.ts +266 -0
- package/src/app/since-last-visit/strip.tsx +193 -0
- package/src/app/since-last-visit/use-since-last-visit.ts +289 -0
- package/src/app/since-last-visit/visit-tracker.ts +191 -0
- package/src/app.tsx +15 -0
- package/src/architecture/floating-promise-allowlist.json +0 -1
- package/src/brokers/signed-in/sign-in-dialog.tsx +38 -38
- package/src/cli/commands/market.ts +103 -27
- package/src/cli/commands/overview.ts +18 -4
- package/src/cli/commands/system.ts +29 -1
- package/src/cli/commands/ticker.ts +12 -5
- package/src/cli/desktop-pane-shot-api-policy.ts +4 -1
- package/src/cli/desktop-pane-shot-browser.ts +2 -1
- package/src/cli/desktop-pane-shot-view.ts +3 -7
- package/src/cli/desktop-pane-shot.ts +26 -28
- package/src/cli/errors.ts +3 -1
- package/src/cli/freshness.ts +7 -2
- package/src/cli/glossary.ts +10 -5
- package/src/cli/help.ts +1 -0
- package/src/cli/helpers.ts +8 -16
- package/src/cli/history-export.ts +4 -0
- package/src/cli/history-rows.ts +24 -0
- package/src/cli/index.ts +4 -0
- package/src/cli/known-gaps.ts +2 -2
- package/src/cli/listing-arg.ts +79 -11
- package/src/cli/not-a-ticker.ts +4 -0
- package/src/cli/options.ts +29 -1
- package/src/cli/pane-functions/catalog.ts +70 -12
- package/src/cli/pane-functions/function-help.ts +1 -1
- package/src/cli/pane-functions/headless.ts +68 -3
- package/src/cli/pane-functions/index.ts +2 -2
- package/src/cli/pane-functions/options.ts +7 -0
- package/src/cli/pane-functions/resolver.ts +104 -15
- package/src/cli/pane-functions/screenshot-payload.ts +3 -0
- package/src/cli/report-tables.ts +20 -5
- package/src/cli/result.ts +22 -4
- package/src/cli/shot-temp-dir.ts +30 -0
- package/src/cli/suffixed-listing-rows.ts +11 -0
- package/src/cli/symbol-args.ts +5 -3
- package/src/cli/symbol-list.ts +23 -10
- package/src/cli/symbol-rows.ts +135 -3
- package/src/cli/treasury-yields.ts +15 -1
- package/src/components/chart/composite/composite-chart.tsx +3 -3
- package/src/components/chart/composite/format.ts +2 -1
- package/src/components/chart/composite/panel-surface/axis-markers.ts +133 -0
- package/src/components/chart/composite/panel-surface/level-labels.tsx +78 -0
- package/src/components/chart/composite/panel-surface/overlays.ts +108 -0
- package/src/components/chart/composite/panel-surface/pan-coast.ts +54 -0
- package/src/components/chart/composite/panel-surface/panel-cursor.tsx +138 -0
- package/src/components/chart/composite/panel-surface/panel-levels.ts +47 -0
- package/src/components/chart/composite/panel-surface/plot-gestures.ts +403 -0
- package/src/components/chart/composite/panel-surface/plot-pointer.ts +65 -0
- package/src/components/chart/composite/panel-surface/plot-wheel.ts +102 -0
- package/src/components/chart/composite/panel-surface/pointer.ts +12 -0
- package/src/components/chart/composite/panel-surface/props.ts +79 -0
- package/src/components/chart/composite/panel-surface/tool-readout.ts +151 -0
- package/src/components/chart/composite/panel-surface/value-axis-gestures.ts +152 -0
- package/src/components/chart/composite/panel-surface.tsx +81 -1177
- package/src/components/command-bar/commands/collection-list.ts +1 -0
- package/src/components/command-bar/commands/direct/index.ts +31 -8
- package/src/components/command-bar/commands/registry.ts +7 -0
- package/src/components/command-bar/routes/root/command-items.ts +8 -0
- package/src/components/command-bar/routes/root/results.ts +19 -2
- package/src/components/command-bar/routes/root/runtime.ts +3 -2
- package/src/components/command-bar/routes/root/selection.ts +3 -2
- package/src/components/command-bar/routes/root/shortcuts.ts +15 -0
- package/src/components/company-logo.tsx +10 -3
- package/src/components/data-table/sections.ts +6 -1
- package/src/components/layout/pane/title.ts +16 -6
- package/src/components/layout/shell/index.tsx +5 -1
- package/src/components/layout/shell/ticker-link-menu.ts +12 -9
- package/src/components/pane-settings-dialog/tui.tsx +6 -3
- package/src/components/pane-settings-dialog.tsx +2 -1
- package/src/components/pane-template-wizard.tsx +2 -0
- package/src/components/ticker/badge/format.ts +12 -3
- package/src/components/ticker/badge/index.tsx +9 -3
- package/src/components/ticker/list-table-view.tsx +119 -17
- package/src/components/ui/choice-dialog.tsx +1 -1
- package/src/components/ui/confirm-dialog.tsx +3 -2
- package/src/components/ui/data-table/display-columns.ts +16 -0
- package/src/components/ui/data-table/index.tsx +40 -9
- package/src/components/ui/data-table/types.ts +14 -0
- package/src/components/ui/frame.tsx +7 -3
- package/src/components/ui/icon.tsx +4 -2
- package/src/components/ui/list-view.tsx +8 -0
- package/src/components/ui/number-prompt-dialog.tsx +2 -1
- package/src/components/use-pane-notice-footer.tsx +3 -1
- package/src/core/state/app/layout-reducer.ts +3 -1
- package/src/core/state/app/layout.ts +2 -2
- package/src/data/config/layout.ts +14 -0
- package/src/data/config/store/normalize.ts +11 -1
- package/src/docs/snapshot.json +2 -2
- package/src/i18n/es.ts +39 -0
- package/src/i18n/ja.ts +39 -0
- package/src/i18n/ko.ts +39 -0
- package/src/i18n/zh-cn.ts +39 -0
- package/src/i18n/zh-tw.ts +39 -0
- package/src/layout/pane-follow.ts +141 -4
- package/src/layout/pane-layout-move.ts +10 -7
- package/src/layout/ticker-navigation.ts +13 -19
- package/src/layout/ticker-retarget.ts +3 -2
- package/src/market-data/market/format.ts +35 -1
- package/src/market-data/market/index-level.ts +19 -0
- package/src/market-data/quotes/contributions.ts +13 -0
- package/src/market-data/quotes/export-identity.ts +36 -1
- package/src/market-data/quotes/resolution.ts +16 -0
- package/src/plugins/builtin/account-management/keyboard.ts +14 -0
- package/src/plugins/builtin/account-management/model.ts +2 -0
- package/src/plugins/builtin/account-management/pane.tsx +79 -7
- package/src/plugins/builtin/account-management/password-dialog.tsx +2 -2
- package/src/plugins/builtin/account-management/payment-recovery-row.tsx +97 -0
- package/src/plugins/builtin/account-management/yearly-plan-row.tsx +359 -0
- package/src/plugins/builtin/analytics/risk-client.ts +12 -2
- package/src/plugins/builtin/analytics/risk-headless.ts +66 -6
- package/src/plugins/builtin/analytics/risk-math.ts +23 -6
- package/src/plugins/builtin/analytics/risk-model.ts +20 -9
- package/src/plugins/builtin/analytics/risk-pane.tsx +2 -2
- package/src/plugins/builtin/awards/pane.tsx +6 -8
- package/src/plugins/builtin/changelog/index.tsx +6 -44
- package/src/plugins/builtin/changelog/versions.ts +17 -68
- package/src/plugins/builtin/chart-composer/catalog-inventory.ts +5 -2
- package/src/plugins/builtin/chart-composer/editor.tsx +1 -0
- package/src/plugins/builtin/chart-composer/pane.tsx +1 -1
- package/src/plugins/builtin/chart-composer/quick-add.tsx +4 -1
- package/src/plugins/builtin/chart-composer/series-catalog.ts +17 -1
- package/src/plugins/builtin/cloud/askg/executor.ts +2 -1
- package/src/plugins/builtin/cloud/askg/sources.ts +2 -1
- package/src/plugins/builtin/cloud/plugin.tsx +2 -0
- package/src/plugins/builtin/cloud/thesis/module.tsx +2 -0
- package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +6 -2
- package/src/plugins/builtin/cpi/headless.ts +6 -1
- package/src/plugins/builtin/cpi/model.ts +17 -0
- package/src/plugins/builtin/cpi/pane.tsx +4 -2
- package/src/plugins/builtin/crypto-board/client.ts +6 -1
- package/src/plugins/builtin/crypto-board/headless.ts +10 -2
- package/src/plugins/builtin/crypto-board/model.ts +89 -11
- package/src/plugins/builtin/crypto-board/pane.tsx +20 -5
- package/src/plugins/builtin/debt-maturities/model.ts +1 -1
- package/src/plugins/builtin/dividend-yield/client.ts +24 -2
- package/src/plugins/builtin/dividend-yield/headless.ts +4 -2
- package/src/plugins/builtin/dividend-yield/ranking.ts +2 -1
- package/src/plugins/builtin/dividend-yield/view.ts +5 -1
- package/src/plugins/builtin/earnings/board-table.ts +1 -1
- package/src/plugins/builtin/earnings/board.tsx +36 -16
- package/src/plugins/builtin/earnings/highlight.ts +47 -0
- package/src/plugins/builtin/earnings/history-table.ts +9 -1
- package/src/plugins/builtin/earnings/index.tsx +1 -1
- package/src/plugins/builtin/earnings-calls/pane.tsx +2 -2
- package/src/plugins/builtin/earnings-ripple/index.tsx +2 -0
- package/src/plugins/builtin/econ/calendar-model.ts +17 -1
- package/src/plugins/builtin/econ/fred-catalog.ts +33 -4
- package/src/plugins/builtin/econ-statistics/headless.ts +21 -0
- package/src/plugins/builtin/estimate-revisions/model.ts +1 -1
- package/src/plugins/builtin/exposure/index.tsx +1 -1
- package/src/plugins/builtin/macro-day/headless.ts +21 -10
- package/src/plugins/builtin/macro-day/model.ts +42 -3
- package/src/plugins/builtin/macro-day/pane.tsx +26 -8
- package/src/plugins/builtin/macro-day/releases.ts +24 -1
- package/src/plugins/builtin/market-valuation/detail.tsx +3 -3
- package/src/plugins/builtin/market-valuation/headless.ts +11 -4
- package/src/plugins/builtin/market-valuation/pane.tsx +3 -1
- package/src/plugins/builtin/market-valuation/view.ts +14 -0
- package/src/plugins/builtin/money-markets/client.ts +4 -1
- package/src/plugins/builtin/money-markets/headless.ts +15 -4
- package/src/plugins/builtin/money-markets/index.tsx +1 -1
- package/src/plugins/builtin/money-markets/pane.tsx +7 -1
- package/src/plugins/builtin/news/wire/news/detail-view.tsx +20 -8
- package/src/plugins/builtin/pe-band/pane.tsx +1 -1
- package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +4 -2
- package/src/plugins/builtin/portfolio-list/cli/period-report.ts +61 -11
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +11 -3
- package/src/plugins/builtin/portfolio-list/cli/render.ts +8 -1
- package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +178 -17
- package/src/plugins/builtin/portfolio-list/headless.ts +33 -6
- package/src/plugins/builtin/portfolio-list/pane/groups.tsx +220 -0
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +95 -18
- package/src/plugins/builtin/portfolio-list/pane/period-pnl.ts +24 -6
- package/src/plugins/builtin/portfolio-list/period-pnl.ts +16 -1
- package/src/plugins/builtin/portfolio-list/summary/index.tsx +4 -1
- package/src/plugins/builtin/portfolio-list/summary/totals.ts +6 -4
- package/src/plugins/builtin/portfolio-list/table.tsx +38 -16
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +4 -2
- package/src/plugins/builtin/research/relative-valuation-headless.ts +15 -5
- package/src/plugins/builtin/research/relative-valuation-model.ts +7 -1
- package/src/plugins/builtin/research/relative-valuation-pane.tsx +7 -4
- package/src/plugins/builtin/shared/cloud-upgrade.ts +4 -2
- package/src/plugins/builtin/shared/cpi-year-gap.ts +67 -0
- package/src/plugins/builtin/shared/headless-options.ts +1 -1
- package/src/plugins/builtin/social-mentions/model.ts +2 -2
- package/src/plugins/builtin/thirteenf/pane.tsx +1 -1
- package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +45 -2
- package/src/plugins/builtin/ticker-detail/financials/model.ts +51 -16
- package/src/plugins/builtin/ticker-detail/financials/nopat.ts +16 -0
- package/src/plugins/builtin/ticker-detail/financials/ratios.ts +44 -13
- package/src/plugins/builtin/ticker-detail/financials/schema.ts +33 -2
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +4 -2
- package/src/plugins/builtin/ticker-detail/headless-schema.ts +30 -4
- package/src/plugins/builtin/ticker-detail/headless.ts +280 -35
- package/src/plugins/builtin/ticker-detail/overview/components.tsx +4 -5
- package/src/plugins/builtin/ticker-detail/overview/model.ts +9 -2
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +10 -2
- package/src/plugins/builtin/ticker-detail/pharma-signals/eligibility.ts +32 -0
- package/src/plugins/builtin/ticker-detail/pharma-signals/tab.tsx +162 -0
- package/src/plugins/builtin/ticker-detail/pharma-signals/waitlist.ts +126 -0
- package/src/plugins/builtin/ticker-detail/research-groups.ts +6 -4
- package/src/plugins/builtin/ticker-detail/research-tabs.ts +11 -0
- package/src/portfolio/collection-name.ts +2 -1
- package/src/portfolio/column-values.ts +34 -12
- package/src/portfolio/listed-symbol.ts +4 -2
- package/src/portfolio/period-pnl.ts +51 -1
- package/src/portfolio/suffixed-listings.ts +3 -1
- package/src/portfolio/watchlist-groups.ts +212 -0
- package/src/react/ticker-source.ts +3 -1
- package/src/renderers/dom/dialog-host.tsx +5 -5
- package/src/renderers/dom/styles.css +7 -0
- package/src/renderers/electrobun/view/remote/capability-invoker.ts +1 -1
- package/src/renderers/opentui/dialog-host.tsx +3 -4
- package/src/sources/gloomberb-cloud/normalizers.ts +5 -0
- package/src/sources/provider-router/history.ts +5 -2
- package/src/state/app/bootstrap.ts +11 -0
- package/src/state/app/context/index.tsx +6 -0
- package/src/sync/collections-contributor.ts +5 -2
- package/src/sync/config-merge.ts +10 -2
- package/src/sync/sanitize.ts +28 -0
- package/src/telemetry/usage-counts.ts +17 -0
- package/src/test-support/plugin-persistence.ts +12 -0
- package/src/tickers/company-name-listing.ts +4 -3
- package/src/tickers/company-name.ts +19 -1
- package/src/tickers/instrument-coverage.ts +27 -0
- package/src/tickers/search/home-listing.ts +38 -1
- package/src/tickers/search/index.ts +3 -2
- package/src/tickers/search/ranking.ts +21 -2
- package/src/time-series/base-series.ts +4 -0
- package/src/time-series/chart-seed.ts +1 -1
- package/src/time-series/financial-period-coverage.ts +4 -12
- package/src/time-series/parsed-history-cache.ts +1 -1
- package/src/time-series/resolve.ts +1 -1
- package/src/time-series/types.ts +5 -2
- package/src/time-series/use-chart-resolution.ts +6 -1
- package/src/types/config.ts +32 -0
- package/src/types/financials.ts +13 -0
- package/src/types/headless.ts +7 -0
- package/src/types/plugin-context.ts +5 -0
- package/src/types/ticker.ts +14 -0
- package/src/ui/ascii-font.ts +1 -4
- package/src/ui/dialog-stack.ts +17 -0
- package/src/ui/dialog.tsx +6 -2
- package/src/utils/async-deadline.ts +2 -2
- package/src/utils/crypto-pair.ts +9 -0
- package/src/utils/csv.ts +44 -5
- package/src/utils/exchanges.ts +13 -0
- package/src/utils/financial-statements.ts +60 -3
- package/src/utils/futures-generic.ts +17 -0
- package/src/utils/trailing-dividend.ts +13 -3
|
@@ -95,6 +95,33 @@ export function uncoveredInstrumentMessage(
|
|
|
95
95
|
return `${name} covers ${coveredNoun(covered)} only, and ${instrument.symbol} is ${instrumentKindNoun(instrument)}.`;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
/** "futures contracts", "ETFs", "indices": what several instruments of one kind are. */
|
|
99
|
+
function pluralNoun(noun: string): string {
|
|
100
|
+
const bare = noun.replace(/^an? /, "");
|
|
101
|
+
if (bare === "index") return "indices";
|
|
102
|
+
return bare.endsWith("y") ? `${bare.slice(0, -1)}ies` : `${bare}s`;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* What a list function says once of every entry outside what it covers, in
|
|
107
|
+
* place of a line each: "RIPL covers companies only, and leaves out ES=F, NQ1
|
|
108
|
+
* (futures contracts) and ES3:SGX (an ETF)."
|
|
109
|
+
*/
|
|
110
|
+
export function uncoveredInstrumentsMessage(
|
|
111
|
+
name: string,
|
|
112
|
+
covered: readonly TickerInstrumentKind[],
|
|
113
|
+
instruments: readonly InstrumentOfKind[],
|
|
114
|
+
): string {
|
|
115
|
+
const groups = new Map<string, string[]>();
|
|
116
|
+
for (const instrument of instruments) {
|
|
117
|
+
const noun = instrumentKindNoun(instrument);
|
|
118
|
+
groups.set(noun, [...groups.get(noun) ?? [], instrument.symbol]);
|
|
119
|
+
}
|
|
120
|
+
const parts = [...groups].map(([noun, symbols]) => `${symbols.join(", ")} (${symbols.length > 1 ? pluralNoun(noun) : noun})`);
|
|
121
|
+
const list = parts.length > 1 ? `${parts.slice(0, -1).join(", ")} and ${parts.at(-1)}` : parts[0] ?? "";
|
|
122
|
+
return `${name} covers ${coveredNoun(covered)} only, and leaves out ${list}.`;
|
|
123
|
+
}
|
|
124
|
+
|
|
98
125
|
/**
|
|
99
126
|
* What a ticker is without asking for its quote: an index, pair, future or
|
|
100
127
|
* coin by its symbol (^VIX, EURUSD=X), a fund by the type it was saved with
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { canonicalExchange, isUsListingExchange } from "../../utils/exchanges";
|
|
2
2
|
import { companyLines, companyNameExtraWords, companyNameMatch, namedByService, type CompanyLineFacts } from "../company-name";
|
|
3
|
-
import { answersOnlyByKeyword, getIssuerGroupKey, isPlaceholderLine, isQualifiedTickerQuery, normalizeTickerSymbol, readsAsUsTicker } from "./ranking";
|
|
3
|
+
import { answersOnlyByKeyword, classifyInstrumentKind, getIssuerGroupKey, isPlaceholderLine, isQualifiedTickerQuery, normalizeTickerSymbol, readsAsUsTicker } from "./ranking";
|
|
4
4
|
import type { TickerSearchCandidate } from "./types";
|
|
5
5
|
|
|
6
6
|
/** Venues that only quote shares listed elsewhere: the OTC tiers, Frankfurt's open market and Germany's regional exchanges. */
|
|
@@ -23,16 +23,53 @@ export function listingDistance(candidate: TickerSearchCandidate): 0 | 1 | 2 {
|
|
|
23
23
|
return lineDistance(candidate.instrumentType ?? "", candidateExchange(candidate), candidate.symbol);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/** B3's own codes: four letters and the class's number (PETR3, PETR4, BOVA11). */
|
|
27
|
+
const B3_CODE = /^[A-Z]{4}\d{1,2}$/i;
|
|
28
|
+
/** B3's odd-lot (fractional) line of a code: the code and F (PETR3F), which quotes the same shares in lots under 100. */
|
|
29
|
+
const B3_ODD_LOT = /^[A-Z]{4}\d{1,2}F$/i;
|
|
30
|
+
|
|
26
31
|
/** `listingDistance` of a line by its type, its canonical venue and its symbol. */
|
|
27
32
|
export function lineDistance(type: string, exchange: string, symbol: string): 0 | 1 | 2 {
|
|
28
33
|
if (RECEIPT_TYPE.test(type)) return 2;
|
|
29
34
|
// An index's code is its own (XU100 for the BIST 100), never a secondary line of shares.
|
|
30
35
|
if (/^\s*index\s*$/i.test(type)) return 0;
|
|
36
|
+
// B3's own codes mix letters and digits (PETR3); its odd-lot line quotes the same shares (PETR3F).
|
|
37
|
+
if (exchange === "B3" && (B3_CODE.test(symbol) || B3_ODD_LOT.test(symbol))) return B3_ODD_LOT.test(symbol) ? 1 : 0;
|
|
31
38
|
// A code mixing digits and letters is a secondary line (Milan's 4MSFT, London's 0R1I), except on SGX, whose
|
|
32
39
|
// own codes mix them (D05, 5E2).
|
|
33
40
|
return SECONDARY_VENUES.has(exchange) || exchange !== "SGX" && /\d/.test(symbol) && /[A-Za-z]/.test(symbol) ? 1 : 0;
|
|
34
41
|
}
|
|
35
42
|
|
|
43
|
+
/** A receipt's name without the words that say it is one: "Tracker Fund of Hong Kong DR" is the fund's name. */
|
|
44
|
+
const receiptFreeName = (name: string | null | undefined) => (name ?? "").toLowerCase()
|
|
45
|
+
.replace(/\b(?:adrs?|adss?|gdrs?|cdrs?|drs?|cedears?|(?:american |global )?depositary (?:receipts?|shares?))\b/g, " ")
|
|
46
|
+
.replace(/[^\p{L}\p{N}]+/gu, " ").trim();
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Whether a depositary receipt is one on a fund: search lists a fund under the
|
|
50
|
+
* receipt's name. The Thai receipt on the Tracker Fund of Hong Kong (HK01 on
|
|
51
|
+
* SET) is the fund's line, not a company's shares, so it ranks and is listed
|
|
52
|
+
* as the fund is, never as a company's primary listing over the fund itself
|
|
53
|
+
* (2800 on HKEX).
|
|
54
|
+
*/
|
|
55
|
+
export function isFundReceipt(
|
|
56
|
+
line: { type?: string | null; name?: string | null },
|
|
57
|
+
lines: readonly { type?: string | null; name?: string | null }[],
|
|
58
|
+
): boolean {
|
|
59
|
+
if (!RECEIPT_TYPE.test(line.type ?? "")) return false;
|
|
60
|
+
const name = receiptFreeName(line.name);
|
|
61
|
+
return !!name && lines.some((other) => other !== line && !RECEIPT_TYPE.test(other.type ?? "")
|
|
62
|
+
&& classifyInstrumentKind(other.type ?? "") === "fund" && receiptFreeName(other.name) === name);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Search's rows with each receipt on a fund (`isFundReceipt`) classed as the fund is. */
|
|
66
|
+
export function withFundReceiptsAsFunds<T extends TickerSearchCandidate>(items: T[]): T[] {
|
|
67
|
+
const lines = items.map((item) => item.result ?? {});
|
|
68
|
+
return items.map((item, index) => item.kind === "search" && item.instrumentClass !== "fund" && isFundReceipt(lines[index]!, lines)
|
|
69
|
+
? { ...item, instrumentClass: "fund" as const }
|
|
70
|
+
: item);
|
|
71
|
+
}
|
|
72
|
+
|
|
36
73
|
/** How the primary-listing choice weighs one of a company's lines. */
|
|
37
74
|
export interface WeighedCompanyLine {
|
|
38
75
|
/** `listingDistance`: 0 its own line, 1 a line quoting shares listed elsewhere, 2 a receipt. */
|
|
@@ -41,7 +41,7 @@ import { endsInLegalForm, readNearMissListing, readVenueFirstListing, readTermin
|
|
|
41
41
|
import { isProviderBusy, ProviderBusyError, SEARCH_BUSY_MESSAGE } from "../../sources/provider-errors";
|
|
42
42
|
import { settleWithin } from "../../utils/async-deadline";
|
|
43
43
|
import { companyNameExtraWords } from "../company-name";
|
|
44
|
-
import { withHomeListingLead, withNamedCompanyAfterUsLead } from "./home-listing";
|
|
44
|
+
import { withFundReceiptsAsFunds, withHomeListingLead, withNamedCompanyAfterUsLead } from "./home-listing";
|
|
45
45
|
import { answeredInFull, rememberSearchAnswer, withKnownListings } from "./listing-index";
|
|
46
46
|
import { savedAbroadForBareSymbol, savedUsListingOf } from "./bare-symbol";
|
|
47
47
|
import { delistingLabel, parseListingWithdrawal, withdrawalLabel } from "../../market-data/quotes/delisting";
|
|
@@ -361,7 +361,8 @@ export function buildTickerSearchCandidates({
|
|
|
361
361
|
createLocalTickerSearchCandidates(tickers.values(), providerHints.results, candidateOptions),
|
|
362
362
|
query,
|
|
363
363
|
);
|
|
364
|
-
|
|
364
|
+
// A receipt on a fund is the fund's line, never a company's primary listing over it (HK01 on SET for the Tracker Fund).
|
|
365
|
+
const providerItems = withFundReceiptsAsFunds(createProviderTickerSearchCandidates(filteredProviderResults, tickers, candidateOptions));
|
|
365
366
|
const ranked = withNamedCompanyAfterUsLead(
|
|
366
367
|
withHomeListingLead(withSuccessorFirst(rankTickerSearchItems([...localItems, ...providerItems], query), query), query),
|
|
367
368
|
query,
|
|
@@ -8,6 +8,7 @@ import { typedCoinPairListing } from "../../utils/crypto-pair";
|
|
|
8
8
|
import { canonicalExchange, exchangeCodeVenues, isUsListingExchange, parsePublicTickerKey, typedExchangeCode } from "../../utils/exchanges";
|
|
9
9
|
import { assetClassKeeps, assetClassMarketSymbol, instrumentClassCode, parseAssetClassQuery } from "./asset-classes";
|
|
10
10
|
import { futuresContractByCode } from "../../market-data/futures-board";
|
|
11
|
+
import { sameCompany } from "../company-name";
|
|
11
12
|
|
|
12
13
|
const FUND_TYPES = new Set(["ETF", "ETN", "ETP", "FUND", "MUTUALFUND", "CEF", "CLOSEDEND"]);
|
|
13
14
|
const DERIVATIVE_TYPES = new Set(["OPT", "OPTION", "OPTIONS", "FUT", "FUTURE", "FUTURES", "PERP", "PERPETUAL", "WARRANT", "WARRANTS", "RIGHT", "RIGHTS"]);
|
|
@@ -700,13 +701,31 @@ export function answersOnlyByKeyword(
|
|
|
700
701
|
* wants (an exchange or "ETF" beside the word).
|
|
701
702
|
*/
|
|
702
703
|
export function themeQueryWord(
|
|
703
|
-
items: ReadonlyArray<
|
|
704
|
+
items: ReadonlyArray<ThemeAnswerRow>,
|
|
704
705
|
query: string,
|
|
705
706
|
): string | null {
|
|
706
707
|
const intent = analyzeSearchQuery(query);
|
|
707
708
|
const word = intent.normalizedQuery;
|
|
708
709
|
if (!word || word.includes(" ") || intent.exchangeHints.length > 0 || intent.assetPreference != null) return null;
|
|
709
|
-
|
|
710
|
+
const tagged = (item: ThemeAnswerRow) => item.searchKeywords?.some((keyword) => normalizeSearchText(keyword) === word) ?? false;
|
|
711
|
+
if (!items.some(tagged)) return null;
|
|
712
|
+
return namesOneCompany(items.filter((item) => !tagged(item))) ? null : word;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
/** A row of an answer as `themeQueryWord` reads it: a search row (`name`) or a ranked row (`detail`, its name first). */
|
|
716
|
+
type ThemeAnswerRow = Pick<TickerSearchRankableItem, "searchKeywords" | "homeListing"> & { name?: string; detail?: string };
|
|
717
|
+
|
|
718
|
+
/**
|
|
719
|
+
* Whether most of the rows the service sent for a word by name are one
|
|
720
|
+
* company's lines, its home line among them: the word is that company's
|
|
721
|
+
* name, whatever rows it also tags ("Hermes" is Hermès International,
|
|
722
|
+
* though the service sends Federated Hermes's funds and holdings with the
|
|
723
|
+
* word). A sector word's rows are many companies' ("steel", "gaming").
|
|
724
|
+
*/
|
|
725
|
+
function namesOneCompany(rows: readonly ThemeAnswerRow[]): boolean {
|
|
726
|
+
const name = (row: ThemeAnswerRow) => row.name ?? row.detail?.split(" | ")[0] ?? "";
|
|
727
|
+
return rows.some((home) => home.homeListing === true
|
|
728
|
+
&& rows.filter((row) => sameCompany(name(row), name(home))).length * 2 > rows.length);
|
|
710
729
|
}
|
|
711
730
|
|
|
712
731
|
/** How many sector funds lead a sector word's list: the rest of the list is the companies named for it. */
|
|
@@ -164,6 +164,10 @@ export function baseSecuritySeries(
|
|
|
164
164
|
const volumeUnit = unknownBondBasis ? undefined
|
|
165
165
|
: assetKind === "equity" || instrumentKind === "equity" || instrumentKind === "fund" ? "shares" as const
|
|
166
166
|
: assetKind === "contract" || instrumentKind === "future" || instrumentKind === "option" ? "contracts" as const
|
|
167
|
+
// A coin's volume from Gloom Cloud, whose bars say what it counts (`aggregate`, `1 spot venue`), is the value
|
|
168
|
+
// traded in its quote currency, never a count of coins; another source's states no unit.
|
|
169
|
+
: (assetKind === "crypto" || instrumentKind === "crypto") && currency
|
|
170
|
+
&& (financials.priceHistory ?? []).some((point) => point.volumeBasis != null) ? currency
|
|
167
171
|
: undefined;
|
|
168
172
|
// An index has no volume of its own: sources sum its members' volume.
|
|
169
173
|
const volumeBasis = !volumeUnit && !unknownBondBasis && instrumentKind === "index" ? "index-members" as const : undefined;
|
|
@@ -85,7 +85,7 @@ export function seedChartResolutionResult(
|
|
|
85
85
|
const facts = readSeedListingFacts(seriesSpec.source.instrument);
|
|
86
86
|
const { symbol, exchange } = seriesSpec.source.instrument;
|
|
87
87
|
const bars = builtBarSize ? aggregatePriceBars(history, builtBarSize, { symbol, exchange }) : history;
|
|
88
|
-
const base = baseSecuritySeries(seriesSpec, emptyFinancials(bars), index, resolution, facts?.quoteMetadata, facts?.contractUnit);
|
|
88
|
+
const base = baseSecuritySeries(seriesSpec, emptyFinancials(bars), index, resolution, facts?.quoteMetadata ?? undefined, facts?.contractUnit);
|
|
89
89
|
const resolved = base && builtBarSize ? withBuiltBarSize(base, builtBarSize) : base;
|
|
90
90
|
if (!resolved?.points.length) return;
|
|
91
91
|
if (hidden) {
|
|
@@ -15,19 +15,11 @@ export function limitSeriesObservations(spec: ChartSpec, series: ResolvedSeries)
|
|
|
15
15
|
if (!isFinancialSeries(definition)) {
|
|
16
16
|
return { ...series, points: series.points.slice(-spec.viewport.maxPoints) };
|
|
17
17
|
}
|
|
18
|
+
// The latest N periods, a missing one among them, so `--periods 5` reads the last five fiscal years and never reaches
|
|
19
|
+
// back past a gap for older ones; the gap stays a point so a chart cannot draw through it, and the coverage counts
|
|
20
|
+
// how many of the N have a value.
|
|
18
21
|
const points = series.points.filter((point) => point.periodLabel !== "Current");
|
|
19
|
-
|
|
20
|
-
let start = points.length;
|
|
21
|
-
for (let index = points.length - 1; index >= 0; index--) {
|
|
22
|
-
if (!isUsableFinancialObservation(points[index]!)) continue;
|
|
23
|
-
start = index;
|
|
24
|
-
if (--remaining <= 0) break;
|
|
25
|
-
}
|
|
26
|
-
// Count usable observations, but retain missing periods within the selected
|
|
27
|
-
// history and at its end so charts cannot draw through absent financial data.
|
|
28
|
-
// If coverage is short, retain leading gaps too: they explain which requested
|
|
29
|
-
// periods failed, including the case where every observation is unavailable.
|
|
30
|
-
return { ...series, points: points.slice(remaining > 0 ? 0 : start) };
|
|
22
|
+
return { ...series, points: points.slice(-spec.viewport.maxPoints) };
|
|
31
23
|
}
|
|
32
24
|
|
|
33
25
|
export interface FinancialPeriodCoverage {
|
|
@@ -33,7 +33,7 @@ export function parsedPriceHistoryKey(
|
|
|
33
33
|
* moment later moves the plot and redraws every label.
|
|
34
34
|
*/
|
|
35
35
|
interface SeedListingFacts {
|
|
36
|
-
quoteMetadata?: QuoteMetadata;
|
|
36
|
+
quoteMetadata?: QuoteMetadata | null;
|
|
37
37
|
/** What a future's price counts ("USD / gallon"), so a seed states the unit the settled chart will. */
|
|
38
38
|
contractUnit?: string;
|
|
39
39
|
resolutionSupport?: ChartResolutionSupport[];
|
|
@@ -991,7 +991,7 @@ async function resolveChartSpecPass(
|
|
|
991
991
|
if (marketField) {
|
|
992
992
|
// Same precedence as baseSecuritySeries: the quote's own facts first.
|
|
993
993
|
const listingFacts = mergeQuoteMetadata(merged.quote ? quoteMetadataFromQuote(merged.quote) : undefined, quoteMetadata);
|
|
994
|
-
|
|
994
|
+
rememberSeedListingFacts(source.instrument, { quoteMetadata: listingFacts ?? null });
|
|
995
995
|
if (contractUnit) rememberSeedListingFacts(source.instrument, { contractUnit });
|
|
996
996
|
}
|
|
997
997
|
if (history) {
|
package/src/time-series/types.ts
CHANGED
|
@@ -249,8 +249,11 @@ export interface ResolvedSeries {
|
|
|
249
249
|
* never on decimal steps that read 104-25.60. Unset for decimal prices.
|
|
250
250
|
*/
|
|
251
251
|
tickGrid?: number;
|
|
252
|
-
/**
|
|
253
|
-
|
|
252
|
+
/**
|
|
253
|
+
* Volume basis established by the source instrument; omitted when unspecified. A coin's is the traded value in the
|
|
254
|
+
* currency its price is in (`USD`), as Gloom Cloud serves a coin's volume.
|
|
255
|
+
*/
|
|
256
|
+
volumeUnit?: "shares" | "contracts" | (string & {});
|
|
254
257
|
/**
|
|
255
258
|
* Set where the volume is the combined volume of an index's members. It has
|
|
256
259
|
* no unit of its own to state and nothing unknown to warn about; the volume
|
|
@@ -33,6 +33,7 @@ import { withFormulaNextMonths } from "./formula-months";
|
|
|
33
33
|
import {
|
|
34
34
|
parsedPriceHistoryKey,
|
|
35
35
|
readParsedHistoryResult,
|
|
36
|
+
readSeedListingFacts,
|
|
36
37
|
} from "./parsed-history-cache";
|
|
37
38
|
|
|
38
39
|
export interface UseChartResolutionResult extends ChartResolutionResult {
|
|
@@ -223,7 +224,11 @@ export function useChartResolution(
|
|
|
223
224
|
const now = sources.now ?? new Date();
|
|
224
225
|
// The first paint prices a formula's legs in one month as the settled chart does, from the next months it read.
|
|
225
226
|
const seedSpec = withFormulaNextMonths(spec);
|
|
226
|
-
|
|
227
|
+
const history = collectSeedHistory(seedSpec, now, options);
|
|
228
|
+
if (seedSpec.series.some(({ source }) => source.kind === "security"
|
|
229
|
+
&& history.has(chartQuoteOverrideKeyForSource(source))
|
|
230
|
+
&& readSeedListingFacts(source.instrument)?.quoteMetadata === undefined)) return null;
|
|
231
|
+
return seedChartResolutionResult(seedSpec, history, now, options);
|
|
227
232
|
};
|
|
228
233
|
const [state, setState] = useState(() => ({
|
|
229
234
|
key: specKey,
|
package/src/types/config.ts
CHANGED
|
@@ -103,6 +103,25 @@ export interface PaneInstanceConfig {
|
|
|
103
103
|
locked?: boolean;
|
|
104
104
|
/** Set by Move to New Layout and cleared by Move Back; never published. */
|
|
105
105
|
movedFrom?: PaneMovedFrom;
|
|
106
|
+
/** Set when a follower was pinned on its ticker; read only while it follows nothing. Never published. */
|
|
107
|
+
unlinkedFrom?: PaneUnlinkedFrom;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* The link a follower left when it was pinned on the ticker it showed. Its title says so
|
|
112
|
+
* (`AAPL ⧉ Unlinked`) until it is linked again.
|
|
113
|
+
*/
|
|
114
|
+
export interface PaneUnlinkedFrom {
|
|
115
|
+
/** The pane it followed. */
|
|
116
|
+
instanceId: string;
|
|
117
|
+
/** That pane's kind (`portfolio-list`), so a research pane can follow a new one of it. */
|
|
118
|
+
paneId?: string;
|
|
119
|
+
/**
|
|
120
|
+
* The app cut the link, not the user: the source closed or left the layout, or another
|
|
121
|
+
* research pane took it. A research pane pinned this way follows again once its source, or
|
|
122
|
+
* one of that kind, is in the layout with no research pane of its own (`relinkPinnedResearchPanes`).
|
|
123
|
+
*/
|
|
124
|
+
auto?: true;
|
|
106
125
|
}
|
|
107
126
|
|
|
108
127
|
interface DockPaneNode {
|
|
@@ -380,6 +399,13 @@ export interface AppConfig {
|
|
|
380
399
|
* are never shifted by it.
|
|
381
400
|
*/
|
|
382
401
|
timezone?: string;
|
|
402
|
+
/**
|
|
403
|
+
* The decimal mark CSV exports write numbers with, the CLI's and the app's:
|
|
404
|
+
* `comma` writes `17,2` with cells split by `;`, as a spreadsheet in a
|
|
405
|
+
* decimal-comma locale reads them. Absent is the dot. Text and JSON keep
|
|
406
|
+
* the dot. Kept on this machine only.
|
|
407
|
+
*/
|
|
408
|
+
csvDecimal?: "comma" | "dot";
|
|
383
409
|
/**
|
|
384
410
|
* Presentation mode: the panes fill the window, without the header or the
|
|
385
411
|
* status bar, for a screen that is shown rather than worked at. Absent is off.
|
|
@@ -390,6 +416,12 @@ export interface AppConfig {
|
|
|
390
416
|
* benchmark of this machine's time zone. Kept on this machine only.
|
|
391
417
|
*/
|
|
392
418
|
headerMarket?: HeaderMarketChoice;
|
|
419
|
+
/**
|
|
420
|
+
* The strip above the layout that says what moved in the user's portfolios
|
|
421
|
+
* and watchlists since their last visit. `false` turns it off; absent means
|
|
422
|
+
* on. Kept on this machine only.
|
|
423
|
+
*/
|
|
424
|
+
sinceLastVisit?: boolean;
|
|
393
425
|
}
|
|
394
426
|
|
|
395
427
|
/** A benchmark the header offers, by its id (`hang-seng`), or any listing the user searched for. */
|
package/src/types/financials.ts
CHANGED
|
@@ -211,6 +211,14 @@ export interface Quote extends DepositaryReceiptFacts {
|
|
|
211
211
|
* repeated the day's range, or reached zero): said beside it.
|
|
212
212
|
*/
|
|
213
213
|
yearRangeBasis?: "daily-bars";
|
|
214
|
+
/**
|
|
215
|
+
* What a coin's day range and volume measure, as the service says: the
|
|
216
|
+
* composite's across exchanges, or one exchange's own day (a real-time
|
|
217
|
+
* crypto feed's). Said beside each, so a source switch is never silent.
|
|
218
|
+
*/
|
|
219
|
+
statsBasis?: "composite" | "exchange";
|
|
220
|
+
/** The composite's day range was widened to take in `priceVenue`'s price, which fell outside it. */
|
|
221
|
+
rangeWidened?: boolean;
|
|
214
222
|
/**
|
|
215
223
|
* No live quote: the price is the close of the latest stored daily bar of
|
|
216
224
|
* `session` (an exchange-local date), said beside the price.
|
|
@@ -300,6 +308,11 @@ export interface Quote extends DepositaryReceiptFacts {
|
|
|
300
308
|
provenance?: QuoteProvenance;
|
|
301
309
|
/** Freshness class for the quote data. Provider identity lives in providerId/provenance. */
|
|
302
310
|
dataSource?: QuoteDataSource;
|
|
311
|
+
/**
|
|
312
|
+
* The spot exchange whose own last trade the price is (Coinbase, Kraken), on a coin's quote; absent on the
|
|
313
|
+
* composite price, which blends several exchanges. Sources name the quote by it (`quoteSourceName`).
|
|
314
|
+
*/
|
|
315
|
+
priceVenue?: string;
|
|
303
316
|
/**
|
|
304
317
|
* A perpetual contract's whole market row as of this quote (funding, open
|
|
305
318
|
* interest, premium), so every view of the contract reads the figures that
|
package/src/types/headless.ts
CHANGED
|
@@ -240,6 +240,11 @@ export interface HeadlessPaneColumn {
|
|
|
240
240
|
* screen; JSON keeps the row's figure whole.
|
|
241
241
|
*/
|
|
242
242
|
exportAsShown?: boolean;
|
|
243
|
+
/**
|
|
244
|
+
* A column the export gained after its others were set (RV's `Fwd P/E period`): CSV and NDJSON write it last,
|
|
245
|
+
* after the fixed columns and `retrieved_at`, so no column an earlier export had moves.
|
|
246
|
+
*/
|
|
247
|
+
exportLast?: boolean;
|
|
243
248
|
/**
|
|
244
249
|
* The text report prints the value on its own lines under the row instead
|
|
245
250
|
* of in a column, for a footnote that belongs to that row; an empty value
|
|
@@ -572,6 +577,8 @@ export interface HeadlessRowsResult extends HeadlessPaneResultBase {
|
|
|
572
577
|
rowAsOfKey?: string;
|
|
573
578
|
/** The interval every row is at (`daily`), which each exported row names in `interval`. */
|
|
574
579
|
interval?: string;
|
|
580
|
+
/** The currency or unit every row's figures are in (`GBP`, `index points`), which each exported row names in `currency_or_unit`. */
|
|
581
|
+
unit?: string;
|
|
575
582
|
/**
|
|
576
583
|
* Tables `--csv` and `--ndjson` write after the rows, each in its own
|
|
577
584
|
* section, such as the dated history the rows sum up. The text report and
|
|
@@ -53,6 +53,11 @@ export interface PinTickerOptions {
|
|
|
53
53
|
tabId?: string;
|
|
54
54
|
/** Merge this state into the resolved research pane when selecting `tabId`. */
|
|
55
55
|
tabState?: Record<string, unknown>;
|
|
56
|
+
/**
|
|
57
|
+
* A pinned pane of `paneType` that shows the ticker instead of a new one, when no pane shows
|
|
58
|
+
* it yet: Enter on a list row with no research pane of its own.
|
|
59
|
+
*/
|
|
60
|
+
reusePaneId?: string;
|
|
56
61
|
}
|
|
57
62
|
|
|
58
63
|
export interface GloomPluginContext {
|
package/src/types/ticker.ts
CHANGED
|
@@ -117,10 +117,24 @@ export interface PortfolioCash {
|
|
|
117
117
|
currency: string;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
+
/** A named section of a watchlist's tickers (`Watchlist.groups`). */
|
|
121
|
+
export interface WatchlistGroup {
|
|
122
|
+
name: string;
|
|
123
|
+
/** The tickers' keys (`TickerMetadata.ticker`); a ticker is in one group of a list at most. */
|
|
124
|
+
symbols: string[];
|
|
125
|
+
}
|
|
126
|
+
|
|
120
127
|
export interface Watchlist {
|
|
121
128
|
id: string;
|
|
122
129
|
name: string;
|
|
123
130
|
description?: string;
|
|
124
131
|
/** Set on watchlists shared with a team; the server holds the items. */
|
|
125
132
|
teamId?: string;
|
|
133
|
+
/**
|
|
134
|
+
* Sections the user put the list's tickers in, in the order they show; a
|
|
135
|
+
* ticker in none shows under Ungrouped. Kept on the list, not the ticker, so
|
|
136
|
+
* a ticker on two lists can sit in a different group on each. Absent on a
|
|
137
|
+
* list without groups, which shows and syncs as it did before groups.
|
|
138
|
+
*/
|
|
139
|
+
groups?: WatchlistGroup[];
|
|
126
140
|
}
|
package/src/ui/ascii-font.ts
CHANGED
|
@@ -72,10 +72,7 @@ const GLOOMBERB_WORDMARK = [
|
|
|
72
72
|
/** The first five letters of the wordmark above. */
|
|
73
73
|
const GLOOM_WORDMARK = GLOOMBERB_WORDMARK.map((line) => line.slice(0, 15));
|
|
74
74
|
|
|
75
|
-
/**
|
|
76
|
-
* The drawn wordmarks, by the text they spell. The app is Gloom; chart
|
|
77
|
-
* screenshots keep the Gloomberb watermark.
|
|
78
|
-
*/
|
|
75
|
+
/** The drawn wordmarks, by the text they spell. */
|
|
79
76
|
const WORDMARKS = new Map<string, string[]>([
|
|
80
77
|
["gloom", GLOOM_WORDMARK],
|
|
81
78
|
["gloomberb", GLOOMBERB_WORDMARK],
|
package/src/ui/dialog-stack.ts
CHANGED
|
@@ -9,6 +9,23 @@ import type { DialogApi, DialogOptions, PromptContext } from "./dialog";
|
|
|
9
9
|
|
|
10
10
|
export type DialogKind = "alert" | "prompt";
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* A click outside that closes a dialog only while nothing in it would be lost:
|
|
14
|
+
* the prompt takes `closeOnClickOutside`, its content reports `setClean`.
|
|
15
|
+
*/
|
|
16
|
+
export function clickOutsideWhileClean(): { closeOnClickOutside: () => boolean; setClean: (clean: boolean) => void } {
|
|
17
|
+
let clean = true;
|
|
18
|
+
return {
|
|
19
|
+
closeOnClickOutside: () => clean,
|
|
20
|
+
setClean: (next) => { clean = next; },
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Whether a click on the backdrop closes the dialog now. */
|
|
25
|
+
export function closesOnClickOutside(option: DialogOptions["closeOnClickOutside"]): boolean {
|
|
26
|
+
return typeof option === "function" ? option() : option === true;
|
|
27
|
+
}
|
|
28
|
+
|
|
12
29
|
interface DialogStackOptions<E extends { id: string }> {
|
|
13
30
|
idPrefix: string;
|
|
14
31
|
/** Builds the host's record. `stackWasEmpty` is true for the first dialog of a stack. */
|
package/src/ui/dialog.tsx
CHANGED
|
@@ -36,8 +36,12 @@ export interface DialogOptions<C = AlertContext> {
|
|
|
36
36
|
style?: DialogStyle;
|
|
37
37
|
/** Terminal: Esc closes the dialog unless this is false. The desktop always closes on Esc. */
|
|
38
38
|
closeOnEscape?: boolean;
|
|
39
|
-
/**
|
|
40
|
-
|
|
39
|
+
/**
|
|
40
|
+
* A click on the backdrop closes the dialog. Off by default. A function is
|
|
41
|
+
* asked at the click, for a dialog that closes so only while nothing in it
|
|
42
|
+
* would be lost.
|
|
43
|
+
*/
|
|
44
|
+
closeOnClickOutside?: boolean | (() => boolean);
|
|
41
45
|
/** Hosts ignore options they do not know. */
|
|
42
46
|
[key: string]: unknown;
|
|
43
47
|
}
|
|
@@ -53,8 +53,8 @@ export function abortable<T>(promise: Promise<T>, signal: AbortSignal | undefine
|
|
|
53
53
|
if (!signal) return promise;
|
|
54
54
|
return new Promise<T>((resolve, reject) => {
|
|
55
55
|
const abort = () => reject(abortError(message));
|
|
56
|
-
if (signal.aborted)
|
|
57
|
-
signal.addEventListener("abort", abort, { once: true });
|
|
56
|
+
if (signal.aborted) abort();
|
|
57
|
+
else signal.addEventListener("abort", abort, { once: true });
|
|
58
58
|
promise.then(resolve, reject).finally(() => signal.removeEventListener("abort", abort));
|
|
59
59
|
});
|
|
60
60
|
}
|
package/src/utils/crypto-pair.ts
CHANGED
|
@@ -39,6 +39,15 @@ export function isRoundTheClockCoin(symbol?: string, exchange?: string): boolean
|
|
|
39
39
|
return !!parsed && (isUsdCoinPair(parsed.symbol) || (!venue && isQuotedCoinPair(parsed.symbol)));
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* A message as a reader takes it: a coin named by its pair (USDT-USD), never with
|
|
44
|
+
* the crypto venue's internal code after it (USDT-USD:CCC). A credit rating's CCC,
|
|
45
|
+
* which no listing precedes, stays.
|
|
46
|
+
*/
|
|
47
|
+
export function withoutCryptoVenueCode(text: string): string {
|
|
48
|
+
return text.replace(/(\S):CCC\b/g, "$1");
|
|
49
|
+
}
|
|
50
|
+
|
|
42
51
|
const SLASH_COIN_PAIR = /^([A-Z0-9]{1,15})\/(USD|EUR|GBP|JPY|KRW|CAD|INR|CNY|AUD|USDT|USDC|BTC|ETH)$/;
|
|
43
52
|
|
|
44
53
|
/**
|
package/src/utils/csv.ts
CHANGED
|
@@ -23,22 +23,61 @@ function normalizeCsvCell(value: unknown): string {
|
|
|
23
23
|
return String(value);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
/**
|
|
27
|
+
* The decimal mark a CSV writes its numbers with. `comma` is what a
|
|
28
|
+
* spreadsheet set to a decimal-comma locale (German, French, Brazilian) reads
|
|
29
|
+
* as a number: `17,2`, never the date `17.2` becomes. Its cells are then
|
|
30
|
+
* separated by `;`, as those spreadsheets read them, so a decimal comma never
|
|
31
|
+
* splits a cell. Text, dates and JSON are never changed.
|
|
32
|
+
*/
|
|
33
|
+
export type CsvDecimal = "dot" | "comma";
|
|
34
|
+
|
|
35
|
+
let defaultDecimal: CsvDecimal = "dot";
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The decimal mark every CSV is written with unless the caller names one:
|
|
39
|
+
* the `csvDecimal` setting, or `--decimal` for one command. Null or absent is
|
|
40
|
+
* the dot.
|
|
41
|
+
*/
|
|
42
|
+
export function setCsvDecimal(decimal: CsvDecimal | null | undefined): void {
|
|
43
|
+
defaultDecimal = decimal === "comma" ? "comma" : "dot";
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The decimal mark CSVs are written with now (setCsvDecimal). */
|
|
47
|
+
export function csvDecimal(): CsvDecimal {
|
|
48
|
+
return defaultDecimal;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** The cell separator that goes with a decimal mark: `;` beside a decimal comma, `,` beside a dot. */
|
|
52
|
+
function csvSeparator(decimal: CsvDecimal = defaultDecimal): string {
|
|
53
|
+
return decimal === "comma" ? ";" : ",";
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** `1,234.5` and `-0.07%` as a decimal-comma spreadsheet reads them: `1234,5` and `-0,07%`. Other text stays. */
|
|
57
|
+
function withDecimalComma(text: string): string {
|
|
58
|
+
if (!isNumericCsvText(text)) return text;
|
|
59
|
+
return text.trim().replace(/,/g, "").replace(".", ",");
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function escapeCsvCell(value: unknown, excelCompatible: boolean, decimal: CsvDecimal): string {
|
|
27
63
|
const normalized = normalizeCsvCell(value);
|
|
28
64
|
// A signed number is data, not a formula: "-2.10" must stay a number.
|
|
29
|
-
const
|
|
65
|
+
const guarded = excelCompatible && FORMULA_START.test(normalized) && !isNumericCsvText(normalized)
|
|
30
66
|
? `'${normalized}`
|
|
31
67
|
: normalized;
|
|
32
|
-
|
|
68
|
+
const text = decimal === "comma" && (typeof value === "number" || typeof value === "string") ? withDecimalComma(guarded) : guarded;
|
|
69
|
+
const separator = csvSeparator(decimal);
|
|
70
|
+
if (!text.includes(separator) && !/["\n\r]/.test(text)) return text;
|
|
33
71
|
return `"${text.replace(/"/g, '""')}"`;
|
|
34
72
|
}
|
|
35
73
|
|
|
36
74
|
export function serializeCsv(
|
|
37
75
|
rows: readonly (readonly unknown[])[],
|
|
38
|
-
options: { excelCompatible?: boolean } = {},
|
|
76
|
+
options: { excelCompatible?: boolean; decimal?: CsvDecimal } = {},
|
|
39
77
|
): string {
|
|
40
78
|
const excelCompatible = options.excelCompatible === true;
|
|
41
|
-
const
|
|
79
|
+
const decimal = options.decimal ?? defaultDecimal;
|
|
80
|
+
const csv = rows.map((row) => row.map((cell) => escapeCsvCell(cell, excelCompatible, decimal)).join(csvSeparator(decimal))).join("\n");
|
|
42
81
|
return excelCompatible ? `${EXCEL_CSV_BOM}${csv}` : csv;
|
|
43
82
|
}
|
|
44
83
|
|
package/src/utils/exchanges.ts
CHANGED
|
@@ -260,6 +260,19 @@ export function displayTickerKey(key: string): string {
|
|
|
260
260
|
return isKnownExchangeCode(parsePublicTickerKey(key).exchange) ? canonicalTickerKey(key) : key;
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
+
/**
|
|
264
|
+
* A stored key as the listing a request names: a row saved under its venue's
|
|
265
|
+
* code (`ES3:XSES`, as a key is when another listing holds the bare symbol)
|
|
266
|
+
* is ES3 on SGX, as `D05` on SGX is D05 there. A key whose suffix names no
|
|
267
|
+
* venue (`FRED:DFII10`) is requested as stored, on the row's exchange.
|
|
268
|
+
*/
|
|
269
|
+
export function storedKeyListing(key: string, exchange?: string): { symbol: string; exchange: string } {
|
|
270
|
+
const parsed = parsePublicTickerKey(key);
|
|
271
|
+
return parsed.exchange && isKnownExchangeCode(parsed.exchange)
|
|
272
|
+
? { symbol: parsed.symbol, exchange: parsed.exchange }
|
|
273
|
+
: { symbol: key, exchange: exchange ?? "" };
|
|
274
|
+
}
|
|
275
|
+
|
|
263
276
|
export function publicTickerKey(symbol: string, exchange?: string): string {
|
|
264
277
|
const parsed = parsePublicTickerKey(symbol);
|
|
265
278
|
const publicValue = publicExchange(parsed.exchange ?? exchange);
|