@gloom-sh/terminal 0.20.10 → 0.20.11

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.
Files changed (103) hide show
  1. package/package.json +1 -1
  2. package/patches/@opentui%2Fcore@0.3.2.patch +16 -0
  3. package/src/api-client/socket-connection.ts +355 -0
  4. package/src/api-client/socket-features.ts +75 -0
  5. package/src/api-client/socket-frames.ts +161 -0
  6. package/src/api-client/socket-listeners.ts +207 -0
  7. package/src/api-client/socket-quotes.ts +332 -0
  8. package/src/api-client/socket.ts +150 -983
  9. package/src/brokers/signed-in/adapter.ts +19 -5
  10. package/src/brokers/signed-in/client.ts +13 -1
  11. package/src/brokers/signed-in/sign-in-dialog.tsx +33 -9
  12. package/src/components/chart/native/kitty/manager.ts +2 -0
  13. package/src/components/chart/native/surface/manager.ts +211 -11
  14. package/src/components/command-bar/panel/index.tsx +2 -13
  15. package/src/components/command-bar/panel/layout.ts +1 -7
  16. package/src/components/command-bar/panel/runtime.ts +0 -1
  17. package/src/components/command-bar/panel/types.ts +0 -2
  18. package/src/components/data-table/column-menu.tsx +89 -0
  19. package/src/components/data-table/sort-menu.tsx +9 -2
  20. package/src/components/data-table/view.tsx +33 -6
  21. package/src/components/form-modal/content.tsx +10 -0
  22. package/src/components/index.ts +1 -1
  23. package/src/components/layout/pane/footer/index.tsx +25 -11
  24. package/src/components/layout/pane/footer/model.ts +62 -20
  25. package/src/components/layout/pane/sidebar.tsx +125 -15
  26. package/src/components/layout/shell/active-drag.ts +18 -13
  27. package/src/components/layout/shell/drag/magnets.ts +34 -18
  28. package/src/components/ticker/list-table-view.tsx +5 -0
  29. package/src/components/ui/data-table/column-order.ts +180 -0
  30. package/src/components/ui/data-table/index.tsx +12 -1
  31. package/src/components/ui/data-table/opentui/index.tsx +267 -23
  32. package/src/components/ui/data-table/opentui/model.ts +43 -4
  33. package/src/components/ui/data-table/types.ts +49 -0
  34. package/src/components/ui/data-table/use-column-order.ts +135 -0
  35. package/src/components/ui/index.ts +1 -1
  36. package/src/components/ui/table-layout.ts +120 -0
  37. package/src/docs/snapshot.json +3 -2
  38. package/src/i18n/es.ts +2 -0
  39. package/src/i18n/ja.ts +2 -0
  40. package/src/i18n/ko.ts +2 -0
  41. package/src/i18n/zh-cn.ts +2 -0
  42. package/src/i18n/zh-tw.ts +2 -0
  43. package/src/market-data/coordinator/index.ts +4 -3
  44. package/src/market-data/coordinator/quotes.ts +12 -4
  45. package/src/market-data/quotes/freshness.ts +12 -0
  46. package/src/market-data/quotes/live-valuation.ts +1 -1
  47. package/src/market-data/quotes/regular-session-valuation.ts +1 -1
  48. package/src/plugins/builtin/broker-manager/detail.tsx +5 -3
  49. package/src/plugins/builtin/broker-manager/index.tsx +6 -6
  50. package/src/plugins/builtin/broker-manager/model.ts +15 -6
  51. package/src/plugins/builtin/broker-manager/pane-actions.tsx +11 -4
  52. package/src/plugins/builtin/broker-manager/sign-in-end.ts +50 -19
  53. package/src/plugins/builtin/broker-manager/table.ts +10 -4
  54. package/src/plugins/builtin/chat/sidebar.tsx +33 -16
  55. package/src/plugins/builtin/cloud/askg/tool-timeline.tsx +2 -0
  56. package/src/plugins/builtin/equity-screener/live.ts +74 -18
  57. package/src/plugins/builtin/equity-screener/model.ts +19 -4
  58. package/src/plugins/builtin/equity-screener/pane.tsx +19 -14
  59. package/src/plugins/builtin/equity-screener/refresh-anchor.ts +45 -0
  60. package/src/plugins/builtin/equity-screener/results.ts +22 -2
  61. package/src/plugins/builtin/equity-screener/screen-check.ts +9 -3
  62. package/src/plugins/builtin/futures/index.tsx +15 -1
  63. package/src/plugins/builtin/futures/table.tsx +1 -1
  64. package/src/plugins/builtin/fx-matrix/index.tsx +2 -0
  65. package/src/plugins/builtin/holders/pane.tsx +30 -20
  66. package/src/plugins/builtin/iv-history/events.ts +5 -0
  67. package/src/plugins/builtin/iv-history/headless.ts +7 -2
  68. package/src/plugins/builtin/kelly-sizer/sections.tsx +2 -0
  69. package/src/plugins/builtin/macro-day/headless.ts +12 -3
  70. package/src/plugins/builtin/options/view.tsx +2 -0
  71. package/src/plugins/builtin/options-scenario/pane.tsx +2 -1
  72. package/src/plugins/builtin/perps/cascade-tabs.tsx +2 -1
  73. package/src/plugins/builtin/portfolio-list/pane/index.tsx +13 -0
  74. package/src/plugins/builtin/portfolio-list/table.tsx +5 -0
  75. package/src/plugins/builtin/rate-path/pane.tsx +2 -0
  76. package/src/plugins/builtin/revenue-breakdown/pane.tsx +2 -0
  77. package/src/plugins/builtin/reverse-dcf/pane.tsx +2 -1
  78. package/src/plugins/builtin/seasonality/pane.tsx +2 -1
  79. package/src/plugins/builtin/thirteenf/pane.tsx +2 -0
  80. package/src/plugins/builtin/ticker-detail/financials/model.ts +28 -6
  81. package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +26 -9
  82. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +58 -35
  83. package/src/plugins/builtin/vol-surface/heat-grid.tsx +2 -1
  84. package/src/plugins/builtin/vol-surface/pane.tsx +2 -1
  85. package/src/plugins/builtin/world-indices/index.tsx +5 -1
  86. package/src/plugins/builtin/yield-curve/index.tsx +2 -1
  87. package/src/renderers/dom/data-table/column-drag.ts +147 -0
  88. package/src/renderers/dom/data-table/index.tsx +22 -0
  89. package/src/renderers/dom/data-table/row.tsx +27 -5
  90. package/src/renderers/dom/styles.css +22 -0
  91. package/src/renderers/opentui/chart-surface.tsx +1 -0
  92. package/src/renderers/opentui/frame-hits.ts +33 -0
  93. package/src/renderers/opentui/host.tsx +2 -0
  94. package/src/renderers/opentui/native-surface.ts +14 -21
  95. package/src/renderers/opentui/test-utils.tsx +3 -0
  96. package/src/state/app/context/index.tsx +22 -0
  97. package/src/test-support/app-store.ts +24 -1
  98. package/src/time-series/live-quotes.ts +3 -9
  99. package/src/ui/host.tsx +18 -0
  100. package/src/ui/pointer-drag.ts +11 -2
  101. package/src/utils/fundamentals.ts +14 -3
  102. package/src/utils/share-multiples.cases.json +780 -2
  103. package/src/utils/share-multiples.ts +154 -24
