gloomberb 0.19.6 → 0.20.1
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/LICENSE +0 -4
- package/package.json +6 -5
- package/patches/electrobun-devkit@2.0.5.patch +408 -0
- package/src/api-client/bond-trades.ts +59 -0
- package/src/api-client/crypto-markets.ts +20 -2
- package/src/api-client/data.ts +21 -0
- package/src/api-client/fund-facts.ts +23 -1
- package/src/api-client/index.ts +2 -0
- package/src/api-client/types/account.ts +86 -0
- package/src/api-client/types/assist.ts +32 -0
- package/src/api-client/types/auth.ts +63 -0
- package/src/api-client/types/billing.ts +54 -0
- package/src/api-client/types/chat.ts +180 -0
- package/src/api-client/types/congress.ts +107 -0
- package/src/api-client/types/credit.ts +110 -0
- package/src/api-client/types/econ.ts +158 -0
- package/src/api-client/types/equity-diagnostic.ts +73 -0
- package/src/api-client/types/filings-and-calls.ts +356 -0
- package/src/api-client/types/index.ts +25 -0
- package/src/api-client/types/jobs.ts +147 -0
- package/src/api-client/types/market.ts +122 -0
- package/src/api-client/types/news.ts +91 -0
- package/src/api-client/types/notes-and-theses.ts +172 -0
- package/src/api-client/types/quotes.ts +28 -0
- package/src/api-client/types/scanners.ts +125 -0
- package/src/api-client/types/screener.ts +65 -0
- package/src/api-client/types/search.ts +107 -0
- package/src/api-client/types/sync.ts +14 -0
- package/src/api-client/types/team-collections.ts +43 -0
- package/src/api-client/types/team-views.ts +32 -0
- package/src/api-client/types/teams.ts +135 -0
- package/src/api-client/types/ticker-data.ts +57 -0
- package/src/api-client/types/tweets.ts +59 -0
- package/src/api-client/types/world-venues.ts +23 -0
- package/src/app/runtime/desktop-deeplink.ts +41 -6
- package/src/app/runtime/plugin-seed.ts +119 -0
- package/src/app/runtime/startup.ts +45 -9
- package/src/app/star-prompt/status-line.tsx +1 -1
- package/src/app.tsx +2 -7
- package/src/architecture/ui-tokens-allowlist.json +0 -8
- package/src/cli/board-coins.ts +38 -5
- package/src/cli/commands/crypto-hints.ts +8 -1
- package/src/cli/commands/market.ts +29 -26
- package/src/cli/commands/overview.ts +13 -6
- package/src/cli/commands/ticker.ts +78 -18
- package/src/cli/company-name-hint.ts +19 -0
- package/src/cli/desktop-pane-shot-browser.ts +69 -3
- package/src/cli/entry.ts +10 -4
- package/src/cli/glossary.ts +25 -0
- package/src/cli/helpers.ts +4 -2
- package/src/cli/not-a-ticker.ts +26 -1
- package/src/cli/pane-functions/catalog.ts +3 -1
- package/src/cli/pane-functions/freshness.ts +45 -29
- package/src/cli/pane-functions/market-session.ts +14 -5
- package/src/cli/restore-plugins.ts +164 -51
- package/src/components/chart/composite/use-composite-chart-keyboard.ts +11 -2
- package/src/components/chart-table/header.tsx +10 -1
- package/src/components/chart-table/layout.ts +14 -5
- package/src/components/command-bar/panel/index.tsx +13 -0
- package/src/components/command-bar/panel/layout.ts +7 -0
- package/src/components/command-bar/panel/runtime.ts +1 -0
- package/src/components/command-bar/panel/types.ts +2 -0
- package/src/components/data-table/export.ts +4 -1
- package/src/components/layout/detached-pane-shell.tsx +10 -37
- package/src/components/layout/double-escape-close.ts +90 -0
- package/src/components/layout/header.tsx +3 -2
- package/src/components/layout/market-summary.ts +6 -3
- package/src/components/layout/pane/footer/index.tsx +2 -6
- package/src/components/layout/pane/footer/model.ts +6 -12
- package/src/components/layout/shell/active-drag.ts +53 -11
- package/src/components/layout/shell/drag/magnets.ts +128 -19
- package/src/components/layout/shell/pane/actions.ts +6 -2
- package/src/components/layout/shell/pane/management-shortcuts.ts +13 -51
- package/src/components/layout/status-bar.tsx +4 -78
- package/src/components/layout/status-widget-space.ts +5 -5
- package/src/components/onboarding/portfolio-step/positions-panel.tsx +1 -1
- package/src/components/ui/data-table/index.tsx +5 -1
- package/src/components/ui/data-table/render-cell.ts +19 -0
- package/src/components/ui/delayed-mark.tsx +59 -7
- package/src/components/ui/icon.tsx +1 -8
- package/src/components/ui/menu.tsx +6 -1
- package/src/i18n/es.ts +6 -3
- package/src/i18n/ja.ts +6 -3
- package/src/i18n/ko.ts +6 -3
- package/src/i18n/zh-cn.ts +6 -3
- package/src/i18n/zh-tw.ts +6 -3
- package/src/market-data/fund-facts.ts +7 -1
- package/src/market-data/market/change-basis.ts +20 -0
- package/src/market-data/market/format.ts +62 -2
- package/src/market-data/market/futures-week.ts +3 -1
- package/src/plugins/builtin/chart-composer/headless.ts +57 -17
- package/src/plugins/builtin/chart-composer/session-range.ts +82 -3
- package/src/plugins/builtin/chat/content/composer.tsx +21 -27
- package/src/plugins/builtin/chat/content/index.tsx +31 -3
- package/src/plugins/builtin/chat/content/shortcuts.ts +4 -2
- package/src/plugins/builtin/chat/content/snapshot.ts +0 -3
- package/src/plugins/builtin/cloud/auth-actions.tsx +51 -23
- package/src/plugins/builtin/cloud/trial-offer-status-widget.tsx +3 -3
- package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +32 -25
- package/src/plugins/builtin/congress-trades/model.ts +2 -1
- package/src/plugins/builtin/congress-trades/pane.tsx +3 -0
- package/src/plugins/builtin/correlation/compute.ts +8 -2
- package/src/plugins/builtin/correlation/headless.ts +10 -9
- package/src/plugins/builtin/correlation/history.ts +30 -0
- package/src/plugins/builtin/correlation/matrix/model.ts +10 -10
- package/src/plugins/builtin/correlation/relationship/model.ts +3 -6
- package/src/plugins/builtin/correlation/relationship/pane.tsx +1 -2
- package/src/plugins/builtin/crypto-board/client.ts +6 -1
- package/src/plugins/builtin/crypto-board/defi-view.tsx +12 -1
- package/src/plugins/builtin/crypto-board/defi.ts +44 -7
- package/src/plugins/builtin/crypto-board/headless.ts +83 -12
- package/src/plugins/builtin/crypto-board/model.ts +30 -6
- package/src/plugins/builtin/crypto-board/pane.tsx +13 -2
- package/src/plugins/builtin/custom-view/index.tsx +1 -1
- package/src/plugins/builtin/custom-view/loader.ts +85 -8
- package/src/plugins/builtin/custom-view/view-spec.ts +28 -0
- package/src/plugins/builtin/equity-screener/criterion-editor.tsx +13 -4
- package/src/plugins/builtin/equity-screener/headless.ts +33 -1
- package/src/plugins/builtin/equity-screener/model.ts +58 -15
- package/src/plugins/builtin/equity-screener/pane.tsx +36 -6
- package/src/plugins/builtin/executives/format.ts +5 -4
- package/src/plugins/builtin/executives/pane.tsx +1 -1
- package/src/plugins/builtin/help/index.tsx +55 -1
- package/src/plugins/builtin/insider/model.ts +30 -2
- package/src/plugins/builtin/jobs/model.ts +2 -2
- package/src/plugins/builtin/mna/model.ts +2 -2
- package/src/plugins/builtin/notes/files.ts +2 -0
- package/src/plugins/builtin/notes/owner.tsx +20 -1
- package/src/plugins/builtin/notes/quick-notes-pane.tsx +22 -4
- package/src/plugins/builtin/notes/store.ts +6 -1
- package/src/plugins/builtin/perps/headless.ts +8 -2
- package/src/plugins/builtin/portfolio-list/header.tsx +1 -1
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +29 -25
- package/src/plugins/builtin/risk-factors/index.tsx +2 -28
- package/src/plugins/builtin/risk-factors/lock-note.ts +58 -0
- package/src/plugins/builtin/risk-factors/pane.tsx +10 -3
- package/src/plugins/builtin/scanner/hilo-model.ts +4 -3
- package/src/plugins/builtin/sec/fund-facts.ts +45 -11
- package/src/plugins/builtin/sec/headless.ts +30 -1
- package/src/plugins/builtin/sec/index.tsx +26 -5
- package/src/plugins/builtin/series-inventory.ts +1 -0
- package/src/plugins/builtin/shared/earnings-report.ts +7 -2
- package/src/plugins/builtin/shared/pro-lock-note.ts +5 -1
- package/src/plugins/builtin/shared/use-quote-board.ts +85 -46
- package/src/plugins/builtin/short-interest/headless.ts +1 -1
- package/src/plugins/builtin/short-interest/model.ts +15 -6
- package/src/plugins/builtin/short-interest/types.ts +2 -0
- package/src/plugins/builtin/thirteenf/overlap-pane.tsx +3 -0
- package/src/plugins/builtin/thirteenf/pane.tsx +3 -0
- package/src/plugins/builtin/ticker-detail/overview/model.ts +19 -9
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +4 -4
- package/src/plugins/builtin/time-sales/headless.ts +23 -7
- package/src/plugins/builtin/time-sales/index.tsx +2 -2
- package/src/plugins/builtin/trace-bonds/detail.tsx +198 -0
- package/src/plugins/builtin/trace-bonds/headless.ts +62 -4
- package/src/plugins/builtin/trace-bonds/history.ts +155 -0
- package/src/plugins/builtin/trace-bonds/pane.tsx +64 -5
- package/src/plugins/extracted-plugins.ts +49 -24
- package/src/plugins/installer.ts +234 -32
- package/src/plugins/plugin-names.ts +11 -2
- package/src/plugins/running-installs.ts +34 -0
- package/src/plugins/seed-progress.ts +72 -0
- package/src/remote/controller.ts +9 -2
- package/src/remote/schema.ts +2 -1
- package/src/renderers/cloudflare/http-proxy.ts +67 -8
- package/src/renderers/cloudflare/proxy-session.ts +1 -1
- package/src/renderers/cloudflare/worker.ts +29 -2
- package/src/renderers/dom/desktop/icons.tsx +0 -2
- package/src/renderers/dom/styles.css +0 -3
- package/src/renderers/electrobun/bun/desktop/backend.ts +14 -0
- package/src/renderers/electrobun/bun/desktop/host-requests.ts +14 -7
- package/src/renderers/electrobun/bun/desktop/initialization.ts +24 -14
- package/src/renderers/electrobun/bun/desktop/install-records.ts +59 -0
- package/src/renderers/electrobun/bun/desktop/installer-folder.ts +208 -592
- package/src/renderers/electrobun/bun/desktop/macos-objc.ts +14 -0
- package/src/renderers/electrobun/bun/desktop/update.ts +1 -1
- package/src/renderers/electrobun/bun/index.ts +24 -13
- package/src/renderers/electrobun/bun/window/context-menu-thread.ts +84 -0
- package/src/renderers/electrobun/bun/window/create.ts +23 -3
- package/src/renderers/electrobun/bun/window/electrobun-window-host.ts +4 -4
- package/src/renderers/electrobun/bun/window/events.ts +4 -4
- package/src/renderers/electrobun/bun/window/frame.ts +2 -1
- package/src/renderers/electrobun/bun/window/native-call-thread.ts +224 -0
- package/src/renderers/electrobun/bun/window/native-min-size.ts +322 -0
- package/src/renderers/electrobun/bun/window/native-timing.ts +10 -0
- package/src/renderers/electrobun/bun/window/script-for-webview.ts +15 -0
- package/src/renderers/electrobun/bun/window/webview-script-thread.ts +82 -0
- package/src/renderers/electrobun/shared/protocol.ts +13 -2
- package/src/renderers/electrobun/view/backend-rpc.ts +8 -1
- package/src/renderers/electrobun/view/cli-pane-shot-frame.tsx +1 -1
- package/src/renderers/electrobun/view/main.tsx +4 -3
- package/src/renderers/opentui/start.tsx +3 -0
- package/src/sources/gloomberb-cloud/index.ts +5 -7
- package/src/sources/provider-router/batches.ts +18 -3
- package/src/sources/provider-router/financials.ts +18 -4
- package/src/telemetry/stall-reports.ts +21 -4
- package/src/types/data-provider.ts +14 -0
- package/src/types/financials.ts +15 -3
- package/src/types/headless.ts +2 -0
- package/src/utils/double-escape-close.ts +38 -16
- package/src/utils/format.ts +23 -3
- package/src/utils/main-thread-stall.ts +21 -5
- package/src/utils/perf-marks.ts +88 -9
- package/src/utils/price-earnings.ts +18 -0
- package/src/utils/reported-money.ts +9 -2
- package/src/utils/sec.ts +34 -3
- package/patches/electrobun@1.18.1.patch +0 -633
- package/src/api-client/types.ts +0 -2441
- package/src/plugins/seed-notice.ts +0 -20
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { PluginActivation } from "../../plugins/marketplace/activation";
|
|
2
|
+
import {
|
|
3
|
+
getPluginSeedProgress,
|
|
4
|
+
samePluginSeedFailure,
|
|
5
|
+
subscribePluginSeed,
|
|
6
|
+
type PluginSeedNotice,
|
|
7
|
+
type PluginSeedProgress,
|
|
8
|
+
type PluginSeedRecord,
|
|
9
|
+
} from "../../plugins/seed-progress";
|
|
10
|
+
import type { AppConfig } from "../../types/config";
|
|
11
|
+
import { logFailure } from "../../utils/log-failure";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Brings the plugins the launch restores (cli/restore-plugins.ts) into the
|
|
15
|
+
* running app as each lands, the way the Plugins pane does after an install,
|
|
16
|
+
* then records the outcome in the config and says what could not be
|
|
17
|
+
* installed. The main window alone does this: it owns the config and the
|
|
18
|
+
* plugin registrations.
|
|
19
|
+
*/
|
|
20
|
+
export interface PluginSeedConsumer {
|
|
21
|
+
/** Settles once the plugins the app started with have registered. */
|
|
22
|
+
ready: Promise<unknown>;
|
|
23
|
+
/** Brings an installed folder, and the siblings it brought along, into the session. Null when nothing can. */
|
|
24
|
+
activate(install: { directory: string; peers: string[] }): Promise<PluginActivation | null>;
|
|
25
|
+
/** Whether the plugin in this folder already runs in the session. */
|
|
26
|
+
isRunning(directory: string): boolean;
|
|
27
|
+
/** The broker types registered in the session now. */
|
|
28
|
+
brokerTypes(): Iterable<string>;
|
|
29
|
+
/**
|
|
30
|
+
* Syncs the saved broker profiles of these types. The launch's sync ran
|
|
31
|
+
* before their plugin was back, so it had no broker to ask.
|
|
32
|
+
*/
|
|
33
|
+
syncBrokers(types: ReadonlySet<string>): void;
|
|
34
|
+
record(record: PluginSeedRecord): void;
|
|
35
|
+
notify(notice: PluginSeedNotice): void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Folders being brought in, across consumers: a remounted app must not register one twice. */
|
|
39
|
+
const activating = new Set<string>();
|
|
40
|
+
|
|
41
|
+
/** `TV, Polls and Substack`. */
|
|
42
|
+
function nameList(names: readonly string[]): string {
|
|
43
|
+
return names.length <= 1 ? names.join("") : `${names.slice(0, -1).join(", ")} and ${names.at(-1)}`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Follows the restore until it is over, or until the returned function is called. */
|
|
47
|
+
export function startPluginSeedConsumer(consumer: PluginSeedConsumer): () => void {
|
|
48
|
+
const handled = new Set<string>();
|
|
49
|
+
const unloaded: string[] = [];
|
|
50
|
+
const restart: string[] = [];
|
|
51
|
+
let finished = false;
|
|
52
|
+
let disposed = false;
|
|
53
|
+
// One at a time, in the order they landed: a sibling before what needs it.
|
|
54
|
+
let chain: Promise<void> = consumer.ready.then(() => {}, () => {
|
|
55
|
+
// Intentional ignore: a plugin that failed to register is reported where it registers.
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const bringIn = async (name: string, directory: string, peers: string[]) => {
|
|
59
|
+
if (disposed || activating.has(directory) || consumer.isRunning(directory)) return;
|
|
60
|
+
activating.add(directory);
|
|
61
|
+
try {
|
|
62
|
+
const before = new Set(consumer.brokerTypes());
|
|
63
|
+
const activated = await consumer.activate({ directory, peers: peers.filter((peer) => !consumer.isRunning(peer)) });
|
|
64
|
+
// Nothing here can load it (no plugin manager): the next launch does.
|
|
65
|
+
if (!activated || (activated.ok && activated.restart)) restart.push(name);
|
|
66
|
+
else if (!activated.ok) unloaded.push(name);
|
|
67
|
+
const added = new Set([...consumer.brokerTypes()].filter((type) => !before.has(type)));
|
|
68
|
+
if (added.size > 0 && !disposed) consumer.syncBrokers(added);
|
|
69
|
+
} finally {
|
|
70
|
+
activating.delete(directory);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const finish = (outcome: NonNullable<PluginSeedProgress["outcome"]>) => {
|
|
75
|
+
if (disposed) return;
|
|
76
|
+
consumer.record(outcome.record);
|
|
77
|
+
if (outcome.notice) consumer.notify(outcome.notice);
|
|
78
|
+
if (unloaded.length > 0) consumer.notify({ type: "error", body: `${nameList(unloaded)} installed but did not load. Open Plugins to see why.` });
|
|
79
|
+
else if (restart.length > 0) consumer.notify({ type: "info", body: `Restart Gloom to finish installing ${nameList(restart)}.` });
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const step = () => {
|
|
83
|
+
const progress = getPluginSeedProgress();
|
|
84
|
+
if (!progress || disposed) return;
|
|
85
|
+
for (const entry of progress.plugins) {
|
|
86
|
+
if (entry.state !== "installed" || !entry.directory || handled.has(entry.id)) continue;
|
|
87
|
+
handled.add(entry.id);
|
|
88
|
+
const { name, directory } = entry;
|
|
89
|
+
chain = chain.then(() => bringIn(name, directory, entry.peers ?? []))
|
|
90
|
+
.catch(logFailure("plugin-seed", "Restored plugin activation failed"));
|
|
91
|
+
}
|
|
92
|
+
const { outcome } = progress;
|
|
93
|
+
if (outcome && !finished) {
|
|
94
|
+
finished = true;
|
|
95
|
+
chain = chain.then(() => finish(outcome)).catch(logFailure("plugin-seed", "Plugin restore record failed"));
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const unsubscribe = subscribePluginSeed(step);
|
|
100
|
+
step();
|
|
101
|
+
return () => {
|
|
102
|
+
disposed = true;
|
|
103
|
+
unsubscribe();
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The config with the restore's record: every plugin seeded so far stays
|
|
109
|
+
* seeded, and the failure is this launch's. Null when that changes nothing.
|
|
110
|
+
*/
|
|
111
|
+
export function withPluginSeedRecord(config: AppConfig, record: PluginSeedRecord): AppConfig | null {
|
|
112
|
+
const seededPlugins = [...new Set([...config.seededPlugins ?? [], ...record.seededPlugins ?? []])].sort();
|
|
113
|
+
const sameSeeded = seededPlugins.join() === [...new Set(config.seededPlugins ?? [])].sort().join();
|
|
114
|
+
if (sameSeeded && samePluginSeedFailure(config.pluginSeedFailure, record.pluginSeedFailure)) return null;
|
|
115
|
+
const next: AppConfig = { ...config, seededPlugins };
|
|
116
|
+
if (record.pluginSeedFailure) next.pluginSeedFailure = record.pluginSeedFailure;
|
|
117
|
+
else delete next.pluginSeedFailure;
|
|
118
|
+
return next;
|
|
119
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { logFailure } from "../../utils/log-failure";
|
|
2
|
-
import { useCallback, useEffect, type Dispatch } from "react";
|
|
2
|
+
import { useCallback, useEffect, useRef, type Dispatch } from "react";
|
|
3
3
|
import { loadPersistedBrokerAccountMap } from "../../brokers/account-cache";
|
|
4
4
|
import type { AppSessionSnapshot } from "../../core/state/session-persistence";
|
|
5
5
|
import type { AppTickerRepositoryPort } from "../../core/app-service-ports";
|
|
@@ -8,7 +8,11 @@ import { instrumentFromTicker, type InstrumentRef } from "../../market-data/requ
|
|
|
8
8
|
import { useSavedLayoutWarmup } from "./layout-warmup";
|
|
9
9
|
import { chatController } from "../../plugins/builtin/chat/controller";
|
|
10
10
|
import { PLUGIN_MARKETPLACE_PANE_ID } from "../../plugins/marketplace/ids";
|
|
11
|
-
import {
|
|
11
|
+
import { activateInstall } from "../../plugins/marketplace/activation";
|
|
12
|
+
import { getMarketplaceHost, getPluginManager } from "../../plugins/marketplace/store";
|
|
13
|
+
import { listExternalPlugins } from "../../plugins/external-runtime";
|
|
14
|
+
import { scheduleConfigSave } from "../../state/config-save-scheduler";
|
|
15
|
+
import { startPluginSeedConsumer, withPluginSeedRecord } from "./plugin-seed";
|
|
12
16
|
import type { LoadedExternalPlugin } from "../../plugins/loader";
|
|
13
17
|
import type { PluginRegistry } from "../../plugins/registry";
|
|
14
18
|
import type {
|
|
@@ -65,6 +69,8 @@ function restoredUsageFunctions(
|
|
|
65
69
|
interface UseAppStartupRuntimeOptions {
|
|
66
70
|
appActive: boolean;
|
|
67
71
|
autoImportBrokerPositions: InitializeAppStateArgs["autoImportBrokerPositions"];
|
|
72
|
+
/** Syncs one saved broker profile, as its Sync action does. */
|
|
73
|
+
importBrokerPositions: (instanceId: string) => Promise<unknown>;
|
|
68
74
|
dataProvider: DataProvider;
|
|
69
75
|
dispatch: Dispatch<AppAction>;
|
|
70
76
|
externalPlugins: readonly LoadedExternalPlugin[];
|
|
@@ -88,6 +94,7 @@ interface UseAppStartupRuntimeOptions {
|
|
|
88
94
|
export function useAppStartupRuntime({
|
|
89
95
|
appActive,
|
|
90
96
|
autoImportBrokerPositions,
|
|
97
|
+
importBrokerPositions,
|
|
91
98
|
dataProvider,
|
|
92
99
|
dispatch,
|
|
93
100
|
externalPlugins,
|
|
@@ -208,15 +215,44 @@ export function useAppStartupRuntime({
|
|
|
208
215
|
// identity, so this runs when initialization flips and not again.
|
|
209
216
|
}, [externalPlugins, isDetachedWindow, pluginRegistry, state.initialized]);
|
|
210
217
|
|
|
211
|
-
// Official plugins
|
|
212
|
-
//
|
|
218
|
+
// Official plugins that moved out of Gloom install after the first frame
|
|
219
|
+
// (cli/restore-plugins.ts). Each is brought into the session as it lands,
|
|
220
|
+
// the outcome is recorded, and what could not be installed (no git,
|
|
221
|
+
// offline) is said once, since it is otherwise simply missing. The import
|
|
222
|
+
// is read through a ref: a new one must not restart the restore's consumer,
|
|
223
|
+
// which would say its outcome again.
|
|
224
|
+
const importBrokerPositionsRef = useRef(importBrokerPositions);
|
|
225
|
+
importBrokerPositionsRef.current = importBrokerPositions;
|
|
213
226
|
useEffect(() => {
|
|
214
227
|
if (!state.initialized || isDetachedWindow) return;
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
228
|
+
return startPluginSeedConsumer({
|
|
229
|
+
ready: pluginsReady ?? Promise.resolve(),
|
|
230
|
+
activate: async (install) => {
|
|
231
|
+
const host = getMarketplaceHost();
|
|
232
|
+
const manager = getPluginManager();
|
|
233
|
+
return host && manager ? activateInstall(install, host, manager) : null;
|
|
234
|
+
},
|
|
235
|
+
isRunning: (directory) => listExternalPlugins().some((entry) => entry.directory === directory && !entry.error),
|
|
236
|
+
brokerTypes: () => pluginRegistry.brokers.keys(),
|
|
237
|
+
syncBrokers: (types) => {
|
|
238
|
+
for (const instance of getState().config.brokerInstances) {
|
|
239
|
+
if (instance.enabled === false || !types.has(instance.brokerType)) continue;
|
|
240
|
+
// A failure is on the profile's row, with Sync to retry.
|
|
241
|
+
void importBrokerPositionsRef.current(instance.id).catch(logFailure("app.runtime.startup", "Restored broker positions import failed"));
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
record: (record) => {
|
|
245
|
+
const config = withPluginSeedRecord(getState().config, record);
|
|
246
|
+
if (!config) return;
|
|
247
|
+
dispatch({ type: "SET_CONFIG", config });
|
|
248
|
+
scheduleConfigSave(config);
|
|
249
|
+
},
|
|
250
|
+
notify: (notice) => {
|
|
251
|
+
appLog.warn("official plugin restore", { notice: notice.body });
|
|
252
|
+
pluginRegistry.notify({ ...notice, duration: PLUGIN_SEED_NOTICE_MS });
|
|
253
|
+
},
|
|
254
|
+
});
|
|
255
|
+
}, [dispatch, getState, isDetachedWindow, pluginRegistry, pluginsReady, state.initialized]);
|
|
220
256
|
|
|
221
257
|
// What people keep on screen: the functions open in the workspace restored
|
|
222
258
|
// at launch, counted once per session. The layout is taken as restored,
|
|
@@ -156,7 +156,7 @@ function StarPromptLine({ delayMs = STAR_PROMPT_DELAY_MS, visibleMs = STAR_PROMP
|
|
|
156
156
|
|
|
157
157
|
const showing = phase === "showing" && fits;
|
|
158
158
|
useEffect(() => (showing ? bindStarPromptKeys({ open, dismiss }) : undefined), [dismiss, open, showing]);
|
|
159
|
-
// The
|
|
159
|
+
// The connection note gives way to the line.
|
|
160
160
|
useStatusWidgetClaim("star-prompt", showing && copy ? copy.columns : 0);
|
|
161
161
|
|
|
162
162
|
if (!showing || !copy) return null;
|
package/src/app.tsx
CHANGED
|
@@ -364,6 +364,7 @@ function AppInner({
|
|
|
364
364
|
useAppStartupRuntime({
|
|
365
365
|
appActive,
|
|
366
366
|
autoImportBrokerPositions,
|
|
367
|
+
importBrokerPositions,
|
|
367
368
|
dataProvider,
|
|
368
369
|
dispatch,
|
|
369
370
|
externalPlugins,
|
|
@@ -534,13 +535,7 @@ function AppInner({
|
|
|
534
535
|
desktopDockPreview={desktopDockPreview}
|
|
535
536
|
commandBarNativeOccluder={commandBarNativeOccluder}
|
|
536
537
|
/>
|
|
537
|
-
<StatusBar
|
|
538
|
-
onOpenChangelog={(version) => {
|
|
539
|
-
void pluginRegistry.createPaneFromTemplateAsync("changelog-pane", {
|
|
540
|
-
values: { version },
|
|
541
|
-
}).catch(() => {});
|
|
542
|
-
}}
|
|
543
|
-
/>
|
|
538
|
+
<StatusBar />
|
|
544
539
|
</TransientLayoutProvider>
|
|
545
540
|
{!onboardingActive ? <CompanyPickerHost pluginRegistry={pluginRegistry} /> : null}
|
|
546
541
|
{initialized && !onboardingActive && !signInGateActive ? <AttentionCountsNotice notify={notifyRequest} /> : null}
|
|
@@ -21,14 +21,6 @@
|
|
|
21
21
|
"why": "Registry plugin (gloomberb-crypto-fear-greed): the gauge's figure, as above."
|
|
22
22
|
}
|
|
23
23
|
],
|
|
24
|
-
"CHAT": [
|
|
25
|
-
{
|
|
26
|
-
"measure": "inset",
|
|
27
|
-
"value": 7.2,
|
|
28
|
-
"component": "PaneSidebarRow",
|
|
29
|
-
"why": "Chat has its own owner: its channel rows start 7px in (reported, not changed)."
|
|
30
|
-
}
|
|
31
|
-
],
|
|
32
24
|
"FXMD_REST_HEALTH": [
|
|
33
25
|
{
|
|
34
26
|
"measure": "inset",
|
package/src/cli/board-coins.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { apiClient } from "../api-client";
|
|
2
2
|
import type { CryptoMarketAsset } from "../api-client/crypto-markets";
|
|
3
|
+
import { TOP_COIN_NAMES } from "../utils/crypto-pair";
|
|
3
4
|
import { logFailure } from "../utils/log-failure";
|
|
4
5
|
|
|
5
6
|
/** A coin on the crypto board as a hint names it: its one symbol and its name. */
|
|
@@ -12,10 +13,37 @@ type BoardEntry = Pick<CryptoMarketAsset, "symbol" | "code" | "name" | "marketCa
|
|
|
12
13
|
|
|
13
14
|
/** How long a hint waits for the board; a slow board leaves the plain search hint. */
|
|
14
15
|
const BOARD_TIMEOUT_MS = 4_000;
|
|
15
|
-
|
|
16
|
+
// A bare word no listing has, or one the data service could not check ("Could not check USDT: ...").
|
|
17
|
+
const BARE_NOT_A_TICKER = /Not a ticker: ([A-Za-z0-9]+)\.|Could not (?:check|look up) [^\s,]+(?:, [^\s,]+)*: /;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The largest stablecoins, by the code and name the board gives them, which
|
|
21
|
+
* the coins people type bare most often are (USDT, USDC). With the largest
|
|
22
|
+
* coins (TOP_COIN_NAMES) they stand in for a board that cannot be read, as in
|
|
23
|
+
* an outage of the data service that also left the word unchecked.
|
|
24
|
+
*/
|
|
25
|
+
const STABLECOIN_NAMES: ReadonlyArray<readonly [string, string]> = [
|
|
26
|
+
["USDT", "Tether USDt"],
|
|
27
|
+
["USDC", "USDC"],
|
|
28
|
+
["USDS", "USDS"],
|
|
29
|
+
["USDE", "Ethena USDe"],
|
|
30
|
+
["DAI", "Dai"],
|
|
31
|
+
["USD1", "World Liberty Financial USD"],
|
|
32
|
+
["PYUSD", "PayPal USD"],
|
|
33
|
+
["RLUSD", "Ripple USD"],
|
|
34
|
+
["FDUSD", "First Digital USD"],
|
|
35
|
+
["TUSD", "TrueUSD"],
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
const KNOWN_COINS: readonly BoardEntry[] = [
|
|
39
|
+
...[...TOP_COIN_NAMES].map(([code, name]) => [code, name.replace(/\b\p{Ll}/gu, (letter) => letter.toUpperCase())] as const),
|
|
40
|
+
...STABLECOIN_NAMES,
|
|
41
|
+
].map(([code, name]) => ({ symbol: `${code}-USD`, code, name, marketCap: null }));
|
|
16
42
|
|
|
17
43
|
let board: readonly BoardEntry[] | null = null;
|
|
18
44
|
let loading: Promise<void> | null = null;
|
|
45
|
+
/** The board was asked for and did not come: the known coins answer instead. */
|
|
46
|
+
let unread = false;
|
|
19
47
|
|
|
20
48
|
/**
|
|
21
49
|
* Reads the crypto board once, when some text says a bare word is not a
|
|
@@ -31,7 +59,10 @@ export async function primeBoardCoins(
|
|
|
31
59
|
loading ??= Promise.race([
|
|
32
60
|
load().then((data) => { board = boardEntries(data.assets); }),
|
|
33
61
|
new Promise<void>((resolve) => { timer = setTimeout(resolve, BOARD_TIMEOUT_MS); }),
|
|
34
|
-
]).catch(logFailure("cli.board-coins", "Read the crypto board for a coin hint failed")).finally(() =>
|
|
62
|
+
]).catch(logFailure("cli.board-coins", "Read the crypto board for a coin hint failed")).finally(() => {
|
|
63
|
+
clearTimeout(timer);
|
|
64
|
+
if (!board) unread = true;
|
|
65
|
+
});
|
|
35
66
|
await loading;
|
|
36
67
|
}
|
|
37
68
|
|
|
@@ -52,9 +83,10 @@ const compact = (text: string) => text.toUpperCase().replace(/[^\p{L}\p{N}]/gu,
|
|
|
52
83
|
*/
|
|
53
84
|
export function boardCoinFor(typed: string): BoardCoin | null {
|
|
54
85
|
const id = typed.trim().replace(/^\$/, "").toUpperCase();
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const
|
|
86
|
+
const coins = board ?? (unread ? KNOWN_COINS : null);
|
|
87
|
+
if (!coins || !/^[A-Z0-9]+$/.test(id)) return null;
|
|
88
|
+
const byCode = coins.filter((coin) => coin.code.toUpperCase() === id);
|
|
89
|
+
const byName = byCode.length ? [] : coins.filter((coin) => {
|
|
58
90
|
const name = compact(coin.name);
|
|
59
91
|
const first = compact(coin.name.split(/\s+/)[0] ?? "");
|
|
60
92
|
return name === id || (id.length >= 5 && first === id);
|
|
@@ -67,4 +99,5 @@ export function boardCoinFor(typed: string): BoardCoin | null {
|
|
|
67
99
|
export function resetBoardCoins(entries: readonly BoardEntry[] | null = null): void {
|
|
68
100
|
board = entries;
|
|
69
101
|
loading = null;
|
|
102
|
+
unread = false;
|
|
70
103
|
}
|
|
@@ -5,6 +5,7 @@ import { isCryptoPairSymbol, TOP_COIN_NAMES } from "../../utils/crypto-pair";
|
|
|
5
5
|
import { isNotATickerMessage } from "../not-a-ticker";
|
|
6
6
|
import { groupByCompany } from "../../tickers/company-name";
|
|
7
7
|
import { DATA_SERVICE_UNREACHABLE_MESSAGE } from "../../utils/network-failure";
|
|
8
|
+
import { serviceDidNotAnswerMessage } from "../../sources/provider-errors";
|
|
8
9
|
import type { TickerRecord } from "../../types/ticker";
|
|
9
10
|
|
|
10
11
|
/** Where a crypto pair that will not load can still be read. `fn CRYP` takes no argument. */
|
|
@@ -101,6 +102,11 @@ function failureReason(message: string, symbol: string): string {
|
|
|
101
102
|
return at > 0 ? `${line.slice(0, at)}${line.slice(at + suffix.length)}` : line;
|
|
102
103
|
}
|
|
103
104
|
|
|
105
|
+
/** A reason that says the data service gave no answer at all, not what it found: the symbol was never checked. */
|
|
106
|
+
function unanswered(reason: string): boolean {
|
|
107
|
+
return reason === DATA_SERVICE_UNREACHABLE_MESSAGE || reason.startsWith(serviceDidNotAnswerMessage().split(".")[0]!);
|
|
108
|
+
}
|
|
109
|
+
|
|
104
110
|
/**
|
|
105
111
|
* Text-mode notes under a quote table: one line per distinct failure reason (with the crypto board
|
|
106
112
|
* pointer when a failed symbol is a crypto pair, unless nothing could be reached), then the perpetual futures line.
|
|
@@ -118,7 +124,8 @@ export function quoteNotes(results: QuoteNoteResult[]): string[] {
|
|
|
118
124
|
// "Not a ticker: APPLE." already names its symbol.
|
|
119
125
|
isNotATickerMessage(reason)
|
|
120
126
|
? reason
|
|
121
|
-
|
|
127
|
+
// Nothing answered for the symbol, so it is no more a typo than a ticker: the line says it went unchecked.
|
|
128
|
+
: `${unanswered(reason) ? "Could not check " : ""}${symbols.join(", ")}: ${reason}${symbols.some(isCryptoPairSymbol) && reason !== DATA_SERVICE_UNREACHABLE_MESSAGE ? `${/[.!?]$/.test(reason) ? "" : "."} ${CRYPTO_BOARD_HINT}` : ""}`
|
|
122
129
|
));
|
|
123
130
|
const perpetuals = results
|
|
124
131
|
.filter((result) => result.quote && isCryptoVenuePerpetual(result.quote.instrumentType, result.quote.name))
|
|
@@ -16,9 +16,9 @@ import type {
|
|
|
16
16
|
Quote,
|
|
17
17
|
TickerFinancials,
|
|
18
18
|
} from "../../types/financials";
|
|
19
|
-
import { currencyPriceMinDigits, formatMarketPrice, formatMarketPriceWithCurrency, penceFigure, quoteFormatOptions,
|
|
19
|
+
import { currencyPriceMinDigits, formatMarketPrice, formatMarketPriceWithCurrency, nearParCoinPriceDigits, penceFigure, quoteFormatOptions, withCurrencyMinorDigits } from "../../market-data/market/format";
|
|
20
20
|
import { INDEX_POINTS_EXPORT_UNIT, isIndexLevel, reportedQuoteVolume } from "../../market-data/market/index-level";
|
|
21
|
-
import { changeBasisJson, changeBasisLabel, changeBasisNote, quoteChangeBasis, quotePreviousCloseDate, quoteSettleText } from "../../market-data/market/change-basis";
|
|
21
|
+
import { changeBasisJson, changeBasisLabel, changeBasisNote, printPredatesChangeBasis, quoteChangeBasis, quotePreviousCloseDate, quoteSettleText } from "../../market-data/market/change-basis";
|
|
22
22
|
import {
|
|
23
23
|
EXTENDED_SESSION_LABELS,
|
|
24
24
|
getExtendedSessionDisplay,
|
|
@@ -258,6 +258,7 @@ import {
|
|
|
258
258
|
type ListingIdentity,
|
|
259
259
|
} from "../listing-arg";
|
|
260
260
|
import { currencyNameMiss, currencyNameStop } from "../currency-name-hint";
|
|
261
|
+
import { liveCompanyQuestion } from "../company-name-hint";
|
|
261
262
|
import { bareListingNote, listingFateNotes, loadNoQuoteLastTraded, noLongerTradingNote, noQuoteLastTraded, noQuoteLastTradeNote, SUCCESSOR_CHANGE_WAIT_MS, tradingListing, usVenueOf } from "../../tickers/listing-fate";
|
|
262
263
|
import { isYieldIndexSymbol } from "../../tickers/index-roots";
|
|
263
264
|
import {
|
|
@@ -509,6 +510,8 @@ const QUOTE_LEAD_COLUMNS = [
|
|
|
509
510
|
header: "Chg%",
|
|
510
511
|
align: "right" as const,
|
|
511
512
|
format: (value: unknown, row: QuoteRow) => {
|
|
513
|
+
// A print older than what the move is from has no move as of now.
|
|
514
|
+
if (row.predatesChangeBasis) return "—";
|
|
512
515
|
const move = row.yieldIndex ? yieldChangeCell(row) : formatChangePercentCell(value);
|
|
513
516
|
// Keep a rolling move's short label with the value when narrow tables drop Chg Basis.
|
|
514
517
|
return move && row.changeBasis === "24h" ? `${move} ${cliStyles.muted("24h")}` : move;
|
|
@@ -519,7 +522,8 @@ const QUOTE_LEAD_COLUMNS = [
|
|
|
519
522
|
extendedColumn("POST"),
|
|
520
523
|
extendedColumn("OVERNIGHT"),
|
|
521
524
|
// An export keeps the market state (PRE-MKT); the table names the close a pre-market with no trade stands at (Thu close).
|
|
522
|
-
|
|
525
|
+
// A print older than its move's basis has no session of its own either.
|
|
526
|
+
{ key: "session", header: "Session", shrink: false, format: (_value: unknown, row: QuoteRow) => row.predatesChangeBasis ? "—" : row.sessionLabel },
|
|
523
527
|
];
|
|
524
528
|
|
|
525
529
|
type QuoteRow = ReturnType<typeof quoteRows>[number];
|
|
@@ -617,6 +621,7 @@ function pairExportUnit(symbol: string, currency: string): string | null {
|
|
|
617
621
|
|
|
618
622
|
function quoteExportStatus(row: QuoteRow): string {
|
|
619
623
|
if (row.rawPrice == null || !Number.isFinite(row.rawPrice)) return row.error || "Last: no price";
|
|
624
|
+
if (row.predatesChangeBasis) return row.predatesChangeBasis;
|
|
620
625
|
if (row.changePercent == null || !Number.isFinite(row.changePercent)) return "Chg%: no previous close";
|
|
621
626
|
return "";
|
|
622
627
|
}
|
|
@@ -697,21 +702,6 @@ function quoteFeedState(quote: QuoteCliRecord["quote"], now: number): "stale" |
|
|
|
697
702
|
return quote.dataSource === "live" || quote.dataSource === "delayed" ? quote.dataSource : "";
|
|
698
703
|
}
|
|
699
704
|
|
|
700
|
-
/** A hundredth of a cent, one basis point of a dollar peg: the decimals CRYP prints a stablecoin to. */
|
|
701
|
-
const STABLECOIN_PRICE_DIGITS = 4;
|
|
702
|
-
|
|
703
|
-
/**
|
|
704
|
-
* A coin trading near a dollar, a dollar stablecoin, prints to four decimals
|
|
705
|
-
* either side of par (0.9987, 1.0003), as CRYP does, whatever digits its
|
|
706
|
-
* source sent (0.99874, 0.99968725); below a dollar a coin otherwise keeps up to eight.
|
|
707
|
-
*/
|
|
708
|
-
function nearParCoin(quote: QuoteCliRecord["quote"]): boolean {
|
|
709
|
-
if (!quote || resolveAssetDisplayKind({ assetCategory: quote.instrumentType }) !== "crypto") return false;
|
|
710
|
-
if ((quote.currency ?? "USD").trim().toUpperCase() !== "USD") return false;
|
|
711
|
-
const reference = [quote.previousClose, quote.price].find((value) => typeof value === "number" && Number.isFinite(value) && value > 0);
|
|
712
|
-
return reference != null && reference >= 0.9 && reference < 1.1;
|
|
713
|
-
}
|
|
714
|
-
|
|
715
705
|
/** What a row's move is measured from, worded as its Chg Basis cell: empty without a move. */
|
|
716
706
|
function rowChangeBasis(result: Pick<QuoteCliRecord, "quote" | "futuresContract">) {
|
|
717
707
|
return quoteChangeBasis(result.quote, { terms: result.futuresContract });
|
|
@@ -749,6 +739,10 @@ function quoteSessionFields(quote: Quote | null | undefined) {
|
|
|
749
739
|
function quoteRows(results: QuoteCliRecord[], now = Date.now()) {
|
|
750
740
|
return results.map((result) => {
|
|
751
741
|
const quote = result.quote;
|
|
742
|
+
// A print older than what its move is from (a coin's last trade before 00:00 UTC) has no move as of now,
|
|
743
|
+
// and the session the market is in is not its own: both read "—", and the Feed cell says it is stale.
|
|
744
|
+
const basis = rowChangeBasis(result);
|
|
745
|
+
const predates = printPredatesChangeBasis(quote, basis, now);
|
|
752
746
|
// Last and Chg% are the regular session, as `ticker` and the quote monitor read it; a
|
|
753
747
|
// pre-market or after-hours print is its own column, measured from that session's close.
|
|
754
748
|
const display = quoteSessionFields(quote);
|
|
@@ -758,10 +752,12 @@ function quoteRows(results: QuoteCliRecord[], now = Date.now()) {
|
|
|
758
752
|
const indexPoints = isIndexLevel(quote?.instrumentType);
|
|
759
753
|
// Pad to two decimals so a column lines up, but never past the currency's minor unit (JPY has none).
|
|
760
754
|
// Points have no minor unit, so a yen-listed index still pads to two.
|
|
755
|
+
const nearParDigits = nearParCoinPriceDigits(quote);
|
|
761
756
|
const options = {
|
|
762
757
|
...quoteFormatOptions(quote),
|
|
763
758
|
minimumFractionDigits: indexPoints ? 2 : currencyPriceMinDigits(quote?.currency),
|
|
764
|
-
|
|
759
|
+
// A coin near a dollar prints to four decimals, as `ticker`, `G` and CRYP print it.
|
|
760
|
+
...nearParDigits != null ? { fixedFractionDigits: nearParDigits } : {},
|
|
765
761
|
};
|
|
766
762
|
const price = (value: number | null | undefined) => (
|
|
767
763
|
quote && value != null
|
|
@@ -780,8 +776,10 @@ function quoteRows(results: QuoteCliRecord[], now = Date.now()) {
|
|
|
780
776
|
rawPrice: display.price,
|
|
781
777
|
priceBasis: quote?.priceBasis ?? null,
|
|
782
778
|
instrumentType: quote?.instrumentType ?? null,
|
|
783
|
-
change: display.change,
|
|
784
|
-
changePercent: roundedPercent(display.changePercent ?? undefined),
|
|
779
|
+
change: predates ? null : display.change,
|
|
780
|
+
changePercent: predates ? null : roundedPercent(display.changePercent ?? undefined),
|
|
781
|
+
// Why Chg% is empty when it is for that reason, for an export's status column.
|
|
782
|
+
predatesChangeBasis: !predates ? "" : basis?.kind === "24h" ? "Chg%: last print over 24h old" : "Chg%: last print before 00:00 UTC",
|
|
785
783
|
// A Cboe yield index is read as a yield in percent and moves in basis points.
|
|
786
784
|
yieldIndex,
|
|
787
785
|
changeBasisPoints: yieldIndex && display.change != null ? toBasisPoints(display.change, 1) : null,
|
|
@@ -792,8 +790,8 @@ function quoteRows(results: QuoteCliRecord[], now = Date.now()) {
|
|
|
792
790
|
extendedChangePercent: roundedPercent(extended?.changePercent),
|
|
793
791
|
// The extended price is the session's bid and ask midpoint, nothing having traded in it.
|
|
794
792
|
extendedMark: extended?.mark === true,
|
|
795
|
-
session: quoteSessionStateLabel(quote, now) ?? "",
|
|
796
|
-
sessionLabel: quoteSessionLabel(quote, now) ?? "",
|
|
793
|
+
session: predates ? "" : quoteSessionStateLabel(quote, now) ?? "",
|
|
794
|
+
sessionLabel: predates ? "" : quoteSessionLabel(quote, now) ?? "",
|
|
797
795
|
// The close the shown move is measured from: the one before the session Last is.
|
|
798
796
|
previousClose: price(previousClose),
|
|
799
797
|
rawPreviousClose: previousClose ?? null,
|
|
@@ -812,7 +810,7 @@ function quoteRows(results: QuoteCliRecord[], now = Date.now()) {
|
|
|
812
810
|
updatedAt: quote?.lastUpdated ? new Date(quoteHeadlineTime(quote)).toISOString() : "",
|
|
813
811
|
error: result.error ?? "",
|
|
814
812
|
// Last, so a row read by position keeps every field where it was.
|
|
815
|
-
changeBasis: basisLabel(result, now),
|
|
813
|
+
changeBasis: predates ? "" : basisLabel(result, now),
|
|
816
814
|
changeBasisNote: changeBasisNote(rowChangeBasis(result), now) ?? "",
|
|
817
815
|
};
|
|
818
816
|
});
|
|
@@ -1101,6 +1099,10 @@ async function runQuote(rawArgs: string[], ctx: Parameters<CliCommandDef["execut
|
|
|
1101
1099
|
const lastTraded = await Promise.all(answers.map(({ result, listing }) => !result.quote && !isNetworkFailure(result.error)
|
|
1102
1100
|
&& answers.length <= MAX_CHOICE_LOOKUPS ? loadNoQuoteLastTraded(listing.request, market.dataProvider, now) : null));
|
|
1103
1101
|
const endedNotes = answers.map(({ listing }, index) => lastTraded[index] ? `${noQuoteLastTradeNote(listing.symbol, lastTraded[index]!)}.` : null);
|
|
1102
|
+
// A bare symbol whose listing stopped asks after the company by that name that still trades (DBS: D05 on SGX).
|
|
1103
|
+
const liveCompanies = await Promise.all(answers.map(({ result, listing }) => result.quote && !listing.exchange
|
|
1104
|
+
&& answers.length <= MAX_CHOICE_LOOKUPS && noLongerTradingNote(listing.symbol, result.quote, now)
|
|
1105
|
+
? liveCompanyQuestion(listing.typed ?? listing.symbol, market, now) : null));
|
|
1104
1106
|
if (symbols.length === 1 && endedNotes[0]) ctx.fail(endedNotes[0], quoteChangeLine(tickerChanges[0], formerIssuers[0]) || undefined);
|
|
1105
1107
|
const failed = answers[0]?.failure;
|
|
1106
1108
|
if (symbols.length === 1 && failed) {
|
|
@@ -1157,10 +1159,11 @@ async function runQuote(rawArgs: string[], ctx: Parameters<CliCommandDef["execut
|
|
|
1157
1159
|
...answers.flatMap((answer) => answer.notes),
|
|
1158
1160
|
// A row that stopped trading long ago reads as a quote that is merely stale, and one with
|
|
1159
1161
|
// nothing printed in a session the calendar has open (a feed that stalled, a typhoon day) says since when.
|
|
1160
|
-
...data.flatMap((row) => {
|
|
1162
|
+
...data.flatMap((row, index) => {
|
|
1161
1163
|
if (!row.quote) return [];
|
|
1162
1164
|
const label = `${row.target.symbol}${row.listing.name ? ` (${row.listing.name})` : ""}`;
|
|
1163
|
-
const
|
|
1165
|
+
const stopped = noLongerTradingNote(label, row.quote, now);
|
|
1166
|
+
const ended = stopped && liveCompanies[index] ? `${stopped}. ${liveCompanies[index]}` : stopped;
|
|
1164
1167
|
const quiet = ended ? null : noPrintsTodayText(row.quote, now);
|
|
1165
1168
|
return [ended ?? (quiet ? `${label}: ${quiet}` : []), quoteBarNotes(label, row.quote, now)].flat();
|
|
1166
1169
|
}),
|
|
@@ -58,7 +58,7 @@ import { isoDate, rejectExtraArgs, requireArg, requireOneArg, takeFlag, takeOpti
|
|
|
58
58
|
import { buildCorrelationSeries } from "../../plugins/builtin/correlation/matrix/model";
|
|
59
59
|
import { alignDailyCloses, correlateDailyCloses } from "../../plugins/builtin/correlation/compute";
|
|
60
60
|
import { mixedSessionCloseNote } from "../../market-data/market/session-close-note";
|
|
61
|
-
import { CORRELATION_RETURN_BASIS, loadCorrelationHistory } from "../../plugins/builtin/correlation/history";
|
|
61
|
+
import { contradictoryBarsNote, CORRELATION_RETURN_BASIS, loadCorrelationHistory, thinCorrelationNote } from "../../plugins/builtin/correlation/history";
|
|
62
62
|
import { coinListingNotes, EXCHANGE_OPTION, listingIdentity, listingReadNotes, loadForListing, loadListingQuote, requireCliListing, type CliListing } from "../listing-arg";
|
|
63
63
|
import { CLI_COMMAND_GROUPS } from "../help";
|
|
64
64
|
import { formatChangePercentCell, formatCompactCell } from "../helpers";
|
|
@@ -886,15 +886,21 @@ async function runCorrelation(rawArgs: string[], ctx: Parameters<CliCommandDef["
|
|
|
886
886
|
const right = rightListing!.key;
|
|
887
887
|
// Same daily-return model as the CORR pane: price levels of two trending
|
|
888
888
|
// assets correlate spuriously, often with the opposite sign.
|
|
889
|
-
const loadSeries = async (listing: CliListing) =>
|
|
890
|
-
|
|
891
|
-
await loadForListing(
|
|
889
|
+
const loadSeries = async (listing: CliListing) => {
|
|
890
|
+
const bars = await loadForListing(
|
|
892
891
|
listing, services, ctx,
|
|
893
892
|
() => loadCorrelationHistory(services.dataProvider, listing.request.symbol, listing.request.exchange, "1Y"),
|
|
894
|
-
)
|
|
895
|
-
|
|
893
|
+
);
|
|
894
|
+
return { ...buildCorrelationSeries(listing.key, bars), bars: bars.length };
|
|
895
|
+
};
|
|
896
896
|
const [leftSeries, rightSeries] = await Promise.all([loadSeries(leftListing!), loadSeries(rightListing!)]);
|
|
897
897
|
const { correlation, sampleSize } = correlateDailyCloses(leftSeries.prices, rightSeries.prices);
|
|
898
|
+
// The series history reads: contradictory bars are gaps, and a thin pair says which side is short.
|
|
899
|
+
const seriesNotes = [
|
|
900
|
+
...[leftSeries, rightSeries].filter((series, index) => index === 0 || left !== right)
|
|
901
|
+
.map((series) => contradictoryBarsNote(series.symbol, series.integrity?.length ?? 0, series.bars)),
|
|
902
|
+
thinCorrelationNote({ label: left, closes: leftSeries.prices.length }, { label: right, closes: rightSeries.prices.length }, sampleSize, "1Y"),
|
|
903
|
+
].filter((note) => note != null);
|
|
898
904
|
// A bare symbol names no exchange; its quote says where it lists, which sets when its daily close is taken.
|
|
899
905
|
const [leftQuote, rightQuote] = await Promise.all([leftListing!, rightListing!].map((listing) => loadListingQuote(services.dataProvider, listing)));
|
|
900
906
|
const sessionNote = mixedSessionCloseNote(
|
|
@@ -914,6 +920,7 @@ async function runCorrelation(rawArgs: string[], ctx: Parameters<CliCommandDef["
|
|
|
914
920
|
...listingReadNotes(leftListing!), ...listingReadNotes(rightListing!),
|
|
915
921
|
...coinListingNotes(leftListing!, leftQuote), ...coinListingNotes(rightListing!, rightQuote),
|
|
916
922
|
...sessionNote ? [sessionNote] : [],
|
|
923
|
+
...seriesNotes,
|
|
917
924
|
];
|
|
918
925
|
ctx.printResult({
|
|
919
926
|
data: [{ left, right, samples: sampleSize, correlation }],
|