@gaberoo/kalshitools 1.0.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.
Files changed (57) hide show
  1. package/README.md +666 -0
  2. package/bin/dev.cmd +3 -0
  3. package/bin/dev.js +5 -0
  4. package/bin/run.cmd +3 -0
  5. package/bin/run.js +5 -0
  6. package/dist/commands/config/init.d.ts +13 -0
  7. package/dist/commands/config/init.js +89 -0
  8. package/dist/commands/config/show.d.ts +10 -0
  9. package/dist/commands/config/show.js +77 -0
  10. package/dist/commands/markets/list.d.ts +11 -0
  11. package/dist/commands/markets/list.js +64 -0
  12. package/dist/commands/markets/show.d.ts +13 -0
  13. package/dist/commands/markets/show.js +79 -0
  14. package/dist/commands/orders/cancel.d.ts +14 -0
  15. package/dist/commands/orders/cancel.js +129 -0
  16. package/dist/commands/orders/create.d.ts +19 -0
  17. package/dist/commands/orders/create.js +211 -0
  18. package/dist/commands/orders/list.d.ts +13 -0
  19. package/dist/commands/orders/list.js +92 -0
  20. package/dist/commands/portfolio/balance.d.ts +9 -0
  21. package/dist/commands/portfolio/balance.js +36 -0
  22. package/dist/commands/portfolio/fills.d.ts +11 -0
  23. package/dist/commands/portfolio/fills.js +80 -0
  24. package/dist/commands/portfolio/positions.d.ts +9 -0
  25. package/dist/commands/portfolio/positions.js +58 -0
  26. package/dist/index.d.ts +1 -0
  27. package/dist/index.js +1 -0
  28. package/dist/lib/base-command.d.ts +13 -0
  29. package/dist/lib/base-command.js +38 -0
  30. package/dist/lib/config/manager.d.ts +71 -0
  31. package/dist/lib/config/manager.js +137 -0
  32. package/dist/lib/config/schema.d.ts +175 -0
  33. package/dist/lib/config/schema.js +59 -0
  34. package/dist/lib/errors/base.d.ts +84 -0
  35. package/dist/lib/errors/base.js +106 -0
  36. package/dist/lib/kalshi/auth.d.ts +17 -0
  37. package/dist/lib/kalshi/auth.js +71 -0
  38. package/dist/lib/kalshi/client.d.ts +86 -0
  39. package/dist/lib/kalshi/client.js +228 -0
  40. package/dist/lib/kalshi/index.d.ts +8 -0
  41. package/dist/lib/kalshi/index.js +19 -0
  42. package/dist/lib/kalshi/types.d.ts +155 -0
  43. package/dist/lib/kalshi/types.js +4 -0
  44. package/dist/lib/logger.d.ts +9 -0
  45. package/dist/lib/logger.js +41 -0
  46. package/dist/lib/output/formatter.d.ts +69 -0
  47. package/dist/lib/output/formatter.js +111 -0
  48. package/dist/lib/retry.d.ts +18 -0
  49. package/dist/lib/retry.js +81 -0
  50. package/dist/lib/sanitize.d.ts +28 -0
  51. package/dist/lib/sanitize.js +124 -0
  52. package/dist/lib/shutdown.d.ts +43 -0
  53. package/dist/lib/shutdown.js +106 -0
  54. package/dist/lib/validation.d.ts +37 -0
  55. package/dist/lib/validation.js +120 -0
  56. package/oclif.manifest.json +520 -0
  57. package/package.json +98 -0
