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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RowWindowOptions } from "../row-window";
|
|
1
2
|
import { logFailure } from "../../utils/log-failure";
|
|
2
3
|
import type { PaneInstanceConfig } from "../../types/config";
|
|
3
4
|
import { CHART_COMPOSER_PANE_ID } from "../../types/config";
|
|
@@ -9,13 +10,14 @@ import type {
|
|
|
9
10
|
} from "../../types/plugin";
|
|
10
11
|
import { applyChartComposerCapabilityOptions } from "../../plugins/builtin/chart-composer/cli-options";
|
|
11
12
|
import { parseChartSpec } from "../../plugins/builtin/chart-composer/chart-spec";
|
|
13
|
+
import { CHART_COMPOSER_TEMPLATE_ID } from "../../plugins/builtin/chart-composer/catalog-inventory";
|
|
12
14
|
import { normalizeTickerInput } from "../../tickers/search";
|
|
13
15
|
import { slugifyName } from "../../utils/slugify";
|
|
14
16
|
import { fredSeriesArgument } from "../../series/fred-argument";
|
|
15
17
|
import {
|
|
16
18
|
type CliListing, listCoinNotes, ListingArgError, listingInstrument, listingReadNotes, MAX_CHOICE_LOOKUPS, resolveCliListing, usListingsOnlyMessage,
|
|
17
19
|
} from "../listing-arg";
|
|
18
|
-
import { uncoveredInstrumentKind, uncoveredInstrumentMessage } from "../../tickers/instrument-coverage";
|
|
20
|
+
import { uncoveredInstrumentKind, uncoveredInstrumentMessage, uncoveredInstrumentsMessage } from "../../tickers/instrument-coverage";
|
|
19
21
|
import { uncoveredInstrumentCommand } from "../uncovered-instrument";
|
|
20
22
|
import { listingAbroadVenue } from "../../utils/sec";
|
|
21
23
|
import { splitSymbolArgs, stripStrayEdges } from "../symbol-args";
|
|
@@ -27,7 +29,7 @@ import { readTerminalCodeArg } from "../../tickers/company-name-listing";
|
|
|
27
29
|
import { unknownBloombergMarket, unreadBloombergCode } from "../../tickers/terminal-codes";
|
|
28
30
|
import { notATickerWords } from "../company-name-hint";
|
|
29
31
|
import type { MarketContext } from "../types";
|
|
30
|
-
import {
|
|
32
|
+
import { shellWord } from "../../utils/shell-word";
|
|
31
33
|
import { readWatchlistArgument, watchlistMemberSymbol } from "../../portfolio/collection-name";
|
|
32
34
|
import {
|
|
33
35
|
buildPaneFunctionLookup,
|
|
@@ -78,6 +80,11 @@ export interface ResolvedPaneFunction {
|
|
|
78
80
|
optionSettings: Record<string, unknown>;
|
|
79
81
|
capability: PaneFunctionCapability;
|
|
80
82
|
options: NormalizedPaneFunctionOptions;
|
|
83
|
+
/**
|
|
84
|
+
* `--limit` and `--tail` of a report whose function takes no such option of its own: the rows the report keeps,
|
|
85
|
+
* as every command that prints a list keeps them (row-window).
|
|
86
|
+
*/
|
|
87
|
+
rowWindow?: RowWindowOptions;
|
|
81
88
|
/** `--section` of a report: the table `--csv` and `--ndjson` write, when the function has no `section` option of its own. */
|
|
82
89
|
tableSection?: string | true;
|
|
83
90
|
}
|
|
@@ -225,6 +232,8 @@ export async function applyListingArgument(
|
|
|
225
232
|
): Promise<ParsedPaneFunctionArgs> {
|
|
226
233
|
const found = args.target ? findPaneFunction(registry, args.target) : null;
|
|
227
234
|
if (!found?.pane || !args.arg) return args;
|
|
235
|
+
// G's series are text (`fn G AAPL MSFT` is two), but a quoted terminal code in them is one listing.
|
|
236
|
+
if (found.template?.id === CHART_COMPOSER_TEMPLATE_ID) return withChartTerminalCodes(args, context);
|
|
228
237
|
const headless = getHeadlessPaneDefinition(found.template, found.pane);
|
|
229
238
|
const kind = headless?.argument.kind ?? found.template?.shortcut?.argKind;
|
|
230
239
|
const takesOneTicker = kind === "ticker";
|
|
@@ -233,7 +242,7 @@ export async function applyListingArgument(
|
|
|
233
242
|
if (!(takesOneTicker || takesList) || getPaneFunctionCapability(found.template, found.pane).options.some((option) => option.key === "exchange")) {
|
|
234
243
|
return args;
|
|
235
244
|
}
|
|
236
|
-
// A watchlist's name stands for its symbols, as saved (`fn SIW HY3`).
|
|
245
|
+
// A watchlist's or a portfolio's name stands for its symbols, as saved (`fn SIW HY3`, `fn RIPL "Pension Book"`).
|
|
237
246
|
const watchlist = takesList ? await watchlistArgument(args.arg, context, headless?.argument.maximum) : null;
|
|
238
247
|
if (watchlist) args = { ...args, arg: watchlist.symbols.join(", ") };
|
|
239
248
|
// A function that reads FRED series (MDAY) gets FRED:T10Y2Y as typed; any other is told it is no listing.
|
|
@@ -299,7 +308,10 @@ export async function applyListingArgument(
|
|
|
299
308
|
if (listings.length === 0) {
|
|
300
309
|
throw new ListingArgError(answers.map((answer) => answer.message).join("\n"), answers.map((answer) => answer.details).join("\n"));
|
|
301
310
|
}
|
|
302
|
-
|
|
311
|
+
// Several are said in one line (a portfolio's futures and funds), each one's own command left out.
|
|
312
|
+
notes.push(...outside.length > 1
|
|
313
|
+
? [uncoveredInstrumentsMessage(token, covered, outside.map(({ instrument }) => instrument))]
|
|
314
|
+
: answers.map((answer) => `${answer.message} ${answer.details}`));
|
|
303
315
|
refused.push(...outside.map(({ listing }, index) => ({ symbol: listing.key, reason: answers[index]!.message })));
|
|
304
316
|
}
|
|
305
317
|
}
|
|
@@ -348,10 +360,39 @@ export async function applyListingArgument(
|
|
|
348
360
|
}
|
|
349
361
|
|
|
350
362
|
/**
|
|
351
|
-
*
|
|
352
|
-
*
|
|
353
|
-
*
|
|
354
|
-
*
|
|
363
|
+
* A chart's series typed in quotes that is a terminal's code for one listing
|
|
364
|
+
* (`fn G "VOD LN"`, `"MC FP Equity"`) is that listing, as `quote`, `history`,
|
|
365
|
+
* HP and GP read it, and says so: its words are not two series (VOD on NASDAQ
|
|
366
|
+
* and LN, a ticker that stopped trading in 2020). So is each such entry of a
|
|
367
|
+
* quoted list (`"VOD LN, MC FP"`). Words typed apart (`fn G AAPL MSFT`) are a
|
|
368
|
+
* series each, and a qualified symbol (VOD:LSE) is read as written.
|
|
369
|
+
*/
|
|
370
|
+
async function withChartTerminalCodes(args: ParsedPaneFunctionArgs, context: MarketContext): Promise<ParsedPaneFunctionArgs> {
|
|
371
|
+
if (!args.quotedWords) return args;
|
|
372
|
+
const notes: string[] = [];
|
|
373
|
+
const readEntry = async (entry: string) => {
|
|
374
|
+
const typed = entry.trim();
|
|
375
|
+
const code = /\s/.test(typed) ? await readTerminalCodeArg(context.dataProvider, typed) : null;
|
|
376
|
+
if (!code) return entry;
|
|
377
|
+
notes.push(`Read "${typed}" as ${code.key}.`);
|
|
378
|
+
return entry.replace(typed, code.key);
|
|
379
|
+
};
|
|
380
|
+
const words = await Promise.all(args.quotedWords.map(async (word) => /\s/.test(word.trim())
|
|
381
|
+
? (await Promise.all(word.split(/([;,\n])/).map((part, index) => index % 2 === 1 ? part : readEntry(part)))).join("")
|
|
382
|
+
: word));
|
|
383
|
+
if (notes.length === 0) return args;
|
|
384
|
+
return { ...args, arg: words.join(" ").trim(), listingNotes: [...args.listingNotes ?? [], ...notes] };
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* The symbols of the watchlist or portfolio a list argument names by its name
|
|
389
|
+
* (case aside), as saved, a portfolio's holdings being what it holds now, at
|
|
390
|
+
* most the function's `maximum` of them, with the note that says the name was
|
|
391
|
+
* read as that list (`readWatchlistArgument`). A list's id is no name: `main`
|
|
392
|
+
* is the default portfolio's id and a ticker too. Null when the argument names
|
|
393
|
+
* neither, or names an empty list a ticker could be named as (an empty
|
|
394
|
+
* watchlist named AI reads AI); an empty list's name of several words fails,
|
|
395
|
+
* saying so.
|
|
355
396
|
*/
|
|
356
397
|
async function watchlistArgument(
|
|
357
398
|
arg: string,
|
|
@@ -359,13 +400,24 @@ async function watchlistArgument(
|
|
|
359
400
|
maximum: number | undefined,
|
|
360
401
|
): Promise<{ symbols: string[]; notes: string[] } | null> {
|
|
361
402
|
if (/[,;\t\n]/.test(arg)) return null;
|
|
362
|
-
const
|
|
363
|
-
|
|
364
|
-
const
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
if (
|
|
368
|
-
const
|
|
403
|
+
const wanted = arg.trim().toLowerCase();
|
|
404
|
+
const named = <T extends { name: string }>(lists: readonly T[]) => lists.find((list) => list.name.trim().toLowerCase() === wanted) ?? null;
|
|
405
|
+
const watchlist = named(context.config.watchlists);
|
|
406
|
+
const portfolio = watchlist ? null : named(context.config.portfolios);
|
|
407
|
+
const list = watchlist ?? portfolio;
|
|
408
|
+
if (!list) return null;
|
|
409
|
+
const members = (await context.store.loadAllTickers()).filter((ticker) => watchlist
|
|
410
|
+
? ticker.metadata.watchlists.includes(watchlist.id)
|
|
411
|
+
: ticker.metadata.portfolios.includes(portfolio!.id)
|
|
412
|
+
|| ticker.metadata.positions.some((position) => position.portfolio === portfolio!.id && position.shares !== 0));
|
|
413
|
+
const symbols = [...new Set(members.map((ticker) => watchlistMemberSymbol(ticker.metadata)))];
|
|
414
|
+
const kind = watchlist ? "watchlist" : "portfolio";
|
|
415
|
+
if (symbols.length === 0) {
|
|
416
|
+
if (!/\s/.test(arg.trim())) return null;
|
|
417
|
+
throw new ListingArgError(`${kind === "watchlist" ? "Watchlist" : "Portfolio"} "${list.name}" is empty, so there is nothing to read.`,
|
|
418
|
+
`Add symbols with gloom ${kind} add ${shellWord(list.name)} AAPL, or type tickers.`);
|
|
419
|
+
}
|
|
420
|
+
const read = readWatchlistArgument(arg, list, symbols, maximum, kind);
|
|
369
421
|
return { symbols: read.symbols, notes: [read.note] };
|
|
370
422
|
}
|
|
371
423
|
|
|
@@ -464,6 +516,8 @@ export async function resolvePaneFunction(
|
|
|
464
516
|
resolutionSettings: {
|
|
465
517
|
strictHeadlessOptions?: boolean;
|
|
466
518
|
tableSection?: boolean;
|
|
519
|
+
/** `fn`: a `--limit` or `--tail` the function takes no option for picks the report's rows (`rowWindow`). */
|
|
520
|
+
rowWindow?: boolean;
|
|
467
521
|
command?: "fn" | "shot";
|
|
468
522
|
/** The plugins whose catalog series a name that opens nothing is pointed at. */
|
|
469
523
|
seriesSources?: readonly SeriesSource[];
|
|
@@ -487,6 +541,14 @@ export async function resolvePaneFunction(
|
|
|
487
541
|
throw new Error(`Template "${template?.id}" points at missing pane "${template?.paneId}".`);
|
|
488
542
|
}
|
|
489
543
|
const headless = getHeadlessPaneDefinition(template, pane);
|
|
544
|
+
// A report that reads a list for a pane that shows one ticker (FA, INS): a capture of the list is refused with
|
|
545
|
+
// both commands, rather than read as one ticker named by the whole list.
|
|
546
|
+
const asked = argumentSymbols(args.arg ?? "");
|
|
547
|
+
if (resolutionSettings.command === "shot" && headless?.argument.kind === "tickers" && template?.shortcut?.argKind === "ticker"
|
|
548
|
+
&& !template.opensTickerList && asked.length > 1) {
|
|
549
|
+
const code = paneFunctionCode(template, pane, registry);
|
|
550
|
+
throw new Error(`${code}'s pane shows one ticker: gloom shot ${code} ${asked[0]}. Its report reads all ${asked.length} in one table: gloom fn ${code} ${asked.join(" ")}`);
|
|
551
|
+
}
|
|
490
552
|
const createOptions = withTickerList(template, buildCreateOptions(template, args.arg), headless, args.arg, paneFunctionCode(template, pane, registry));
|
|
491
553
|
const capability = getPaneFunctionCapability(template, pane);
|
|
492
554
|
let tableSection: string | true | undefined;
|
|
@@ -508,6 +570,9 @@ export async function resolvePaneFunction(
|
|
|
508
570
|
if (bank) throw new UnknownPaneFunctionError(args.target, bank.details, null, bank.message);
|
|
509
571
|
throw new Error(noArgumentMessage(capability.options, token, args.arg, resolutionSettings.command ?? "fn"));
|
|
510
572
|
}
|
|
573
|
+
// `--limit` and `--tail` are global options: a report whose function has none of its own keeps the rows they say.
|
|
574
|
+
const rowWindow = resolutionSettings.rowWindow ? reportRowWindow(capability, args.options) : null;
|
|
575
|
+
if (rowWindow) args = { ...args, options: rowWindow.options };
|
|
511
576
|
const normalizedOptions = normalizeCapabilityOptions(capability, args.options, {
|
|
512
577
|
strict: args.requireBotSafe || capability.strictOptions === true || (!!headless && resolutionSettings.strictHeadlessOptions === true),
|
|
513
578
|
code: token,
|
|
@@ -534,12 +599,36 @@ export async function resolvePaneFunction(
|
|
|
534
599
|
optionSettings: settings,
|
|
535
600
|
capability,
|
|
536
601
|
options: normalizedOptions,
|
|
602
|
+
...(rowWindow ? { rowWindow: rowWindow.window } : {}),
|
|
537
603
|
...(tableSection !== undefined ? { tableSection } : {}),
|
|
538
604
|
};
|
|
539
605
|
resolved.instance = await buildPaneInstance(resolved, context, args.arg, resolutionSettings.command ?? "fn");
|
|
540
606
|
return resolved;
|
|
541
607
|
}
|
|
542
608
|
|
|
609
|
+
/**
|
|
610
|
+
* The `--limit` and `--tail` a function with no option of that name leaves to the report, taken out of its options;
|
|
611
|
+
* null when neither was given or the function reads both itself. A function with options of its own for them
|
|
612
|
+
* (DVD's `--limit`) checks and reads them there.
|
|
613
|
+
*/
|
|
614
|
+
function reportRowWindow(
|
|
615
|
+
capability: PaneFunctionCapability,
|
|
616
|
+
options: Record<string, string | true>,
|
|
617
|
+
): { window: RowWindowOptions; options: Record<string, string | true> } | null {
|
|
618
|
+
const window: RowWindowOptions = {};
|
|
619
|
+
const rest = { ...options };
|
|
620
|
+
for (const key of ["limit", "tail"] as const) {
|
|
621
|
+
const value = options[key];
|
|
622
|
+
if (value === undefined || capabilityHasOption(capability, key)) continue;
|
|
623
|
+
const count = Number(value);
|
|
624
|
+
if (value === true || !Number.isInteger(count) || count < 1) throw new Error(`--${key} must be a positive integer.`);
|
|
625
|
+
window[key] = count;
|
|
626
|
+
delete rest[key];
|
|
627
|
+
}
|
|
628
|
+
if (window.limit != null && window.tail != null) throw new Error("--limit and --tail each pick rows; give one of them.");
|
|
629
|
+
return window.limit != null || window.tail != null ? { window, options: rest } : null;
|
|
630
|
+
}
|
|
631
|
+
|
|
543
632
|
/**
|
|
544
633
|
* A one-ticker template whose pane also opens on a list (`opensTickerList`:
|
|
545
634
|
* DVD's ranking): the list is passed as `symbols`, so `shot` draws the same
|
|
@@ -201,6 +201,9 @@ export async function buildDesktopShotPayload(
|
|
|
201
201
|
if (isFinancialAnalysisFunction(resolved) && !initialPaneState.activeTabId) {
|
|
202
202
|
initialPaneState.activeTabId = "financials";
|
|
203
203
|
}
|
|
204
|
+
// A capture of a ratio tab shows each ratio's inputs (NOPAT, invested capital), as the report lists them; the
|
|
205
|
+
// pane opens them collapsed for a reader who opens the one they want.
|
|
206
|
+
if (shotRatioTab(resolved)) initialPaneState.financialRatiosExpanded = true;
|
|
204
207
|
// The pane opens on what the report found (13F: the fund a name resolved to, on its view's tab).
|
|
205
208
|
const opened = resolved.headless?.shotState
|
|
206
209
|
? await resolved.headless.shotState(
|
package/src/cli/report-tables.ts
CHANGED
|
@@ -82,6 +82,11 @@ export interface CliReportColumn<Row = Record<string, unknown>> {
|
|
|
82
82
|
unitColumn?: boolean;
|
|
83
83
|
/** CSV and NDJSON write the figure to the digits `format` draws (figureAsDrawn); JSON keeps it whole. */
|
|
84
84
|
exportAsShown?: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* A column the export gained after its others were set (RV's `Fwd P/E period`): it closes the row, after the
|
|
87
|
+
* fixed columns and `retrieved_at` (`appendedColumns`), so no column an earlier export had moves.
|
|
88
|
+
*/
|
|
89
|
+
exportLast?: boolean;
|
|
85
90
|
}
|
|
86
91
|
|
|
87
92
|
/** A label/value line of a report. `unit` names the unit of a numeric `value` when `formatted` cannot say it. */
|
|
@@ -111,6 +116,8 @@ interface ResolvedColumn {
|
|
|
111
116
|
unit?: string;
|
|
112
117
|
/** The unit always has a column of its own (`unitColumn`). */
|
|
113
118
|
unitColumn?: boolean;
|
|
119
|
+
/** The column closes the row after the fixed columns (`exportLast`). */
|
|
120
|
+
last?: boolean;
|
|
114
121
|
}
|
|
115
122
|
|
|
116
123
|
const BLANK = { kind: "blank" } as const;
|
|
@@ -397,7 +404,8 @@ function assembleTable(title: string, columns: readonly ResolvedColumn[], rowCou
|
|
|
397
404
|
const units = columns.map((column) => rowCount === 0 && column.unit != null ? new Set([column.unit]) : numberUnits(column.cells));
|
|
398
405
|
const mixed = units.map((columnUnits, index) => columnUnits.size > 1 || columns[index]!.unitColumn === true);
|
|
399
406
|
const byRow = mixed.some(Boolean) ? rowUnits(columns, mixed, rowCount) : null;
|
|
400
|
-
|
|
407
|
+
type LayoutColumn = { header: string; value: (row: number) => CliReportValue };
|
|
408
|
+
const columnLayout = (column: ResolvedColumn, index: number): LayoutColumn[] => {
|
|
401
409
|
const columnUnits = units[index]!;
|
|
402
410
|
const cell = (row: number) => cellValue(column.cells[row] ?? BLANK);
|
|
403
411
|
if (index === 0 && byRow) {
|
|
@@ -418,12 +426,18 @@ function assembleTable(title: string, columns: readonly ResolvedColumn[], rowCou
|
|
|
418
426
|
},
|
|
419
427
|
},
|
|
420
428
|
];
|
|
421
|
-
}
|
|
429
|
+
};
|
|
430
|
+
const layoutOf = new Map<ResolvedColumn, LayoutColumn[]>(columns.map((column, index) => [column, columnLayout(column, index)]));
|
|
431
|
+
const layout = columns.flatMap((column) => layoutOf.get(column)!);
|
|
422
432
|
if (status) layout.push({ header: status.header, value: (row: number) => status.values[row] ?? "" });
|
|
433
|
+
// A column the export gained later (`exportLast`) closes the row, after the status and the fixed columns.
|
|
434
|
+
const appended = columns.flatMap((column) => column.last ? layoutOf.get(column) ?? [] : []);
|
|
435
|
+
const ordered = [...layout.filter((entry) => !appended.includes(entry)), ...appended];
|
|
423
436
|
return {
|
|
424
437
|
title,
|
|
425
|
-
columns:
|
|
426
|
-
rows: Array.from({ length: rowCount }, (_, row) =>
|
|
438
|
+
columns: ordered.map((column) => column.header),
|
|
439
|
+
rows: Array.from({ length: rowCount }, (_, row) => ordered.map((column) => column.value(row))),
|
|
440
|
+
...appended.length > 0 ? { appendedColumns: appended.length } : {},
|
|
427
441
|
};
|
|
428
442
|
}
|
|
429
443
|
|
|
@@ -566,7 +580,8 @@ export function exportRowsTable<Row extends Record<string, unknown>>(
|
|
|
566
580
|
};
|
|
567
581
|
const unit = units[columnIndex];
|
|
568
582
|
const withUnit = unit == null ? table : { ...table, unit };
|
|
569
|
-
|
|
583
|
+
const last = column.exportLast ? { ...withUnit, last: true } : withUnit;
|
|
584
|
+
return column.unitColumn && column.unitKey && !inRowUnit ? { ...last, unitColumn: true } : last;
|
|
570
585
|
});
|
|
571
586
|
const statusColumn = withStatus ? {
|
|
572
587
|
header: columns.some((column) => column.header.trim().toLowerCase() === "status") ? "value_status" : "status",
|
package/src/cli/result.ts
CHANGED
|
@@ -156,6 +156,12 @@ export interface CliResultRenderOptions<T = unknown, Row = Record<string, unknow
|
|
|
156
156
|
* without a reason here, named as `<header>: not available`.
|
|
157
157
|
*/
|
|
158
158
|
exportStatus?: (row: Row) => string | null | undefined;
|
|
159
|
+
/**
|
|
160
|
+
* Row fields a report gained after its columns were set: CSV writes them
|
|
161
|
+
* last, after `retrieved_at`, and NDJSON ends each row with them, so no
|
|
162
|
+
* column an earlier export had moves.
|
|
163
|
+
*/
|
|
164
|
+
exportAppendedKeys?: readonly string[];
|
|
159
165
|
}
|
|
160
166
|
|
|
161
167
|
interface CliResultJsonEnvelope<T> extends Omit<CliResult<T>, "freshness" | "exportFreshness" | "failure"> {
|
|
@@ -378,11 +384,16 @@ function renderCsv<Row extends Record<string, unknown>>(
|
|
|
378
384
|
dating?: (row: Row) => string[],
|
|
379
385
|
/** When the data was retrieved, which an undated export's rows end with (`retrieved_at`). */
|
|
380
386
|
retrieved?: string,
|
|
387
|
+
/** Keys written after every other column (`exportAppendedKeys`), in this order. */
|
|
388
|
+
appendedKeys: readonly string[] = [],
|
|
381
389
|
): string {
|
|
382
|
-
const
|
|
390
|
+
const allColumns = columns && columns.length > 0
|
|
383
391
|
? columns
|
|
384
392
|
: inferColumns(rows as Record<string, unknown>[]) as CliResultColumn<Row>[];
|
|
393
|
+
const resolvedColumns = allColumns.filter((column) => !appendedKeys.includes(column.key));
|
|
394
|
+
const appended = appendedKeys.flatMap((key) => allColumns.filter((column) => column.key === key));
|
|
385
395
|
const headers = resolvedColumns.map((column) => column.header);
|
|
396
|
+
const cell = (value: unknown) => isNonFiniteNumber(value) ? "" : typeof value === "number" ? exportNumber(value) : value;
|
|
386
397
|
// A dated export's own `released` column keeps its values; the others close the row.
|
|
387
398
|
const datingAdded = dating
|
|
388
399
|
? EXPORT_DATING_COLUMNS.flatMap((column, index) => headers.includes(column) ? [] : [index]) : [];
|
|
@@ -394,17 +405,19 @@ function renderCsv<Row extends Record<string, unknown>>(
|
|
|
394
405
|
...identity ? EXPORT_IDENTITY_COLUMNS : [],
|
|
395
406
|
...datingAdded.map((index) => EXPORT_DATING_COLUMNS[index]!),
|
|
396
407
|
...retrieval ? [EXPORT_RETRIEVAL_COLUMN] : [],
|
|
408
|
+
...appended.map((column) => column.header),
|
|
397
409
|
],
|
|
398
410
|
...rows.map((row) => {
|
|
399
411
|
const values = resolvedColumns.map((column) => (column.value ? column.value(row) : row[column.key]));
|
|
400
412
|
const blanked = resolvedColumns.flatMap((column, index) => isNonFiniteNumber(values[index]) ? [column.header] : []);
|
|
401
413
|
const datingCells = dating?.(row) ?? [];
|
|
402
414
|
return [
|
|
403
|
-
...values.map(
|
|
415
|
+
...values.map(cell),
|
|
404
416
|
...status ? [exportStatusText(status(row), blanked)] : [],
|
|
405
417
|
...identity?.(row) ?? [],
|
|
406
418
|
...datingAdded.map((index) => datingCells[index] ?? ""),
|
|
407
419
|
...retrieval ? [retrieved] : [],
|
|
420
|
+
...appended.map((column) => cell(column.value ? column.value(row) : row[column.key])),
|
|
408
421
|
];
|
|
409
422
|
}),
|
|
410
423
|
]);
|
|
@@ -587,13 +600,17 @@ function serializeCliRows<T, Row extends Record<string, unknown>>(
|
|
|
587
600
|
// An undated row says when it was retrieved last, as CSV's `retrieved_at` does.
|
|
588
601
|
const retrieval = !renderOptions.exportDated && !(EXPORT_RETRIEVAL_COLUMN in fields)
|
|
589
602
|
? { [EXPORT_RETRIEVAL_COLUMN]: exportRetrievalCell(cited) } : {};
|
|
590
|
-
|
|
603
|
+
// Fields a report gained later end the row, as they end a CSV row.
|
|
604
|
+
const appended = Object.fromEntries((renderOptions.exportAppendedKeys ?? []).flatMap((key) => key in fields ? [[key, fields[key]]] : []));
|
|
605
|
+
const own = Object.fromEntries(Object.entries(fields).filter(([key]) => !(key in appended)));
|
|
606
|
+
return JSON.stringify({ ...own, ...exportIdentityFields(cited, identity), ...dating, ...retrieval, ...appended }, exportJsonValue);
|
|
591
607
|
}).join("\n");
|
|
592
608
|
}
|
|
593
609
|
if (options.format === "csv") {
|
|
594
610
|
// The rows a window cut say so after them, as text and JSON do: a script has no other way to know.
|
|
595
611
|
const cutNote = window.note ? [`note: ${window.note}`] : [];
|
|
596
|
-
|
|
612
|
+
const appended = renderOptions.exportAppendedKeys ?? [];
|
|
613
|
+
if (!cited) return withCsvFooter(renderCsv(rows as Row[], renderOptions.columns, undefined, status, undefined, undefined, appended), cutNote);
|
|
597
614
|
const csv = renderCsv(
|
|
598
615
|
rows as Row[],
|
|
599
616
|
renderOptions.columns,
|
|
@@ -601,6 +618,7 @@ function serializeCliRows<T, Row extends Record<string, unknown>>(
|
|
|
601
618
|
status,
|
|
602
619
|
renderOptions.exportDated ? (row) => exportDatingCells(cited, rowIdentity(row, renderOptions.exportIdentity)) : undefined,
|
|
603
620
|
exportRetrievalCell(cited),
|
|
621
|
+
appended,
|
|
604
622
|
);
|
|
605
623
|
return withCsvFooter(csv, [...exportSourceLines(cited), ...cutNote, ...(renderOptions.exportNotes ?? []).map((note) => `note: ${note}`)]);
|
|
606
624
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { mkdtemp, rm } from "fs/promises";
|
|
2
|
+
import { tmpdir } from "os";
|
|
3
|
+
import { join } from "path";
|
|
4
|
+
import { logFailure } from "../utils/log-failure";
|
|
5
|
+
|
|
6
|
+
type RemoveFolder = (
|
|
7
|
+
path: string,
|
|
8
|
+
options: { recursive: true; force: true; maxRetries: number; retryDelay: number },
|
|
9
|
+
) => Promise<void>;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Hands `use` a fresh folder under the system temp folder and removes it
|
|
13
|
+
* afterwards. Removal is best effort: on Windows Chrome's helper processes can
|
|
14
|
+
* hold files in its profile for a moment after the browser exits, so the
|
|
15
|
+
* removal retries and, if the folder is still locked, leaves it behind rather
|
|
16
|
+
* than replacing what `use` returned (or threw) with the lock error.
|
|
17
|
+
*/
|
|
18
|
+
export async function withShotTempDir<T>(
|
|
19
|
+
prefix: string,
|
|
20
|
+
use: (dir: string) => Promise<T>,
|
|
21
|
+
remove: RemoveFolder = rm,
|
|
22
|
+
): Promise<T> {
|
|
23
|
+
const dir = await mkdtemp(join(tmpdir(), prefix));
|
|
24
|
+
try {
|
|
25
|
+
return await use(dir);
|
|
26
|
+
} finally {
|
|
27
|
+
await remove(dir, { recursive: true, force: true, maxRetries: 5, retryDelay: 200 })
|
|
28
|
+
.catch(logFailure("cli.screenshot", "Could not remove a capture's temporary folder"));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { saveConfig } from "../data/config/store";
|
|
2
2
|
import { mergeSavedSuffixedListings } from "../portfolio/suffixed-listings";
|
|
3
|
+
import { withoutStaleWatchlistGroupSymbols } from "../portfolio/watchlist-groups";
|
|
3
4
|
import type { CliCommandContext } from "../types/plugin";
|
|
4
5
|
import { debugLog } from "../utils/debug-log";
|
|
5
6
|
import { logFailure } from "../utils/log-failure";
|
|
@@ -29,6 +30,16 @@ async function mergedForWrite<TContext extends ConfigContext>(ctx: Pick<CliComma
|
|
|
29
30
|
} catch (error) {
|
|
30
31
|
logFailure("cli.suffixed-listings", "Merging suffixed listing rows failed")(error);
|
|
31
32
|
}
|
|
33
|
+
// A ticker that left a list some other way leaves its groups too, so an add puts it in none.
|
|
34
|
+
try {
|
|
35
|
+
const ungrouped = withoutStaleWatchlistGroupSymbols(context.config, await context.store.loadAllTickers());
|
|
36
|
+
if (ungrouped !== context.config) {
|
|
37
|
+
await saveConfig(ungrouped);
|
|
38
|
+
context.config = ungrouped;
|
|
39
|
+
}
|
|
40
|
+
} catch (error) {
|
|
41
|
+
logFailure("cli.suffixed-listings", "Dropping stale watchlist group symbols failed")(error);
|
|
42
|
+
}
|
|
32
43
|
return context;
|
|
33
44
|
}
|
|
34
45
|
|
package/src/cli/symbol-args.ts
CHANGED
|
@@ -136,10 +136,12 @@ export function symbolInputKey(symbol: string): string {
|
|
|
136
136
|
|
|
137
137
|
/**
|
|
138
138
|
* How a command's symbol list spots one security typed twice: `symbolInputKey`,
|
|
139
|
-
* with a share class written with a dot
|
|
139
|
+
* with a share class written with a dot, a dash or, as a broker writes it, a
|
|
140
|
+
* slash as one (BRK.B, BRK-B and BRK/B). One letter before a slash is no
|
|
141
|
+
* symbol's (N/A, P/E).
|
|
140
142
|
*/
|
|
141
|
-
function securityInputKey(symbol: string): string {
|
|
142
|
-
return symbolInputKey(symbol).replace(/-/g, ".");
|
|
143
|
+
export function securityInputKey(symbol: string): string {
|
|
144
|
+
return symbolInputKey(symbol).replace(/-/g, ".").replace(/^([A-Z]{2,5})\/([A-Z])$/, "$1.$2");
|
|
143
145
|
}
|
|
144
146
|
|
|
145
147
|
/** The securities of a symbol list, each once, in the first spelling typed: `AAPL aapl BRK.B BRK-B` is AAPL and BRK.B. */
|
package/src/cli/symbol-list.ts
CHANGED
|
@@ -221,6 +221,8 @@ interface SymbolText {
|
|
|
221
221
|
entries?: true;
|
|
222
222
|
/** A first row read as a header in words no header list knows (`Hisse,Adet,Maliyet`), skipped and named. */
|
|
223
223
|
header?: string[];
|
|
224
|
+
/** Each symbol is a line of the text, whole: a list of one entry a line, as a sheet's column pastes. */
|
|
225
|
+
lines?: true;
|
|
224
226
|
}
|
|
225
227
|
|
|
226
228
|
/** Words a sheet writes where a value is missing, beside the marks isJunkCell knows (`N/A`, `-`, `—`). */
|
|
@@ -296,7 +298,7 @@ export function parseSymbolText(text: string): SymbolText {
|
|
|
296
298
|
const cleaned = records.map((cells) => cells.map((cell) => stripStrayEdges(cell).text));
|
|
297
299
|
const figures = cleaned.some((cells) => cells.some((cell, index) => index > 0 && isFigure(cell)));
|
|
298
300
|
// Lines split by spaces alone are entries, unless figures sit beside the symbols.
|
|
299
|
-
if (!delimited && !figures) return { symbols: records.map((cells) => cells.join(" ")), ignored: [], entries: true };
|
|
301
|
+
if (!delimited && !figures) return { symbols: records.map((cells) => cells.join(" ")), ignored: [], entries: true, lines: true };
|
|
300
302
|
// A grid of symbols: a terminal's code is one cell (`CZR US Equity`), and so is a numeric code among tickers (`2007`).
|
|
301
303
|
const codes = symbolColumns(cleaned);
|
|
302
304
|
const grid = numericCodeGrid(cleaned) || cleaned.every((cells) => cells.every((cell, index) => (
|
|
@@ -479,13 +481,15 @@ export async function readSymbolList(source: SymbolListSource): Promise<{ symbol
|
|
|
479
481
|
const code = (error as NodeJS.ErrnoException).code;
|
|
480
482
|
throw new SymbolListError(code === "ENOENT" ? `No file at ${source.file}.` : `Could not read ${source.file}: ${error instanceof Error ? error.message : String(error)}`);
|
|
481
483
|
}
|
|
482
|
-
|
|
483
|
-
|
|
484
|
+
const parsed = parseSymbolText(foldTypedText(text));
|
|
485
|
+
typedForms.push(...typedLines(text, !!parsed.lines));
|
|
486
|
+
await addCells(parsed);
|
|
484
487
|
}
|
|
485
488
|
if (wantsStdin || (typed.length === 0 && source.file == null && (source.stdinPiped ?? stdinIsPiped()))) {
|
|
486
489
|
const text = await readStdin();
|
|
487
|
-
|
|
488
|
-
|
|
490
|
+
const parsed = parseSymbolText(foldTypedText(text));
|
|
491
|
+
typedForms.push(...typedLines(text, !!parsed.lines));
|
|
492
|
+
await addCells(parsed);
|
|
489
493
|
}
|
|
490
494
|
// A number where a symbol goes (a line of prices, a typed 1.899) is left out with those typed beside a symbol.
|
|
491
495
|
const numbers = [...figures, ...collected.filter(isNumberCell)];
|
|
@@ -498,17 +502,26 @@ export interface TypedForm {
|
|
|
498
502
|
typed: string;
|
|
499
503
|
/** The entry the line reads as, its repeats' key (`symbolInputKey`): `USDJPY` and `usdjpy` are both `USDJPY`'s. */
|
|
500
504
|
key: string;
|
|
505
|
+
/**
|
|
506
|
+
* A line of a list of one entry a line, which has a row whatever it reads as, so the rows line up with the
|
|
507
|
+
* sheet's: a blank one (`typed` empty), or one no entry was read from (`N/A`, a number).
|
|
508
|
+
*/
|
|
509
|
+
ownRow?: true;
|
|
501
510
|
}
|
|
502
511
|
|
|
503
512
|
/**
|
|
504
513
|
* Each line of a list's text that is one entry, as typed and in order, an exact repeat too, with the key of the entry
|
|
505
514
|
* it reads as: so a command can give every line its row and say which line of a sheet each row is, where several
|
|
506
|
-
* were read as one entry.
|
|
515
|
+
* were read as one entry. In a list of one entry a line (`everyLine`), every line up to the last that holds
|
|
516
|
+
* anything is one, a blank line too; a comment (`# held since 2019`) is none.
|
|
507
517
|
*/
|
|
508
|
-
function typedLines(text: string): TypedForm[] {
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
518
|
+
function typedLines(text: string, everyLine: boolean): TypedForm[] {
|
|
519
|
+
const lines = text.replace(/^\uFEFF/, "").split(/\r?\n/).map((line) => line.trim());
|
|
520
|
+
const last = lines.findLastIndex(Boolean);
|
|
521
|
+
return lines.slice(0, last + 1).flatMap((typed) => {
|
|
522
|
+
// The list reads a line's words with one space between them (`MC FP Equity` is MC FP Equity), so its key does too.
|
|
523
|
+
const key = symbolInputKey(stripStrayEdges(foldTypedText(typed)).text.replace(/\s+/g, " "));
|
|
524
|
+
if (everyLine && !isComment(typed)) return [{ typed, key, ownRow: true as const }];
|
|
512
525
|
if (!typed || !key) return [];
|
|
513
526
|
return [{ typed, key }];
|
|
514
527
|
});
|