kalshi-trading-bot-cli 2.1.1 → 2.1.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 +34 -8
- package/package.json +1 -1
- package/src/cli.ts +1 -1
- package/src/commands/help.ts +5 -5
- package/src/commands/status.ts +2 -2
- package/src/model/llm.ts +5 -5
- package/src/setup/wizard.ts +6 -6
- package/src/utils/env.ts +1 -1
- package/src/utils/model.ts +1 -1
package/README.md
CHANGED
|
@@ -8,12 +8,20 @@ Integrates with the [Octagon Research API](https://app.octagonai.co) for AI-gene
|
|
|
8
8
|
|
|
9
9
|

|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Prerequisites
|
|
12
|
+
|
|
13
|
+
- **[Bun](https://bun.com/) ≥ 1.1** (required — the bot uses `bun:sqlite` and runs `.tsx` directly; Node.js won't work)
|
|
14
|
+
```bash
|
|
15
|
+
curl -fsSL https://bun.com/install | bash
|
|
16
|
+
```
|
|
17
|
+
- A **Kalshi** account with API access (API key + RSA private key)
|
|
18
|
+
- One **LLM provider key** (OpenAI / Anthropic / Google / xAI / OpenRouter / Ollama). The setup wizard collects these on first run.
|
|
19
|
+
- Optional: an **[Octagon](https://app.octagonai.co)** key for AI edge analysis, and a **Tavily** key for web research.
|
|
12
20
|
|
|
13
|
-
|
|
21
|
+
## Quick Start
|
|
14
22
|
|
|
15
23
|
```bash
|
|
16
|
-
bunx kalshi-trading-bot-cli
|
|
24
|
+
bunx kalshi-trading-bot-cli@latest
|
|
17
25
|
```
|
|
18
26
|
|
|
19
27
|
That's it — no clone, no install. The setup wizard runs automatically on first launch and walks you through API keys.
|
|
@@ -29,18 +37,36 @@ bun install
|
|
|
29
37
|
bun start
|
|
30
38
|
```
|
|
31
39
|
|
|
32
|
-
> Don't have Bun? Install it with `curl -fsSL https://bun.com/install | bash`
|
|
33
|
-
|
|
34
40
|
### Where things live
|
|
35
41
|
|
|
36
42
|
- **Config, cache, SQLite DB:** `~/.kalshi-bot/`
|
|
37
43
|
- **API keys (`.env`):** `~/.kalshi-bot/.env` — written by the setup wizard. A `.env` in the current directory takes precedence (handy for dev).
|
|
38
44
|
- **First run** with no keys configured triggers the setup wizard automatically.
|
|
39
45
|
|
|
40
|
-
|
|
46
|
+
### Updating
|
|
41
47
|
|
|
48
|
+
Using `@latest` in the `bunx` command always pulls the newest published version — so `bunx kalshi-trading-bot-cli@latest` is the zero-friction path.
|
|
49
|
+
|
|
50
|
+
If you ran `bunx kalshi-trading-bot-cli` without `@latest`, Bun may serve a cached copy. Force a refresh:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
bunx kalshi-trading-bot-cli@latest # pin latest for this invocation
|
|
54
|
+
bun pm cache rm # or clear Bun's install cache
|
|
42
55
|
```
|
|
43
|
-
|
|
56
|
+
|
|
57
|
+
If you installed globally with `bun add -g kalshi-trading-bot-cli`:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
bun update -g kalshi-trading-bot-cli # update in place
|
|
61
|
+
bun add -g kalshi-trading-bot-cli@latest # or reinstall pinned to latest
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Check your installed version with `kalshi --version` (or `bun pm ls -g | grep kalshi`).
|
|
65
|
+
|
|
66
|
+
## Example Session
|
|
67
|
+
|
|
68
|
+
```text
|
|
69
|
+
$ bunx kalshi-trading-bot-cli@latest
|
|
44
70
|
|
|
45
71
|
Welcome to Kalshi Trading Bot CLI
|
|
46
72
|
Type help for commands, or just ask a question.
|
|
@@ -338,7 +364,7 @@ TELEMETRY_ENABLED=false
|
|
|
338
364
|
Or set the environment variable before running:
|
|
339
365
|
|
|
340
366
|
```bash
|
|
341
|
-
TELEMETRY_ENABLED=false bunx kalshi-trading-bot-cli
|
|
367
|
+
TELEMETRY_ENABLED=false bunx kalshi-trading-bot-cli@latest
|
|
342
368
|
```
|
|
343
369
|
|
|
344
370
|
## Documentation
|
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -922,7 +922,7 @@ export async function runCli(options?: { forceSetup?: boolean }) {
|
|
|
922
922
|
editor.addToHistory(msg);
|
|
923
923
|
}
|
|
924
924
|
|
|
925
|
-
// Auto-launch setup wizard if credentials are missing or `
|
|
925
|
+
// Auto-launch setup wizard if credentials are missing or `kalshi init` was used
|
|
926
926
|
if (!hasKalshiCreds || options?.forceSetup) {
|
|
927
927
|
setupWizard.start();
|
|
928
928
|
}
|
package/src/commands/help.ts
CHANGED
|
@@ -109,12 +109,12 @@ from the snapshot when available, else current Kalshi lifetime volume.
|
|
|
109
109
|
ROI is capital-weighted: sum(pnl) / sum(capital) across edge signals, where capital
|
|
110
110
|
is kp/100 for YES edges and (100-kp)/100 for NO edges (matches Supabase methodology).`,
|
|
111
111
|
|
|
112
|
-
'clear-cache': `**${ctx === 'cli' ? '' : '
|
|
112
|
+
'clear-cache': `**${ctx === 'cli' ? '' : 'kalshi '}clear-cache** — Delete local cache
|
|
113
113
|
|
|
114
|
-
${ctx === 'cli' ? `${p}` : '
|
|
114
|
+
${ctx === 'cli' ? `${p}` : 'kalshi '}clear-cache Delete the local SQLite database (~/.kalshi-bot/kalshi-bot.db)
|
|
115
115
|
A fresh database will be created on next command.
|
|
116
116
|
|
|
117
|
-
Use this when the local cache is corrupted or you want to start fresh.${ctx !== 'cli' ? '\nRun from terminal:
|
|
117
|
+
Use this when the local cache is corrupted or you want to start fresh.${ctx !== 'cli' ? '\nRun from terminal: kalshi clear-cache' : ''}`,
|
|
118
118
|
|
|
119
119
|
init: `**${p}init** — Re-run setup wizard
|
|
120
120
|
|
|
@@ -211,8 +211,8 @@ Account:
|
|
|
211
211
|
System:
|
|
212
212
|
/model Change LLM model/provider
|
|
213
213
|
/setup Re-run setup wizard
|
|
214
|
-
init Launch with setup wizard (run:
|
|
215
|
-
clear-cache Delete local cache (run:
|
|
214
|
+
init Launch with setup wizard (run: kalshi init)
|
|
215
|
+
clear-cache Delete local cache (run: kalshi clear-cache)
|
|
216
216
|
/help [command] Show help for a command
|
|
217
217
|
/quit Quit
|
|
218
218
|
|
package/src/commands/status.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { callKalshiApi } from '../tools/kalshi/api.js';
|
|
2
|
-
import { PROVIDERS } from '
|
|
3
|
-
import { getDefaultModelForProvider } from '
|
|
2
|
+
import { PROVIDERS } from '../providers.js';
|
|
3
|
+
import { getDefaultModelForProvider } from '../utils/model.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Verify setup: check API keys, exchange connectivity, and optional services.
|
package/src/model/llm.ts
CHANGED
|
@@ -9,11 +9,11 @@ import { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
|
|
9
9
|
import { StructuredToolInterface } from '@langchain/core/tools';
|
|
10
10
|
import { Runnable } from '@langchain/core/runnables';
|
|
11
11
|
import { z } from 'zod';
|
|
12
|
-
import { DEFAULT_SYSTEM_PROMPT } from '
|
|
13
|
-
import type { TokenUsage } from '
|
|
14
|
-
import { logger } from '
|
|
15
|
-
import { classifyError, isNonRetryableError } from '
|
|
16
|
-
import { resolveProvider, getProviderById } from '
|
|
12
|
+
import { DEFAULT_SYSTEM_PROMPT } from '../agent/prompts.js';
|
|
13
|
+
import type { TokenUsage } from '../agent/types.js';
|
|
14
|
+
import { logger } from '../utils/index.js';
|
|
15
|
+
import { classifyError, isNonRetryableError } from '../utils/errors.js';
|
|
16
|
+
import { resolveProvider, getProviderById } from '../providers.js';
|
|
17
17
|
|
|
18
18
|
export const DEFAULT_PROVIDER = 'openai';
|
|
19
19
|
export const DEFAULT_MODEL = process.env.DEFAULT_MODEL ?? 'gpt-5.4';
|
package/src/setup/wizard.ts
CHANGED
|
@@ -202,13 +202,13 @@ export class SetupWizardController {
|
|
|
202
202
|
if (this.configWritten) {
|
|
203
203
|
lines.push('');
|
|
204
204
|
lines.push(theme.muted(' Default thresholds (to customize, run the command shown):'));
|
|
205
|
-
lines.push(` min_edge_threshold = 5% ${theme.muted('e.g.
|
|
206
|
-
lines.push(` kelly_multiplier = 0.5 ${theme.muted('e.g.
|
|
207
|
-
lines.push(` max_position_pct = 10% ${theme.muted('e.g.
|
|
208
|
-
lines.push(` daily_loss_limit = $200 ${theme.muted('e.g.
|
|
209
|
-
lines.push(` max_positions = 10 ${theme.muted('e.g.
|
|
205
|
+
lines.push(` min_edge_threshold = 5% ${theme.muted('e.g. kalshi config risk.min_edge_threshold 0.10')}`);
|
|
206
|
+
lines.push(` kelly_multiplier = 0.5 ${theme.muted('e.g. kalshi config risk.kelly_multiplier 0.25')}`);
|
|
207
|
+
lines.push(` max_position_pct = 10% ${theme.muted('e.g. kalshi config risk.max_position_pct 0.05')}`);
|
|
208
|
+
lines.push(` daily_loss_limit = $200 ${theme.muted('e.g. kalshi config risk.daily_loss_limit 100')}`);
|
|
209
|
+
lines.push(` max_positions = 10 ${theme.muted('e.g. kalshi config risk.max_positions 5')}`);
|
|
210
210
|
lines.push('');
|
|
211
|
-
lines.push(theme.muted(' Run "
|
|
211
|
+
lines.push(theme.muted(' Run "kalshi config" to see all settings.'));
|
|
212
212
|
}
|
|
213
213
|
return lines;
|
|
214
214
|
}
|
package/src/utils/env.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
|
|
2
2
|
import { resolve } from 'path';
|
|
3
3
|
import { config } from 'dotenv';
|
|
4
|
-
import { getProviderById } from '
|
|
4
|
+
import { getProviderById } from '../providers.js';
|
|
5
5
|
import { appPath, getAppDir } from './paths.js';
|
|
6
6
|
|
|
7
7
|
// Resolve .env from a CWD override (dev workflow) or the home config dir
|
package/src/utils/model.ts
CHANGED