@@ -0,0 +1,520 @@
1
+ {
2
+ "commands": {
3
+ "config:init": {
4
+ "aliases": [],
5
+ "args": {},
6
+ "description": "Initialize kalshitools configuration interactively",
7
+ "examples": [
8
+ "<%= config.bin %> <%= command.id %>",
9
+ "<%= config.bin %> <%= command.id %> --env production"
10
+ ],
11
+ "flags": {
12
+ "json": {
13
+ "description": "Output in JSON format",
14
+ "name": "json",
15
+ "allowNo": false,
16
+ "type": "boolean"
17
+ },
18
+ "env": {
19
+ "description": "Environment to configure (demo or production)",
20
+ "name": "env",
21
+ "default": "demo",
22
+ "hasDynamicHelp": false,
23
+ "multiple": false,
24
+ "options": [
25
+ "demo",
26
+ "production"
27
+ ],
28
+ "type": "option"
29
+ },
30
+ "keyId": {
31
+ "description": "API key ID (email)",
32
+ "name": "keyId",
33
+ "hasDynamicHelp": false,
34
+ "multiple": false,
35
+ "type": "option"
36
+ },
37
+ "privateKeyPath": {
38
+ "description": "Path to private key file",
39
+ "name": "privateKeyPath",
40
+ "hasDynamicHelp": false,
41
+ "multiple": false,
42
+ "type": "option"
43
+ }
44
+ },
45
+ "hasDynamicHelp": false,
46
+ "hiddenAliases": [],
47
+ "id": "config:init",
48
+ "pluginAlias": "@gaberoo/kalshitools",
49
+ "pluginName": "@gaberoo/kalshitools",
50
+ "pluginType": "core",
51
+ "strict": true,
52
+ "enableJsonFlag": false,
53
+ "isESM": true,
54
+ "relativePath": [
55
+ "dist",
56
+ "commands",
57
+ "config",
58
+ "init.js"
59
+ ]
60
+ },
61
+ "config:show": {
62
+ "aliases": [],
63
+ "args": {},
64
+ "description": "Show current configuration (credentials redacted)",
65
+ "examples": [
66
+ "<%= config.bin %> <%= command.id %>",
67
+ "<%= config.bin %> <%= command.id %> --json"
68
+ ],
69
+ "flags": {
70
+ "json": {
71
+ "description": "Output in JSON format",
72
+ "name": "json",
73
+ "allowNo": false,
74
+ "type": "boolean"
75
+ }
76
+ },
77
+ "hasDynamicHelp": false,
78
+ "hiddenAliases": [],
79
+ "id": "config:show",
80
+ "pluginAlias": "@gaberoo/kalshitools",
81
+ "pluginName": "@gaberoo/kalshitools",
82
+ "pluginType": "core",
83
+ "strict": true,
84
+ "enableJsonFlag": false,
85
+ "isESM": true,
86
+ "relativePath": [
87
+ "dist",
88
+ "commands",
89
+ "config",
90
+ "show.js"
91
+ ]
92
+ },
93
+ "markets:list": {
94
+ "aliases": [],
95
+ "args": {},
96
+ "description": "List prediction markets",
97
+ "examples": [
98
+ "<%= config.bin %> <%= command.id %>",
99
+ "<%= config.bin %> <%= command.id %> --status active --limit 10",
100
+ "<%= config.bin %> <%= command.id %> --json"
101
+ ],
102
+ "flags": {
103
+ "json": {
104
+ "description": "Output in JSON format",
105
+ "name": "json",
106
+ "allowNo": false,
107
+ "type": "boolean"
108
+ },
109
+ "status": {
110
+ "description": "Filter by market status",
111
+ "name": "status",
112
+ "hasDynamicHelp": false,
113
+ "multiple": false,
114
+ "options": [
115
+ "active",
116
+ "closed",
117
+ "settled",
118
+ "finalized"
119
+ ],
120
+ "type": "option"
121
+ },
122
+ "limit": {
123
+ "description": "Maximum number of markets to return",
124
+ "name": "limit",
125
+ "default": 20,
126
+ "hasDynamicHelp": false,
127
+ "multiple": false,
128
+ "type": "option"
129
+ }
130
+ },
131
+ "hasDynamicHelp": false,
132
+ "hiddenAliases": [],
133
+ "id": "markets:list",
134
+ "pluginAlias": "@gaberoo/kalshitools",
135
+ "pluginName": "@gaberoo/kalshitools",
136
+ "pluginType": "core",
137
+ "strict": true,
138
+ "enableJsonFlag": false,
139
+ "isESM": true,
140
+ "relativePath": [
141
+ "dist",
142
+ "commands",
143
+ "markets",
144
+ "list.js"
145
+ ]
146
+ },
147
+ "markets:show": {
148
+ "aliases": [],
149
+ "args": {
150
+ "ticker": {
151
+ "description": "Market ticker symbol",
152
+ "name": "ticker",
153
+ "required": true
154
+ }
155
+ },
156
+ "description": "Show market details",
157
+ "examples": [
158
+ "<%= config.bin %> <%= command.id %> TICKER",
159
+ "<%= config.bin %> <%= command.id %> TICKER --json"
160
+ ],
161
+ "flags": {
162
+ "json": {
163
+ "description": "Output in JSON format",
164
+ "name": "json",
165
+ "allowNo": false,
166
+ "type": "boolean"
167
+ }
168
+ },
169
+ "hasDynamicHelp": false,
170
+ "hiddenAliases": [],
171
+ "id": "markets:show",
172
+ "pluginAlias": "@gaberoo/kalshitools",
173
+ "pluginName": "@gaberoo/kalshitools",
174
+ "pluginType": "core",
175
+ "strict": true,
176
+ "enableJsonFlag": false,
177
+ "isESM": true,
178
+ "relativePath": [
179
+ "dist",
180
+ "commands",
181
+ "markets",
182
+ "show.js"
183
+ ]
184
+ },
185
+ "orders:cancel": {
186
+ "aliases": [],
187
+ "args": {
188
+ "orderId": {
189
+ "description": "Order ID to cancel",
190
+ "name": "orderId",
191
+ "required": true
192
+ }
193
+ },
194
+ "description": "Cancel an order",
195
+ "examples": [
196
+ "<%= config.bin %> <%= command.id %> ORDER_ID",
197
+ "<%= config.bin %> <%= command.id %> ORDER_ID --yes",
198
+ "<%= config.bin %> <%= command.id %> ORDER_ID --json"
199
+ ],
200
+ "flags": {
201
+ "json": {
202
+ "description": "Output in JSON format",
203
+ "name": "json",
204
+ "allowNo": false,
205
+ "type": "boolean"
206
+ },
207
+ "yes": {
208
+ "char": "y",
209
+ "description": "Skip confirmation prompt",
210
+ "name": "yes",
211
+ "allowNo": false,
212
+ "type": "boolean"
213
+ }
214
+ },
215
+ "hasDynamicHelp": false,
216
+ "hiddenAliases": [],
217
+ "id": "orders:cancel",
218
+ "pluginAlias": "@gaberoo/kalshitools",
219
+ "pluginName": "@gaberoo/kalshitools",
220
+ "pluginType": "core",
221
+ "strict": true,
222
+ "enableJsonFlag": false,
223
+ "isESM": true,
224
+ "relativePath": [
225
+ "dist",
226
+ "commands",
227
+ "orders",
228
+ "cancel.js"
229
+ ]
230
+ },
231
+ "orders:create": {
232
+ "aliases": [],
233
+ "args": {},
234
+ "description": "Create a new order (buy or sell contracts)",
235
+ "examples": [
236
+ "<%= config.bin %> <%= command.id %> --ticker TICKER --action buy --side yes --quantity 10 --type market",
237
+ "<%= config.bin %> <%= command.id %> --ticker TICKER --action buy --side yes --quantity 10 --type limit --price 0.65",
238
+ "<%= config.bin %> <%= command.id %> --ticker TICKER --action sell --side no --quantity 5 --type market --yes",
239
+ "<%= config.bin %> <%= command.id %> --ticker TICKER --action buy --side yes --quantity 100 --dry-run"
240
+ ],
241
+ "flags": {
242
+ "json": {
243
+ "description": "Output in JSON format",
244
+ "name": "json",
245
+ "allowNo": false,
246
+ "type": "boolean"
247
+ },
248
+ "ticker": {
249
+ "char": "t",
250
+ "description": "Market ticker symbol",
251
+ "name": "ticker",
252
+ "required": true,
253
+ "hasDynamicHelp": false,
254
+ "multiple": false,
255
+ "type": "option"
256
+ },
257
+ "action": {
258
+ "char": "a",
259
+ "description": "Order action (buy or sell)",
260
+ "name": "action",
261
+ "required": true,
262
+ "hasDynamicHelp": false,
263
+ "multiple": false,
264
+ "options": [
265
+ "buy",
266
+ "sell"
267
+ ],
268
+ "type": "option"
269
+ },
270
+ "side": {
271
+ "char": "s",
272
+ "description": "Contract side (yes or no)",
273
+ "name": "side",
274
+ "required": true,
275
+ "hasDynamicHelp": false,
276
+ "multiple": false,
277
+ "options": [
278
+ "yes",
279
+ "no"
280
+ ],
281
+ "type": "option"
282
+ },
283
+ "quantity": {
284
+ "char": "q",
285
+ "description": "Number of contracts",
286
+ "name": "quantity",
287
+ "required": true,
288
+ "hasDynamicHelp": false,
289
+ "multiple": false,
290
+ "type": "option"
291
+ },
292
+ "type": {
293
+ "description": "Order type (market or limit)",
294
+ "name": "type",
295
+ "default": "market",
296
+ "hasDynamicHelp": false,
297
+ "multiple": false,
298
+ "options": [
299
+ "market",
300
+ "limit"
301
+ ],
302
+ "type": "option"
303
+ },
304
+ "price": {
305
+ "char": "p",
306
+ "description": "Limit price (required for limit orders, 0.01-0.99)",
307
+ "name": "price",
308
+ "hasDynamicHelp": false,
309
+ "multiple": false,
310
+ "type": "option"
311
+ },
312
+ "yes": {
313
+ "char": "y",
314
+ "description": "Skip confirmation prompt",
315
+ "name": "yes",
316
+ "allowNo": false,
317
+ "type": "boolean"
318
+ },
319
+ "dry-run": {
320
+ "description": "Simulate the order without actually placing it",
321
+ "name": "dry-run",
322
+ "allowNo": false,
323
+ "type": "boolean"
324
+ }
325
+ },
326
+ "hasDynamicHelp": false,
327
+ "hiddenAliases": [],
328
+ "id": "orders:create",
329
+ "pluginAlias": "@gaberoo/kalshitools",
330
+ "pluginName": "@gaberoo/kalshitools",
331
+ "pluginType": "core",
332
+ "strict": true,
333
+ "enableJsonFlag": false,
334
+ "isESM": true,
335
+ "relativePath": [
336
+ "dist",
337
+ "commands",
338
+ "orders",
339
+ "create.js"
340
+ ]
341
+ },
342
+ "orders:list": {
343
+ "aliases": [],
344
+ "args": {},
345
+ "description": "List orders",
346
+ "examples": [
347
+ "<%= config.bin %> <%= command.id %>",
348
+ "<%= config.bin %> <%= command.id %> --status resting",
349
+ "<%= config.bin %> <%= command.id %> --ticker TICKER",
350
+ "<%= config.bin %> <%= command.id %> --json"
351
+ ],
352
+ "flags": {
353
+ "json": {
354
+ "description": "Output in JSON format",
355
+ "name": "json",
356
+ "allowNo": false,
357
+ "type": "boolean"
358
+ },
359
+ "status": {
360
+ "description": "Filter by order status",
361
+ "name": "status",
362
+ "hasDynamicHelp": false,
363
+ "multiple": false,
364
+ "options": [
365
+ "pending",
366
+ "resting",
367
+ "canceled",
368
+ "executed",
369
+ "expired"
370
+ ],
371
+ "type": "option"
372
+ },
373
+ "ticker": {
374
+ "description": "Filter by ticker",
375
+ "name": "ticker",
376
+ "hasDynamicHelp": false,
377
+ "multiple": false,
378
+ "type": "option"
379
+ },
380
+ "limit": {
381
+ "description": "Maximum number of orders to return",
382
+ "name": "limit",
383
+ "default": 50,
384
+ "hasDynamicHelp": false,
385
+ "multiple": false,
386
+ "type": "option"
387
+ }
388
+ },
389
+ "hasDynamicHelp": false,
390
+ "hiddenAliases": [],
391
+ "id": "orders:list",
392
+ "pluginAlias": "@gaberoo/kalshitools",
393
+ "pluginName": "@gaberoo/kalshitools",
394
+ "pluginType": "core",
395
+ "strict": true,
396
+ "enableJsonFlag": false,
397
+ "isESM": true,
398
+ "relativePath": [
399
+ "dist",
400
+ "commands",
401
+ "orders",
402
+ "list.js"
403
+ ]
404
+ },
405
+ "portfolio:balance": {
406
+ "aliases": [],
407
+ "args": {},
408
+ "description": "View account balance",
409
+ "examples": [
410
+ "<%= config.bin %> <%= command.id %>",
411
+ "<%= config.bin %> <%= command.id %> --json"
412
+ ],
413
+ "flags": {
414
+ "json": {
415
+ "description": "Output in JSON format",
416
+ "name": "json",
417
+ "allowNo": false,
418
+ "type": "boolean"
419
+ }
420
+ },
421
+ "hasDynamicHelp": false,
422
+ "hiddenAliases": [],
423
+ "id": "portfolio:balance",
424
+ "pluginAlias": "@gaberoo/kalshitools",
425
+ "pluginName": "@gaberoo/kalshitools",
426
+ "pluginType": "core",
427
+ "strict": true,
428
+ "enableJsonFlag": false,
429
+ "isESM": true,
430
+ "relativePath": [
431
+ "dist",
432
+ "commands",
433
+ "portfolio",
434
+ "balance.js"
435
+ ]
436
+ },
437
+ "portfolio:fills": {
438
+ "aliases": [],
439
+ "args": {},
440
+ "description": "View trade history (fills)",
441
+ "examples": [
442
+ "<%= config.bin %> <%= command.id %>",
443
+ "<%= config.bin %> <%= command.id %> --ticker TICKER",
444
+ "<%= config.bin %> <%= command.id %> --limit 20",
445
+ "<%= config.bin %> <%= command.id %> --json"
446
+ ],
447
+ "flags": {
448
+ "json": {
449
+ "description": "Output in JSON format",
450
+ "name": "json",
451
+ "allowNo": false,
452
+ "type": "boolean"
453
+ },
454
+ "ticker": {
455
+ "description": "Filter by ticker",
456
+ "name": "ticker",
457
+ "hasDynamicHelp": false,
458
+ "multiple": false,
459
+ "type": "option"
460
+ },
461
+ "limit": {
462
+ "description": "Maximum number of fills to return",
463
+ "name": "limit",
464
+ "default": 50,
465
+ "hasDynamicHelp": false,
466
+ "multiple": false,
467
+ "type": "option"
468
+ }
469
+ },
470
+ "hasDynamicHelp": false,
471
+ "hiddenAliases": [],
472
+ "id": "portfolio:fills",
473
+ "pluginAlias": "@gaberoo/kalshitools",
474
+ "pluginName": "@gaberoo/kalshitools",
475
+ "pluginType": "core",
476
+ "strict": true,
477
+ "enableJsonFlag": false,
478
+ "isESM": true,
479
+ "relativePath": [
480
+ "dist",
481
+ "commands",
482
+ "portfolio",
483
+ "fills.js"
484
+ ]
485
+ },
486
+ "portfolio:positions": {
487
+ "aliases": [],
488
+ "args": {},
489
+ "description": "View current positions with P&L",
490
+ "examples": [
491
+ "<%= config.bin %> <%= command.id %>",
492
+ "<%= config.bin %> <%= command.id %> --json"
493
+ ],
494
+ "flags": {
495
+ "json": {
496
+ "description": "Output in JSON format",
497
+ "name": "json",
498
+ "allowNo": false,
499
+ "type": "boolean"
500
+ }
501
+ },
502
+ "hasDynamicHelp": false,
503
+ "hiddenAliases": [],
504
+ "id": "portfolio:positions",
505
+ "pluginAlias": "@gaberoo/kalshitools",
506
+ "pluginName": "@gaberoo/kalshitools",
507
+ "pluginType": "core",
508
+ "strict": true,
509
+ "enableJsonFlag": false,
510
+ "isESM": true,
511
+ "relativePath": [
512
+ "dist",
513
+ "commands",
514
+ "portfolio",
515
+ "positions.js"
516
+ ]
517
+ }
518
+ },
519
+ "version": "1.0.0"
520
+ }
package/package.json ADDED
@@ -0,0 +1,98 @@
1
+ {
2
+ "name": "@gaberoo/kalshitools",
3
+ "description": "CLI for interacting with Kalshi prediction markets API",
4
+ "version": "1.0.0",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "author": "gaberoo322",
9
+ "bin": {
10
+ "kalshitools": "./bin/run.js"
11
+ },
12
+ "bugs": "https://github.com/kalshitools/kalshitools/issues",
13
+ "dependencies": {
14
+ "@oclif/core": "^4",
15
+ "@oclif/plugin-help": "^6",
16
+ "@oclif/plugin-plugins": "^5",
17
+ "axios": "^1.13.5",
18
+ "bottleneck": "^2.19.5",
19
+ "chalk": "^5.3.0",
20
+ "cli-table3": "^0.6.5",
21
+ "conf": "^13.0.1",
22
+ "pino": "^9.5.0",
23
+ "pino-pretty": "^13.0.0",
24
+ "undici": "^7.21.0",
25
+ "zod": "^3.24.1"
26
+ },
27
+ "devDependencies": {
28
+ "@eslint/compat": "^1",
29
+ "@oclif/prettier-config": "^0.2.1",
30
+ "@oclif/test": "^4",
31
+ "@types/node": "^22",
32
+ "@vitest/ui": "^2.1.8",
33
+ "eslint": "^9",
34
+ "eslint-config-oclif": "^6",
35
+ "eslint-config-prettier": "^10",
36
+ "oclif": "^4",
37
+ "shx": "^0.3.3",
38
+ "ts-node": "^10",
39
+ "typescript": "^5",
40
+ "vitest": "^2.1.8"
41
+ },
42
+ "engines": {
43
+ "node": ">=18.0.0"
44
+ },
45
+ "files": [
46
+ "./bin",
47
+ "./dist",
48
+ "./oclif.manifest.json"
49
+ ],
50
+ "homepage": "https://github.com/kalshitools/kalshitools",
51
+ "keywords": [
52
+ "oclif",
53
+ "kalshi",
54
+ "prediction-markets",
55
+ "trading",
56
+ "cli"
57
+ ],
58
+ "license": "MIT",
59
+ "main": "dist/index.js",
60
+ "type": "module",
61
+ "oclif": {
62
+ "bin": "kalshitools",
63
+ "dirname": "kalshitools",
64
+ "commands": "./dist/commands",
65
+ "plugins": [
66
+ "@oclif/plugin-help",
67
+ "@oclif/plugin-plugins"
68
+ ],
69
+ "topicSeparator": " ",
70
+ "topics": {
71
+ "config": {
72
+ "description": "Manage kalshitools configuration"
73
+ },
74
+ "markets": {
75
+ "description": "Browse and query prediction markets"
76
+ },
77
+ "portfolio": {
78
+ "description": "View account balance and positions"
79
+ },
80
+ "orders": {
81
+ "description": "Manage trading orders"
82
+ }
83
+ }
84
+ },
85
+ "repository": "kalshitools/kalshitools",
86
+ "scripts": {
87
+ "build": "shx rm -rf dist && tsc -b",
88
+ "lint": "eslint",
89
+ "postpack": "shx rm -f oclif.manifest.json",
90
+ "posttest": "pnpm run lint",
91
+ "prepack": "oclif manifest && oclif readme",
92
+ "test": "vitest run",
93
+ "test:watch": "vitest",
94
+ "test:ui": "vitest --ui",
95
+ "version": "oclif readme && git add README.md"
96
+ },
97
+ "types": "dist/index.d.ts"
98
+ }