@gloom-sh/terminal 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
|
@@ -9,16 +9,15 @@ import type {
|
|
|
9
9
|
HeadlessRowsResult,
|
|
10
10
|
} from "../../../types/plugin";
|
|
11
11
|
import type { EarningsEvent } from "../../../types/data-provider";
|
|
12
|
-
import { addDays, boardReport, fallbackReport, MIN_AVERAGE_REPORTS, newYorkToday, type BoardReport } from "./board-model";
|
|
12
|
+
import { addDays, boardKey, boardReport, boardRowOf, fallbackReport, MIN_AVERAGE_REPORTS, newYorkToday, type BoardReport } from "./board-model";
|
|
13
13
|
import { BOARD_WEEKS, boardRangeDays, boardRangeLabel, isBoardWeek, requestedBoardRange, type BoardRange } from "./calendar-model";
|
|
14
|
-
import { fetchEarningsCalendar, fetchEarningsHistory, hasEarningsHistory, noHistoryAbroad } from "./client";
|
|
14
|
+
import { fetchEarningsCalendar, fetchEarningsHistory, hasEarningsHistory, noHistoryAbroad, sameHistoryListing } from "./client";
|
|
15
15
|
import { loadEarningsCalendar } from "./data/cache";
|
|
16
16
|
import { epsText, impliedText, moneyText, moveSize, signedPercent, TIMING_LABEL } from "./format";
|
|
17
17
|
import { historyRows, periodText } from "./history-model";
|
|
18
18
|
import { fiscalQuarterText } from "./fiscal-quarter";
|
|
19
19
|
import { loadNoEarningsText } from "./no-earnings";
|
|
20
20
|
import { EPS_BASIS_NOTE, epsBasisName, PROVISIONAL_NOTE, showsEpsBasis } from "../shared/earnings-report";
|
|
21
|
-
import { isUsListingExchange } from "../../../utils/exchanges";
|
|
22
21
|
import { listingAbroadVenue } from "../../../utils/sec";
|
|
23
22
|
import { findUsListingOfCompany } from "../../../tickers/us-listing";
|
|
24
23
|
import { shortCompanyName } from "../../../tickers/company-name";
|
|
@@ -42,7 +41,10 @@ const BOARD_COLUMNS: HeadlessPaneColumn[] = [
|
|
|
42
41
|
{ key: "timing", header: "When" },
|
|
43
42
|
{ key: "symbol", header: "Ticker" },
|
|
44
43
|
{ key: "name", header: "Name" },
|
|
45
|
-
|
|
44
|
+
// Dollars for every company, a listing abroad's too, so the board ranks them together.
|
|
45
|
+
{ key: "marketCap", header: "Mkt cap $", align: right, format: (value) => moneyText(num(value)) },
|
|
46
|
+
// The EPS and sales figures' currency: a listing abroad's own (CNY for Tencent).
|
|
47
|
+
{ key: "currency", header: "Ccy" },
|
|
46
48
|
{ key: "epsEstimate", header: "EPS est", align: right, format: (value) => epsText(num(value)) },
|
|
47
49
|
{ key: "epsAnalysts", header: "Ests", align: right },
|
|
48
50
|
{ key: "epsActual", header: "EPS act", align: right, format: (value) => epsText(num(value)) },
|
|
@@ -53,6 +55,9 @@ const BOARD_COLUMNS: HeadlessPaneColumn[] = [
|
|
|
53
55
|
{ key: "averageMove", header: "Avg move", align: right, format: (value) => moveSize(num(value)) },
|
|
54
56
|
];
|
|
55
57
|
|
|
58
|
+
/** What the board's currency and cap are, and which listings abroad it has, in its metadata. */
|
|
59
|
+
const BOARD_CURRENCY_NOTE = "currency is the ISO currency of a report's EPS and sales figures: dollars for US listings, a listing abroad's own (CNY for Tencent), never converted. marketCap is in dollars for every company, so the board ranks them together. Besides US listings the board has the Hong Kong, China A and Singapore top 100's reports whose date the company confirmed or that are out, from each listing's earnings history; they have no time of day, implied or average move. A company listed on two of those markets is shown once, under its primary listing, and found by any of its lines.";
|
|
60
|
+
|
|
56
61
|
/** What an ERN <ticker> report's quarter is, in its metadata. */
|
|
57
62
|
const FISCAL_QUARTER_NOTE = "fiscalQuarter is the quarter as the company names it (Q3 FY2027), from its earnings calls on record; fiscalPeriod is the month the quarter ended. A company whose calls do not name its quarters has fiscalQuarter null.";
|
|
58
63
|
|
|
@@ -96,7 +101,7 @@ const LISTING_HISTORY_COLUMNS: HeadlessPaneColumn[] = [
|
|
|
96
101
|
const LISTING_PERIOD_NOTE = "period is what the figures cover: a quarter (Q3 FY2026, or its end month), a half (H1 FY2026), a year (FY2025) or a year to date (9M FY2026), a fiscal year named by the calendar year it ends in. A half-yearly reporter's half is never a quarter. currency is the ISO currency of every amount on the row, estimates included. EPS estimates and actuals are the street's quarter figures, compared only in one currency and on one basis; a period the street has no quarter for shows the company's reported EPS and revenue from its results announcement (filing) with no estimate, its EPS diluted (basis GAAP) where the filing gives one, else basic (basis basic). The announcements' figures and links come with Gloom Pro, as KPIS has them; the street's quarters are everyone's.";
|
|
97
102
|
|
|
98
103
|
interface EarningsHeadlessDependencies {
|
|
99
|
-
calendar(query: { from: string; to: string; perDay: number; symbols: string[] }, context: HeadlessPaneContext): Promise<EarningsCalendarPayload>;
|
|
104
|
+
calendar(query: { from: string; to: string; perDay: number; symbols: string[]; markets?: "all" }, context: HeadlessPaneContext): Promise<EarningsCalendarPayload>;
|
|
100
105
|
history(symbol: string, context: HeadlessPaneContext): Promise<EarningsHistoryPayload>;
|
|
101
106
|
upcoming(symbols: string[], context: HeadlessPaneContext): Promise<EarningsEvent[]>;
|
|
102
107
|
}
|
|
@@ -114,15 +119,16 @@ const NO_OWNERSHIP = new Map();
|
|
|
114
119
|
* report says so once, whether the ticker is on it and when, and where its
|
|
115
120
|
* own report dates are.
|
|
116
121
|
*/
|
|
117
|
-
function boardTickerNotice(symbol: string, board: ReadonlyArray<
|
|
118
|
-
const
|
|
119
|
-
//
|
|
120
|
-
const
|
|
121
|
-
const where = report ? `${symbol} reports on ${report.date}` : `${symbol} is not on it`;
|
|
122
|
+
function boardTickerNotice(symbol: string, board: ReadonlyArray<Pick<BoardReport, "symbol" | "listings" | "date">>, from: string, to: string): { notice: string; date: string | null; row: string | null } {
|
|
123
|
+
const report = board.find((entry) => boardRowOf(entry, symbol));
|
|
124
|
+
// CCB named by its H share is on the board under its A share.
|
|
125
|
+
const shownAs = report?.listings && !sameHistoryListing(report.symbol, boardKey(symbol)) ? ` (as ${report.symbol})` : "";
|
|
126
|
+
const where = report ? `${symbol} reports on ${report.date}${shownAs}` : `${symbol} is not on it`;
|
|
122
127
|
const days = from === to ? from : `${from} to ${to}`;
|
|
123
128
|
return {
|
|
124
129
|
notice: `EVTS is the market's earnings board for ${days}, not one company's: ${where}. For ${symbol}'s own report dates run \`gloom fn ERN ${symbol}\`.`,
|
|
125
130
|
date: report?.date ?? null,
|
|
131
|
+
row: report?.symbol ?? null,
|
|
126
132
|
};
|
|
127
133
|
}
|
|
128
134
|
|
|
@@ -166,9 +172,12 @@ async function boardRows(args: HeadlessPaneLoadArgs, context: HeadlessPaneContex
|
|
|
166
172
|
const named = args.symbols;
|
|
167
173
|
const days = boardRangeDays(range, today);
|
|
168
174
|
// Named companies' upcoming reports by default; a chosen week or day reads that range for them as for the market.
|
|
175
|
+
// Every view of the board shows each report's currency, so it reads the listings abroad too; EVTS 0700.HK names its
|
|
176
|
+
// listing, which the board then keeps whatever the day's cut.
|
|
177
|
+
const abroad = highlight && listingAbroadVenue(boardKey(highlight)) ? [boardKey(highlight)] : [];
|
|
169
178
|
const query = named.length && !range
|
|
170
|
-
? { from: today, to: addDays(today, 90), perDay: 0, symbols: named }
|
|
171
|
-
: { from: days[0]!.from, to: days.at(-1)!.to, perDay: named.length ? 0 : 200, symbols: named };
|
|
179
|
+
? { from: today, to: addDays(today, 90), perDay: 0, symbols: named, markets: "all" as const }
|
|
180
|
+
: { from: days[0]!.from, to: days.at(-1)!.to, perDay: named.length ? 0 : 200, symbols: named.length ? named : abroad, markets: "all" as const };
|
|
172
181
|
const inRange = (event: EarningsEvent) => {
|
|
173
182
|
const date = event.earningsDate.toISOString().slice(0, 10);
|
|
174
183
|
return !range || (date >= query.from && date <= query.to);
|
|
@@ -180,7 +189,8 @@ async function boardRows(args: HeadlessPaneLoadArgs, context: HeadlessPaneContex
|
|
|
180
189
|
if (cloud.status === "rejected" && (!named.length || fallback.status === "rejected")) throw cloud.reason;
|
|
181
190
|
const payload = cloud.status === "fulfilled" ? cloud.value : null;
|
|
182
191
|
const reports = (payload?.reports ?? []).map((report) => boardReport(report, NO_OWNERSHIP));
|
|
183
|
-
|
|
192
|
+
// A listing abroad named by another of its company's lines (0939:HKEX) is covered by its row.
|
|
193
|
+
const covered = new Set(reports.flatMap((report) => [report.symbol, ...report.listings ?? []]));
|
|
184
194
|
const uncovered = fallback.status === "fulfilled" ? fallback.value.filter((event) => !covered.has(event.symbol)) : [];
|
|
185
195
|
// The days ahead leave out a report just gone by, which the stored board has as the date board shows it.
|
|
186
196
|
const stored = named.length && !range ? await storedPastReports(uncovered, today, context, deps) : new Map<EarningsEvent, BoardReport>();
|
|
@@ -195,6 +205,8 @@ async function boardRows(args: HeadlessPaneLoadArgs, context: HeadlessPaneContex
|
|
|
195
205
|
symbol: report.symbol,
|
|
196
206
|
name: report.name,
|
|
197
207
|
marketCap: report.marketCap,
|
|
208
|
+
currency: report.currency ?? null,
|
|
209
|
+
...report.listings ? { listings: report.listings } : {},
|
|
198
210
|
epsEstimate: report.epsEstimate,
|
|
199
211
|
epsAnalysts: report.epsAnalysts,
|
|
200
212
|
epsActual: report.epsActual,
|
|
@@ -211,7 +223,7 @@ async function boardRows(args: HeadlessPaneLoadArgs, context: HeadlessPaneContex
|
|
|
211
223
|
rows,
|
|
212
224
|
errors: cloud.status === "rejected" ? [String(cloud.reason instanceof Error ? cloud.reason.message : cloud.reason)] : undefined,
|
|
213
225
|
metadata: {
|
|
214
|
-
...(ticker ? { notices: [ticker.notice], highlight: { symbol: highlight, onBoard: ticker.date != null, date: ticker.date } } : {}),
|
|
226
|
+
...(ticker ? { notices: [ticker.notice], highlight: { symbol: highlight, onBoard: ticker.date != null, date: ticker.date, row: ticker.row } } : {}),
|
|
215
227
|
asOf: payload?.asOf ?? null,
|
|
216
228
|
from: query.from,
|
|
217
229
|
to: query.to,
|
|
@@ -219,6 +231,7 @@ async function boardRows(args: HeadlessPaneLoadArgs, context: HeadlessPaneContex
|
|
|
219
231
|
epsBasis: EPS_BASIS_NOTE,
|
|
220
232
|
provisional: PROVISIONAL_NOTE,
|
|
221
233
|
marketCap: MARKET_CAP_NOTE,
|
|
234
|
+
currency: BOARD_CURRENCY_NOTE,
|
|
222
235
|
total: all.length,
|
|
223
236
|
returned: rows.length,
|
|
224
237
|
truncated: rows.length < all.length,
|
|
@@ -22,6 +22,8 @@ export type EconCalendarFrom =
|
|
|
22
22
|
events: EconEvent[];
|
|
23
23
|
/** The first UTC day the stored calendar holds; null when it holds nothing. */
|
|
24
24
|
storedFrom: string | null;
|
|
25
|
+
/** The first UTC day any read lists (the stored calendar's, or the furthest back it reaches); null from an older server. */
|
|
26
|
+
listedFrom: string | null;
|
|
25
27
|
/** The last UTC day the calendar lists releases for; null from a server that does not say. */
|
|
26
28
|
listedThrough: string | null;
|
|
27
29
|
}
|
|
@@ -47,6 +49,7 @@ export async function fetchEconCalendarFrom(from: string): Promise<EconCalendarF
|
|
|
47
49
|
return {
|
|
48
50
|
events: withPercentUnits(payload.events.map(toEconEvent)),
|
|
49
51
|
storedFrom: payload.storedFrom,
|
|
52
|
+
listedFrom: typeof payload.listedFrom === "string" && /^\d{4}-\d{2}-\d{2}$/.test(payload.listedFrom) ? payload.listedFrom : null,
|
|
50
53
|
listedThrough: typeof payload.listedThrough === "string" && /^\d{4}-\d{2}-\d{2}$/.test(payload.listedThrough) ? payload.listedThrough : null,
|
|
51
54
|
};
|
|
52
55
|
} catch (error) {
|
|
@@ -4,7 +4,7 @@ import type { HeadlessPaneColumn, HeadlessPaneDefinition, HeadlessPaneEntry, Hea
|
|
|
4
4
|
import { formatPercentRaw } from "../../../utils/format";
|
|
5
5
|
import { DATE_OPTION_EXAMPLES } from "../../../utils/calendar-date";
|
|
6
6
|
import { fetchFuturesCurve, loadCurveSpot, loadCurveSpotBars, loadCurveSpotCloses, loadFuturesCurveAsOf } from "./client";
|
|
7
|
-
import { curveReportFreshness, basisSpotSymbol, BASIS_CONVENTION, blankBasisNote, catalogueCurveUnit, curveAsOfDate, curveCache, curveSpotBars, curveBasisPercent, curveBasisRows, curveChangeText, curveContractCode, curvePrice, curveReadsThirtySeconds, curveRoundedPrice, curveSpotSource, curveSpotPremium, curveSpreadLabel, curveTimestamp, curveNoTradeSince, curveSessionNote, curveSettleShown, curveStandIn, curveUnitLabel, curveRootNamed, noTradeChangeNote, normalizeCurveRoot, shortDatedBasisNote, skippedSpreadNotice, spotIndexSymbol, thinSpreadNotice, unpairedContractCount, unsupportedCurveRootMessage, type ContractBasis, type CurveSpotPremium } from "./model";
|
|
7
|
+
import { curveReportFreshness, basisSpotSymbol, BASIS_CONVENTION, blankBasisNote, catalogueCurveUnit, curveAsOfDate, curveCache, curveSpotBars, curveBasisPercent, curveBasisRows, curveChangeText, curveContractCode, curveIncompleteDetail, curvePrice, curveReadsThirtySeconds, curveRoundedPrice, curveSpotSource, curveSpotPremium, curveSpreadLabel, curveTimestamp, curveNoTradeSince, curveSessionNote, curveSettleShown, curveStandIn, curveUnitLabel, curveRootNamed, noTradeChangeNote, normalizeCurveRoot, shortDatedBasisNote, skippedSpreadNotice, spotIndexSymbol, thinSpreadNotice, unpairedContractCount, unsupportedCurveRootMessage, type ContractBasis, type CurveSpotPremium } from "./model";
|
|
8
8
|
import { COMMODITIES_VIEW_STATE } from "../commodities-energy/view-state";
|
|
9
9
|
import { knownGapMessage } from "../../../cli/known-gaps";
|
|
10
10
|
|
|
@@ -235,6 +235,8 @@ export const futuresCurveHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
|
235
235
|
annualizedRollYield: data.slope.annualizedRollYield == null ? null : Number(data.slope.annualizedRollYield.toFixed(2)),
|
|
236
236
|
percentile: rank(data.slope.percentile), rollPercentile: rank(data.slope.rollPercentile), [SKIPPED_FIELD]: data.slope.skippedSymbols ?? [] };
|
|
237
237
|
const spreadFormats = { ...ROLL_YIELD_FORMAT, ...thirtySecondsFormat(root, "value") };
|
|
238
|
+
// The status line names the contracts a partial curve lacks, not just that it is partial.
|
|
239
|
+
const incompleteDetail = data.status === "available" ? null : curveIncompleteDetail(data);
|
|
238
240
|
return {
|
|
239
241
|
freshness,
|
|
240
242
|
sections: [
|
|
@@ -252,6 +254,7 @@ export const futuresCurveHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
|
252
254
|
],
|
|
253
255
|
errors: data.gaps,
|
|
254
256
|
...(notes.length ? { notes } : {}),
|
|
257
|
+
...(incompleteDetail ? { incompleteDetail } : {}),
|
|
255
258
|
metadata: { ...data, quoteUnit: unit, ...(spot && bases ? { spot, basisBlankedUnpaired: unpairedContractCount(bases.values()) } : {}),
|
|
256
259
|
...(spotPremium ? { spotPremium } : {}), ...(args.argument ? {} : { defaultArgument: DEFAULT_ROOT }),
|
|
257
260
|
...(notices.length ? { notices } : {}),
|
|
@@ -957,6 +957,30 @@ export function noTradeChangeNote(rows: readonly Pick<FuturesContract, "symbol"
|
|
|
957
957
|
return `Change blank ${named} (no trade since ${data.settlementDate})${options.count ? "" : "."}`;
|
|
958
958
|
}
|
|
959
959
|
|
|
960
|
+
/** Most contract codes a partial curve's status line names before it counts the rest. */
|
|
961
|
+
const NAMED_INCOMPLETE_CONTRACTS = 6;
|
|
962
|
+
|
|
963
|
+
/**
|
|
964
|
+
* What a partial curve leaves out, by contract, for its report's status line:
|
|
965
|
+
* "NGZ31 not resolved", "NGF35, NGG35 unquoted". Null when it names none: a
|
|
966
|
+
* curve from a server that does not list what it could not resolve, or one
|
|
967
|
+
* whose gap is not about a contract.
|
|
968
|
+
*/
|
|
969
|
+
export function curveIncompleteDetail(data: Pick<FuturesCurvePayload, "catalogue" | "contracts">): string | null {
|
|
970
|
+
const codes = (symbols: readonly string[]) => {
|
|
971
|
+
const named = symbols.map(curveContractCode);
|
|
972
|
+
return named.length > NAMED_INCOMPLETE_CONTRACTS
|
|
973
|
+
? `${named.slice(0, NAMED_INCOMPLETE_CONTRACTS).join(", ")} and ${named.length - NAMED_INCOMPLETE_CONTRACTS} more`
|
|
974
|
+
: named.join(", ");
|
|
975
|
+
};
|
|
976
|
+
const unresolved = data.catalogue.unresolved ?? [];
|
|
977
|
+
const unquoted = data.contracts.filter((row) => row.price == null).map((row) => row.symbol);
|
|
978
|
+
return [
|
|
979
|
+
unresolved.length ? `${codes(unresolved)} not resolved` : null,
|
|
980
|
+
unquoted.length ? `${codes(unquoted)} unquoted` : null,
|
|
981
|
+
].filter((part): part is string => part != null).join(", ") || null;
|
|
982
|
+
}
|
|
983
|
+
|
|
960
984
|
/**
|
|
961
985
|
* The archived curve on a past date in the live curve's shape, so the pane
|
|
962
986
|
* draws it the same way. Its week- and month-back ghosts are the curves as
|
|
@@ -340,7 +340,7 @@ function HelpPane({ focused, width, height }: PaneProps) {
|
|
|
340
340
|
? keyEntry("panel-height", ["Shift+Up/Down"], "Make the top panel taller or shorter; Reset Panel Heights in the pane menu puts back the split.")
|
|
341
341
|
: keyEntry("panel-height", ["Drag", "Shift+Up/Down"], tf("Drag the line between two panels to resize them, double-click it for the default split; {taller} and {shorter} resize the top panel.", { taller: keyLabel("Shift+Up"), shorter: keyLabel("Shift+Down") })),
|
|
342
342
|
keyEntry("panel-max", ["Double-click"], "Double-click a panel to give it the whole chart, and again to show every panel."),
|
|
343
|
-
keyEntry("tools-hide", ["Shift+T"], "
|
|
343
|
+
keyEntry("tools-hide", ["Shift+T"], "Keep the drawing tools open, or let them fold again to a single button showing the tool in hand that opens under the pointer."),
|
|
344
344
|
keyEntry("legend-fold", ["Shift+L"], "Fold the legend to its first series and a count of the rest, or open it again."),
|
|
345
345
|
],
|
|
346
346
|
},
|
|
@@ -334,9 +334,9 @@ const IPO_COLUMNS: readonly IpoColumn[] = [
|
|
|
334
334
|
{ id: "status", label: "STATUS", width: 9, align: "left" },
|
|
335
335
|
// "HK$26.20-28.50".
|
|
336
336
|
{ id: "price", label: "PRICE", width: 14, align: "right" },
|
|
337
|
-
// "$218.82M".
|
|
338
|
-
{ id: "size", label: "SIZE", width: 8, align: "right" },
|
|
339
|
-
{ id: "return", label: "RETURN", width: 8, align: "right" },
|
|
337
|
+
// "$218.82M". A deal's size comes with its terms and its return with its first day: an upcoming one has neither.
|
|
338
|
+
{ id: "size", label: "SIZE", width: 8, align: "right", mayBeBlank: true },
|
|
339
|
+
{ id: "return", label: "RETURN", width: 8, align: "right", mayBeBlank: true },
|
|
340
340
|
];
|
|
341
341
|
|
|
342
342
|
/**
|
|
@@ -7,7 +7,7 @@ import { HV_WINDOWS, type HvWindow, type IvLookback, type IvStatRow, projectIvHi
|
|
|
7
7
|
import { vcaUniverse } from "./universe";
|
|
8
8
|
import { offsetText, releaseOffsetRows } from "./events";
|
|
9
9
|
import { loadMacroReleases } from "../macro-day/client";
|
|
10
|
-
import { MACRO_EVENT_LABELS, MACRO_RELEASE_SOURCES, staleMacroReleasesNotice,
|
|
10
|
+
import { IV_EVENT_KINDS, MACRO_EVENT_LABELS, MACRO_RELEASE_SOURCES, staleMacroReleasesNotice, type MacroEventKind, type MacroRelease,
|
|
11
11
|
type MacroReleaseList } from "../macro-day/releases";
|
|
12
12
|
import { lookupScheduledDates } from "../alerts/scheduled";
|
|
13
13
|
import { fetchCpiBoard } from "../cpi/client";
|
|
@@ -37,17 +37,17 @@ export const ivHistoryHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
|
37
37
|
options: [
|
|
38
38
|
{ key: "lookback", type: "enum", values: [{ value: "1Y" }, { value: "2Y" }, { value: "ALL" }], defaultValue: "1Y", description: "Visible history" },
|
|
39
39
|
{ key: "hvWindow", type: "enum", values: HV_WINDOWS.map((window) => ({ value: String(window) })), defaultValue: "20", description: "Realized volatility window in sessions" },
|
|
40
|
-
{ key: "event", type: "enum", aliases: ["release"], values:
|
|
41
|
-
description: "One row per release of this kind whose session at --offset has closed (the next scheduled FOMC or
|
|
40
|
+
{ key: "event", type: "enum", aliases: ["release"], values: IV_EVENT_KINDS.map((value) => ({ value, ...value === "jobs" ? { aliases: ["nfp", "payrolls"] } : {} })),
|
|
41
|
+
description: "One row per release of this kind whose session at --offset has closed (the next scheduled FOMC, CPI or ECB decision included), in place of the daily history",
|
|
42
42
|
example: "--event fomc --offset -6", shot: { reportOnly: "lists the readings around past release days" } },
|
|
43
43
|
{ key: "offset", type: "integer", minimum: -60, maximum: 60, defaultValue: 0,
|
|
44
44
|
description: "Sessions from each release with --event: 0 is the first session on or after the release day, -6 the sixth session before that",
|
|
45
45
|
example: "--event cpi --offset -1", shot: { reportOnly: "picks the session read around each release" } },
|
|
46
46
|
],
|
|
47
47
|
async load(args, ctx) {
|
|
48
|
-
const event = typeof args.options.event === "string" && args.options.event ? args.options.event as
|
|
48
|
+
const event = typeof args.options.event === "string" && args.options.event ? args.options.event as MacroEventKind : null;
|
|
49
49
|
const offset = Number(args.options.offset) || 0;
|
|
50
|
-
if (!event && offset !== 0) throw new Error("--offset counts sessions from a release day: add --event fomc, cpi or
|
|
50
|
+
if (!event && offset !== 0) throw new Error("--offset counts sessions from a release day: add --event fomc, cpi, jobs or ecb.");
|
|
51
51
|
const instrument = await resolveHeadlessInstrument(ctx, args.symbols[0]!);
|
|
52
52
|
// What became of the symbol, as `quote` reads it, looked up beside the figures: FB's are the fund listed
|
|
53
53
|
// there now, TWTR stopped trading, and HFC, which became DINO, has none of its own.
|
|
@@ -237,27 +237,29 @@ export const ivScreenHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
|
237
237
|
* The releases of `event` HIVG reads around: the days MDAY studies (the list
|
|
238
238
|
* the app ships with, extended by Gloom Cloud's), and the next one scheduled,
|
|
239
239
|
* from the CPI board's release calendar or the FOMC meetings WIRP prices, as
|
|
240
|
-
* scheduled alerts read them
|
|
240
|
+
* scheduled alerts read them, or the ECB's next decision as Gloom Cloud lists
|
|
241
|
+
* it with its decision days. Payrolls have no schedule to read.
|
|
241
242
|
*/
|
|
242
|
-
async function eventReleases(event:
|
|
243
|
+
async function eventReleases(event: MacroEventKind, ctx: HeadlessPaneContext): Promise<{
|
|
243
244
|
list: MacroReleaseList; upcoming: string | null; upcomingNote: string | null;
|
|
244
245
|
}> {
|
|
245
246
|
const label = MACRO_EVENT_LABELS[event];
|
|
246
247
|
const [published, next] = await Promise.all([
|
|
247
248
|
loadMacroReleases({}, () => ctx.apiClient.getCloudMacroReleaseDays()),
|
|
248
|
-
event
|
|
249
|
+
event !== "cpi" && event !== "fomc" ? null : lookupScheduledDates([{ kind: "macro", event }], {
|
|
249
250
|
earnings: async () => [],
|
|
250
251
|
cpi: () => fetchCpiBoard(ctx.apiClient),
|
|
251
252
|
fomc: async () => (await fetchRatePath(ctx.apiClient)).meetings,
|
|
252
253
|
}, zonedDateKey(Date.now(), "America/New_York")).then((dates) => dates.get(`macro:${event}`) ?? { date: null }),
|
|
253
254
|
]);
|
|
254
|
-
const upcoming = next && "date" in next ? next.date : null;
|
|
255
|
+
const upcoming = event === "ecb" ? published.scheduled?.ecb ?? null : next && "date" in next ? next.date : null;
|
|
255
256
|
const listed = upcoming != null && published.releases.some((release) => release.kind === event && release.date === upcoming);
|
|
256
257
|
const releases: MacroRelease[] = upcoming && !listed ? [...published.releases, { kind: event, date: upcoming }] : published.releases;
|
|
257
258
|
return {
|
|
258
259
|
list: { ...published, releases },
|
|
259
260
|
upcoming,
|
|
260
|
-
upcomingNote:
|
|
261
|
+
upcomingNote: event === "ecb" ? upcoming ? null : `The next ${label} decision is not scheduled here, so it has no row yet.`
|
|
262
|
+
: next == null ? `The next ${label} release is not scheduled here, so it has no row yet.`
|
|
261
263
|
: "error" in next ? `The next ${label} date could not be loaded (${next.error}), so it has no row.` : null,
|
|
262
264
|
};
|
|
263
265
|
}
|
|
@@ -33,7 +33,7 @@ function inputEntries(inputs: KellyHistoryInputs, edge: number) {
|
|
|
33
33
|
const payoff = inputs.downsideReturn < 0 ? inputs.upsideReturn / -inputs.downsideReturn : null;
|
|
34
34
|
return [
|
|
35
35
|
{ key: "window", label: "Window", value: { start: inputs.start, end: inputs.end, months: inputs.periods },
|
|
36
|
-
formatted: `${inputs.start} to ${inputs.end}, ${inputs.periods} monthly returns` },
|
|
36
|
+
formatted: `${inputs.start} to ${inputs.end}, ${inputs.periods} monthly returns${inputs.rollNote ? `, ${inputs.rollNote}` : ""}` },
|
|
37
37
|
{ key: "winRate", label: "Win rate", value: inputs.winProbability,
|
|
38
38
|
formatted: `${formatPct(inputs.winProbability)} (${inputs.wins} of ${inputs.periods} months up)` },
|
|
39
39
|
{ key: "averageGain", label: "Average gain", value: inputs.upsideReturn, formatted: `${formatSignedPct(inputs.upsideReturn)} a month` },
|
|
@@ -111,7 +111,7 @@ export const kellyHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
|
111
111
|
]);
|
|
112
112
|
const history = resolveEntryValue(entry) ?? [];
|
|
113
113
|
ctx.signal.throwIfAborted();
|
|
114
|
-
const inputs = estimateKellyHistoryInputs(history, years, { exchange });
|
|
114
|
+
const inputs = estimateKellyHistoryInputs(history, years, { exchange, symbol });
|
|
115
115
|
if (!inputs) {
|
|
116
116
|
return {
|
|
117
117
|
complete: false,
|
|
@@ -2,6 +2,7 @@ import type { PricePoint } from "../../../types/financials";
|
|
|
2
2
|
import type { ChartRequest, InstrumentRef } from "../../../market-data/request-types";
|
|
3
3
|
import { dailyBarDate, getPricePointTimestamp } from "../../../utils/price-history";
|
|
4
4
|
import { calendarMonthReturnsRequest, trailingDailyClosesRequest, venueMonth } from "../../../time-series/calendar-month-returns";
|
|
5
|
+
import { rollAdjustedHistory } from "../../../market-data/futures-roll-returns";
|
|
5
6
|
|
|
6
7
|
export const KELLY_HISTORY_DEFAULT_YEARS = 5;
|
|
7
8
|
export const KELLY_HISTORY_MAX_YEARS = 5;
|
|
@@ -24,6 +25,8 @@ export interface KellyHistoryInputs {
|
|
|
24
25
|
/** The newest daily close read, which a month in progress may follow, as YYYY-MM-DD. */
|
|
25
26
|
latest: string;
|
|
26
27
|
years: number;
|
|
28
|
+
/** A continuous future's months read within one contract at each roll: "rolls back-adjusted" (rollAdjustedHistory). */
|
|
29
|
+
rollNote?: string;
|
|
27
30
|
}
|
|
28
31
|
|
|
29
32
|
export function clampKellyHistoryYears(value: unknown): number {
|
|
@@ -50,13 +53,16 @@ export function kellyTrailingHistoryRequest(instrument: InstrumentRef, years: nu
|
|
|
50
53
|
* months are used. Days and the month now are the venue's (`exchange`), a
|
|
51
54
|
* coin's UTC, so a month that has ended in Tokyo counts before it has in UTC. Null
|
|
52
55
|
* when that leaves fewer than `KELLY_HISTORY_MIN_PERIODS` returns, or every
|
|
53
|
-
* one of them is a gain, or every one of them is a loss.
|
|
56
|
+
* one of them is a gain, or every one of them is a loss. A continuous future
|
|
57
|
+
* (`symbol` NG=F) is read within one contract at each roll.
|
|
54
58
|
*/
|
|
55
59
|
export function estimateKellyHistoryInputs(
|
|
56
|
-
|
|
60
|
+
served: readonly PricePoint[],
|
|
57
61
|
yearsInput: number,
|
|
58
|
-
options: { exchange?: string; now?: number } = {},
|
|
62
|
+
options: { exchange?: string; now?: number; symbol?: string } = {},
|
|
59
63
|
): KellyHistoryInputs | null {
|
|
64
|
+
const adjusted = options.symbol ? rollAdjustedHistory(served, options.symbol) : { points: served, note: null };
|
|
65
|
+
const points = adjusted.points;
|
|
60
66
|
const years = clampKellyHistoryYears(yearsInput);
|
|
61
67
|
const now = venueMonth(options.now ?? Date.now(), options.exchange ?? "");
|
|
62
68
|
const thisMonth = `${now.year}-${String(now.month).padStart(2, "0")}`;
|
|
@@ -87,5 +93,6 @@ export function estimateKellyHistoryInputs(
|
|
|
87
93
|
end: picks.at(-1)!.day,
|
|
88
94
|
latest: dailyBarDate(closes.at(-1)!.time, options.exchange ?? ""),
|
|
89
95
|
years,
|
|
96
|
+
...(adjusted.note ? { rollNote: adjusted.note } : {}),
|
|
90
97
|
};
|
|
91
98
|
}
|
|
@@ -323,9 +323,9 @@ export function KellySizerPane({ focused, width, height }: PaneProps) {
|
|
|
323
323
|
const historyPoints = useResolvedEntryValue(historyEntry);
|
|
324
324
|
const historyInputs = useMemo(
|
|
325
325
|
() => historyPoints
|
|
326
|
-
? estimateKellyHistoryInputs(historyPoints, historyYears, { exchange: ticker?.metadata.exchange ?? "" })
|
|
326
|
+
? estimateKellyHistoryInputs(historyPoints, historyYears, { exchange: ticker?.metadata.exchange ?? "", symbol: ticker?.metadata.ticker })
|
|
327
327
|
: null,
|
|
328
|
-
[historyPoints, historyYears, ticker?.metadata.exchange],
|
|
328
|
+
[historyPoints, historyYears, ticker?.metadata.exchange, ticker?.metadata.ticker],
|
|
329
329
|
);
|
|
330
330
|
const rawActiveDraft = drafts[sizingMode] ?? DEFAULT_KELLY_DRAFTS[sizingMode];
|
|
331
331
|
const { commonAssumptions, updateCommon } = useKellyCommonAssumptions(rawActiveDraft);
|
|
@@ -25,7 +25,7 @@ export function buildKellyHistoryItems(inputs: KellyHistoryInputs): StatItem[] {
|
|
|
25
25
|
const payoff = inputs.downsideReturn < 0 ? inputs.upsideReturn / -inputs.downsideReturn : null;
|
|
26
26
|
return [
|
|
27
27
|
// The dates take a row of their own so a narrow pane never cuts them.
|
|
28
|
-
{ id: "window", label: "Window", value: `${inputs.start} to ${inputs.end}`, detail: `${inputs.periods} monthly returns`, wide: true },
|
|
28
|
+
{ id: "window", label: "Window", value: `${inputs.start} to ${inputs.end}`, detail: `${inputs.periods} monthly returns${inputs.rollNote ? `, ${inputs.rollNote}` : ""}`, wide: true },
|
|
29
29
|
{ id: "winRate", label: "Win rate", value: formatPct(inputs.winProbability, 1), detail: `${inputs.wins}/${inputs.periods}` },
|
|
30
30
|
{ id: "avgGain", label: "Avg gain", value: formatSignedPct(inputs.upsideReturn), color: priceColor(inputs.upsideReturn) },
|
|
31
31
|
{ id: "avgLoss", label: "Avg loss", value: formatSignedPct(inputs.downsideReturn), color: priceColor(inputs.downsideReturn) },
|
|
@@ -5,7 +5,7 @@ import { fredSeriesArgument } from "../../../series/fred-argument";
|
|
|
5
5
|
import { formatMacroDayMove, macroDayEventLabel, macroDayReleaseName, macroDayStats, macroFigureGapNotices, matchesSurprise, projectMacroDays, type MacroDayEvent,
|
|
6
6
|
type MacroDayStats } from "./model";
|
|
7
7
|
import { MACRO_EVENT_KINDS, MACRO_EVENT_LABELS, MACRO_RELEASE_SOURCES, MACRO_SURPRISE_LABELS, MACRO_SURPRISES, staleMacroReleasesNotice,
|
|
8
|
-
type MacroEventKind, type MacroReleaseFigures, type MacroSurprise } from "./releases";
|
|
8
|
+
US_MACRO_EVENT_KINDS, type MacroEventKind, type MacroReleaseFigures, type MacroSurprise } from "./releases";
|
|
9
9
|
|
|
10
10
|
// A mean that rounds to zero reads 0.00%, never -0.00%.
|
|
11
11
|
const percent = (value: unknown) => typeof value !== "number" ? "--" : /[1-9]/.test((value * 100).toFixed(2)) ? `${(value * 100).toFixed(2)}%` : "0.00%";
|
|
@@ -15,6 +15,8 @@ const share = (value: unknown) => typeof value === "number" ? `${Math.round(valu
|
|
|
15
15
|
export const macroDayHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
16
16
|
shape: "bundle", argument: { kind: "ticker", description: "Ticker, or a FRED series such as FRED:T10Y2Y", examples: ["TLT", "FRED:T10Y2Y"] },
|
|
17
17
|
usListingsOnly: "Macro release day data",
|
|
18
|
+
// Daily closes in the US session, which a line over the counter has as a listed one does.
|
|
19
|
+
usListingsOtc: true,
|
|
18
20
|
// A spread the catalog prints (FRED:T10Y2Y) moves on release days too: its moves in bp.
|
|
19
21
|
fredSeriesArgument: true,
|
|
20
22
|
// Dated by the release list (releasesThrough) as much as by the closes, so no session schedule applies.
|
|
@@ -22,8 +24,9 @@ export const macroDayHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
|
22
24
|
describe: (args) => `MDAY ${args.symbols[0] ?? ""}`,
|
|
23
25
|
discovery: { screenshotReadiness: "live-dom", limitations: [
|
|
24
26
|
"US listings, or a FRED series (FRED:T10Y2Y, whose moves in a rate or spread read in bp); close-to-close on the release day.",
|
|
25
|
-
"Published CPI, jobs and FOMC days, and Brazil's IPCA days
|
|
26
|
-
"Actual, forecast and prior for the days Gloom Cloud has them (the US headlines from its kept economic calendar, under either feed's title; an FOMC day's are the federal funds target range and whether it held or moved; IPCA from the central bank's SGS series); --surprise keeps the days that came in hot, cool or in line with the forecast.",
|
|
27
|
+
"Published CPI, jobs and FOMC days, and from Gloom Cloud Brazil's IPCA days and the ECB's decision days (every Governing Council monetary policy meeting); sessions after the list's last covered day (releasesThrough) are left out.",
|
|
28
|
+
"Actual, forecast and prior for the days Gloom Cloud has them (the US headlines from its kept economic calendar, under either feed's title; an FOMC day's are the federal funds target range and whether it held or moved, an ECB day's the deposit facility rate; IPCA from the central bank's SGS series); --surprise keeps the days that came in hot, cool or in line with the forecast.",
|
|
29
|
+
"A CPI day the calendar lists without its year-on-year actual takes one computed from the CPI index against a year earlier, labelled computed.",
|
|
27
30
|
"A release day without figures says why: before the kept calendar starts, or listed without them.",
|
|
28
31
|
"A release day that is also the reaction session of the company's own earnings report is marked earnings and left out of the release averages and the normal day.",
|
|
29
32
|
] },
|
|
@@ -66,6 +69,8 @@ export const macroDayHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
|
66
69
|
// A day without figures says why: before the kept calendar (one note for them all), or the calendar's own gap.
|
|
67
70
|
const figuresFrom = releases.figuresFrom;
|
|
68
71
|
const beforeCalendar = (event: MacroDayEvent) => !!figuresFrom && event.kind !== "ipca" && !event.figures && event.date < figuresFrom;
|
|
72
|
+
// A release Gloom Cloud alone lists (IPCA, the ECB) is summed up on its own: "Any release" is then the US ones'.
|
|
73
|
+
const usOnly = model.kinds.some((kind) => !US_MACRO_EVENT_KINDS.includes(kind as (typeof US_MACRO_EVENT_KINDS)[number]));
|
|
69
74
|
const missing = (event: MacroDayEvent) => event.figures ? null : event.figuresMissing
|
|
70
75
|
?? (beforeCalendar(event) ? `before ${figuresFrom}, when Gloom Cloud's economic calendar starts` : null);
|
|
71
76
|
const figureNotes = [
|
|
@@ -78,12 +83,15 @@ export const macroDayHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
|
78
83
|
{ key: "meanAbs", header: header("Avg |move|"), format: absMove }, { key: "multiple", header: "vs normal", format: multiple },
|
|
79
84
|
{ key: "mean", header: header("Avg move"), format: move }, { key: "hitRate", header: "Up", format: share }],
|
|
80
85
|
rows: [...model.kinds.map((kind) => row(MACRO_EVENT_LABELS[kind], model.byKind[kind])), ...selected,
|
|
81
|
-
row(
|
|
86
|
+
row(usOnly ? "Any US release" : "Any release", model.allEvents), ...(model.earnings.count ? [row("Earnings", model.earnings)] : []), row("Normal day", model.normal)] },
|
|
82
87
|
{ title: "Release days", columns: [{ key: "date", header: "Date" },
|
|
83
88
|
// The text table reads the decision beside its release (FOMC held), as the pane does; exports keep the two apart.
|
|
84
89
|
{ key: "event", header: "Release", textFormat: (_value, row) => macroDayEventLabel({ kind: row.kind as MacroEventKind,
|
|
85
90
|
earnings: row.earnings === true, figures: typeof row.decision === "string" ? { decision: row.decision } as MacroReleaseFigures : null }) },
|
|
86
|
-
|
|
91
|
+
// A computed actual (a CPI's year-on-year change from the index) says so beside it; the export keeps the flag apart.
|
|
92
|
+
{ key: "actual", header: "Actual", textFormat: (value, row) => typeof value !== "string" ? "-"
|
|
93
|
+
: row.actualComputed === true ? `${value} (computed)` : value },
|
|
94
|
+
{ key: "forecast", header: "Forecast" }, { key: "prior", header: "Prior" },
|
|
87
95
|
{ key: "surprise", header: "Surprise" },
|
|
88
96
|
{ key: "session", header: "Session" }, { key: "move", header: header("Move"), format: move }, { key: "multiple", header: "vs normal", format: multiple }],
|
|
89
97
|
rows: events.map((day) => {
|
|
@@ -92,6 +100,8 @@ export const macroDayHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
|
92
100
|
return { ...event, event: macroDayReleaseName(day), actual: figures?.actual ?? null,
|
|
93
101
|
forecast: figures?.forecast ?? null, prior: figures?.prior ?? null, surprise: figures?.surprise ?? null,
|
|
94
102
|
...(figures ? { headline: figures.event } : {}), ...(figures?.decision ? { decision: figures.decision } : {}),
|
|
103
|
+
...(figures?.computed ? { actualComputed: true, actualBasis: figures.computed } : {}),
|
|
104
|
+
...(figures?.actualMissing ? { actualMissing: figures.actualMissing } : {}),
|
|
95
105
|
...(why ? { figuresMissing: why } : {}) };
|
|
96
106
|
}) },
|
|
97
107
|
],
|
|
@@ -3,6 +3,7 @@ import type { PricePoint } from "../../../types/financials";
|
|
|
3
3
|
import { zonedDateTimeParts } from "../../../utils/zoned-date-time";
|
|
4
4
|
import { toBasisPoints } from "../../../utils/basis-points";
|
|
5
5
|
import { isYieldIndexSymbol } from "../../../tickers/index-roots";
|
|
6
|
+
import { pricePointCloseCopied } from "../../../utils/price-history-integrity";
|
|
6
7
|
import { MACRO_EVENT_KINDS, MACRO_EVENT_LABELS, US_MACRO_EVENT_KINDS, type MacroEventKind, type MacroRelease, type MacroReleaseFigures,
|
|
7
8
|
type MacroSurprise } from "./releases";
|
|
8
9
|
|
|
@@ -107,10 +108,18 @@ export const macroDayEventLabel = (event: Pick<MacroDayEvent, "kind" | "earnings
|
|
|
107
108
|
export const macroDayReleaseName = (event: Pick<MacroDayEvent, "kind" | "earnings">) =>
|
|
108
109
|
event.earnings ? `${MACRO_EVENT_LABELS[event.kind]} (earnings)` : MACRO_EVENT_LABELS[event.kind];
|
|
109
110
|
|
|
110
|
-
/**
|
|
111
|
+
/**
|
|
112
|
+
* One line for each release day the economic calendar covers that has no
|
|
113
|
+
* figures, or no actual, saying why, and for each whose actual is computed
|
|
114
|
+
* (a CPI's year-on-year change from the index), saying how.
|
|
115
|
+
*/
|
|
111
116
|
export const macroFigureGapNotices = (events: readonly Pick<MacroDayEvent, "kind" | "date" | "figures" | "figuresMissing">[]) =>
|
|
112
|
-
events.
|
|
113
|
-
|
|
117
|
+
events.flatMap((event) => {
|
|
118
|
+
const label = `${event.date} ${MACRO_EVENT_LABELS[event.kind]}`;
|
|
119
|
+
if (!event.figures) return event.figuresMissing ? [`${label} has no figures: ${event.figuresMissing}.`] : [];
|
|
120
|
+
if (event.figures.computed) return [`${label} actual is ${event.figures.computed}.`];
|
|
121
|
+
return event.figures.actualMissing ? [`${label} has no actual: ${event.figures.actualMissing}.`] : [];
|
|
122
|
+
});
|
|
114
123
|
|
|
115
124
|
/** What a row adds to its release's name: a policy decision's move, and the earnings marker. */
|
|
116
125
|
export const macroDayEventNote = (event: Pick<MacroDayEvent, "earnings" | "figures">) =>
|
|
@@ -191,17 +200,20 @@ export function projectMacroDays(history: readonly PricePoint[], options: {
|
|
|
191
200
|
const { coveredThrough } = options;
|
|
192
201
|
const basis = options.basis ?? macroDayMoveBasis(options.symbol);
|
|
193
202
|
const byDate = new Map<string, number>();
|
|
203
|
+
// A pair's sessions whose close the source copied from the open, which nothing rebuilt: no move into or out of them is a day's.
|
|
204
|
+
const copied = new Set<string>();
|
|
194
205
|
for (const point of history) {
|
|
195
206
|
const time = new Date(point.date).getTime();
|
|
196
207
|
// A yield can sit at zero or below it; a price cannot.
|
|
197
208
|
if (!Number.isFinite(time) || !Number.isFinite(point.close) || (basis === "return" && point.close <= 0)) continue;
|
|
198
209
|
byDate.set(sessionDate(time), point.close);
|
|
210
|
+
if (pricePointCloseCopied(point)) copied.add(sessionDate(time));
|
|
199
211
|
}
|
|
200
212
|
const sessions = [...byDate.keys()].sort();
|
|
201
213
|
const last = sessions.at(-1) ?? null;
|
|
202
214
|
const empty = (): MacroDayStats => stats([], null);
|
|
203
215
|
const kinds = MACRO_EVENT_KINDS.filter((kind) => US_KINDS.has(kind) || options.releases.some((release) => release.kind === kind));
|
|
204
|
-
if (!last) return { symbol: options.symbol, basis, events: [], kinds, byKind: { cpi: empty(), jobs: empty(), fomc: empty(), ipca: empty() },
|
|
216
|
+
if (!last) return { symbol: options.symbol, basis, events: [], kinds, byKind: { cpi: empty(), jobs: empty(), fomc: empty(), ipca: empty(), ecb: empty() },
|
|
205
217
|
allEvents: empty(), earnings: empty(), normal: empty(), start: null, asOf: null };
|
|
206
218
|
|
|
207
219
|
// Sessions after the published lists end may be unlisted release days, so they are left out of both sides.
|
|
@@ -217,6 +229,7 @@ export function projectMacroDays(history: readonly PricePoint[], options: {
|
|
|
217
229
|
for (let index = 1; index < sessions.length; index++) {
|
|
218
230
|
const date = sessions[index]!, previous = sessions[index - 1]!;
|
|
219
231
|
if (date <= start || date > end || dayNumber(date) - dayNumber(previous) > MAX_SESSION_GAP_DAYS) continue;
|
|
232
|
+
if (copied.has(date) || copied.has(previous)) continue;
|
|
220
233
|
moves.set(date, basis === "yield" ? byDate.get(date)! - byDate.get(previous)! : byDate.get(date)! / byDate.get(previous)! - 1);
|
|
221
234
|
}
|
|
222
235
|
|