@newyorkcompute/kalshi-tui 0.1.0
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 +105 -0
- package/dist/App.d.ts +5 -0
- package/dist/App.d.ts.map +1 -0
- package/dist/App.js +49 -0
- package/dist/App.js.map +1 -0
- package/dist/cli.d.ts +9 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +64 -0
- package/dist/cli.js.map +1 -0
- package/dist/components/Header.d.ts +5 -0
- package/dist/components/Header.d.ts.map +1 -0
- package/dist/components/Header.js +14 -0
- package/dist/components/Header.js.map +1 -0
- package/dist/components/HelpModal.d.ts +5 -0
- package/dist/components/HelpModal.d.ts.map +1 -0
- package/dist/components/HelpModal.js +19 -0
- package/dist/components/HelpModal.js.map +1 -0
- package/dist/components/MarketList.d.ts +5 -0
- package/dist/components/MarketList.d.ts.map +1 -0
- package/dist/components/MarketList.js +68 -0
- package/dist/components/MarketList.js.map +1 -0
- package/dist/components/OrderEntry.d.ts +9 -0
- package/dist/components/OrderEntry.d.ts.map +1 -0
- package/dist/components/OrderEntry.js +77 -0
- package/dist/components/OrderEntry.js.map +1 -0
- package/dist/components/Orderbook.d.ts +9 -0
- package/dist/components/Orderbook.d.ts.map +1 -0
- package/dist/components/Orderbook.js +43 -0
- package/dist/components/Orderbook.js.map +1 -0
- package/dist/components/Positions.d.ts +5 -0
- package/dist/components/Positions.d.ts.map +1 -0
- package/dist/components/Positions.js +22 -0
- package/dist/components/Positions.js.map +1 -0
- package/dist/components/SearchBar.d.ts +5 -0
- package/dist/components/SearchBar.d.ts.map +1 -0
- package/dist/components/SearchBar.js +27 -0
- package/dist/components/SearchBar.js.map +1 -0
- package/dist/components/StatusBar.d.ts +5 -0
- package/dist/components/StatusBar.d.ts.map +1 -0
- package/dist/components/StatusBar.js +9 -0
- package/dist/components/StatusBar.js.map +1 -0
- package/dist/components/index.d.ts +11 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +12 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/ui/Box.d.ts +14 -0
- package/dist/components/ui/Box.d.ts.map +1 -0
- package/dist/components/ui/Box.js +9 -0
- package/dist/components/ui/Box.js.map +1 -0
- package/dist/components/ui/Sparkline.d.ts +11 -0
- package/dist/components/ui/Sparkline.d.ts.map +1 -0
- package/dist/components/ui/Sparkline.js +32 -0
- package/dist/components/ui/Sparkline.js.map +1 -0
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +5 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/useKalshi.d.ts +16 -0
- package/dist/hooks/useKalshi.d.ts.map +1 -0
- package/dist/hooks/useKalshi.js +31 -0
- package/dist/hooks/useKalshi.js.map +1 -0
- package/dist/hooks/useMarkets.d.ts +13 -0
- package/dist/hooks/useMarkets.d.ts.map +1 -0
- package/dist/hooks/useMarkets.js +89 -0
- package/dist/hooks/useMarkets.js.map +1 -0
- package/dist/hooks/useOrderbook.d.ts +13 -0
- package/dist/hooks/useOrderbook.d.ts.map +1 -0
- package/dist/hooks/useOrderbook.js +81 -0
- package/dist/hooks/useOrderbook.js.map +1 -0
- package/dist/hooks/usePortfolio.d.ts +18 -0
- package/dist/hooks/usePortfolio.d.ts.map +1 -0
- package/dist/hooks/usePortfolio.js +84 -0
- package/dist/hooks/usePortfolio.js.map +1 -0
- package/dist/stores/app-store.d.ts +17 -0
- package/dist/stores/app-store.d.ts.map +1 -0
- package/dist/stores/app-store.js +21 -0
- package/dist/stores/app-store.js.map +1 -0
- package/dist/theme.d.ts +31 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +37 -0
- package/dist/theme.js.map +1 -0
- package/package.json +64 -0
package/README.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# @newyorkcompute/kalshi-tui
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@newyorkcompute/kalshi-tui)
|
|
4
|
+
[](https://github.com/newyorkcompute/kalshi/blob/main/LICENSE)
|
|
5
|
+
|
|
6
|
+
**Free. Open source. Beautiful.**
|
|
7
|
+
|
|
8
|
+
A terminal so polished that the screenshot alone is the pitch. Real-time market data, orderbook visualization, portfolio management, and trading — all without leaving your terminal.
|
|
9
|
+
|
|
10
|
+
No AI. No gimmicks. Pure craft.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npx @newyorkcompute/kalshi-tui
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Or install globally:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install -g @newyorkcompute/kalshi-tui
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Screenshot
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
┌──────────────────────────────────────────────────────────────────────────────┐
|
|
28
|
+
│ ▓ KALSHI Balance: $1,234.56 ◉ │
|
|
29
|
+
│ NEW YORK COMPUTE │
|
|
30
|
+
├────────────────────────────────────┬─────────────────────────────────────────┤
|
|
31
|
+
│ MARKETS [F1] │ ORDERBOOK: KXBTC-25JAN-B100 │
|
|
32
|
+
│ ──────────────────────────────────│ ───────────────────────────────────── │
|
|
33
|
+
│ KXBTC-25JAN-B100 45¢ ▲ +2 │ ASK ████████████████ 52¢ (120) │
|
|
34
|
+
│ KXBTC-25JAN-B105 32¢ ▼ -1 │ ASK ████████████ 50¢ (85) │
|
|
35
|
+
│ KXETH-25JAN-B4000 67¢ ━ 0 │ BID ██████████ 46¢ (60) │
|
|
36
|
+
│ TRUMP-WIN-2024 52¢ ▲ +5 │ BID ████████████████ 42¢ (150) │
|
|
37
|
+
├───────────────────────────────────┼─────────────────────────────────────────┤
|
|
38
|
+
│ POSITIONS [F2] │ QUICK TRADE [F4] │
|
|
39
|
+
│ ──────────────────────────────────│ ───────────────────────────────────── │
|
|
40
|
+
│ KXBTC-25JAN-B100 +10 YES $45 │ Ticker: KXBTC-25JAN-B100 │
|
|
41
|
+
│ TRUMP-WIN-2024 -5 NO $26 │ Side: [YES] NO │
|
|
42
|
+
│ ──────────────────────────────────│ Qty: 10 Price: 45¢ │
|
|
43
|
+
│ Total Exposure: $71 │ Cost: $4.50 [BUY] │
|
|
44
|
+
├───────────────────────────────────┴─────────────────────────────────────────┤
|
|
45
|
+
│ Built by New York Compute • newyorkcompute.xyz [?] Help [q] Quit │
|
|
46
|
+
└──────────────────────────────────────────────────────────────────────────────┘
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Features
|
|
50
|
+
|
|
51
|
+
- **Market Watch** - Real-time prices with keyboard navigation
|
|
52
|
+
- **Orderbook** - Visual depth chart for selected market
|
|
53
|
+
- **Portfolio** - Live balance and position tracking
|
|
54
|
+
- **Quick Trade** - Place orders without leaving the terminal
|
|
55
|
+
- **Keyboard-first** - Full navigation without a mouse
|
|
56
|
+
|
|
57
|
+
## Keybindings
|
|
58
|
+
|
|
59
|
+
| Key | Action |
|
|
60
|
+
|-----|--------|
|
|
61
|
+
| `↑` / `↓` | Navigate markets |
|
|
62
|
+
| `Enter` | Select market |
|
|
63
|
+
| `Tab` | Toggle YES/NO side |
|
|
64
|
+
| `[` / `]` | Adjust quantity |
|
|
65
|
+
| `-` / `+` | Adjust price |
|
|
66
|
+
| `?` | Show help |
|
|
67
|
+
| `q` | Quit |
|
|
68
|
+
|
|
69
|
+
## Environment Variables
|
|
70
|
+
|
|
71
|
+
| Variable | Required | Description |
|
|
72
|
+
|----------|----------|-------------|
|
|
73
|
+
| `KALSHI_API_KEY` | Yes | Your Kalshi API key ID |
|
|
74
|
+
| `KALSHI_PRIVATE_KEY` | Yes | RSA private key (PEM format) |
|
|
75
|
+
| `KALSHI_BASE_PATH` | No | API base URL (default: production) |
|
|
76
|
+
|
|
77
|
+
## Usage
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# With environment variables
|
|
81
|
+
export KALSHI_API_KEY="your-api-key"
|
|
82
|
+
export KALSHI_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----
|
|
83
|
+
...
|
|
84
|
+
-----END RSA PRIVATE KEY-----"
|
|
85
|
+
|
|
86
|
+
kalshi-tui
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Getting API Keys
|
|
90
|
+
|
|
91
|
+
1. Log into your [Kalshi account](https://kalshi.com)
|
|
92
|
+
2. Go to Account Settings → API
|
|
93
|
+
3. Generate a new API key (you'll create an RSA key pair)
|
|
94
|
+
4. Save your API Key ID and private key securely
|
|
95
|
+
|
|
96
|
+
## Built By
|
|
97
|
+
|
|
98
|
+
**New York Compute** — Command-native tools for quantitative research, execution, and market intelligence.
|
|
99
|
+
|
|
100
|
+
Want this for equities? [Request early access →](https://newyorkcompute.xyz)
|
|
101
|
+
|
|
102
|
+
## License
|
|
103
|
+
|
|
104
|
+
MIT © [NewYorkCompute](https://github.com/newyorkcompute)
|
|
105
|
+
|
package/dist/App.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../src/App.tsx"],"names":[],"mappings":"AAaA;;GAEG;AACH,wBAAgB,GAAG,4CA0FlB"}
|
package/dist/App.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { Box, Text, useApp, useInput } from "ink";
|
|
4
|
+
import { Header } from "./components/Header.js";
|
|
5
|
+
import { MarketList } from "./components/MarketList.js";
|
|
6
|
+
import { Orderbook } from "./components/Orderbook.js";
|
|
7
|
+
import { Positions } from "./components/Positions.js";
|
|
8
|
+
import { OrderEntry } from "./components/OrderEntry.js";
|
|
9
|
+
import { StatusBar } from "./components/StatusBar.js";
|
|
10
|
+
import { HelpModal } from "./components/HelpModal.js";
|
|
11
|
+
import { SearchBar } from "./components/SearchBar.js";
|
|
12
|
+
import { useAppStore } from "./stores/app-store.js";
|
|
13
|
+
import { useKalshi } from "./hooks/useKalshi.js";
|
|
14
|
+
/**
|
|
15
|
+
* Main application component
|
|
16
|
+
*/
|
|
17
|
+
export function App() {
|
|
18
|
+
const { exit } = useApp();
|
|
19
|
+
const [error, setError] = useState(null);
|
|
20
|
+
const { isConfigured, configError } = useKalshi();
|
|
21
|
+
const selectedMarket = useAppStore((state) => state.selectedMarket);
|
|
22
|
+
// Handle keyboard input
|
|
23
|
+
useInput((input, key) => {
|
|
24
|
+
// Quit on 'q' or Ctrl+C
|
|
25
|
+
if (input === "q" || (key.ctrl && input === "c")) {
|
|
26
|
+
exit();
|
|
27
|
+
}
|
|
28
|
+
// Help on '?'
|
|
29
|
+
if (input === "?") {
|
|
30
|
+
useAppStore.getState().toggleHelp();
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
// Check configuration on mount
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (configError) {
|
|
36
|
+
setError(configError);
|
|
37
|
+
}
|
|
38
|
+
}, [configError]);
|
|
39
|
+
// Show error screen if not configured
|
|
40
|
+
if (error) {
|
|
41
|
+
return (_jsxs(Box, { flexDirection: "column", padding: 1, children: [_jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: "red", bold: true, children: "Configuration Error" }) }), _jsx(Text, { color: "gray", children: error }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { color: "gray", children: "Set KALSHI_API_KEY and KALSHI_PRIVATE_KEY environment variables." }) }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { color: "gray", children: "Run `kalshi-tui --help` for more information." }) })] }));
|
|
42
|
+
}
|
|
43
|
+
// Loading state
|
|
44
|
+
if (!isConfigured) {
|
|
45
|
+
return (_jsxs(Box, { flexDirection: "column", padding: 1, children: [_jsx(Text, { color: "green", children: "\u2593" }), _jsx(Text, { children: " Connecting to Kalshi..." })] }));
|
|
46
|
+
}
|
|
47
|
+
return (_jsxs(Box, { flexDirection: "column", width: "100%", children: [_jsx(Header, {}), _jsx(SearchBar, {}), _jsxs(Box, { flexDirection: "row", flexGrow: 1, children: [_jsxs(Box, { flexDirection: "column", width: "50%", children: [_jsx(MarketList, {}), _jsx(Positions, {})] }), _jsxs(Box, { flexDirection: "column", width: "50%", children: [_jsx(Orderbook, { ticker: selectedMarket }), _jsx(OrderEntry, { ticker: selectedMarket })] })] }), _jsx(StatusBar, {}), _jsx(HelpModal, {})] }));
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=App.js.map
|
package/dist/App.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"App.js","sourceRoot":"","sources":["../src/App.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD;;GAEG;AACH,MAAM,UAAU,GAAG;IACjB,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,EAAE,CAAC;IAC1B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAgB,I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B;IAChB,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,OAAO,CACL,MAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,EAAC,OAAO,EAAE,CAAC,aACpC,KAAC,IAAI,IAAC,KAAK,EAAC,OAAO,uBAAS,EAC5B,KAAC,IAAI,2CAAgC,IACjC,CACP,CAAC;IACJ,CAAC;IAED,OAAO,CACL,MAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,EAAC,KAAK,EAAC,MAAM,aAEtC,KAAC,MAAM,KAAG,EAGV,KAAC,SAAS,KAAG,EAGb,MAAC,GAAG,IAAC,aAAa,EAAC,KAAK,EAAC,QAAQ,EAAE,CAAC,aAElC,MAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,EAAC,KAAK,EAAC,KAAK,aACrC,KAAC,UAAU,KAAG,EACd,KAAC,SAAS,KAAG,IACT,EAGN,MAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,EAAC,KAAK,EAAC,KAAK,aACrC,KAAC,SAAS,IAAC,MAAM,EAAE,cAAc,GAAI,EACrC,KAAC,UAAU,IAAC,MAAM,EAAE,cAAc,GAAI,IAClC,IACF,EAGN,KAAC,SAAS,KAAG,EAGb,KAAC,SAAS,KAAG,IACT,CACP,CAAC;AACJ,CAAC"}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.tsx"],"names":[],"mappings":";AACA;;;;;GAKG"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { render } from "ink";
|
|
4
|
+
import { App } from "./App.js";
|
|
5
|
+
// Handle --help and --version flags
|
|
6
|
+
const args = process.argv.slice(2);
|
|
7
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
8
|
+
console.log(`
|
|
9
|
+
Kalshi TUI - Terminal Trading Dashboard
|
|
10
|
+
|
|
11
|
+
Usage:
|
|
12
|
+
kalshi-tui [options]
|
|
13
|
+
|
|
14
|
+
Options:
|
|
15
|
+
--help, -h Show this help message
|
|
16
|
+
--version, -v Show version number
|
|
17
|
+
--about Show about information
|
|
18
|
+
|
|
19
|
+
Environment Variables:
|
|
20
|
+
KALSHI_API_KEY Your Kalshi API key ID (required)
|
|
21
|
+
KALSHI_PRIVATE_KEY RSA private key in PEM format (required)
|
|
22
|
+
KALSHI_BASE_PATH API base URL (optional, defaults to production)
|
|
23
|
+
|
|
24
|
+
Examples:
|
|
25
|
+
$ kalshi-tui
|
|
26
|
+
$ KALSHI_API_KEY=xxx KALSHI_PRIVATE_KEY="..." kalshi-tui
|
|
27
|
+
|
|
28
|
+
Built by New York Compute
|
|
29
|
+
https://newyorkcompute.xyz
|
|
30
|
+
`);
|
|
31
|
+
process.exit(0);
|
|
32
|
+
}
|
|
33
|
+
if (args.includes("--version") || args.includes("-v")) {
|
|
34
|
+
console.log("0.1.0");
|
|
35
|
+
process.exit(0);
|
|
36
|
+
}
|
|
37
|
+
if (args.includes("--about")) {
|
|
38
|
+
console.log(`
|
|
39
|
+
┌──────────────────────────────────────────────────────────┐
|
|
40
|
+
│ │
|
|
41
|
+
│ ▓ KALSHI TUI │
|
|
42
|
+
│ NEW YORK COMPUTE │
|
|
43
|
+
│ │
|
|
44
|
+
│ Free. Open source. Beautiful. │
|
|
45
|
+
│ │
|
|
46
|
+
│ A terminal so polished that the screenshot alone │
|
|
47
|
+
│ is the pitch. No AI. No gimmicks. Pure craft. │
|
|
48
|
+
│ │
|
|
49
|
+
│ Version: 0.1.0 │
|
|
50
|
+
│ License: MIT │
|
|
51
|
+
│ │
|
|
52
|
+
│ GitHub: github.com/newyorkcompute/kalshi │
|
|
53
|
+
│ Website: newyorkcompute.xyz │
|
|
54
|
+
│ │
|
|
55
|
+
│ Want this for equities? Request early access: │
|
|
56
|
+
│ → newyorkcompute.xyz │
|
|
57
|
+
│ │
|
|
58
|
+
└──────────────────────────────────────────────────────────┘
|
|
59
|
+
`);
|
|
60
|
+
process.exit(0);
|
|
61
|
+
}
|
|
62
|
+
// Render the app
|
|
63
|
+
render(_jsx(App, {}));
|
|
64
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.tsx"],"names":[],"mappings":";;AASA,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,oCAAoC;AACpC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAEnC,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;IACnD,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;CAsBb,CAAC,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;IACtD,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;IAC7B,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;CAqBb,CAAC,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,iBAAiB;AACjB,MAAM,CAAC,KAAC,GAAG,KAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Header.d.ts","sourceRoot":"","sources":["../../src/components/Header.tsx"],"names":[],"mappings":"AAMA;;GAEG;AACH,wBAAgB,MAAM,4CA4CrB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Text } from "ink";
|
|
3
|
+
import { formatCurrency } from "@newyorkcompute/kalshi-core";
|
|
4
|
+
import { usePortfolio } from "../hooks/usePortfolio.js";
|
|
5
|
+
import { useAppStore } from "../stores/app-store.js";
|
|
6
|
+
/**
|
|
7
|
+
* Header component with branding and balance
|
|
8
|
+
*/
|
|
9
|
+
export function Header() {
|
|
10
|
+
const { balance } = usePortfolio();
|
|
11
|
+
const isConnected = useAppStore((state) => state.isConnected);
|
|
12
|
+
return (_jsxs(Box, { borderStyle: "single", borderColor: "gray", paddingX: 1, justifyContent: "space-between", children: [_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Text, { color: "green", bold: true, children: "\u2593" }), _jsx(Text, { bold: true, children: " KALSHI" })] }), _jsx(Text, { color: "gray", dimColor: true, children: "NEW YORK COMPUTE" })] }), _jsxs(Box, { flexDirection: "column", alignItems: "flex-end", children: [_jsxs(Box, { children: [_jsx(Text, { children: "Balance: " }), _jsx(Text, { color: "white", bold: true, children: balance ? formatCurrency(balance.balance) : "—" })] }), _jsxs(Box, { children: [_jsx(Text, { color: isConnected ? "green" : "red", children: isConnected ? "◉" : "○" }), _jsxs(Text, { color: "gray", dimColor: true, children: [" ", isConnected ? "connected" : "disconnected"] })] })] })] }));
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=Header.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Header.js","sourceRoot":"","sources":["../../src/components/Header.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,6B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C,IACH,IACF,IACF,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HelpModal.d.ts","sourceRoot":"","sources":["../../src/components/HelpModal.tsx"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAgB,SAAS,mDAuGxB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Text, useInput } from "ink";
|
|
3
|
+
import { useAppStore } from "../stores/app-store.js";
|
|
4
|
+
/**
|
|
5
|
+
* Help modal showing keybindings and commands
|
|
6
|
+
*/
|
|
7
|
+
export function HelpModal() {
|
|
8
|
+
const showHelp = useAppStore((state) => state.showHelp);
|
|
9
|
+
const toggleHelp = useAppStore((state) => state.toggleHelp);
|
|
10
|
+
useInput((input, key) => {
|
|
11
|
+
if (showHelp && (input === "?" || key.escape || input === "q")) {
|
|
12
|
+
toggleHelp();
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
if (!showHelp)
|
|
16
|
+
return null;
|
|
17
|
+
return (_jsxs(Box, { flexDirection: "column", borderStyle: "double", borderColor: "green", padding: 1, position: "absolute", marginLeft: 10, marginTop: 5, children: [_jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: "green", bold: true, children: "\u2593 KALSHI TUI \u2014 HELP" }) }), _jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { color: "white", bold: true, children: "Navigation" }), _jsxs(Box, { marginLeft: 2, flexDirection: "column", children: [_jsxs(Text, { children: [_jsx(Text, { color: "green", children: "\u2191 / \u2193" }), _jsx(Text, { color: "gray", children: " \u2014 Navigate markets" })] }), _jsxs(Text, { children: [_jsx(Text, { color: "green", children: "Enter" }), _jsx(Text, { color: "gray", children: " \u2014 Select market" })] }), _jsxs(Text, { children: [_jsx(Text, { color: "green", children: "F1-F4" }), _jsx(Text, { color: "gray", children: " \u2014 Switch panels" })] }), _jsxs(Text, { children: [_jsx(Text, { color: "green", children: "/" }), _jsx(Text, { color: "gray", children: " \u2014 Search markets" })] })] }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { color: "white", bold: true, children: "Trading" }) }), _jsxs(Box, { marginLeft: 2, flexDirection: "column", children: [_jsxs(Text, { children: [_jsx(Text, { color: "green", children: "Tab" }), _jsx(Text, { color: "gray", children: " \u2014 Toggle YES/NO side" })] }), _jsxs(Text, { children: [_jsx(Text, { color: "green", children: "[ / ]" }), _jsx(Text, { color: "gray", children: " \u2014 Adjust quantity" })] }), _jsxs(Text, { children: [_jsx(Text, { color: "green", children: "- / +" }), _jsx(Text, { color: "gray", children: " \u2014 Adjust price" })] }), _jsxs(Text, { children: [_jsx(Text, { color: "green", children: "Enter" }), _jsx(Text, { color: "gray", children: " \u2014 Place order" })] })] }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { color: "white", bold: true, children: "General" }) }), _jsxs(Box, { marginLeft: 2, flexDirection: "column", children: [_jsxs(Text, { children: [_jsx(Text, { color: "green", children: "r" }), _jsx(Text, { color: "gray", children: " \u2014 Refresh data" })] }), _jsxs(Text, { children: [_jsx(Text, { color: "green", children: "?" }), _jsx(Text, { color: "gray", children: " \u2014 Toggle this help" })] }), _jsxs(Text, { children: [_jsx(Text, { color: "green", children: "q" }), _jsx(Text, { color: "gray", children: " \u2014 Quit" })] })] })] }), _jsx(Box, { marginTop: 1, justifyContent: "center", children: _jsx(Text, { color: "gray", dimColor: true, children: "Press ? or Esc to close" }) })] }));
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=HelpModal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HelpModal.js","sourceRoot":"","sources":["../../src/components/HelpModal.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD;;GAEG;AACH,MA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I,IAAC,KAAK,EAAC,OAAO,kBAAS,EAC5B,KAAC,IAAI,IAAC,KAAK,EAAC,MAAM,yCAA2B,IACxC,EACP,MAAC,IAAI,eACH,KAAC,IAAI,IAAC,KAAK,EAAC,OAAO,kBAAS,EAC5B,KAAC,IAAI,IAAC,KAAK,EAAC,MAAM,6BAAe,IAC5B,IACH,IACF,EAEN,KAAC,GAAG,IAAC,SAAS,EAAE,CAAC,EAAE,cAAc,EAAC,QAAQ,YACxC,KAAC,IAAI,IAAC,KAAK,EAAC,MAAM,EAAC,QAAQ,8CAEpB,GACH,IACF,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarketList.d.ts","sourceRoot":"","sources":["../../src/components/MarketList.tsx"],"names":[],"mappings":"AAMA;;GAEG;AACH,wBAAgB,UAAU,4CAgJzB"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useState } from "react";
|
|
3
|
+
import { Box, Text, useInput } from "ink";
|
|
4
|
+
import { formatPrice, truncate } from "@newyorkcompute/kalshi-core";
|
|
5
|
+
import { useMarkets } from "../hooks/useMarkets.js";
|
|
6
|
+
import { useAppStore } from "../stores/app-store.js";
|
|
7
|
+
/**
|
|
8
|
+
* Market list panel with scrollable market data
|
|
9
|
+
*/
|
|
10
|
+
export function MarketList() {
|
|
11
|
+
const { markets, isLoading, error } = useMarkets();
|
|
12
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
13
|
+
const [scrollOffset, setScrollOffset] = useState(0);
|
|
14
|
+
const setSelectedMarket = useAppStore((state) => state.setSelectedMarket);
|
|
15
|
+
const activePanel = useAppStore((state) => state.activePanel);
|
|
16
|
+
const searchQuery = useAppStore((state) => state.searchQuery);
|
|
17
|
+
const isActive = activePanel === "markets";
|
|
18
|
+
const visibleRows = 8;
|
|
19
|
+
// Filter markets by search query
|
|
20
|
+
const filteredMarkets = markets.filter((m) => m.ticker?.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
|
21
|
+
m.title?.toLowerCase().includes(searchQuery.toLowerCase()));
|
|
22
|
+
// Handle keyboard navigation
|
|
23
|
+
useInput((input, key) => {
|
|
24
|
+
if (!isActive)
|
|
25
|
+
return;
|
|
26
|
+
if (key.upArrow) {
|
|
27
|
+
const newIndex = Math.max(0, selectedIndex - 1);
|
|
28
|
+
setSelectedIndex(newIndex);
|
|
29
|
+
if (newIndex < scrollOffset) {
|
|
30
|
+
setScrollOffset(newIndex);
|
|
31
|
+
}
|
|
32
|
+
if (filteredMarkets[newIndex]) {
|
|
33
|
+
setSelectedMarket(filteredMarkets[newIndex].ticker || null);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (key.downArrow) {
|
|
37
|
+
const newIndex = Math.min(filteredMarkets.length - 1, selectedIndex + 1);
|
|
38
|
+
setSelectedIndex(newIndex);
|
|
39
|
+
if (newIndex >= scrollOffset + visibleRows) {
|
|
40
|
+
setScrollOffset(newIndex - visibleRows + 1);
|
|
41
|
+
}
|
|
42
|
+
if (filteredMarkets[newIndex]) {
|
|
43
|
+
setSelectedMarket(filteredMarkets[newIndex].ticker || null);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (key.return && filteredMarkets[selectedIndex]) {
|
|
47
|
+
setSelectedMarket(filteredMarkets[selectedIndex].ticker || null);
|
|
48
|
+
}
|
|
49
|
+
}, { isActive });
|
|
50
|
+
// Select first market on initial load
|
|
51
|
+
React.useEffect(() => {
|
|
52
|
+
if (filteredMarkets.length > 0 && !useAppStore.getState().selectedMarket) {
|
|
53
|
+
setSelectedMarket(filteredMarkets[0].ticker || null);
|
|
54
|
+
}
|
|
55
|
+
}, [filteredMarkets, setSelectedMarket]);
|
|
56
|
+
const visibleMarkets = filteredMarkets.slice(scrollOffset, scrollOffset + visibleRows);
|
|
57
|
+
return (_jsxs(Box, { flexDirection: "column", borderStyle: "single", borderColor: isActive ? "green" : "gray", flexGrow: 1, children: [_jsxs(Box, { paddingX: 1, justifyContent: "space-between", children: [_jsx(Text, { bold: true, color: isActive ? "green" : "white", children: "MARKETS" }), _jsx(Text, { color: "gray", dimColor: true, children: "[F1]" })] }), _jsx(Box, { paddingX: 1, children: _jsx(Text, { color: "gray", children: "─".repeat(40) }) }), _jsxs(Box, { flexDirection: "column", paddingX: 1, flexGrow: 1, children: [isLoading && (_jsx(Text, { color: "gray", children: "Loading markets..." })), error && (_jsx(Text, { color: "red", children: error })), !isLoading && !error && filteredMarkets.length === 0 && (_jsx(Text, { color: "gray", children: "No markets found" })), visibleMarkets.map((market, index) => {
|
|
58
|
+
const actualIndex = scrollOffset + index;
|
|
59
|
+
const isSelected = actualIndex === selectedIndex;
|
|
60
|
+
const yesBid = market.yes_bid ?? 0;
|
|
61
|
+
// Calculate price change (mock for now - would need historical data)
|
|
62
|
+
const change = 0;
|
|
63
|
+
const changeColor = change > 0 ? "green" : change < 0 ? "red" : "gray";
|
|
64
|
+
const changeSymbol = change > 0 ? "▲" : change < 0 ? "▼" : "━";
|
|
65
|
+
return (_jsxs(Box, { justifyContent: "space-between", children: [_jsxs(Text, { color: isSelected ? "green" : "white", bold: isSelected, inverse: isSelected, children: [" ", truncate(market.ticker || "", 20)] }), _jsxs(Box, { children: [_jsx(Text, { color: "white", children: formatPrice(yesBid) }), _jsxs(Text, { color: changeColor, children: [" ", changeSymbol, " ", change >= 0 ? "+" : "", change] })] })] }, market.ticker));
|
|
66
|
+
}), filteredMarkets.length > visibleRows && (_jsx(Box, { justifyContent: "center", marginTop: 1, children: _jsxs(Text, { color: "gray", dimColor: true, children: [scrollOffset + 1, "-", Math.min(scrollOffset + visibleRows, filteredMarkets.length), " of", " ", filteredMarkets.length] }) }))] })] }));
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=MarketList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarketList.js","sourceRoot":"","sources":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,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EACrC,MAAM,IACF,IACH,KAhBE,MAAM,CAAC,MAAM,CAiBjB,CACP,CAAC;oBACJ,CAAC,CAAC,EAGD,eAAe,CAAC,MAAM,GAAG,WAAW,IAAI,CACvC,KAAC,GAAG,IAAC,cAAc,EAAC,QAAQ,EAAC,SAAS,EAAE,CAAC,YACvC,MAAC,IAAI,IAAC,KAAK,EAAC,MAAM,EAAC,QAAQ,mBACxB,YAAY,GAAG,CAAC,OAAG,IAAI,CAAC,GAAG,CAAC,YAAY,GAAG,WAAW,EAAE,eAAe,CAAC,MAAM,CAAC,SAAK,GAAG,EACvF,eAAe,CAAC,MAAM,IAClB,GACH,CACP,IACG,IACF,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface OrderEntryProps {
|
|
2
|
+
ticker: string | null;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Order entry form for placing trades
|
|
6
|
+
*/
|
|
7
|
+
export declare function OrderEntry({ ticker }: OrderEntryProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=OrderEntry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OrderEntry.d.ts","sourceRoot":"","sources":["../../src/components/OrderEntry.tsx"],"names":[],"mappings":"AAMA,UAAU,eAAe;IACvB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,EAAE,MAAM,EAAE,EAAE,eAAe,2CA4LrD"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { Box, Text, useInput } from "ink";
|
|
4
|
+
import { formatPrice, formatCurrency } from "@newyorkcompute/kalshi-core";
|
|
5
|
+
import { useAppStore } from "../stores/app-store.js";
|
|
6
|
+
import { useKalshi } from "../hooks/useKalshi.js";
|
|
7
|
+
/**
|
|
8
|
+
* Order entry form for placing trades
|
|
9
|
+
*/
|
|
10
|
+
export function OrderEntry({ ticker }) {
|
|
11
|
+
const { ordersApi } = useKalshi();
|
|
12
|
+
const activePanel = useAppStore((state) => state.activePanel);
|
|
13
|
+
const isActive = activePanel === "order";
|
|
14
|
+
const [side, setSide] = useState("yes");
|
|
15
|
+
const [quantity, setQuantity] = useState(10);
|
|
16
|
+
const [price, setPrice] = useState(50);
|
|
17
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
18
|
+
const [message, setMessage] = useState(null);
|
|
19
|
+
// Calculate cost
|
|
20
|
+
const cost = (quantity * price) / 100;
|
|
21
|
+
// Handle keyboard input
|
|
22
|
+
useInput((input, key) => {
|
|
23
|
+
if (!isActive || !ticker)
|
|
24
|
+
return;
|
|
25
|
+
// Toggle side with Tab
|
|
26
|
+
if (key.tab) {
|
|
27
|
+
setSide((s) => (s === "yes" ? "no" : "yes"));
|
|
28
|
+
}
|
|
29
|
+
// Adjust quantity with [ and ]
|
|
30
|
+
if (input === "[") {
|
|
31
|
+
setQuantity((q) => Math.max(1, q - 1));
|
|
32
|
+
}
|
|
33
|
+
if (input === "]") {
|
|
34
|
+
setQuantity((q) => q + 1);
|
|
35
|
+
}
|
|
36
|
+
// Adjust price with - and +
|
|
37
|
+
if (input === "-") {
|
|
38
|
+
setPrice((p) => Math.max(1, p - 1));
|
|
39
|
+
}
|
|
40
|
+
if (input === "=" || input === "+") {
|
|
41
|
+
setPrice((p) => Math.min(99, p + 1));
|
|
42
|
+
}
|
|
43
|
+
// Submit with Enter
|
|
44
|
+
if (key.return && !isSubmitting) {
|
|
45
|
+
handleSubmit();
|
|
46
|
+
}
|
|
47
|
+
}, { isActive });
|
|
48
|
+
const handleSubmit = async () => {
|
|
49
|
+
if (!ordersApi || !ticker)
|
|
50
|
+
return;
|
|
51
|
+
setIsSubmitting(true);
|
|
52
|
+
setMessage(null);
|
|
53
|
+
try {
|
|
54
|
+
await ordersApi.createOrder({
|
|
55
|
+
ticker,
|
|
56
|
+
side: side === "yes" ? "yes" : "no",
|
|
57
|
+
action: "buy",
|
|
58
|
+
count: quantity,
|
|
59
|
+
type: "limit",
|
|
60
|
+
yes_price: side === "yes" ? price : undefined,
|
|
61
|
+
no_price: side === "no" ? price : undefined,
|
|
62
|
+
});
|
|
63
|
+
setMessage({ type: "success", text: "Order placed successfully" });
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
setMessage({
|
|
67
|
+
type: "error",
|
|
68
|
+
text: error instanceof Error ? error.message : "Failed to place order",
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
setIsSubmitting(false);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
return (_jsxs(Box, { flexDirection: "column", borderStyle: "single", borderColor: isActive ? "green" : "gray", height: 10, children: [_jsxs(Box, { paddingX: 1, justifyContent: "space-between", children: [_jsx(Text, { bold: true, color: isActive ? "green" : "white", children: "QUICK TRADE" }), _jsx(Text, { color: "gray", dimColor: true, children: "[F4]" })] }), _jsx(Box, { paddingX: 1, children: _jsx(Text, { color: "gray", children: "─".repeat(40) }) }), _jsxs(Box, { flexDirection: "column", paddingX: 1, flexGrow: 1, children: [!ticker && (_jsx(Text, { color: "gray", children: "Select a market to trade" })), ticker && (_jsxs(_Fragment, { children: [_jsxs(Box, { children: [_jsx(Text, { color: "gray", children: "Ticker: " }), _jsx(Text, { color: "white", children: ticker })] }), _jsxs(Box, { children: [_jsx(Text, { color: "gray", children: "Side: " }), _jsx(Text, { color: side === "yes" ? "green" : "gray", bold: side === "yes", inverse: side === "yes", children: "[YES]" }), _jsx(Text, { children: " " }), _jsx(Text, { color: side === "no" ? "red" : "gray", bold: side === "no", inverse: side === "no", children: "[NO]" }), _jsxs(Text, { color: "gray", dimColor: true, children: [" ", "(Tab)"] })] }), _jsxs(Box, { justifyContent: "space-between", children: [_jsxs(Box, { children: [_jsx(Text, { color: "gray", children: "Qty: " }), _jsx(Text, { color: "white", children: quantity }), _jsxs(Text, { color: "gray", dimColor: true, children: [" ", "([/])"] })] }), _jsxs(Box, { children: [_jsx(Text, { color: "gray", children: "Price: " }), _jsx(Text, { color: "white", children: formatPrice(price) }), _jsxs(Text, { color: "gray", dimColor: true, children: [" ", "(-/+)"] })] })] }), _jsxs(Box, { justifyContent: "space-between", marginTop: 1, children: [_jsxs(Box, { children: [_jsx(Text, { color: "gray", children: "Cost: " }), _jsx(Text, { color: "white", bold: true, children: formatCurrency(cost * 100) })] }), _jsx(Box, { children: _jsx(Text, { color: isSubmitting ? "gray" : "green", bold: true, inverse: !isSubmitting, children: isSubmitting ? " PLACING... " : " [BUY] " }) })] }), message && (_jsx(Box, { marginTop: 1, children: _jsx(Text, { color: message.type === "success" ? "green" : "red", children: message.text }) }))] }))] })] }));
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=OrderEntry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OrderEntry.js","sourceRoot":"","sources":["../../src/components/OrderEntry.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAMlD;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,EAAE,MAAM,EAAmB;IACpD,MAAM,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,CAAC;IAClC,MAAM,WAAW,GAAG,WAAW,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KA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AE,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EACtC,IAAI,QACJ,OAAO,EAAE,CAAC,YAAY,YAErB,YAAY,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,GACrC,GACH,IACF,EAGL,OAAO,IAAI,CACV,KAAC,GAAG,IAAC,SAAS,EAAE,CAAC,YACf,KAAC,IAAI,IAAC,KAAK,EAAE,OAAO,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,YACtD,OAAO,CAAC,IAAI,GACR,GACH,CACP,IACA,CACJ,IACG,IACF,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface OrderbookProps {
|
|
2
|
+
ticker: string | null;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Orderbook visualization with depth bars
|
|
6
|
+
*/
|
|
7
|
+
export declare function Orderbook({ ticker }: OrderbookProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=Orderbook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Orderbook.d.ts","sourceRoot":"","sources":["../../src/components/Orderbook.tsx"],"names":[],"mappings":"AAMA,UAAU,cAAc;IACtB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,EAAE,MAAM,EAAE,EAAE,cAAc,2CA0HnD"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Text } from "ink";
|
|
3
|
+
import { formatPrice } from "@newyorkcompute/kalshi-core";
|
|
4
|
+
import { useOrderbook } from "../hooks/useOrderbook.js";
|
|
5
|
+
import { useAppStore } from "../stores/app-store.js";
|
|
6
|
+
/**
|
|
7
|
+
* Orderbook visualization with depth bars
|
|
8
|
+
*/
|
|
9
|
+
export function Orderbook({ ticker }) {
|
|
10
|
+
const { orderbook, isLoading, error } = useOrderbook(ticker);
|
|
11
|
+
const activePanel = useAppStore((state) => state.activePanel);
|
|
12
|
+
const isActive = activePanel === "orderbook";
|
|
13
|
+
// Calculate max quantity for bar scaling
|
|
14
|
+
const yesQtys = orderbook?.yes?.map((level) => level[1]) || [];
|
|
15
|
+
const noQtys = orderbook?.no?.map((level) => level[1]) || [];
|
|
16
|
+
const allQuantities = [...yesQtys, ...noQtys];
|
|
17
|
+
const maxQty = Math.max(...allQuantities, 1);
|
|
18
|
+
// Render a depth bar
|
|
19
|
+
const renderBar = (quantity, side, maxWidth = 20) => {
|
|
20
|
+
const barWidth = Math.round((quantity / maxQty) * maxWidth);
|
|
21
|
+
const bar = "█".repeat(barWidth);
|
|
22
|
+
const padding = " ".repeat(maxWidth - barWidth);
|
|
23
|
+
if (side === "ask") {
|
|
24
|
+
return (_jsxs(Text, { color: "red", children: [padding, bar] }));
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
return _jsx(Text, { color: "green", children: bar });
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
// Get asks (sorted high to low) and bids (sorted high to low)
|
|
31
|
+
const asks = (orderbook?.no || [])
|
|
32
|
+
.slice(0, 5)
|
|
33
|
+
.sort((a, b) => b[0] - a[0]);
|
|
34
|
+
const bids = (orderbook?.yes || [])
|
|
35
|
+
.slice(0, 5)
|
|
36
|
+
.sort((a, b) => b[0] - a[0]);
|
|
37
|
+
// Calculate spread
|
|
38
|
+
const bestAsk = asks.length > 0 ? asks[asks.length - 1][0] : null;
|
|
39
|
+
const bestBid = bids.length > 0 ? bids[0][0] : null;
|
|
40
|
+
const spread = bestAsk && bestBid ? bestAsk - bestBid : null;
|
|
41
|
+
return (_jsxs(Box, { flexDirection: "column", borderStyle: "single", borderColor: isActive ? "green" : "gray", flexGrow: 1, children: [_jsxs(Box, { paddingX: 1, justifyContent: "space-between", children: [_jsxs(Box, { children: [_jsx(Text, { bold: true, color: isActive ? "green" : "white", children: "ORDERBOOK" }), ticker && (_jsxs(Text, { color: "gray", dimColor: true, children: [": ", ticker] }))] }), _jsx(Text, { color: "gray", dimColor: true, children: "[F2]" })] }), _jsx(Box, { paddingX: 1, children: _jsx(Text, { color: "gray", children: "─".repeat(40) }) }), _jsxs(Box, { flexDirection: "column", paddingX: 1, flexGrow: 1, children: [!ticker && (_jsx(Text, { color: "gray", children: "Select a market to view orderbook" })), ticker && isLoading && (_jsx(Text, { color: "gray", children: "Loading orderbook..." })), ticker && error && _jsx(Text, { color: "red", children: error }), ticker && orderbook && !isLoading && (_jsxs(_Fragment, { children: [asks.map(([price, qty], index) => (_jsxs(Box, { justifyContent: "space-between", children: [_jsx(Text, { color: "gray", children: "ASK" }), renderBar(qty, "ask"), _jsx(Text, { color: "red", children: formatPrice(100 - price) }), _jsxs(Text, { color: "gray", dimColor: true, children: ["(", qty, ")"] })] }, `ask-${index}`))), _jsx(Box, { justifyContent: "center", marginY: 1, children: _jsxs(Text, { color: "gray", children: ["─── SPREAD: ", spread !== null ? `${spread}¢` : "—", " ───"] }) }), bids.map(([price, qty], index) => (_jsxs(Box, { justifyContent: "space-between", children: [_jsx(Text, { color: "gray", children: "BID" }), renderBar(qty, "bid"), _jsx(Text, { color: "green", children: formatPrice(price) }), _jsxs(Text, { color: "gray", dimColor: true, children: ["(", qty, ")"] })] }, `bid-${index}`)))] }))] })] }));
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=Orderbook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Orderbook.js","sourceRoot":"","sources":["../../src/components/Orderbook.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,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