@gloom-sh/terminal 0.20.9 → 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/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 +26 -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/headless.ts +4 -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/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/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/fx-closes.ts +14 -2
- package/src/market-data/market/change-basis.ts +35 -1
- package/src/market-data/market/status.ts +37 -0
- package/src/market-data/performance.ts +4 -1
- 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/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/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/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/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/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/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/host/image-surface.tsx +19 -9
- package/src/renderers/dom/host/input.tsx +4 -0
- package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +23 -1
- 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 +20 -0
- package/src/types/headless.ts +9 -0
- package/src/ui/host.tsx +2 -0
- package/src/utils/exchanges.ts +13 -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,6 +1,6 @@
|
|
|
1
1
|
import type { DataTableCell, DataTableColumn } from "../../../components";
|
|
2
2
|
import { withCompanyLogo } from "../../../components/company-logo";
|
|
3
|
-
import { TABLE_COLUMN_GAP, tableColumnWidth } from "../../../components/ui/table-layout";
|
|
3
|
+
import { TABLE_COLUMN_GAP, tableColumnLeadGap, tableColumnWidth } from "../../../components/ui/table-layout";
|
|
4
4
|
import { colors } from "../../../theme/colors";
|
|
5
5
|
import { TextAttributes } from "../../../ui";
|
|
6
6
|
import { epsBasisShort, showsEpsBasis } from "../shared/earnings-report";
|
|
@@ -8,27 +8,33 @@ import type { BoardReport, BoardRow, BoardSort } from "./board-model";
|
|
|
8
8
|
import { epsText, impliedText, moneyText, moveSize, signedPercent, TIMING_LABEL, weekday } from "./format";
|
|
9
9
|
|
|
10
10
|
type BoardColumnId =
|
|
11
|
-
| "owned" | "symbol" | "name" | "when" | "status" | "cap" | "epsEstimate" | "analysts" | "epsActual" | "basis"
|
|
11
|
+
| "owned" | "symbol" | "name" | "when" | "status" | "cap" | "ccy" | "epsEstimate" | "analysts" | "epsActual" | "basis"
|
|
12
12
|
| "epsSurprise" | "revenueEstimate" | "implied" | "move" | "average";
|
|
13
13
|
|
|
14
14
|
export type BoardColumn = DataTableColumn & { id: BoardColumnId };
|
|
15
15
|
|
|
16
16
|
const NAME_MIN_WIDTH = 12;
|
|
17
|
+
/** TICKER fits a US ticker; a listing abroad's key is longer (0700:HKEX, 601939:SSE, 000333:SZSE). */
|
|
18
|
+
const SYMBOL_WIDTH = 6;
|
|
19
|
+
const SYMBOL_MAX_WIDTH = 11;
|
|
17
20
|
|
|
18
21
|
const ALL_COLUMNS: BoardColumn[] = [
|
|
19
22
|
{ id: "owned", label: "", width: 1, align: "left" },
|
|
20
|
-
{ id: "symbol", label: "TICKER", width:
|
|
23
|
+
{ id: "symbol", label: "TICKER", width: SYMBOL_WIDTH, align: "left" },
|
|
21
24
|
{ id: "name", label: "NAME", width: NAME_MIN_WIDTH, align: "left" },
|
|
22
25
|
{ id: "when", label: "WHEN", width: 7, align: "left" },
|
|
23
26
|
{ id: "status", label: "STATUS", width: 9, align: "left" },
|
|
24
27
|
{ id: "implied", label: "IMPLIED", width: 7, align: "right" },
|
|
25
|
-
|
|
28
|
+
// The move, the actual EPS and its surprise come with the report: an upcoming one has none.
|
|
29
|
+
{ id: "move", label: "MOVE", width: 7, align: "right", mayBeBlank: true },
|
|
26
30
|
{ id: "average", label: "AVG MOVE", width: 8, align: "right" },
|
|
31
|
+
// The currency of the EPS and sales figures, on a board with a listing abroad's (CNY for Tencent).
|
|
32
|
+
{ id: "ccy", label: "CCY", width: 3, align: "left" },
|
|
27
33
|
{ id: "epsEstimate", label: "EPS EST", width: 7, align: "right" },
|
|
28
34
|
{ id: "analysts", label: "ESTS", width: 4, align: "right" },
|
|
29
|
-
{ id: "epsActual", label: "EPS ACT", width: 7, align: "right" },
|
|
35
|
+
{ id: "epsActual", label: "EPS ACT", width: 7, align: "right", mayBeBlank: true },
|
|
30
36
|
{ id: "basis", label: "BASIS", width: 5, align: "left" },
|
|
31
|
-
{ id: "epsSurprise", label: "EPS SURP", width: 8, align: "right" },
|
|
37
|
+
{ id: "epsSurprise", label: "EPS SURP", width: 8, align: "right", mayBeBlank: true },
|
|
32
38
|
{ id: "revenueEstimate", label: "SALES EST", width: 9, align: "right" },
|
|
33
39
|
{ id: "cap", label: "MKT CAP", width: 8, align: "right" },
|
|
34
40
|
];
|
|
@@ -36,8 +42,9 @@ const ALL_COLUMNS: BoardColumn[] = [
|
|
|
36
42
|
/**
|
|
37
43
|
* Dropped first when narrow, the report's labels before its figures; the
|
|
38
44
|
* implied move, the move on the report and their average stay beside the name.
|
|
45
|
+
* CCY goes only with the last figure it is the currency of.
|
|
39
46
|
*/
|
|
40
|
-
const DROP_ORDER: BoardColumnId[] = ["basis", "analysts", "epsSurprise", "status", "epsActual", "cap", "revenueEstimate", "epsEstimate", "owned"];
|
|
47
|
+
const DROP_ORDER: BoardColumnId[] = ["basis", "analysts", "epsSurprise", "status", "epsActual", "cap", "revenueEstimate", "epsEstimate", "ccy", "owned"];
|
|
41
48
|
|
|
42
49
|
/**
|
|
43
50
|
* With an actual on the board the report is the news: EPS ACT, then EPS SURP,
|
|
@@ -46,9 +53,12 @@ const DROP_ORDER: BoardColumnId[] = ["basis", "analysts", "epsSurprise", "status
|
|
|
46
53
|
* goes. Without one, those two columns would be empty, so DROP_ORDER holds.
|
|
47
54
|
*/
|
|
48
55
|
const REPORTED_DROP_ORDER: BoardColumnId[] = [
|
|
49
|
-
"basis", "analysts", "status", "average", "cap", "revenueEstimate", "epsSurprise", "epsActual", "epsEstimate", "owned",
|
|
56
|
+
"basis", "analysts", "status", "average", "cap", "revenueEstimate", "epsSurprise", "epsActual", "epsEstimate", "ccy", "owned",
|
|
50
57
|
];
|
|
51
58
|
|
|
59
|
+
/** The columns in the report's currency, which CCY names. */
|
|
60
|
+
const CURRENCY_FIGURES: BoardColumnId[] = ["epsEstimate", "epsActual", "revenueEstimate"];
|
|
61
|
+
|
|
52
62
|
/** Header clicks sort these; the rest keep the ranking. */
|
|
53
63
|
export const SORTABLE: Partial<Record<BoardColumnId, BoardSort["column"]>> = {
|
|
54
64
|
symbol: "symbol", cap: "cap", implied: "implied", average: "average",
|
|
@@ -59,14 +69,41 @@ export function boardHasActuals(rows: readonly BoardRow[]): boolean {
|
|
|
59
69
|
return rows.some((row) => row.kind === "report" && row.report.epsActual != null);
|
|
60
70
|
}
|
|
61
71
|
|
|
62
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Whether a report on the board is in another currency than dollars (a
|
|
74
|
+
* listing abroad's): the board then shows CCY, and says its market cap is in
|
|
75
|
+
* dollars (boardColumns). A board of US reports looks as it always has.
|
|
76
|
+
*/
|
|
77
|
+
export function boardHasCurrencies(rows: readonly BoardRow[]): boolean {
|
|
78
|
+
return rows.some((row) => row.kind === "report" && row.report.currency != null && row.report.currency !== "USD");
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** TICKER's width for the board's symbols: a US ticker's, or wide enough for the longest listing abroad's key. */
|
|
82
|
+
export function boardSymbolWidth(rows: readonly BoardRow[]): number {
|
|
83
|
+
const longest = Math.max(0, ...rows.map((row) => (row.kind === "report" ? row.report.symbol.length : 0)));
|
|
84
|
+
return Math.min(SYMBOL_MAX_WIDTH, Math.max(SYMBOL_WIDTH, longest));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function boardColumns(
|
|
88
|
+
width: number,
|
|
89
|
+
{ actuals = false, currencies = false, symbolWidth = SYMBOL_WIDTH }: { actuals?: boolean; currencies?: boolean; symbolWidth?: number } = {},
|
|
90
|
+
): BoardColumn[] {
|
|
91
|
+
// Every column but the name, with the space a left-aligned column keeps from a right-aligned one before it (CCY after
|
|
92
|
+
// AVG MOVE, BASIS after EPS ACT), so the last column is never cut at the pane's edge.
|
|
63
93
|
const fixed = (list: BoardColumn[]) =>
|
|
64
|
-
list.reduce((sum, column) =>
|
|
65
|
-
|
|
94
|
+
list.reduce((sum, column, index) =>
|
|
95
|
+
sum + tableColumnLeadGap(list, index, TABLE_COLUMN_GAP) + (column.id === "name" ? 0 : tableColumnWidth(column)) + TABLE_COLUMN_GAP, 2);
|
|
96
|
+
// Beside figures in yuan or Hong Kong dollars, the cap says it is in dollars.
|
|
97
|
+
let columns = (currencies ? ALL_COLUMNS : ALL_COLUMNS.filter((column) => column.id !== "ccy")).map((column) =>
|
|
98
|
+
column.id === "cap" && currencies ? { ...column, label: "MKT CAP $", width: 9 }
|
|
99
|
+
: column.id === "symbol" ? { ...column, width: symbolWidth }
|
|
100
|
+
: column);
|
|
66
101
|
for (const id of actuals ? REPORTED_DROP_ORDER : DROP_ORDER) {
|
|
67
102
|
if (fixed(columns) + NAME_MIN_WIDTH <= width) break;
|
|
68
103
|
columns = columns.filter((column) => column.id !== id);
|
|
69
104
|
}
|
|
105
|
+
// CCY is the currency of the figures beside it; with none left it goes too.
|
|
106
|
+
if (!columns.some((column) => CURRENCY_FIGURES.includes(column.id))) columns = columns.filter((column) => column.id !== "ccy");
|
|
70
107
|
// The name takes what the other columns leave.
|
|
71
108
|
const nameWidth = Math.max(NAME_MIN_WIDTH, width - fixed(columns));
|
|
72
109
|
return columns.map((column) => (column.id === "name" ? { ...column, width: nameWidth } : column));
|
|
@@ -120,6 +157,8 @@ export function renderBoardCell(row: BoardRow, column: BoardColumn, context: Boa
|
|
|
120
157
|
return { text: report.dateStatus ?? "--", color: report.dateStatus === "projected" ? colors.textMuted : dim };
|
|
121
158
|
case "cap":
|
|
122
159
|
return { text: moneyText(report.marketCap), color: dim };
|
|
160
|
+
case "ccy":
|
|
161
|
+
return { text: report.currency ?? "--", color: dim };
|
|
123
162
|
case "epsEstimate":
|
|
124
163
|
return { text: epsText(report.epsEstimate), color: dim };
|
|
125
164
|
case "analysts":
|
|
@@ -25,9 +25,12 @@ import { useAssetData, usePluginAppActions, usePluginTickerActions } from "../..
|
|
|
25
25
|
import { earningsResultsAlertValues } from "../alerts/research-builder";
|
|
26
26
|
import { cachedMembers, loadMembers } from "../members/client";
|
|
27
27
|
import { isBoardRowLoading, useQuoteBoard } from "../shared/use-quote-board";
|
|
28
|
+
import { listingAbroadVenue } from "../../../utils/sec";
|
|
28
29
|
import {
|
|
29
30
|
addDays,
|
|
31
|
+
boardKey,
|
|
30
32
|
boardReport,
|
|
33
|
+
boardRowOf,
|
|
31
34
|
boardRows,
|
|
32
35
|
fallbackReport,
|
|
33
36
|
newYorkToday,
|
|
@@ -38,7 +41,7 @@ import {
|
|
|
38
41
|
type BoardRow,
|
|
39
42
|
type BoardSort,
|
|
40
43
|
} from "./board-model";
|
|
41
|
-
import { boardColumns, boardHasActuals, renderBoardCell, renderBoardSection, SORTABLE, type BoardCellContext, type BoardColumn } from "./board-table";
|
|
44
|
+
import { boardColumns, boardHasActuals, boardHasCurrencies, boardSymbolWidth, renderBoardCell, renderBoardSection, SORTABLE, type BoardCellContext, type BoardColumn } from "./board-table";
|
|
42
45
|
import { EarningsCalendarView, CALENDAR_GROUP_ROWS, calendarSlotsPerRow } from "./calendar";
|
|
43
46
|
import {
|
|
44
47
|
boardRangeDays,
|
|
@@ -99,7 +102,9 @@ interface BoardData {
|
|
|
99
102
|
* ERN without a ticker: the market's report days, largest companies first,
|
|
100
103
|
* with the implied move and each company's average move. With tickers, or the
|
|
101
104
|
* Names filter (Mine, a portfolio, a watchlist or a fund's holdings),
|
|
102
|
-
* the upcoming reports of those companies instead.
|
|
105
|
+
* the upcoming reports of those companies instead. Every board reads the Hong
|
|
106
|
+
* Kong, China A and Singapore top 100's reports too, ranked by their value in
|
|
107
|
+
* dollars beside US companies, each with the currency of its figures (CCY).
|
|
103
108
|
*/
|
|
104
109
|
export function EarningsBoard({ focused, width, height, scopedSymbols, highlight = null }: {
|
|
105
110
|
focused: boolean;
|
|
@@ -185,13 +190,18 @@ export function EarningsBoard({ focused, width, height, scopedSymbols, highlight
|
|
|
185
190
|
const days = useMemo(() => (market || range ? boardRangeDays(range, today) : relativeDays(today)), [market, range, today]);
|
|
186
191
|
const weekOffset = boardRangeWeek(range, today);
|
|
187
192
|
const week = useMemo(() => calendarWeekDates(today, weekOffset), [today, weekOffset]);
|
|
188
|
-
//
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
193
|
+
// EVTS 0700.HK names its listing, which the market board then keeps whatever the day's cut.
|
|
194
|
+
const highlightListing = market && highlight && listingAbroadVenue(boardKey(highlight)) ? boardKey(highlight) : null;
|
|
195
|
+
// The calendar reads its week, reported days included; the table its days. Each report says its currency
|
|
196
|
+
// (CCY), so every board reads the listings abroad too.
|
|
197
|
+
const query = useMemo<EarningsCalendarQuery>(() => {
|
|
198
|
+
const symbols = highlightListing && !named.includes(highlightListing) ? [...named, highlightListing] : named;
|
|
199
|
+
return calendar
|
|
200
|
+
? { from: week[0]!, to: week.at(-1)!, perDay: market ? MARKET_PER_DAY : 0, symbols, markets: "all" }
|
|
201
|
+
: market || range
|
|
202
|
+
? { from: days[0]!.from, to: days.at(-1)!.to, perDay: market ? MARKET_PER_DAY : 0, symbols, markets: "all" }
|
|
203
|
+
: { from: today, to: addDays(today, HORIZON_DAYS), perDay: 0, symbols, markets: "all" };
|
|
204
|
+
}, [calendar, days, highlightListing, market, named, range, today, week]);
|
|
195
205
|
// A fund's read is named by the fund: its companies are known once its holdings are.
|
|
196
206
|
const queryKey = fund ? `${fund.etf}|${earningsCalendarKey(query)}` : earningsCalendarKey(query);
|
|
197
207
|
|
|
@@ -208,7 +218,8 @@ export function EarningsBoard({ focused, width, height, scopedSymbols, highlight
|
|
|
208
218
|
]);
|
|
209
219
|
if (cloud.status === "rejected" && (!perTicker || fallback.status === "rejected")) throw cloud.reason;
|
|
210
220
|
const reports = cloud.status === "fulfilled" ? cloud.value.payload.reports.map((report) => boardReport(report, owned)) : [];
|
|
211
|
-
|
|
221
|
+
// A listing abroad named by another of its company's lines (0939.HK) is covered by its row.
|
|
222
|
+
const covered = new Set(reports.flatMap((report) => [report.symbol, ...report.listings ?? []]));
|
|
212
223
|
const extra = fallback.status === "fulfilled"
|
|
213
224
|
? fallback.value.filter((event) => !covered.has(event.symbol)).map((event) => fallbackReport(event, owned, today))
|
|
214
225
|
: [];
|
|
@@ -248,9 +259,13 @@ export function EarningsBoard({ focused, width, height, scopedSymbols, highlight
|
|
|
248
259
|
const selected = reportRows.find((row) => row.key === selectedKey) ?? reportRows[0] ?? null;
|
|
249
260
|
const open = reportRows.find((row) => row.key === openKey)?.report
|
|
250
261
|
?? (openKey ? data?.reports.find((report) => report.key === openKey) : undefined) ?? null;
|
|
251
|
-
// A board with an actual keeps EPS ACT and EPS SURP when narrow
|
|
262
|
+
// A board with an actual keeps EPS ACT and EPS SURP when narrow, and one with a listing abroad's report shows CCY;
|
|
263
|
+
// keyed by the flags, so the columns hold between renders.
|
|
252
264
|
const actuals = boardHasActuals(rows);
|
|
253
|
-
const
|
|
265
|
+
const currencies = boardHasCurrencies(rows);
|
|
266
|
+
// TICKER fits a listing abroad's key (601939:SSE) when the board has one.
|
|
267
|
+
const symbolWidth = boardSymbolWidth(rows);
|
|
268
|
+
const columns = useMemo(() => boardColumns(width, { actuals, currencies, symbolWidth }), [actuals, currencies, symbolWidth, width]);
|
|
254
269
|
// The move on each report out today, beside its implied move, from the quotes every board reads.
|
|
255
270
|
// Keyed by content: the rows are rebuilt on renders that change nothing, and the quote board reloads on a new list.
|
|
256
271
|
const reportedKey = [...new Set(reportRows.filter((row) => row.report.dateStatus === "reported" && row.report.date === today)
|
|
@@ -292,7 +307,8 @@ export function EarningsBoard({ focused, width, height, scopedSymbols, highlight
|
|
|
292
307
|
|
|
293
308
|
useEffect(() => {
|
|
294
309
|
if (!highlight || highlighted.current === highlight) return;
|
|
295
|
-
|
|
310
|
+
// 0700.HK as typed is the board's 0700:HKEX; 0939.HK is CCB's row under its A share.
|
|
311
|
+
const row = reportRows.find((candidate) => boardRowOf(candidate.report, highlight));
|
|
296
312
|
if (!row) return;
|
|
297
313
|
highlighted.current = highlight;
|
|
298
314
|
setSelectedKey(row.key);
|
|
@@ -88,9 +88,11 @@ function locate(grid: readonly Slot[][][], key: string | null): Position | null
|
|
|
88
88
|
/** What hovering a logo says: the company, when it reports and, once out, how it did. */
|
|
89
89
|
function reportTitle(report: BoardReport): string {
|
|
90
90
|
const when = report.timing ? TIMING_LABEL[report.timing] : "time not set";
|
|
91
|
+
// A listing abroad's figures say their currency (CNY for Tencent), as the table's CCY does.
|
|
92
|
+
const currency = report.currency && report.currency !== "USD" ? ` ${report.currency}` : "";
|
|
91
93
|
const figures = report.epsActual != null
|
|
92
|
-
? `EPS ${epsText(report.epsActual)} vs ${epsText(report.epsEstimate)} est${report.epsSurprise != null ? `, ${signedPercent(report.epsSurprise)}` : ""}`
|
|
93
|
-
: report.epsEstimate != null ? `EPS est ${epsText(report.epsEstimate)}` : null;
|
|
94
|
+
? `EPS ${epsText(report.epsActual)} vs ${epsText(report.epsEstimate)} est${currency}${report.epsSurprise != null ? `, ${signedPercent(report.epsSurprise)}` : ""}`
|
|
95
|
+
: report.epsEstimate != null ? `EPS est ${epsText(report.epsEstimate)}${currency}` : null;
|
|
94
96
|
return [`${report.symbol} · ${report.name}`, when, figures].filter(Boolean).join(" · ");
|
|
95
97
|
}
|
|
96
98
|
|
|
@@ -267,6 +269,14 @@ const TILE_STYLE = {
|
|
|
267
269
|
} as const;
|
|
268
270
|
/** The logo of a calendar tile: a square near two cells tall, most of the slot's width. */
|
|
269
271
|
const LOGO_STYLE = { width: "calc(var(--cell-h) * 1.75)", height: "calc(var(--cell-h) * 1.75)", flexShrink: 0 } as const;
|
|
272
|
+
/** The ticker under the logo is never wider than its tile: it ends in an ellipsis instead of running under the next. */
|
|
273
|
+
const LABEL_STYLE = { maxWidth: "100%", minWidth: 0 } as const;
|
|
274
|
+
|
|
275
|
+
/** A tile's ticker: a listing abroad's code without its venue (0700 for 0700:HKEX), which the tile's title names. */
|
|
276
|
+
function tileLabel(symbol: string): string {
|
|
277
|
+
const venue = symbol.indexOf(":");
|
|
278
|
+
return venue > 0 ? symbol.slice(0, venue) : symbol;
|
|
279
|
+
}
|
|
270
280
|
|
|
271
281
|
function ReportTile({ report, selected, onPress, tileRef }: {
|
|
272
282
|
report: BoardReport;
|
|
@@ -299,7 +309,9 @@ function ReportTile({ report, selected, onPress, tileRef }: {
|
|
|
299
309
|
<Box style={LOGO_STYLE}>
|
|
300
310
|
<CompanyLogoMark symbol={report.symbol} name={report.name} size="lead" />
|
|
301
311
|
</Box>
|
|
302
|
-
<
|
|
312
|
+
<Box style={LABEL_STYLE}>
|
|
313
|
+
<ClippedText text={tileLabel(report.symbol)} width={CALENDAR_SLOT_CELLS - 1} fg={ink} attributes={TextAttributes.BOLD} />
|
|
314
|
+
</Box>
|
|
303
315
|
</Box>
|
|
304
316
|
);
|
|
305
317
|
}
|
|
@@ -32,11 +32,14 @@ export function resetEarningsCloudCaches() {
|
|
|
32
32
|
|
|
33
33
|
const isDate = (value: unknown) => typeof value === "string" && /^\d{4}-\d{2}-\d{2}$/.test(value);
|
|
34
34
|
const numberOrNull = (value: unknown) => value === null || (typeof value === "number" && Number.isFinite(value));
|
|
35
|
+
const currencyOrAbsent = (value: unknown) => value == null || (typeof value === "string" && /^[A-Z]{3}$/.test(value));
|
|
36
|
+
const linesOrAbsent = (value: unknown) => value == null || (Array.isArray(value) && value.every((line) => typeof line === "string"));
|
|
35
37
|
|
|
36
38
|
function validReport(report: EarningsReport): boolean {
|
|
37
39
|
return !!report && typeof report.symbol === "string" && isDate(report.date)
|
|
38
40
|
&& [null, "bmo", "dmh", "amc"].includes(report.timing)
|
|
39
41
|
&& [report.marketCap, report.epsEstimate, report.epsActual, report.revenueEstimate].every(numberOrNull)
|
|
42
|
+
&& currencyOrAbsent(report.currency) && linesOrAbsent(report.listings)
|
|
40
43
|
&& (report.implied === null || (typeof report.implied === "object" && Number.isFinite(report.implied.move) && isDate(report.implied.expiry)))
|
|
41
44
|
&& (report.realized === null || (typeof report.realized === "object" && Number.isFinite(report.realized.move)));
|
|
42
45
|
}
|
|
@@ -69,7 +72,7 @@ type HistoryClient = Pick<typeof apiClient, "getCloudEarningsHistory">;
|
|
|
69
72
|
|
|
70
73
|
/** Names a calendar query: the cache's key, and how the board tells one week's reports from another's. */
|
|
71
74
|
export const earningsCalendarKey = (query: EarningsCalendarQuery) =>
|
|
72
|
-
`${query.from}:${query.to}:${query.perDay ?? ""}:${[...(query.symbols ?? [])].sort().join(",")}`;
|
|
75
|
+
`${query.from}:${query.to}:${query.perDay ?? ""}:${[...(query.symbols ?? [])].sort().join(",")}${query.markets ? `:${query.markets}` : ""}`;
|
|
73
76
|
|
|
74
77
|
export async function fetchEarningsCalendar(query: EarningsCalendarQuery, client: CalendarClient = apiClient) {
|
|
75
78
|
try {
|
|
@@ -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) {
|
|
@@ -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
|
}
|
|
@@ -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
|
],
|