gloomberb 0.20.8 → 0.20.10
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/auth.ts +6 -0
- package/src/api-client/data.ts +1 -0
- package/src/api-client/earnings.ts +15 -0
- package/src/api-client/futures-curve.ts +5 -1
- package/src/api-client/index.ts +14 -3
- package/src/api-client/types/account.ts +10 -0
- package/src/api-client/types/billing.ts +10 -0
- package/src/api-client/types/econ.ts +19 -7
- package/src/api-client/types/market.ts +7 -0
- package/src/api-client/types/screener.ts +2 -0
- package/src/cli/commands/market.ts +18 -8
- package/src/cli/commands/overview.ts +28 -7
- package/src/cli/commands/ticker.ts +40 -15
- package/src/cli/desktop-pane-shot.ts +39 -0
- package/src/cli/errors.ts +20 -3
- package/src/cli/fx-pair.ts +11 -2
- package/src/cli/history-rows.ts +34 -3
- package/src/cli/index.ts +1 -1
- package/src/cli/listing-arg.ts +51 -13
- package/src/cli/pane-functions/data.ts +3 -2
- package/src/cli/pane-functions/headless.ts +5 -2
- package/src/cli/pane-functions/index.ts +1 -0
- package/src/cli/pane-functions/resolver.ts +2 -1
- package/src/cli/pane-functions/screenshot-assessment.ts +73 -5
- package/src/cli/pane-functions/screenshot-types.ts +4 -0
- package/src/cli/symbol-cells.ts +6 -0
- package/src/cli/symbol-list.ts +14 -6
- package/src/cli/symbol-rows.ts +12 -5
- package/src/components/chart/composite/chart-layout.ts +7 -4
- package/src/components/chart/composite/composite-chart.tsx +6 -16
- package/src/components/chart/composite/toolbar.tsx +258 -82
- package/src/components/chart/composite/use-composite-chart-keyboard.ts +5 -6
- package/src/components/command-bar/list/model.ts +13 -0
- package/src/components/command-bar/routes/ticker-search/actions.ts +2 -0
- package/src/components/command-bar/routes/ticker-search/results.ts +15 -8
- package/src/components/command-bar/surface/index.tsx +10 -5
- package/src/components/command-bar/workflow/alert.ts +21 -7
- package/src/components/data-table/table-pane.ts +3 -1
- package/src/components/layout/pane/footer/model.ts +26 -1
- package/src/components/metric-treemap/heat-surface.tsx +2 -1
- package/src/components/metric-treemap/index.tsx +3 -2
- package/src/components/ui/confirm-dialog.tsx +253 -7
- package/src/components/ui/data-table/index.tsx +1 -1
- package/src/components/ui/data-table/types.ts +7 -0
- package/src/components/ui/list-view.tsx +4 -3
- package/src/components/ui/page-stack-view.tsx +24 -6
- package/src/components/ui/status.tsx +9 -6
- package/src/docs/snapshot.json +36 -0
- package/src/i18n/es.ts +12 -0
- package/src/i18n/ja.ts +12 -0
- package/src/i18n/ko.ts +12 -0
- package/src/i18n/zh-cn.ts +12 -0
- package/src/i18n/zh-tw.ts +12 -0
- package/src/market-data/futures-roll-returns.ts +226 -0
- package/src/market-data/fx-closes.ts +14 -2
- package/src/market-data/market/change-basis.ts +35 -1
- package/src/market-data/market/session-close-note.ts +41 -4
- package/src/market-data/market/status.ts +37 -0
- package/src/market-data/performance.ts +4 -1
- package/src/market-data/quotes/listing-enterprise-value.ts +8 -4
- package/src/market-data/quotes/live-valuation.ts +25 -2
- package/src/market-data/realized-volatility.ts +3 -0
- package/src/market-data/us-bond-market.ts +115 -0
- package/src/plugins/builtin/account-management/invite-row.tsx +54 -0
- package/src/plugins/builtin/account-management/keyboard.ts +3 -0
- package/src/plugins/builtin/account-management/model.ts +1 -0
- package/src/plugins/builtin/account-management/pane.tsx +51 -5
- package/src/plugins/builtin/account-management/trial-cancel.ts +32 -7
- package/src/plugins/builtin/backtest/client.ts +9 -2
- package/src/plugins/builtin/backtest/pane.tsx +1 -1
- package/src/plugins/builtin/backtest/report.ts +22 -6
- package/src/plugins/builtin/backtest/window.ts +17 -9
- package/src/plugins/builtin/cloud/askg/pane-session.ts +94 -0
- package/src/plugins/builtin/cloud/askg/pane.tsx +40 -83
- package/src/plugins/builtin/congress-trades/pane.tsx +8 -2
- package/src/plugins/builtin/correlation/compute.ts +4 -3
- package/src/plugins/builtin/correlation/headless.ts +6 -2
- package/src/plugins/builtin/correlation/index.tsx +7 -3
- package/src/plugins/builtin/correlation/matrix/model.ts +15 -1
- package/src/plugins/builtin/correlation/relationship/model.ts +15 -1
- package/src/plugins/builtin/correlation/relationship/pane.tsx +4 -2
- package/src/plugins/builtin/earnings/board-model.ts +33 -0
- package/src/plugins/builtin/earnings/board-table.ts +50 -11
- package/src/plugins/builtin/earnings/board.tsx +29 -13
- package/src/plugins/builtin/earnings/calendar.tsx +15 -3
- package/src/plugins/builtin/earnings/client.ts +4 -1
- package/src/plugins/builtin/earnings/headless.ts +27 -14
- package/src/plugins/builtin/econ/calendar-source.ts +3 -0
- package/src/plugins/builtin/futures-curve/headless.ts +4 -1
- package/src/plugins/builtin/futures-curve/model.ts +24 -0
- package/src/plugins/builtin/help/index.tsx +1 -1
- package/src/plugins/builtin/ipo-calendar/model.ts +3 -3
- package/src/plugins/builtin/iv-history/headless.ts +12 -10
- package/src/plugins/builtin/kelly-sizer/headless.ts +2 -2
- package/src/plugins/builtin/kelly-sizer/history.ts +10 -3
- package/src/plugins/builtin/kelly-sizer/pane.tsx +2 -2
- package/src/plugins/builtin/kelly-sizer/sections.tsx +1 -1
- package/src/plugins/builtin/macro-day/headless.ts +15 -5
- package/src/plugins/builtin/macro-day/model.ts +17 -4
- package/src/plugins/builtin/macro-day/releases.ts +36 -15
- package/src/plugins/builtin/market-halts/model.ts +3 -2
- package/src/plugins/builtin/market-movers/headless.ts +2 -1
- package/src/plugins/builtin/market-movers/index.tsx +3 -2
- package/src/plugins/builtin/market-movers/model.ts +75 -22
- package/src/plugins/builtin/market-movers/screener.ts +2 -1
- package/src/plugins/builtin/market-movers/table.ts +7 -5
- package/src/plugins/builtin/pe-band/model.ts +4 -0
- package/src/plugins/builtin/portfolio-list/cell-version.ts +4 -4
- package/src/plugins/builtin/portfolio-list/cli/render.ts +9 -4
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +2 -1
- package/src/plugins/builtin/portfolio-list/summary/index.tsx +24 -7
- package/src/plugins/builtin/portfolio-list/summary/totals.ts +40 -11
- package/src/plugins/builtin/portfolio-list/table.tsx +13 -1
- package/src/plugins/builtin/realized-vol/headless.ts +11 -6
- package/src/plugins/builtin/realized-vol/model.ts +14 -6
- package/src/plugins/builtin/realized-vol/pane.tsx +2 -1
- package/src/plugins/builtin/realized-vol/settings.ts +2 -1
- package/src/plugins/builtin/research/analyst-headless.ts +9 -1
- package/src/plugins/builtin/research/analyst-pane.tsx +10 -4
- package/src/plugins/builtin/research/client.ts +25 -1
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +2 -1
- package/src/plugins/builtin/research/event-model.ts +3 -13
- package/src/plugins/builtin/research/event-sources.ts +3 -1
- package/src/plugins/builtin/seasonality/client.ts +66 -17
- package/src/plugins/builtin/seasonality/headless.ts +7 -2
- package/src/plugins/builtin/seasonality/model.ts +12 -3
- package/src/plugins/builtin/seasonality/pane.tsx +4 -2
- package/src/plugins/builtin/shared/use-quote-board.ts +28 -6
- package/src/plugins/builtin/short-interest/headless.ts +2 -0
- package/src/plugins/builtin/short-interest/publications-headless.ts +2 -0
- package/src/plugins/builtin/short-interest/watch-headless.ts +1 -0
- package/src/plugins/builtin/yield-curve/headless.ts +5 -1
- package/src/plugins/builtin/yield-curve/index.tsx +5 -0
- package/src/portfolio/column-values.ts +47 -14
- package/src/portfolio/return-metrics.ts +4 -2
- package/src/renderers/dom/desktop/controls.tsx +1 -1
- package/src/renderers/dom/host/image-surface.tsx +19 -9
- package/src/renderers/dom/host/input.tsx +4 -0
- package/src/renderers/dom/styles.css +7 -4
- package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +23 -1
- package/src/renderers/opentui/box-width.ts +30 -0
- package/src/sources/gloomberb-cloud/normalizers.ts +2 -0
- package/src/sources/provider-errors.ts +12 -0
- package/src/sources/provider-router/index.ts +12 -4
- package/src/state/pane-session.ts +145 -0
- package/src/tickers/search/home-listing.ts +44 -1
- package/src/tickers/search/index.ts +5 -2
- package/src/tickers/search/ranking.ts +7 -7
- package/src/tickers/us-listing.ts +11 -5
- package/src/time-series/base-series.ts +7 -1
- package/src/time-series/fundamentals/current-valuation.ts +8 -0
- package/src/time-series/fundamentals/series.ts +6 -0
- package/src/time-series/resolve.ts +1 -0
- package/src/types/financials.ts +36 -3
- package/src/types/headless.ts +15 -0
- package/src/ui/host.tsx +2 -0
- package/src/utils/exchanges.ts +13 -8
- package/src/utils/fundamentals.ts +49 -8
- package/src/utils/price-earnings.ts +17 -10
- package/src/utils/price-history-integrity.ts +15 -0
- package/src/utils/reason-codes.ts +79 -0
- package/src/utils/share-multiples.cases.json +889 -0
- package/src/utils/share-multiples.ts +254 -0
- package/src/utils/untrusted-text.ts +11 -0
|
@@ -1,25 +1,40 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { confirmDialogWithAnswer } from "../../../components/ui/confirm-dialog";
|
|
2
2
|
import { formatTrialEnd } from "../../../account/billing";
|
|
3
3
|
import { t, tf } from "../../../i18n";
|
|
4
|
+
import { CLOUD_CANCEL_COMMENT_MAX } from "../../../api-client";
|
|
5
|
+
import type { CloudCancelFeedback, CloudCancelReason } from "../../../api-client";
|
|
4
6
|
import type { PlanAccess } from "../../../api-client/plan-rules";
|
|
5
7
|
import type { DialogApi } from "../../../ui/dialog";
|
|
6
8
|
|
|
9
|
+
/** The reasons gloom.sh's cancel window offers, in its words and order. */
|
|
10
|
+
const CANCEL_REASONS: ReadonlyArray<{ id: CloudCancelReason; label: string }> = [
|
|
11
|
+
{ id: "bugs", label: "Bugs or reliability" },
|
|
12
|
+
{ id: "missing_feature", label: "Missing feature" },
|
|
13
|
+
{ id: "too_expensive", label: "Too expensive" },
|
|
14
|
+
{ id: "not_using", label: "Not using it enough" },
|
|
15
|
+
{ id: "temporary", label: "Only needed it temporarily" },
|
|
16
|
+
{ id: "other", label: "Other" },
|
|
17
|
+
];
|
|
18
|
+
|
|
7
19
|
/**
|
|
8
20
|
* Ends a Pro trial the way the account page on gloom.sh does: first a warning
|
|
9
21
|
* that it ends the trial and Pro now, and only a confirmed answer reaches the
|
|
10
22
|
* server. Ending Pro cannot be undone, so a stray Enter keeps the trial; `y`
|
|
11
|
-
* or End Trial Now ends it.
|
|
12
|
-
*
|
|
23
|
+
* or End Trial Now ends it. The warning also asks why, as the cancel window
|
|
24
|
+
* on gloom.sh does, but nothing there is required and it adds no step: the
|
|
25
|
+
* reason and note picked go with the request, and none go when none were.
|
|
26
|
+
* Null when the person kept the trial, or when no trial is running (a stale
|
|
27
|
+
* key or click after it ended), which asks nothing.
|
|
13
28
|
*/
|
|
14
29
|
export async function endTrialAfterWarning(
|
|
15
30
|
dialog: DialogApi,
|
|
16
31
|
trial: Pick<PlanAccess, "isTrialActive" | "trialEndsAt">,
|
|
17
|
-
end: () => Promise<{ endedNow?: boolean }>,
|
|
32
|
+
end: (feedback: CloudCancelFeedback) => Promise<{ endedNow?: boolean }>,
|
|
18
33
|
onConfirmed?: () => void,
|
|
19
34
|
): Promise<{ endedNow: boolean } | null> {
|
|
20
35
|
if (!trial.isTrialActive) return null;
|
|
21
36
|
const date = formatTrialEnd(trial.trialEndsAt);
|
|
22
|
-
const
|
|
37
|
+
const answer = await confirmDialogWithAnswer(dialog, {
|
|
23
38
|
closeOnClickOutside: false,
|
|
24
39
|
title: t("Cancel Trial?"),
|
|
25
40
|
body: [
|
|
@@ -32,9 +47,19 @@ export async function endTrialAfterWarning(
|
|
|
32
47
|
cancelLabel: t("Keep Trial"),
|
|
33
48
|
confirmVariant: "danger",
|
|
34
49
|
defaultAction: "cancel",
|
|
50
|
+
question: {
|
|
51
|
+
label: "What made you decide to cancel? (optional)",
|
|
52
|
+
choices: CANCEL_REASONS,
|
|
53
|
+
notePlaceholder: "Anything else? (optional)",
|
|
54
|
+
noteMaxLength: CLOUD_CANCEL_COMMENT_MAX,
|
|
55
|
+
},
|
|
35
56
|
});
|
|
36
|
-
if (!
|
|
57
|
+
if (!answer) return null;
|
|
37
58
|
onConfirmed?.();
|
|
38
|
-
const
|
|
59
|
+
const reason = CANCEL_REASONS.find(({ id }) => id === answer.choice)?.id;
|
|
60
|
+
const result = await end({
|
|
61
|
+
...(reason ? { reason } : {}),
|
|
62
|
+
...(answer.note ? { comment: answer.note } : {}),
|
|
63
|
+
});
|
|
39
64
|
return { endedNow: result.endedNow === true };
|
|
40
65
|
}
|
|
@@ -5,6 +5,7 @@ import type { DataProvider } from "../../../types/data-provider";
|
|
|
5
5
|
import type { ListingDelisting, PricePoint } from "../../../types/financials";
|
|
6
6
|
import type { BacktestBar } from "./rules";
|
|
7
7
|
import { isFiniteNumber } from "../../../utils/guards";
|
|
8
|
+
import { rollAdjustedHistory } from "../../../market-data/futures-roll-returns";
|
|
8
9
|
|
|
9
10
|
export interface BacktestHistoryDependencies {
|
|
10
11
|
loadChart(request: ChartRequest, options?: { forceRefresh?: boolean }): Promise<QueryEntry<PricePoint[]>>;
|
|
@@ -29,6 +30,8 @@ export interface BacktestHistory {
|
|
|
29
30
|
fetchedAt: number;
|
|
30
31
|
/** The listing no longer trades: its last bar is its last session, and no later one will come. */
|
|
31
32
|
delisting?: ListingDelisting;
|
|
33
|
+
/** A continuous future's bars, back-adjusted at each roll: "rolls back-adjusted" (rollAdjustedHistory). */
|
|
34
|
+
rollNote?: string;
|
|
32
35
|
}
|
|
33
36
|
|
|
34
37
|
/**
|
|
@@ -91,8 +94,12 @@ export async function loadBacktestHistory(
|
|
|
91
94
|
{ forceRefresh: options.forceRefresh },
|
|
92
95
|
);
|
|
93
96
|
options.signal?.throwIfAborted();
|
|
94
|
-
|
|
97
|
+
// A continuous future is tested on one contract's returns at each roll, its earlier prices scaled to the newest
|
|
98
|
+
// contract's: the run's prices (Close, Entry and Exit) are back-adjusted, and the report's headers say so.
|
|
99
|
+
const adjusted = rollAdjustedHistory(resolveEntryValue(entry) ?? [], symbol);
|
|
100
|
+
const history = toBacktestBars(adjusted.points, entry.history?.nonPositiveCloseDates);
|
|
95
101
|
if (!history.bars.length) throw new Error(entry.error?.message ?? "Daily price history unavailable");
|
|
96
102
|
const delisting = entry.history?.delisting;
|
|
97
|
-
return { symbol, ...history, fetchedAt: entry.fetchedAt ?? Date.now(), ...(delisting ? { delisting } : {})
|
|
103
|
+
return { symbol, ...history, fetchedAt: entry.fetchedAt ?? Date.now(), ...(delisting ? { delisting } : {}),
|
|
104
|
+
...(adjusted.note ? { rollNote: adjusted.note } : {}) };
|
|
98
105
|
}
|
|
@@ -121,7 +121,7 @@ export function BacktestPane({ width, height, focused }: PaneProps) {
|
|
|
121
121
|
}
|
|
122
122
|
}, [history.data, rules, lookback, costBps, runWindow]);
|
|
123
123
|
const result = run.result;
|
|
124
|
-
const continuation = instrument ? continuationNote(instrument.symbol, instrument.exchange) : null;
|
|
124
|
+
const continuation = instrument ? continuationNote(instrument.symbol, instrument.exchange, history.data?.rollNote) : null;
|
|
125
125
|
// Export CSV writes the daily curve `fn BT --csv --equity` prints for this run, whichever table is in view;
|
|
126
126
|
// the table reads it when the export runs. Without a run the table's own rows export.
|
|
127
127
|
const exportCsv = result && symbol ? () => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { cleanFloat32Price, historyUnit } from "../../../cli/history-rows";
|
|
2
2
|
import { barsPerYearLabel } from "../../../market-data/bars-per-year";
|
|
3
|
+
import { ROLLS_BACK_ADJUSTED } from "../../../market-data/futures-roll-returns";
|
|
3
4
|
import type { HeadlessBundleResult, HeadlessBundleSection, HeadlessPaneColumn, HeadlessPaneFreshness, HeadlessPaneRow } from "../../../types/headless";
|
|
4
5
|
import { formatStat, formatTradePrice, PRICE_RETURN_LABEL, PRICE_RETURN_NOTE, SUMMARY_ROWS, type StatValue } from "./format";
|
|
5
6
|
import { continuationNote, type BacktestWindowOptions, type HistoryBacktestResult } from "./window";
|
|
@@ -47,7 +48,8 @@ const price = (value: unknown) => typeof value !== "number" || !Number.isFinite(
|
|
|
47
48
|
* lines as the growth of 1 on the price alone and the strategy's drawdown in percent. Exports
|
|
48
49
|
* keep every digit; the text view rounds. The close is the price as `history`
|
|
49
50
|
* exports it, without a float32 feed's noise (671.29999 is 671.3); the run
|
|
50
|
-
* itself used the price as served.
|
|
51
|
+
* itself used the price as served. A continuous future's closes are
|
|
52
|
+
* back-adjusted at its rolls, and its Close header says so (withAdjustedPrices).
|
|
51
53
|
*/
|
|
52
54
|
const EQUITY_COLUMNS: HeadlessPaneColumn[] = [
|
|
53
55
|
{ key: "date", header: "Date", literalHeader: true, shrink: false },
|
|
@@ -66,11 +68,25 @@ const EXPORTED_EQUITY_COLUMNS: HeadlessPaneColumn[] = EQUITY_COLUMNS.map((column
|
|
|
66
68
|
? { ...column, header: column.header.replace(")", ", price return, distributions not included)") }
|
|
67
69
|
: column);
|
|
68
70
|
|
|
71
|
+
/** The price columns a run over back-adjusted bars prints, which are not prices that traded. */
|
|
72
|
+
const ADJUSTED_PRICE_KEYS = new Set(["close", "entryPrice", "exitPrice"]);
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* A run's columns with "(back-adjusted)" on each price header when its bars
|
|
76
|
+
* were back-adjusted at a continuous future's rolls (`rollNote`): the
|
|
77
|
+
* returns are one contract's, but a price before the newest roll is scaled to
|
|
78
|
+
* the newest contract's. Any other run's columns as they are.
|
|
79
|
+
*/
|
|
80
|
+
function withAdjustedPrices(columns: HeadlessPaneColumn[], result: HistoryBacktestResult): HeadlessPaneColumn[] {
|
|
81
|
+
if (!result.rollNote?.startsWith(ROLLS_BACK_ADJUSTED)) return columns;
|
|
82
|
+
return columns.map((column) => ADJUSTED_PRICE_KEYS.has(column.key) ? { ...column, header: `${column.header} (back-adjusted)` } : column);
|
|
83
|
+
}
|
|
84
|
+
|
|
69
85
|
function equitySection(result: HistoryBacktestResult, unit: string | null): HeadlessBundleSection {
|
|
70
86
|
return {
|
|
71
87
|
title: `Daily curve, ${PRICE_RETURN_LABEL.toLowerCase()} · ${result.start} to ${result.end}`,
|
|
72
|
-
columns: EXPORTED_EQUITY_COLUMNS,
|
|
73
|
-
textColumns: EQUITY_COLUMNS,
|
|
88
|
+
columns: withAdjustedPrices(EXPORTED_EQUITY_COLUMNS, result),
|
|
89
|
+
textColumns: withAdjustedPrices(EQUITY_COLUMNS, result),
|
|
74
90
|
rows: result.equity.map((row): HeadlessPaneRow => ({ ...row, close: cleanFloat32Price(row.close), ...(unit ? { currency: unit } : {}) })),
|
|
75
91
|
...(unit ? { unit } : {}),
|
|
76
92
|
interval: INTERVAL,
|
|
@@ -112,13 +128,13 @@ function summarySections(input: BacktestReportInput): HeadlessBundleSection[] {
|
|
|
112
128
|
{
|
|
113
129
|
// Prices are in the listing's currency, which the row names; the return and the hold say their own units.
|
|
114
130
|
title: "Trades",
|
|
115
|
-
columns: [
|
|
131
|
+
columns: withAdjustedPrices([
|
|
116
132
|
{ key: "entryDate", header: "Entry" },
|
|
117
133
|
{ key: "entryPrice", header: "Entry price", align: "right", unitKey: "currency", format: tradePrice },
|
|
118
134
|
{ key: "exitDate", header: "Exit" },
|
|
119
135
|
{ key: "exitPrice", header: "Exit price", align: "right", unitKey: "currency", format: tradePrice },
|
|
120
136
|
{ key: "returnPct", header: "Return %", align: "right", format: fixed(2) }, { key: "sessions", header: "Sessions", align: "right" },
|
|
121
|
-
],
|
|
137
|
+
], result),
|
|
122
138
|
rows: result.trades.map((trade) => ({
|
|
123
139
|
entryDate: trade.entryDate, entryPrice: trade.entryPrice,
|
|
124
140
|
exitDate: trade.open ? "open" : trade.exitDate, exitPrice: trade.exitPrice,
|
|
@@ -139,7 +155,7 @@ function summarySections(input: BacktestReportInput): HeadlessBundleSection[] {
|
|
|
139
155
|
*/
|
|
140
156
|
export function backtestReport(input: BacktestReportInput): HeadlessBundleResult {
|
|
141
157
|
const { result } = input;
|
|
142
|
-
const continuation = continuationNote(input.symbol, input.exchange);
|
|
158
|
+
const continuation = continuationNote(input.symbol, input.exchange, result.rollNote);
|
|
143
159
|
const end = input.window.end?.trim() || null;
|
|
144
160
|
return {
|
|
145
161
|
complete: true,
|
|
@@ -6,6 +6,7 @@ import { runBacktest, type BacktestOptions, type BacktestResult } from "./engine
|
|
|
6
6
|
import { delistingLabel } from "../../../market-data/quotes/delisting";
|
|
7
7
|
import type { BacktestBar, Rule } from "./rules";
|
|
8
8
|
import { formingBarsState, isFormingBar } from "../shared/forming-bars";
|
|
9
|
+
import { ROLLS_BACK_ADJUSTED } from "../../../market-data/futures-roll-returns";
|
|
9
10
|
|
|
10
11
|
/** Which served sessions a run tests. */
|
|
11
12
|
export interface BacktestWindowOptions {
|
|
@@ -34,6 +35,8 @@ export interface HistoryBacktestResult extends BacktestResult {
|
|
|
34
35
|
* later sessions change it.
|
|
35
36
|
*/
|
|
36
37
|
repeatable: boolean;
|
|
38
|
+
/** A continuous future's bars were back-adjusted at its rolls (BacktestHistory.rollNote). */
|
|
39
|
+
rollNote?: string;
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
/**
|
|
@@ -47,7 +50,7 @@ export interface HistoryBacktestResult extends BacktestResult {
|
|
|
47
50
|
* says so, and is repeatable.
|
|
48
51
|
*/
|
|
49
52
|
export function backtestWindow(
|
|
50
|
-
history: Pick<BacktestHistory, "bars" | "skippedDates" | "undatedSkipped" | "delisting"> & { symbol?: string },
|
|
53
|
+
history: Pick<BacktestHistory, "bars" | "skippedDates" | "undatedSkipped" | "delisting" | "rollNote"> & { symbol?: string },
|
|
51
54
|
options: BacktestWindowOptions = {},
|
|
52
55
|
): { bars: BacktestBar[]; warnings: string[]; repeatable: boolean } {
|
|
53
56
|
const end = options.end?.trim() || null;
|
|
@@ -95,7 +98,7 @@ export function backtestWindow(
|
|
|
95
98
|
|
|
96
99
|
/** The run over a loaded history: its window's bars, then the engine, every left-out session warned first. */
|
|
97
100
|
export function runHistoryBacktest(
|
|
98
|
-
history: Pick<BacktestHistory, "bars" | "skippedDates" | "undatedSkipped" | "delisting"> & { symbol?: string },
|
|
101
|
+
history: Pick<BacktestHistory, "bars" | "skippedDates" | "undatedSkipped" | "delisting" | "rollNote"> & { symbol?: string },
|
|
99
102
|
entry: Rule,
|
|
100
103
|
exit: Rule,
|
|
101
104
|
options: BacktestOptions & BacktestWindowOptions,
|
|
@@ -103,20 +106,25 @@ export function runHistoryBacktest(
|
|
|
103
106
|
const window = backtestWindow(history, options);
|
|
104
107
|
// A currency pair's year is every weekday, however short the run.
|
|
105
108
|
const result = runBacktest(window.bars, entry, exit, { ...options, instrument: options.instrument ?? currencyPairInstrument(history.symbol) });
|
|
106
|
-
return { ...result, warnings: [...window.warnings, ...result.warnings], repeatable: window.repeatable
|
|
109
|
+
return { ...result, warnings: [...window.warnings, ...result.warnings], repeatable: window.repeatable,
|
|
110
|
+
...(history.rollNote ? { rollNote: history.rollNote } : {}) };
|
|
107
111
|
}
|
|
108
112
|
|
|
109
113
|
/**
|
|
110
114
|
* What a futures continuation is, said wherever its backtest is read: a
|
|
111
|
-
* continuous symbol (CL=F) rolls front months
|
|
112
|
-
*
|
|
113
|
-
*
|
|
115
|
+
* continuous symbol (CL=F) rolls front months, its bars back-adjusted at
|
|
116
|
+
* each roll as `rollNote` says (rollAdjustedHistory), a generic (CL2F5R) by
|
|
117
|
+
* its rule; unless adjusted each roll is a jump between two contracts' prices
|
|
118
|
+
* that the returns include. Null for anything else, a dated contract included.
|
|
114
119
|
*/
|
|
115
|
-
export function continuationNote(symbol: string, exchange?: string | null): string | null {
|
|
120
|
+
export function continuationNote(symbol: string, exchange?: string | null, rollNote?: string | null): string | null {
|
|
116
121
|
const key = parsePublicTickerKey(symbol);
|
|
117
122
|
if (/^[A-Z0-9]{1,6}=F$/.test(key.symbol)) {
|
|
118
|
-
|
|
119
|
-
|
|
123
|
+
const jump = "each roll shows in the returns as a jump between the two contracts' prices";
|
|
124
|
+
const head = `${key.symbol} is a rolled front-month continuation, not one contract`;
|
|
125
|
+
if (rollNote === ROLLS_BACK_ADJUSTED) return `${head}: ${rollNote}, so prices before each roll are not prices that traded.`;
|
|
126
|
+
if (rollNote?.startsWith(ROLLS_BACK_ADJUSTED)) return `${head}: ${rollNote}; before then ${jump}.`;
|
|
127
|
+
return `${head}: it moves to the next contract as that one becomes the most active, and ${jump}.`;
|
|
120
128
|
}
|
|
121
129
|
const generic = futuresGenericListing(symbol, exchange ?? key.exchange);
|
|
122
130
|
if (!generic) return null;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { apiClient } from "../../../../api-client";
|
|
2
|
+
import type { RemoteControlHandler } from "../../../../remote/app-host";
|
|
3
|
+
import type { AppState } from "../../../../state/app/context";
|
|
4
|
+
import type { AppConfig } from "../../../../types/config";
|
|
5
|
+
import { getCurrentPluginTarget } from "../../../current-target";
|
|
6
|
+
import { ASKGSessionController, type ASKGControllerManifest } from "./controller";
|
|
7
|
+
import { createASKGRendererToolExecutor, loadASKGClientManifest } from "./host";
|
|
8
|
+
import { attachedPaneContext, type ASKGAttachedPane } from "./pane-attachment";
|
|
9
|
+
import { ASKGUndoManager } from "./undo";
|
|
10
|
+
import { buildASKGUserData } from "./user-data";
|
|
11
|
+
|
|
12
|
+
const CLIENT_VERSION = "1";
|
|
13
|
+
|
|
14
|
+
function clientKind(): "tui" | "desktop" | "web" {
|
|
15
|
+
const target = getCurrentPluginTarget();
|
|
16
|
+
return target === "web" || target === "desktop" ? target : "tui";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** What the pane that is mounted now gives the session; the pane writes it on every render. */
|
|
20
|
+
export interface ASKGPaneBindings {
|
|
21
|
+
config: AppConfig;
|
|
22
|
+
remoteHandler: RemoteControlHandler | null;
|
|
23
|
+
getAppState: () => AppState;
|
|
24
|
+
/** The ticker open beside the pane and the pane's own id, read when a question is sent. */
|
|
25
|
+
context: { symbol: string | null; paneId: string };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The conversation an Ask Gloom pane is in: the transcript on screen and the
|
|
30
|
+
* answer still coming in. It belongs to the pane, not to one drawing of it, so
|
|
31
|
+
* docking, floating or stacking the pane picks it up where it was instead of
|
|
32
|
+
* mounting an empty conversation and fetching the last one back.
|
|
33
|
+
*/
|
|
34
|
+
export interface ASKGPaneSession {
|
|
35
|
+
controller: ASKGSessionController;
|
|
36
|
+
bindings: ASKGPaneBindings;
|
|
37
|
+
/** The pane the conversation on screen is about, read whenever a question goes. */
|
|
38
|
+
attached: { current: ASKGAttachedPane | null };
|
|
39
|
+
/** Whether this pane has already looked for the conversation it showed before. */
|
|
40
|
+
restored: boolean;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function createASKGPaneSession(initial: ASKGPaneBindings): ASKGPaneSession {
|
|
44
|
+
const bindings = { ...initial };
|
|
45
|
+
const attached: ASKGPaneSession["attached"] = { current: null };
|
|
46
|
+
// Each call and each undo gets a fresh executor, so the tokens live here:
|
|
47
|
+
// an executor's own manager would forget them as soon as its call returned.
|
|
48
|
+
const undoManager = new ASKGUndoManager((request) => {
|
|
49
|
+
const handler = bindings.remoteHandler;
|
|
50
|
+
if (!handler) return Promise.reject(new Error("This window cannot undo tool calls."));
|
|
51
|
+
return handler(request);
|
|
52
|
+
});
|
|
53
|
+
const controller = new ASKGSessionController({
|
|
54
|
+
transport: apiClient.askg,
|
|
55
|
+
loadManifest: () => loadASKGClientManifest(),
|
|
56
|
+
getExecutor: (manifest: ASKGControllerManifest) => {
|
|
57
|
+
const handler = bindings.remoteHandler;
|
|
58
|
+
if (!handler) return null;
|
|
59
|
+
return createASKGRendererToolExecutor({
|
|
60
|
+
config: bindings.config,
|
|
61
|
+
remoteHandler: handler,
|
|
62
|
+
manifest: {
|
|
63
|
+
tools: manifest.tools,
|
|
64
|
+
manifestHash: manifest.manifestHash,
|
|
65
|
+
skipped: [],
|
|
66
|
+
},
|
|
67
|
+
undoManager,
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
client: { kind: clientKind(), version: CLIENT_VERSION },
|
|
71
|
+
getContext: () => {
|
|
72
|
+
const state = bindings.getAppState();
|
|
73
|
+
const userData = buildASKGUserData({
|
|
74
|
+
config: state.config,
|
|
75
|
+
brokerAccounts: state.brokerAccounts,
|
|
76
|
+
tickers: state.tickers.values(),
|
|
77
|
+
});
|
|
78
|
+
const pane = attached.current;
|
|
79
|
+
// An attached pane is what the question is about: its function, its
|
|
80
|
+
// symbol and, once that may go, what it shows.
|
|
81
|
+
if (pane) return { ...attachedPaneContext(pane), ...(userData ? { userData } : {}) };
|
|
82
|
+
return {
|
|
83
|
+
...(bindings.context.symbol ? { symbol: bindings.context.symbol } : {}),
|
|
84
|
+
paneId: bindings.context.paneId,
|
|
85
|
+
...(userData ? { userData } : {}),
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
return { controller, bindings, attached, restored: false };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function disposeASKGPaneSession(session: ASKGPaneSession): void {
|
|
93
|
+
session.controller.dispose();
|
|
94
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { CLOUD_PLAN_KEY } from "../../shared/cloud-upgrade";
|
|
2
|
-
import { getCurrentPluginTarget } from "../../../current-target";
|
|
3
2
|
import {
|
|
4
3
|
useCallback,
|
|
5
4
|
useEffect,
|
|
@@ -44,6 +43,7 @@ import {
|
|
|
44
43
|
useAppSelector,
|
|
45
44
|
usePaneAppConfig,
|
|
46
45
|
} from "../../../../state/app/context";
|
|
46
|
+
import { usePaneSession, usePaneSessionState } from "../../../../state/pane-session";
|
|
47
47
|
import { useInlineTickers } from "../../../../state/hooks/inline-tickers";
|
|
48
48
|
import { useRemoteControlHandler } from "../../../../remote/app-host";
|
|
49
49
|
import { RemoteUiScope } from "../../../../remote/semantic-tree";
|
|
@@ -62,14 +62,12 @@ import { usePlanAccess } from "../../../../api-client/plan-access";
|
|
|
62
62
|
import { SignInWall } from "../auth-actions";
|
|
63
63
|
import { afterLayout, revealInScrollBox } from "../../../../components/ui/reveal-in-scroll-box";
|
|
64
64
|
import { describePortfolioTab } from "../../analytics/portfolio-selection";
|
|
65
|
-
import { ASKGSessionController, type ASKGControllerManifest } from "./controller";
|
|
66
65
|
import {
|
|
67
|
-
createASKGRendererToolExecutor,
|
|
68
66
|
buildASKGSourceShare,
|
|
69
67
|
type ASKGSourceShare,
|
|
70
|
-
loadASKGClientManifest,
|
|
71
68
|
resolveToolPaneTarget,
|
|
72
69
|
} from "./host";
|
|
70
|
+
import { createASKGPaneSession, disposeASKGPaneSession } from "./pane-session";
|
|
73
71
|
import { getSharedRegistry } from "../../../registry";
|
|
74
72
|
import {
|
|
75
73
|
answerReadNothing,
|
|
@@ -102,7 +100,6 @@ import type { AskGloomPaneAttachment } from "../../../../ask-gloom/pane-request"
|
|
|
102
100
|
import { moveComposerCursorToOffset } from "../../chat/content/composer-cursor";
|
|
103
101
|
import {
|
|
104
102
|
ASKG_PANE_QUESTION,
|
|
105
|
-
attachedPaneContext,
|
|
106
103
|
attachPane,
|
|
107
104
|
type ASKGAttachedPane,
|
|
108
105
|
} from "./pane-attachment";
|
|
@@ -112,9 +109,7 @@ import {
|
|
|
112
109
|
attachedPaneBlockHeight,
|
|
113
110
|
LEAVE_OUT_PANE_KEY,
|
|
114
111
|
} from "./attached-pane";
|
|
115
|
-
import { buildASKGUserData } from "./user-data";
|
|
116
112
|
import { ASKGConversationSidebar } from "./sidebar";
|
|
117
|
-
import { ASKGUndoManager } from "./undo";
|
|
118
113
|
import {
|
|
119
114
|
activeTurn,
|
|
120
115
|
canRateTurn,
|
|
@@ -146,7 +141,6 @@ import { logFailure } from "../../../../utils/log-failure";
|
|
|
146
141
|
|
|
147
142
|
export const ASKG_PANE_ID = "askg";
|
|
148
143
|
|
|
149
|
-
const CLIENT_VERSION = "1";
|
|
150
144
|
const MIN_DETAIL_HEIGHT = 8;
|
|
151
145
|
/** The composer grows with the question up to this many lines, then scrolls. */
|
|
152
146
|
const MAX_COMPOSER_LINES = 6;
|
|
@@ -155,11 +149,6 @@ const LOW_QUOTA = 20;
|
|
|
155
149
|
/** What unlocks Ask Gloom: a free account with a verified email; a paid plan only changes the model. */
|
|
156
150
|
const ASKG_WALL_HINT = "Free with a verified Gloom account.";
|
|
157
151
|
|
|
158
|
-
function clientKind(): "tui" | "desktop" | "web" {
|
|
159
|
-
const target = getCurrentPluginTarget();
|
|
160
|
-
return target === "web" || target === "desktop" ? target : "tui";
|
|
161
|
-
}
|
|
162
|
-
|
|
163
152
|
function tierLabel(row: ASKGToolRow): string | null {
|
|
164
153
|
if (row.writeTier === "read") return null;
|
|
165
154
|
if (row.writeTier === "ui-write") return "layout";
|
|
@@ -611,72 +600,37 @@ export function ASKGPane({ paneId, focused, width, height }: PaneProps) {
|
|
|
611
600
|
const dialog = useDialog();
|
|
612
601
|
const rendererHost = useRendererHost();
|
|
613
602
|
|
|
614
|
-
const configRef = useRef(config);
|
|
615
|
-
configRef.current = config;
|
|
616
|
-
const remoteHandlerRef = useRef(remoteHandler);
|
|
617
|
-
remoteHandlerRef.current = remoteHandler;
|
|
618
|
-
const contextRef = useRef({ symbol: activeSymbol, paneId });
|
|
619
|
-
contextRef.current = { symbol: activeSymbol, paneId };
|
|
620
603
|
// Read when a question is sent, so portfolio and ticker changes do not re-render the pane.
|
|
621
604
|
const getAppState = useAppGetState();
|
|
622
|
-
|
|
623
|
-
|
|
605
|
+
|
|
606
|
+
// The conversation belongs to the pane, not to this drawing of it: docking
|
|
607
|
+
// or floating the pane mounts it again, and it picks the conversation up
|
|
608
|
+
// where it was (see `usePaneSession`).
|
|
609
|
+
const session = usePaneSession(
|
|
610
|
+
"askg:conversation",
|
|
611
|
+
() => createASKGPaneSession({
|
|
612
|
+
config,
|
|
613
|
+
remoteHandler,
|
|
614
|
+
getAppState,
|
|
615
|
+
context: { symbol: activeSymbol, paneId },
|
|
616
|
+
}),
|
|
617
|
+
disposeASKGPaneSession,
|
|
618
|
+
paneId,
|
|
619
|
+
);
|
|
620
|
+
const { controller } = session;
|
|
621
|
+
session.bindings.config = config;
|
|
622
|
+
session.bindings.remoteHandler = remoteHandler;
|
|
623
|
+
session.bindings.getAppState = getAppState;
|
|
624
|
+
session.bindings.context = { symbol: activeSymbol, paneId };
|
|
624
625
|
|
|
625
626
|
// The pane the conversation on screen is about, read whenever a question
|
|
626
627
|
// goes so every turn of it carries the pane.
|
|
627
|
-
const [attached, setAttachedState] =
|
|
628
|
-
const attachedRef =
|
|
628
|
+
const [attached, setAttachedState] = usePaneSessionState<ASKGAttachedPane | null>("askg:attached", null, paneId);
|
|
629
|
+
const attachedRef = session.attached;
|
|
629
630
|
const setAttached = useCallback((next: ASKGAttachedPane | null) => {
|
|
630
631
|
attachedRef.current = next;
|
|
631
632
|
setAttachedState(next);
|
|
632
|
-
}, []);
|
|
633
|
-
|
|
634
|
-
// Each call and each undo gets a fresh executor, so the tokens live here:
|
|
635
|
-
// an executor's own manager would forget them as soon as its call returned.
|
|
636
|
-
const undoManager = useMemo(() => new ASKGUndoManager((request) => {
|
|
637
|
-
const handler = remoteHandlerRef.current;
|
|
638
|
-
if (!handler) return Promise.reject(new Error("This window cannot undo tool calls."));
|
|
639
|
-
return handler(request);
|
|
640
|
-
}), []);
|
|
641
|
-
|
|
642
|
-
const controller = useMemo(() => new ASKGSessionController({
|
|
643
|
-
transport: apiClient.askg,
|
|
644
|
-
loadManifest: () => loadASKGClientManifest(),
|
|
645
|
-
getExecutor: (manifest: ASKGControllerManifest) => {
|
|
646
|
-
const handler = remoteHandlerRef.current;
|
|
647
|
-
if (!handler) return null;
|
|
648
|
-
return createASKGRendererToolExecutor({
|
|
649
|
-
config: configRef.current,
|
|
650
|
-
remoteHandler: handler,
|
|
651
|
-
manifest: {
|
|
652
|
-
tools: manifest.tools,
|
|
653
|
-
manifestHash: manifest.manifestHash,
|
|
654
|
-
skipped: [],
|
|
655
|
-
},
|
|
656
|
-
undoManager,
|
|
657
|
-
});
|
|
658
|
-
},
|
|
659
|
-
client: { kind: clientKind(), version: CLIENT_VERSION },
|
|
660
|
-
getContext: () => {
|
|
661
|
-
const state = getAppStateRef.current();
|
|
662
|
-
const userData = buildASKGUserData({
|
|
663
|
-
config: state.config,
|
|
664
|
-
brokerAccounts: state.brokerAccounts,
|
|
665
|
-
tickers: state.tickers.values(),
|
|
666
|
-
});
|
|
667
|
-
const pane = attachedRef.current;
|
|
668
|
-
// An attached pane is what the question is about: its function, its
|
|
669
|
-
// symbol and, once that may go, what it shows.
|
|
670
|
-
if (pane) return { ...attachedPaneContext(pane), ...(userData ? { userData } : {}) };
|
|
671
|
-
return {
|
|
672
|
-
...(contextRef.current.symbol ? { symbol: contextRef.current.symbol } : {}),
|
|
673
|
-
paneId: contextRef.current.paneId,
|
|
674
|
-
...(userData ? { userData } : {}),
|
|
675
|
-
};
|
|
676
|
-
},
|
|
677
|
-
}), [undoManager]);
|
|
678
|
-
|
|
679
|
-
useEffect(() => () => controller.dispose(), [controller]);
|
|
633
|
+
}, [attachedRef, setAttachedState]);
|
|
680
634
|
|
|
681
635
|
const state: ASKGConversationState = useSyncExternalStore(
|
|
682
636
|
useCallback((listener) => controller.subscribe(listener), [controller]),
|
|
@@ -684,14 +638,16 @@ export function ASKGPane({ paneId, focused, width, height }: PaneProps) {
|
|
|
684
638
|
useCallback(() => controller.getState(), [controller]),
|
|
685
639
|
);
|
|
686
640
|
|
|
687
|
-
|
|
641
|
+
// What is in the composer and which row of the conversation the keyboard is
|
|
642
|
+
// on go with the conversation, so a dock change leaves them where they were.
|
|
643
|
+
const [inputValue, setInputValue] = usePaneSessionState("askg:draft", "", paneId);
|
|
688
644
|
const [inputFocused, setInputFocused] = useState(false);
|
|
689
645
|
// A tool row or a turn's folded calls; j/k walk them.
|
|
690
|
-
const [selectedId, setSelectedId] =
|
|
691
|
-
const [expandedToolCallId, setExpandedToolCallId] =
|
|
692
|
-
const [openGroups, setOpenGroups] =
|
|
646
|
+
const [selectedId, setSelectedId] = usePaneSessionState<string | null>("askg:selected", null, paneId);
|
|
647
|
+
const [expandedToolCallId, setExpandedToolCallId] = usePaneSessionState<string | null>("askg:expanded", null, paneId);
|
|
648
|
+
const [openGroups, setOpenGroups] = usePaneSessionState<ReadonlySet<string>>("askg:open-groups", () => new Set(), paneId);
|
|
693
649
|
// The answer whose thumbs down shows its reasons and the send action.
|
|
694
|
-
const [feedbackFollowUpTurnId, setFeedbackFollowUpTurnId] =
|
|
650
|
+
const [feedbackFollowUpTurnId, setFeedbackFollowUpTurnId] = usePaneSessionState<string | null>("askg:feedback-follow-up", null, paneId);
|
|
695
651
|
// The example question the keyboard is on while the pane is empty.
|
|
696
652
|
const [exampleIndex, setExampleIndex] = useState<number | null>(null);
|
|
697
653
|
const inputRef = useRef<TextareaRenderable | null>(null);
|
|
@@ -793,7 +749,7 @@ export function ASKGPane({ paneId, focused, width, height }: PaneProps) {
|
|
|
793
749
|
}, [state]);
|
|
794
750
|
|
|
795
751
|
const profileExamples = useMemo(() => {
|
|
796
|
-
const appState =
|
|
752
|
+
const appState = getAppState();
|
|
797
753
|
return askgExampleQuestions({
|
|
798
754
|
config: appState.config,
|
|
799
755
|
tickers: appState.tickers.values(),
|
|
@@ -1019,10 +975,11 @@ export function ASKGPane({ paneId, focused, width, height }: PaneProps) {
|
|
|
1019
975
|
// Closing the pane is two Escs away, so the conversation it showed comes
|
|
1020
976
|
// back with the next one this session opens. A question typed with the
|
|
1021
977
|
// command that opened it starts a new one instead.
|
|
1022
|
-
const restoredRef = useRef(false);
|
|
1023
978
|
useEffect(() => {
|
|
1024
|
-
|
|
1025
|
-
|
|
979
|
+
// Once per pane: a pane that comes back from a dock change has its
|
|
980
|
+
// conversation already, and one that was started empty stays empty.
|
|
981
|
+
if (session.restored || !planAccess.emailVerified) return;
|
|
982
|
+
session.restored = true;
|
|
1026
983
|
const remembered = askgConversationListStore.rememberedOpen();
|
|
1027
984
|
if (!remembered || queuedQuestionRef.current || queuedPaneRef.current || controller.getState().turns.length > 0) return;
|
|
1028
985
|
void apiClient.askg.loadConversation(remembered).then((conversation) => {
|
|
@@ -1031,7 +988,7 @@ export function ASKGPane({ paneId, focused, width, height }: PaneProps) {
|
|
|
1031
988
|
if (!conversation || current.turns.length > 0 || current.conversationId || attachedRef.current || queuedPaneRef.current) return;
|
|
1032
989
|
controller.openConversation(conversation);
|
|
1033
990
|
}).catch(logFailure("cloud.askg.pane", "Restore the last open conversation failed"));
|
|
1034
|
-
}, [controller, planAccess.emailVerified]);
|
|
991
|
+
}, [attachedRef, controller, planAccess.emailVerified, session]);
|
|
1035
992
|
|
|
1036
993
|
useEffect(() => {
|
|
1037
994
|
if (state.conversationId) askgConversationListStore.rememberOpen(state.conversationId);
|
|
@@ -1162,7 +1119,7 @@ export function ASKGPane({ paneId, focused, width, height }: PaneProps) {
|
|
|
1162
1119
|
if (target.kind !== "pane") return;
|
|
1163
1120
|
const failed = (reason: string) => notify({ body: `Could not open ${formatSourceCommand(target.command)}: ${reason}`, type: "error" });
|
|
1164
1121
|
try {
|
|
1165
|
-
const share = await buildASKGSourceShare(target.command,
|
|
1122
|
+
const share = await buildASKGSourceShare(target.command, session.bindings.config);
|
|
1166
1123
|
openSharedPane(share.data, () => failed("panes cannot open from here."));
|
|
1167
1124
|
} catch (error) {
|
|
1168
1125
|
failed(error instanceof Error ? error.message : String(error));
|
|
@@ -1350,7 +1307,7 @@ export function ASKGPane({ paneId, focused, width, height }: PaneProps) {
|
|
|
1350
1307
|
if (source.target.kind !== "pane") continue;
|
|
1351
1308
|
const key = formatSourceCommand(source.target.command);
|
|
1352
1309
|
if (links.has(key) || pending.some((entry) => entry.key === key)) continue;
|
|
1353
|
-
const share = await buildASKGSourceShare(source.target.command,
|
|
1310
|
+
const share = await buildASKGSourceShare(source.target.command, session.bindings.config).catch((error: unknown) => {
|
|
1354
1311
|
logFailure("cloud.askg.pane", "An answer source could not be shared")(error);
|
|
1355
1312
|
return null;
|
|
1356
1313
|
});
|
|
@@ -263,7 +263,12 @@ export function CongressTradesPane({ focused, width, height, tickerFilter }: Pan
|
|
|
263
263
|
|
|
264
264
|
const openTicker = useInlineTickerOpener();
|
|
265
265
|
|
|
266
|
+
// The rows come in after the pane mounts, every time it mounts (docking or
|
|
267
|
+
// floating it mounts it again), so no rows yet says nothing about which row
|
|
268
|
+
// was selected. Only a loaded table with no such row moves the selection.
|
|
269
|
+
const rowsLoaded = !!payload && status === "loaded";
|
|
266
270
|
useEffect(() => {
|
|
271
|
+
if (!rowsLoaded) return;
|
|
267
272
|
if (tradeRows.length === 0) {
|
|
268
273
|
if (selectedTradeId !== null) setSelectedTradeId(null);
|
|
269
274
|
return;
|
|
@@ -271,9 +276,10 @@ export function CongressTradesPane({ focused, width, height, tickerFilter }: Pan
|
|
|
271
276
|
if (!selectedTrade || !selectedTradeId) {
|
|
272
277
|
setSelectedTradeId(tradeRows[0]!.id);
|
|
273
278
|
}
|
|
274
|
-
}, [selectedTrade, selectedTradeId, setSelectedTradeId, tradeRows]);
|
|
279
|
+
}, [rowsLoaded, selectedTrade, selectedTradeId, setSelectedTradeId, tradeRows]);
|
|
275
280
|
|
|
276
281
|
useEffect(() => {
|
|
282
|
+
if (!rowsLoaded) return;
|
|
277
283
|
if (memberRows.length === 0) {
|
|
278
284
|
if (selectedMemberId !== null) setSelectedMemberId(null);
|
|
279
285
|
return;
|
|
@@ -281,7 +287,7 @@ export function CongressTradesPane({ focused, width, height, tickerFilter }: Pan
|
|
|
281
287
|
if (!selectedMember || !selectedMemberId) {
|
|
282
288
|
setSelectedMemberId(memberRows[0]!.id);
|
|
283
289
|
}
|
|
284
|
-
}, [memberRows, selectedMember, selectedMemberId, setSelectedMemberId]);
|
|
290
|
+
}, [memberRows, rowsLoaded, selectedMember, selectedMemberId, setSelectedMemberId]);
|
|
285
291
|
|
|
286
292
|
useEffect(() => {
|
|
287
293
|
if (!payload || status !== "loaded") return;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PricePoint } from "../../../types/financials";
|
|
2
2
|
import { getPricePointTimestamp } from "../../../utils/price-history";
|
|
3
|
-
import { pricePointIntegrity } from "../../../utils/price-history-integrity";
|
|
3
|
+
import { pricePointCloseCopied, pricePointIntegrity } from "../../../utils/price-history-integrity";
|
|
4
4
|
|
|
5
5
|
export interface CorrelationResult {
|
|
6
6
|
correlation: number | null;
|
|
@@ -26,13 +26,14 @@ export type ChangeBasis = "return" | "difference";
|
|
|
26
26
|
* Keep the final valid close for each UTC trading date, in chronological order.
|
|
27
27
|
* A bar whose prices contradict each other (a high under its open) is left out,
|
|
28
28
|
* as `history` leaves it blank: the series has a gap there, and the next return
|
|
29
|
-
* runs from the close before it, as across a holiday.
|
|
29
|
+
* runs from the close before it, as across a holiday. So is a pair's close its
|
|
30
|
+
* source copied from the open, which nothing rebuilt (flag close copied).
|
|
30
31
|
*/
|
|
31
32
|
export function dailyCloses(points: readonly PricePoint[]): DailyClose[] {
|
|
32
33
|
const byDate = new Map<string, number>();
|
|
33
34
|
for (const point of [...points].sort(comparePricePointsByDate)) {
|
|
34
35
|
const dateKey = toDateKey(point);
|
|
35
|
-
if (!dateKey || !Number.isFinite(point.close) || point.close <= 0 || pricePointIntegrity(point)) continue;
|
|
36
|
+
if (!dateKey || !Number.isFinite(point.close) || point.close <= 0 || pricePointIntegrity(point) || pricePointCloseCopied(point)) continue;
|
|
36
37
|
byDate.set(dateKey, point.close);
|
|
37
38
|
}
|
|
38
39
|
return [...byDate].map(([dateKey, close]) => ({ dateKey, close }));
|