@spfunctions/cli 1.7.19 → 1.7.20
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/dist/101.index.js +1 -0
- package/dist/12.index.js +1 -0
- package/dist/160.index.js +1 -0
- package/dist/174.index.js +1 -0
- package/dist/278.index.js +6 -0
- package/dist/582.index.js +1 -0
- package/dist/641.index.js +324 -0
- package/dist/669.index.js +1 -0
- package/dist/722.index.js +1 -0
- package/dist/788.index.js +1 -0
- package/dist/816.index.js +12 -0
- package/dist/830.index.js +1 -0
- package/dist/921.index.js +1 -0
- package/dist/index.js +1 -833
- package/package.json +5 -2
- package/dist/cache.d.ts +0 -6
- package/dist/cache.js +0 -31
- package/dist/cache.test.d.ts +0 -1
- package/dist/cache.test.js +0 -73
- package/dist/client.d.ts +0 -56
- package/dist/client.js +0 -205
- package/dist/client.test.d.ts +0 -1
- package/dist/client.test.js +0 -89
- package/dist/commands/agent.d.ts +0 -20
- package/dist/commands/agent.js +0 -4119
- package/dist/commands/announcements.d.ts +0 -3
- package/dist/commands/announcements.js +0 -28
- package/dist/commands/augment.d.ts +0 -12
- package/dist/commands/augment.js +0 -56
- package/dist/commands/balance.d.ts +0 -3
- package/dist/commands/balance.js +0 -17
- package/dist/commands/book.d.ts +0 -17
- package/dist/commands/book.js +0 -220
- package/dist/commands/cancel.d.ts +0 -5
- package/dist/commands/cancel.js +0 -41
- package/dist/commands/context.d.ts +0 -6
- package/dist/commands/context.js +0 -208
- package/dist/commands/create.d.ts +0 -7
- package/dist/commands/create.js +0 -42
- package/dist/commands/dashboard.d.ts +0 -14
- package/dist/commands/dashboard.js +0 -215
- package/dist/commands/delta.d.ts +0 -16
- package/dist/commands/delta.js +0 -115
- package/dist/commands/edges.d.ts +0 -26
- package/dist/commands/edges.js +0 -246
- package/dist/commands/evaluate.d.ts +0 -4
- package/dist/commands/evaluate.js +0 -30
- package/dist/commands/explore.d.ts +0 -14
- package/dist/commands/explore.js +0 -116
- package/dist/commands/feed.d.ts +0 -13
- package/dist/commands/feed.js +0 -73
- package/dist/commands/fills.d.ts +0 -4
- package/dist/commands/fills.js +0 -29
- package/dist/commands/forecast.d.ts +0 -4
- package/dist/commands/forecast.js +0 -53
- package/dist/commands/get.d.ts +0 -5
- package/dist/commands/get.js +0 -98
- package/dist/commands/heartbeat.d.ts +0 -20
- package/dist/commands/heartbeat.js +0 -73
- package/dist/commands/history.d.ts +0 -3
- package/dist/commands/history.js +0 -38
- package/dist/commands/liquidity.d.ts +0 -14
- package/dist/commands/liquidity.js +0 -378
- package/dist/commands/list.d.ts +0 -5
- package/dist/commands/list.js +0 -38
- package/dist/commands/login.d.ts +0 -10
- package/dist/commands/login.js +0 -98
- package/dist/commands/markets.d.ts +0 -10
- package/dist/commands/markets.js +0 -39
- package/dist/commands/milestones.d.ts +0 -8
- package/dist/commands/milestones.js +0 -56
- package/dist/commands/orders.d.ts +0 -4
- package/dist/commands/orders.js +0 -28
- package/dist/commands/performance.d.ts +0 -11
- package/dist/commands/performance.js +0 -250
- package/dist/commands/positions.d.ts +0 -19
- package/dist/commands/positions.js +0 -294
- package/dist/commands/prompt.d.ts +0 -13
- package/dist/commands/prompt.js +0 -35
- package/dist/commands/publish.d.ts +0 -15
- package/dist/commands/publish.js +0 -39
- package/dist/commands/query.d.ts +0 -15
- package/dist/commands/query.js +0 -132
- package/dist/commands/rfq.d.ts +0 -5
- package/dist/commands/rfq.js +0 -35
- package/dist/commands/scan.d.ts +0 -11
- package/dist/commands/scan.js +0 -230
- package/dist/commands/schedule.d.ts +0 -3
- package/dist/commands/schedule.js +0 -38
- package/dist/commands/settlements.d.ts +0 -6
- package/dist/commands/settlements.js +0 -50
- package/dist/commands/setup.d.ts +0 -24
- package/dist/commands/setup.js +0 -700
- package/dist/commands/signal.d.ts +0 -6
- package/dist/commands/signal.js +0 -32
- package/dist/commands/strategies.d.ts +0 -11
- package/dist/commands/strategies.js +0 -130
- package/dist/commands/telegram.d.ts +0 -15
- package/dist/commands/telegram.js +0 -125
- package/dist/commands/trade.d.ts +0 -12
- package/dist/commands/trade.js +0 -112
- package/dist/commands/watch.d.ts +0 -19
- package/dist/commands/watch.js +0 -157
- package/dist/commands/whatif.d.ts +0 -17
- package/dist/commands/whatif.js +0 -209
- package/dist/commands/x.d.ts +0 -28
- package/dist/commands/x.js +0 -167
- package/dist/config.d.ts +0 -55
- package/dist/config.js +0 -139
- package/dist/config.test.d.ts +0 -1
- package/dist/config.test.js +0 -138
- package/dist/index.d.ts +0 -20
- package/dist/kalshi.d.ts +0 -144
- package/dist/kalshi.js +0 -498
- package/dist/polymarket.d.ts +0 -237
- package/dist/polymarket.js +0 -353
- package/dist/polymarket.test.d.ts +0 -1
- package/dist/polymarket.test.js +0 -424
- package/dist/share.d.ts +0 -4
- package/dist/share.js +0 -27
- package/dist/skills/loader.d.ts +0 -19
- package/dist/skills/loader.js +0 -86
- package/dist/telegram/agent-bridge.d.ts +0 -15
- package/dist/telegram/agent-bridge.js +0 -573
- package/dist/telegram/bot.d.ts +0 -10
- package/dist/telegram/bot.js +0 -297
- package/dist/telegram/commands.d.ts +0 -11
- package/dist/telegram/commands.js +0 -120
- package/dist/telegram/format.d.ts +0 -11
- package/dist/telegram/format.js +0 -51
- package/dist/telegram/format.test.d.ts +0 -1
- package/dist/telegram/format.test.js +0 -73
- package/dist/telegram/poller.d.ts +0 -6
- package/dist/telegram/poller.js +0 -32
- package/dist/topics.d.ts +0 -17
- package/dist/topics.js +0 -102
- package/dist/topics.test.d.ts +0 -1
- package/dist/topics.test.js +0 -131
- package/dist/tui/border.d.ts +0 -33
- package/dist/tui/border.js +0 -87
- package/dist/tui/chart.d.ts +0 -19
- package/dist/tui/chart.js +0 -117
- package/dist/tui/dashboard.d.ts +0 -9
- package/dist/tui/dashboard.js +0 -814
- package/dist/tui/layout.d.ts +0 -16
- package/dist/tui/layout.js +0 -41
- package/dist/tui/screen.d.ts +0 -33
- package/dist/tui/screen.js +0 -102
- package/dist/tui/state.d.ts +0 -40
- package/dist/tui/state.js +0 -36
- package/dist/tui/widgets/commandbar.d.ts +0 -8
- package/dist/tui/widgets/commandbar.js +0 -82
- package/dist/tui/widgets/detail.d.ts +0 -9
- package/dist/tui/widgets/detail.js +0 -151
- package/dist/tui/widgets/edges.d.ts +0 -4
- package/dist/tui/widgets/edges.js +0 -34
- package/dist/tui/widgets/liquidity.d.ts +0 -9
- package/dist/tui/widgets/liquidity.js +0 -142
- package/dist/tui/widgets/orders.d.ts +0 -4
- package/dist/tui/widgets/orders.js +0 -37
- package/dist/tui/widgets/portfolio.d.ts +0 -4
- package/dist/tui/widgets/portfolio.js +0 -59
- package/dist/tui/widgets/signals.d.ts +0 -4
- package/dist/tui/widgets/signals.js +0 -31
- package/dist/tui/widgets/statusbar.d.ts +0 -8
- package/dist/tui/widgets/statusbar.js +0 -72
- package/dist/tui/widgets/thesis.d.ts +0 -4
- package/dist/tui/widgets/thesis.js +0 -66
- package/dist/tui/widgets/trade.d.ts +0 -9
- package/dist/tui/widgets/trade.js +0 -117
- package/dist/tui/widgets/upcoming.d.ts +0 -4
- package/dist/tui/widgets/upcoming.js +0 -41
- package/dist/tui/widgets/whatif.d.ts +0 -7
- package/dist/tui/widgets/whatif.js +0 -113
- package/dist/types/output.d.ts +0 -412
- package/dist/types/output.js +0 -9
- package/dist/utils.d.ts +0 -52
- package/dist/utils.js +0 -146
- package/dist/utils.test.d.ts +0 -1
- package/dist/utils.test.js +0 -111
package/dist/tui/layout.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Layout Engine — divide terminal into named regions
|
|
3
|
-
*/
|
|
4
|
-
export interface Region {
|
|
5
|
-
name: string;
|
|
6
|
-
row: number;
|
|
7
|
-
col: number;
|
|
8
|
-
width: number;
|
|
9
|
-
height: number;
|
|
10
|
-
}
|
|
11
|
-
/** Compute OVERVIEW layout (6 panels + status bars) */
|
|
12
|
-
export declare function overviewLayout(cols: number, rows: number): Region[];
|
|
13
|
-
/** Full-screen region (for DETAIL, LIQUIDITY, WHATIF modes) */
|
|
14
|
-
export declare function fullLayout(cols: number, rows: number): Region;
|
|
15
|
-
/** Narrow layout for terminals < 80 cols (single column) */
|
|
16
|
-
export declare function narrowLayout(cols: number, rows: number): Region[];
|
package/dist/tui/layout.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Layout Engine — divide terminal into named regions
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.overviewLayout = overviewLayout;
|
|
7
|
-
exports.fullLayout = fullLayout;
|
|
8
|
-
exports.narrowLayout = narrowLayout;
|
|
9
|
-
/** Compute OVERVIEW layout (6 panels + status bars) */
|
|
10
|
-
function overviewLayout(cols, rows) {
|
|
11
|
-
const contentRows = rows - 2; // -1 status bar, -1 command bar
|
|
12
|
-
const leftWidth = Math.floor(cols * 0.55);
|
|
13
|
-
const rightWidth = cols - leftWidth - 1; // -1 for vertical divider
|
|
14
|
-
const rightCol = leftWidth + 1;
|
|
15
|
-
// Vertical split: 45% top, 25% mid, 30% bottom
|
|
16
|
-
const topH = Math.max(Math.floor(contentRows * 0.45), 6);
|
|
17
|
-
const midH = Math.max(Math.floor(contentRows * 0.25), 4);
|
|
18
|
-
const botH = Math.max(contentRows - topH - midH, 3);
|
|
19
|
-
return [
|
|
20
|
-
{ name: 'positions', row: 1, col: 0, width: leftWidth, height: topH },
|
|
21
|
-
{ name: 'thesis', row: 1, col: rightCol, width: rightWidth, height: topH },
|
|
22
|
-
{ name: 'edges', row: 1 + topH, col: 0, width: leftWidth, height: midH },
|
|
23
|
-
{ name: 'upcoming', row: 1 + topH, col: rightCol, width: rightWidth, height: midH },
|
|
24
|
-
{ name: 'orders', row: 1 + topH + midH, col: 0, width: leftWidth, height: botH },
|
|
25
|
-
{ name: 'signals', row: 1 + topH + midH, col: rightCol, width: rightWidth, height: botH },
|
|
26
|
-
];
|
|
27
|
-
}
|
|
28
|
-
/** Full-screen region (for DETAIL, LIQUIDITY, WHATIF modes) */
|
|
29
|
-
function fullLayout(cols, rows) {
|
|
30
|
-
return { name: 'main', row: 1, col: 0, width: cols, height: rows - 2 };
|
|
31
|
-
}
|
|
32
|
-
/** Narrow layout for terminals < 80 cols (single column) */
|
|
33
|
-
function narrowLayout(cols, rows) {
|
|
34
|
-
const contentRows = rows - 2;
|
|
35
|
-
const h = Math.floor(contentRows / 3);
|
|
36
|
-
return [
|
|
37
|
-
{ name: 'positions', row: 1, col: 0, width: cols, height: h },
|
|
38
|
-
{ name: 'edges', row: 1 + h, col: 0, width: cols, height: h },
|
|
39
|
-
{ name: 'thesis', row: 1 + 2 * h, col: 0, width: cols, height: contentRows - 2 * h },
|
|
40
|
-
];
|
|
41
|
-
}
|
package/dist/tui/screen.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ScreenBuffer — Double-buffered terminal renderer
|
|
3
|
-
*
|
|
4
|
-
* Only writes changed cells to stdout (no flickering).
|
|
5
|
-
* This is how Bloomberg terminals stay "alive" without blinking.
|
|
6
|
-
*/
|
|
7
|
-
export interface Cell {
|
|
8
|
-
char: string;
|
|
9
|
-
fg: string;
|
|
10
|
-
bg: string;
|
|
11
|
-
}
|
|
12
|
-
export declare class ScreenBuffer {
|
|
13
|
-
private front;
|
|
14
|
-
private back;
|
|
15
|
-
cols: number;
|
|
16
|
-
rows: number;
|
|
17
|
-
constructor();
|
|
18
|
-
private createBuffer;
|
|
19
|
-
/** Write a plain string at position. Strips ANSI codes for positioning. */
|
|
20
|
-
write(row: number, col: number, text: string, fg?: string, bg?: string): void;
|
|
21
|
-
/** Write styled text — supports inline ANSI codes (parses them for fg tracking) */
|
|
22
|
-
writeStyled(row: number, col: number, segments: Array<{
|
|
23
|
-
text: string;
|
|
24
|
-
fg?: string;
|
|
25
|
-
bg?: string;
|
|
26
|
-
}>): void;
|
|
27
|
-
/** Fill a rectangular region with a character */
|
|
28
|
-
fill(row: number, col: number, width: number, height: number, char?: string, fg?: string, bg?: string): void;
|
|
29
|
-
/** Diff front vs back, output only changed cells */
|
|
30
|
-
flush(): void;
|
|
31
|
-
/** Handle terminal resize */
|
|
32
|
-
resize(): void;
|
|
33
|
-
}
|
package/dist/tui/screen.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* ScreenBuffer — Double-buffered terminal renderer
|
|
4
|
-
*
|
|
5
|
-
* Only writes changed cells to stdout (no flickering).
|
|
6
|
-
* This is how Bloomberg terminals stay "alive" without blinking.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.ScreenBuffer = void 0;
|
|
10
|
-
class ScreenBuffer {
|
|
11
|
-
front;
|
|
12
|
-
back;
|
|
13
|
-
cols;
|
|
14
|
-
rows;
|
|
15
|
-
constructor() {
|
|
16
|
-
this.cols = process.stdout.columns || 120;
|
|
17
|
-
this.rows = process.stdout.rows || 40;
|
|
18
|
-
this.front = this.createBuffer();
|
|
19
|
-
this.back = this.createBuffer();
|
|
20
|
-
}
|
|
21
|
-
createBuffer() {
|
|
22
|
-
return Array.from({ length: this.rows }, () => Array.from({ length: this.cols }, () => ({ char: ' ', fg: '', bg: '' })));
|
|
23
|
-
}
|
|
24
|
-
/** Write a plain string at position. Strips ANSI codes for positioning. */
|
|
25
|
-
write(row, col, text, fg = '', bg = '') {
|
|
26
|
-
if (row < 0 || row >= this.rows)
|
|
27
|
-
return;
|
|
28
|
-
let pos = col;
|
|
29
|
-
for (let i = 0; i < text.length && pos < this.cols; i++) {
|
|
30
|
-
if (pos >= 0) {
|
|
31
|
-
this.back[row][pos] = { char: text[i], fg, bg };
|
|
32
|
-
}
|
|
33
|
-
pos++;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
/** Write styled text — supports inline ANSI codes (parses them for fg tracking) */
|
|
37
|
-
writeStyled(row, col, segments) {
|
|
38
|
-
let pos = col;
|
|
39
|
-
for (const seg of segments) {
|
|
40
|
-
for (let i = 0; i < seg.text.length && pos < this.cols; i++) {
|
|
41
|
-
if (row >= 0 && row < this.rows && pos >= 0) {
|
|
42
|
-
this.back[row][pos] = { char: seg.text[i], fg: seg.fg || '', bg: seg.bg || '' };
|
|
43
|
-
}
|
|
44
|
-
pos++;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
/** Fill a rectangular region with a character */
|
|
49
|
-
fill(row, col, width, height, char = ' ', fg = '', bg = '') {
|
|
50
|
-
for (let r = row; r < row + height && r < this.rows; r++) {
|
|
51
|
-
for (let c = col; c < col + width && c < this.cols; c++) {
|
|
52
|
-
if (r >= 0 && c >= 0) {
|
|
53
|
-
this.back[r][c] = { char, fg, bg };
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
/** Diff front vs back, output only changed cells */
|
|
59
|
-
flush() {
|
|
60
|
-
let output = '';
|
|
61
|
-
let lastFg = '';
|
|
62
|
-
let lastBg = '';
|
|
63
|
-
for (let r = 0; r < this.rows; r++) {
|
|
64
|
-
for (let c = 0; c < this.cols; c++) {
|
|
65
|
-
const f = this.front[r][c];
|
|
66
|
-
const b = this.back[r][c];
|
|
67
|
-
if (f.char !== b.char || f.fg !== b.fg || f.bg !== b.bg) {
|
|
68
|
-
// Move cursor
|
|
69
|
-
output += `\x1b[${r + 1};${c + 1}H`;
|
|
70
|
-
// Set colors if changed
|
|
71
|
-
if (b.fg !== lastFg || b.bg !== lastBg) {
|
|
72
|
-
output += '\x1b[0m';
|
|
73
|
-
if (b.fg)
|
|
74
|
-
output += b.fg;
|
|
75
|
-
if (b.bg)
|
|
76
|
-
output += b.bg;
|
|
77
|
-
lastFg = b.fg;
|
|
78
|
-
lastBg = b.bg;
|
|
79
|
-
}
|
|
80
|
-
output += b.char;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
if (output) {
|
|
85
|
-
output += '\x1b[0m'; // reset at end
|
|
86
|
-
process.stdout.write(output);
|
|
87
|
-
}
|
|
88
|
-
// Swap: back becomes front, create fresh back
|
|
89
|
-
this.front = this.back;
|
|
90
|
-
this.back = this.createBuffer();
|
|
91
|
-
}
|
|
92
|
-
/** Handle terminal resize */
|
|
93
|
-
resize() {
|
|
94
|
-
this.cols = process.stdout.columns || 120;
|
|
95
|
-
this.rows = process.stdout.rows || 40;
|
|
96
|
-
this.front = this.createBuffer();
|
|
97
|
-
this.back = this.createBuffer();
|
|
98
|
-
// Force full redraw
|
|
99
|
-
process.stdout.write('\x1b[2J');
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
exports.ScreenBuffer = ScreenBuffer;
|
package/dist/tui/state.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dashboard state — single source of truth
|
|
3
|
-
*/
|
|
4
|
-
export type Mode = 'overview' | 'detail' | 'liquidity' | 'whatif' | 'trade';
|
|
5
|
-
export type FocusArea = 'positions' | 'edges';
|
|
6
|
-
export interface DashboardState {
|
|
7
|
-
mode: Mode;
|
|
8
|
-
prevMode: Mode;
|
|
9
|
-
selectedIndex: number;
|
|
10
|
-
focusArea: FocusArea;
|
|
11
|
-
detailTicker: string | null;
|
|
12
|
-
liquidityTopic: string;
|
|
13
|
-
liquiditySelectedIndex: number;
|
|
14
|
-
whatifScenarioIndex: number;
|
|
15
|
-
whatifResult: any | null;
|
|
16
|
-
whatifThesisId: string | null;
|
|
17
|
-
tradeParams: {
|
|
18
|
-
ticker: string;
|
|
19
|
-
side: string;
|
|
20
|
-
action: string;
|
|
21
|
-
qty: number;
|
|
22
|
-
price: number;
|
|
23
|
-
} | null;
|
|
24
|
-
tradeCountdown: number;
|
|
25
|
-
tradeField: 'qty' | 'price';
|
|
26
|
-
positions: any[];
|
|
27
|
-
theses: any[];
|
|
28
|
-
contexts: Map<string, any>;
|
|
29
|
-
edges: any[];
|
|
30
|
-
orders: any[];
|
|
31
|
-
signals: any[];
|
|
32
|
-
events: any[];
|
|
33
|
-
balance: number;
|
|
34
|
-
candleCache: Map<string, any[]>;
|
|
35
|
-
liquidityData: Map<string, any[]>;
|
|
36
|
-
error: string | null;
|
|
37
|
-
lastRefresh: Record<string, number>;
|
|
38
|
-
exchangeOpen: boolean | null;
|
|
39
|
-
}
|
|
40
|
-
export declare function initialState(): DashboardState;
|
package/dist/tui/state.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Dashboard state — single source of truth
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.initialState = initialState;
|
|
7
|
-
function initialState() {
|
|
8
|
-
return {
|
|
9
|
-
mode: 'overview',
|
|
10
|
-
prevMode: 'overview',
|
|
11
|
-
selectedIndex: 0,
|
|
12
|
-
focusArea: 'positions',
|
|
13
|
-
detailTicker: null,
|
|
14
|
-
liquidityTopic: 'oil',
|
|
15
|
-
liquiditySelectedIndex: 0,
|
|
16
|
-
whatifScenarioIndex: 0,
|
|
17
|
-
whatifResult: null,
|
|
18
|
-
whatifThesisId: null,
|
|
19
|
-
tradeParams: null,
|
|
20
|
-
tradeCountdown: -1,
|
|
21
|
-
tradeField: 'qty',
|
|
22
|
-
positions: [],
|
|
23
|
-
theses: [],
|
|
24
|
-
contexts: new Map(),
|
|
25
|
-
edges: [],
|
|
26
|
-
orders: [],
|
|
27
|
-
signals: [],
|
|
28
|
-
events: [],
|
|
29
|
-
balance: 0,
|
|
30
|
-
candleCache: new Map(),
|
|
31
|
-
liquidityData: new Map(),
|
|
32
|
-
error: null,
|
|
33
|
-
lastRefresh: {},
|
|
34
|
-
exchangeOpen: null,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Command bar — bottom row of the dashboard
|
|
3
|
-
*
|
|
4
|
-
* Context-sensitive key hints that change based on current mode.
|
|
5
|
-
*/
|
|
6
|
-
import type { ScreenBuffer } from '../screen.js';
|
|
7
|
-
import type { DashboardState } from '../state.js';
|
|
8
|
-
export declare function renderCommandBar(screen: ScreenBuffer, row: number, state: DashboardState): void;
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Command bar — bottom row of the dashboard
|
|
4
|
-
*
|
|
5
|
-
* Context-sensitive key hints that change based on current mode.
|
|
6
|
-
*/
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.renderCommandBar = renderCommandBar;
|
|
9
|
-
const border_js_1 = require("../border.js");
|
|
10
|
-
const CMD_BG = (0, border_js_1.bgRgb)(22, 22, 26);
|
|
11
|
-
const HINTS = {
|
|
12
|
-
overview: [
|
|
13
|
-
{ key: 'j/k', label: 'nav' },
|
|
14
|
-
{ key: 'Enter', label: 'detail' },
|
|
15
|
-
{ key: 'Tab', label: 'focus' },
|
|
16
|
-
{ key: 'l', label: 'liquidity' },
|
|
17
|
-
{ key: 'w', label: 'whatif' },
|
|
18
|
-
{ key: 'b', label: 'buy' },
|
|
19
|
-
{ key: 's', label: 'sell' },
|
|
20
|
-
{ key: 'e', label: 'evaluate' },
|
|
21
|
-
{ key: 'r', label: 'refresh' },
|
|
22
|
-
{ key: 'q', label: 'quit' },
|
|
23
|
-
],
|
|
24
|
-
detail: [
|
|
25
|
-
{ key: 'b', label: 'buy' },
|
|
26
|
-
{ key: 's', label: 'sell' },
|
|
27
|
-
{ key: 'w', label: 'whatif' },
|
|
28
|
-
{ key: 'Esc', label: 'back' },
|
|
29
|
-
{ key: 'q', label: 'quit' },
|
|
30
|
-
],
|
|
31
|
-
liquidity: [
|
|
32
|
-
{ key: 'j/k', label: 'nav' },
|
|
33
|
-
{ key: 'Tab', label: 'topic' },
|
|
34
|
-
{ key: 'b', label: 'buy' },
|
|
35
|
-
{ key: 'r', label: 'refresh' },
|
|
36
|
-
{ key: 'Esc', label: 'back' },
|
|
37
|
-
{ key: 'q', label: 'quit' },
|
|
38
|
-
],
|
|
39
|
-
whatif: [
|
|
40
|
-
{ key: 'j/k', label: 'nav' },
|
|
41
|
-
{ key: 'Enter', label: 'apply' },
|
|
42
|
-
{ key: 'Esc', label: 'back' },
|
|
43
|
-
{ key: 'q', label: 'quit' },
|
|
44
|
-
],
|
|
45
|
-
trade: [
|
|
46
|
-
{ key: '\u2191\u2193', label: 'adjust' },
|
|
47
|
-
{ key: 'Tab', label: 'field' },
|
|
48
|
-
{ key: 'Enter', label: 'confirm' },
|
|
49
|
-
{ key: 'Esc', label: 'cancel' },
|
|
50
|
-
],
|
|
51
|
-
};
|
|
52
|
-
function renderCommandBar(screen, row, state) {
|
|
53
|
-
const w = screen.cols;
|
|
54
|
-
// Fill background
|
|
55
|
-
screen.fill(row, 0, w, 1, ' ', '', CMD_BG);
|
|
56
|
-
const hints = HINTS[state.mode] || HINTS.overview;
|
|
57
|
-
let col = 1;
|
|
58
|
-
for (const hint of hints) {
|
|
59
|
-
if (col + hint.key.length + hint.label.length + 4 > w)
|
|
60
|
-
break;
|
|
61
|
-
// Key in white/emerald, label in dim
|
|
62
|
-
screen.write(row, col, hint.key, border_js_1.CLR.emerald, CMD_BG);
|
|
63
|
-
col += hint.key.length;
|
|
64
|
-
screen.write(row, col, ' ', border_js_1.CLR.dim, CMD_BG);
|
|
65
|
-
col++;
|
|
66
|
-
screen.write(row, col, hint.label, border_js_1.CLR.dim, CMD_BG);
|
|
67
|
-
col += hint.label.length;
|
|
68
|
-
// Separator
|
|
69
|
-
col += 2;
|
|
70
|
-
if (col < w - 2) {
|
|
71
|
-
screen.write(row, col - 1, '│', border_js_1.CLR.veryDim, CMD_BG);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
// Error display on the right
|
|
75
|
-
if (state.error) {
|
|
76
|
-
const errStr = state.error.slice(0, 30);
|
|
77
|
-
const errCol = w - errStr.length - 2;
|
|
78
|
-
if (errCol > col) {
|
|
79
|
-
screen.write(row, errCol, errStr, border_js_1.CLR.red, CMD_BG);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Detail view — full-screen position deep-dive
|
|
3
|
-
*
|
|
4
|
-
* Shows position summary, P&L chart, causal tree nodes, and orderbook snapshot.
|
|
5
|
-
*/
|
|
6
|
-
import type { ScreenBuffer } from '../screen.js';
|
|
7
|
-
import type { Region } from '../layout.js';
|
|
8
|
-
import type { DashboardState } from '../state.js';
|
|
9
|
-
export declare function renderDetail(screen: ScreenBuffer, region: Region, state: DashboardState): void;
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Detail view — full-screen position deep-dive
|
|
4
|
-
*
|
|
5
|
-
* Shows position summary, P&L chart, causal tree nodes, and orderbook snapshot.
|
|
6
|
-
*/
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.renderDetail = renderDetail;
|
|
9
|
-
const border_js_1 = require("../border.js");
|
|
10
|
-
const chart_js_1 = require("../chart.js");
|
|
11
|
-
function renderDetail(screen, region, state) {
|
|
12
|
-
(0, border_js_1.drawBorder)(screen, region, 'POSITION DETAIL');
|
|
13
|
-
const x = region.col + 2;
|
|
14
|
-
const w = region.width - 4;
|
|
15
|
-
// Find selected position
|
|
16
|
-
const pos = state.positions.find(p => (p.ticker_symbol || p.ticker) === state.detailTicker) || state.positions[0];
|
|
17
|
-
if (!pos) {
|
|
18
|
-
screen.write(region.row + 2, x, 'No position selected', border_js_1.CLR.dim);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
const ticker = pos.ticker_symbol || pos.ticker || '???';
|
|
22
|
-
const qty = pos.quantity ?? 0;
|
|
23
|
-
const entry = pos.average_price_paid ?? pos.cost_basis ?? 0;
|
|
24
|
-
const current = pos.current_value ?? entry;
|
|
25
|
-
const pnl = (current - entry) * qty;
|
|
26
|
-
const pnlDollars = pnl / 100;
|
|
27
|
-
const pnlColor = pnl >= 0 ? border_js_1.CLR.green : border_js_1.CLR.red;
|
|
28
|
-
const side = pos.side || 'yes';
|
|
29
|
-
// ── Top: Position Summary (3 rows) ──
|
|
30
|
-
let line = 1;
|
|
31
|
-
screen.writeStyled(region.row + line, x, [
|
|
32
|
-
{ text: (0, border_js_1.fit)(ticker, 30), fg: border_js_1.CLR.white },
|
|
33
|
-
{ text: ` ${side.toUpperCase()} `, fg: border_js_1.CLR.emerald },
|
|
34
|
-
{ text: ` qty: ${qty}`, fg: border_js_1.CLR.dim },
|
|
35
|
-
]);
|
|
36
|
-
line++;
|
|
37
|
-
screen.writeStyled(region.row + line, x, [
|
|
38
|
-
{ text: `Entry: ${entry.toFixed(0)}\u00A2`, fg: border_js_1.CLR.dim },
|
|
39
|
-
{ text: ` Current: ${current.toFixed(0)}\u00A2`, fg: border_js_1.CLR.text },
|
|
40
|
-
{ text: ` P&L: ${pnlDollars >= 0 ? '+' : ''}$${Math.abs(pnlDollars).toFixed(2)}`, fg: pnlColor },
|
|
41
|
-
]);
|
|
42
|
-
line++;
|
|
43
|
-
// Expiry
|
|
44
|
-
const expiry = pos.expiration_time || pos.expiry || pos.close_time || '';
|
|
45
|
-
if (expiry) {
|
|
46
|
-
const expiryDate = new Date(expiry);
|
|
47
|
-
const daysLeft = Math.ceil((expiryDate.getTime() - Date.now()) / 86400000);
|
|
48
|
-
screen.write(region.row + line, x, `Expiry: ${expiryDate.toISOString().slice(0, 10)} (${daysLeft}d)`, border_js_1.CLR.dim);
|
|
49
|
-
}
|
|
50
|
-
line++;
|
|
51
|
-
// ── Divider ──
|
|
52
|
-
(0, border_js_1.drawHDivider)(screen, region, line);
|
|
53
|
-
line++;
|
|
54
|
-
// ── Middle: Chart area ──
|
|
55
|
-
const chartHeight = Math.min(8, Math.floor((region.height - line - 8) / 2) + 4);
|
|
56
|
-
const candles = state.candleCache.get(ticker) || [];
|
|
57
|
-
if (candles.length > 1) {
|
|
58
|
-
const values = candles.map((c) => {
|
|
59
|
-
const close = c.close ?? 0; // already in cents from dashboard parsing
|
|
60
|
-
return ((close - entry) * qty) / 100; // P&L in dollars
|
|
61
|
-
});
|
|
62
|
-
const dateLabels = candles.map((c) => {
|
|
63
|
-
const d = c.date ? new Date(c.date) : new Date(c.end_period_ts ? c.end_period_ts * 1000 : 0);
|
|
64
|
-
return `${d.getMonth() + 1}/${d.getDate()}`;
|
|
65
|
-
});
|
|
66
|
-
screen.write(region.row + line, x, 'Daily P&L ($)', border_js_1.CLR.title);
|
|
67
|
-
line++;
|
|
68
|
-
(0, chart_js_1.drawChart)(screen, region.row + line, x, w, chartHeight, values, dateLabels);
|
|
69
|
-
line += chartHeight + 1;
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
screen.write(region.row + line, x, 'No chart data available', border_js_1.CLR.dim);
|
|
73
|
-
line += 2;
|
|
74
|
-
}
|
|
75
|
-
// ── Divider ──
|
|
76
|
-
if (line < region.height - 5) {
|
|
77
|
-
(0, border_js_1.drawHDivider)(screen, region, line);
|
|
78
|
-
line++;
|
|
79
|
-
}
|
|
80
|
-
// ── Bottom: Two columns — causal tree (left) and orderbook (right) ──
|
|
81
|
-
const halfW = Math.floor(w / 2) - 1;
|
|
82
|
-
const bottomRow = region.row + line;
|
|
83
|
-
const remainingRows = region.height - line - 1;
|
|
84
|
-
// Left: Causal tree nodes from context
|
|
85
|
-
// Find context that contains an edge matching this ticker
|
|
86
|
-
screen.write(bottomRow, x, 'Causal Tree', border_js_1.CLR.title);
|
|
87
|
-
let ctx = null;
|
|
88
|
-
for (const [, c] of state.contexts) {
|
|
89
|
-
const edges = c?.edges || [];
|
|
90
|
-
if (edges.some((e) => e.marketId === ticker || e.ticker === ticker)) {
|
|
91
|
-
ctx = c;
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
const treeNodes = ctx?.causalTree?.nodes || [];
|
|
96
|
-
// Flatten nested nodes
|
|
97
|
-
const flatNodes = [];
|
|
98
|
-
function walk(nodes, depth = 0) {
|
|
99
|
-
for (const n of nodes) {
|
|
100
|
-
flatNodes.push({ ...n, depth });
|
|
101
|
-
if (n.children)
|
|
102
|
-
walk(n.children, depth + 1);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
walk(treeNodes);
|
|
106
|
-
const nodes = flatNodes.filter(n => n.depth <= 1).slice(0, remainingRows - 1);
|
|
107
|
-
for (let i = 0; i < nodes.length; i++) {
|
|
108
|
-
const node = nodes[i];
|
|
109
|
-
const indent = ' '.repeat(node.depth + 1);
|
|
110
|
-
const name = node.label || node.claim || node.name || node.id || '?';
|
|
111
|
-
const prob = node.probability != null ? `${Math.round(node.probability * 100)}%` : '';
|
|
112
|
-
screen.writeStyled(bottomRow + 1 + i, x, [
|
|
113
|
-
{ text: indent + (0, border_js_1.fit)(name, halfW - indent.length - 5), fg: border_js_1.CLR.text },
|
|
114
|
-
{ text: (0, border_js_1.fit)(prob, 5, 'right'), fg: border_js_1.CLR.emerald },
|
|
115
|
-
]);
|
|
116
|
-
}
|
|
117
|
-
if (nodes.length === 0) {
|
|
118
|
-
screen.write(bottomRow + 1, x, ' (no context data)', border_js_1.CLR.dim);
|
|
119
|
-
}
|
|
120
|
-
// Right: Orderbook snapshot
|
|
121
|
-
const rightX = x + halfW + 2;
|
|
122
|
-
screen.write(bottomRow, rightX, 'Orderbook', border_js_1.CLR.title);
|
|
123
|
-
// Find orderbook from the edge matching this ticker
|
|
124
|
-
const matchingEdge = ctx?.edges?.find((e) => e.marketId === ticker || e.ticker === ticker);
|
|
125
|
-
const ob = matchingEdge?.orderbook;
|
|
126
|
-
if (ob) {
|
|
127
|
-
const bestBid = ob.bidPrice ?? ob.bestBid ?? 0;
|
|
128
|
-
const bestAsk = ob.askPrice ?? ob.bestAsk ?? 0;
|
|
129
|
-
const spread = ob.spread ?? (bestAsk - bestBid);
|
|
130
|
-
screen.writeStyled(bottomRow + 1, rightX, [
|
|
131
|
-
{ text: 'Bid: ', fg: border_js_1.CLR.dim },
|
|
132
|
-
{ text: `${bestBid}\u00A2`, fg: border_js_1.CLR.green },
|
|
133
|
-
{ text: ' Ask: ', fg: border_js_1.CLR.dim },
|
|
134
|
-
{ text: `${bestAsk}\u00A2`, fg: border_js_1.CLR.red },
|
|
135
|
-
]);
|
|
136
|
-
screen.writeStyled(bottomRow + 2, rightX, [
|
|
137
|
-
{ text: 'Spread: ', fg: border_js_1.CLR.dim },
|
|
138
|
-
{ text: `${spread}\u00A2`, fg: spread <= 2 ? border_js_1.CLR.green : spread <= 5 ? border_js_1.CLR.yellow : border_js_1.CLR.red },
|
|
139
|
-
]);
|
|
140
|
-
if (ob.bidDepth != null) {
|
|
141
|
-
screen.writeStyled(bottomRow + 3, rightX, [
|
|
142
|
-
{ text: 'Depth: ', fg: border_js_1.CLR.dim },
|
|
143
|
-
{ text: `bid ${ob.bidDepth}`, fg: border_js_1.CLR.dim },
|
|
144
|
-
{ text: ` / ask ${ob.askDepth}`, fg: border_js_1.CLR.dim },
|
|
145
|
-
]);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
screen.write(bottomRow + 1, rightX, ' (no orderbook data)', border_js_1.CLR.dim);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.renderEdges = renderEdges;
|
|
4
|
-
const border_js_1 = require("../border.js");
|
|
5
|
-
function renderEdges(screen, region, state) {
|
|
6
|
-
(0, border_js_1.drawBorder)(screen, region, 'TOP EDGES');
|
|
7
|
-
const x = region.col + 2;
|
|
8
|
-
const w = region.width - 4;
|
|
9
|
-
const maxRows = region.height - 2;
|
|
10
|
-
// Filter out edges already held as positions
|
|
11
|
-
const heldTickers = new Set(state.positions.map((p) => p.ticker));
|
|
12
|
-
const unpositioned = state.edges.filter((e) => !heldTickers.has(e.marketId || e.ticker || ''));
|
|
13
|
-
const top = unpositioned.slice(0, Math.min(5, maxRows));
|
|
14
|
-
if (top.length === 0) {
|
|
15
|
-
screen.write(region.row + 1, x, 'No unpositioned edges', border_js_1.CLR.dim);
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
for (let i = 0; i < top.length; i++) {
|
|
19
|
-
const e = top[i];
|
|
20
|
-
const y = region.row + 1 + i;
|
|
21
|
-
const selected = state.focusArea === 'edges' && state.selectedIndex === i;
|
|
22
|
-
const marker = selected ? '▸' : ' ';
|
|
23
|
-
const name = e.market || e.marketTitle || e.marketId || '???';
|
|
24
|
-
const edgeVal = e.edge ?? e.edgeSize ?? 0;
|
|
25
|
-
const edgeStr = `+${edgeVal.toFixed(1)}¢`;
|
|
26
|
-
const liq = e.orderbook?.liquidityScore || '?';
|
|
27
|
-
const liqColor = liq === 'high' ? border_js_1.CLR.green : liq === 'low' ? border_js_1.CLR.yellow : border_js_1.CLR.dim;
|
|
28
|
-
const venueTag = e.venue === 'polymarket' ? 'P ' : 'K ';
|
|
29
|
-
const nameWidth = Math.max(w - 20, 10);
|
|
30
|
-
screen.write(y, x, `${marker}${venueTag}${(0, border_js_1.fit)(name, nameWidth)}`, selected ? border_js_1.CLR.white : border_js_1.CLR.text);
|
|
31
|
-
screen.write(y, x + nameWidth + 3, (0, border_js_1.fit)(edgeStr, 8, 'right'), border_js_1.CLR.emerald);
|
|
32
|
-
screen.write(y, x + nameWidth + 12, (0, border_js_1.fit)(liq, 5, 'right'), liqColor);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Liquidity view — full-screen market liquidity scanner
|
|
3
|
-
*
|
|
4
|
-
* Shows markets grouped by topic and horizon with bid/ask/spread/depth info.
|
|
5
|
-
*/
|
|
6
|
-
import type { ScreenBuffer } from '../screen.js';
|
|
7
|
-
import type { Region } from '../layout.js';
|
|
8
|
-
import type { DashboardState } from '../state.js';
|
|
9
|
-
export declare function renderLiquidity(screen: ScreenBuffer, region: Region, state: DashboardState): void;
|