@newyorkcompute/kalshi-tui 0.1.0 → 0.2.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 +35 -0
- package/dist/App.d.ts +2 -1
- package/dist/App.d.ts.map +1 -1
- package/dist/App.js +38 -36
- package/dist/App.js.map +1 -1
- package/dist/cli.d.ts +2 -2
- package/dist/cli.js +28 -33
- package/dist/cli.js.map +1 -1
- package/dist/components/Footer.d.ts +6 -0
- package/dist/components/Footer.d.ts.map +1 -0
- package/dist/components/Footer.js +10 -0
- package/dist/components/Footer.js.map +1 -0
- package/dist/components/Header.d.ts +9 -2
- package/dist/components/Header.d.ts.map +1 -1
- package/dist/components/Header.js +7 -9
- package/dist/components/Header.js.map +1 -1
- package/dist/components/Markets.d.ts +21 -0
- package/dist/components/Markets.d.ts.map +1 -0
- package/dist/components/Markets.js +24 -0
- package/dist/components/Markets.js.map +1 -0
- package/dist/components/Orderbook.d.ts +18 -5
- package/dist/components/Orderbook.d.ts.map +1 -1
- package/dist/components/Orderbook.js +25 -36
- package/dist/components/Orderbook.js.map +1 -1
- package/dist/components/Positions.d.ts +13 -2
- package/dist/components/Positions.d.ts.map +1 -1
- package/dist/components/Positions.js +10 -17
- package/dist/components/Positions.js.map +1 -1
- package/dist/components/index.d.ts +8 -10
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +8 -11
- package/dist/components/index.js.map +1 -1
- package/dist/hooks/index.d.ts +4 -4
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +4 -4
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/useKalshi.d.ts +21 -12
- package/dist/hooks/useKalshi.d.ts.map +1 -1
- package/dist/hooks/useKalshi.js +139 -19
- package/dist/hooks/useKalshi.js.map +1 -1
- package/dist/utils.d.ts +32 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +74 -0
- package/dist/utils.js.map +1 -0
- package/dist/utils.test.d.ts +2 -0
- package/dist/utils.test.d.ts.map +1 -0
- package/dist/utils.test.js +101 -0
- package/dist/utils.test.js.map +1 -0
- package/package.json +6 -8
- package/dist/components/HelpModal.d.ts +0 -5
- package/dist/components/HelpModal.d.ts.map +0 -1
- package/dist/components/HelpModal.js +0 -19
- package/dist/components/HelpModal.js.map +0 -1
- package/dist/components/MarketList.d.ts +0 -5
- package/dist/components/MarketList.d.ts.map +0 -1
- package/dist/components/MarketList.js +0 -68
- package/dist/components/MarketList.js.map +0 -1
- package/dist/components/OrderEntry.d.ts +0 -9
- package/dist/components/OrderEntry.d.ts.map +0 -1
- package/dist/components/OrderEntry.js +0 -77
- package/dist/components/OrderEntry.js.map +0 -1
- package/dist/components/SearchBar.d.ts +0 -5
- package/dist/components/SearchBar.d.ts.map +0 -1
- package/dist/components/SearchBar.js +0 -27
- package/dist/components/SearchBar.js.map +0 -1
- package/dist/components/StatusBar.d.ts +0 -5
- package/dist/components/StatusBar.d.ts.map +0 -1
- package/dist/components/StatusBar.js +0 -9
- package/dist/components/StatusBar.js.map +0 -1
- package/dist/components/ui/Box.d.ts +0 -14
- package/dist/components/ui/Box.d.ts.map +0 -1
- package/dist/components/ui/Box.js +0 -9
- package/dist/components/ui/Box.js.map +0 -1
- package/dist/components/ui/Sparkline.d.ts +0 -11
- package/dist/components/ui/Sparkline.d.ts.map +0 -1
- package/dist/components/ui/Sparkline.js +0 -32
- package/dist/components/ui/Sparkline.js.map +0 -1
- package/dist/hooks/useMarkets.d.ts +0 -13
- package/dist/hooks/useMarkets.d.ts.map +0 -1
- package/dist/hooks/useMarkets.js +0 -89
- package/dist/hooks/useMarkets.js.map +0 -1
- package/dist/hooks/useOrderbook.d.ts +0 -13
- package/dist/hooks/useOrderbook.d.ts.map +0 -1
- package/dist/hooks/useOrderbook.js +0 -81
- package/dist/hooks/useOrderbook.js.map +0 -1
- package/dist/hooks/usePortfolio.d.ts +0 -18
- package/dist/hooks/usePortfolio.d.ts.map +0 -1
- package/dist/hooks/usePortfolio.js +0 -84
- package/dist/hooks/usePortfolio.js.map +0 -1
- package/dist/stores/app-store.d.ts +0 -17
- package/dist/stores/app-store.d.ts.map +0 -1
- package/dist/stores/app-store.js +0 -21
- package/dist/stores/app-store.js.map +0 -1
- package/dist/theme.d.ts +0 -31
- package/dist/theme.d.ts.map +0 -1
- package/dist/theme.js +0 -37
- package/dist/theme.js.map +0 -1
package/README.md
CHANGED
|
@@ -93,6 +93,41 @@ kalshi-tui
|
|
|
93
93
|
3. Generate a new API key (you'll create an RSA key pair)
|
|
94
94
|
4. Save your API Key ID and private key securely
|
|
95
95
|
|
|
96
|
+
## Development
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
# Install dependencies
|
|
100
|
+
npm install
|
|
101
|
+
|
|
102
|
+
# Build the TUI
|
|
103
|
+
npx nx run @newyorkcompute/kalshi-tui:build
|
|
104
|
+
|
|
105
|
+
# Run the TUI (loads .env.local)
|
|
106
|
+
npx dotenv -e .env.local -- node packages/tui/dist/cli.js
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Watch Mode
|
|
110
|
+
|
|
111
|
+
For active development, run the build in watch mode in one terminal:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
# Terminal 1: Watch for changes
|
|
115
|
+
npx nx run @newyorkcompute/kalshi-tui:dev
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Then run the TUI in another terminal:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# Terminal 2: Run the app (re-run after changes compile)
|
|
122
|
+
npx dotenv -e .env.local -- node packages/tui/dist/cli.js
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Tech Stack
|
|
126
|
+
|
|
127
|
+
- **[Ink](https://github.com/vadimdemedes/ink)** - React for the terminal
|
|
128
|
+
- **[@inkjs/ui](https://github.com/vadimdemedes/ink-ui)** - Polished UI components
|
|
129
|
+
- **React 18** - Declarative UI with hooks
|
|
130
|
+
|
|
96
131
|
## Built By
|
|
97
132
|
|
|
98
133
|
**New York Compute** — Command-native tools for quantitative research, execution, and market intelligence.
|
package/dist/App.d.ts
CHANGED
package/dist/App.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../src/App.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../src/App.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAWH,wBAAgB,GAAG,4CA0FlB"}
|
package/dist/App.js
CHANGED
|
@@ -1,49 +1,51 @@
|
|
|
1
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
2
|
/**
|
|
15
|
-
* Main
|
|
3
|
+
* Kalshi TUI - Main Application
|
|
4
|
+
* Clean, minimal, beautiful terminal trading
|
|
16
5
|
*/
|
|
6
|
+
import { Box, useApp, useInput, useStdout } from 'ink';
|
|
7
|
+
import { useState, useEffect } from 'react';
|
|
8
|
+
import { Header } from './components/Header.js';
|
|
9
|
+
import { Markets } from './components/Markets.js';
|
|
10
|
+
import { Orderbook } from './components/Orderbook.js';
|
|
11
|
+
import { Positions } from './components/Positions.js';
|
|
12
|
+
import { Footer } from './components/Footer.js';
|
|
13
|
+
import { useKalshi } from './hooks/useKalshi.js';
|
|
17
14
|
export function App() {
|
|
18
15
|
const { exit } = useApp();
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
|
|
16
|
+
const { stdout } = useStdout();
|
|
17
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
18
|
+
// Get terminal dimensions
|
|
19
|
+
const width = stdout?.columns ?? 120;
|
|
20
|
+
const height = stdout?.rows ?? 40;
|
|
21
|
+
// Fetch data from Kalshi
|
|
22
|
+
const { markets, orderbook, balance, positions, isConnected, error, selectMarket } = useKalshi();
|
|
23
|
+
// Update orderbook when selection changes
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
const ticker = markets[selectedIndex]?.ticker;
|
|
26
|
+
if (ticker) {
|
|
27
|
+
selectMarket(ticker);
|
|
28
|
+
}
|
|
29
|
+
}, [selectedIndex, markets, selectMarket]);
|
|
22
30
|
// Handle keyboard input
|
|
23
31
|
useInput((input, key) => {
|
|
24
|
-
|
|
25
|
-
if (input === "q" || (key.ctrl && input === "c")) {
|
|
32
|
+
if (input === 'q') {
|
|
26
33
|
exit();
|
|
27
34
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
useAppStore.getState().toggleHelp();
|
|
35
|
+
if (key.upArrow) {
|
|
36
|
+
setSelectedIndex(i => Math.max(0, i - 1));
|
|
31
37
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
if (configError) {
|
|
36
|
-
setError(configError);
|
|
38
|
+
if (key.downArrow) {
|
|
39
|
+
setSelectedIndex(i => Math.min(markets.length - 1, i + 1));
|
|
37
40
|
}
|
|
38
|
-
}
|
|
39
|
-
//
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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, {})] }));
|
|
41
|
+
});
|
|
42
|
+
// Layout calculations
|
|
43
|
+
const leftWidth = Math.floor(width / 2);
|
|
44
|
+
const contentHeight = height - 6; // Header (3) + Footer (3)
|
|
45
|
+
const marketsHeight = Math.floor(contentHeight * 0.65);
|
|
46
|
+
const positionsHeight = contentHeight - marketsHeight;
|
|
47
|
+
// Get selected market for orderbook
|
|
48
|
+
const selectedMarket = markets[selectedIndex] ?? null;
|
|
49
|
+
return (_jsxs(Box, { flexDirection: "column", width: width, height: height, children: [_jsx(Header, { balance: balance, isConnected: isConnected, error: error }), _jsxs(Box, { flexDirection: "row", height: contentHeight, children: [_jsxs(Box, { flexDirection: "column", width: leftWidth, children: [_jsx(Markets, { markets: markets, selectedIndex: selectedIndex, height: marketsHeight }), _jsx(Positions, { positions: positions, height: positionsHeight })] }), _jsx(Box, { flexGrow: 1, children: _jsx(Orderbook, { market: selectedMarket, orderbook: orderbook, height: contentHeight }) })] }), _jsx(Footer, {})] }));
|
|
48
50
|
}
|
|
49
51
|
//# sourceMappingURL=App.js.map
|
package/dist/App.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.js","sourceRoot":"","sources":["../src/App.tsx"],"names":[],"mappings":";AAAA,
|
|
1
|
+
{"version":3,"file":"App.js","sourceRoot":"","sources":["../src/App.tsx"],"names":[],"mappings":";AAAA;;;GAGG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,MAAM,E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,EAAE,CAAC,YACd,KAAC,SAAS,IACR,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,aAAa,GACrB,GACE,IACF,EAGN,KAAC,MAAM,KAAG,IACN,CACP,CAAC;AACJ,CAAC"}
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
3
|
* Kalshi TUI - Terminal Trading Dashboard
|
|
4
|
+
* Built with Ink for buttery-smooth rendering
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
-
* Built by New York Compute.
|
|
6
|
+
* Built by New York Compute
|
|
7
7
|
*/
|
|
8
8
|
export {};
|
|
9
9
|
//# sourceMappingURL=cli.d.ts.map
|
package/dist/cli.js
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Kalshi TUI - Terminal Trading Dashboard
|
|
5
|
+
* Built with Ink for buttery-smooth rendering
|
|
6
|
+
*
|
|
7
|
+
* Built by New York Compute
|
|
8
|
+
*/
|
|
9
|
+
import { render } from 'ink';
|
|
10
|
+
import { App } from './App.js';
|
|
5
11
|
// Handle --help and --version flags
|
|
6
12
|
const args = process.argv.slice(2);
|
|
7
|
-
if (args.includes(
|
|
13
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
8
14
|
console.log(`
|
|
9
15
|
Kalshi TUI - Terminal Trading Dashboard
|
|
10
16
|
|
|
@@ -14,50 +20,39 @@ if (args.includes("--help") || args.includes("-h")) {
|
|
|
14
20
|
Options:
|
|
15
21
|
--help, -h Show this help message
|
|
16
22
|
--version, -v Show version number
|
|
17
|
-
--about Show about information
|
|
18
23
|
|
|
19
24
|
Environment Variables:
|
|
20
25
|
KALSHI_API_KEY Your Kalshi API key ID (required)
|
|
21
26
|
KALSHI_PRIVATE_KEY RSA private key in PEM format (required)
|
|
22
|
-
KALSHI_BASE_PATH API base URL (optional, defaults to production)
|
|
23
27
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
Controls:
|
|
29
|
+
↑/↓ Navigate markets
|
|
30
|
+
q Quit
|
|
27
31
|
|
|
28
32
|
Built by New York Compute
|
|
29
33
|
https://newyorkcompute.xyz
|
|
30
34
|
`);
|
|
31
35
|
process.exit(0);
|
|
32
36
|
}
|
|
33
|
-
if (args.includes(
|
|
34
|
-
console.log(
|
|
37
|
+
if (args.includes('--version') || args.includes('-v')) {
|
|
38
|
+
console.log('0.1.0');
|
|
35
39
|
process.exit(0);
|
|
36
40
|
}
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
└──────────────────────────────────────────────────────────┘
|
|
41
|
+
// Check if stdin supports raw mode (required for keyboard input)
|
|
42
|
+
const isRawModeSupported = process.stdin.isTTY;
|
|
43
|
+
if (!isRawModeSupported) {
|
|
44
|
+
console.error(`
|
|
45
|
+
Error: Kalshi TUI requires an interactive terminal.
|
|
46
|
+
|
|
47
|
+
This usually happens when running through a task runner or piped input.
|
|
48
|
+
|
|
49
|
+
Try running directly:
|
|
50
|
+
node dist/cli.js
|
|
51
|
+
|
|
52
|
+
Or:
|
|
53
|
+
npx @newyorkcompute/kalshi-tui
|
|
59
54
|
`);
|
|
60
|
-
process.exit(
|
|
55
|
+
process.exit(1);
|
|
61
56
|
}
|
|
62
57
|
// Render the app
|
|
63
58
|
render(_jsx(App, {}));
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.tsx"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.tsx"],"names":[],"mappings":";;AACA;;;;;GAKG;AAEH,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;;;;;;;;;;;;;;;;;;;;CAoBb,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,iEAAiE;AACjE,MAAM,kBAAkB,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;AAE/C,IAAI,CAAC,kBAAkB,EAAE,CAAC;IACxB,OAAO,CAAC,KAAK,CAAC;;;;;;;;;;CAUf,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":"Footer.d.ts","sourceRoot":"","sources":["../../src/components/Footer.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,wBAAgB,MAAM,4CAiBrB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Footer Component
|
|
4
|
+
* Branding and keyboard shortcuts
|
|
5
|
+
*/
|
|
6
|
+
import { Box, Text } from 'ink';
|
|
7
|
+
export function Footer() {
|
|
8
|
+
return (_jsxs(Box, { flexDirection: "row", justifyContent: "space-between", borderStyle: "single", borderColor: "gray", paddingX: 1, height: 3, width: "100%", children: [_jsxs(Text, { children: ["Built by ", _jsx(Text, { bold: true, children: "New York Compute" }), " \u2022 ", _jsx(Text, { color: "green", children: "newyorkcompute.xyz" })] }), _jsx(Text, { color: "gray", children: "[?] Help [q] Quit" })] }));
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=Footer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Footer.js","sourceRoot":"","sources":["../../src/components/Footer.tsx"],"names":[],"mappings":";AAAA;;;GAGG;AAEH,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAEhC,MAAM,UAAU,MAAM;IACpB,OAAO,CACL,MAAC,GAAG,IACF,aAAa,EAAC,KAAK,EACnB,cAAc,EAAC,eAAe,EAC9B,WAAW,EAAC,QAAQ,EACpB,WAAW,EAAC,MAAM,EAClB,QAAQ,EAAE,CAAC,EACX,MAAM,EAAE,CAAC,EACT,KAAK,EAAC,MAAM,aAEZ,MAAC,IAAI,4BACM,KAAC,IAAI,IAAC,IAAI,uCAAwB,cAAG,KAAC,IAAI,IAAC,KAAK,EAAC,OAAO,mCAA0B,IACtF,EACP,KAAC,IAAI,IAAC,KAAK,EAAC,MAAM,kCAAyB,IACvC,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Header
|
|
2
|
+
* Header Component
|
|
3
|
+
* Displays branding, balance, and connection status
|
|
3
4
|
*/
|
|
4
|
-
|
|
5
|
+
interface HeaderProps {
|
|
6
|
+
balance: number | null;
|
|
7
|
+
isConnected: boolean;
|
|
8
|
+
error: string | null;
|
|
9
|
+
}
|
|
10
|
+
export declare function Header({ balance, isConnected, error }: HeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
5
12
|
//# sourceMappingURL=Header.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Header.d.ts","sourceRoot":"","sources":["../../src/components/Header.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Header.d.ts","sourceRoot":"","sources":["../../src/components/Header.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,UAAU,WAAW;IACnB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC;IACrB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED,wBAAgB,MAAM,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,EAAE,WAAW,2CAqClE"}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
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
2
|
/**
|
|
7
|
-
* Header
|
|
3
|
+
* Header Component
|
|
4
|
+
* Displays branding, balance, and connection status
|
|
8
5
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
6
|
+
import { Box, Text } from 'ink';
|
|
7
|
+
export function Header({ balance, isConnected, error }) {
|
|
8
|
+
const formatCurrency = (cents) => `$${(cents / 100).toFixed(2)}`;
|
|
9
|
+
const balanceText = balance !== null ? formatCurrency(balance) : '—';
|
|
10
|
+
return (_jsxs(Box, { flexDirection: "row", justifyContent: "space-between", borderStyle: "single", borderColor: "gray", paddingX: 1, height: 3, width: "100%", children: [_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { color: "green", bold: true, children: "\u2588 KALSHI" }), _jsx(Text, { color: "gray", children: "NEW YORK COMPUTE" })] }), _jsxs(Box, { flexDirection: "column", alignItems: "flex-end", children: [_jsxs(Text, { children: ["Balance: ", _jsx(Text, { bold: true, children: balanceText })] }), _jsxs(Box, { children: [_jsx(Text, { color: isConnected ? 'green' : 'red', children: isConnected ? '●' : '○' }), _jsxs(Text, { color: "gray", children: [" ", isConnected ? 'connected' : 'disconnected'] })] }), error && (_jsx(Text, { color: "red", dimColor: true, children: error }))] })] }));
|
|
13
11
|
}
|
|
14
12
|
//# sourceMappingURL=Header.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Header.js","sourceRoot":"","sources":["../../src/components/Header.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Header.js","sourceRoot":"","sources":["../../src/components/Header.tsx"],"names":[],"mappings":";AAAA;;;GAGG;AAEH,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAQhC,MAAM,UAAU,MAAM,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAe;IACjE,MAAM,cAAc,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;IACzE,MAAM,WAAW,GAAG,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IAErE,OAAO,CACL,MAAC,GAAG,IACF,aAAa,EAAC,KAAK,EACnB,cAAc,EAAC,eAAe,EAC9B,WAAW,EAAC,QAAQ,EACpB,WAAW,EAAC,MAAM,EAClB,QAAQ,EAAE,CAAC,EACX,MAAM,EAAE,CAAC,EACT,KAAK,EAAC,MAAM,aAGZ,MAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,aACzB,KAAC,IAAI,IAAC,KAAK,EAAC,OAAO,EAAC,IAAI,oCAAgB,EACxC,KAAC,IAAI,IAAC,KAAK,EAAC,MAAM,iCAAwB,IACtC,EAGN,MAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,EAAC,UAAU,EAAC,UAAU,aAC/C,MAAC,IAAI,4BACM,KAAC,IAAI,IAAC,IAAI,kBAAE,WAAW,GAAQ,IACnC,EACP,MAAC,GAAG,eACF,KAAC,IAAI,IAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,YACvC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GACnB,EACP,MAAC,IAAI,IAAC,KAAK,EAAC,MAAM,kBAAG,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,cAAc,IAAQ,IACnE,EACL,KAAK,IAAI,CACR,KAAC,IAAI,IAAC,KAAK,EAAC,KAAK,EAAC,QAAQ,kBAAE,KAAK,GAAQ,CAC1C,IACG,IACF,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Markets Component
|
|
3
|
+
* Displays a scrollable list of markets with selection
|
|
4
|
+
*/
|
|
5
|
+
interface Market {
|
|
6
|
+
ticker: string;
|
|
7
|
+
title: string;
|
|
8
|
+
yes_bid?: number;
|
|
9
|
+
yes_ask?: number;
|
|
10
|
+
volume?: number;
|
|
11
|
+
close_time?: string;
|
|
12
|
+
previousYesBid?: number;
|
|
13
|
+
}
|
|
14
|
+
interface MarketsProps {
|
|
15
|
+
markets: Market[];
|
|
16
|
+
selectedIndex: number;
|
|
17
|
+
height: number;
|
|
18
|
+
}
|
|
19
|
+
export declare function Markets({ markets, selectedIndex, height }: MarketsProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=Markets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Markets.d.ts","sourceRoot":"","sources":["../../src/components/Markets.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,UAAU,MAAM;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,UAAU,YAAY;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,OAAO,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,EAAE,YAAY,2CA8EvE"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Markets Component
|
|
4
|
+
* Displays a scrollable list of markets with selection
|
|
5
|
+
*/
|
|
6
|
+
import { Box, Text } from 'ink';
|
|
7
|
+
import { formatExpiry, getPriceChange, formatPrice } from '../utils.js';
|
|
8
|
+
export function Markets({ markets, selectedIndex, height }) {
|
|
9
|
+
// Calculate visible window (scroll with selection)
|
|
10
|
+
const visibleRows = height - 4; // Border + title + padding
|
|
11
|
+
const halfWindow = Math.floor(visibleRows / 2);
|
|
12
|
+
let startIndex = Math.max(0, selectedIndex - halfWindow);
|
|
13
|
+
const maxStart = Math.max(0, markets.length - visibleRows);
|
|
14
|
+
startIndex = Math.min(startIndex, maxStart);
|
|
15
|
+
const visibleMarkets = markets.slice(startIndex, startIndex + visibleRows);
|
|
16
|
+
return (_jsxs(Box, { flexDirection: "column", borderStyle: "single", borderColor: "green", height: height, width: "100%", children: [_jsx(Box, { paddingX: 1, children: _jsx(Text, { color: "green", bold: true, children: " MARKETS " }) }), _jsx(Box, { flexDirection: "column", paddingX: 1, flexGrow: 1, children: markets.length === 0 ? (_jsx(Text, { color: "gray", children: "Loading markets..." })) : (visibleMarkets.map((market, i) => {
|
|
17
|
+
const actualIndex = startIndex + i;
|
|
18
|
+
const isSelected = actualIndex === selectedIndex;
|
|
19
|
+
const priceChange = getPriceChange(market.yes_bid, market.previousYesBid);
|
|
20
|
+
const expiry = formatExpiry(market.close_time);
|
|
21
|
+
return (_jsxs(Box, { justifyContent: "space-between", children: [_jsxs(Box, { children: [_jsx(Text, { color: isSelected ? 'green' : 'gray', children: isSelected ? '▶ ' : ' ' }), _jsx(Text, { color: isSelected ? 'green' : 'white', bold: isSelected, children: market.ticker.slice(0, 20) })] }), _jsxs(Box, { children: [expiry && (_jsx(Text, { color: "gray", dimColor: true, children: expiry.padStart(7) })), _jsx(Text, { color: isSelected ? 'green' : 'white', children: formatPrice(market.yes_bid).padStart(5) }), _jsxs(Text, { color: priceChange.color, children: [" ", priceChange.text] })] })] }, market.ticker));
|
|
22
|
+
})) }), markets.length > 0 && (_jsx(Box, { justifyContent: "center", paddingX: 1, children: _jsxs(Text, { color: "gray", children: [selectedIndex + 1, " of ", markets.length] }) }))] }));
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=Markets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Markets.js","sourceRoot":"","sources":["../../src/components/Markets.tsx"],"names":[],"mappings":";AAAA;;;GAGG;AAEH,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,EAAE,YAA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C,MAAC,IAAI,IAAC,KAAK,EAAC,MAAM,aACf,aAAa,GAAG,CAAC,UAAM,OAAO,CAAC,MAAM,IACjC,GACH,CACP,IACG,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -1,9 +1,22 @@
|
|
|
1
|
-
interface OrderbookProps {
|
|
2
|
-
ticker: string | null;
|
|
3
|
-
}
|
|
4
1
|
/**
|
|
5
|
-
* Orderbook
|
|
2
|
+
* Orderbook Component
|
|
3
|
+
* Visual depth chart showing bids and asks with spread indicator
|
|
6
4
|
*/
|
|
7
|
-
|
|
5
|
+
interface OrderbookData {
|
|
6
|
+
yes: [number, number][];
|
|
7
|
+
no: [number, number][];
|
|
8
|
+
}
|
|
9
|
+
interface SelectedMarket {
|
|
10
|
+
ticker: string;
|
|
11
|
+
title: string;
|
|
12
|
+
close_time?: string;
|
|
13
|
+
volume?: number;
|
|
14
|
+
}
|
|
15
|
+
interface OrderbookProps {
|
|
16
|
+
market: SelectedMarket | null;
|
|
17
|
+
orderbook: OrderbookData | null;
|
|
18
|
+
height: number;
|
|
19
|
+
}
|
|
20
|
+
export declare function Orderbook({ market, orderbook, height }: OrderbookProps): import("react/jsx-runtime").JSX.Element;
|
|
8
21
|
export {};
|
|
9
22
|
//# sourceMappingURL=Orderbook.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Orderbook.d.ts","sourceRoot":"","sources":["../../src/components/Orderbook.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Orderbook.d.ts","sourceRoot":"","sources":["../../src/components/Orderbook.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,UAAU,aAAa;IACrB,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;IACxB,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;CACxB;AAED,UAAU,cAAc;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,cAAc;IACtB,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC;IAC9B,SAAS,EAAE,aAAa,GAAG,IAAI,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,SAAS,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,cAAc,2CAiHtE"}
|
|
@@ -1,43 +1,32 @@
|
|
|
1
|
-
import {
|
|
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";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
6
2
|
/**
|
|
7
|
-
* Orderbook
|
|
3
|
+
* Orderbook Component
|
|
4
|
+
* Visual depth chart showing bids and asks with spread indicator
|
|
8
5
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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 || [])
|
|
6
|
+
import { Box, Text } from 'ink';
|
|
7
|
+
import { formatExpiry, formatVolume, formatPriceDecimal, calculateSpread } from '../utils.js';
|
|
8
|
+
export function Orderbook({ market, orderbook, height }) {
|
|
9
|
+
// Parse orderbook into asks (no side, converted to YES equivalent) and bids (yes side)
|
|
10
|
+
const asks = (orderbook?.no ?? [])
|
|
32
11
|
.slice(0, 5)
|
|
33
|
-
.
|
|
34
|
-
|
|
12
|
+
.map(([price, qty]) => ({ price: 100 - price, quantity: qty }))
|
|
13
|
+
.sort((a, b) => b.price - a.price);
|
|
14
|
+
const bids = (orderbook?.yes ?? [])
|
|
35
15
|
.slice(0, 5)
|
|
36
|
-
.
|
|
16
|
+
.map(([price, qty]) => ({ price, quantity: qty }))
|
|
17
|
+
.sort((a, b) => b.price - a.price);
|
|
37
18
|
// Calculate spread
|
|
38
|
-
const bestAsk = asks.length > 0 ? asks
|
|
39
|
-
const bestBid = bids.length > 0 ? bids
|
|
40
|
-
const spread =
|
|
41
|
-
|
|
19
|
+
const bestAsk = asks.length > 0 ? Math.min(...asks.map(a => a.price)) : null;
|
|
20
|
+
const bestBid = bids.length > 0 ? Math.max(...bids.map(b => b.price)) : null;
|
|
21
|
+
const spread = calculateSpread(bestBid, bestAsk);
|
|
22
|
+
// Calculate max quantity for bar scaling
|
|
23
|
+
const maxQty = Math.max(...asks.map(l => l.quantity), ...bids.map(l => l.quantity), 1);
|
|
24
|
+
const renderBar = (qty, color, maxWidth = 20) => {
|
|
25
|
+
const barLength = Math.min(Math.floor((qty / maxQty) * maxWidth), maxWidth);
|
|
26
|
+
return _jsx(Text, { color: color, children: '█'.repeat(barLength) });
|
|
27
|
+
};
|
|
28
|
+
const expiry = formatExpiry(market?.close_time);
|
|
29
|
+
const volume = formatVolume(market?.volume);
|
|
30
|
+
return (_jsxs(Box, { flexDirection: "column", borderStyle: "single", borderColor: "gray", height: height, width: "100%", children: [_jsxs(Box, { paddingX: 1, flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Text, { bold: true, children: " ORDERBOOK" }), _jsxs(Text, { color: "gray", children: [": ", market?.ticker || 'Select a market'] })] }), market?.title && (_jsxs(Text, { color: "cyan", wrap: "truncate", children: [market.title.slice(0, 50), market.title.length > 50 ? '…' : ''] })), market && (_jsxs(Box, { children: [expiry && (_jsxs(Text, { color: "yellow", children: ["\u23F1 ", expiry] })), volume && (_jsxs(Text, { color: "gray", children: [" Vol: ", volume] }))] }))] }), _jsx(Box, { flexDirection: "column", paddingX: 1, flexGrow: 1, children: !orderbook ? (_jsx(Text, { color: "gray", children: "Select a market to view orderbook" })) : (_jsxs(_Fragment, { children: [asks.map((level, i) => (_jsxs(Box, { justifyContent: "space-between", children: [_jsxs(Box, { children: [_jsx(Text, { color: "gray", children: "ASK " }), renderBar(level.quantity, 'red')] }), _jsxs(Box, { children: [_jsx(Text, { color: "red", children: formatPriceDecimal(level.price) }), _jsxs(Text, { color: "gray", children: [" (", level.quantity, ")"] })] })] }, `ask-${i}`))), _jsxs(Box, { marginY: 1, justifyContent: "space-between", children: [_jsx(Text, { color: "gray", children: '─'.repeat(30) }), spread !== null && (_jsxs(Text, { color: "yellow", bold: true, children: ["SPREAD: ", spread.toFixed(2), "\u00A2"] }))] }), bids.map((level, i) => (_jsxs(Box, { justifyContent: "space-between", children: [_jsxs(Box, { children: [_jsx(Text, { color: "gray", children: "BID " }), renderBar(level.quantity, 'green')] }), _jsxs(Box, { children: [_jsx(Text, { color: "green", children: formatPriceDecimal(level.price) }), _jsxs(Text, { color: "gray", children: [" (", level.quantity, ")"] })] })] }, `bid-${i}`)))] })) })] }));
|
|
42
31
|
}
|
|
43
32
|
//# sourceMappingURL=Orderbook.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Orderbook.js","sourceRoot":"","sources":["../../src/components/Orderbook.ts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K,EAAC,KAAK,YAAE,kBAAkB,CAAC,KAAK,CAAC,KAAK,CAAC,GAAQ,EAC1D,MAAC,IAAI,IAAC,KAAK,EAAC,MAAM,mBAAI,KAAK,CAAC,QAAQ,SAAS,IACzC,KARE,OAAO,CAAC,EAAE,CASd,CACP,CAAC,EAGF,MAAC,GAAG,IAAC,OAAO,EAAE,CAAC,EAAE,cAAc,EAAC,eAAe,aAC7C,KAAC,IAAI,IAAC,KAAK,EAAC,MAAM,YAAE,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,GAAQ,EACzC,MAAM,KAAK,IAAI,IAAI,CAClB,MAAC,IAAI,IAAC,KAAK,EAAC,QAAQ,EAAC,IAAI,+BACd,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,cACrB,CACR,IACG,EAGL,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,CACtB,MAAC,GAAG,IAAkB,cAAc,EAAC,eAAe,aAClD,MAAC,GAAG,eACF,KAAC,IAAI,IAAC,KAAK,EAAC,MAAM,qBAAY,EAC7B,SAAS,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,IAC/B,EACN,MAAC,GAAG,eACF,KAAC,IAAI,IAAC,KAAK,EAAC,OAAO,YAAE,kBAAkB,CAAC,KAAK,CAAC,KAAK,CAAC,GAAQ,EAC5D,MAAC,IAAI,IAAC,KAAK,EAAC,MAAM,mBAAI,KAAK,CAAC,QAAQ,SAAS,IACzC,KARE,OAAO,CAAC,EAAE,CASd,CACP,CAAC,IACD,CACJ,GACG,IACF,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Positions
|
|
2
|
+
* Positions Component
|
|
3
|
+
* Displays open positions with P&L
|
|
3
4
|
*/
|
|
4
|
-
|
|
5
|
+
interface Position {
|
|
6
|
+
ticker: string;
|
|
7
|
+
position: number;
|
|
8
|
+
market_exposure: number;
|
|
9
|
+
}
|
|
10
|
+
interface PositionsProps {
|
|
11
|
+
positions: Position[];
|
|
12
|
+
height: number;
|
|
13
|
+
}
|
|
14
|
+
export declare function Positions({ positions, height }: PositionsProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export {};
|
|
5
16
|
//# sourceMappingURL=Positions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Positions.d.ts","sourceRoot":"","sources":["../../src/components/Positions.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Positions.d.ts","sourceRoot":"","sources":["../../src/components/Positions.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,UAAU,QAAQ;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,UAAU,cAAc;IACtB,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,SAAS,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,cAAc,2CAyC9D"}
|