@gaberoo/kalshitools 1.0.2 → 1.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 +328 -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/scan.d.ts +18 -0
- package/dist/commands/markets/scan.js +237 -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/analytics.d.ts +12 -0
- package/dist/commands/portfolio/analytics.js +192 -0
- package/dist/commands/portfolio/fills.d.ts +1 -1
- package/dist/commands/portfolio/fills.js +7 -7
- package/dist/commands/portfolio/history.d.ts +14 -0
- package/dist/commands/portfolio/history.js +245 -0
- package/dist/commands/portfolio/positions.d.ts +1 -0
- package/dist/commands/portfolio/positions.js +11 -2
- package/dist/commands/portfolio/risk.d.ts +11 -0
- package/dist/commands/portfolio/risk.js +206 -0
- package/dist/lib/analytics.d.ts +64 -0
- package/dist/lib/analytics.js +236 -0
- 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/risk.d.ts +51 -0
- package/dist/lib/risk.js +153 -0
- package/dist/lib/sanitize.js +9 -9
- package/dist/lib/scanner.d.ts +58 -0
- package/dist/lib/scanner.js +160 -0
- 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/docs/TRADING_STRATEGIES.md +538 -0
- package/oclif.manifest.json +559 -170
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,11 +9,17 @@ 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
|
|
19
|
+
- 📊 **Portfolio Analytics**: Comprehensive performance metrics, win rate, P&L analysis, fee tracking
|
|
20
|
+
- ⚠️ **Risk Management**: Real-time risk assessment, concentration analysis, correlation detection
|
|
21
|
+
- 📈 **Historical Analysis**: Time-series performance data, maker/taker statistics, trend analysis
|
|
22
|
+
- 🔎 **Market Scanner**: Automated opportunity discovery based on liquidity, spreads, and volume
|
|
17
23
|
|
|
18
24
|
## Quick Start
|
|
19
25
|
|
|
@@ -83,10 +89,22 @@ kalshitools markets list --status active
|
|
|
83
89
|
# Get market details
|
|
84
90
|
kalshitools markets show TICKER-SYMBOL
|
|
85
91
|
|
|
92
|
+
# View order book for liquidity analysis
|
|
93
|
+
kalshitools markets orderbook TICKER-SYMBOL --depth 5
|
|
94
|
+
|
|
95
|
+
# Discover markets within an event
|
|
96
|
+
kalshitools markets list --event-ticker EVENT-ID
|
|
97
|
+
|
|
98
|
+
# Batch query multiple tickers
|
|
99
|
+
kalshitools markets list --tickers "TICKER1,TICKER2,TICKER3"
|
|
100
|
+
|
|
86
101
|
# View your portfolio
|
|
87
102
|
kalshitools portfolio balance
|
|
88
103
|
kalshitools portfolio positions
|
|
89
104
|
|
|
105
|
+
# Filter positions by settlement status
|
|
106
|
+
kalshitools portfolio positions --settlement-status open
|
|
107
|
+
|
|
90
108
|
# Place an order (with confirmation)
|
|
91
109
|
kalshitools orders create \
|
|
92
110
|
--ticker MARKET-TICKER \
|
|
@@ -106,6 +124,86 @@ kalshitools orders create \
|
|
|
106
124
|
|
|
107
125
|
# View order history
|
|
108
126
|
kalshitools orders list
|
|
127
|
+
|
|
128
|
+
# Analyze portfolio performance
|
|
129
|
+
kalshitools portfolio analytics --period 30 --json
|
|
130
|
+
|
|
131
|
+
# Check portfolio risk
|
|
132
|
+
kalshitools portfolio risk --threshold 20
|
|
133
|
+
|
|
134
|
+
# View historical performance
|
|
135
|
+
kalshitools portfolio history --group-by week
|
|
136
|
+
|
|
137
|
+
# Scan markets for opportunities
|
|
138
|
+
kalshitools markets scan --min-liquidity 200 --min-spread 0.05
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Advanced Features for AI Trading Agents
|
|
142
|
+
|
|
143
|
+
kalshitools provides powerful analytics and scanning capabilities designed for automated trading systems:
|
|
144
|
+
|
|
145
|
+
### Portfolio Analytics
|
|
146
|
+
|
|
147
|
+
Get comprehensive performance metrics for strategy evaluation:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
# Full analytics for last 30 days
|
|
151
|
+
kalshitools portfolio analytics --period 30 --json
|
|
152
|
+
|
|
153
|
+
# Custom date range
|
|
154
|
+
kalshitools portfolio analytics \
|
|
155
|
+
--min-ts 2026-01-01T00:00:00Z \
|
|
156
|
+
--max-ts 2026-02-01T00:00:00Z \
|
|
157
|
+
--json
|
|
158
|
+
|
|
159
|
+
# Returns: win rate, avg P&L, total return, exposure ratio, concentration, fees
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Risk Management
|
|
163
|
+
|
|
164
|
+
Real-time risk assessment to prevent over-concentration:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
# Check portfolio risk with 20% position limit
|
|
168
|
+
kalshitools portfolio risk --threshold 20 --json
|
|
169
|
+
|
|
170
|
+
# Analyze concentration by event
|
|
171
|
+
kalshitools portfolio risk --group-by event --json
|
|
172
|
+
|
|
173
|
+
# Returns: risk score, concentrations, correlations, alerts, recommendations
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Historical Performance
|
|
177
|
+
|
|
178
|
+
Deep dive into trading history with time-series analytics:
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
# Daily performance breakdown
|
|
182
|
+
kalshitools portfolio history --group-by day --json
|
|
183
|
+
|
|
184
|
+
# Filter by specific market
|
|
185
|
+
kalshitools portfolio history --ticker MARKET-A --json
|
|
186
|
+
|
|
187
|
+
# Returns: time-series data, maker/taker stats, performance by ticker
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Market Opportunity Scanner
|
|
191
|
+
|
|
192
|
+
Discover high-quality trading opportunities:
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
# Scan for markets with good liquidity and spreads
|
|
196
|
+
kalshitools markets scan \
|
|
197
|
+
--min-liquidity 200 \
|
|
198
|
+
--min-spread 0.05 \
|
|
199
|
+
--max-spread 0.20 \
|
|
200
|
+
--min-volume 1000 \
|
|
201
|
+
--json
|
|
202
|
+
|
|
203
|
+
# Filter to specific event
|
|
204
|
+
kalshitools markets scan --event-ticker EVENT-2024 --json
|
|
205
|
+
|
|
206
|
+
# Returns: scored opportunities with liquidity, spread, and volume data
|
|
109
207
|
```
|
|
110
208
|
|
|
111
209
|
## Configuration
|
|
@@ -149,10 +247,30 @@ export LOG_LEVEL=info
|
|
|
149
247
|
* [List active markets](#list-active-markets)
|
|
150
248
|
* [View available markets](#view-available-markets)
|
|
151
249
|
* [Get market details](#get-market-details)
|
|
250
|
+
* [View order book for liquidity analysis](#view-order-book-for-liquidity-analysis)
|
|
251
|
+
* [Discover markets within an event](#discover-markets-within-an-event)
|
|
252
|
+
* [Batch query multiple tickers](#batch-query-multiple-tickers)
|
|
152
253
|
* [View your portfolio](#view-your-portfolio)
|
|
254
|
+
* [Filter positions by settlement status](#filter-positions-by-settlement-status)
|
|
153
255
|
* [Place an order (with confirmation)](#place-an-order-with-confirmation)
|
|
154
256
|
* [Use --dry-run to simulate without placing order](#use---dry-run-to-simulate-without-placing-order)
|
|
155
257
|
* [View order history](#view-order-history)
|
|
258
|
+
* [Analyze portfolio performance](#analyze-portfolio-performance)
|
|
259
|
+
* [Check portfolio risk](#check-portfolio-risk)
|
|
260
|
+
* [View historical performance](#view-historical-performance)
|
|
261
|
+
* [Scan markets for opportunities](#scan-markets-for-opportunities)
|
|
262
|
+
* [Full analytics for last 30 days](#full-analytics-for-last-30-days)
|
|
263
|
+
* [Custom date range](#custom-date-range)
|
|
264
|
+
* [Returns: win rate, avg P&L, total return, exposure ratio, concentration, fees](#returns-win-rate-avg-pl-total-return-exposure-ratio-concentration-fees)
|
|
265
|
+
* [Check portfolio risk with 20% position limit](#check-portfolio-risk-with-20-position-limit)
|
|
266
|
+
* [Analyze concentration by event](#analyze-concentration-by-event)
|
|
267
|
+
* [Returns: risk score, concentrations, correlations, alerts, recommendations](#returns-risk-score-concentrations-correlations-alerts-recommendations)
|
|
268
|
+
* [Daily performance breakdown](#daily-performance-breakdown)
|
|
269
|
+
* [Filter by specific market](#filter-by-specific-market)
|
|
270
|
+
* [Returns: time-series data, maker/taker stats, performance by ticker](#returns-time-series-data-makertaker-stats-performance-by-ticker)
|
|
271
|
+
* [Scan for markets with good liquidity and spreads](#scan-for-markets-with-good-liquidity-and-spreads)
|
|
272
|
+
* [Filter to specific event](#filter-to-specific-event)
|
|
273
|
+
* [Returns: scored opportunities with liquidity, spread, and volume data](#returns-scored-opportunities-with-liquidity-spread-and-volume-data)
|
|
156
274
|
* [Usage](#usage)
|
|
157
275
|
* [Commands](#commands)
|
|
158
276
|
<!-- tocstop -->
|
|
@@ -163,7 +281,7 @@ $ npm install -g @gaberoo/kalshitools
|
|
|
163
281
|
$ kalshitools COMMAND
|
|
164
282
|
running command...
|
|
165
283
|
$ kalshitools (--version)
|
|
166
|
-
@gaberoo/kalshitools/1.0
|
|
284
|
+
@gaberoo/kalshitools/1.1.0 darwin-arm64 node-v22.20.0
|
|
167
285
|
$ kalshitools --help [COMMAND]
|
|
168
286
|
USAGE
|
|
169
287
|
$ kalshitools COMMAND
|
|
@@ -176,6 +294,8 @@ USAGE
|
|
|
176
294
|
* [`kalshitools config show`](#kalshitools-config-show)
|
|
177
295
|
* [`kalshitools help [COMMAND]`](#kalshitools-help-command)
|
|
178
296
|
* [`kalshitools markets list`](#kalshitools-markets-list)
|
|
297
|
+
* [`kalshitools markets orderbook TICKER`](#kalshitools-markets-orderbook-ticker)
|
|
298
|
+
* [`kalshitools markets scan`](#kalshitools-markets-scan)
|
|
179
299
|
* [`kalshitools markets show TICKER`](#kalshitools-markets-show-ticker)
|
|
180
300
|
* [`kalshitools orders cancel ORDERID`](#kalshitools-orders-cancel-orderid)
|
|
181
301
|
* [`kalshitools orders create`](#kalshitools-orders-create)
|
|
@@ -190,9 +310,12 @@ USAGE
|
|
|
190
310
|
* [`kalshitools plugins uninstall [PLUGIN]`](#kalshitools-plugins-uninstall-plugin)
|
|
191
311
|
* [`kalshitools plugins unlink [PLUGIN]`](#kalshitools-plugins-unlink-plugin)
|
|
192
312
|
* [`kalshitools plugins update`](#kalshitools-plugins-update)
|
|
313
|
+
* [`kalshitools portfolio analytics`](#kalshitools-portfolio-analytics)
|
|
193
314
|
* [`kalshitools portfolio balance`](#kalshitools-portfolio-balance)
|
|
194
315
|
* [`kalshitools portfolio fills`](#kalshitools-portfolio-fills)
|
|
316
|
+
* [`kalshitools portfolio history`](#kalshitools-portfolio-history)
|
|
195
317
|
* [`kalshitools portfolio positions`](#kalshitools-portfolio-positions)
|
|
318
|
+
* [`kalshitools portfolio risk`](#kalshitools-portfolio-risk)
|
|
196
319
|
|
|
197
320
|
## `kalshitools config init`
|
|
198
321
|
|
|
@@ -218,7 +341,7 @@ EXAMPLES
|
|
|
218
341
|
$ kalshitools config init --env production
|
|
219
342
|
```
|
|
220
343
|
|
|
221
|
-
_See code: [src/commands/config/init.ts](https://github.com/kalshitools/kalshitools/blob/v1.0
|
|
344
|
+
_See code: [src/commands/config/init.ts](https://github.com/kalshitools/kalshitools/blob/v1.1.0/src/commands/config/init.ts)_
|
|
222
345
|
|
|
223
346
|
## `kalshitools config show`
|
|
224
347
|
|
|
@@ -240,7 +363,7 @@ EXAMPLES
|
|
|
240
363
|
$ kalshitools config show --json
|
|
241
364
|
```
|
|
242
365
|
|
|
243
|
-
_See code: [src/commands/config/show.ts](https://github.com/kalshitools/kalshitools/blob/v1.0
|
|
366
|
+
_See code: [src/commands/config/show.ts](https://github.com/kalshitools/kalshitools/blob/v1.1.0/src/commands/config/show.ts)_
|
|
244
367
|
|
|
245
368
|
## `kalshitools help [COMMAND]`
|
|
246
369
|
|
|
@@ -268,13 +391,18 @@ List prediction markets
|
|
|
268
391
|
|
|
269
392
|
```
|
|
270
393
|
USAGE
|
|
271
|
-
$ kalshitools markets list [--json] [--
|
|
394
|
+
$ kalshitools markets list [--json] [--event-ticker <value>] [--limit <value>] [--series-ticker <value>]
|
|
395
|
+
[--status active|closed|settled|finalized] [--tickers <value>] [--with-nested]
|
|
272
396
|
|
|
273
397
|
FLAGS
|
|
274
|
-
--
|
|
275
|
-
--
|
|
276
|
-
--
|
|
277
|
-
|
|
398
|
+
--event-ticker=<value> Filter by event ticker
|
|
399
|
+
--json Output in JSON format
|
|
400
|
+
--limit=<value> [default: 20] Maximum number of markets to return
|
|
401
|
+
--series-ticker=<value> Filter by series ticker
|
|
402
|
+
--status=<option> Filter by market status
|
|
403
|
+
<options: active|closed|settled|finalized>
|
|
404
|
+
--tickers=<value> Comma-separated list of tickers to fetch
|
|
405
|
+
--with-nested Include nested markets
|
|
278
406
|
|
|
279
407
|
DESCRIPTION
|
|
280
408
|
List prediction markets
|
|
@@ -284,10 +412,84 @@ EXAMPLES
|
|
|
284
412
|
|
|
285
413
|
$ kalshitools markets list --status active --limit 10
|
|
286
414
|
|
|
415
|
+
$ kalshitools markets list --event-ticker ELECTION-2024
|
|
416
|
+
|
|
417
|
+
$ kalshitools markets list --tickers "TICKER1,TICKER2,TICKER3"
|
|
418
|
+
|
|
419
|
+
$ kalshitools markets list --with-nested
|
|
420
|
+
|
|
287
421
|
$ kalshitools markets list --json
|
|
288
422
|
```
|
|
289
423
|
|
|
290
|
-
_See code: [src/commands/markets/list.ts](https://github.com/kalshitools/kalshitools/blob/v1.0
|
|
424
|
+
_See code: [src/commands/markets/list.ts](https://github.com/kalshitools/kalshitools/blob/v1.1.0/src/commands/markets/list.ts)_
|
|
425
|
+
|
|
426
|
+
## `kalshitools markets orderbook TICKER`
|
|
427
|
+
|
|
428
|
+
Show order book for a market
|
|
429
|
+
|
|
430
|
+
```
|
|
431
|
+
USAGE
|
|
432
|
+
$ kalshitools markets orderbook TICKER [--json] [--depth <value>]
|
|
433
|
+
|
|
434
|
+
ARGUMENTS
|
|
435
|
+
TICKER Market ticker symbol
|
|
436
|
+
|
|
437
|
+
FLAGS
|
|
438
|
+
--depth=<value> [default: 10] Number of price levels to show
|
|
439
|
+
--json Output in JSON format
|
|
440
|
+
|
|
441
|
+
DESCRIPTION
|
|
442
|
+
Show order book for a market
|
|
443
|
+
|
|
444
|
+
EXAMPLES
|
|
445
|
+
$ kalshitools markets orderbook TICKER
|
|
446
|
+
|
|
447
|
+
$ kalshitools markets orderbook TICKER --depth 5
|
|
448
|
+
|
|
449
|
+
$ kalshitools markets orderbook TICKER --json
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
_See code: [src/commands/markets/orderbook.ts](https://github.com/kalshitools/kalshitools/blob/v1.1.0/src/commands/markets/orderbook.ts)_
|
|
453
|
+
|
|
454
|
+
## `kalshitools markets scan`
|
|
455
|
+
|
|
456
|
+
Scan markets for trading opportunities based on liquidity and spreads
|
|
457
|
+
|
|
458
|
+
```
|
|
459
|
+
USAGE
|
|
460
|
+
$ kalshitools markets scan [--json] [--depth <value>] [--event-ticker <value>] [--limit <value>] [--max-spread
|
|
461
|
+
<value>] [--min-liquidity <value>] [--min-spread <value>] [--min-volume <value>] [--series-ticker <value>]
|
|
462
|
+
[--sort-by liquidity|score|spread|volume]
|
|
463
|
+
|
|
464
|
+
FLAGS
|
|
465
|
+
--depth=<value> [default: 5] Orderbook depth to fetch for analysis
|
|
466
|
+
--event-ticker=<value> Filter to specific event
|
|
467
|
+
--json Output in JSON format
|
|
468
|
+
--limit=<value> [default: 50] Maximum markets to scan
|
|
469
|
+
--max-spread=<value> [default: 0.30] Maximum spread in cents (e.g., 0.30 = 30 cents)
|
|
470
|
+
--min-liquidity=<value> [default: 100] Minimum orderbook depth in dollars
|
|
471
|
+
--min-spread=<value> [default: 0.03] Minimum spread in cents (e.g., 0.03 = 3 cents)
|
|
472
|
+
--min-volume=<value> [default: 500] Minimum 24h volume in dollars
|
|
473
|
+
--series-ticker=<value> Filter to specific series
|
|
474
|
+
--sort-by=<option> [default: score] Ranking criteria
|
|
475
|
+
<options: liquidity|score|spread|volume>
|
|
476
|
+
|
|
477
|
+
DESCRIPTION
|
|
478
|
+
Scan markets for trading opportunities based on liquidity and spreads
|
|
479
|
+
|
|
480
|
+
EXAMPLES
|
|
481
|
+
$ kalshitools markets scan
|
|
482
|
+
|
|
483
|
+
$ kalshitools markets scan --min-liquidity 200 --min-spread 0.05
|
|
484
|
+
|
|
485
|
+
$ kalshitools markets scan --event-ticker EVENT-2024
|
|
486
|
+
|
|
487
|
+
$ kalshitools markets scan --sort-by liquidity --limit 20
|
|
488
|
+
|
|
489
|
+
$ kalshitools markets scan --json
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
_See code: [src/commands/markets/scan.ts](https://github.com/kalshitools/kalshitools/blob/v1.1.0/src/commands/markets/scan.ts)_
|
|
291
493
|
|
|
292
494
|
## `kalshitools markets show TICKER`
|
|
293
495
|
|
|
@@ -312,7 +514,7 @@ EXAMPLES
|
|
|
312
514
|
$ kalshitools markets show TICKER --json
|
|
313
515
|
```
|
|
314
516
|
|
|
315
|
-
_See code: [src/commands/markets/show.ts](https://github.com/kalshitools/kalshitools/blob/v1.0
|
|
517
|
+
_See code: [src/commands/markets/show.ts](https://github.com/kalshitools/kalshitools/blob/v1.1.0/src/commands/markets/show.ts)_
|
|
316
518
|
|
|
317
519
|
## `kalshitools orders cancel ORDERID`
|
|
318
520
|
|
|
@@ -340,7 +542,7 @@ EXAMPLES
|
|
|
340
542
|
$ kalshitools orders cancel ORDER_ID --json
|
|
341
543
|
```
|
|
342
544
|
|
|
343
|
-
_See code: [src/commands/orders/cancel.ts](https://github.com/kalshitools/kalshitools/blob/v1.0
|
|
545
|
+
_See code: [src/commands/orders/cancel.ts](https://github.com/kalshitools/kalshitools/blob/v1.1.0/src/commands/orders/cancel.ts)_
|
|
344
546
|
|
|
345
547
|
## `kalshitools orders create`
|
|
346
548
|
|
|
@@ -348,8 +550,8 @@ Create a new order (buy or sell contracts)
|
|
|
348
550
|
|
|
349
551
|
```
|
|
350
552
|
USAGE
|
|
351
|
-
$ kalshitools orders create -
|
|
352
|
-
|
|
553
|
+
$ kalshitools orders create -a buy|sell -q <value> -s yes|no -t <value> [--json] [--dry-run] [-p <value>] [--type
|
|
554
|
+
market|limit] [-y]
|
|
353
555
|
|
|
354
556
|
FLAGS
|
|
355
557
|
-a, --action=<option> (required) Order action (buy or sell)
|
|
@@ -378,7 +580,7 @@ EXAMPLES
|
|
|
378
580
|
$ kalshitools orders create --ticker TICKER --action buy --side yes --quantity 100 --dry-run
|
|
379
581
|
```
|
|
380
582
|
|
|
381
|
-
_See code: [src/commands/orders/create.ts](https://github.com/kalshitools/kalshitools/blob/v1.0
|
|
583
|
+
_See code: [src/commands/orders/create.ts](https://github.com/kalshitools/kalshitools/blob/v1.1.0/src/commands/orders/create.ts)_
|
|
382
584
|
|
|
383
585
|
## `kalshitools orders list`
|
|
384
586
|
|
|
@@ -386,8 +588,8 @@ List orders
|
|
|
386
588
|
|
|
387
589
|
```
|
|
388
590
|
USAGE
|
|
389
|
-
$ kalshitools orders list [--json] [--status pending|resting|canceled|executed|expired]
|
|
390
|
-
[--
|
|
591
|
+
$ kalshitools orders list [--json] [--limit <value>] [--status pending|resting|canceled|executed|expired]
|
|
592
|
+
[--ticker <value>]
|
|
391
593
|
|
|
392
594
|
FLAGS
|
|
393
595
|
--json Output in JSON format
|
|
@@ -409,7 +611,7 @@ EXAMPLES
|
|
|
409
611
|
$ kalshitools orders list --json
|
|
410
612
|
```
|
|
411
613
|
|
|
412
|
-
_See code: [src/commands/orders/list.ts](https://github.com/kalshitools/kalshitools/blob/v1.0
|
|
614
|
+
_See code: [src/commands/orders/list.ts](https://github.com/kalshitools/kalshitools/blob/v1.1.0/src/commands/orders/list.ts)_
|
|
413
615
|
|
|
414
616
|
## `kalshitools plugins`
|
|
415
617
|
|
|
@@ -701,6 +903,35 @@ DESCRIPTION
|
|
|
701
903
|
|
|
702
904
|
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.56/src/commands/plugins/update.ts)_
|
|
703
905
|
|
|
906
|
+
## `kalshitools portfolio analytics`
|
|
907
|
+
|
|
908
|
+
Comprehensive portfolio performance analytics
|
|
909
|
+
|
|
910
|
+
```
|
|
911
|
+
USAGE
|
|
912
|
+
$ kalshitools portfolio analytics [--json] [--max-ts <value>] [--min-ts <value>] [--period <value>]
|
|
913
|
+
|
|
914
|
+
FLAGS
|
|
915
|
+
--json Output in JSON format
|
|
916
|
+
--max-ts=<value> End date for analysis (ISO-8601 format)
|
|
917
|
+
--min-ts=<value> Start date for analysis (ISO-8601 format)
|
|
918
|
+
--period=<value> Analysis period in days (overridden by min-ts/max-ts)
|
|
919
|
+
|
|
920
|
+
DESCRIPTION
|
|
921
|
+
Comprehensive portfolio performance analytics
|
|
922
|
+
|
|
923
|
+
EXAMPLES
|
|
924
|
+
$ kalshitools portfolio analytics
|
|
925
|
+
|
|
926
|
+
$ kalshitools portfolio analytics --period 7
|
|
927
|
+
|
|
928
|
+
$ kalshitools portfolio analytics --min-ts 2026-01-01T00:00:00Z
|
|
929
|
+
|
|
930
|
+
$ kalshitools portfolio analytics --json
|
|
931
|
+
```
|
|
932
|
+
|
|
933
|
+
_See code: [src/commands/portfolio/analytics.ts](https://github.com/kalshitools/kalshitools/blob/v1.1.0/src/commands/portfolio/analytics.ts)_
|
|
934
|
+
|
|
704
935
|
## `kalshitools portfolio balance`
|
|
705
936
|
|
|
706
937
|
View account balance
|
|
@@ -721,7 +952,7 @@ EXAMPLES
|
|
|
721
952
|
$ kalshitools portfolio balance --json
|
|
722
953
|
```
|
|
723
954
|
|
|
724
|
-
_See code: [src/commands/portfolio/balance.ts](https://github.com/kalshitools/kalshitools/blob/v1.0
|
|
955
|
+
_See code: [src/commands/portfolio/balance.ts](https://github.com/kalshitools/kalshitools/blob/v1.1.0/src/commands/portfolio/balance.ts)_
|
|
725
956
|
|
|
726
957
|
## `kalshitools portfolio fills`
|
|
727
958
|
|
|
@@ -729,7 +960,7 @@ View trade history (fills)
|
|
|
729
960
|
|
|
730
961
|
```
|
|
731
962
|
USAGE
|
|
732
|
-
$ kalshitools portfolio fills [--json] [--
|
|
963
|
+
$ kalshitools portfolio fills [--json] [--limit <value>] [--ticker <value>]
|
|
733
964
|
|
|
734
965
|
FLAGS
|
|
735
966
|
--json Output in JSON format
|
|
@@ -749,7 +980,42 @@ EXAMPLES
|
|
|
749
980
|
$ kalshitools portfolio fills --json
|
|
750
981
|
```
|
|
751
982
|
|
|
752
|
-
_See code: [src/commands/portfolio/fills.ts](https://github.com/kalshitools/kalshitools/blob/v1.0
|
|
983
|
+
_See code: [src/commands/portfolio/fills.ts](https://github.com/kalshitools/kalshitools/blob/v1.1.0/src/commands/portfolio/fills.ts)_
|
|
984
|
+
|
|
985
|
+
## `kalshitools portfolio history`
|
|
986
|
+
|
|
987
|
+
Historical performance analysis with time-series data
|
|
988
|
+
|
|
989
|
+
```
|
|
990
|
+
USAGE
|
|
991
|
+
$ kalshitools portfolio history [--json] [--group-by day|week|month] [--limit <value>] [--max-ts <value>] [--min-ts
|
|
992
|
+
<value>] [--ticker <value>]
|
|
993
|
+
|
|
994
|
+
FLAGS
|
|
995
|
+
--group-by=<option> [default: day] Time aggregation level
|
|
996
|
+
<options: day|week|month>
|
|
997
|
+
--json Output in JSON format
|
|
998
|
+
--limit=<value> [default: 500] Maximum fills to fetch (handles pagination)
|
|
999
|
+
--max-ts=<value> End date (ISO-8601 format)
|
|
1000
|
+
--min-ts=<value> Start date (ISO-8601 format)
|
|
1001
|
+
--ticker=<value> Filter by specific market ticker
|
|
1002
|
+
|
|
1003
|
+
DESCRIPTION
|
|
1004
|
+
Historical performance analysis with time-series data
|
|
1005
|
+
|
|
1006
|
+
EXAMPLES
|
|
1007
|
+
$ kalshitools portfolio history
|
|
1008
|
+
|
|
1009
|
+
$ kalshitools portfolio history --ticker MARKET-A
|
|
1010
|
+
|
|
1011
|
+
$ kalshitools portfolio history --group-by week
|
|
1012
|
+
|
|
1013
|
+
$ kalshitools portfolio history --min-ts 2026-01-01T00:00:00Z --max-ts 2026-02-01T00:00:00Z
|
|
1014
|
+
|
|
1015
|
+
$ kalshitools portfolio history --json
|
|
1016
|
+
```
|
|
1017
|
+
|
|
1018
|
+
_See code: [src/commands/portfolio/history.ts](https://github.com/kalshitools/kalshitools/blob/v1.1.0/src/commands/portfolio/history.ts)_
|
|
753
1019
|
|
|
754
1020
|
## `kalshitools portfolio positions`
|
|
755
1021
|
|
|
@@ -757,10 +1023,12 @@ View current positions with P&L
|
|
|
757
1023
|
|
|
758
1024
|
```
|
|
759
1025
|
USAGE
|
|
760
|
-
$ kalshitools portfolio positions [--json]
|
|
1026
|
+
$ kalshitools portfolio positions [--json] [--settlement-status open|pending|settled]
|
|
761
1027
|
|
|
762
1028
|
FLAGS
|
|
763
|
-
--json
|
|
1029
|
+
--json Output in JSON format
|
|
1030
|
+
--settlement-status=<option> Filter by settlement status
|
|
1031
|
+
<options: open|pending|settled>
|
|
764
1032
|
|
|
765
1033
|
DESCRIPTION
|
|
766
1034
|
View current positions with P&L
|
|
@@ -768,8 +1036,41 @@ DESCRIPTION
|
|
|
768
1036
|
EXAMPLES
|
|
769
1037
|
$ kalshitools portfolio positions
|
|
770
1038
|
|
|
1039
|
+
$ kalshitools portfolio positions --settlement-status open
|
|
1040
|
+
|
|
1041
|
+
$ kalshitools portfolio positions --settlement-status settled
|
|
1042
|
+
|
|
771
1043
|
$ kalshitools portfolio positions --json
|
|
772
1044
|
```
|
|
773
1045
|
|
|
774
|
-
_See code: [src/commands/portfolio/positions.ts](https://github.com/kalshitools/kalshitools/blob/v1.0
|
|
1046
|
+
_See code: [src/commands/portfolio/positions.ts](https://github.com/kalshitools/kalshitools/blob/v1.1.0/src/commands/portfolio/positions.ts)_
|
|
1047
|
+
|
|
1048
|
+
## `kalshitools portfolio risk`
|
|
1049
|
+
|
|
1050
|
+
Real-time portfolio risk analysis and warnings
|
|
1051
|
+
|
|
1052
|
+
```
|
|
1053
|
+
USAGE
|
|
1054
|
+
$ kalshitools portfolio risk [--json] [--group-by event|series|ticker] [--threshold <value>]
|
|
1055
|
+
|
|
1056
|
+
FLAGS
|
|
1057
|
+
--group-by=<option> [default: ticker] Grouping for concentration analysis
|
|
1058
|
+
<options: event|series|ticker>
|
|
1059
|
+
--json Output in JSON format
|
|
1060
|
+
--threshold=<value> [default: 20] Alert threshold for position concentration (%)
|
|
1061
|
+
|
|
1062
|
+
DESCRIPTION
|
|
1063
|
+
Real-time portfolio risk analysis and warnings
|
|
1064
|
+
|
|
1065
|
+
EXAMPLES
|
|
1066
|
+
$ kalshitools portfolio risk
|
|
1067
|
+
|
|
1068
|
+
$ kalshitools portfolio risk --threshold 15
|
|
1069
|
+
|
|
1070
|
+
$ kalshitools portfolio risk --group-by event
|
|
1071
|
+
|
|
1072
|
+
$ kalshitools portfolio risk --json
|
|
1073
|
+
```
|
|
1074
|
+
|
|
1075
|
+
_See code: [src/commands/portfolio/risk.ts](https://github.com/kalshitools/kalshitools/blob/v1.1.0/src/commands/portfolio/risk.ts)_
|
|
775
1076
|
<!-- 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) {
|