@@ -33,6 +33,107 @@ const SET_WARRANT = /-W\d*$/;
33
33
  */
34
34
  const THAI_RECEIPT = /^[A-Z][A-Z0-9]{1,7}(?:01|03|06|11|13|19|23|24|80)$/;
35
35
 
36
+ /**
37
+ * A fund's own name: an exchange-traded fund, note or product (a UCITS one
38
+ * too), a Brazilian index fund ("Fundo de Índice", "Classe de Índice"), an
39
+ * index or mutual fund, a unit trust, an investment trust plc. A sponsor's
40
+ * name ("Global X ETFs") is not one, nor is a company named after the unit
41
+ * trusts it runs ("Unit Trust Corporation"), nor "Fund", "Trust" or "REIT"
42
+ * alone (Blackstone Secured Lending Fund, Northern Trust, Federal Realty
43
+ * Investment Trust).
44
+ */
45
+ const FUND_NAMES = [
46
+ /\b(?:ETF|ETN|ETP)\b/,
47
+ /\bUCITS\b/,
48
+ /\bexchange[- ]traded\s+(?:fund|note|product|commodity)\b/i,
49
+ /\b(?:fundos?|classes?)\s+de\s+[íi]ndice\b/i,
50
+ /\b(?:index|mutual)\s+funds?\b/i,
51
+ /\bunit\s+trusts?\b(?!\s+(?:corporation|company|bank)\b)/i,
52
+ /(?<!real[- ]estate\s|property\s)\binvestment\s+trust\s+(?:plc|ltd|limited)\b/i,
53
+ ];
54
+ /**
55
+ * A profile's first sentence saying the line is a fund: "The Inv-GW CHNXT 50
56
+ * ETF is an exchange-traded fund", "Cohen & Steers Infrastructure Fund, Inc.
57
+ * is a closed ended balanced mutual fund", "PIMCO Dynamic Income Fund is a
58
+ * closed ended fixed income mutual fund", "Literacy Capital plc is a British
59
+ * closed-ended investment company", "Sprott Physical Uranium Trust is a
60
+ * closed-end commodity trust", "... is an investment trust", an Australian
61
+ * listed investment company. Closed-end funds and investment trusts are
62
+ * valued on their assets, not their earnings. Not a company that sponsors or
63
+ * runs funds ("is an exchange-traded fund sponsor"), nor a real estate
64
+ * investment trust; a business development company is read apart.
65
+ */
66
+ const FUND_DESCRIPTION =
67
+ /\bis\s+(?:an?\s+|the\s+)?(?:(?:type|kind|form)\s+of\s+)?(?:(?!(?:of|sponsor|provider|manager|issuer|operator|administrator|distributor|advis[eo]r)\b)[\w&,'’-]+\s+){0,3}?(?:exchange[- ]traded\s+(?:funds?|notes?|products?|commodit(?:y|ies))|closed[- ]end(?:ed)?\s+(?:[\w-]+\s+){0,3}?(?:funds?|trusts?|(?:investment|management)\s+(?:compan(?:y|ies)|firms?|vehicles?))|mutual\s+funds?|unit\s+(?:investment\s+)?trusts?|index\s+funds?|listed\s+investment\s+compan(?:y|ies)|(?<!real[- ]estate\s|realty\s|property\s|mortgage\s)investment\s+trusts?)\b(?!\s+(?:sponsor|provider|manager|management|issuer|company|corporation|bank|business|platform|firm|operator|administrator|distributor)s?\b)/i;
68
+ /** A business development company lends to private companies and is valued on its earnings: it keeps its P/E, closed-end or not. */
69
+ const BUSINESS_DEVELOPMENT = /\bbusiness\s+development\s+compan(?:y|ies)\b/i;
70
+ /** Abbreviations whose period does not end a profile's first sentence: Inc., Ltd., Corp., Co., plc., U.S. */
71
+ const ABBREVIATIONS = /\b(?:Inc|Ltd|Corp|Co|Plc|plc|PLC|LLC|Pty|Pvt|Bhd)\.|\b(?:[A-Z]\.){2,}/g;
72
+ /** A profile's first sentence, read past abbreviations. */
73
+ const firstSentence = (text: string): string =>
74
+ text.trim().replace(ABBREVIATIONS, (match) => match.replaceAll(".", "")).split(/\.(?:\s|$)/)[0] ?? "";
75
+ /**
76
+ * The types a source gives a fund, as one exact list (spaces, dashes and
77
+ * underscores dropped, upper case): an exchange-traded fund, note or product,
78
+ * a mutual, money market or closed-end fund, a unit or investment trust.
79
+ * Gloom Cloud's screener reads the same list.
80
+ */
81
+ const FUND_TYPES = new Set([
82
+ "ETF", "ETN", "ETP", "EXCHANGETRADEDFUND", "EXCHANGETRADEDNOTE", "EXCHANGETRADEDPRODUCT", "FUND", "MUTUALFUND",
83
+ "MONEYMARKET", "MONEYMARKETFUND", "CEF", "CLOSEDEND", "CLOSEDENDFUND", "UNITTRUST", "UNITINVESTMENTTRUST", "UIT",
84
+ "INVESTMENTTRUST",
85
+ ]);
86
+ /** Words that name no particular company or fund, left out when two names are compared (ownProfileText). */
87
+ const GENERIC_NAME_WORDS = new Set([
88
+ "the", "and", "inc", "incorporated", "ltd", "limited", "plc", "corp", "corporation", "company", "group", "holdings",
89
+ "holding", "fund", "funds", "etf", "etfs", "etc", "etn", "etp", "trust", "ord", "shares", "share", "class", "common",
90
+ "stock", "units", "unit", "capital", "global", "international", "investment", "investments", "management", "asset",
91
+ "assets", "securities", "index", "ucits", "usd", "eur", "gbp", "acc", "dist", "new", "llc", "pty", "pvt", "bhd",
92
+ "mutual",
93
+ ]);
94
+ const nameWords = (name: string): string[] => [...new Set(name.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").toLowerCase()
95
+ .split(/[^a-z0-9]+/).filter((word) => word.length >= 3 && !GENERIC_NAME_WORDS.has(word)))];
96
+ /** Two words name the same thing: equal, or one of four letters or more inside the other (Dspnifty, Nifty). */
97
+ const sameWord = (left: string, right: string): boolean =>
98
+ left === right || (Math.min(left.length, right.length) >= 4 && (left.includes(right) || right.includes(left)));
99
+ /** What a profile's first sentence is about: the words before its verb. */
100
+ const profileSubject = (description: string): string =>
101
+ firstSentence(description).split(/\s+(?:is|was|are|operates|engages|provides)\s/)[0] ?? "";
102
+
103
+ /**
104
+ * Whether a profile's name or first sentence is this listing's own: it shares a word with the quote's name, or names
105
+ * the listing's symbol (IBOV11 Fund). A receipt's profile is its underlying's, which it stands for (COPX on BYMA,
106
+ * Banco Comafi's CEDEAR of the Global X Copper Miners ETF). A profile can be another listing's under the same symbol
107
+ * (USAU, U.S. Gold Corp., carried the name of a Lyxor ETF): such a name says nothing of this listing. Without a quote
108
+ * name, or a word to compare, it stands.
109
+ */
110
+ function ownProfileText(financials: ShareInputs, text: string): boolean {
111
+ const quote = nameWords(financials.quote?.name ?? "");
112
+ const profile = nameWords(text);
113
+ if (!quote.length || !profile.length || isReceipt(financials)) return true;
114
+ if (financials.quote?.cedearRatio ?? financials.fundamentals?.cedearRatio) return true;
115
+ const code = (financials.quote?.symbol ?? "").split(":")[0]!.trim().toUpperCase();
116
+ if (code.length >= 3 && text.toUpperCase().split(/[^A-Z0-9.]+/).includes(code)) return true;
117
+ return profile.some((word) => quote.some((other) => sameWord(word, other)));
118
+ }
119
+
120
+ /**
121
+ * Whether a listing is a fund, whose units are no company's shares: its type (FUND_TYPES), its quote's name, or its
122
+ * profile's name or first sentence where each is the listing's own (ownProfileText). 159682 on SZSE, the ChiNext 50
123
+ * ETF a source types EQUITY, read 0.87x on an EPS of 1.27. Closed-end funds and investment trusts are funds wherever
124
+ * they list (Polar Capital Technology, Scottish Mortgage, Pershing Square, Literacy Capital); a business development
125
+ * company is not. Gloom Cloud's screener reads funds alike.
126
+ */
127
+ function isFund(financials: ShareInputs): boolean {
128
+ if (FUND_TYPES.has((financials.quote?.instrumentType ?? "").replace(/[\s_-]/g, "").toUpperCase())) return true;
129
+ const profileName = financials.profile?.name?.trim() ?? "";
130
+ const names = [financials.quote?.name ?? "", ownProfileText(financials, profileName) ? profileName : ""];
131
+ if (names.some((name) => FUND_NAMES.some((rule) => rule.test(name)))) return true;
132
+ const description = financials.profile?.description ?? "";
133
+ return ownProfileText(financials, profileSubject(description)) && !BUSINESS_DEVELOPMENT.test(description)
134
+ && FUND_DESCRIPTION.test(firstSentence(description));
135
+ }
136
+
36
137
  type Instrument = "warrant" | "right" | "unit";
37
138
 
38
139
  const instrumentOf = (code: string): Instrument => {
@@ -54,7 +155,8 @@ type EpsInputs = ShareInputs & Partial<Pick<TickerFinancials, "financialCurrency
54
155
  * ratio is on record on the receipt already (TSM's 5 shares, a CEDEAR's
55
156
  * published ratio). A unit is told by its name only on a US venue or for a
56
157
  * blank-check company; a REIT's, a fund's or a partnership's units are its
57
- * share, and PSA.PR.U is a preferred.
158
+ * share, and PSA.PR.U is a preferred. Nor is a fund's price over the EPS a
159
+ * source gives it a P/E (isFund).
58
160
  */
59
161
  export function notTheShare(financials: ShareInputs): string | undefined {
60
162
  const quote = financials.quote;
@@ -72,6 +174,7 @@ export function notTheShare(financials: ShareInputs): string | undefined {
72
174
  : venue === "SET" && SET_WARRANT.test(code) ? "W" : undefined;
73
175
  const instrument = byName ?? (bySymbol ? instrumentOf(bySymbol) : undefined);
74
176
  if (instrument) return `a ${instrument} is not the share the EPS is per`;
177
+ if (isFund(financials)) return "a fund is not a company's share";
75
178
  const country = financials.profile?.country?.trim().toUpperCase();
76
179
  const fundamentals = financials.fundamentals;
77
180
  const receipt = quote.isDepositaryReceipt || fundamentals?.isDepositaryReceipt || fundamentals?.shareBasis === "depositary_receipt"
@@ -91,7 +194,9 @@ const finite = (value: number | null | undefined): value is number => typeof val
91
194
  /** A per-share figure in a reason: whole above 100, cents above 0.01, else two significant digits (BZT's 0.000089). */
92
195
  const perShare = (value: number) => Math.abs(value) >= 100 ? value.toFixed(0)
93
196
  : Math.abs(value) >= 0.01 ? value.toFixed(2) : value.toPrecision(2);
94
- const majorCurrency = (currency: string | null | undefined) => resolveCurrencyUnit(currency).currency || undefined;
197
+ /** A currency's major unit; ZAC is South African cents here, as Gloom Cloud quotes it. */
198
+ const majorCurrency = (currency: string | null | undefined) =>
199
+ resolveCurrencyUnit(currency?.trim() === "ZAC" ? "ZAc" : currency).currency || undefined;
95
200
 
96
201
  /** The latest statement's currency. */
97
202
  function statementsCurrency(financials: EpsInputs): string | undefined {
@@ -112,31 +217,31 @@ const days = (from: string, to: string) => (Date.parse(to) - Date.parse(from)) /
112
217
  const quarterApart = (from: string, to: string) => days(from, to) >= 80 && days(from, to) <= 100;
113
218
 
114
219
  /**
115
- * The statements' trailing net income in `currency`: the latest fiscal year
116
- * when no quarter runs past it, four consecutive quarters, the year plus the
117
- * half since it where Gloom Cloud serves one, or the latest year plus the
118
- * quarters since it less the same quarters a year earlier. Gloom Cloud reads
119
- * the same window to tell an EPS in the reporting currency.
220
+ * The statements' trailing net income or diluted EPS in `currency`: the
221
+ * latest fiscal year when no quarter runs past it, four consecutive quarters,
222
+ * the year plus the half since it where Gloom Cloud serves one, or the latest
223
+ * year plus the quarters since it less the same quarters a year earlier.
224
+ * Gloom Cloud reads the same window to tell an EPS in the reporting currency.
120
225
  */
121
- function statementsTrailingNetIncome(financials: EpsInputs, currency: string): number | undefined {
226
+ function statementsTrailing(financials: EpsInputs, currency: string, field: "netIncome" | "eps"): number | undefined {
122
227
  const usable = (rows: readonly FinancialStatement[]) => rows
123
- .filter((row) => finite(row.netIncome) && Number.isFinite(Date.parse(row.date)) && row.currency === currency)
228
+ .filter((row) => finite(row[field]) && Number.isFinite(Date.parse(row.date)) && row.currency === currency)
124
229
  .sort((left, right) => left.date.localeCompare(right.date));
125
230
  const quarters = usable(quarterRows(financials.quarterlyStatements ?? []));
126
231
  const annual = usable(financials.annualStatements ?? []).at(-1);
127
232
  const latest = quarters.at(-1);
128
233
  const trailing = financials.trailingStatement;
129
234
  const served = trailing?.trailing?.method === "annual-plus-interim" && Number.isFinite(Date.parse(trailing.date))
130
- && trailing.currency === currency && finite(trailing.netIncome)
235
+ && trailing.currency === currency && finite(trailing[field])
131
236
  && !(annual && days(annual.date, trailing.date) <= SAME_DATE_DAYS)
132
237
  && !(latest && days(trailing.date, latest.date) > SAME_DATE_DAYS)
133
- ? { value: trailing.netIncome, end: trailing.date } : undefined;
134
- if (!served && annual && (!latest || days(annual.date, latest.date) <= SAME_DATE_DAYS)) return annual.netIncome!;
238
+ ? { value: trailing[field], end: trailing.date } : undefined;
239
+ if (!served && annual && (!latest || days(annual.date, latest.date) <= SAME_DATE_DAYS)) return annual[field]!;
135
240
  if (!latest) return served?.value;
136
241
  const lastFour = quarters.slice(-4);
137
242
  if ((!served || Math.abs(days(latest.date, served.end)) <= SAME_DATE_DAYS) && lastFour.length === 4
138
243
  && lastFour.every((row, index) => index === 0 || quarterApart(lastFour[index - 1]!.date, row.date))) {
139
- return lastFour.reduce((total, row) => total + row.netIncome!, 0);
244
+ return lastFour.reduce((total, row) => total + row[field]!, 0);
140
245
  }
141
246
  if (served) return served.value;
142
247
  if (!annual) return undefined;
@@ -148,20 +253,39 @@ function statementsTrailingNetIncome(financials: EpsInputs, currency: string): n
148
253
  }
149
254
  const prior = interims.map((row) => quarters.find((candidate) => Math.abs(days(candidate.date, row.date) - 365) <= SAME_DATE_DAYS));
150
255
  if (prior.some((row) => !row)) return undefined;
151
- return annual.netIncome! + interims.reduce((total, row) => total + row.netIncome!, 0)
152
- - prior.reduce((total, row) => total + row!.netIncome!, 0);
256
+ return annual[field]! + interims.reduce((total, row) => total + row[field]!, 0)
257
+ - prior.reduce((total, row) => total + row![field]!, 0);
258
+ }
259
+
260
+ /** An EPS the statements' own diluted EPS in `currency` matches, within 1% or half a cent (the source rounds to cents). */
261
+ function statementsOwnEps(financials: EpsInputs, currency: string, eps: number): boolean {
262
+ if (eps === 0) return false;
263
+ const annual = (financials.annualStatements ?? [])
264
+ .filter((row) => row.currency === currency && finite(row.eps) && Number.isFinite(Date.parse(row.date)))
265
+ .sort((left, right) => left.date.localeCompare(right.date))
266
+ .at(-1)?.eps;
267
+ return [annual, statementsTrailing(financials, currency, "eps")].some((own) =>
268
+ finite(own) && own !== 0 && Math.abs(eps - own) <= Math.max(0.01 * Math.abs(own), 0.005));
153
269
  }
154
270
 
155
271
  /**
156
272
  * Why a trailing EPS in the statements' reporting currency beside a price in
157
- * another gives no P/E: there is no rate on record to price it at (the served
158
- * P/E's `trailingPEConversion`). U.UN on the TSX divided its CA$26.47 by a
273
+ * another gives no P/E: the served block names no rate it was converted at
274
+ * (the served P/E's `trailingPEConversion`). U.UN on the TSX divided its CA$26.47 by a
159
275
  * USD 1.64 and read 16.14; NEW on Stuttgart €1.63 by GBP 0.0241, 67.63. The
160
276
  * EPS is shown to be in the reporting currency where it is labelled so, sits
161
- * beside a trailing block in it, or the block's net income is the statements'
162
- * own in it. Gloom Cloud's screener reads the same. Undefined for an EPS the
163
- * filed quarters give (in the price's currency), a receipt's on its home
164
- * line, and one whose currency cannot be told.
277
+ * beside a trailing block in it, the block's net income is the statements'
278
+ * own in it, or the EPS is their own diluted EPS for the latest fiscal year
279
+ * or their trailing twelve months (TBT on MUNICH's 308.64 JPY, Tokuyama's
280
+ * year to March 2026, beside €21.60 read 0.07x). The reason says what is
281
+ * known: Gloom Cloud labels a block's currency only with the rates at hand,
282
+ * so a labelled one was left unconverted because its source's P/E does not
283
+ * match the EPS; an unlabelled one has no conversion on record, which a
284
+ * missing rate and figures that do not tie to the statements both leave, and
285
+ * the payload does not say which. Gloom Cloud's screener, which knows its
286
+ * rates, says "no rate on record" only when it has none.
287
+ * Undefined for an EPS the filed quarters give (in the price's currency), a
288
+ * receipt's on its home line, and one whose currency cannot be told.
165
289
  */
166
290
  function noRateForEps(financials: EpsInputs): string | undefined {
167
291
  const fundamentals = financials.fundamentals;
@@ -175,10 +299,16 @@ function noRateForEps(financials: EpsInputs): string | undefined {
175
299
  const conversion = fundamentals.trailingPEConversion;
176
300
  if (conversion && majorCurrency(conversion.from) === reporting && finite(conversion.rate) && conversion.rate > 0) return undefined;
177
301
  const income = fundamentals.netIncome;
178
- const statements = finite(income) ? statementsTrailingNetIncome(financials, reporting) : undefined;
302
+ const statements = finite(income) ? statementsTrailing(financials, reporting, "netIncome") : undefined;
179
303
  const inReporting = stated === reporting || (!!fundamentals.financialCurrency && !fundamentals.epsCurrency)
180
- || (finite(income) && finite(statements) && Math.abs(income - statements) <= 0.01 * Math.max(Math.abs(income), Math.abs(statements)));
181
- return inReporting ? `EPS (TTM) in ${reporting} beside a price in ${listing}, with no rate on record` : undefined;
304
+ || (finite(income) && finite(statements) && Math.abs(income - statements) <= 0.01 * Math.max(Math.abs(income), Math.abs(statements)))
305
+ || statementsOwnEps(financials, reporting, eps);
306
+ if (!inReporting) return undefined;
307
+ // Gloom Cloud labels a block's currency only with the rates at hand: such a block was left unconverted because
308
+ // its source's P/E is not the price over that EPS, not for want of a rate.
309
+ return fundamentals.financialCurrency
310
+ ? `EPS (TTM) in ${reporting} beside a price in ${listing}, and the source's P/E does not match that EPS`
311
+ : `EPS (TTM) in ${reporting} beside a price in ${listing}, with no conversion on record`;
182
312
  }
183
313
 
184
314
  /**