@gaberoo/kalshitools 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +91 -27
- package/dist/commands/config/init.js +4 -4
- package/dist/commands/config/show.js +5 -5
- package/dist/commands/markets/list.d.ts +5 -1
- package/dist/commands/markets/list.js +28 -8
- package/dist/commands/markets/orderbook.d.ts +13 -0
- package/dist/commands/markets/orderbook.js +83 -0
- package/dist/commands/markets/show.d.ts +3 -3
- package/dist/commands/markets/show.js +7 -7
- package/dist/commands/orders/cancel.d.ts +3 -3
- package/dist/commands/orders/cancel.js +7 -7
- package/dist/commands/orders/create.d.ts +5 -5
- package/dist/commands/orders/create.js +33 -33
- package/dist/commands/orders/list.d.ts +1 -1
- package/dist/commands/orders/list.js +9 -9
- package/dist/commands/portfolio/fills.d.ts +1 -1
- package/dist/commands/portfolio/fills.js +7 -7
- package/dist/commands/portfolio/positions.d.ts +1 -0
- package/dist/commands/portfolio/positions.js +11 -2
- package/dist/lib/base-command.d.ts +2 -2
- package/dist/lib/base-command.js +8 -8
- package/dist/lib/config/manager.d.ts +25 -25
- package/dist/lib/config/manager.js +51 -51
- package/dist/lib/config/schema.d.ts +11 -11
- package/dist/lib/config/schema.js +6 -6
- package/dist/lib/errors/base.d.ts +10 -10
- package/dist/lib/errors/base.js +7 -7
- package/dist/lib/kalshi/auth.d.ts +4 -4
- package/dist/lib/kalshi/auth.js +24 -24
- package/dist/lib/kalshi/client.d.ts +35 -35
- package/dist/lib/kalshi/client.js +93 -91
- package/dist/lib/kalshi/index.d.ts +1 -1
- package/dist/lib/kalshi/index.js +1 -1
- package/dist/lib/kalshi/types.d.ts +53 -53
- package/dist/lib/logger.js +3 -3
- package/dist/lib/output/formatter.d.ts +20 -20
- package/dist/lib/output/formatter.js +55 -55
- package/dist/lib/retry.d.ts +2 -2
- package/dist/lib/retry.js +8 -10
- package/dist/lib/sanitize.js +9 -9
- package/dist/lib/shutdown.d.ts +4 -4
- package/dist/lib/shutdown.js +7 -7
- package/dist/lib/validation.d.ts +5 -5
- package/dist/lib/validation.js +14 -20
- package/oclif.manifest.json +138 -47
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,11 +9,13 @@ A powerful CLI tool for interacting with the Kalshi prediction markets API. Buil
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
11
11
|
- 🔐 **Secure Authentication**: RSA-PSS based authentication with secure credential storage
|
|
12
|
-
- 📊 **Market Data**: Browse
|
|
13
|
-
- 💼 **Portfolio Management**: View balances
|
|
14
|
-
- 📈 **Trading**: Place and manage orders with safety features
|
|
15
|
-
- 🤖 **AI-Friendly**: Structured JSON output for automated systems
|
|
12
|
+
- 📊 **Market Data**: Browse markets, view order books, filter by event/series, batch queries
|
|
13
|
+
- 💼 **Portfolio Management**: View balances, positions with P&L, settlement status filtering
|
|
14
|
+
- 📈 **Trading**: Place and manage orders with safety features, dry-run mode
|
|
15
|
+
- 🤖 **AI-Friendly**: Structured JSON output for automated systems (OpenClaw integration ready)
|
|
16
16
|
- 🛡️ **Safety First**: Demo environment default, confirmations, and order limits
|
|
17
|
+
- 📈 **Order Book Analysis**: Real-time order depth and liquidity assessment
|
|
18
|
+
- 🔍 **Market Discovery**: Event/series filtering, nested markets, multi-ticker batch queries
|
|
17
19
|
|
|
18
20
|
## Quick Start
|
|
19
21
|
|
|
@@ -83,10 +85,22 @@ kalshitools markets list --status active
|
|
|
83
85
|
# Get market details
|
|
84
86
|
kalshitools markets show TICKER-SYMBOL
|
|
85
87
|
|
|
88
|
+
# View order book for liquidity analysis
|
|
89
|
+
kalshitools markets orderbook TICKER-SYMBOL --depth 5
|
|
90
|
+
|
|
91
|
+
# Discover markets within an event
|
|
92
|
+
kalshitools markets list --event-ticker EVENT-ID
|
|
93
|
+
|
|
94
|
+
# Batch query multiple tickers
|
|
95
|
+
kalshitools markets list --tickers "TICKER1,TICKER2,TICKER3"
|
|
96
|
+
|
|
86
97
|
# View your portfolio
|
|
87
98
|
kalshitools portfolio balance
|
|
88
99
|
kalshitools portfolio positions
|
|
89
100
|
|
|
101
|
+
# Filter positions by settlement status
|
|
102
|
+
kalshitools portfolio positions --settlement-status open
|
|
103
|
+
|
|
90
104
|
# Place an order (with confirmation)
|
|
91
105
|
kalshitools orders create \
|
|
92
106
|
--ticker MARKET-TICKER \
|
|
@@ -149,7 +163,11 @@ export LOG_LEVEL=info
|
|
|
149
163
|
* [List active markets](#list-active-markets)
|
|
150
164
|
* [View available markets](#view-available-markets)
|
|
151
165
|
* [Get market details](#get-market-details)
|
|
166
|
+
* [View order book for liquidity analysis](#view-order-book-for-liquidity-analysis)
|
|
167
|
+
* [Discover markets within an event](#discover-markets-within-an-event)
|
|
168
|
+
* [Batch query multiple tickers](#batch-query-multiple-tickers)
|
|
152
169
|
* [View your portfolio](#view-your-portfolio)
|
|
170
|
+
* [Filter positions by settlement status](#filter-positions-by-settlement-status)
|
|
153
171
|
* [Place an order (with confirmation)](#place-an-order-with-confirmation)
|
|
154
172
|
* [Use --dry-run to simulate without placing order](#use---dry-run-to-simulate-without-placing-order)
|
|
155
173
|
* [View order history](#view-order-history)
|
|
@@ -163,7 +181,7 @@ $ npm install -g @gaberoo/kalshitools
|
|
|
163
181
|
$ kalshitools COMMAND
|
|
164
182
|
running command...
|
|
165
183
|
$ kalshitools (--version)
|
|
166
|
-
@gaberoo/kalshitools/1.0.
|
|
184
|
+
@gaberoo/kalshitools/1.0.3 darwin-arm64 node-v22.20.0
|
|
167
185
|
$ kalshitools --help [COMMAND]
|
|
168
186
|
USAGE
|
|
169
187
|
$ kalshitools COMMAND
|
|
@@ -176,6 +194,7 @@ USAGE
|
|
|
176
194
|
* [`kalshitools config show`](#kalshitools-config-show)
|
|
177
195
|
* [`kalshitools help [COMMAND]`](#kalshitools-help-command)
|
|
178
196
|
* [`kalshitools markets list`](#kalshitools-markets-list)
|
|
197
|
+
* [`kalshitools markets orderbook TICKER`](#kalshitools-markets-orderbook-ticker)
|
|
179
198
|
* [`kalshitools markets show TICKER`](#kalshitools-markets-show-ticker)
|
|
180
199
|
* [`kalshitools orders cancel ORDERID`](#kalshitools-orders-cancel-orderid)
|
|
181
200
|
* [`kalshitools orders create`](#kalshitools-orders-create)
|
|
@@ -218,7 +237,7 @@ EXAMPLES
|
|
|
218
237
|
$ kalshitools config init --env production
|
|
219
238
|
```
|
|
220
239
|
|
|
221
|
-
_See code: [src/commands/config/init.ts](https://github.com/kalshitools/kalshitools/blob/v1.0.
|
|
240
|
+
_See code: [src/commands/config/init.ts](https://github.com/kalshitools/kalshitools/blob/v1.0.3/src/commands/config/init.ts)_
|
|
222
241
|
|
|
223
242
|
## `kalshitools config show`
|
|
224
243
|
|
|
@@ -240,7 +259,7 @@ EXAMPLES
|
|
|
240
259
|
$ kalshitools config show --json
|
|
241
260
|
```
|
|
242
261
|
|
|
243
|
-
_See code: [src/commands/config/show.ts](https://github.com/kalshitools/kalshitools/blob/v1.0.
|
|
262
|
+
_See code: [src/commands/config/show.ts](https://github.com/kalshitools/kalshitools/blob/v1.0.3/src/commands/config/show.ts)_
|
|
244
263
|
|
|
245
264
|
## `kalshitools help [COMMAND]`
|
|
246
265
|
|
|
@@ -268,13 +287,18 @@ List prediction markets
|
|
|
268
287
|
|
|
269
288
|
```
|
|
270
289
|
USAGE
|
|
271
|
-
$ kalshitools markets list [--json] [--
|
|
290
|
+
$ kalshitools markets list [--json] [--event-ticker <value>] [--limit <value>] [--series-ticker <value>]
|
|
291
|
+
[--status active|closed|settled|finalized] [--tickers <value>] [--with-nested]
|
|
272
292
|
|
|
273
293
|
FLAGS
|
|
274
|
-
--
|
|
275
|
-
--
|
|
276
|
-
--
|
|
277
|
-
|
|
294
|
+
--event-ticker=<value> Filter by event ticker
|
|
295
|
+
--json Output in JSON format
|
|
296
|
+
--limit=<value> [default: 20] Maximum number of markets to return
|
|
297
|
+
--series-ticker=<value> Filter by series ticker
|
|
298
|
+
--status=<option> Filter by market status
|
|
299
|
+
<options: active|closed|settled|finalized>
|
|
300
|
+
--tickers=<value> Comma-separated list of tickers to fetch
|
|
301
|
+
--with-nested Include nested markets
|
|
278
302
|
|
|
279
303
|
DESCRIPTION
|
|
280
304
|
List prediction markets
|
|
@@ -284,10 +308,44 @@ EXAMPLES
|
|
|
284
308
|
|
|
285
309
|
$ kalshitools markets list --status active --limit 10
|
|
286
310
|
|
|
311
|
+
$ kalshitools markets list --event-ticker ELECTION-2024
|
|
312
|
+
|
|
313
|
+
$ kalshitools markets list --tickers "TICKER1,TICKER2,TICKER3"
|
|
314
|
+
|
|
315
|
+
$ kalshitools markets list --with-nested
|
|
316
|
+
|
|
287
317
|
$ kalshitools markets list --json
|
|
288
318
|
```
|
|
289
319
|
|
|
290
|
-
_See code: [src/commands/markets/list.ts](https://github.com/kalshitools/kalshitools/blob/v1.0.
|
|
320
|
+
_See code: [src/commands/markets/list.ts](https://github.com/kalshitools/kalshitools/blob/v1.0.3/src/commands/markets/list.ts)_
|
|
321
|
+
|
|
322
|
+
## `kalshitools markets orderbook TICKER`
|
|
323
|
+
|
|
324
|
+
Show order book for a market
|
|
325
|
+
|
|
326
|
+
```
|
|
327
|
+
USAGE
|
|
328
|
+
$ kalshitools markets orderbook TICKER [--json] [--depth <value>]
|
|
329
|
+
|
|
330
|
+
ARGUMENTS
|
|
331
|
+
TICKER Market ticker symbol
|
|
332
|
+
|
|
333
|
+
FLAGS
|
|
334
|
+
--depth=<value> [default: 10] Number of price levels to show
|
|
335
|
+
--json Output in JSON format
|
|
336
|
+
|
|
337
|
+
DESCRIPTION
|
|
338
|
+
Show order book for a market
|
|
339
|
+
|
|
340
|
+
EXAMPLES
|
|
341
|
+
$ kalshitools markets orderbook TICKER
|
|
342
|
+
|
|
343
|
+
$ kalshitools markets orderbook TICKER --depth 5
|
|
344
|
+
|
|
345
|
+
$ kalshitools markets orderbook TICKER --json
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
_See code: [src/commands/markets/orderbook.ts](https://github.com/kalshitools/kalshitools/blob/v1.0.3/src/commands/markets/orderbook.ts)_
|
|
291
349
|
|
|
292
350
|
## `kalshitools markets show TICKER`
|
|
293
351
|
|
|
@@ -312,7 +370,7 @@ EXAMPLES
|
|
|
312
370
|
$ kalshitools markets show TICKER --json
|
|
313
371
|
```
|
|
314
372
|
|
|
315
|
-
_See code: [src/commands/markets/show.ts](https://github.com/kalshitools/kalshitools/blob/v1.0.
|
|
373
|
+
_See code: [src/commands/markets/show.ts](https://github.com/kalshitools/kalshitools/blob/v1.0.3/src/commands/markets/show.ts)_
|
|
316
374
|
|
|
317
375
|
## `kalshitools orders cancel ORDERID`
|
|
318
376
|
|
|
@@ -340,7 +398,7 @@ EXAMPLES
|
|
|
340
398
|
$ kalshitools orders cancel ORDER_ID --json
|
|
341
399
|
```
|
|
342
400
|
|
|
343
|
-
_See code: [src/commands/orders/cancel.ts](https://github.com/kalshitools/kalshitools/blob/v1.0.
|
|
401
|
+
_See code: [src/commands/orders/cancel.ts](https://github.com/kalshitools/kalshitools/blob/v1.0.3/src/commands/orders/cancel.ts)_
|
|
344
402
|
|
|
345
403
|
## `kalshitools orders create`
|
|
346
404
|
|
|
@@ -348,8 +406,8 @@ Create a new order (buy or sell contracts)
|
|
|
348
406
|
|
|
349
407
|
```
|
|
350
408
|
USAGE
|
|
351
|
-
$ kalshitools orders create -
|
|
352
|
-
|
|
409
|
+
$ kalshitools orders create -a buy|sell -q <value> -s yes|no -t <value> [--json] [--dry-run] [-p <value>] [--type
|
|
410
|
+
market|limit] [-y]
|
|
353
411
|
|
|
354
412
|
FLAGS
|
|
355
413
|
-a, --action=<option> (required) Order action (buy or sell)
|
|
@@ -378,7 +436,7 @@ EXAMPLES
|
|
|
378
436
|
$ kalshitools orders create --ticker TICKER --action buy --side yes --quantity 100 --dry-run
|
|
379
437
|
```
|
|
380
438
|
|
|
381
|
-
_See code: [src/commands/orders/create.ts](https://github.com/kalshitools/kalshitools/blob/v1.0.
|
|
439
|
+
_See code: [src/commands/orders/create.ts](https://github.com/kalshitools/kalshitools/blob/v1.0.3/src/commands/orders/create.ts)_
|
|
382
440
|
|
|
383
441
|
## `kalshitools orders list`
|
|
384
442
|
|
|
@@ -386,8 +444,8 @@ List orders
|
|
|
386
444
|
|
|
387
445
|
```
|
|
388
446
|
USAGE
|
|
389
|
-
$ kalshitools orders list [--json] [--status pending|resting|canceled|executed|expired]
|
|
390
|
-
[--
|
|
447
|
+
$ kalshitools orders list [--json] [--limit <value>] [--status pending|resting|canceled|executed|expired]
|
|
448
|
+
[--ticker <value>]
|
|
391
449
|
|
|
392
450
|
FLAGS
|
|
393
451
|
--json Output in JSON format
|
|
@@ -409,7 +467,7 @@ EXAMPLES
|
|
|
409
467
|
$ kalshitools orders list --json
|
|
410
468
|
```
|
|
411
469
|
|
|
412
|
-
_See code: [src/commands/orders/list.ts](https://github.com/kalshitools/kalshitools/blob/v1.0.
|
|
470
|
+
_See code: [src/commands/orders/list.ts](https://github.com/kalshitools/kalshitools/blob/v1.0.3/src/commands/orders/list.ts)_
|
|
413
471
|
|
|
414
472
|
## `kalshitools plugins`
|
|
415
473
|
|
|
@@ -721,7 +779,7 @@ EXAMPLES
|
|
|
721
779
|
$ kalshitools portfolio balance --json
|
|
722
780
|
```
|
|
723
781
|
|
|
724
|
-
_See code: [src/commands/portfolio/balance.ts](https://github.com/kalshitools/kalshitools/blob/v1.0.
|
|
782
|
+
_See code: [src/commands/portfolio/balance.ts](https://github.com/kalshitools/kalshitools/blob/v1.0.3/src/commands/portfolio/balance.ts)_
|
|
725
783
|
|
|
726
784
|
## `kalshitools portfolio fills`
|
|
727
785
|
|
|
@@ -729,7 +787,7 @@ View trade history (fills)
|
|
|
729
787
|
|
|
730
788
|
```
|
|
731
789
|
USAGE
|
|
732
|
-
$ kalshitools portfolio fills [--json] [--
|
|
790
|
+
$ kalshitools portfolio fills [--json] [--limit <value>] [--ticker <value>]
|
|
733
791
|
|
|
734
792
|
FLAGS
|
|
735
793
|
--json Output in JSON format
|
|
@@ -749,7 +807,7 @@ EXAMPLES
|
|
|
749
807
|
$ kalshitools portfolio fills --json
|
|
750
808
|
```
|
|
751
809
|
|
|
752
|
-
_See code: [src/commands/portfolio/fills.ts](https://github.com/kalshitools/kalshitools/blob/v1.0.
|
|
810
|
+
_See code: [src/commands/portfolio/fills.ts](https://github.com/kalshitools/kalshitools/blob/v1.0.3/src/commands/portfolio/fills.ts)_
|
|
753
811
|
|
|
754
812
|
## `kalshitools portfolio positions`
|
|
755
813
|
|
|
@@ -757,10 +815,12 @@ View current positions with P&L
|
|
|
757
815
|
|
|
758
816
|
```
|
|
759
817
|
USAGE
|
|
760
|
-
$ kalshitools portfolio positions [--json]
|
|
818
|
+
$ kalshitools portfolio positions [--json] [--settlement-status open|pending|settled]
|
|
761
819
|
|
|
762
820
|
FLAGS
|
|
763
|
-
--json
|
|
821
|
+
--json Output in JSON format
|
|
822
|
+
--settlement-status=<option> Filter by settlement status
|
|
823
|
+
<options: open|pending|settled>
|
|
764
824
|
|
|
765
825
|
DESCRIPTION
|
|
766
826
|
View current positions with P&L
|
|
@@ -768,8 +828,12 @@ DESCRIPTION
|
|
|
768
828
|
EXAMPLES
|
|
769
829
|
$ kalshitools portfolio positions
|
|
770
830
|
|
|
831
|
+
$ kalshitools portfolio positions --settlement-status open
|
|
832
|
+
|
|
833
|
+
$ kalshitools portfolio positions --settlement-status settled
|
|
834
|
+
|
|
771
835
|
$ kalshitools portfolio positions --json
|
|
772
836
|
```
|
|
773
837
|
|
|
774
|
-
_See code: [src/commands/portfolio/positions.ts](https://github.com/kalshitools/kalshitools/blob/v1.0.
|
|
838
|
+
_See code: [src/commands/portfolio/positions.ts](https://github.com/kalshitools/kalshitools/blob/v1.0.3/src/commands/portfolio/positions.ts)_
|
|
775
839
|
<!-- commandsstop -->
|
|
@@ -12,9 +12,9 @@ export default class ConfigInit extends BaseCommand {
|
|
|
12
12
|
static flags = {
|
|
13
13
|
...BaseCommand.baseFlags,
|
|
14
14
|
env: Flags.string({
|
|
15
|
+
default: 'demo',
|
|
15
16
|
description: 'Environment to configure (demo or production)',
|
|
16
17
|
options: ['demo', 'production'],
|
|
17
|
-
default: 'demo',
|
|
18
18
|
}),
|
|
19
19
|
keyId: Flags.string({
|
|
20
20
|
description: 'API key ID (email)',
|
|
@@ -28,8 +28,8 @@ export default class ConfigInit extends BaseCommand {
|
|
|
28
28
|
const configManager = getConfig();
|
|
29
29
|
// Interactive prompts
|
|
30
30
|
const env = flags.env || 'demo';
|
|
31
|
-
let keyId = flags
|
|
32
|
-
let privateKeyPath = flags
|
|
31
|
+
let { keyId } = flags;
|
|
32
|
+
let { privateKeyPath } = flags;
|
|
33
33
|
// If not provided via flags, prompt the user
|
|
34
34
|
if (!keyId) {
|
|
35
35
|
keyId = await this.promptForInput('API Key ID (email)');
|
|
@@ -45,10 +45,10 @@ export default class ConfigInit extends BaseCommand {
|
|
|
45
45
|
configManager.setEnvironment(env);
|
|
46
46
|
if (flags.json) {
|
|
47
47
|
this.formatter.success({
|
|
48
|
+
configPath: configManager.getConfigPath(),
|
|
48
49
|
environment: env,
|
|
49
50
|
keyId,
|
|
50
51
|
privateKeyPath,
|
|
51
|
-
configPath: configManager.getConfigPath(),
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
else {
|
|
@@ -14,25 +14,25 @@ export default class ConfigShow extends BaseCommand {
|
|
|
14
14
|
const env = configManager.getEnvironment();
|
|
15
15
|
// Redact sensitive information
|
|
16
16
|
const safeConfig = {
|
|
17
|
-
version: config.version,
|
|
18
|
-
environment: env,
|
|
19
|
-
configPath: configManager.getConfigPath(),
|
|
20
17
|
api: {
|
|
21
18
|
demo: {
|
|
22
19
|
baseUrl: config.api.demo.baseUrl,
|
|
20
|
+
configured: Boolean(config.api.demo.keyId && config.api.demo.privateKeyPath),
|
|
23
21
|
keyId: config.api.demo.keyId ? this.redact(config.api.demo.keyId) : undefined,
|
|
24
22
|
privateKeyPath: config.api.demo.privateKeyPath,
|
|
25
|
-
configured: Boolean(config.api.demo.keyId && config.api.demo.privateKeyPath),
|
|
26
23
|
},
|
|
27
24
|
production: {
|
|
28
25
|
baseUrl: config.api.production.baseUrl,
|
|
26
|
+
configured: Boolean(config.api.production.keyId && config.api.production.privateKeyPath),
|
|
29
27
|
keyId: config.api.production.keyId ? this.redact(config.api.production.keyId) : undefined,
|
|
30
28
|
privateKeyPath: config.api.production.privateKeyPath,
|
|
31
|
-
configured: Boolean(config.api.production.keyId && config.api.production.privateKeyPath),
|
|
32
29
|
},
|
|
33
30
|
},
|
|
31
|
+
configPath: configManager.getConfigPath(),
|
|
32
|
+
environment: env,
|
|
34
33
|
output: config.output,
|
|
35
34
|
trading: config.trading,
|
|
35
|
+
version: config.version,
|
|
36
36
|
};
|
|
37
37
|
if (this.formatter.isJSONMode()) {
|
|
38
38
|
this.formatter.success(safeConfig);
|
|
@@ -3,8 +3,12 @@ export default class MarketsList extends BaseCommand {
|
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
|
-
|
|
6
|
+
'event-ticker': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
7
|
limit: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
'series-ticker': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
status: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
tickers: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
'with-nested': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
12
|
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
13
|
};
|
|
10
14
|
run(): Promise<void>;
|
|
@@ -8,17 +8,33 @@ export default class MarketsList extends BaseCommand {
|
|
|
8
8
|
static examples = [
|
|
9
9
|
'<%= config.bin %> <%= command.id %>',
|
|
10
10
|
'<%= config.bin %> <%= command.id %> --status active --limit 10',
|
|
11
|
+
'<%= config.bin %> <%= command.id %> --event-ticker ELECTION-2024',
|
|
12
|
+
'<%= config.bin %> <%= command.id %> --tickers "TICKER1,TICKER2,TICKER3"',
|
|
13
|
+
'<%= config.bin %> <%= command.id %> --with-nested',
|
|
11
14
|
'<%= config.bin %> <%= command.id %> --json',
|
|
12
15
|
];
|
|
13
16
|
static flags = {
|
|
14
17
|
...BaseCommand.baseFlags,
|
|
18
|
+
'event-ticker': Flags.string({
|
|
19
|
+
description: 'Filter by event ticker',
|
|
20
|
+
}),
|
|
21
|
+
limit: Flags.integer({
|
|
22
|
+
default: 20,
|
|
23
|
+
description: 'Maximum number of markets to return',
|
|
24
|
+
}),
|
|
25
|
+
'series-ticker': Flags.string({
|
|
26
|
+
description: 'Filter by series ticker',
|
|
27
|
+
}),
|
|
15
28
|
status: Flags.string({
|
|
16
29
|
description: 'Filter by market status',
|
|
17
30
|
options: ['active', 'closed', 'settled', 'finalized'],
|
|
18
31
|
}),
|
|
19
|
-
|
|
20
|
-
description: '
|
|
21
|
-
|
|
32
|
+
'tickers': Flags.string({
|
|
33
|
+
description: 'Comma-separated list of tickers to fetch',
|
|
34
|
+
}),
|
|
35
|
+
'with-nested': Flags.boolean({
|
|
36
|
+
default: false,
|
|
37
|
+
description: 'Include nested markets',
|
|
22
38
|
}),
|
|
23
39
|
};
|
|
24
40
|
async run() {
|
|
@@ -28,12 +44,16 @@ export default class MarketsList extends BaseCommand {
|
|
|
28
44
|
const client = createClientFromConfig();
|
|
29
45
|
// Fetch markets
|
|
30
46
|
const result = await client.getMarkets({
|
|
31
|
-
|
|
47
|
+
event_ticker: flags['event-ticker'],
|
|
32
48
|
limit: flags.limit,
|
|
49
|
+
series_ticker: flags['series-ticker'],
|
|
50
|
+
status: flags.status,
|
|
51
|
+
tickers: flags.tickers,
|
|
52
|
+
with_nested_markets: flags['with-nested'],
|
|
33
53
|
});
|
|
34
|
-
const markets = result
|
|
54
|
+
const { markets } = result;
|
|
35
55
|
if (this.formatter.isJSONMode()) {
|
|
36
|
-
this.formatter.success({
|
|
56
|
+
this.formatter.success({ cursor: result.cursor, markets });
|
|
37
57
|
}
|
|
38
58
|
else {
|
|
39
59
|
if (markets.length === 0) {
|
|
@@ -46,8 +66,8 @@ export default class MarketsList extends BaseCommand {
|
|
|
46
66
|
market.ticker,
|
|
47
67
|
market.title.length > 50 ? market.title.slice(0, 47) + '...' : market.title,
|
|
48
68
|
market.status,
|
|
49
|
-
market.last_price
|
|
50
|
-
market.volume_24h
|
|
69
|
+
market.last_price === undefined ? 'N/A' : market.last_price.toFixed(2),
|
|
70
|
+
market.volume_24h === undefined ? 'N/A' : market.volume_24h.toLocaleString(),
|
|
51
71
|
]);
|
|
52
72
|
this.formatter.outputTable(['Ticker', 'Title', 'Status', 'Price', 'Volume 24h'], rows);
|
|
53
73
|
if (result.cursor) {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseCommand } from '../../lib/base-command.js';
|
|
2
|
+
export default class MarketsOrderbook extends BaseCommand {
|
|
3
|
+
static args: {
|
|
4
|
+
ticker: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static description: string;
|
|
7
|
+
static examples: string[];
|
|
8
|
+
static flags: {
|
|
9
|
+
depth: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
};
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { BaseCommand } from '../../lib/base-command.js';
|
|
4
|
+
import { createClientFromConfig } from '../../lib/kalshi/index.js';
|
|
5
|
+
import { logger } from '../../lib/logger.js';
|
|
6
|
+
export default class MarketsOrderbook extends BaseCommand {
|
|
7
|
+
static args = {
|
|
8
|
+
ticker: Args.string({
|
|
9
|
+
description: 'Market ticker symbol',
|
|
10
|
+
required: true,
|
|
11
|
+
}),
|
|
12
|
+
};
|
|
13
|
+
static description = 'Show order book for a market';
|
|
14
|
+
static examples = [
|
|
15
|
+
'<%= config.bin %> <%= command.id %> TICKER',
|
|
16
|
+
'<%= config.bin %> <%= command.id %> TICKER --depth 5',
|
|
17
|
+
'<%= config.bin %> <%= command.id %> TICKER --json',
|
|
18
|
+
];
|
|
19
|
+
static flags = {
|
|
20
|
+
...BaseCommand.baseFlags,
|
|
21
|
+
depth: Flags.integer({
|
|
22
|
+
default: 10,
|
|
23
|
+
description: 'Number of price levels to show',
|
|
24
|
+
}),
|
|
25
|
+
};
|
|
26
|
+
async run() {
|
|
27
|
+
const { args, flags } = await this.parse(MarketsOrderbook);
|
|
28
|
+
try {
|
|
29
|
+
// Create API client from configuration
|
|
30
|
+
const client = createClientFromConfig();
|
|
31
|
+
// Fetch order book
|
|
32
|
+
const orderbook = await client.getOrderBook(args.ticker, flags.depth);
|
|
33
|
+
if (this.formatter.isJSONMode()) {
|
|
34
|
+
this.formatter.success(orderbook);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
// Human-readable output
|
|
38
|
+
this.log(chalk.cyan.bold(`Order Book: ${orderbook.ticker}`));
|
|
39
|
+
this.log();
|
|
40
|
+
// YES Side (Buy)
|
|
41
|
+
this.log(chalk.green.bold('YES Side (Buy)'));
|
|
42
|
+
if (orderbook.yes.length === 0) {
|
|
43
|
+
this.log(chalk.gray(' No orders'));
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
const yesRows = orderbook.yes.map((level) => [
|
|
47
|
+
level.price.toFixed(2),
|
|
48
|
+
level.count.toString(),
|
|
49
|
+
(level.price * level.count).toFixed(2),
|
|
50
|
+
]);
|
|
51
|
+
this.formatter.outputTable(['Price', 'Quantity', 'Total'], yesRows);
|
|
52
|
+
}
|
|
53
|
+
this.log();
|
|
54
|
+
// NO Side (Sell)
|
|
55
|
+
this.log(chalk.red.bold('NO Side (Sell)'));
|
|
56
|
+
if (orderbook.no.length === 0) {
|
|
57
|
+
this.log(chalk.gray(' No orders'));
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
const noRows = orderbook.no.map((level) => [
|
|
61
|
+
level.price.toFixed(2),
|
|
62
|
+
level.count.toString(),
|
|
63
|
+
(level.price * level.count).toFixed(2),
|
|
64
|
+
]);
|
|
65
|
+
this.formatter.outputTable(['Price', 'Quantity', 'Total'], noRows);
|
|
66
|
+
}
|
|
67
|
+
// Calculate and display spread if both sides have orders
|
|
68
|
+
if (orderbook.yes.length > 0 && orderbook.no.length > 0) {
|
|
69
|
+
const bestYes = orderbook.yes[0].price;
|
|
70
|
+
const bestNo = orderbook.no[0].price;
|
|
71
|
+
const spread = Math.abs(bestYes - bestNo);
|
|
72
|
+
const spreadPct = ((spread / ((bestYes + bestNo) / 2)) * 100).toFixed(1);
|
|
73
|
+
this.log();
|
|
74
|
+
this.log(`${chalk.cyan('Spread:')} ${spread.toFixed(2)} (${spreadPct}%)`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
logger.info({ depth: flags.depth, ticker: args.ticker }, 'Order book fetched successfully');
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
throw error;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { BaseCommand } from '../../lib/base-command.js';
|
|
2
2
|
export default class MarketsShow extends BaseCommand {
|
|
3
|
+
static args: {
|
|
4
|
+
ticker: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
3
6
|
static description: string;
|
|
4
7
|
static examples: string[];
|
|
5
8
|
static flags: {
|
|
6
9
|
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
7
10
|
};
|
|
8
|
-
static args: {
|
|
9
|
-
ticker: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
10
|
-
};
|
|
11
11
|
run(): Promise<void>;
|
|
12
12
|
private formatStatus;
|
|
13
13
|
}
|
|
@@ -4,6 +4,12 @@ import { BaseCommand } from '../../lib/base-command.js';
|
|
|
4
4
|
import { createClientFromConfig } from '../../lib/kalshi/index.js';
|
|
5
5
|
import { logger } from '../../lib/logger.js';
|
|
6
6
|
export default class MarketsShow extends BaseCommand {
|
|
7
|
+
static args = {
|
|
8
|
+
ticker: Args.string({
|
|
9
|
+
description: 'Market ticker symbol',
|
|
10
|
+
required: true,
|
|
11
|
+
}),
|
|
12
|
+
};
|
|
7
13
|
static description = 'Show market details';
|
|
8
14
|
static examples = [
|
|
9
15
|
'<%= config.bin %> <%= command.id %> TICKER',
|
|
@@ -12,12 +18,6 @@ export default class MarketsShow extends BaseCommand {
|
|
|
12
18
|
static flags = {
|
|
13
19
|
...BaseCommand.baseFlags,
|
|
14
20
|
};
|
|
15
|
-
static args = {
|
|
16
|
-
ticker: Args.string({
|
|
17
|
-
description: 'Market ticker symbol',
|
|
18
|
-
required: true,
|
|
19
|
-
}),
|
|
20
|
-
};
|
|
21
21
|
async run() {
|
|
22
22
|
const { args } = await this.parse(MarketsShow);
|
|
23
23
|
try {
|
|
@@ -70,8 +70,8 @@ export default class MarketsShow extends BaseCommand {
|
|
|
70
70
|
const colors = {
|
|
71
71
|
active: chalk.green,
|
|
72
72
|
closed: chalk.yellow,
|
|
73
|
-
settled: chalk.blue,
|
|
74
73
|
finalized: chalk.gray,
|
|
74
|
+
settled: chalk.blue,
|
|
75
75
|
};
|
|
76
76
|
const colorFn = colors[status] || chalk.white;
|
|
77
77
|
return colorFn(status);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { BaseCommand } from '../../lib/base-command.js';
|
|
2
2
|
export default class OrdersCancel extends BaseCommand {
|
|
3
|
+
static args: {
|
|
4
|
+
orderId: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
3
6
|
static description: string;
|
|
4
7
|
static examples: string[];
|
|
5
8
|
static flags: {
|
|
6
9
|
yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
7
10
|
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
11
|
};
|
|
9
|
-
static args: {
|
|
10
|
-
orderId: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
11
|
-
};
|
|
12
12
|
run(): Promise<void>;
|
|
13
13
|
private confirm;
|
|
14
14
|
}
|
|
@@ -5,6 +5,12 @@ import { getConfig } from '../../lib/config/manager.js';
|
|
|
5
5
|
import { createClientFromConfig } from '../../lib/kalshi/index.js';
|
|
6
6
|
import { logger } from '../../lib/logger.js';
|
|
7
7
|
export default class OrdersCancel extends BaseCommand {
|
|
8
|
+
static args = {
|
|
9
|
+
orderId: Args.string({
|
|
10
|
+
description: 'Order ID to cancel',
|
|
11
|
+
required: true,
|
|
12
|
+
}),
|
|
13
|
+
};
|
|
8
14
|
static description = 'Cancel an order';
|
|
9
15
|
static examples = [
|
|
10
16
|
'<%= config.bin %> <%= command.id %> ORDER_ID',
|
|
@@ -15,14 +21,8 @@ export default class OrdersCancel extends BaseCommand {
|
|
|
15
21
|
...BaseCommand.baseFlags,
|
|
16
22
|
yes: Flags.boolean({
|
|
17
23
|
char: 'y',
|
|
18
|
-
description: 'Skip confirmation prompt',
|
|
19
24
|
default: false,
|
|
20
|
-
|
|
21
|
-
};
|
|
22
|
-
static args = {
|
|
23
|
-
orderId: Args.string({
|
|
24
|
-
description: 'Order ID to cancel',
|
|
25
|
-
required: true,
|
|
25
|
+
description: 'Skip confirmation prompt',
|
|
26
26
|
}),
|
|
27
27
|
};
|
|
28
28
|
async run() {
|
|
@@ -3,17 +3,17 @@ export default class OrdersCreate extends BaseCommand {
|
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
|
-
ticker: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
6
|
action: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
-
|
|
7
|
+
'dry-run': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
price: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
9
|
quantity: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
side: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
ticker: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
12
|
type: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
-
price: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
13
|
yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
|
-
'dry-run': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
14
14
|
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
15
15
|
};
|
|
16
16
|
run(): Promise<void>;
|
|
17
|
-
private formatStatus;
|
|
18
17
|
private confirm;
|
|
18
|
+
private formatStatus;
|
|
19
19
|
}
|