@gloom-sh/terminal 0.20.14 → 0.20.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/api-client/data.ts +13 -3
- package/src/api-client/index.ts +54 -0
- package/src/api-client/install-experiments.ts +8 -7
- package/src/api-client/paths.ts +2 -1
- package/src/api-client/product-waitlist.ts +63 -0
- package/src/api-client/request.ts +4 -2
- package/src/api-client/types/billing.ts +45 -0
- package/src/api-client/types/econ.ts +3 -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/cli/commands/fred-series.ts +3 -1
- package/src/cli/commands/market.ts +8 -4
- package/src/cli/commands/overview.ts +65 -13
- package/src/cli/commands/system.ts +29 -1
- package/src/cli/commands/ticker.ts +12 -5
- package/src/cli/csv-export.ts +73 -0
- 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 +29 -30
- package/src/cli/help.ts +5 -2
- package/src/cli/history-rows.ts +24 -0
- package/src/cli/index.ts +4 -0
- package/src/cli/options.ts +29 -1
- package/src/cli/pane-functions/catalog.ts +41 -4
- package/src/cli/pane-functions/function-help.ts +1 -1
- package/src/cli/pane-functions/headless.ts +70 -3
- package/src/cli/pane-functions/index.ts +4 -4
- package/src/cli/pane-functions/resolver.ts +43 -0
- package/src/cli/pane-functions/screenshot-bridge.ts +4 -2
- package/src/cli/pane-functions/screenshot-payload.ts +3 -0
- package/src/cli/report-tables.ts +37 -8
- package/src/cli/result.ts +3 -6
- package/src/cli/shot-temp-dir.ts +30 -0
- package/src/cli/suffixed-listing-rows.ts +11 -0
- package/src/components/chart/composite/composite-chart.tsx +3 -3
- package/src/components/chart/composite/legend.tsx +37 -7
- 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 +16 -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 +6 -2
- package/src/components/layout/shell/index.tsx +5 -1
- package/src/components/layout/shell/ticker-link-menu.ts +12 -9
- 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/data-table/display-columns.ts +19 -0
- package/src/components/ui/data-table/hooks.ts +2 -3
- package/src/components/ui/data-table/index.tsx +43 -9
- package/src/components/ui/data-table/types.ts +21 -0
- package/src/components/ui/data-table/visible-range.ts +11 -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/i18n/es.ts +38 -0
- package/src/i18n/ja.ts +38 -0
- package/src/i18n/ko.ts +38 -0
- package/src/i18n/zh-cn.ts +38 -0
- package/src/i18n/zh-tw.ts +38 -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/index-level.ts +19 -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/payment-recovery-row.tsx +97 -0
- package/src/plugins/builtin/account-management/yearly-plan-row.tsx +359 -0
- package/src/plugins/builtin/awards/pane.tsx +12 -10
- package/src/plugins/builtin/changelog/index.tsx +6 -44
- package/src/plugins/builtin/changelog/versions.ts +17 -68
- package/src/plugins/builtin/chart-composer/pane.tsx +4 -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/cpi/pane.tsx +1 -1
- package/src/plugins/builtin/credit-conditions/series.ts +2 -2
- package/src/plugins/builtin/debt-maturities/model.ts +1 -1
- package/src/plugins/builtin/earnings/board-model.ts +12 -0
- package/src/plugins/builtin/earnings/board-table.ts +8 -5
- package/src/plugins/builtin/earnings/board.tsx +38 -18
- package/src/plugins/builtin/earnings/highlight.ts +47 -0
- package/src/plugins/builtin/earnings/history-table.ts +1 -1
- package/src/plugins/builtin/earnings/index.tsx +1 -1
- package/src/plugins/builtin/earnings-calls/pane.tsx +2 -2
- package/src/plugins/builtin/econ/calendar-model.ts +2 -0
- package/src/plugins/builtin/econ/fred-catalog.ts +1 -256
- package/src/plugins/builtin/econ-statistics/cache.ts +1 -1
- package/src/plugins/builtin/econ-statistics/client.ts +11 -10
- package/src/plugins/builtin/econ-statistics/detail.tsx +1 -0
- package/src/plugins/builtin/econ-statistics/headless.ts +42 -6
- package/src/plugins/builtin/econ-statistics/index.tsx +1 -0
- package/src/plugins/builtin/econ-statistics/pane.tsx +7 -2
- package/src/plugins/builtin/econ-statistics/stats.ts +2 -1
- package/src/plugins/builtin/econ-statistics/view.ts +9 -3
- 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/model.ts +6 -4
- 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/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/render.ts +8 -1
- package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +176 -17
- package/src/plugins/builtin/portfolio-list/pane/groups.tsx +220 -0
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +90 -15
- package/src/plugins/builtin/portfolio-list/table.tsx +13 -1
- 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/fred-catalog.ts +256 -0
- package/src/plugins/builtin/shared/headless-options.ts +1 -1
- package/src/plugins/builtin/shared/series-cache.ts +3 -0
- package/src/plugins/builtin/shared/series-detail-chart.tsx +3 -0
- package/src/plugins/builtin/short-interest/watch-pane.tsx +7 -7
- 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/model.ts +16 -0
- package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +8 -4
- 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 +254 -34
- package/src/plugins/builtin/ticker-detail/overview/model.ts +7 -3
- 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/plugins/builtin/time-sales/headless.ts +4 -1
- package/src/plugins/builtin/time-sales/pane.tsx +2 -0
- package/src/plugins/builtin/time-sales/window.ts +12 -0
- package/src/plugins/builtin/treasury-auctions/client.ts +4 -0
- package/src/plugins/builtin/treasury-auctions/treasury-direct.ts +2 -0
- package/src/plugins/builtin/treasury-daily/client.ts +23 -11
- package/src/portfolio/column-values.ts +20 -8
- 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/styles.css +7 -0
- package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +2 -0
- package/src/sources/gloomberb-cloud/fred-publisher.ts +25 -0
- package/src/sources/gloomberb-cloud/fred-series.ts +1 -1
- 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/time-series/base-series.ts +3 -0
- package/src/time-series/chart-seed.ts +1 -1
- package/src/time-series/financial-period-coverage.ts +4 -12
- package/src/time-series/ice-credit.ts +1 -0
- package/src/time-series/parsed-history-cache.ts +1 -1
- package/src/time-series/resolve.ts +1 -1
- package/src/time-series/types.ts +1 -0
- package/src/time-series/use-chart-resolution.ts +6 -1
- package/src/types/config.ts +32 -0
- package/src/types/headless.ts +9 -2
- 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/utils/async-deadline.ts +2 -2
- package/src/utils/csv.ts +44 -5
- package/src/utils/futures-generic.ts +3 -0
- package/src/utils/throttled-fetch.ts +15 -1
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
import type { apiClient } from "../../../../api-client";
|
|
3
|
+
import { isEmailVerificationRequired, type WaitlistProduct, type WaitlistState } from "../../../../api-client/product-waitlist";
|
|
4
|
+
import { errorMessage } from "../../../../utils/errors";
|
|
5
|
+
|
|
6
|
+
/** The waitlist calls the tab makes; tests hand it their own. */
|
|
7
|
+
export type WaitlistClient = Pick<typeof apiClient, "getWaitlist" | "joinWaitlist" | "leaveWaitlist">;
|
|
8
|
+
|
|
9
|
+
export interface ProductWaitlist {
|
|
10
|
+
/** Whether the signed-in account is on the list; undefined until its read answers, or signed out. */
|
|
11
|
+
joined: boolean | undefined;
|
|
12
|
+
/** The account's place is being read. */
|
|
13
|
+
loading: boolean;
|
|
14
|
+
/** Why the read failed; null otherwise. */
|
|
15
|
+
error: string | null;
|
|
16
|
+
/**
|
|
17
|
+
* The service refused the account because its address is not verified: its
|
|
18
|
+
* place cannot be read or changed until it is. Not an error to retry.
|
|
19
|
+
*/
|
|
20
|
+
unverified: boolean;
|
|
21
|
+
/** A join or a leave on its way. */
|
|
22
|
+
pending: "join" | "leave" | null;
|
|
23
|
+
/** Reads the account's place again. */
|
|
24
|
+
retry(): void;
|
|
25
|
+
/**
|
|
26
|
+
* Joins or leaves for `account`, the one the person decided as. Nothing is
|
|
27
|
+
* sent when another account holds the session by now, and an answer that
|
|
28
|
+
* lands after the account changed is not shown: null in both cases.
|
|
29
|
+
*/
|
|
30
|
+
change(joined: boolean, account: string): Promise<WaitlistState | null>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface Snapshot {
|
|
34
|
+
account: string | null;
|
|
35
|
+
joined: boolean | undefined;
|
|
36
|
+
error: string | null;
|
|
37
|
+
unverified: boolean;
|
|
38
|
+
pending: "join" | "leave" | null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function fresh(account: string | null): Snapshot {
|
|
42
|
+
return { account, joined: undefined, error: null, unverified: false, pending: null };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The signed-in account's place on a product's waitlist. Everything is the
|
|
47
|
+
* account's: a sign-in, a sign-out or another account starts from nothing at
|
|
48
|
+
* once, and no answer for the account that left is shown for the next one.
|
|
49
|
+
* A read that was already out when a join or a leave began is dropped, so it
|
|
50
|
+
* cannot put back the state from before the change. `account` is null for an
|
|
51
|
+
* account the app already knows is unverified: nothing is sent for it.
|
|
52
|
+
*/
|
|
53
|
+
export function useProductWaitlist(client: WaitlistClient, product: WaitlistProduct, account: string | null): ProductWaitlist {
|
|
54
|
+
const [stored, setStored] = useState<Snapshot>(() => fresh(account));
|
|
55
|
+
const [reads, setReads] = useState(0);
|
|
56
|
+
const accountRef = useRef(account);
|
|
57
|
+
accountRef.current = account;
|
|
58
|
+
// Bumped by every change: a read that began before it answers too late.
|
|
59
|
+
const changes = useRef(0);
|
|
60
|
+
// The account a change is on its way for; a second press waits for it.
|
|
61
|
+
const changing = useRef<string | null>(null);
|
|
62
|
+
|
|
63
|
+
const snapshot = stored.account === account ? stored : fresh(account);
|
|
64
|
+
if (snapshot !== stored) setStored(snapshot);
|
|
65
|
+
|
|
66
|
+
const update = useCallback((forAccount: string, patch: Partial<Snapshot>) => {
|
|
67
|
+
setStored((current) => (current.account === forAccount ? { ...current, ...patch } : current));
|
|
68
|
+
}, []);
|
|
69
|
+
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
if (!account) return;
|
|
72
|
+
let live = true;
|
|
73
|
+
const since = changes.current;
|
|
74
|
+
const current = () => live && accountRef.current === account && changes.current === since;
|
|
75
|
+
client.getWaitlist(product).then((state) => {
|
|
76
|
+
if (current()) update(account, { joined: state.joined, error: null, unverified: false });
|
|
77
|
+
}, (error: unknown) => {
|
|
78
|
+
if (!current()) return;
|
|
79
|
+
// Refused for an unverified address, the place is unknown again, not the last one read.
|
|
80
|
+
update(account, isEmailVerificationRequired(error) ? { joined: undefined, unverified: true } : { error: errorMessage(error) });
|
|
81
|
+
});
|
|
82
|
+
return () => { live = false; };
|
|
83
|
+
}, [account, client, product, reads, update]);
|
|
84
|
+
|
|
85
|
+
const retry = useCallback(() => {
|
|
86
|
+
if (accountRef.current) update(accountRef.current, { error: null, unverified: false });
|
|
87
|
+
setReads((count) => count + 1);
|
|
88
|
+
}, [update]);
|
|
89
|
+
|
|
90
|
+
const change = useCallback(async (joined: boolean, forAccount: string): Promise<WaitlistState | null> => {
|
|
91
|
+
if (accountRef.current !== forAccount || changing.current === forAccount) return null;
|
|
92
|
+
changing.current = forAccount;
|
|
93
|
+
changes.current += 1;
|
|
94
|
+
update(forAccount, { pending: joined ? "join" : "leave" });
|
|
95
|
+
try {
|
|
96
|
+
const state = joined ? await client.joinWaitlist(product) : await client.leaveWaitlist(product);
|
|
97
|
+
if (accountRef.current !== forAccount) return null;
|
|
98
|
+
update(forAccount, { joined: state.joined, error: null, unverified: false, pending: null });
|
|
99
|
+
return state;
|
|
100
|
+
} catch (error) {
|
|
101
|
+
if (accountRef.current === forAccount) {
|
|
102
|
+
if (isEmailVerificationRequired(error)) {
|
|
103
|
+
// The service holds no answer for this account until it verifies: nothing to read again.
|
|
104
|
+
update(forAccount, { joined: undefined, unverified: true, pending: null });
|
|
105
|
+
} else {
|
|
106
|
+
update(forAccount, { pending: null });
|
|
107
|
+
// The read this change dropped is asked again, so the state is known.
|
|
108
|
+
setReads((count) => count + 1);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
throw error;
|
|
112
|
+
} finally {
|
|
113
|
+
if (changing.current === forAccount) changing.current = null;
|
|
114
|
+
}
|
|
115
|
+
}, [client, product, update]);
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
joined: snapshot.joined,
|
|
119
|
+
loading: !!account && snapshot.joined === undefined && snapshot.error === null && !snapshot.unverified,
|
|
120
|
+
error: snapshot.error,
|
|
121
|
+
unverified: snapshot.unverified,
|
|
122
|
+
pending: snapshot.pending,
|
|
123
|
+
retry,
|
|
124
|
+
change,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ADR_PAIR_TAB_ID } from "./adr-pair/model";
|
|
2
|
+
import { PHARMA_SIGNALS_TAB_ID } from "./pharma-signals/eligibility";
|
|
2
3
|
|
|
3
4
|
/** What the grouping reads of a research tab. */
|
|
4
5
|
export interface TickerResearchTabSummary {
|
|
@@ -23,9 +24,10 @@ interface TickerResearchGroupDef {
|
|
|
23
24
|
* Trade is Chart with the ticket beside it, and closing the ticket goes back
|
|
24
25
|
* to Chart (`ResearchTradeWorkspace`), so it is Chart's second view. ADR vs
|
|
25
26
|
* Home, the receipt's price against its home line, is the last of
|
|
26
|
-
* Financials.
|
|
27
|
-
*
|
|
28
|
-
*
|
|
27
|
+
* Financials. Signals, a drug developer's add-on waitlist, is the last of
|
|
28
|
+
* Events, beside its catalysts. Each shows only for some tickers, so each
|
|
29
|
+
* comes after the views every ticker has. A plugin's own tab is in no group:
|
|
30
|
+
* it gets its own top tab after these (`groupTickerResearchTabs`).
|
|
29
31
|
*/
|
|
30
32
|
const TICKER_RESEARCH_GROUPS: readonly TickerResearchGroupDef[] = [
|
|
31
33
|
{ id: "overview", name: "Overview", views: ["overview"] },
|
|
@@ -33,7 +35,7 @@ const TICKER_RESEARCH_GROUPS: readonly TickerResearchGroupDef[] = [
|
|
|
33
35
|
{ id: "financials", name: "Financials", views: ["financials", "revenue", "equity-diagnostic", "dividend-yield", ADR_PAIR_TAB_ID] },
|
|
34
36
|
{ id: "analysts", name: "Analysts", views: ["analyst-research", "earnings-calls"] },
|
|
35
37
|
{ id: "options", name: "Options", views: ["options"] },
|
|
36
|
-
{ id: "events", name: "Events", views: ["corporate-actions", "catalysts", "mna"] },
|
|
38
|
+
{ id: "events", name: "Events", views: ["corporate-actions", "catalysts", "mna", PHARMA_SIGNALS_TAB_ID] },
|
|
37
39
|
{ id: "filings", name: "Filings", views: ["sec", "filing-events", "risk-factors"] },
|
|
38
40
|
{ id: "ownership", name: "Ownership", views: ["holders", "insider", "thirteenf", "congress", "short-interest"] },
|
|
39
41
|
{ id: "people", name: "People", views: ["executives", "jobs", "hiring-momentum"] },
|
|
@@ -5,6 +5,8 @@ import { AdrPairResearchTab } from "./adr-pair/tab";
|
|
|
5
5
|
import { ADR_PAIR_TAB_ID } from "./adr-pair/model";
|
|
6
6
|
import { listingDepositaryPair } from "../../../market-data/depositary-pair";
|
|
7
7
|
import { hasStatementFinancials } from "./financials/model";
|
|
8
|
+
import { isPharmaSignalsListing, PHARMA_SIGNALS_TAB_ID } from "./pharma-signals/eligibility";
|
|
9
|
+
import { PharmaSignalsResearchTab } from "./pharma-signals/tab";
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* Tabs this module owns. They are registered through `setup()` like any other
|
|
@@ -36,4 +38,13 @@ export const TICKER_RESEARCH_BUILTIN_TABS: TickerResearchTabDef[] = [
|
|
|
36
38
|
component: AdrPairResearchTab,
|
|
37
39
|
isVisible: ({ financials }) => !!listingDepositaryPair(financials),
|
|
38
40
|
},
|
|
41
|
+
{
|
|
42
|
+
// A drug developer's add-on that is not built yet: a no-charge waitlist, on no other listing.
|
|
43
|
+
id: PHARMA_SIGNALS_TAB_ID,
|
|
44
|
+
name: "Signals",
|
|
45
|
+
order: 36,
|
|
46
|
+
component: PharmaSignalsResearchTab,
|
|
47
|
+
instruments: ["equity"],
|
|
48
|
+
isVisible: ({ financials, instrumentKind }) => isPharmaSignalsListing(instrumentKind, financials?.profile),
|
|
49
|
+
},
|
|
39
50
|
];
|
|
@@ -5,7 +5,7 @@ import type { TapeRange, TapeSnapshot } from "../../../api-client/tape";
|
|
|
5
5
|
import { fetchTape } from "./client";
|
|
6
6
|
import { newestFirst, quoteSpread, tapePrice, tapePriceDigits, tapeStatistics, tapeTimeKey } from "./model";
|
|
7
7
|
import { REPORT_ROWS } from "../shared/headless-options";
|
|
8
|
-
import { inTapeRange, normalizeTapeClock, parseTapeClock, servedWindow, sessionDay, tapeMoment, tapeWindowRange } from "./window";
|
|
8
|
+
import { inTapeRange, lastSessionNote, normalizeTapeClock, parseTapeClock, servedWindow, sessionDay, tapeMoment, tapeWindowRange } from "./window";
|
|
9
9
|
|
|
10
10
|
type Format = NonNullable<HeadlessPaneColumn["format"]>;
|
|
11
11
|
const fixedPrice = (digits: number): Format => (value) => tapePrice(typeof value === "number" ? value : null, digits);
|
|
@@ -109,6 +109,9 @@ export const timeSalesHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
|
109
109
|
const price = fixedPrice(tapePriceDigits(data.trades.map((row) => row.price)));
|
|
110
110
|
const trades = ordered(data.trades).slice(0, limit).map((row) => ({ ...row, conditions: row.conditions.join(" ") }));
|
|
111
111
|
const notes = windowed ? [...windowed.notes, ...listedNote(windowed.range, data.trades.length, trades.length)] : [];
|
|
112
|
+
const lastSession = lastSessionNote(data);
|
|
113
|
+
if (!windowed && lastSession) notes.unshift(lastSession);
|
|
114
|
+
if (!windowed && trades.length < data.trades.length) notes.push(`Listing the first ${trades.length} of ${data.trades.length} observed trades, newest first; --limit takes up to 1000.`);
|
|
112
115
|
// SIP prints, real-time or fifteen minutes delayed by entitlement, dated by the newest print.
|
|
113
116
|
const freshness = data.feed === "sip"
|
|
114
117
|
? { status: "live" as const, cadence: "daily" as const }
|
|
@@ -15,6 +15,7 @@ import { isCloudSessionRequired, useResearchCloudSession } from "../shared/resea
|
|
|
15
15
|
import { newestFirst, quoteKey, quoteSpread, stickyTapePriceDigits, tapeClockNewYork, tapeConditionWords, tapePrice, tapeQuantity, tapeStampNewYork, tapeStatistics, tapeTicks, tapeTime, tapeAfter, tapeMomentKey, tapeRowAtOrBefore, tapeVenue, tradeKey, type TapeDigits } from "./model";
|
|
16
16
|
import { usePinnedMoment } from "../../../components/use-pinned-moment";
|
|
17
17
|
import { useTape } from "./use-tape";
|
|
18
|
+
import { lastSessionNote } from "./window";
|
|
18
19
|
|
|
19
20
|
const TABS = [{ value: "trades", label: "Trades" }, { value: "quotes", label: "NBBO" }];
|
|
20
21
|
const TRADES: DataTableColumn[] = [
|
|
@@ -121,6 +122,7 @@ function TimeSalesView({ width, height, focused, symbol, exchange }: PaneProps &
|
|
|
121
122
|
...(pinnedBeforeTape ? [`The pinned moment is before this tape's first ${tab === "quotes" ? "quote" : "print"}, ${tapeStampNewYork(rowTime(rows.at(-1)!))}.`] : [])] });
|
|
122
123
|
usePaneStatusFooter({ registrationId: "time-sales:status", loading: resource.loading, error: resource.error,
|
|
123
124
|
info: data ? [...splitDelayedStatus({ id: "feed", quoteStatus: true, parts: [{ text: `${data.feed === "sip" ? "real-time" : "15m delayed"} · ${tapeStampNewYork(data.asOf)}`, tone: "muted" }] }),
|
|
125
|
+
...(lastSessionNote(data) ? [{ id: "last-session", parts: [{ text: lastSessionNote(data)!, tone: "muted" as const }] }] : []),
|
|
124
126
|
...(frozen ? [{ id: "paused", parts: [{ text: "paused", tone: "warning" as const }] }] : []),
|
|
125
127
|
...(!data.connected || resource.snapshotOnly ? [{ id: "snapshot", parts: [{ text: "snapshot", tone: "warning" as const }] }] : [])] : [] });
|
|
126
128
|
const quoteColumns = useMemo(() => dropColumnsToFit(QUOTES, width - 1, QUOTE_DROP_ORDER), [width]);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { TapeRange, TapeSnapshot } from "../../../api-client/tape";
|
|
2
|
+
import { isVenueTradingDay } from "../../../market-data/market/freshness";
|
|
2
3
|
import { formatUtcDayTime } from "../../../utils/utc-time";
|
|
3
4
|
import { tapeTimeKey } from "./model";
|
|
4
5
|
|
|
@@ -96,6 +97,17 @@ export function servedWindow(snapshot: Pick<TapeSnapshot, "session" | "generated
|
|
|
96
97
|
return { date, from, to: Math.min(close, cutoff), cutoff: cutoff < close, delayMinutes: Math.round(snapshot.delaySeconds / 60) };
|
|
97
98
|
}
|
|
98
99
|
|
|
100
|
+
export function lastSessionNote(snapshot: Pick<TapeSnapshot, "session" | "generatedAt" | "delaySeconds" | "asOf">): string | null {
|
|
101
|
+
const served = servedWindow(snapshot);
|
|
102
|
+
if (!served) return null;
|
|
103
|
+
const now = newYorkParts(Date.parse(snapshot.generatedAt));
|
|
104
|
+
const observedDay = snapshot.asOf ? newYorkParts(Date.parse(snapshot.asOf)).date : served.date;
|
|
105
|
+
if (observedDay > served.date) return null;
|
|
106
|
+
if (now.date <= served.date && served.cutoff) return null;
|
|
107
|
+
const closed = !isVenueTradingDay("NYSE", now.date) || now.seconds < SIP_OPEN || now.seconds >= SIP_CLOSE;
|
|
108
|
+
return `${closed ? "Market closed; last session" : "Last available session"} ${sessionDay(served.date)}.`;
|
|
109
|
+
}
|
|
110
|
+
|
|
99
111
|
/** What TAS serves, for a window it cannot read: `Fri 16 Oct 2026, 04:00:00 ET (08:00:00 UTC) to ...`. */
|
|
100
112
|
function servedWindowText(served: ServedWindow): string {
|
|
101
113
|
const end = served.cutoff ? `${tapeMoment(served.to)}, the feed cutoff${served.delayMinutes ? ` (${served.delayMinutes} min delayed)` : ""}` : tapeMoment(served.to);
|
|
@@ -66,9 +66,13 @@ export interface AuctionQuery {
|
|
|
66
66
|
pageSize?: number;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
// A query that has not answered in 15 s does not answer the second time
|
|
70
|
+
// either: the source stalls for a minute at a time. The board then stands on
|
|
71
|
+
// TreasuryDirect and the saved copy (cache.ts) at once, not after 48 s of retries.
|
|
69
72
|
const TREASURY_FETCH = createThrottledFetch({
|
|
70
73
|
requestsPerMinute: 20,
|
|
71
74
|
maxRetries: 2,
|
|
75
|
+
retryTimeouts: false,
|
|
72
76
|
timeoutMs: 15_000,
|
|
73
77
|
backoffBaseMs: 800,
|
|
74
78
|
defaultHeaders: { Accept: "application/json" },
|
|
@@ -22,9 +22,11 @@ export const DIRECT_LOOKBACK_DAYS = 60;
|
|
|
22
22
|
/** Announced auctions are listed days to two weeks ahead; a month leaves none out. */
|
|
23
23
|
const DIRECT_LOOKAHEAD_DAYS = 30;
|
|
24
24
|
|
|
25
|
+
// As Fiscal Data's (client.ts): a stalled search is not waited out twice more.
|
|
25
26
|
const DIRECT_FETCH = createThrottledFetch({
|
|
26
27
|
requestsPerMinute: 20,
|
|
27
28
|
maxRetries: 2,
|
|
29
|
+
retryTimeouts: false,
|
|
28
30
|
timeoutMs: 20_000,
|
|
29
31
|
backoffBaseMs: 800,
|
|
30
32
|
defaultHeaders: { Accept: "application/json" },
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { signalWithTimeout } from "../../../utils/async-deadline";
|
|
1
2
|
import { httpFetch } from "../../../utils/http-transport";
|
|
2
3
|
import { numericOrNull, scalarTextOrNull } from "../../../utils/guards";
|
|
3
4
|
import { cashLineLabel, type CashAccount, type DebtDay, type OperatingCash, type TgaClose } from "./model";
|
|
@@ -100,13 +101,21 @@ function parseDebtToPenny(payload: unknown): DebtDay[] {
|
|
|
100
101
|
.slice(0, DEBT_DAYS);
|
|
101
102
|
}
|
|
102
103
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
104
|
+
/**
|
|
105
|
+
* One statement read, bounded whoever asks: a caller's signal (a command's)
|
|
106
|
+
* ends it sooner, never later, so a source that does not answer is an error
|
|
107
|
+
* in seconds rather than whenever its gateway gives up.
|
|
108
|
+
*/
|
|
109
|
+
async function readJson(url: string, label: string, signal: AbortSignal | undefined, timeoutMs: number): Promise<unknown> {
|
|
110
|
+
const deadline = signalWithTimeout(signal, timeoutMs);
|
|
111
|
+
try {
|
|
112
|
+
const response = await httpFetch(url, { headers: { Accept: "application/json" }, signal: deadline });
|
|
113
|
+
if (!response.ok) throw new Error(`${label} request failed (${response.status})`);
|
|
114
|
+
return await response.json() as unknown;
|
|
115
|
+
} catch (error) {
|
|
116
|
+
if (deadline.aborted && !signal?.aborted) throw new Error(`${label} request timed out after ${Math.round(timeoutMs / 1000)} s`);
|
|
117
|
+
throw error;
|
|
118
|
+
}
|
|
110
119
|
}
|
|
111
120
|
|
|
112
121
|
/**
|
|
@@ -114,11 +123,14 @@ async function readJson(url: string, label: string, signal?: AbortSignal): Promi
|
|
|
114
123
|
* closing balance history unless `history` is off (a report that does not draw it).
|
|
115
124
|
* A history that cannot be read leaves the figures as they are.
|
|
116
125
|
*/
|
|
117
|
-
export async function fetchTreasuryDaily(
|
|
126
|
+
export async function fetchTreasuryDaily(
|
|
127
|
+
signal?: AbortSignal,
|
|
128
|
+
{ history = true, timeoutMs = FETCH_TIMEOUT_MS }: { history?: boolean; timeoutMs?: number } = {},
|
|
129
|
+
): Promise<TreasuryDaily> {
|
|
118
130
|
const [cash, debt, tga] = await Promise.all([
|
|
119
|
-
readJson(CASH_URL, "Treasury cash", signal),
|
|
120
|
-
readJson(DEBT_URL, "Treasury debt", signal),
|
|
121
|
-
history ? readJson(TGA_HISTORY_URL, "Treasury account history", signal).then(parseTgaHistory).then(
|
|
131
|
+
readJson(CASH_URL, "Treasury cash", signal, timeoutMs),
|
|
132
|
+
readJson(DEBT_URL, "Treasury debt", signal, timeoutMs),
|
|
133
|
+
history ? readJson(TGA_HISTORY_URL, "Treasury account history", signal, timeoutMs).then(parseTgaHistory).then(
|
|
122
134
|
(closes) => ({ closes }),
|
|
123
135
|
(error: unknown) => ({ closes: [] as TgaClose[], error: error instanceof Error ? error.message : String(error) }),
|
|
124
136
|
) : { closes: [] as TgaClose[] },
|
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
import { formatOptionTicker } from "../utils/options";
|
|
41
41
|
import { distributionHistory, forwardYieldMayHaveLapsed, lapsedDividend } from "../utils/forward-dividend";
|
|
42
42
|
import { classifyInstrumentType } from "../tickers/instrument-kind";
|
|
43
|
-
import { isIndexLevel, reportedQuoteVolume } from "../market-data/market/index-level";
|
|
43
|
+
import { isIndexLevel, quoteVolumeCurrency, reportedQuoteVolume } from "../market-data/market/index-level";
|
|
44
44
|
import { futuresQuoteFromSettle } from "../market-data/market/change-basis";
|
|
45
45
|
import { perpetualDisplaySymbol, perpetualListing } from "../tickers/perpetual-listing";
|
|
46
46
|
import { premiumToUnderlying, type PerpetualPremiumRow } from "../market-data/perpetual-premium";
|
|
@@ -692,9 +692,8 @@ export function getColumnValue(
|
|
|
692
692
|
return { text: volume != null ? formatCompact(volume, { fixedDecimals: true }) : MISSING_VALUE };
|
|
693
693
|
}
|
|
694
694
|
case "dollar_volume": {
|
|
695
|
-
const
|
|
696
|
-
|
|
697
|
-
return { text: formatCompact(toBaseQuote(displayQuote.price * volume), { fixedDecimals: true }) };
|
|
695
|
+
const traded = tradedValue(quote, displayQuote, toBaseQuote);
|
|
696
|
+
return { text: traded == null ? MISSING_VALUE : formatCompact(traded, { fixedDecimals: true }) };
|
|
698
697
|
}
|
|
699
698
|
case "range_52w": {
|
|
700
699
|
const position = fiftyTwoWeekPosition(displayQuote, quote);
|
|
@@ -869,6 +868,21 @@ export function getColumnValue(
|
|
|
869
868
|
}
|
|
870
869
|
}
|
|
871
870
|
|
|
871
|
+
/**
|
|
872
|
+
* The value a row's volume traded, in the base currency: shares or contracts at the price, or a coin's volume
|
|
873
|
+
* itself, which is already a value in its quote currency (quoteVolumeCurrency), never priced again.
|
|
874
|
+
*/
|
|
875
|
+
function tradedValue(
|
|
876
|
+
quote: Quote | null | undefined,
|
|
877
|
+
displayQuote: { price: number } | null | undefined,
|
|
878
|
+
toBaseQuote: (value: number) => number,
|
|
879
|
+
): number | null {
|
|
880
|
+
const volume = reportedQuoteVolume(quote);
|
|
881
|
+
if (volume == null) return null;
|
|
882
|
+
if (quoteVolumeCurrency(quote)) return toBaseQuote(volume);
|
|
883
|
+
return displayQuote ? toBaseQuote(displayQuote.price * volume) : null;
|
|
884
|
+
}
|
|
885
|
+
|
|
872
886
|
export function getSortValue(
|
|
873
887
|
col: ColumnConfig,
|
|
874
888
|
ticker: TickerRecord,
|
|
@@ -942,10 +956,8 @@ export function getSortValue(
|
|
|
942
956
|
return quote?.delisting ? null : headlineChangePercent(headlineQuote, quote) ?? null;
|
|
943
957
|
case "volume":
|
|
944
958
|
return reportedQuoteVolume(quote);
|
|
945
|
-
case "dollar_volume":
|
|
946
|
-
|
|
947
|
-
return displayQuote && volume != null ? toBaseQuote(displayQuote.price * volume) : null;
|
|
948
|
-
}
|
|
959
|
+
case "dollar_volume":
|
|
960
|
+
return tradedValue(quote, displayQuote, toBaseQuote);
|
|
949
961
|
case "range_52w":
|
|
950
962
|
return fiftyTwoWeekPosition(displayQuote, quote);
|
|
951
963
|
case "market_cap": {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AppConfig } from "../types/config";
|
|
2
2
|
import type { TickerMetadata, TickerPosition, TickerRecord } from "../types/ticker";
|
|
3
3
|
import { listingSuffixVenue, tickerHasListingSuffix } from "../sources/listing-symbols";
|
|
4
|
+
import { moveWatchlistGroupSymbols } from "./watchlist-groups";
|
|
4
5
|
import { canonicalExchange, parsePublicTickerKey, publicTickerKey } from "../utils/exchanges";
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -197,7 +198,8 @@ export async function mergeSavedSuffixedListings(
|
|
|
197
198
|
): Promise<{ tickers: TickerRecord[]; config: AppConfig; keptCustom: SuffixedListingMerge["keptCustom"] } | null> {
|
|
198
199
|
const merge = mergeSuffixedListings(tickers);
|
|
199
200
|
if (!merge) return null;
|
|
200
|
-
|
|
201
|
+
// Target weights and watchlist groups follow their rows to the listing's key.
|
|
202
|
+
const nextConfig = moveWatchlistGroupSymbols(moveTargetWeights(config, merge.moved), merge.moved);
|
|
201
203
|
if (merge.saves.length === 0 && nextConfig === config) return null;
|
|
202
204
|
if (nextConfig !== config) await save.config(nextConfig);
|
|
203
205
|
if (merge.saves.length > 0) await save.tickers(merge.saves);
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import type { AppConfig } from "../types/config";
|
|
2
|
+
import type { Watchlist, WatchlistGroup } from "../types/ticker";
|
|
3
|
+
import { parseCollectionRef } from "../team/collections";
|
|
4
|
+
import { isRecord } from "../utils/guards";
|
|
5
|
+
|
|
6
|
+
/** The longest name a group takes, so its header and the CLI's Group column stay readable. */
|
|
7
|
+
const MAX_GROUP_NAME_LENGTH = 40;
|
|
8
|
+
|
|
9
|
+
/** The section a list's tickers in no group show under; no group takes the name. */
|
|
10
|
+
export const UNGROUPED_LABEL = "Ungrouped";
|
|
11
|
+
|
|
12
|
+
const sameName = (left: string, right: string) => left.toLocaleLowerCase() === right.toLocaleLowerCase();
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A list's groups as they are kept: names trimmed, two names that differ only
|
|
16
|
+
* in case one group under the first's name, each symbol in the first group
|
|
17
|
+
* that lists it, and a group left with no symbol dropped. Undefined when none
|
|
18
|
+
* remain, so a list without groups saves and syncs as it did before groups.
|
|
19
|
+
* Reads anything (a pulled or hand-edited config) and keeps what is well formed.
|
|
20
|
+
*/
|
|
21
|
+
export function normalizeWatchlistGroups(value: unknown): WatchlistGroup[] | undefined {
|
|
22
|
+
if (!Array.isArray(value)) return undefined;
|
|
23
|
+
const groups: WatchlistGroup[] = [];
|
|
24
|
+
const placed = new Set<string>();
|
|
25
|
+
for (const entry of value) {
|
|
26
|
+
if (!isRecord(entry) || typeof entry.name !== "string" || !Array.isArray(entry.symbols)) continue;
|
|
27
|
+
const name = entry.name.trim();
|
|
28
|
+
if (!name) continue;
|
|
29
|
+
let group = groups.find((existing) => sameName(existing.name, name));
|
|
30
|
+
if (!group) {
|
|
31
|
+
group = { name, symbols: [] };
|
|
32
|
+
groups.push(group);
|
|
33
|
+
}
|
|
34
|
+
for (const symbol of entry.symbols) {
|
|
35
|
+
if (typeof symbol !== "string" || !symbol.trim() || placed.has(symbol)) continue;
|
|
36
|
+
placed.add(symbol);
|
|
37
|
+
group.symbols.push(symbol);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const kept = groups.filter((group) => group.symbols.length > 0);
|
|
41
|
+
return kept.length > 0 ? kept : undefined;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** A list's groups, none for a list without; a config pulled from another device is read as it came, so this checks it. */
|
|
45
|
+
export function watchlistGroups(watchlist: Pick<Watchlist, "groups"> | null | undefined): WatchlistGroup[] {
|
|
46
|
+
return normalizeWatchlistGroups(watchlist?.groups) ?? [];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** The name of the group a ticker of the list is in, by its key; null when it is in none. */
|
|
50
|
+
export function watchlistGroupOf(watchlist: Pick<Watchlist, "groups"> | null | undefined, symbol: string): string | null {
|
|
51
|
+
return watchlistGroups(watchlist).find((group) => group.symbols.includes(symbol))?.name ?? null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Whether the list takes groups: a personal one. A team list is shared with
|
|
56
|
+
* everyone on the team and its items are the server's, so it has none.
|
|
57
|
+
*/
|
|
58
|
+
export function watchlistTakesGroups(watchlist: Pick<Watchlist, "id" | "teamId">): boolean {
|
|
59
|
+
return !watchlist.teamId && parseCollectionRef(watchlist.id).scope !== "team";
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** A group name as typed, trimmed; throws saying why one cannot be used. */
|
|
63
|
+
export function parseWatchlistGroupName(input: string): string {
|
|
64
|
+
const name = input.trim().replace(/\s+/g, " ");
|
|
65
|
+
if (!name) throw new Error("A group needs a name.");
|
|
66
|
+
if (name.length > MAX_GROUP_NAME_LENGTH) throw new Error(`A group name is at most ${MAX_GROUP_NAME_LENGTH} characters.`);
|
|
67
|
+
if (sameName(name, UNGROUPED_LABEL)) throw new Error(`"${UNGROUPED_LABEL}" is where tickers in no group show; name the group something else.`);
|
|
68
|
+
return name;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function withGroups(config: AppConfig, watchlistId: string, groups: readonly WatchlistGroup[]): AppConfig {
|
|
72
|
+
const kept = normalizeWatchlistGroups(groups);
|
|
73
|
+
return {
|
|
74
|
+
...config,
|
|
75
|
+
watchlists: config.watchlists.map((watchlist) => {
|
|
76
|
+
if (watchlist.id !== watchlistId) return watchlist;
|
|
77
|
+
const { groups: _groups, ...rest } = watchlist;
|
|
78
|
+
return kept ? { ...rest, groups: kept } : rest;
|
|
79
|
+
}),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Puts `symbols` (tickers' keys) in the list's group `group` names, matched in
|
|
85
|
+
* any case, taking each out of any other group of the list; a new group goes
|
|
86
|
+
* last. `null` takes them out of their group. `moved` names the symbols whose
|
|
87
|
+
* group changed, and `group` is the name they are under now; the config comes
|
|
88
|
+
* back as it was when none moved.
|
|
89
|
+
*/
|
|
90
|
+
export function setWatchlistGroup(
|
|
91
|
+
config: AppConfig,
|
|
92
|
+
watchlistId: string,
|
|
93
|
+
symbols: readonly string[],
|
|
94
|
+
group: string | null,
|
|
95
|
+
): { config: AppConfig; group: string | null; moved: string[] } {
|
|
96
|
+
const watchlist = config.watchlists.find((entry) => entry.id === watchlistId);
|
|
97
|
+
if (!watchlist) throw new Error("Watchlist not found.");
|
|
98
|
+
const groups = watchlistGroups(watchlist);
|
|
99
|
+
const target = group == null ? null : groups.find((entry) => sameName(entry.name, group))?.name ?? parseWatchlistGroupName(group);
|
|
100
|
+
const moving = [...new Set(symbols)].filter((symbol) => watchlistGroupOf(watchlist, symbol) !== target);
|
|
101
|
+
if (moving.length === 0) return { config, group: target, moved: [] };
|
|
102
|
+
const next = groups.map((entry) => ({ name: entry.name, symbols: entry.symbols.filter((symbol) => !moving.includes(symbol)) }));
|
|
103
|
+
if (target != null) {
|
|
104
|
+
const existing = next.find((entry) => entry.name === target);
|
|
105
|
+
if (existing) existing.symbols.push(...moving);
|
|
106
|
+
else next.push({ name: target, symbols: [...moving] });
|
|
107
|
+
}
|
|
108
|
+
return { config: withGroups(config, watchlistId, next), group: target, moved: moving };
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** The list's groups without `symbols`, tickers that left the list: one added back later starts in no group. */
|
|
112
|
+
export function withoutWatchlistGroupSymbols(config: AppConfig, watchlistId: string, symbols: readonly string[]): AppConfig {
|
|
113
|
+
const watchlist = config.watchlists.find((entry) => entry.id === watchlistId);
|
|
114
|
+
const groups = watchlistGroups(watchlist);
|
|
115
|
+
if (!groups.some((group) => group.symbols.some((symbol) => symbols.includes(symbol)))) return config;
|
|
116
|
+
return withGroups(config, watchlistId, groups.map((group) => ({ ...group, symbols: group.symbols.filter((symbol) => !symbols.includes(symbol)) })));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* The config without group symbols whose ticker is loaded and no longer on
|
|
121
|
+
* the list: taken off it some other way (the command bar, another device, an
|
|
122
|
+
* older build), so one added back later starts in no group. A symbol with no
|
|
123
|
+
* loaded row is kept: a pull may not have written it yet, or its row did not
|
|
124
|
+
* read, and a symbol with no row shows nowhere anyway.
|
|
125
|
+
*/
|
|
126
|
+
export function withoutStaleWatchlistGroupSymbols(
|
|
127
|
+
config: AppConfig,
|
|
128
|
+
tickers: Iterable<{ metadata: { ticker: string; watchlists: readonly string[] } }>,
|
|
129
|
+
): AppConfig {
|
|
130
|
+
if (!config.watchlists.some((watchlist) => watchlist.groups)) return config;
|
|
131
|
+
const listsOf = new Map<string, readonly string[]>();
|
|
132
|
+
for (const ticker of tickers) listsOf.set(ticker.metadata.ticker, ticker.metadata.watchlists);
|
|
133
|
+
let next = config;
|
|
134
|
+
for (const watchlist of config.watchlists) {
|
|
135
|
+
const stale = watchlistGroups(watchlist).flatMap((group) => group.symbols.filter((symbol) => {
|
|
136
|
+
const lists = listsOf.get(symbol);
|
|
137
|
+
return lists != null && !lists.includes(watchlist.id);
|
|
138
|
+
}));
|
|
139
|
+
if (stale.length > 0) next = withoutWatchlistGroupSymbols(next, watchlist.id, stale);
|
|
140
|
+
}
|
|
141
|
+
return next;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Names a group of the list, matched in any case, `to` instead. A name another
|
|
146
|
+
* group has merges the two, where the first of them was.
|
|
147
|
+
*/
|
|
148
|
+
export function renameWatchlistGroup(config: AppConfig, watchlistId: string, from: string, to: string): AppConfig {
|
|
149
|
+
const watchlist = config.watchlists.find((entry) => entry.id === watchlistId);
|
|
150
|
+
const groups = watchlistGroups(watchlist);
|
|
151
|
+
const renamed = parseWatchlistGroupName(to);
|
|
152
|
+
if (!groups.some((group) => sameName(group.name, from))) throw new Error(`"${watchlist?.name ?? watchlistId}" has no group "${from}".`);
|
|
153
|
+
return withGroups(config, watchlistId, groups.map((group) => (sameName(group.name, from) ? { ...group, name: renamed } : group)));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Group symbols saved under an old key moved to their listing's key
|
|
158
|
+
* (`mergeSuffixedListings`: GARAN.IS into GARAN:BIST), as target weights are.
|
|
159
|
+
* A listing already in a group keeps that group.
|
|
160
|
+
*/
|
|
161
|
+
export function moveWatchlistGroupSymbols(config: AppConfig, moved: ReadonlyMap<string, string>): AppConfig {
|
|
162
|
+
let changed = false;
|
|
163
|
+
const watchlists = config.watchlists.map((watchlist) => {
|
|
164
|
+
const groups = watchlistGroups(watchlist);
|
|
165
|
+
if (!groups.some((group) => group.symbols.some((symbol) => moved.has(symbol)))) return watchlist;
|
|
166
|
+
changed = true;
|
|
167
|
+
const grouped = new Set(groups.flatMap((group) => group.symbols));
|
|
168
|
+
const next = normalizeWatchlistGroups(groups.map((group) => ({
|
|
169
|
+
...group,
|
|
170
|
+
symbols: group.symbols.flatMap((symbol) => {
|
|
171
|
+
const to = moved.get(symbol);
|
|
172
|
+
return to == null ? [symbol] : grouped.has(to) ? [] : [to];
|
|
173
|
+
}),
|
|
174
|
+
})));
|
|
175
|
+
const { groups: _groups, ...rest } = watchlist;
|
|
176
|
+
return next ? { ...rest, groups: next } : rest;
|
|
177
|
+
});
|
|
178
|
+
return changed ? { ...config, watchlists } : config;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export interface WatchlistSection<T> {
|
|
182
|
+
/** The group's name; null for the tickers in no group. */
|
|
183
|
+
name: string | null;
|
|
184
|
+
items: T[];
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Items of a list under their sections, each section in the order the items
|
|
189
|
+
* come: every group that holds one, in the list's order, then the items in no
|
|
190
|
+
* group. Null when no item is in a group, so a list without groups shows as it
|
|
191
|
+
* always has.
|
|
192
|
+
*/
|
|
193
|
+
export function sectionWatchlistItems<T>(
|
|
194
|
+
groups: readonly WatchlistGroup[],
|
|
195
|
+
items: readonly T[],
|
|
196
|
+
keyOf: (item: T) => string,
|
|
197
|
+
): WatchlistSection<T>[] | null {
|
|
198
|
+
const groupOf = new Map<string, number>();
|
|
199
|
+
groups.forEach((group, index) => group.symbols.forEach((symbol) => groupOf.set(symbol, index)));
|
|
200
|
+
const grouped: T[][] = groups.map(() => []);
|
|
201
|
+
const ungrouped: T[] = [];
|
|
202
|
+
for (const item of items) {
|
|
203
|
+
const index = groupOf.get(keyOf(item));
|
|
204
|
+
if (index == null) ungrouped.push(item);
|
|
205
|
+
else grouped[index]!.push(item);
|
|
206
|
+
}
|
|
207
|
+
if (ungrouped.length === items.length) return null;
|
|
208
|
+
return [
|
|
209
|
+
...groups.flatMap((group, index) => grouped[index]!.length > 0 ? [{ name: group.name, items: grouped[index]! }] : []),
|
|
210
|
+
...ungrouped.length > 0 ? [{ name: null, items: ungrouped }] : [],
|
|
211
|
+
];
|
|
212
|
+
}
|
|
@@ -6,7 +6,8 @@ import { usePluginAppActions, usePluginTickerActions } from "../plugins/runtime"
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Shared Enter routing for panes that publish a cursor symbol: reuse the Ticker Research pane
|
|
9
|
-
* already bound to this one instead of stacking another pane on
|
|
9
|
+
* already bound to this one, or a pinned one the layout has, instead of stacking another pane on
|
|
10
|
+
* top of it (`resolveTickerActivation`).
|
|
10
11
|
*/
|
|
11
12
|
export function useTickerSourceActivate(): (
|
|
12
13
|
symbol: string,
|
|
@@ -27,6 +28,7 @@ export function useTickerSourceActivate(): (
|
|
|
27
28
|
floating: options?.floating ?? true,
|
|
28
29
|
forceNewPane: options?.newPane,
|
|
29
30
|
paneType: TICKER_RESEARCH_PANE_ID,
|
|
31
|
+
...(activation.reusePaneId ? { reusePaneId: activation.reusePaneId } : {}),
|
|
30
32
|
});
|
|
31
33
|
}, [focusPane, paneId, pinTicker, stateRef]);
|
|
32
34
|
}
|
|
@@ -319,6 +319,13 @@ button, [data-gloom-interactive="true"] { cursor: pointer; }
|
|
|
319
319
|
[data-gloom-role="status-bar"] span {
|
|
320
320
|
line-height: var(--cell-h);
|
|
321
321
|
}
|
|
322
|
+
/* The returning-user strip under the header: one row of shell chrome, ruled off from the layout. */
|
|
323
|
+
[data-gloom-role="since-last-visit"] {
|
|
324
|
+
flex: none;
|
|
325
|
+
align-items: center;
|
|
326
|
+
border-bottom: 1px solid var(--gloom-hairline);
|
|
327
|
+
font-size: var(--gloom-type-ui);
|
|
328
|
+
}
|
|
322
329
|
[data-gloom-role="pane-body"] {
|
|
323
330
|
overflow: hidden;
|
|
324
331
|
}
|
|
@@ -201,6 +201,8 @@ function installShotHttpFetchTransport(): void {
|
|
|
201
201
|
method: "POST",
|
|
202
202
|
headers: { "Content-Type": "application/json" },
|
|
203
203
|
body: JSON.stringify(await toRequestEnvelope(url, init)),
|
|
204
|
+
// A pane's own deadline ends the read here as in the app, not when the Bun side gives up.
|
|
205
|
+
signal: init?.signal ?? null,
|
|
204
206
|
});
|
|
205
207
|
const result = await response.json() as { ok: boolean; error?: string; data?: HttpProxyResponseEnvelope };
|
|
206
208
|
if (!result.ok || !result.data) throw new Error(result.error ?? `Request failed: ${url}`);
|