liquilens 0.5.0 → 0.5.2
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 +59 -29
- package/dist/App.js +14 -11
- package/dist/cli.js +16 -4
- package/dist/plain.js +25 -13
- package/dist/riskBands.js +15 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# liquilens
|
|
1
|
+
# liquilens: the terminal
|
|
2
2
|
|
|
3
3
|
The LiquiLens Failure Radar as a live terminal dashboard, in the spirit of
|
|
4
4
|
Claude Code / htop. Zero keys required: it reads the same public, no-auth
|
|
@@ -9,21 +9,24 @@ Need the radar on your own counterparty or borrower book? A fixed-scope,
|
|
|
9
9
|
self-hosted proof pilot is available at
|
|
10
10
|
[liquilens.in/pilot](https://liquilens.in/pilot/).
|
|
11
11
|
|
|
12
|
+
Layout of the India board while review tiers are paused (values elided):
|
|
13
|
+
|
|
12
14
|
```
|
|
13
15
|
◆ LIQUILENS · Failure Radar · IN/US (t to switch)
|
|
14
|
-
market regime
|
|
16
|
+
market regime ... (log-SR ..., last change ...) · <regime date>
|
|
17
|
+
review tiers paused since 2026-11-03: tiers paused, research only; no grade, band or colour is shown and PDs are research only
|
|
15
18
|
|
|
16
|
-
INSTITUTION TYPE
|
|
17
|
-
❯
|
|
18
|
-
...
|
|
19
|
+
INSTITUTION TYPE SCORE PD 12M* Δ PD FUNDING
|
|
20
|
+
❯ ...
|
|
19
21
|
```
|
|
20
22
|
|
|
21
23
|
Two boards, one command:
|
|
22
24
|
|
|
23
|
-
- **IN**
|
|
25
|
+
- **IN** (Indian banks, SFBs, NBFCs and MFIs): score, 12/24/36-month
|
|
24
26
|
failure probabilities, funding bands, PCA status, forensics, market lens,
|
|
25
|
-
GDELT news watch.
|
|
26
|
-
|
|
27
|
+
GDELT news watch. Grades and row colours appear only while the API
|
|
28
|
+
publishes India review tiers; see "While India review tiers are paused".
|
|
29
|
+
- **US** (the riskiest tail of 1,000+ FDIC-scored banks, undertow engine):
|
|
27
30
|
within-quarter percentile score, noncurrent assets, uninsured/brokered
|
|
28
31
|
deposits, CRE concentration, NDFI-to-tier-1.
|
|
29
32
|
|
|
@@ -57,28 +60,54 @@ liquilens
|
|
|
57
60
|
- **Interactive TUI** (default in a terminal): live board, auto-refreshes
|
|
58
61
|
every 5 minutes, adapts to any terminal size (scrolling viewport on short
|
|
59
62
|
terminals, adaptive columns on narrow ones), `t` switches region.
|
|
60
|
-
- **`--plain`** (automatic when piped): one-shot ANSI-free table
|
|
63
|
+
- **`--plain`** (automatic when piped): one-shot ANSI-free table, safe for
|
|
61
64
|
scripts, cron mails, CI logs.
|
|
62
|
-
- **`--json`**: one-shot machine-readable dump
|
|
65
|
+
- **`--json`**: one-shot machine-readable dump of rows, regime and
|
|
66
|
+
`tier_publication`. India rows carry `risk_band` only while review tiers
|
|
67
|
+
are published; US rows always carry their rank band.
|
|
63
68
|
- **`--record`**: one-shot historical-evidence ledger for India, the US, and
|
|
64
69
|
Europe. It prints each market's construction/case-file status plus
|
|
65
70
|
`validated_backtest_eligible` and `real_money_eligible`; add `--json` to
|
|
66
71
|
preserve the served `/api/evidence/markets` payload exactly. It cannot be
|
|
67
72
|
combined with `--region` or `--fail-on`.
|
|
68
|
-
- **`--fail-on amber|red`**: alerting for cron/CI
|
|
69
|
-
institution is at/above the band
|
|
70
|
-
|
|
71
|
-
|
|
73
|
+
- **`--fail-on amber|red`**: alerting for cron/CI. Exits 3 when any Indian
|
|
74
|
+
institution is at/above the band, 0 when none is, and 4 when the API has
|
|
75
|
+
paused India review tiers (there is no band to compare, so the check is
|
|
76
|
+
not evaluated). India only: US scores are within-quarter percentile ranks,
|
|
77
|
+
a relative leaderboard, so an absolute threshold would always fire.
|
|
72
78
|
|
|
73
79
|
```bash
|
|
74
|
-
# cron: mail me the board
|
|
75
|
-
|
|
80
|
+
# cron: mail me the board when something turns red, and say so when the
|
|
81
|
+
# check could not run (4 = review tiers paused, 1 = no data)
|
|
82
|
+
liquilens --fail-on red > /tmp/board.txt
|
|
83
|
+
case $? in
|
|
84
|
+
0) ;;
|
|
85
|
+
3) mail -s "LiquiLens RED" me@x < /tmp/board.txt ;;
|
|
86
|
+
*) mail -s "LiquiLens check not evaluated" me@x < /tmp/board.txt ;;
|
|
87
|
+
esac
|
|
76
88
|
|
|
77
89
|
# audit the historical-evidence boundary without opening the web app
|
|
78
90
|
liquilens --record
|
|
79
91
|
liquilens --record --json | jq '.markets[] | {name, historical_evidence}'
|
|
80
92
|
```
|
|
81
93
|
|
|
94
|
+
## While India review tiers are paused
|
|
95
|
+
|
|
96
|
+
Since 2026-11-03 the API has paused India review tiers. The reason, in the
|
|
97
|
+
API's own words, is in the `tier_publication` object it serves. While the
|
|
98
|
+
pause holds:
|
|
99
|
+
|
|
100
|
+
- the board shows no grade, band or row colour, and the PD columns are
|
|
101
|
+
marked research only;
|
|
102
|
+
- `--json` rows carry no `risk_band`, and the top-level `tier_publication`
|
|
103
|
+
object states the pause;
|
|
104
|
+
- `--fail-on` exits 4 ("not evaluated") rather than 0 or 3. A paused board
|
|
105
|
+
is not a calm board, so the CLI never reports a pass it could not check.
|
|
106
|
+
|
|
107
|
+
The CLI reads this from `tier_publication.state` alone. Anything other than
|
|
108
|
+
`published`, including a missing field or an older cached board, is treated
|
|
109
|
+
as paused.
|
|
110
|
+
|
|
82
111
|
## Keys
|
|
83
112
|
|
|
84
113
|
| key | action |
|
|
@@ -97,15 +126,15 @@ liquilens --record --json | jq '.markets[] | {name, historical_evidence}'
|
|
|
97
126
|
- **Retries**: 3 attempts with backoff on network errors, 429s and 5xx.
|
|
98
127
|
- **Offline cache**: every good board is snapshotted per region (atomic write,
|
|
99
128
|
XDG cache dir; `%LOCALAPPDATA%` on Windows). If the API is unreachable you
|
|
100
|
-
get the cached board
|
|
129
|
+
get the cached board under an offline banner that states its age.
|
|
101
130
|
Exit 1 only when there is no data at all.
|
|
102
131
|
- **Networks**: IPv4-first DNS plus undici `autoSelectFamily` (fast Happy
|
|
103
|
-
Eyeballs)
|
|
132
|
+
Eyeballs), so it works on IPv6-blackholed *and* IPv6-only networks. `HTTPS_PROXY`
|
|
104
133
|
/ `HTTP_PROXY` / `NO_PROXY` are honored.
|
|
105
134
|
- **Partial failure**: if only the market-regime endpoint fails, the board
|
|
106
135
|
still renders with a "regime unavailable" note.
|
|
107
136
|
- **Tests + CI**: pure logic (columns, sorting, filtering, viewport, risk
|
|
108
|
-
bands, sparkline, US formatting, cache) is unit-tested (`npm test`);
|
|
137
|
+
bands, review-tier pause, sparkline, US formatting, cache) is unit-tested (`npm test`);
|
|
109
138
|
CI runs build + tests + live smokes on Node
|
|
110
139
|
18/20/22.
|
|
111
140
|
|
|
@@ -118,21 +147,22 @@ and machine details are never sent as analytics.
|
|
|
118
147
|
|
|
119
148
|
## Exit codes
|
|
120
149
|
|
|
121
|
-
0 ok · 1 no data (API down, no cache) · 2 bad usage · 3 `--fail-on` breached
|
|
150
|
+
0 ok · 1 no data (API down, no cache) · 2 bad usage · 3 `--fail-on` breached ·
|
|
151
|
+
4 `--fail-on` not evaluated (India review tiers paused)
|
|
122
152
|
|
|
123
153
|
## Config
|
|
124
154
|
|
|
125
|
-
- `--api <url>` or `LIQUILENS_API
|
|
155
|
+
- `--api <url>` or `LIQUILENS_API`: API host (default
|
|
126
156
|
`https://api.liquilens.in`), e.g. a local backend on `:8000`.
|
|
127
|
-
- `HTTPS_PROXY
|
|
157
|
+
- `HTTPS_PROXY`: standard CONNECT proxy, honored by all requests.
|
|
128
158
|
|
|
129
159
|
## Where things live
|
|
130
160
|
|
|
131
|
-
- `src/api.ts
|
|
132
|
-
- `src/cache.ts
|
|
133
|
-
- `src/format.ts
|
|
134
|
-
- `src/riskBands.ts
|
|
135
|
-
(domain judgment
|
|
161
|
+
- `src/api.ts`: typed fetchers, retry/backoff, proxy + Happy-Eyeballs dialing.
|
|
162
|
+
- `src/cache.ts`: per-region last-good-snapshot cache.
|
|
163
|
+
- `src/format.ts`: pure layout/sort/filter/viewport/sparkline logic (tested).
|
|
164
|
+
- `src/riskBands.ts`: the row-colour policies and the review-tier pause
|
|
165
|
+
check. India = absolute thresholds (domain judgment, tune here). US = rank-within-board (percentile scores
|
|
136
166
|
drift across quarters, ranks don't).
|
|
137
|
-
- `src/plain.ts
|
|
138
|
-
- `src/App.tsx
|
|
167
|
+
- `src/plain.ts`: `--plain` / `--json` renderers + `--fail-on` band logic.
|
|
168
|
+
- `src/App.tsx`: the Ink UI. `src/cli.tsx`: entry point + arg parsing.
|
package/dist/App.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Box, Text, useApp, useInput, useStdout } from "ink";
|
|
|
4
4
|
import { fetchBoard, fetchNews, fetchRegime, fetchUSBoard, } from "./api.js";
|
|
5
5
|
import { loadCached, saveCached, ageMinutes, describeAge, } from "./cache.js";
|
|
6
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";
|
|
7
|
-
import { riskBand, usRiskBandByRank, bandColor } from "./riskBands.js";
|
|
7
|
+
import { pausedLine, riskBand, tiersPublished, usRiskBandByRank, bandColor } from "./riskBands.js";
|
|
8
8
|
const ACCENT = "#9184d9"; // Nocturne
|
|
9
9
|
const DIM = "gray";
|
|
10
10
|
const REFRESH_MS = 5 * 60_000;
|
|
@@ -54,10 +54,11 @@ function Header({ region, regime, regimeError, usBoard, width, }) {
|
|
|
54
54
|
: "";
|
|
55
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] }));
|
|
56
56
|
}
|
|
57
|
-
function InRow({ row, selected, cols, }) {
|
|
58
|
-
|
|
57
|
+
function InRow({ row, selected, cols, showTiers, }) {
|
|
58
|
+
// Bands, grades and their colours only while the API publishes tiers.
|
|
59
|
+
const color = showTiers ? bandColor[riskBand(row)] : undefined;
|
|
59
60
|
const move = movement(row.movement.delta_pd_12m);
|
|
60
|
-
return (_jsxs(Box, { children: [_jsx(Text, { color: selected ? ACCENT : DIM, children: selected ? "❯ " : " " }), _jsx(Text, { color:
|
|
61
|
+
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(row.hazard.pd_12m), cols.pd) }), _jsx(Text, { color: moveColor(move.dir), children: cell(move.text, cols.move) }), _jsx(Text, { color: fundColor(row.funding.band), children: fundingLabel(row.funding.band) })] }));
|
|
61
62
|
}
|
|
62
63
|
function UsRow({ row, rank, selected, cols, }) {
|
|
63
64
|
const band = usRiskBandByRank(rank);
|
|
@@ -77,9 +78,9 @@ function NewsLine({ news }) {
|
|
|
77
78
|
: bandColor.green;
|
|
78
79
|
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)))] }));
|
|
79
80
|
}
|
|
80
|
-
function InDetail({ row, news, }) {
|
|
81
|
-
const
|
|
82
|
-
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:
|
|
81
|
+
function InDetail({ row, news, showTiers, }) {
|
|
82
|
+
const color = showTiers ? bandColor[riskBand(row)] : undefined;
|
|
83
|
+
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, " (", 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(row.hazard.pd_12m), " / ", pct(row.hazard.pd_24m), " /", " ", pct(row.hazard.pd_36m)] })] }), 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: [" \u2014 ", 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) })] })), _jsx(NewsLine, { news: news })] }));
|
|
83
84
|
}
|
|
84
85
|
function UsDetail({ row, rank }) {
|
|
85
86
|
const band = usRiskBandByRank(rank);
|
|
@@ -277,16 +278,18 @@ export default function App({ initialRegion = "in" }) {
|
|
|
277
278
|
const cols = useMemo(() => computeCols(width), [width]);
|
|
278
279
|
const usCols = useMemo(() => computeUSCols(width), [width]);
|
|
279
280
|
const hasData = region === "in" ? board !== null : usBoard !== null;
|
|
281
|
+
const showTiers = tiersPublished(board);
|
|
280
282
|
const regionStale = staleFrom[region];
|
|
281
283
|
const sortMode = region === "in" ? inSort : usSort;
|
|
282
|
-
const
|
|
284
|
+
const pausedNotice = region === "in" && board !== null && !showTiers ? 1 : 0;
|
|
285
|
+
const chrome = 7 + (showDetail ? 13 : 0) + (regionStale ? 1 : 0) + pausedNotice;
|
|
283
286
|
const visible = Math.max(3, height - chrome);
|
|
284
287
|
const vp = viewport(rowCount, visible, cursor);
|
|
285
|
-
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 \u2014 showing cached board from", " ", describeAge(ageMinutes(regionStale)), " (retrying every 5m, r to retry now)"] })), error && (_jsxs(Text, { color: bandColor.red, children: ["\u2716 ", error, " \u2014 press r to retry, or set LIQUILENS_API / HTTPS_PROXY"] })), loading && !hasData && _jsx(Text, { color: DIM, children: "\u283F loading live board\u2026" }), 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), 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"
|
|
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 \u2014 showing cached board from", " ", describeAge(ageMinutes(regionStale)), " (retrying every 5m, r to retry now)"] })), error && (_jsxs(Text, { color: bandColor.red, children: ["\u2716 ", error, " \u2014 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"
|
|
286
289
|
? inRows
|
|
287
290
|
.slice(vp.start, vp.end)
|
|
288
|
-
.map((row, i) => (_jsx(InRow, { row: row, selected: vp.start + i === cursor, cols: cols }, row.slug)))
|
|
291
|
+
.map((row, i) => (_jsx(InRow, { row: row, selected: vp.start + i === cursor, cols: cols, showTiers: showTiers }, row.slug)))
|
|
289
292
|
: usRows
|
|
290
293
|
.slice(vp.start, vp.end)
|
|
291
|
-
.map(({ row, rank }, i) => (_jsx(UsRow, { row: row, rank: rank, selected: vp.start + i === cursor, cols: usCols }, row.cert))), vp.below > 0 && _jsxs(Text, { color: DIM, children: [" ", "\u2193 ", vp.below, " more"] }), rowCount === 0 && (_jsxs(Text, { color: DIM, children: [" ", "no institutions match \"", query, "\""] })), showDetail && region === "in" && selectedIn && (_jsx(Box, { marginTop: 1, children: _jsx(InDetail, { row: selectedIn, news: news }) })), showDetail && region === "us" && usRows[cursor] && (_jsx(Box, { marginTop: 1, children: _jsx(UsDetail, { row: usRows[cursor].row, rank: usRows[cursor].rank }) }))] })), (filterMode || query) && (_jsxs(Text, { children: [_jsx(Text, { color: ACCENT, children: "/" }), _jsx(Text, { children: query }), filterMode && _jsx(Text, { color: ACCENT, children: "\u258F" }), _jsxs(Text, { color: DIM, children: [" ", "(", rowCount, " match", rowCount === 1 ? "" : "es", filterMode ? ", ⏎ keep · esc clear" : ", esc clear", ")"] })] })), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { color: DIM, wrap: "truncate", children: ["\u2191\u2193 select \u00B7 \u23CE detail \u00B7 t region \u00B7 s sort (", sortMode, ") \u00B7 / filter \u00B7 r refresh \u00B7 q quit", region === "in" && board ? ` · as of ${board.as_of}` : "", region === "us" && usBoard ? ` · quarter ${usBoard.as_of}` : "", " · liquilens.in", loading && hasData ? " · refreshing…" : ""] }) })] }));
|
|
294
|
+
.map(({ row, rank }, i) => (_jsx(UsRow, { row: row, rank: rank, selected: vp.start + i === cursor, cols: usCols }, row.cert))), vp.below > 0 && _jsxs(Text, { color: DIM, children: [" ", "\u2193 ", vp.below, " more"] }), rowCount === 0 && (_jsxs(Text, { color: DIM, children: [" ", "no institutions match \"", query, "\""] })), showDetail && region === "in" && selectedIn && (_jsx(Box, { marginTop: 1, children: _jsx(InDetail, { row: selectedIn, news: news, showTiers: showTiers }) })), showDetail && region === "us" && usRows[cursor] && (_jsx(Box, { marginTop: 1, children: _jsx(UsDetail, { row: usRows[cursor].row, rank: usRows[cursor].rank }) }))] })), (filterMode || query) && (_jsxs(Text, { children: [_jsx(Text, { color: ACCENT, children: "/" }), _jsx(Text, { children: query }), filterMode && _jsx(Text, { color: ACCENT, children: "\u258F" }), _jsxs(Text, { color: DIM, children: [" ", "(", rowCount, " match", rowCount === 1 ? "" : "es", filterMode ? ", ⏎ keep · esc clear" : ", esc clear", ")"] })] })), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { color: DIM, wrap: "truncate", children: ["\u2191\u2193 select \u00B7 \u23CE detail \u00B7 t region \u00B7 s sort (", sortMode, ") \u00B7 / filter \u00B7 r refresh \u00B7 q quit", region === "in" && board ? ` · as of ${board.as_of}` : "", region === "us" && usBoard ? ` · quarter ${usBoard.as_of}` : "", " · liquilens.in", loading && hasData ? " · refreshing…" : ""] }) })] }));
|
|
292
295
|
}
|
package/dist/cli.js
CHANGED
|
@@ -42,6 +42,8 @@ Options:
|
|
|
42
42
|
--fail-on <band> exit 3 if any institution is at/above band (amber|red).
|
|
43
43
|
India board only — the US board is a relative leaderboard.
|
|
44
44
|
Implies --plain unless --json is given. For cron/CI alerts.
|
|
45
|
+
While the API pauses India review tiers it exits 4
|
|
46
|
+
instead: there is no band to compare.
|
|
45
47
|
--api <url> API host (default ${DEFAULT_API}; env LIQUILENS_API)
|
|
46
48
|
-h, --help show this help
|
|
47
49
|
-v, --version show version
|
|
@@ -53,7 +55,8 @@ Environment:
|
|
|
53
55
|
Keys (interactive): ↑↓/jk select · ⏎ detail · t region · s sort · / filter ·
|
|
54
56
|
r refresh · q quit
|
|
55
57
|
Exit codes: 0 ok · 1 no data (API down and no cache) · 2 bad usage ·
|
|
56
|
-
3 --fail-on threshold breached
|
|
58
|
+
3 --fail-on threshold breached ·
|
|
59
|
+
4 --fail-on not evaluated: review tiers paused (research only)`;
|
|
57
60
|
function fail(msg, code) {
|
|
58
61
|
process.stderr.write(`liquilens: ${msg}\n`);
|
|
59
62
|
process.exit(code);
|
|
@@ -199,8 +202,17 @@ else {
|
|
|
199
202
|
? process.stdout.columns
|
|
200
203
|
: 110;
|
|
201
204
|
console.log(parsed.mode === "json" ? renderJson(snap) : renderPlain(snap, width));
|
|
202
|
-
if (parsed.failOn
|
|
203
|
-
|
|
204
|
-
|
|
205
|
+
if (parsed.failOn) {
|
|
206
|
+
const worst = worstBand(snap);
|
|
207
|
+
if (worst === null) {
|
|
208
|
+
// Never a silent pass: a paused board is not a calm board.
|
|
209
|
+
process.stderr.write(`liquilens: --fail-on ${parsed.failOn} not evaluated: India review tiers ` +
|
|
210
|
+
"are paused (research only), so there is no band to compare\n");
|
|
211
|
+
process.exit(4);
|
|
212
|
+
}
|
|
213
|
+
if (bandAtLeast(worst, parsed.failOn)) {
|
|
214
|
+
process.stderr.write(`liquilens: --fail-on ${parsed.failOn} breached\n`);
|
|
215
|
+
process.exit(3);
|
|
216
|
+
}
|
|
205
217
|
}
|
|
206
218
|
}
|
package/dist/plain.js
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { cell, computeCols, computeUSCols, fmtAssets, fundingLabel, movement, pct, pct1, rawPct, sortRows, sortUSRows, } from "./format.js";
|
|
2
|
-
import { riskBand, usRiskBandByRank } from "./riskBands.js";
|
|
2
|
+
import { pausedLine, riskBand, tiersPublished, usRiskBandByRank } from "./riskBands.js";
|
|
3
3
|
function staleLine(stale) {
|
|
4
4
|
return stale
|
|
5
5
|
? [`WARNING: live API unreachable — cached data from ${stale.description}`]
|
|
6
6
|
: [];
|
|
7
7
|
}
|
|
8
|
-
/** Worst risk band on the board
|
|
8
|
+
/** Worst risk band on the board, which drives --fail-on exit codes. Null for
|
|
9
|
+
* India while review tiers are paused: there is no band to compare. */
|
|
9
10
|
export function worstBand(snap) {
|
|
10
11
|
if (snap.region === "us") {
|
|
11
12
|
// US board is a relative leaderboard; callers must not use it for
|
|
12
13
|
// absolute alerting (enforced at arg-parse time).
|
|
13
14
|
return snap.board.board.length > 0 ? "red" : "green";
|
|
14
15
|
}
|
|
16
|
+
if (!tiersPublished(snap.board))
|
|
17
|
+
return null;
|
|
15
18
|
let worst = "green";
|
|
16
19
|
for (const row of snap.board.rows) {
|
|
17
20
|
const b = riskBand(row);
|
|
@@ -34,27 +37,32 @@ export function renderPlain(snap, width = 100) {
|
|
|
34
37
|
`last change ${snap.regime.trading_days_since_last_change}d ago) · ${snap.regime.as_of}`);
|
|
35
38
|
}
|
|
36
39
|
lines.push(...staleLine(snap.stale));
|
|
40
|
+
const published = tiersPublished(snap.board);
|
|
41
|
+
if (!published)
|
|
42
|
+
lines.push(pausedLine(snap.board));
|
|
37
43
|
lines.push("");
|
|
38
44
|
lines.push(" " +
|
|
39
45
|
cell("INSTITUTION", cols.name) +
|
|
40
46
|
cell("TYPE", cols.type) +
|
|
41
|
-
cell("GRADE", cols.grade) +
|
|
47
|
+
(published ? cell("GRADE", cols.grade) : "") +
|
|
42
48
|
cell("SCORE", cols.score) +
|
|
43
|
-
cell("PD 12M", cols.pd) +
|
|
49
|
+
cell(published ? "PD 12M" : "PD 12M*", cols.pd) +
|
|
44
50
|
cell("Δ PD", cols.move) +
|
|
45
|
-
"FUNDING BAND");
|
|
51
|
+
(published ? "FUNDING BAND" : "FUNDING"));
|
|
46
52
|
for (const row of sortRows(snap.board.rows, "risk")) {
|
|
47
|
-
const band = riskBand(row);
|
|
48
53
|
lines.push(" " +
|
|
49
54
|
cell(row.name, cols.name) +
|
|
50
55
|
cell(row.inst_type, cols.type) +
|
|
51
|
-
cell(row.grade, cols.grade) +
|
|
56
|
+
(published ? cell(row.grade ?? "", cols.grade) : "") +
|
|
52
57
|
cell(String(row.score), cols.score) +
|
|
53
58
|
cell(pct(row.hazard.pd_12m), cols.pd) +
|
|
54
59
|
cell(movement(row.movement.delta_pd_12m).text, cols.move) +
|
|
55
|
-
|
|
56
|
-
|
|
60
|
+
(published
|
|
61
|
+
? cell(fundingLabel(row.funding.band), 9) + riskBand(row).toUpperCase()
|
|
62
|
+
: fundingLabel(row.funding.band)));
|
|
57
63
|
}
|
|
64
|
+
if (!published)
|
|
65
|
+
lines.push("* research only while review tiers are paused");
|
|
58
66
|
lines.push("");
|
|
59
67
|
lines.push(`${snap.board.rows.length} institutions · liquilens.in`);
|
|
60
68
|
return lines.join("\n");
|
|
@@ -92,6 +100,11 @@ function renderPlainUS(snap, width) {
|
|
|
92
100
|
lines.push("score = within-quarter percentile rank (relative leaderboard, not a PD) · liquilens.in");
|
|
93
101
|
return lines.join("\n");
|
|
94
102
|
}
|
|
103
|
+
/** A row as research only: no grade letter even from an older cached board. */
|
|
104
|
+
function researchRow(r) {
|
|
105
|
+
const withoutGrade = (o) => Object.fromEntries(Object.entries(o).filter(([k]) => k !== "grade" && k !== "tier"));
|
|
106
|
+
return { ...withoutGrade(r), hazard: withoutGrade(r.hazard), pd_research_only: true };
|
|
107
|
+
}
|
|
95
108
|
/** Machine-readable dump for `--json`. */
|
|
96
109
|
export function renderJson(snap) {
|
|
97
110
|
if (snap.region === "us") {
|
|
@@ -105,15 +118,14 @@ export function renderJson(snap) {
|
|
|
105
118
|
rows: rows.map((r, i) => ({ ...r, risk_band: usRiskBandByRank(i) })),
|
|
106
119
|
}, null, 2);
|
|
107
120
|
}
|
|
121
|
+
const published = tiersPublished(snap.board);
|
|
108
122
|
return JSON.stringify({
|
|
109
123
|
region: "in",
|
|
110
124
|
as_of: snap.board.as_of,
|
|
111
125
|
stale: snap.stale ? { cached_at: snap.stale.savedAt } : null,
|
|
112
126
|
market_regime: snap.regime,
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
risk_band: riskBand(r),
|
|
116
|
-
})),
|
|
127
|
+
tier_publication: snap.board.tier_publication ?? null,
|
|
128
|
+
rows: sortRows(snap.board.rows, "risk").map((r) => published ? { ...r, risk_band: riskBand(r) } : researchRow(r)),
|
|
117
129
|
}, null, 2);
|
|
118
130
|
}
|
|
119
131
|
function evidenceFlag(value) {
|
package/dist/riskBands.js
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* India risk bands, grade letters and their colours are shown only while the
|
|
3
|
+
* API says review tiers are published. A paused state, or an older payload
|
|
4
|
+
* that does not say, renders research-only probabilities instead.
|
|
5
|
+
*/
|
|
6
|
+
export function tiersPublished(board) {
|
|
7
|
+
return board?.tier_publication?.state === "published";
|
|
8
|
+
}
|
|
9
|
+
/** One line stating the pause, in the API's own words when it sends them. */
|
|
10
|
+
export function pausedLine(board) {
|
|
11
|
+
const pub = board?.tier_publication;
|
|
12
|
+
const since = pub?.since ? ` since ${pub.since}` : "";
|
|
13
|
+
return `review tiers paused${since}: ${pub?.label ?? "tiers paused, research only"}; ` +
|
|
14
|
+
"no grade, band or colour is shown and PDs are research only";
|
|
15
|
+
}
|
|
1
16
|
/**
|
|
2
17
|
* Maps a board row to the colour band used for the whole row in the terminal.
|
|
3
18
|
*
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "liquilens",
|
|
3
|
-
"version": "0.5.
|
|
4
|
-
"description": "LiquiLens Failure Radar in your terminal
|
|
3
|
+
"version": "0.5.2",
|
|
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/",
|
|
7
7
|
"repository": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "tsc",
|
|
38
38
|
"dev": "tsc && node dist/cli.js",
|
|
39
|
-
"test": "tsc && node --test dist/cache.test.js dist/format.test.js dist/record.test.js dist/riskBands.test.js dist/us.test.js",
|
|
39
|
+
"test": "tsc && node --test dist/cache.test.js dist/format.test.js dist/paused.test.js dist/record.test.js dist/riskBands.test.js dist/us.test.js",
|
|
40
40
|
"prepare": "tsc"
|
|
41
41
|
},
|
|
42
42
|
"publishConfig": {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"ink": "^5.2.0",
|
|
51
51
|
"react": "^18.3.1",
|
|
52
|
-
"undici": "^6.
|
|
52
|
+
"undici": "^6.29.1"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/node": "^22.10.0",
|