liquilens 0.5.2 → 0.5.3
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 +8 -8
- package/dist/App.js +19 -11
- package/dist/api.js +9 -0
- package/dist/cli.js +7 -9
- package/dist/format.js +14 -6
- package/dist/plain.js +25 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,10 +22,10 @@ review tiers paused since 2026-11-03: tiers paused, research only; no grade, ban
|
|
|
22
22
|
|
|
23
23
|
Two boards, one command:
|
|
24
24
|
|
|
25
|
-
- **IN**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
- **IN** covers Indian banks, SFBs, NBFCs and MFIs. The public summary shows
|
|
26
|
+
the score, 12/24/36-month research probabilities, funding index and RBI zone.
|
|
27
|
+
Detail depends on what the API serves. Grades require published review
|
|
28
|
+
tiers. Risk bands also require the underlying inputs.
|
|
29
29
|
- **US** (the riskiest tail of 1,000+ FDIC-scored banks, undertow engine):
|
|
30
30
|
within-quarter percentile score, noncurrent assets, uninsured/brokered
|
|
31
31
|
deposits, CRE concentration, NDFI-to-tier-1.
|
|
@@ -71,9 +71,9 @@ liquilens
|
|
|
71
71
|
preserve the served `/api/evidence/markets` payload exactly. It cannot be
|
|
72
72
|
combined with `--region` or `--fail-on`.
|
|
73
73
|
- **`--fail-on amber|red`**: alerting for cron/CI. Exits 3 when any Indian
|
|
74
|
-
institution is at/above the band, 0 when
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
institution is at/above the band, 0 when all are below it, and 4 when the
|
|
75
|
+
tiers are paused or the board lacks the detailed inputs for a comparison.
|
|
76
|
+
On the US board, scores are within-quarter percentile ranks,
|
|
77
77
|
a relative leaderboard, so an absolute threshold would always fire.
|
|
78
78
|
|
|
79
79
|
```bash
|
|
@@ -148,7 +148,7 @@ and machine details are never sent as analytics.
|
|
|
148
148
|
## Exit codes
|
|
149
149
|
|
|
150
150
|
0 ok · 1 no data (API down, no cache) · 2 bad usage · 3 `--fail-on` breached ·
|
|
151
|
-
4 `--fail-on` not
|
|
151
|
+
4 `--fail-on` could not evaluate the board (tiers paused or detailed inputs unavailable)
|
|
152
152
|
|
|
153
153
|
## Config
|
|
154
154
|
|
package/dist/App.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { Box, Text, useApp, useInput, useStdout } from "ink";
|
|
4
|
-
import { fetchBoard, fetchNews, fetchRegime, fetchUSBoard, } from "./api.js";
|
|
4
|
+
import { fetchBoard, fetchNews, fetchRegime, fetchUSBoard, hasRadarDetail, probabilities, probabilityChange, } from "./api.js";
|
|
5
5
|
import { loadCached, saveCached, ageMinutes, describeAge, } from "./cache.js";
|
|
6
|
-
import { cell, computeCols, computeUSCols, filterRows, filterUSRows, fmtAssets, fundingLabel, movement, pct, pct1, rawPct, SORT_MODES, sortRows, sortUSRows, sparkline, US_SORT_MODES, viewport, } from "./format.js";
|
|
6
|
+
import { cell, computeCols, computeUSCols, filterRows, filterUSRows, fmtAssets, fundingLabel, fundingSummary, movement, pct, pct1, rawPct, SORT_MODES, sortRows, sortUSRows, sparkline, US_SORT_MODES, viewport, } from "./format.js";
|
|
7
7
|
import { pausedLine, riskBand, tiersPublished, usRiskBandByRank, bandColor } from "./riskBands.js";
|
|
8
8
|
const ACCENT = "#9184d9"; // Nocturne
|
|
9
9
|
const DIM = "gray";
|
|
@@ -52,13 +52,14 @@ function Header({ region, regime, regimeError, usBoard, width, }) {
|
|
|
52
52
|
const spark = region === "in" && width >= 96 && regime?.series?.log_sr
|
|
53
53
|
? sparkline(regime.series.log_sr, 28)
|
|
54
54
|
: "";
|
|
55
|
-
return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Text, { color: ACCENT, bold: true, children: "\u25C6 LIQUILENS" }), _jsx(Text, { color: DIM, children: " \u00B7 Failure Radar \u00B7 " }), _jsx(Text, { color: region === "in" ? ACCENT : DIM, bold: region === "in", children: "IN" }), _jsx(Text, { color: DIM, children: "/" }), _jsx(Text, { color: region === "us" ? ACCENT : DIM, bold: region === "us", children: "US" }), _jsx(Text, { color: DIM, children: " (t to switch)" })] }), region === "in" ? (regime ? (_jsxs(Box, { children: [_jsx(Text, { color: DIM, children: "market regime " }), _jsx(Text, { color: regimeColor(regime.regime), bold: true, children: regime.regime }), _jsxs(Text, { color: DIM, children: [" ", "(log-SR ", regime.log_sr_now.toFixed(2), ", last change", " ", regime.trading_days_since_last_change, "d ago)"] }), spark && (_jsxs(Text, { color: regimeColor(regime.regime), children: [" ", spark] })), _jsxs(Text, { color: DIM, children: [" \u00B7 ", regime.as_of] })] })) : regimeError ? (_jsx(Text, { color: DIM, children: "market regime unavailable right now" })) : null) : usBoard ? (_jsxs(Text, { color: DIM, children: ["top ", usBoard.board.length, " of ", usBoard.universe.banks_scored, " FDIC banks (\u2265$1B assets) \u00B7 undertow score = within-quarter percentile \u00B7 quarter ", usBoard.as_of] })) : null] }));
|
|
55
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Text, { color: ACCENT, bold: true, children: "\u25C6 LIQUILENS" }), _jsx(Text, { color: DIM, children: " \u00B7 Failure Radar \u00B7 " }), _jsx(Text, { color: region === "in" ? ACCENT : DIM, bold: region === "in", children: "IN" }), _jsx(Text, { color: DIM, children: "/" }), _jsx(Text, { color: region === "us" ? ACCENT : DIM, bold: region === "us", children: "US" }), _jsx(Text, { color: DIM, children: " (t to switch)" })] }), region === "in" ? (regime?.available ? (_jsxs(Box, { children: [_jsx(Text, { color: DIM, children: "market regime " }), _jsx(Text, { color: regimeColor(regime.regime), bold: true, children: regime.regime }), _jsxs(Text, { color: DIM, children: [" ", "(log-SR ", regime.log_sr_now.toFixed(2), ", last change", " ", regime.trading_days_since_last_change, "d ago)"] }), spark && (_jsxs(Text, { color: regimeColor(regime.regime), children: [" ", spark] })), _jsxs(Text, { color: DIM, children: [" \u00B7 ", regime.as_of] })] })) : regimeError || regime?.available === false ? (_jsx(Text, { color: DIM, children: "market regime unavailable right now" })) : null) : usBoard ? (_jsxs(Text, { color: DIM, children: ["top ", usBoard.board.length, " of ", usBoard.universe.banks_scored, " FDIC banks (\u2265$1B assets) \u00B7 undertow score = within-quarter percentile \u00B7 quarter ", usBoard.as_of] })) : null] }));
|
|
56
56
|
}
|
|
57
57
|
function InRow({ row, selected, cols, showTiers, }) {
|
|
58
58
|
// Bands, grades and their colours only while the API publishes tiers.
|
|
59
|
-
const
|
|
60
|
-
const
|
|
61
|
-
|
|
59
|
+
const detailed = hasRadarDetail(row);
|
|
60
|
+
const color = showTiers && detailed ? bandColor[riskBand(row)] : undefined;
|
|
61
|
+
const move = movement(probabilityChange(row));
|
|
62
|
+
return (_jsxs(Box, { children: [_jsx(Text, { color: selected ? ACCENT : DIM, children: selected ? "❯ " : " " }), _jsx(Text, { color: color, bold: selected, inverse: selected, children: cell(row.name, cols.name) }), _jsx(Text, { color: DIM, children: cell(row.inst_type, cols.type) }), showTiers && _jsx(Text, { color: color, children: cell(row.grade ?? "", cols.grade) }), _jsx(Text, { children: cell(String(row.score), cols.score) }), _jsx(Text, { color: color, children: cell(pct(probabilities(row).pd_12m), cols.pd) }), _jsx(Text, { color: moveColor(move.dir), children: cell(move.text, cols.move) }), _jsx(Text, { color: detailed ? fundColor(row.funding.band) : DIM, children: fundingSummary(row) })] }));
|
|
62
63
|
}
|
|
63
64
|
function UsRow({ row, rank, selected, cols, }) {
|
|
64
65
|
const band = usRiskBandByRank(rank);
|
|
@@ -71,6 +72,8 @@ function NewsLine({ news }) {
|
|
|
71
72
|
return _jsx(Text, { color: DIM, children: "news watch loading\u2026" });
|
|
72
73
|
if (news === "error")
|
|
73
74
|
return _jsx(Text, { color: DIM, children: "news watch unavailable" });
|
|
75
|
+
if ("not_computed" in news)
|
|
76
|
+
return _jsxs(Text, { color: DIM, children: ["news watch: ", news.not_computed] });
|
|
74
77
|
const stressColor = news.news_stress >= 50
|
|
75
78
|
? bandColor.red
|
|
76
79
|
: news.news_stress >= 20
|
|
@@ -79,8 +82,13 @@ function NewsLine({ news }) {
|
|
|
79
82
|
return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { children: [_jsx(Text, { color: DIM, children: "news watch stress " }), _jsx(Text, { color: stressColor, bold: true, children: news.news_stress.toFixed(1) }), _jsxs(Text, { color: DIM, children: [" ", "tone ", news.tone_recent.toFixed(2), " \u00B7 distress share", " ", pct(news.distress_share), " \u00B7 coverage ", news.coverage] })] }), news.basis.slice(0, 2).map((b, i) => (_jsxs(Text, { color: DIM, children: ["\u00B7 ", b] }, i)))] }));
|
|
80
83
|
}
|
|
81
84
|
function InDetail({ row, news, showTiers, }) {
|
|
82
|
-
const
|
|
83
|
-
|
|
85
|
+
const detailed = hasRadarDetail(row);
|
|
86
|
+
const color = showTiers && detailed ? bandColor[riskBand(row)] : undefined;
|
|
87
|
+
const pd = probabilities(row);
|
|
88
|
+
return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: ACCENT, paddingX: 1, children: [_jsxs(Box, { justifyContent: "space-between", gap: 2, children: [_jsx(Text, { bold: true, color: color, children: row.name }), _jsxs(Text, { color: DIM, children: [row.inst_type, " \u00B7 ", row.quarter, " \u00B7 data as of ", row.as_of, detailed && ` (${row.age_months}mo old)`] })] }), _jsxs(Text, { children: [showTiers && _jsx(Text, { color: DIM, children: "grade " }), showTiers && _jsx(Text, { bold: true, children: row.grade ?? "" }), _jsx(Text, { color: DIM, children: showTiers ? " score " : "score " }), _jsx(Text, { bold: true, children: row.score }), _jsx(Text, { color: DIM, children: showTiers ? " PD 12/24/36m " : " PD 12/24/36m, research only " }), _jsxs(Text, { bold: true, color: color, children: [pct(pd.pd_12m), " / ", pct(pd.pd_24m), " / ", pct(pd.pd_36m)] })] }), detailed ? _jsx(InRiskInputs, { row: row }) : (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { children: ["Funding ", fundingSummary(row), " \u00B7 RBI zone ", row.rbi_zone ?? "n/a"] }), _jsx(Text, { color: DIM, children: "Detailed risk inputs are withheld in the public summary." })] })), _jsx(NewsLine, { news: news })] }));
|
|
89
|
+
}
|
|
90
|
+
function InRiskInputs({ row }) {
|
|
91
|
+
return (_jsxs(_Fragment, { children: [row.hazard.basis.length > 0 && (_jsxs(Text, { color: DIM, children: ["hazard basis: ", row.hazard.basis.join("; ")] })), _jsxs(Text, { children: [_jsx(Text, { color: DIM, children: "funding " }), _jsx(Text, { color: fundColor(row.funding.band), children: fundingLabel(row.funding.band) }), row.funding.flags.length > 0 && (_jsxs(Text, { color: bandColor.amber, children: [" \u2691 ", row.funding.flags.join(", ")] })), row.funding.basis.length > 0 && (_jsxs(Text, { color: DIM, children: [" \u00B7 ", row.funding.basis.join("; ")] }))] }), _jsxs(Text, { children: [_jsx(Text, { color: DIM, children: "PCA " }), _jsx(Text, { children: row.pca.status }), row.pca.breaches.length > 0 && (_jsxs(Text, { color: bandColor.red, children: [" breaches: ", row.pca.breaches.join(", ")] }))] }), _jsxs(Text, { children: [_jsx(Text, { color: DIM, children: "forensics " }), row.forensics.fired ? (_jsxs(Text, { color: bandColor.red, children: ["FIRED: ", row.forensics.indicators.join(", ")] })) : (_jsx(Text, { color: bandColor.green, children: "clear" }))] }), row.market && !row.market.stale && (_jsxs(Text, { children: [_jsx(Text, { color: DIM, children: "market lens DD " }), _jsx(Text, { bold: true, children: row.market.dd.toFixed(2) }), _jsx(Text, { color: DIM, children: " Merton PD 1y " }), _jsx(Text, { bold: true, children: pct(row.market.pd_merton_1y) })] }))] }));
|
|
84
92
|
}
|
|
85
93
|
function UsDetail({ row, rank }) {
|
|
86
94
|
const band = usRiskBandByRank(rank);
|
|
@@ -168,7 +176,7 @@ export default function App({ initialRegion = "in" }) {
|
|
|
168
176
|
});
|
|
169
177
|
}, []);
|
|
170
178
|
const load = useCallback((r = region) => (r === "in" ? loadIn() : loadUs()), [region, loadIn, loadUs]);
|
|
171
|
-
// Initial load only
|
|
179
|
+
// Initial load only: later loads are user- or timer-driven.
|
|
172
180
|
useEffect(() => {
|
|
173
181
|
load(region);
|
|
174
182
|
}, []);
|
|
@@ -285,7 +293,7 @@ export default function App({ initialRegion = "in" }) {
|
|
|
285
293
|
const chrome = 7 + (showDetail ? 13 : 0) + (regionStale ? 1 : 0) + pausedNotice;
|
|
286
294
|
const visible = Math.max(3, height - chrome);
|
|
287
295
|
const vp = viewport(rowCount, visible, cursor);
|
|
288
|
-
return (_jsxs(Box, { flexDirection: "column", paddingX: 1, children: [_jsx(Header, { region: region, regime: regime, regimeError: regimeError, usBoard: usBoard, width: width }), regionStale && (_jsxs(Text, { color: bandColor.amber, children: ["\u26A0 offline
|
|
296
|
+
return (_jsxs(Box, { flexDirection: "column", paddingX: 1, children: [_jsx(Header, { region: region, regime: regime, regimeError: regimeError, usBoard: usBoard, width: width }), regionStale && (_jsxs(Text, { color: bandColor.amber, children: ["\u26A0 offline: showing cached board from", " ", describeAge(ageMinutes(regionStale)), " (retrying every 5m, r to retry now)"] })), error && (_jsxs(Text, { color: bandColor.red, children: ["\u2716 ", error, "; press r to retry, or set LIQUILENS_API / HTTPS_PROXY"] })), loading && !hasData && _jsx(Text, { color: DIM, children: "\u283F loading live board\u2026" }), region === "in" && board !== null && !showTiers && (_jsx(Text, { color: bandColor.amber, children: pausedLine(board) })), hasData && (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [region === "in" ? (_jsxs(Text, { color: DIM, bold: true, children: [" ", cell("INSTITUTION", cols.name), cell("TYPE", cols.type), showTiers && cell("GRADE", cols.grade), cell("SCORE", cols.score), cell("PD 12M", cols.pd), cell("Δ PD", cols.move), "FUNDING"] })) : (_jsxs(Text, { color: DIM, bold: true, children: [" ", cell("BANK", usCols.bank), cell("STATE", usCols.state), cell("ASSETS", usCols.assets), cell("SCORE", usCols.score), cell("NONCURR", usCols.noncurr), cell("UNINSURED", usCols.uninsured), "NDFI/T1"] })), vp.above > 0 && _jsxs(Text, { color: DIM, children: [" ", "\u2191 ", vp.above, " more"] }), region === "in"
|
|
289
297
|
? inRows
|
|
290
298
|
.slice(vp.start, vp.end)
|
|
291
299
|
.map((row, i) => (_jsx(InRow, { row: row, selected: vp.start + i === cursor, cols: cols, showTiers: showTiers }, row.slug)))
|
package/dist/api.js
CHANGED
|
@@ -25,6 +25,15 @@ const hasProxyEnv = Boolean(process.env.HTTPS_PROXY ??
|
|
|
25
25
|
const dispatcher = hasProxyEnv
|
|
26
26
|
? new EnvHttpProxyAgent({ connect: CONNECT_OPTS })
|
|
27
27
|
: new Agent({ connect: CONNECT_OPTS });
|
|
28
|
+
export function hasRadarDetail(row) {
|
|
29
|
+
return "hazard" in row;
|
|
30
|
+
}
|
|
31
|
+
export function probabilities(row) {
|
|
32
|
+
return hasRadarDetail(row) ? row.hazard : row;
|
|
33
|
+
}
|
|
34
|
+
export function probabilityChange(row) {
|
|
35
|
+
return hasRadarDetail(row) ? row.movement.delta_pd_12m : row.delta_pd_12m;
|
|
36
|
+
}
|
|
28
37
|
const RETRIES = 3;
|
|
29
38
|
const ATTEMPT_TIMEOUT_MS = 15_000;
|
|
30
39
|
function sleep(ms) {
|
package/dist/cli.js
CHANGED
|
@@ -9,13 +9,13 @@ import { loadCached, saveCached, ageMinutes, describeAge, } from "./cache.js";
|
|
|
9
9
|
import { renderEvidenceJson, renderEvidenceRecord, renderJson, renderPlain, worstBand, } from "./plain.js";
|
|
10
10
|
import { bandAtLeast } from "./riskBands.js";
|
|
11
11
|
// Some networks blackhole IPv6 (Node's fetch hangs while curl works);
|
|
12
|
-
// prefer IPv4 first
|
|
12
|
+
// prefer IPv4 first; undici's autoSelectFamily in api.ts covers the rest.
|
|
13
13
|
dns.setDefaultResultOrder("ipv4first");
|
|
14
14
|
// A crash should read like a message, not a stack dump, and must not leave
|
|
15
15
|
// the terminal in raw mode (Ink's unmount handles restore on normal exits).
|
|
16
16
|
function crash(err) {
|
|
17
17
|
const msg = err instanceof Error ? err.message : String(err);
|
|
18
|
-
process.stderr.write(`\nliquilens: unexpected error
|
|
18
|
+
process.stderr.write(`\nliquilens: unexpected error: ${msg}\n`);
|
|
19
19
|
process.stderr.write("Run again with --plain for a minimal path, or check --help.\n");
|
|
20
20
|
process.exit(1);
|
|
21
21
|
}
|
|
@@ -24,7 +24,7 @@ process.on("unhandledRejection", crash);
|
|
|
24
24
|
const require = createRequire(import.meta.url);
|
|
25
25
|
const { version } = require("../package.json");
|
|
26
26
|
setClientVersion(version);
|
|
27
|
-
const HELP = `liquilens ${version}
|
|
27
|
+
const HELP = `liquilens ${version}: LiquiLens Failure Radar in your terminal
|
|
28
28
|
|
|
29
29
|
Usage: liquilens [options]
|
|
30
30
|
|
|
@@ -40,10 +40,9 @@ Options:
|
|
|
40
40
|
--plain one-shot ANSI-free table (default when stdout is not a TTY)
|
|
41
41
|
--json one-shot machine-readable JSON dump
|
|
42
42
|
--fail-on <band> exit 3 if any institution is at/above band (amber|red).
|
|
43
|
-
India board only
|
|
43
|
+
India board only; the US board is a relative leaderboard.
|
|
44
44
|
Implies --plain unless --json is given. For cron/CI alerts.
|
|
45
|
-
|
|
46
|
-
instead: there is no band to compare.
|
|
45
|
+
Exits 4 if tiers are paused or detailed inputs are unavailable.
|
|
47
46
|
--api <url> API host (default ${DEFAULT_API}; env LIQUILENS_API)
|
|
48
47
|
-h, --help show this help
|
|
49
48
|
-v, --version show version
|
|
@@ -56,7 +55,7 @@ Keys (interactive): ↑↓/jk select · ⏎ detail · t region · s sort · / fi
|
|
|
56
55
|
r refresh · q quit
|
|
57
56
|
Exit codes: 0 ok · 1 no data (API down and no cache) · 2 bad usage ·
|
|
58
57
|
3 --fail-on threshold breached ·
|
|
59
|
-
4 --fail-on not
|
|
58
|
+
4 --fail-on could not evaluate the board (tiers paused or detailed inputs unavailable)`;
|
|
60
59
|
function fail(msg, code) {
|
|
61
60
|
process.stderr.write(`liquilens: ${msg}\n`);
|
|
62
61
|
process.exit(code);
|
|
@@ -206,8 +205,7 @@ else {
|
|
|
206
205
|
const worst = worstBand(snap);
|
|
207
206
|
if (worst === null) {
|
|
208
207
|
// Never a silent pass: a paused board is not a calm board.
|
|
209
|
-
process.stderr.write(`liquilens: --fail-on ${parsed.failOn} not evaluated:
|
|
210
|
-
"are paused (research only), so there is no band to compare\n");
|
|
208
|
+
process.stderr.write(`liquilens: --fail-on ${parsed.failOn} not evaluated: published tiers and detailed risk inputs are required\n`);
|
|
211
209
|
process.exit(4);
|
|
212
210
|
}
|
|
213
211
|
if (bandAtLeast(worst, parsed.failOn)) {
|
package/dist/format.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { hasRadarDetail, probabilities, probabilityChange } from "./api.js";
|
|
2
|
+
export const pct = (x) => x == null ? "n/a" : `${(x * 100).toFixed(2)}%`;
|
|
2
3
|
/** Fraction -> "17.0%", tolerating missing values. */
|
|
3
|
-
export const pct1 = (x) => x == null ? "
|
|
4
|
+
export const pct1 = (x) => x == null ? "n/a" : `${(x * 100).toFixed(1)}%`;
|
|
4
5
|
/** Value already in percent units (FDIC noncurrent_ratio: 4.0 = 4%). */
|
|
5
|
-
export const rawPct = (x) => x == null ? "
|
|
6
|
+
export const rawPct = (x) => x == null ? "n/a" : `${x.toFixed(2)}%`;
|
|
6
7
|
/** Assets reported in USD thousands -> "$15.2B" / "$980M". */
|
|
7
8
|
export function fmtAssets(usdK) {
|
|
8
9
|
const usd = usdK * 1_000;
|
|
@@ -29,6 +30,8 @@ export function sparkline(values, width) {
|
|
|
29
30
|
.join("");
|
|
30
31
|
}
|
|
31
32
|
export function movement(delta) {
|
|
33
|
+
if (delta == null)
|
|
34
|
+
return { text: "n/a", dir: "flat" };
|
|
32
35
|
if (delta > 0.0005)
|
|
33
36
|
return { text: `▲ ${pct(delta)}`, dir: "up" };
|
|
34
37
|
if (delta < -0.0005)
|
|
@@ -38,6 +41,11 @@ export function movement(delta) {
|
|
|
38
41
|
export function fundingLabel(band) {
|
|
39
42
|
return band === "not_scored" ? "n/a" : band;
|
|
40
43
|
}
|
|
44
|
+
export function fundingSummary(row) {
|
|
45
|
+
if (hasRadarDetail(row))
|
|
46
|
+
return fundingLabel(row.funding.band);
|
|
47
|
+
return row.funding_index == null ? "n/a" : `index ${row.funding_index}`;
|
|
48
|
+
}
|
|
41
49
|
/**
|
|
42
50
|
* Column widths for a given terminal width. The name column absorbs all
|
|
43
51
|
* slack between a floor (narrow terminals truncate names) and a ceiling
|
|
@@ -52,7 +60,7 @@ export function computeCols(termWidth) {
|
|
|
52
60
|
const name = Math.max(18, Math.min(40, termWidth - used));
|
|
53
61
|
return { name, ...fixed };
|
|
54
62
|
}
|
|
55
|
-
/** Truncate to width (with ellipsis) then pad
|
|
63
|
+
/** Truncate to width (with ellipsis) then pad, so cells never overflow. */
|
|
56
64
|
export function cell(text, width) {
|
|
57
65
|
if (text.length > width - 1) {
|
|
58
66
|
return `${text.slice(0, Math.max(0, width - 2))}… `.padEnd(width);
|
|
@@ -64,10 +72,10 @@ export function sortRows(rows, mode) {
|
|
|
64
72
|
const sorted = [...rows];
|
|
65
73
|
switch (mode) {
|
|
66
74
|
case "risk":
|
|
67
|
-
sorted.sort((a, b) => b.
|
|
75
|
+
sorted.sort((a, b) => (probabilities(b).pd_12m ?? -Infinity) - (probabilities(a).pd_12m ?? -Infinity));
|
|
68
76
|
break;
|
|
69
77
|
case "movement":
|
|
70
|
-
sorted.sort((a, b) => b
|
|
78
|
+
sorted.sort((a, b) => (probabilityChange(b) ?? -Infinity) - (probabilityChange(a) ?? -Infinity));
|
|
71
79
|
break;
|
|
72
80
|
case "score":
|
|
73
81
|
sorted.sort((a, b) => a.score - b.score);
|
package/dist/plain.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { hasRadarDetail, probabilities, probabilityChange } from "./api.js";
|
|
2
|
+
import { cell, computeCols, computeUSCols, fmtAssets, fundingSummary, movement, pct, pct1, rawPct, sortRows, sortUSRows, } from "./format.js";
|
|
2
3
|
import { pausedLine, riskBand, tiersPublished, usRiskBandByRank } from "./riskBands.js";
|
|
3
4
|
function staleLine(stale) {
|
|
4
5
|
return stale
|
|
5
|
-
? [`WARNING: live API unreachable
|
|
6
|
+
? [`WARNING: live API unreachable; cached data from ${stale.description}`]
|
|
6
7
|
: [];
|
|
7
8
|
}
|
|
8
9
|
/** Worst risk band on the board, which drives --fail-on exit codes. Null for
|
|
@@ -13,8 +14,9 @@ export function worstBand(snap) {
|
|
|
13
14
|
// absolute alerting (enforced at arg-parse time).
|
|
14
15
|
return snap.board.board.length > 0 ? "red" : "green";
|
|
15
16
|
}
|
|
16
|
-
if (!tiersPublished(snap.board))
|
|
17
|
+
if (!tiersPublished(snap.board) || !snap.board.rows.length || !snap.board.rows.every(hasRadarDetail)) {
|
|
17
18
|
return null;
|
|
19
|
+
}
|
|
18
20
|
let worst = "green";
|
|
19
21
|
for (const row of snap.board.rows) {
|
|
20
22
|
const b = riskBand(row);
|
|
@@ -32,7 +34,7 @@ export function renderPlain(snap, width = 100) {
|
|
|
32
34
|
const cols = computeCols(width);
|
|
33
35
|
const lines = [];
|
|
34
36
|
lines.push(`LIQUILENS Failure Radar · INDIA · board as of ${snap.board.as_of}`);
|
|
35
|
-
if (snap.regime) {
|
|
37
|
+
if (snap.regime?.available) {
|
|
36
38
|
lines.push(`market regime ${snap.regime.regime} (log-SR ${snap.regime.log_sr_now.toFixed(2)}, ` +
|
|
37
39
|
`last change ${snap.regime.trading_days_since_last_change}d ago) · ${snap.regime.as_of}`);
|
|
38
40
|
}
|
|
@@ -40,6 +42,9 @@ export function renderPlain(snap, width = 100) {
|
|
|
40
42
|
const published = tiersPublished(snap.board);
|
|
41
43
|
if (!published)
|
|
42
44
|
lines.push(pausedLine(snap.board));
|
|
45
|
+
if (snap.board.rows.some((row) => !hasRadarDetail(row))) {
|
|
46
|
+
lines.push("Rows in the public summary show a funding index. Detailed risk inputs are withheld.");
|
|
47
|
+
}
|
|
43
48
|
lines.push("");
|
|
44
49
|
lines.push(" " +
|
|
45
50
|
cell("INSTITUTION", cols.name) +
|
|
@@ -55,11 +60,11 @@ export function renderPlain(snap, width = 100) {
|
|
|
55
60
|
cell(row.inst_type, cols.type) +
|
|
56
61
|
(published ? cell(row.grade ?? "", cols.grade) : "") +
|
|
57
62
|
cell(String(row.score), cols.score) +
|
|
58
|
-
cell(pct(row.
|
|
59
|
-
cell(movement(row
|
|
63
|
+
cell(pct(probabilities(row).pd_12m), cols.pd) +
|
|
64
|
+
cell(movement(probabilityChange(row)).text, cols.move) +
|
|
60
65
|
(published
|
|
61
|
-
?
|
|
62
|
-
:
|
|
66
|
+
? fundingSummary(row).padEnd(12) + (hasRadarDetail(row) ? riskBand(row).toUpperCase() : "n/a")
|
|
67
|
+
: fundingSummary(row)));
|
|
63
68
|
}
|
|
64
69
|
if (!published)
|
|
65
70
|
lines.push("* research only while review tiers are paused");
|
|
@@ -103,7 +108,11 @@ function renderPlainUS(snap, width) {
|
|
|
103
108
|
/** A row as research only: no grade letter even from an older cached board. */
|
|
104
109
|
function researchRow(r) {
|
|
105
110
|
const withoutGrade = (o) => Object.fromEntries(Object.entries(o).filter(([k]) => k !== "grade" && k !== "tier"));
|
|
106
|
-
return {
|
|
111
|
+
return {
|
|
112
|
+
...withoutGrade(r),
|
|
113
|
+
...(hasRadarDetail(r) ? { hazard: withoutGrade(r.hazard) } : {}),
|
|
114
|
+
pd_research_only: true,
|
|
115
|
+
};
|
|
107
116
|
}
|
|
108
117
|
/** Machine-readable dump for `--json`. */
|
|
109
118
|
export function renderJson(snap) {
|
|
@@ -125,7 +134,13 @@ export function renderJson(snap) {
|
|
|
125
134
|
stale: snap.stale ? { cached_at: snap.stale.savedAt } : null,
|
|
126
135
|
market_regime: snap.regime,
|
|
127
136
|
tier_publication: snap.board.tier_publication ?? null,
|
|
128
|
-
|
|
137
|
+
...(snap.board.access ? { access: snap.board.access } : {}),
|
|
138
|
+
...(snap.board.historical_evidence ? { historical_evidence: snap.board.historical_evidence } : {}),
|
|
139
|
+
rows: sortRows(snap.board.rows, "risk").map((row) => {
|
|
140
|
+
if (!published)
|
|
141
|
+
return researchRow(row);
|
|
142
|
+
return hasRadarDetail(row) ? { ...row, risk_band: riskBand(row) } : row;
|
|
143
|
+
}),
|
|
129
144
|
}, null, 2);
|
|
130
145
|
}
|
|
131
146
|
function evidenceFlag(value) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "liquilens",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"description": "LiquiLens Failure Radar in your terminal: a live early-warning board for Indian institutions and FDIC-scored US banks, from public data",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"homepage": "https://liquilens.in/developers/",
|