gloomberb 0.20.5 → 0.20.7
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/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/package.json +2 -1
- package/src/api-client/data.ts +10 -2
- package/src/api-client/fund-facts.ts +20 -4
- package/src/api-client/hk-tenders.ts +59 -0
- package/src/api-client/index.ts +1 -0
- package/src/api-client/socket.ts +4 -4
- package/src/api-client/types/econ.ts +20 -2
- package/src/app.tsx +18 -13
- package/src/architecture/floating-promise-allowlist.json +313 -0
- package/src/architecture/shortcut-labels-allowlist.json +1 -0
- package/src/cli/commands/market.ts +197 -57
- package/src/cli/commands/news-search.ts +22 -7
- package/src/cli/commands/overview.ts +12 -6
- package/src/cli/commands/search.ts +19 -3
- package/src/cli/commands/ticker.ts +3 -1
- package/src/cli/desktop-pane-shot.ts +61 -0
- package/src/cli/early-command.ts +2 -0
- package/src/cli/errors.ts +10 -1
- package/src/cli/fx-forward.ts +76 -12
- package/src/cli/fx-pair.ts +1 -1
- package/src/cli/fx-quote-rate.ts +23 -0
- package/src/cli/help.ts +1 -0
- package/src/cli/index-roots.ts +5 -4
- package/src/cli/index.ts +40 -3
- package/src/cli/known-gaps.ts +11 -8
- package/src/cli/listing-arg.ts +6 -4
- package/src/cli/options.ts +52 -3
- package/src/cli/output-file.ts +5 -3
- package/src/cli/pane-functions/catalog.ts +15 -0
- package/src/cli/pane-functions/dom.ts +4 -4
- package/src/cli/pane-functions/freshness.ts +38 -5
- package/src/cli/pane-functions/function-help.ts +4 -4
- package/src/cli/pane-functions/headless.ts +9 -4
- package/src/cli/pane-functions/index.ts +6 -4
- package/src/cli/pane-functions/resolver.ts +2 -2
- package/src/cli/pane-functions/screenshot-assessment.ts +16 -4
- package/src/cli/quote-answer.ts +57 -1
- package/src/cli/result.ts +38 -2
- package/src/cli/spreadsheet-hint.ts +7 -3
- package/src/cli/treasury-yields.ts +5 -3
- package/src/components/chart/composite/legend.tsx +40 -2
- package/src/components/command-bar/workflow/tickers.ts +2 -2
- package/src/components/data-table/view.tsx +9 -2
- package/src/components/ui/data-table/opentui/index.tsx +11 -4
- package/src/components/ui/data-table/opentui/model.ts +8 -6
- package/src/components/ui/data-table/types.ts +6 -1
- package/src/components/ui/table-layout.ts +38 -1
- package/src/docs/snapshot.json +58 -19
- package/src/i18n/es.ts +2 -0
- package/src/i18n/ja.ts +2 -0
- package/src/i18n/ko.ts +2 -0
- package/src/i18n/zh-cn.ts +2 -0
- package/src/i18n/zh-tw.ts +2 -0
- package/src/market-data/market/change-basis.ts +57 -12
- package/src/market-data/market/dated-previous-close.ts +184 -10
- package/src/market-data/market/freshness.ts +18 -6
- package/src/market-data/market/status.ts +9 -1
- package/src/market-data/published-nse-sessions.ts +16 -1
- package/src/market-data/quotes/contributions.ts +2 -0
- package/src/market-data/quotes/freshness.ts +15 -0
- package/src/market-data/quotes/listing-enterprise-value.ts +50 -0
- package/src/plugins/builtin/alerts/alert-engine.ts +15 -0
- package/src/plugins/builtin/alerts/cli.ts +22 -9
- package/src/plugins/builtin/alerts/headless.ts +1 -1
- package/src/plugins/builtin/alerts/index.tsx +5 -1
- package/src/plugins/builtin/alerts/metric-command.ts +1 -1
- package/src/plugins/builtin/alerts/metric-data.ts +15 -2
- package/src/plugins/builtin/backtest/headless.ts +1 -1
- package/src/plugins/builtin/cds/model.ts +0 -6
- package/src/plugins/builtin/chart-composer/formula.ts +16 -3
- package/src/plugins/builtin/chart-composer/headless-schema.ts +2 -0
- package/src/plugins/builtin/chart-composer/headless.ts +2 -1
- package/src/plugins/builtin/chart-composer/presets.ts +1 -0
- package/src/plugins/builtin/cloud/askg/pane.tsx +55 -13
- package/src/plugins/builtin/credit-boards/cdx-pane.tsx +20 -7
- package/src/plugins/builtin/credit-boards/client.ts +8 -0
- package/src/plugins/builtin/credit-boards/headless.ts +4 -1
- package/src/plugins/builtin/credit-boards/model.ts +58 -4
- package/src/plugins/builtin/credit-boards/series.ts +63 -6
- package/src/plugins/builtin/credit-boards/sovr-pane.tsx +3 -2
- package/src/plugins/builtin/credit-conditions/headless.ts +24 -6
- package/src/plugins/builtin/credit-conditions/index.tsx +1 -1
- package/src/plugins/builtin/credit-conditions/model.ts +12 -6
- package/src/plugins/builtin/credit-conditions/series.ts +2 -1
- package/src/plugins/builtin/econ/calendar-model.ts +41 -7
- package/src/plugins/builtin/econ/calendar-source.ts +7 -1
- package/src/plugins/builtin/econ/index.tsx +41 -8
- package/src/plugins/builtin/econ/types.ts +3 -0
- package/src/plugins/builtin/fixed-income/index.tsx +2 -0
- package/src/plugins/builtin/fx-matrix/index.tsx +44 -14
- package/src/plugins/builtin/help/keybindings-editor.tsx +6 -2
- package/src/plugins/builtin/holders/fund-holders.ts +22 -1
- package/src/plugins/builtin/holders/headless.ts +5 -4
- package/src/plugins/builtin/holders/pane.tsx +7 -3
- package/src/plugins/builtin/holders/report-header.ts +23 -0
- package/src/plugins/builtin/members/client.ts +1 -1
- package/src/plugins/builtin/members/headless.ts +2 -0
- package/src/plugins/builtin/members/model.ts +10 -8
- package/src/plugins/builtin/members/pane.tsx +4 -1
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +5 -2
- package/src/plugins/builtin/portfolio-list/cli/render.ts +86 -26
- package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +5 -1
- package/src/plugins/builtin/portfolio-list/headless.ts +2 -1
- package/src/plugins/builtin/portfolio-list/income.ts +46 -22
- package/src/plugins/builtin/portfolio-list/pane/data.ts +16 -6
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +5 -4
- package/src/plugins/builtin/portfolio-list/use-throttled-ticker-order.ts +40 -3
- package/src/plugins/builtin/research/headless-schema.ts +4 -3
- package/src/plugins/builtin/research/relative-valuation-columns.ts +145 -47
- package/src/plugins/builtin/research/relative-valuation-currency.ts +31 -0
- package/src/plugins/builtin/research/relative-valuation-headless.ts +25 -8
- package/src/plugins/builtin/research/relative-valuation-model.ts +40 -9
- package/src/plugins/builtin/research/relative-valuation-pane.tsx +3 -2
- package/src/plugins/builtin/research/relative-valuation-peers.ts +2 -2
- package/src/plugins/builtin/sec/fund-facts.ts +25 -5
- package/src/plugins/builtin/shared/report-freshness.ts +15 -6
- package/src/plugins/builtin/supply-chain/model.ts +18 -6
- package/src/plugins/builtin/thirteenf/api.ts +47 -4
- package/src/plugins/builtin/ticker-detail/data-panes/historical-prices.tsx +8 -7
- package/src/plugins/builtin/ticker-detail/data-panes/history-bars.ts +8 -5
- package/src/plugins/builtin/ticker-detail/financials/model.ts +6 -2
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +1 -1
- package/src/plugins/builtin/ticker-detail/headless.ts +6 -4
- package/src/plugins/builtin/treasury-auctions/cache.ts +36 -2
- package/src/plugins/builtin/treasury-auctions/headless.ts +42 -4
- package/src/plugins/builtin/treasury-auctions/hk-headless.ts +126 -0
- package/src/plugins/builtin/treasury-auctions/hk-view.tsx +347 -0
- package/src/plugins/builtin/treasury-auctions/hk.ts +363 -0
- package/src/plugins/builtin/treasury-auctions/index.tsx +14 -1
- package/src/plugins/builtin/treasury-auctions/model.ts +16 -8
- package/src/plugins/builtin/treasury-auctions/pane.tsx +45 -21
- package/src/portfolio/collection-name.ts +22 -0
- package/src/portfolio/column-values.ts +3 -0
- package/src/portfolio/valuation-basis.ts +23 -1
- package/src/renderers/dom/data-table/frozen-column.ts +3 -1
- package/src/renderers/dom/data-table/index.tsx +27 -9
- package/src/renderers/dom/data-table/row.tsx +2 -0
- package/src/renderers/electrobun/bun/desktop/backend.ts +27 -24
- package/src/renderers/electrobun/bun/desktop/detached-windows.ts +3 -3
- package/src/renderers/electrobun/bun/desktop/snapshot-commit.ts +77 -0
- package/src/renderers/electrobun/shared/protocol.ts +4 -0
- package/src/renderers/electrobun/view/backend-rpc.ts +3 -0
- package/src/renderers/electrobun/view/desktop/window/bridge.ts +3 -0
- package/src/sources/gloomberb-cloud/normalizers.ts +9 -5
- package/src/sources/provider-router/cache.ts +3 -1
- package/src/state/hooks/quote-streaming.ts +14 -6
- package/src/sync/controller.ts +17 -2
- package/src/sync/other-window-tabs.ts +32 -1
- package/src/sync/react.ts +4 -4
- package/src/tickers/instrument-kind.ts +22 -1
- package/src/tickers/search/index.ts +5 -0
- package/src/tickers/terminal-codes.ts +17 -5
- package/src/time-series/bar-spacing.ts +33 -0
- package/src/time-series/base-series.ts +21 -3
- package/src/time-series/chart-bounds.ts +31 -0
- package/src/time-series/field-catalog.ts +17 -0
- package/src/time-series/fundamentals/current-valuation.ts +244 -0
- package/src/time-series/fundamentals/historical-valuation.ts +99 -0
- package/src/time-series/fundamentals/metric-ids.ts +61 -0
- package/src/time-series/fundamentals/period-points.ts +104 -0
- package/src/time-series/fundamentals/quarterly-ttm.ts +220 -0
- package/src/time-series/fundamentals/series.ts +164 -0
- package/src/time-series/fundamentals/source-statements.ts +177 -0
- package/src/time-series/fundamentals/statement-fields.ts +154 -0
- package/src/time-series/fundamentals/statement-merge.ts +124 -0
- package/src/time-series/fundamentals/statement.ts +114 -0
- package/src/time-series/fundamentals/valuation-multiples.ts +50 -0
- package/src/time-series/fundamentals.ts +18 -1275
- package/src/time-series/ice-credit.ts +32 -6
- package/src/time-series/resolve.ts +9 -5
- package/src/time-series/session-bar.ts +78 -9
- package/src/time-series/studies/formula.ts +53 -10
- package/src/time-series/studies/pair.ts +18 -7
- package/src/time-series/studies/units.ts +49 -2
- package/src/time-series/types.ts +12 -0
- package/src/types/desktop-window.ts +2 -0
- package/src/types/financials.ts +15 -0
- package/src/types/headless.ts +8 -0
- package/src/utils/cli-output.ts +6 -3
- package/src/utils/debug-log.ts +29 -0
- package/src/utils/ebitda.ts +128 -0
- package/src/utils/format.ts +1 -1
- package/src/utils/shell-word.ts +13 -0
|
@@ -93,6 +93,21 @@ export function evaluateAlert(alert: AlertRule, currentPrice: number): boolean {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
/**
|
|
97
|
+
* Whether an above or below rule already holds at a reading. Such a rule is a
|
|
98
|
+
* state, not a crossing (`evaluateAlert`, `metricTrigger`), so one that holds
|
|
99
|
+
* when it is added goes off at its first check. `crosses`, a moving-average
|
|
100
|
+
* cross and an RRG quadrant wait for the next move through their level.
|
|
101
|
+
*/
|
|
102
|
+
export function levelAlreadyMet(
|
|
103
|
+
condition: AlertCondition,
|
|
104
|
+
value: number | null | undefined,
|
|
105
|
+
level: number | null | undefined,
|
|
106
|
+
): boolean {
|
|
107
|
+
if (value == null || level == null || !Number.isFinite(value) || !Number.isFinite(level)) return false;
|
|
108
|
+
return condition === "above" ? value > level : condition === "below" ? value < level : false;
|
|
109
|
+
}
|
|
110
|
+
|
|
96
111
|
export function formatAlertDescription(alert: AlertRule): string {
|
|
97
112
|
if (alert.metric) return metricDescription(alert);
|
|
98
113
|
if (alert.move) return `${alertListing({ symbol: alert.symbol, exchange: alert.exchange })} ${moveRuleWords(alert)} from the previous close`;
|
|
@@ -45,7 +45,7 @@ import {
|
|
|
45
45
|
type CalendarEventChoice,
|
|
46
46
|
type ReleaseRename,
|
|
47
47
|
} from "./calendar-events";
|
|
48
|
-
import { createAlert, formatAlertDescription, rearmAlert, sameLevelRule } from "./alert-engine";
|
|
48
|
+
import { createAlert, formatAlertDescription, levelAlreadyMet, rearmAlert, sameLevelRule } from "./alert-engine";
|
|
49
49
|
import { alertPriceText } from "./price-text";
|
|
50
50
|
import { ALERTS_PLUGIN_ID } from "./constants";
|
|
51
51
|
import { MAX_EVENT_ALERTS, eventAlertTarget, toggleEventAlert, writeEventAlertStores, type EventAlertRule } from "./events";
|
|
@@ -205,7 +205,7 @@ function releaseRequest(args: readonly string[], country: CountryFilter | null,
|
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
/**
|
|
208
|
-
* Reads `alerts add` arguments: `<symbol> above
|
|
208
|
+
* Reads `alerts add` arguments: `<symbol> above 400`, `<symbol> earnings`,
|
|
209
209
|
* `<symbol> earnings results`, or a release in the economic calendar by name
|
|
210
210
|
* (`CPI`, `FOMC`, `NBS PMI`, `CN PMI`), with `--days` (already taken out of
|
|
211
211
|
* `args`, `null` when the flag came without a value) and `--country` for the
|
|
@@ -773,16 +773,16 @@ export const alertsCliCommand: CliCommandDef = {
|
|
|
773
773
|
],
|
|
774
774
|
examples: [
|
|
775
775
|
"alerts",
|
|
776
|
-
"alerts add AAPL above
|
|
776
|
+
"alerts add AAPL above 400",
|
|
777
777
|
"alerts add GBPUSD=X moves 0.5%",
|
|
778
778
|
"alerts add HSBA.L BARC.L down 3%",
|
|
779
779
|
"alerts add --watchlist Book up 3%",
|
|
780
780
|
"alerts add VOD.L below 70p",
|
|
781
781
|
"alerts add AAPL pe below 25",
|
|
782
|
-
"alerts add AAPL ps above
|
|
782
|
+
"alerts add AAPL ps above 12",
|
|
783
783
|
'alerts add NVDA "rsi(14)" under 30',
|
|
784
784
|
'alerts add SPY "ma(50)" crosses above "ma(200)"',
|
|
785
|
-
'alerts add TSLA closes
|
|
785
|
+
'alerts add TSLA closes above "ma(200)"',
|
|
786
786
|
"alerts add XLK/SPY above 0.25",
|
|
787
787
|
"alerts add XLE rrg leading",
|
|
788
788
|
"alerts add SMH rrg weakening --benchmark QQQ",
|
|
@@ -1110,7 +1110,7 @@ export const alertsCliCommand: CliCommandDef = {
|
|
|
1110
1110
|
{ key: "createdAt", header: "Created", format: (value) => String(value ?? "") },
|
|
1111
1111
|
{ key: "triggeredAt", header: "Triggered", optional: true },
|
|
1112
1112
|
],
|
|
1113
|
-
empty: "No alerts. Add one with gloom alerts add AAPL above
|
|
1113
|
+
empty: "No alerts. Add one with gloom alerts add AAPL above 400, alerts add CRWV earnings --days 3, alerts add CPI --days 1, or alerts add CN PMI.",
|
|
1114
1114
|
});
|
|
1115
1115
|
return;
|
|
1116
1116
|
}
|
|
@@ -1230,12 +1230,25 @@ export const alertsCliCommand: CliCommandDef = {
|
|
|
1230
1230
|
// A daily rule is first judged on the first close after it was set, once that close has settled.
|
|
1231
1231
|
// An RRG quadrant, on the last session of that week.
|
|
1232
1232
|
const weekly = alert.metric?.kind === "rrg";
|
|
1233
|
-
const
|
|
1233
|
+
const daily = !!alert.metric && isDailyMetric(alert.metric);
|
|
1234
|
+
const firstCheck = daily ? firstDailyCheck(alert.exchange, now, weekly) : null;
|
|
1235
|
+
// The price a price alert is checked on, as the far-target check measures against.
|
|
1236
|
+
const checkedPrice = !alert.metric && priced && Number.isFinite(priced.quote.price) && priced.quote.price !== 0 ? priced.quote.price : null;
|
|
1237
|
+
// An above or below rule that already holds goes off at its first check, not on the next cross: said with the reading.
|
|
1238
|
+
const alreadyMet = alert.metric
|
|
1239
|
+
? levelAlreadyMet(alert.condition, alert.lastCheckedPrice, alert.lastCheckedTarget)
|
|
1240
|
+
: levelAlreadyMet(alert.condition, checkedPrice, alert.targetPrice);
|
|
1241
|
+
const level = alert.metric?.kind === "close_ma" ? "it" : alert.metric ? String(alert.targetPrice) : alertPriceText(alert, alert.targetPrice);
|
|
1242
|
+
const met = alreadyMet ? `, already ${alert.condition} ${level}${daily ? "" : ", so it goes off at the next check"}` : "";
|
|
1243
|
+
const goesOffThen = daily && alreadyMet ? ` It goes off then if it is still ${alert.condition}.` : "";
|
|
1234
1244
|
const notes = [
|
|
1235
|
-
alert.metric ? unread ? `Not read yet: ${unread.replace(/\.$/, "")}.` : `${metricReadingNote(alert)}.`
|
|
1236
|
-
|
|
1245
|
+
alert.metric ? unread ? `Not read yet: ${unread.replace(/\.$/, "")}.` : `${metricReadingNote(alert)}${met}.`
|
|
1246
|
+
: checkedPrice != null ? `Last price ${alertPriceText(alert, checkedPrice)}${met}.` : null,
|
|
1247
|
+
firstCheck ? `First checked on the ${firstCheck.day} ${weekly ? "weekly close" : "close"}, from ${isoUtc(firstCheck.at).slice(11, 16)} UTC.${goesOffThen}`
|
|
1248
|
+
: goesOffThen ? `It goes off on the first close it is checked on if it is still ${alert.condition}.` : null,
|
|
1237
1249
|
].filter(Boolean).join(" ");
|
|
1238
1250
|
ctx.printResult({ data: { changed: !ctx.cliOptions.dryRun, dryRun: ctx.cliOptions.dryRun, alert,
|
|
1251
|
+
...alreadyMet ? { alreadyMet } : {},
|
|
1239
1252
|
...firstCheck ? { firstCheck: { close: firstCheck.day, at: isoUtc(firstCheck.at) } } : {},
|
|
1240
1253
|
...unread ? { unread } : {} }, ...(read.length > 0 ? { warnings: read } : {}) }, {
|
|
1241
1254
|
// The delivery, as docs/usage.md states it, before any full stop, which after the price would read as part of it (below 81.).
|
|
@@ -141,7 +141,7 @@ function pricesResult(alerts: readonly AlertRule[], error: string | null, events
|
|
|
141
141
|
columns: PRICE_COLUMNS,
|
|
142
142
|
textColumns: PRICE_TEXT_COLUMNS,
|
|
143
143
|
rows: [...active, ...triggered].map(priceRow),
|
|
144
|
-
empty: "No level alerts. Add one with gloom alerts add AAPL above
|
|
144
|
+
empty: "No level alerts. Add one with gloom alerts add AAPL above 400.",
|
|
145
145
|
...(error ? { errors: [error], complete: false } : {}),
|
|
146
146
|
...(notes.length ? { notes } : {}),
|
|
147
147
|
};
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
createAlert,
|
|
32
32
|
evaluateAlert,
|
|
33
33
|
formatAlertDescription,
|
|
34
|
+
levelAlreadyMet,
|
|
34
35
|
sameLevelRule,
|
|
35
36
|
} from "./alert-engine";
|
|
36
37
|
import {
|
|
@@ -327,8 +328,11 @@ export const alertsPlugin: GloomPlugin = {
|
|
|
327
328
|
recordFired(alertChangeEntry("created", alertLogRule(alert)));
|
|
328
329
|
alertStream?.sync();
|
|
329
330
|
|
|
331
|
+
// A level the price is already past goes off at the next check, as `alerts add` says.
|
|
332
|
+
const met = !input.metric && levelAlreadyMet(alert.condition, quote.price, alert.targetPrice)
|
|
333
|
+
? `, already ${alert.condition}, so it goes off at the next check` : "";
|
|
330
334
|
ctx.notify({
|
|
331
|
-
body: `Alert set: ${formatAlertDescription(alert)}${input.metric ? firstCheck ? `, ${firstCheck}` : "" : ` (current ${alertPriceText(alert, quote.price)})`}`,
|
|
335
|
+
body: `Alert set: ${formatAlertDescription(alert)}${input.metric ? firstCheck ? `, ${firstCheck}` : "" : ` (current ${alertPriceText(alert, quote.price)}${met})`}`,
|
|
332
336
|
type: "success",
|
|
333
337
|
});
|
|
334
338
|
},
|
|
@@ -7,7 +7,7 @@ import { parsePublicTickerKey } from "../../../utils/exchanges";
|
|
|
7
7
|
|
|
8
8
|
export interface MetricAlertInput { symbol: string; condition: AlertCondition; price: number; metric: AlertMetric }
|
|
9
9
|
const direction = (s: string) => /^(above|over|>)$/i.test(s) ? "above" as const : /^(below|under|<)$/i.test(s) ? "below" as const : null;
|
|
10
|
-
const USAGE = "Use AAPL pe below 25, AAPL ps above
|
|
10
|
+
const USAGE = "Use AAPL pe below 25, AAPL ps above 12, NVDA rsi(14) under 30, SPY ma(50) crosses above ma(200), or TSLA closes above ma(200).";
|
|
11
11
|
function checked(input: MetricAlertInput): MetricAlertInput {
|
|
12
12
|
if (!validMetricRule({ ...input, targetPrice: input.price })) throw new Error("Use a positive multiple, RSI from 0 to 100, and whole MA/RSI periods from 2 to 200 (fast MA shorter than slow MA).");
|
|
13
13
|
return input;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AssetDataProvider } from "../../../types/data-provider";
|
|
2
|
-
import type { TickerFinancials } from "../../../types/financials";
|
|
2
|
+
import type { Quote, TickerFinancials } from "../../../types/financials";
|
|
3
3
|
import { liveMarketCapitalization, liveTrailingPE } from "../../../market-data/quotes/live-valuation";
|
|
4
4
|
import { comparablePriceEarnings } from "../../../utils/price-earnings";
|
|
5
5
|
import { canonicalExchange } from "../../../utils/exchanges";
|
|
@@ -68,6 +68,7 @@ export function metricReadings(provider: AssetDataProvider, now = Date.now()) {
|
|
|
68
68
|
dailyCaches.set(provider, daily);
|
|
69
69
|
const financials = new Map<string, Promise<TickerFinancials>>();
|
|
70
70
|
const history = new Map<string, Promise<Awaited<ReturnType<AssetDataProvider["getPriceHistory"]>> >>();
|
|
71
|
+
const quotes = new Map<string, Promise<Quote | null>>();
|
|
71
72
|
return async (rule: AlertRule): Promise<MetricReading> => {
|
|
72
73
|
const m = rule.metric!;
|
|
73
74
|
const key = `${rule.symbol}|${rule.exchange ?? ""}`;
|
|
@@ -99,8 +100,20 @@ export function metricReadings(provider: AssetDataProvider, now = Date.now()) {
|
|
|
99
100
|
const request = history.get(listing) ?? load(symbol, venue);
|
|
100
101
|
history.set(listing, request);
|
|
101
102
|
// Final as `history` shows it: a close it prints without `partial` is one the rule may judge.
|
|
103
|
+
// A bar the source still marks partial once its session has settled is final at the session's quote,
|
|
104
|
+
// as `history` makes it; the quote is read only then, and one that fails leaves the rule waiting.
|
|
102
105
|
// Bars read back from the saved cache carry their dates as text.
|
|
103
|
-
|
|
106
|
+
const served = await request;
|
|
107
|
+
let quote: Promise<Quote | null> | null = null;
|
|
108
|
+
if (served.at(-1)?.partial) {
|
|
109
|
+
quote = quotes.get(listing) ?? provider.getQuote(symbol, venue).catch(() => {
|
|
110
|
+
// Intentional ignore: the bar stays partial and the rule keeps waiting; the next pass reads the quote again.
|
|
111
|
+
return null;
|
|
112
|
+
});
|
|
113
|
+
quotes.set(listing, quote);
|
|
114
|
+
}
|
|
115
|
+
return finalDailyBars(served, { now, venue }, await quote)
|
|
116
|
+
.map(point => ({ date: barSessionDay(getPricePointTimestamp(point), venue), close: point.close }));
|
|
104
117
|
};
|
|
105
118
|
const bars = await completed(rule.symbol, exchange);
|
|
106
119
|
// RS ratios and RRG quadrants read the benchmark's own completed bars, never a quote.
|
|
@@ -50,7 +50,7 @@ export const backtestHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
|
50
50
|
normalize: (value) => isoDateOption(value, "end") },
|
|
51
51
|
{ key: "include-partial", settingKey: "includePartial", type: "boolean", defaultValue: false,
|
|
52
52
|
description: "Keep a session still forming (partial), which is left out by default because its close moves until the day ends" },
|
|
53
|
-
{ key: "equity", shot: { reportOnly: "prints the daily equity curve in place of the summary" }, type: "boolean", defaultValue: false, example: "--csv --equity
|
|
53
|
+
{ key: "equity", shot: { reportOnly: "prints the daily equity curve in place of the summary" }, type: "boolean", defaultValue: false, example: "--csv --equity --output curve.csv",
|
|
54
54
|
description: "Report the daily curve instead: date, close in the listing's currency, position (1 long, 0 flat), strategy and"
|
|
55
55
|
+ " buy-and-hold growth of 1 on the price alone (distributions not included) and drawdown in percent, every digit in --csv and --json" },
|
|
56
56
|
{ key: "tab", type: "enum", defaultValue: "summary", values: [{ value: "summary" }, { value: "trades" }], description: "Initial view",
|
|
@@ -643,12 +643,6 @@ export function formatEventTime(eventAt: number): string {
|
|
|
643
643
|
return new Date(eventAt).toISOString().slice(0, 16).replace("T", " ");
|
|
644
644
|
}
|
|
645
645
|
|
|
646
|
-
export function formatAsOf(asOf: string | null): string | null {
|
|
647
|
-
if (!asOf) return null;
|
|
648
|
-
const parsed = Date.parse(asOf);
|
|
649
|
-
return Number.isFinite(parsed) ? `${formatEventTime(parsed)} UTC` : asOf;
|
|
650
|
-
}
|
|
651
|
-
|
|
652
646
|
export function formatMaturity(maturity: string | null): string {
|
|
653
647
|
return maturity ?? "--";
|
|
654
648
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { currencyPairSpelling } from "../../../utils/currency-pair";
|
|
2
2
|
import { dashedCoinPair } from "../../../utils/crypto-pair";
|
|
3
3
|
import { GALLONS_PER_BARREL, isBarrelsPerTonne } from "../../../time-series/price-units";
|
|
4
|
+
import { BP_PER_PERCENT } from "../../../time-series/studies/units";
|
|
4
5
|
import { MAX_CHART_COMPOSER_SERIES } from "./chart-spec";
|
|
5
6
|
import { parseSeriesExpression, resolveChartFieldAlias, type ParsedSeriesExpression } from "./series-expression";
|
|
6
7
|
import { getTimeSeriesField } from "../../../time-series/field-catalog";
|
|
@@ -17,8 +18,10 @@ import { getTimeSeriesField } from "../../../time-series/field-catalog";
|
|
|
17
18
|
*
|
|
18
19
|
* A literal 42 on a series is the 42 gallons of a barrel: it makes a price per
|
|
19
20
|
* gallon a price per barrel. A literal 7.45 or 8.45 is the barrels in a tonne
|
|
20
|
-
* of gasoil or gasoline: it makes a price per barrel a price per tonne.
|
|
21
|
-
*
|
|
21
|
+
* of gasoil or gasoline: it makes a price per barrel a price per tonne. A
|
|
22
|
+
* literal 100 makes a percent basis points (0.93% is 93bp), and 0.01 basis
|
|
23
|
+
* points a percent. Any other number is a count and keeps the unit. A series
|
|
24
|
+
* the whole formula is
|
|
22
25
|
* divided or multiplied by changes its unit as the arithmetic does: over
|
|
23
26
|
* EURUSD=X (USD per EUR), dollars are euros.
|
|
24
27
|
*
|
|
@@ -37,6 +40,8 @@ interface FormulaLeg {
|
|
|
37
40
|
perBarrel: boolean;
|
|
38
41
|
/** The barrels in a tonne the leg was multiplied by (7.45 or 8.45), or null. */
|
|
39
42
|
perTonne: number | null;
|
|
43
|
+
/** The leg was multiplied by a literal 100 (1: a percent in bp) or 0.01 (-1: bp in percent), or neither. */
|
|
44
|
+
percentBp: 1 | -1 | null;
|
|
40
45
|
/** The leg as written: `HO=F`. */
|
|
41
46
|
text: string;
|
|
42
47
|
}
|
|
@@ -136,6 +141,11 @@ function tokenize(expression: string): Token[] {
|
|
|
136
141
|
return tokens;
|
|
137
142
|
}
|
|
138
143
|
|
|
144
|
+
/** A literal 100 makes a percent basis points (1), 0.01 basis points a percent (-1); any other number neither. */
|
|
145
|
+
function percentBasisPointFactor(value: number): 1 | -1 | null {
|
|
146
|
+
return value === BP_PER_PERCENT ? 1 : value === 1 / BP_PER_PERCENT ? -1 : null;
|
|
147
|
+
}
|
|
148
|
+
|
|
139
149
|
function fail(message: string): never {
|
|
140
150
|
throw new Error(message);
|
|
141
151
|
}
|
|
@@ -192,6 +202,7 @@ export function parseFormulaExpression(expression: string): ParsedFormula | null
|
|
|
192
202
|
let weight = sign;
|
|
193
203
|
let perBarrel = false;
|
|
194
204
|
let perTonne: number | null = null;
|
|
205
|
+
let percentBp: 1 | -1 | null = null;
|
|
195
206
|
const factors: Token[] = [];
|
|
196
207
|
for (;;) {
|
|
197
208
|
const factor = take();
|
|
@@ -206,6 +217,7 @@ export function parseFormulaExpression(expression: string): ParsedFormula | null
|
|
|
206
217
|
if (factor.value === 0) fail("A multiplier of 0 removes its series; leave the term out instead.");
|
|
207
218
|
if (factor.value === GALLONS_PER_BARREL && !perBarrel) perBarrel = true;
|
|
208
219
|
else if (isBarrelsPerTonne(factor.value) && perTonne === null) perTonne = factor.value;
|
|
220
|
+
else if (percentBp === null) percentBp = percentBasisPointFactor(factor.value);
|
|
209
221
|
weight *= factor.value;
|
|
210
222
|
}
|
|
211
223
|
if (peek()?.kind !== "*") break;
|
|
@@ -224,7 +236,7 @@ export function parseFormulaExpression(expression: string): ParsedFormula | null
|
|
|
224
236
|
if (legs.some((leg) => leg.text.toUpperCase() === text.toUpperCase())) {
|
|
225
237
|
fail(`${text} appears twice. Write it once with its combined multiplier, such as 2*${text}.`);
|
|
226
238
|
}
|
|
227
|
-
legs.push({ series: parsed, weight, perBarrel, perTonne, text });
|
|
239
|
+
legs.push({ series: parsed, weight, perBarrel, perTonne, percentBp, text });
|
|
228
240
|
expectTerm = false;
|
|
229
241
|
|
|
230
242
|
const next = peek();
|
|
@@ -261,6 +273,7 @@ export function parseFormulaExpression(expression: string): ParsedFormula | null
|
|
|
261
273
|
for (const leg of legs) {
|
|
262
274
|
if (value.value === GALLONS_PER_BARREL && !leg.perBarrel) leg.perBarrel = true;
|
|
263
275
|
else if (isBarrelsPerTonne(value.value) && leg.perTonne === null) leg.perTonne = value.value;
|
|
276
|
+
else if (leg.percentBp === null) leg.percentBp = percentBasisPointFactor(value.value);
|
|
264
277
|
leg.weight *= value.value;
|
|
265
278
|
}
|
|
266
279
|
}
|
|
@@ -202,6 +202,8 @@ export const paneSchemas = {
|
|
|
202
202
|
{ value: "operatingMargin", aliases: ["operating margin"] },
|
|
203
203
|
{ value: "netIncome", aliases: ["net income", "profit", "earnings"] },
|
|
204
204
|
{ value: "netMargin", aliases: ["net margin", "profit margin"] },
|
|
205
|
+
{ value: "ebitda", aliases: ["ebitda", "operating income plus d&a"] },
|
|
206
|
+
{ value: "depreciationAndAmortization", aliases: ["d&a", "da", "depreciation", "depreciation and amortization"] },
|
|
205
207
|
{ value: "operatingCashFlow", aliases: ["operating cash flow", "cash flow", "ocf"] },
|
|
206
208
|
{ value: "freeCashFlow", aliases: ["free cash flow", "fcf"] },
|
|
207
209
|
{ value: "freeCashFlowMargin", aliases: ["free cash flow margin", "fcf margin"] },
|
|
@@ -252,7 +252,8 @@ export async function loadChartPaneModel(
|
|
|
252
252
|
errors: [...chart.errors, ...chart.series.filter((series) => series.unreportedPeriod && series.points.length === 0)
|
|
253
253
|
.map((series) => `${series.label}: no ${series.unreportedPeriod} figures are reported; use --period annual.`)],
|
|
254
254
|
unavailableSymbols: spec.series.filter((series) => series.visible !== false).flatMap((series) => {
|
|
255
|
-
if (chart.series.some((output) => output.id === series.id && output.
|
|
255
|
+
if (chart.series.some((output) => output.id === series.id && (output.notMeaningful
|
|
256
|
+
|| output.points.some((point) => point.value !== null && Number.isFinite(point.value))))) return [];
|
|
256
257
|
const source = series.source;
|
|
257
258
|
return [source.kind === "security"
|
|
258
259
|
? publicTickerKey(source.instrument.symbol, source.instrument.exchange)
|
|
@@ -109,6 +109,7 @@ function formulaStudy(formula: ParsedFormula, inputSeriesIds: string[]): ChartSt
|
|
|
109
109
|
parameters[`weight${index + 1}`] = leg.weight;
|
|
110
110
|
if (leg.perBarrel) parameters[`perBarrel${index + 1}`] = 1;
|
|
111
111
|
if (leg.perTonne) parameters[`perTonne${index + 1}`] = leg.perTonne;
|
|
112
|
+
if (leg.percentBp) parameters[`percentBp${index + 1}`] = leg.percentBp;
|
|
112
113
|
});
|
|
113
114
|
formula.factors.forEach((factor, index) => {
|
|
114
115
|
parameters[`power${formula.legs.length + index + 1}`] = factor.power;
|
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
getPaneSidebarWidth,
|
|
31
31
|
IconButton,
|
|
32
32
|
MessageComposer,
|
|
33
|
+
PaneStatusBody,
|
|
33
34
|
Prose,
|
|
34
35
|
shouldShowPaneSidebar,
|
|
35
36
|
usePaneFooter,
|
|
@@ -706,6 +707,10 @@ export function ASKGPane({ paneId, focused, width, height }: PaneProps) {
|
|
|
706
707
|
// The expanded result's rows have the keyboard: j/k walk them and Enter
|
|
707
708
|
// opens one. x moves in, Esc comes back to the timeline.
|
|
708
709
|
const [resultFocused, setResultFocused] = useState(false);
|
|
710
|
+
// A conversation that could not be loaded: its failure takes the body until
|
|
711
|
+
// anything else is opened or asked.
|
|
712
|
+
const [openFailure, setOpenFailure] = useState<{ conversationId: string; message: string } | null>(null);
|
|
713
|
+
const openRequestRef = useRef(0);
|
|
709
714
|
|
|
710
715
|
const conversations = useSyncExternalStore(
|
|
711
716
|
useCallback((listener) => askgConversationListStore.subscribe(listener), []),
|
|
@@ -798,11 +803,19 @@ export function ASKGPane({ paneId, focused, width, height }: PaneProps) {
|
|
|
798
803
|
// With a pane attached, the question in the field is about it; the examples are not.
|
|
799
804
|
const examples = attached ? NO_EXAMPLES : profileExamples;
|
|
800
805
|
|
|
806
|
+
// Anything opened or asked since takes the body back from a conversation
|
|
807
|
+
// that failed to load, and a load still out no longer shows its failure.
|
|
808
|
+
const dropOpenFailure = useCallback(() => {
|
|
809
|
+
openRequestRef.current += 1;
|
|
810
|
+
setOpenFailure(null);
|
|
811
|
+
}, []);
|
|
812
|
+
|
|
801
813
|
const ask = useCallback((question: string) => {
|
|
802
814
|
const trimmed = question.trim();
|
|
803
815
|
if (!trimmed) return;
|
|
816
|
+
dropOpenFailure();
|
|
804
817
|
void controller.ask(trimmed);
|
|
805
|
-
}, [controller]);
|
|
818
|
+
}, [controller, dropOpenFailure]);
|
|
806
819
|
|
|
807
820
|
const focusInput = useCallback(() => {
|
|
808
821
|
setInputFocused(true);
|
|
@@ -831,9 +844,10 @@ export function ASKGPane({ paneId, focused, width, height }: PaneProps) {
|
|
|
831
844
|
if (focusedRef.current) focusInput();
|
|
832
845
|
}, [ask, focusInput]);
|
|
833
846
|
const retryAndCompose = useCallback((turnId: string) => {
|
|
847
|
+
dropOpenFailure();
|
|
834
848
|
void controller.retryTurn(turnId);
|
|
835
849
|
if (focusedRef.current) focusInput();
|
|
836
|
-
}, [controller, focusInput]);
|
|
850
|
+
}, [controller, dropOpenFailure, focusInput]);
|
|
837
851
|
|
|
838
852
|
const resetTimeline = useCallback(() => {
|
|
839
853
|
setSelectedId(null);
|
|
@@ -841,14 +855,29 @@ export function ASKGPane({ paneId, focused, width, height }: PaneProps) {
|
|
|
841
855
|
setOpenGroups(new Set());
|
|
842
856
|
setExampleIndex(null);
|
|
843
857
|
setFeedbackFollowUpTurnId(null);
|
|
844
|
-
|
|
858
|
+
dropOpenFailure();
|
|
859
|
+
}, [dropOpenFailure]);
|
|
845
860
|
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
861
|
+
/** Loads a conversation into the body; one that cannot be loaded leaves its failure there. */
|
|
862
|
+
const showConversation = useCallback(async (conversationId: string) => {
|
|
863
|
+
if (conversationId === state.conversationId) {
|
|
864
|
+
dropOpenFailure();
|
|
865
|
+
return;
|
|
866
|
+
}
|
|
867
|
+
const request = ++openRequestRef.current;
|
|
868
|
+
let conversation: Awaited<ReturnType<typeof apiClient.askg.loadConversation>>;
|
|
869
|
+
try {
|
|
870
|
+
conversation = await apiClient.askg.loadConversation(conversationId);
|
|
871
|
+
} catch (error) {
|
|
872
|
+
logFailure("cloud.askg.pane", "Load a conversation failed")(error);
|
|
873
|
+
if (request !== openRequestRef.current) return;
|
|
874
|
+
resetTimeline();
|
|
875
|
+
setOpenFailure({
|
|
876
|
+
conversationId,
|
|
877
|
+
message: error instanceof Error && error.message ? error.message : "Could not load this conversation.",
|
|
878
|
+
});
|
|
879
|
+
return;
|
|
880
|
+
}
|
|
852
881
|
// A row the sidebar still shows may be gone; the refresh drops it.
|
|
853
882
|
if (!conversation) {
|
|
854
883
|
void askgConversationListStore.refresh();
|
|
@@ -857,7 +886,14 @@ export function ASKGPane({ paneId, focused, width, height }: PaneProps) {
|
|
|
857
886
|
resetTimeline();
|
|
858
887
|
setAttached(null);
|
|
859
888
|
controller.openConversation(conversation);
|
|
860
|
-
}, [controller,
|
|
889
|
+
}, [controller, dropOpenFailure, resetTimeline, setAttached, state.conversationId]);
|
|
890
|
+
|
|
891
|
+
const openConversation = useCallback((conversationId: string) => {
|
|
892
|
+
setSidebarFocused(false);
|
|
893
|
+
setSidebarCursorId(null);
|
|
894
|
+
if (focusedRef.current) focusInput();
|
|
895
|
+
showConversation(conversationId).catch(logFailure("cloud.askg.pane", "Open a conversation failed"));
|
|
896
|
+
}, [focusInput, showConversation]);
|
|
861
897
|
|
|
862
898
|
const newConversation = useCallback(() => {
|
|
863
899
|
resetTimeline();
|
|
@@ -1499,7 +1535,7 @@ export function ASKGPane({ paneId, focused, width, height }: PaneProps) {
|
|
|
1499
1535
|
consume();
|
|
1500
1536
|
const target = sidebarTargetId;
|
|
1501
1537
|
leaveSidebar();
|
|
1502
|
-
if (target)
|
|
1538
|
+
if (target) openConversation(target);
|
|
1503
1539
|
else focusInput();
|
|
1504
1540
|
} else if (isPlainKey(event, "j", "down")) {
|
|
1505
1541
|
consume();
|
|
@@ -1896,7 +1932,7 @@ export function ASKGPane({ paneId, focused, width, height }: PaneProps) {
|
|
|
1896
1932
|
height={height}
|
|
1897
1933
|
focused={focused}
|
|
1898
1934
|
keyboardFocused={focused}
|
|
1899
|
-
onSelect={
|
|
1935
|
+
onSelect={openConversation}
|
|
1900
1936
|
onFocusRequest={() => {
|
|
1901
1937
|
if (inputFocused) blurInput();
|
|
1902
1938
|
setResultFocused(false);
|
|
@@ -1924,7 +1960,13 @@ export function ASKGPane({ paneId, focused, width, height }: PaneProps) {
|
|
|
1924
1960
|
onMouseDown={() => setSidebarFocused(false)}
|
|
1925
1961
|
>
|
|
1926
1962
|
<ScrollBox ref={scrollRef} flexGrow={1} minHeight={0} scrollY focusable={false} paddingX={1}>
|
|
1927
|
-
{
|
|
1963
|
+
{openFailure ? (
|
|
1964
|
+
<PaneStatusBody
|
|
1965
|
+
subject="Conversation"
|
|
1966
|
+
error={openFailure.message}
|
|
1967
|
+
retry={{ onRetry: () => showConversation(openFailure.conversationId) }}
|
|
1968
|
+
/>
|
|
1969
|
+
) : state.turns.length === 0 ? (
|
|
1928
1970
|
<ASKGWelcome
|
|
1929
1971
|
examples={examples}
|
|
1930
1972
|
width={contentWidth}
|
|
@@ -18,9 +18,7 @@ import { useAutoRefresh } from "../../../react/auto-refresh";
|
|
|
18
18
|
import { colors } from "../../../theme/colors";
|
|
19
19
|
import { useThemeColors } from "../../../theme/theme-context";
|
|
20
20
|
import type { PaneProps } from "../../../types/plugin";
|
|
21
|
-
import { formatPercentileRank } from "../../../utils/format";
|
|
22
21
|
import { usePluginPaneState } from "../../runtime";
|
|
23
|
-
import { formatAsOf } from "../cds/model";
|
|
24
22
|
import { FIXED_INCOME_PANE_ID } from "../fixed-income/model";
|
|
25
23
|
import { useCommandValue } from "../shared/command-tab";
|
|
26
24
|
import { getCachedCdxBoard, loadCdxBoard } from "./client";
|
|
@@ -31,6 +29,8 @@ import {
|
|
|
31
29
|
formatContract,
|
|
32
30
|
formatLevel,
|
|
33
31
|
formatMove,
|
|
32
|
+
formatSpreadRank,
|
|
33
|
+
newestRowDate,
|
|
34
34
|
partialDayText,
|
|
35
35
|
SETTLEMENT_TEXT,
|
|
36
36
|
type CdxRow,
|
|
@@ -65,14 +65,18 @@ function HistoryChart({ row, width, height, focused }: { row: CdxRow; width: num
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
function IndexDetail({ row, width, height, focused }: { row: CdxRow; width: number; height: number; focused: boolean }) {
|
|
68
|
-
const { index, year, day } = row;
|
|
68
|
+
const { index, year, day, rank } = row;
|
|
69
69
|
// While today trades the moves run to the last complete day, which the 1D says.
|
|
70
70
|
const through = day.partial && day.changeDate ? `to ${day.changeDate}` : undefined;
|
|
71
|
+
// The rank sits beside what it ranks: HY and EM's spread equivalent, not their price.
|
|
72
|
+
const rankOnSpreadEq = rank.basis === "spread-eq";
|
|
73
|
+
const spreadDetail = [...(rankOnSpreadEq ? [formatSpreadRank(rank)] : []),
|
|
74
|
+
...(index.recovery != null ? [`${Math.round(index.recovery * 100)}% recovery`] : [])].join(" · ");
|
|
71
75
|
const items: StatItem[] = [
|
|
72
76
|
{ id: "level", label: index.quote === "spread" ? "5Y spread" : "5Y price", value: formatLevel(index.quote, index.level),
|
|
73
|
-
detail: [
|
|
77
|
+
detail: [...(rankOnSpreadEq ? [] : [formatSpreadRank(rank)]), index.date ?? "--", ...(index.kind === "settlement" ? [SETTLEMENT_TEXT] : [])].join(" · ") },
|
|
74
78
|
...(index.quote === "price" && index.spreadBp !== undefined ? [{ id: "spread", label: "Spread eq", value: formatLevel("spread", index.spreadBp ?? null),
|
|
75
|
-
...(
|
|
79
|
+
...(spreadDetail ? { detail: spreadDetail } : {}) }] : []),
|
|
76
80
|
{ id: "1d", label: "1D", value: formatMove(index.quote, day.change1D), ...(through ? { detail: through } : {}) },
|
|
77
81
|
{ id: "1w", label: "1W", value: formatMove(index.quote, day.change1W) },
|
|
78
82
|
{ id: "1m", label: "1M", value: formatMove(index.quote, day.change1M) },
|
|
@@ -106,12 +110,21 @@ export function CdxPane({ focused, width, height }: PaneProps) {
|
|
|
106
110
|
useAutoRefresh(resource.updatedAt, refresh);
|
|
107
111
|
usePaneRefreshKey(reload, { focused, enabled: !loading });
|
|
108
112
|
|
|
109
|
-
|
|
113
|
+
// Dated by the newest day the rows carry, not when the response was put together.
|
|
114
|
+
const asOf = newestRowDate(payload?.indexes.map((index) => index.date) ?? []);
|
|
115
|
+
// PCTL 1Y ranks spreads; the rows quoted in price (HY, EM) rank their spread equivalent, which a picture keeps.
|
|
116
|
+
const spreadEqRanked = useMemo(() => rows.filter((row) => row.rank.basis === "spread-eq")
|
|
117
|
+
.map((row) => row.index.name.replace(/^CDX\s+/i, "")).join(", "), [rows]);
|
|
110
118
|
const info = useMemo<PaneFooterSegment[]>(() => [
|
|
111
119
|
...(asOf ? [{ id: "as-of", parts: [{ text: `as of ${asOf}`, tone: "muted" as const }] }] : []),
|
|
112
120
|
...(payload ? [DELAYED_SEGMENT] : []),
|
|
113
121
|
...(resource.data?.stale ? [{ id: "stale", parts: [{ text: "STALE", tone: "warning" as const }] }] : []),
|
|
114
|
-
|
|
122
|
+
...(spreadEqRanked ? [{
|
|
123
|
+
id: "rank-basis", capture: true,
|
|
124
|
+
parts: [{ text: `${spreadEqRanked} pctl on spread eq`, tone: "muted" as const }],
|
|
125
|
+
variants: [[{ text: "pctl on spread eq", tone: "muted" as const }]],
|
|
126
|
+
}] : []),
|
|
127
|
+
], [asOf, payload, resource.data?.stale, spreadEqRanked]);
|
|
115
128
|
usePaneStatusFooter({
|
|
116
129
|
registrationId: "cdx",
|
|
117
130
|
loading,
|
|
@@ -73,6 +73,14 @@ export async function fetchSovrBoard(client: BoardClient = apiClient): Promise<S
|
|
|
73
73
|
catch (error) { throw unavailableOnServer(error, "Sovereign CDS levels are not available yet."); }
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
/** Daily levels: the full history a chart reaches back for stays good for an hour. */
|
|
77
|
+
export const fullCdxHistory = createTtlCache<CdxBoardPayload>({ ttlMs: 60 * 60_000 });
|
|
78
|
+
|
|
79
|
+
/** Every day of index history the server keeps, for a chart that reaches back past the board's year. */
|
|
80
|
+
export function loadFullCdxHistory(client: BoardClient = apiClient): Promise<CdxBoardPayload> {
|
|
81
|
+
return fullCdxHistory.load("all", () => fetchCdxBoard(client, CDX_MAX_DAYS));
|
|
82
|
+
}
|
|
83
|
+
|
|
76
84
|
export const getCachedCdxBoard = () => cachedCloudResource(cdxBoardCache, "5y", validateCdxBoard);
|
|
77
85
|
export const loadCdxBoard = (force = false) =>
|
|
78
86
|
loadCloudResource(cdxBoardCache, "5y", () => fetchCdxBoard(), { force, validate: validateCdxBoard });
|
|
@@ -109,7 +109,10 @@ const CDX_COLUMNS: HeadlessPaneColumn[] = [
|
|
|
109
109
|
moveColumn("change1W", "1W", "changeUnit"),
|
|
110
110
|
moveColumn("change1M", "1M", "changeUnit"),
|
|
111
111
|
spreadColumn,
|
|
112
|
-
{ key: "percentile", header: "Pctl 1Y", align: "right", format: percentile
|
|
112
|
+
{ key: "percentile", header: "Pctl 1Y", align: "right", format: percentile,
|
|
113
|
+
description: "Where the spread sits in its last year, 100 the widest. IG and iTraxx rank their spread; HY and EM rank the spread "
|
|
114
|
+
+ "equivalent of each day's on-the-run contract, not their price; CMBX, quoted in price alone, ranks its price upside down, "
|
|
115
|
+
+ "so its lowest price is 100. Blank with fewer than 20 days of spreads in the year." },
|
|
113
116
|
{ key: "prints", header: "Prints", align: "right" },
|
|
114
117
|
{ key: "contract", header: "Contract" },
|
|
115
118
|
{ key: "date", header: "As of" },
|