gloomberb 0.20.5 → 0.20.6
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/hk-tenders.ts +59 -0
- package/src/api-client/index.ts +1 -0
- 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/cli/commands/market.ts +164 -40
- package/src/cli/commands/news-search.ts +22 -7
- package/src/cli/commands/overview.ts +12 -6
- package/src/cli/commands/ticker.ts +3 -1
- 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/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/result.ts +21 -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 +3 -3
- package/src/market-data/market/change-basis.ts +9 -5
- package/src/market-data/market/dated-previous-close.ts +57 -6
- package/src/market-data/quotes/contributions.ts +2 -0
- package/src/market-data/quotes/listing-enterprise-value.ts +50 -0
- 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/portfolio-list/cli/render.ts +20 -3
- package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +5 -1
- 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/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/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/sync/controller.ts +17 -2
- package/src/sync/other-window-tabs.ts +32 -1
- package/src/sync/react.ts +4 -4
- 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.ts +143 -11
- 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 +6 -0
- package/src/types/headless.ts +8 -0
- package/src/utils/cli-output.ts +6 -3
- package/src/utils/ebitda.ts +128 -0
- package/src/utils/format.ts +1 -1
- package/src/utils/shell-word.ts +13 -0
|
@@ -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" },
|
|
@@ -10,6 +10,7 @@ import { historyStatistics } from "../../../components/chart/curve/model";
|
|
|
10
10
|
import type { MarketBoardRow } from "../../../components/market-board";
|
|
11
11
|
import type { PricePoint } from "../../../types/financials";
|
|
12
12
|
import type { HeadlessPaneColumn } from "../../../types/plugin";
|
|
13
|
+
import { formatPercentileRank } from "../../../utils/format";
|
|
13
14
|
|
|
14
15
|
const YEAR_DAYS = 365;
|
|
15
16
|
/** A level older than this is not the current market. */
|
|
@@ -173,12 +174,60 @@ interface YearStatistics {
|
|
|
173
174
|
high: number | null;
|
|
174
175
|
}
|
|
175
176
|
|
|
176
|
-
/** Where the latest level sits in its own year: midrank, with the range. */
|
|
177
|
-
function yearStatistics(points: readonly CreditBoardPoint[], level: number | null, date: string | null): YearStatistics {
|
|
177
|
+
/** Where the latest level sits in its own year: midrank, with the range, and no rank from fewer than `minCount` days. */
|
|
178
|
+
function yearStatistics(points: readonly CreditBoardPoint[], level: number | null, date: string | null, minCount = 2): YearStatistics {
|
|
178
179
|
if (level == null || !date) return { percentile: null, low: null, high: null };
|
|
179
180
|
const year = historyStatistics(points.map((point) => ({ date: point.date, value: point.level })), level,
|
|
180
181
|
{ asOf: date, windowDays: YEAR_DAYS });
|
|
181
|
-
return { percentile: year.count >=
|
|
182
|
+
return { percentile: year.count >= minCount ? year.percentile : null, low: year.min, high: year.max };
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** The fewest days of spreads in its year a CDX rank is read from: a month of trading; fewer leave it blank. */
|
|
186
|
+
const MIN_SPREAD_RANK_POINTS = 20;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* What a credit rank ranks, so it always reads high = wide: the spread a row
|
|
190
|
+
* quotes; HY and EM's spread equivalent, each day's on its on-the-run
|
|
191
|
+
* contract; or, for a price with no spread beside it (CMBX), the price
|
|
192
|
+
* upside down, the lowest price ranking 100.
|
|
193
|
+
*/
|
|
194
|
+
type SpreadRankBasis = "spread" | "spread-eq" | "price-inverted";
|
|
195
|
+
|
|
196
|
+
export interface SpreadRank {
|
|
197
|
+
percentile: number | null;
|
|
198
|
+
basis: SpreadRankBasis;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Where an index's spread sits in its own year, 100 the widest. A price
|
|
203
|
+
* quote ranks backwards (a falling price is a widening spread), so HY and EM
|
|
204
|
+
* rank their spread equivalent instead, and a price without one is ranked
|
|
205
|
+
* from the top. A spread rank needs a month of spreads in the year
|
|
206
|
+
* (MIN_SPREAD_RANK_POINTS); with fewer it is blank, never read off a handful.
|
|
207
|
+
*/
|
|
208
|
+
export function spreadRank(index: Pick<CdxBoardIndex, "quote" | "points" | "level" | "date" | "spreadBp">): SpreadRank {
|
|
209
|
+
if (index.quote === "spread") {
|
|
210
|
+
return { percentile: yearStatistics(index.points, index.level, index.date, MIN_SPREAD_RANK_POINTS).percentile, basis: "spread" };
|
|
211
|
+
}
|
|
212
|
+
const spreads = index.points.flatMap((point) => typeof point.spreadBp === "number" && Number.isFinite(point.spreadBp)
|
|
213
|
+
? [{ ...point, level: point.spreadBp }] : []);
|
|
214
|
+
if (spreads.length > 0 && typeof index.spreadBp === "number") {
|
|
215
|
+
return { percentile: yearStatistics(spreads, index.spreadBp, index.date, MIN_SPREAD_RANK_POINTS).percentile, basis: "spread-eq" };
|
|
216
|
+
}
|
|
217
|
+
const price = yearStatistics(index.points, index.level, index.date).percentile;
|
|
218
|
+
return { percentile: price == null ? null : 100 - price, basis: "price-inverted" };
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** A spread rank as a detail line says it: `89 pctl 1Y`, and for a price ranked upside down, says so. */
|
|
222
|
+
export function formatSpreadRank(rank: SpreadRank): string {
|
|
223
|
+
const text = formatPercentileRank(rank.percentile, "1Y");
|
|
224
|
+
return rank.basis === "price-inverted" && rank.percentile != null ? `${text}, price inverted` : text;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/** The newest day a board's rows are dated, which its footer dates the board by; null with none. */
|
|
228
|
+
export function newestRowDate(dates: ReadonlyArray<string | null | undefined>): string | null {
|
|
229
|
+
return dates.reduce<string | null>((newest, date) => date && /^\d{4}-\d{2}-\d{2}/.test(date) && (!newest || date > newest)
|
|
230
|
+
? date.slice(0, 10) : newest, null);
|
|
182
231
|
}
|
|
183
232
|
|
|
184
233
|
function daysBetween(from: string, to: string): number {
|
|
@@ -219,7 +268,10 @@ export function findSovereign<T extends { id: string; name: string }>(sovereigns
|
|
|
219
268
|
|
|
220
269
|
export interface CdxRow extends MarketBoardRow {
|
|
221
270
|
index: CdxBoardIndex;
|
|
271
|
+
/** The level's own year: its range, in the quote's unit. */
|
|
222
272
|
year: YearStatistics;
|
|
273
|
+
/** The rank the board shows, high = wide whatever the quote. */
|
|
274
|
+
rank: SpreadRank;
|
|
223
275
|
/** The latest day's standing and the moves between complete days. */
|
|
224
276
|
day: CdxDay;
|
|
225
277
|
/** The 1W and 1M moves as shown. */
|
|
@@ -230,6 +282,7 @@ export interface CdxRow extends MarketBoardRow {
|
|
|
230
282
|
export function cdxRows(indexes: readonly CdxBoardIndex[], asOf: string | null, now = Date.now()): CdxRow[] {
|
|
231
283
|
return indexes.map((index) => {
|
|
232
284
|
const year = yearStatistics(index.points, index.level, index.date);
|
|
285
|
+
const rank = spreadRank(index);
|
|
233
286
|
const day = cdxDay(index, now);
|
|
234
287
|
return {
|
|
235
288
|
id: index.id,
|
|
@@ -238,13 +291,14 @@ export function cdxRows(indexes: readonly CdxBoardIndex[], asOf: string | null,
|
|
|
238
291
|
valueText: formatLevel(index.quote, index.level),
|
|
239
292
|
change: shown(index.quote, day.change1D),
|
|
240
293
|
changeText: formatMove(index.quote, day.change1D),
|
|
241
|
-
percentile:
|
|
294
|
+
percentile: rank.percentile,
|
|
242
295
|
asOf: index.date,
|
|
243
296
|
history: pointHistory(index.points),
|
|
244
297
|
status: index.level == null ? "unavailable" : stale(index.date, asOf) ? "stale" : day.partial ? "partial" : "available",
|
|
245
298
|
adverseMove: adverseMove(index.quote),
|
|
246
299
|
index,
|
|
247
300
|
year,
|
|
301
|
+
rank,
|
|
248
302
|
day,
|
|
249
303
|
week: shown(index.quote, day.change1W),
|
|
250
304
|
month: shown(index.quote, day.change1M),
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { CreditBoardPoint } from "../../../api-client/credit-boards";
|
|
2
|
-
import type { SeriesDefinition, SeriesLoadResult } from "../../../series/types";
|
|
1
|
+
import type { CdxBoardIndex, CreditBoardPoint } from "../../../api-client/credit-boards";
|
|
2
|
+
import type { SeriesDefinition, SeriesLoadRequest, SeriesLoadResult, SeriesPoint } from "../../../series/types";
|
|
3
|
+
import { logFailure } from "../../../utils/log-failure";
|
|
3
4
|
import { cachedSeriesNote } from "../shared/series-warning";
|
|
4
|
-
import { loadCdxBoard, loadSovrBoard } from "./client";
|
|
5
|
+
import { loadCdxBoard, loadFullCdxHistory, loadSovrBoard } from "./client";
|
|
5
6
|
|
|
6
7
|
/** The five on-the-run 5Y index contracts the CDX tab lists; IG and iTraxx quote spread, HY and EM price. */
|
|
7
8
|
const INDEXES = [
|
|
@@ -37,6 +38,49 @@ function boardPoints(
|
|
|
37
38
|
};
|
|
38
39
|
}
|
|
39
40
|
|
|
41
|
+
/** A chart that starts within this of the board's first day is drawn from the board. */
|
|
42
|
+
const BOARD_SLACK_MS = 7 * 86_400_000;
|
|
43
|
+
|
|
44
|
+
type CdxSeriesResource = { stale?: boolean; refreshError?: string | null; savedAt?: number };
|
|
45
|
+
|
|
46
|
+
/** What a chart that asked for more than the board's year says when the rest did not load. */
|
|
47
|
+
const BOARD_YEAR_ONLY = "The full history did not load; showing the last year.";
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The indexes as a chart asks for them: the board, which holds a year, or
|
|
51
|
+
* every day the server keeps when the chart starts before it (ALL, 5Y).
|
|
52
|
+
* When that read fails the board's year stands in, said with `warning`.
|
|
53
|
+
*/
|
|
54
|
+
async function cdxIndexes(request: SeriesLoadRequest): Promise<{ indexes: readonly CdxBoardIndex[]; resource: CdxSeriesResource; warning?: string }> {
|
|
55
|
+
const resource = await loadCdxBoard();
|
|
56
|
+
const first = Math.min(...resource.payload.indexes.flatMap((index) => index.points.slice(0, 1).map((point) => Date.parse(`${point.date}T00:00:00Z`))));
|
|
57
|
+
if (!request.start || request.start.getTime() < first - BOARD_SLACK_MS) {
|
|
58
|
+
const full = await loadFullCdxHistory().catch(logFailure("credit-boards", "Read the full index CDS history failed", null));
|
|
59
|
+
if (full) return { indexes: full.indexes, resource: {} };
|
|
60
|
+
return { indexes: resource.payload.indexes, resource, warning: BOARD_YEAR_ONLY };
|
|
61
|
+
}
|
|
62
|
+
return { indexes: resource.payload.indexes, resource };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** A CDX series' note: the board's own, or, when it stood in for the full history, that. */
|
|
66
|
+
function cdxSeriesNote({ resource, warning }: { resource: CdxSeriesResource; warning?: string }): Pick<SeriesLoadResult, "warning" | "savedAt"> {
|
|
67
|
+
const note = cachedSeriesNote(resource);
|
|
68
|
+
return warning ? { ...note, warning: note.warning ? `${warning} ${note.warning}` : warning } : note;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* HY and EM's price as the spread credit desks compare (each day's on its
|
|
73
|
+
* on-the-run contract, ISDA standard model at the index's coupon and standard
|
|
74
|
+
* recovery), so HY less IG, or cash less CDX, is one formula in bp.
|
|
75
|
+
*/
|
|
76
|
+
function spreadEquivalentPoints(indexes: readonly CdxBoardIndex[], code: string, name: string): SeriesPoint[] {
|
|
77
|
+
const row = indexes.find((entry) => entry.id === code);
|
|
78
|
+
if (!row) throw new Error(`${name} is not on the board right now.`);
|
|
79
|
+
const points = row.points.flatMap((point) => typeof point.spreadBp === "number" ? [{ date: point.date, value: point.spreadBp }] : []);
|
|
80
|
+
if (points.length === 0) throw new Error(`${name} has no spread equivalent from this server yet.`);
|
|
81
|
+
return points;
|
|
82
|
+
}
|
|
83
|
+
|
|
40
84
|
export const CREDIT_BOARD_SERIES: readonly SeriesDefinition[] = [
|
|
41
85
|
...INDEXES.map((index): SeriesDefinition => ({
|
|
42
86
|
id: `cdx:${index.code.toLowerCase()}`,
|
|
@@ -45,9 +89,22 @@ export const CREDIT_BOARD_SERIES: readonly SeriesDefinition[] = [
|
|
|
45
89
|
frequency: "daily",
|
|
46
90
|
group: "Credit",
|
|
47
91
|
tags: ["CDS", "index CDS", index.quote, "credit default swap"],
|
|
48
|
-
load: async () => {
|
|
49
|
-
const
|
|
50
|
-
return boardPoints(
|
|
92
|
+
load: async (request) => {
|
|
93
|
+
const read = await cdxIndexes(request);
|
|
94
|
+
return { ...boardPoints(read.indexes, index.code, index.name, read.resource), ...cdxSeriesNote(read) };
|
|
95
|
+
},
|
|
96
|
+
})),
|
|
97
|
+
...INDEXES.filter((index) => index.quote === "price").map((index): SeriesDefinition => ({
|
|
98
|
+
id: `cdx:${index.code.toLowerCase()}-spread`,
|
|
99
|
+
name: `${index.name} spread eq`,
|
|
100
|
+
unit: "bp",
|
|
101
|
+
frequency: "daily",
|
|
102
|
+
group: "Credit",
|
|
103
|
+
tags: ["CDS", "index CDS", "spread", "spread equivalent", index.code, "credit default swap"],
|
|
104
|
+
description: `${index.name}'s daily price as a conventional spread: a model figure from the ISDA standard model at the index's coupon and standard recovery, on each day's on-the-run contract, not a traded spread.`,
|
|
105
|
+
load: async (request) => {
|
|
106
|
+
const read = await cdxIndexes(request);
|
|
107
|
+
return { points: spreadEquivalentPoints(read.indexes, index.code, `${index.name} spread eq`), ...cdxSeriesNote(read) };
|
|
51
108
|
},
|
|
52
109
|
})),
|
|
53
110
|
...SOVEREIGNS.map(([code, name]): SeriesDefinition => ({
|
|
@@ -21,7 +21,6 @@ import { useThemeColors } from "../../../theme/theme-context";
|
|
|
21
21
|
import type { PaneProps } from "../../../types/plugin";
|
|
22
22
|
import { formatPercentileRank } from "../../../utils/format";
|
|
23
23
|
import { useAssetData, usePluginPaneState } from "../../runtime";
|
|
24
|
-
import { formatAsOf } from "../cds/model";
|
|
25
24
|
import { FIXED_INCOME_PANE_ID } from "../fixed-income/model";
|
|
26
25
|
import { useCommandValue } from "../shared/command-tab";
|
|
27
26
|
import { getCachedSovrBoard, loadCurrencyMoves, loadSovrBoard } from "./client";
|
|
@@ -32,6 +31,7 @@ import {
|
|
|
32
31
|
formatCurrencyMove,
|
|
33
32
|
formatLevel,
|
|
34
33
|
formatMove,
|
|
34
|
+
newestRowDate,
|
|
35
35
|
SETTLEMENT_TEXT,
|
|
36
36
|
sovrRows,
|
|
37
37
|
type SovrRow,
|
|
@@ -115,7 +115,8 @@ export function SovrPane({ focused, width, height }: PaneProps) {
|
|
|
115
115
|
moves.reload();
|
|
116
116
|
}, { focused, enabled: !loading });
|
|
117
117
|
|
|
118
|
-
|
|
118
|
+
// Dated by the newest day the rows carry, not when the response was put together.
|
|
119
|
+
const asOf = newestRowDate(payload?.sovereigns.map((sovereign) => sovereign.date) ?? []);
|
|
119
120
|
const info = useMemo<PaneFooterSegment[]>(() => [
|
|
120
121
|
...(asOf ? [{ id: "as-of", parts: [{ text: `as of ${asOf}`, tone: "muted" as const }] }] : []),
|
|
121
122
|
...(payload ? [DELAYED_SEGMENT] : []),
|