@quantish/agent 0.1.6 → 0.1.7
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 +152 -140
- package/dist/index.js +21 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,45 +1,19 @@
|
|
|
1
|
-
# @quantish/
|
|
1
|
+
# @quantish/agent
|
|
2
2
|
|
|
3
|
-
AI-powered CLI agent for building trading bots on Polymarket.
|
|
3
|
+
AI-powered CLI agent for building trading bots and applications on Polymarket.
|
|
4
4
|
|
|
5
5
|
Combines **coding tools** (file system, shell, git) with **trading tools** (Polymarket orders, positions, wallet) powered by Claude AI.
|
|
6
6
|
|
|
7
|
-
## How It Works
|
|
8
|
-
|
|
9
|
-
Quantish CLI connects to the **Quantish Signing Server** to execute trades on Polymarket. Here's why:
|
|
10
|
-
|
|
11
|
-
### Why We Use a Signing Server
|
|
12
|
-
|
|
13
|
-
Polymarket uses a **gasless relayer system** - this means:
|
|
14
|
-
- ✅ **Free wallet creation** - No MATIC needed to set up
|
|
15
|
-
- ✅ **Free trading** - Polymarket covers gas fees on all transactions
|
|
16
|
-
- ✅ **Simplified signing** - Our server handles the complex signature formats
|
|
17
|
-
|
|
18
|
-
To make this work reliably, the Quantish Signing Server:
|
|
19
|
-
1. **Handles wallet creation** - Your wallet is created and managed through our server
|
|
20
|
-
2. **Signs transactions** - Orders are signed using Polymarket's required format
|
|
21
|
-
3. **Relays to Polymarket** - Transactions go through Polymarket's official relayer
|
|
22
|
-
4. **Bypasses geo-restrictions** - Our server is hosted in a compatible region
|
|
23
|
-
|
|
24
|
-
### What This Means for You
|
|
25
|
-
|
|
26
|
-
- **Your funds are secure** - Only you can authorize transactions via your API key
|
|
27
|
-
- **Wallets are non-custodial** - You can export your private key anytime with `export_private_key`
|
|
28
|
-
- **Trading is free** - No gas fees, ever
|
|
29
|
-
- **It just works** - No VPN or complex setup needed
|
|
30
|
-
|
|
31
|
-
> 🔒 **Security Note**: Your private keys are stored encrypted. You can export them and migrate to a self-hosted solution in the future if needed.
|
|
32
|
-
|
|
33
7
|
## Installation
|
|
34
8
|
|
|
35
9
|
```bash
|
|
36
|
-
npm install -g @quantish/
|
|
10
|
+
npm install -g @quantish/agent
|
|
37
11
|
```
|
|
38
12
|
|
|
39
13
|
Or run directly with npx:
|
|
40
14
|
|
|
41
15
|
```bash
|
|
42
|
-
npx @quantish/
|
|
16
|
+
npx @quantish/agent
|
|
43
17
|
```
|
|
44
18
|
|
|
45
19
|
## Quick Start
|
|
@@ -67,15 +41,15 @@ quantish
|
|
|
67
41
|
Example conversations:
|
|
68
42
|
|
|
69
43
|
```
|
|
70
|
-
You: Create a trading bot that monitors
|
|
71
|
-
Assistant: I'll create that for you. Let me first
|
|
72
|
-
[Calling
|
|
73
|
-
[Writing
|
|
44
|
+
You: Create a trading bot that monitors Bitcoin markets and alerts on price changes
|
|
45
|
+
Assistant: I'll create that for you. Let me first search for Bitcoin markets...
|
|
46
|
+
[Calling search_markets...]
|
|
47
|
+
[Writing bitcoin-monitor.js...]
|
|
74
48
|
|
|
75
49
|
You: What's my current balance?
|
|
76
|
-
Assistant: Your Safe wallet has
|
|
50
|
+
Assistant: Your Safe wallet has 125.50 USDC available for trading.
|
|
77
51
|
|
|
78
|
-
You: Place a $
|
|
52
|
+
You: Place a $10 YES order on Trump winning at 55 cents
|
|
79
53
|
Assistant: Order placed! Order ID: abc123...
|
|
80
54
|
```
|
|
81
55
|
|
|
@@ -85,12 +59,6 @@ Assistant: Order placed! Order ID: abc123...
|
|
|
85
59
|
quantish -p "check my open orders"
|
|
86
60
|
```
|
|
87
61
|
|
|
88
|
-
**Piped input:**
|
|
89
|
-
|
|
90
|
-
```bash
|
|
91
|
-
echo "show my positions" | quantish
|
|
92
|
-
```
|
|
93
|
-
|
|
94
62
|
## Commands
|
|
95
63
|
|
|
96
64
|
| Command | Description |
|
|
@@ -98,6 +66,8 @@ echo "show my positions" | quantish
|
|
|
98
66
|
| `quantish` | Start interactive chat |
|
|
99
67
|
| `quantish init` | Configure API keys |
|
|
100
68
|
| `quantish config` | View configuration |
|
|
69
|
+
| `quantish config --server <url>` | Set custom MCP server URL |
|
|
70
|
+
| `quantish config --export` | Export keys for standalone apps |
|
|
101
71
|
| `quantish tools` | List available tools |
|
|
102
72
|
| `quantish -p "..."` | Run one-shot prompt |
|
|
103
73
|
|
|
@@ -112,124 +82,173 @@ echo "show my positions" | quantish
|
|
|
112
82
|
| `--version` | Show version |
|
|
113
83
|
| `--help` | Show help |
|
|
114
84
|
|
|
115
|
-
##
|
|
85
|
+
## Building Standalone Applications
|
|
116
86
|
|
|
117
|
-
|
|
87
|
+
The real power of Quantish is building standalone applications that interact with prediction markets. The agent can create trading bots, web dashboards, notification systems, and more.
|
|
118
88
|
|
|
119
|
-
|
|
120
|
-
|------|-------------|
|
|
121
|
-
| `read_file` | Read file contents |
|
|
122
|
-
| `write_file` | Write/create files |
|
|
123
|
-
| `list_dir` | List directory contents |
|
|
124
|
-
| `delete_file` | Delete files |
|
|
125
|
-
| `file_exists` | Check if file exists |
|
|
126
|
-
| `run_command` | Execute shell commands |
|
|
127
|
-
| `grep` | Search file contents |
|
|
128
|
-
| `find_files` | Find files by pattern |
|
|
129
|
-
| `git_status` | Get git status |
|
|
130
|
-
| `git_diff` | Show git diff |
|
|
131
|
-
| `git_add` | Stage files |
|
|
132
|
-
| `git_commit` | Create commits |
|
|
133
|
-
| `git_log` | Show commit history |
|
|
134
|
-
| `git_checkout` | Switch branches |
|
|
135
|
-
| `web_search` | Search the web (Exa/DuckDuckGo) |
|
|
136
|
-
| `web_answer` | AI-powered Q&A (Exa) |
|
|
137
|
-
| `fetch_url` | Fetch URL content |
|
|
89
|
+
### MCP API Overview
|
|
138
90
|
|
|
139
|
-
|
|
91
|
+
There are two MCP endpoints:
|
|
140
92
|
|
|
141
|
-
|
|
|
142
|
-
|
|
143
|
-
|
|
|
144
|
-
|
|
|
145
|
-
| `place_order` | Place buy/sell orders |
|
|
146
|
-
| `cancel_order` | Cancel open orders |
|
|
147
|
-
| `get_orders` | List orders |
|
|
148
|
-
| `get_orderbook` | Get market orderbook |
|
|
149
|
-
| `get_price` | Get current price |
|
|
150
|
-
| `transfer_usdc` | Transfer USDC |
|
|
151
|
-
| `swap_tokens` | Swap tokens |
|
|
152
|
-
| `claim_winnings` | Claim from resolved markets |
|
|
93
|
+
| Endpoint | Purpose | Auth Required |
|
|
94
|
+
|----------|---------|---------------|
|
|
95
|
+
| Trading API | Wallet, orders, positions | Yes (QUANTISH_API_KEY) |
|
|
96
|
+
| Discovery API | Search markets, prices | No (public key) |
|
|
153
97
|
|
|
154
|
-
|
|
98
|
+
### Trading API (Requires Your API Key)
|
|
155
99
|
|
|
156
|
-
|
|
100
|
+
```javascript
|
|
101
|
+
const response = await fetch('https://quantish-sdk-production.up.railway.app/mcp/execute', {
|
|
102
|
+
method: 'POST',
|
|
103
|
+
headers: {
|
|
104
|
+
'Content-Type': 'application/json',
|
|
105
|
+
'x-api-key': process.env.QUANTISH_API_KEY
|
|
106
|
+
},
|
|
107
|
+
body: JSON.stringify({
|
|
108
|
+
jsonrpc: '2.0',
|
|
109
|
+
method: 'tools/call',
|
|
110
|
+
params: { name: 'get_balances', arguments: {} },
|
|
111
|
+
id: Date.now()
|
|
112
|
+
})
|
|
113
|
+
});
|
|
157
114
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
"anthropicApiKey": "sk-ant-...",
|
|
161
|
-
"quantishApiKey": "pk_live_...",
|
|
162
|
-
"mcpServerUrl": "https://quantish-sdk-production.up.railway.app/mcp"
|
|
163
|
-
}
|
|
115
|
+
const data = await response.json();
|
|
116
|
+
const result = JSON.parse(data.result.content[0].text);
|
|
164
117
|
```
|
|
165
118
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
119
|
+
**Trading Tools:** `get_balances`, `get_positions`, `place_order`, `cancel_order`, `get_orders`, `get_orderbook`, `get_price`, `transfer_usdc`
|
|
120
|
+
|
|
121
|
+
### Discovery API (Free, No Auth)
|
|
122
|
+
|
|
123
|
+
```javascript
|
|
124
|
+
const response = await fetch('https://quantish.live/mcp/execute', {
|
|
125
|
+
method: 'POST',
|
|
126
|
+
headers: {
|
|
127
|
+
'Content-Type': 'application/json',
|
|
128
|
+
'X-API-Key': 'qm_ueQeqrmvZyHtR1zuVbLYkhx0fKyVAuV8' // Public key
|
|
129
|
+
},
|
|
130
|
+
body: JSON.stringify({
|
|
131
|
+
name: 'search_markets', // Simple format for Discovery
|
|
132
|
+
arguments: { query: 'bitcoin', limit: 5 }
|
|
133
|
+
})
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
const data = await response.json();
|
|
137
|
+
const result = JSON.parse(data.result.content[0].text);
|
|
138
|
+
```
|
|
169
139
|
|
|
170
|
-
|
|
140
|
+
**Discovery Tools:** `search_markets`, `get_market_details`, `get_trending_markets`, `find_arbitrage`
|
|
171
141
|
|
|
172
|
-
### Build
|
|
142
|
+
### Example: Ask the Agent to Build an App
|
|
173
143
|
|
|
174
144
|
```bash
|
|
175
145
|
quantish
|
|
176
|
-
> Create a
|
|
146
|
+
> Create a Node.js script that monitors Bitcoin markets and sends a Discord notification when prices move more than 10%
|
|
177
147
|
```
|
|
178
148
|
|
|
179
|
-
|
|
149
|
+
The agent will create all necessary files:
|
|
150
|
+
- Main application code with MCP helper functions
|
|
151
|
+
- `package.json` with dependencies
|
|
152
|
+
- `.env.example` with required environment variables
|
|
153
|
+
- `README.md` with setup instructions
|
|
154
|
+
|
|
155
|
+
## Architecture
|
|
180
156
|
|
|
181
|
-
```
|
|
182
|
-
quantish
|
|
157
|
+
```
|
|
158
|
+
quantish (CLI)
|
|
159
|
+
│
|
|
160
|
+
├── Local Tools (filesystem, shell, git)
|
|
161
|
+
│ └── Runs directly on your machine
|
|
162
|
+
│
|
|
163
|
+
└── MCP Tools (trading + discovery)
|
|
164
|
+
├── Trading MCP (your wallet, orders)
|
|
165
|
+
│ └── https://quantish-sdk-production.up.railway.app/mcp
|
|
166
|
+
│
|
|
167
|
+
└── Discovery MCP (public market data)
|
|
168
|
+
└── https://quantish.live/mcp
|
|
183
169
|
```
|
|
184
170
|
|
|
185
|
-
|
|
171
|
+
## Self-Hosting
|
|
186
172
|
|
|
187
|
-
|
|
188
|
-
quantish
|
|
189
|
-
> Help me set up a basic market making strategy. I want to place both bid and ask orders around the current mid price.
|
|
190
|
-
```
|
|
173
|
+
You can run your own Trading MCP server for full control over your wallet keys.
|
|
191
174
|
|
|
192
|
-
###
|
|
175
|
+
### Configure Custom Server
|
|
193
176
|
|
|
194
177
|
```bash
|
|
195
|
-
|
|
196
|
-
|
|
178
|
+
# Set via CLI
|
|
179
|
+
quantish config --server https://your-server.com/mcp
|
|
180
|
+
|
|
181
|
+
# Or via environment variable
|
|
182
|
+
export MCP_SERVER_URL=https://your-server.com/mcp
|
|
197
183
|
```
|
|
198
184
|
|
|
199
|
-
|
|
185
|
+
### What You Need
|
|
200
186
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
187
|
+
1. **Server**: Deploy the `quantish-server` to Railway, Render, or your own VPS
|
|
188
|
+
2. **Database**: PostgreSQL for user data and encrypted keys
|
|
189
|
+
3. **Polymarket Builder Credentials**: Apply at https://polymarket.com/builder
|
|
204
190
|
|
|
205
|
-
|
|
206
|
-
cd packages/quantish-cli
|
|
207
|
-
npm install
|
|
191
|
+
See [Self-Hosting Guide](https://quantish.live/docs/self-hosting.html) for full instructions.
|
|
208
192
|
|
|
209
|
-
|
|
210
|
-
npm run build
|
|
193
|
+
## Configuration
|
|
211
194
|
|
|
212
|
-
|
|
213
|
-
npm start
|
|
195
|
+
Configuration is stored in `~/.quantish/config.json`:
|
|
214
196
|
|
|
215
|
-
|
|
216
|
-
|
|
197
|
+
```json
|
|
198
|
+
{
|
|
199
|
+
"anthropicApiKey": "sk-ant-...",
|
|
200
|
+
"quantishApiKey": "qtsh_...",
|
|
201
|
+
"mcpServerUrl": "https://quantish-sdk-production.up.railway.app/mcp",
|
|
202
|
+
"model": "claude-sonnet-4-5-20250929"
|
|
203
|
+
}
|
|
217
204
|
```
|
|
218
205
|
|
|
219
|
-
|
|
206
|
+
Environment variables take precedence:
|
|
207
|
+
- `ANTHROPIC_API_KEY`
|
|
208
|
+
- `QUANTISH_API_KEY`
|
|
209
|
+
- `MCP_SERVER_URL`
|
|
220
210
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
211
|
+
## Available Tools
|
|
212
|
+
|
|
213
|
+
### Local Tools (Coding)
|
|
214
|
+
|
|
215
|
+
| Tool | Description |
|
|
216
|
+
|------|-------------|
|
|
217
|
+
| `read_file` | Read file contents |
|
|
218
|
+
| `write_file` | Write/create files |
|
|
219
|
+
| `edit_file` | Search and replace in files |
|
|
220
|
+
| `list_dir` | List directory contents |
|
|
221
|
+
| `delete_file` | Delete files |
|
|
222
|
+
| `setup_env` | Create/update .env files |
|
|
223
|
+
| `run_command` | Execute shell commands |
|
|
224
|
+
| `grep` | Search file contents |
|
|
225
|
+
| `find_files` | Find files by pattern |
|
|
226
|
+
| `git_status` | Get git status |
|
|
227
|
+
| `git_diff` | Show git diff |
|
|
228
|
+
| `git_add` | Stage files |
|
|
229
|
+
| `git_commit` | Create commits |
|
|
230
|
+
|
|
231
|
+
### MCP Tools (Trading)
|
|
232
|
+
|
|
233
|
+
| Tool | Description |
|
|
234
|
+
|------|-------------|
|
|
235
|
+
| `get_balances` | Check wallet balances |
|
|
236
|
+
| `get_positions` | View current positions |
|
|
237
|
+
| `place_order` | Place buy/sell orders |
|
|
238
|
+
| `cancel_order` | Cancel open orders |
|
|
239
|
+
| `get_orders` | List orders |
|
|
240
|
+
| `get_orderbook` | Get market orderbook |
|
|
241
|
+
| `get_price` | Get current price |
|
|
242
|
+
| `transfer_usdc` | Transfer USDC |
|
|
231
243
|
|
|
232
|
-
|
|
244
|
+
### MCP Tools (Discovery)
|
|
245
|
+
|
|
246
|
+
| Tool | Description |
|
|
247
|
+
|------|-------------|
|
|
248
|
+
| `search_markets` | Search markets by keyword |
|
|
249
|
+
| `get_market_details` | Get full market info |
|
|
250
|
+
| `get_trending_markets` | Popular markets |
|
|
251
|
+
| `find_arbitrage` | Find price discrepancies |
|
|
233
252
|
|
|
234
253
|
## Platform Support
|
|
235
254
|
|
|
@@ -239,23 +258,16 @@ The agent uses Claude to understand your requests and decide which tools to use.
|
|
|
239
258
|
| Linux | ✅ Full support |
|
|
240
259
|
| Windows | ⚠️ Requires WSL |
|
|
241
260
|
|
|
242
|
-
**Windows users:** Install [WSL
|
|
243
|
-
|
|
244
|
-
## Environment Variables
|
|
245
|
-
|
|
246
|
-
| Variable | Description |
|
|
247
|
-
|----------|-------------|
|
|
248
|
-
| `ANTHROPIC_API_KEY` | Your Anthropic API key (required) |
|
|
249
|
-
| `QUANTISH_API_KEY` | Your Quantish trading API key |
|
|
250
|
-
| `EXA_API_KEY` | Optional: Exa AI search key for powerful web search |
|
|
261
|
+
**Windows users:** Install [WSL](https://learn.microsoft.com/en-us/windows/wsl/install) and run Quantish from within WSL.
|
|
251
262
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
Web search works without API keys (using DuckDuckGo fallback), but **Exa is strongly recommended** for AI-quality search results.
|
|
263
|
+
## How It Works
|
|
255
264
|
|
|
256
|
-
|
|
265
|
+
Quantish CLI connects to the **Quantish Signing Server** to execute trades on Polymarket:
|
|
257
266
|
|
|
258
|
-
|
|
267
|
+
- **Your funds are secure** - Only you can authorize transactions via your API key
|
|
268
|
+
- **Wallets are non-custodial** - Export your private key anytime with `export_private_key`
|
|
269
|
+
- **Trading is free** - No gas fees (Polymarket covers them)
|
|
270
|
+
- **Self-hosting available** - Run your own server for full control
|
|
259
271
|
|
|
260
272
|
## License
|
|
261
273
|
|
package/dist/index.js
CHANGED
|
@@ -70,8 +70,11 @@ var ConfigManager = class {
|
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
72
|
* Get the Trading MCP server URL (user's wallet/orders)
|
|
73
|
+
* Priority: MCP_SERVER_URL env var > config file > default
|
|
73
74
|
*/
|
|
74
75
|
getMcpServerUrl() {
|
|
76
|
+
const envUrl = process.env.MCP_SERVER_URL;
|
|
77
|
+
if (envUrl) return envUrl;
|
|
75
78
|
return this.conf.get("mcpServerUrl") ?? DEFAULT_MCP_URL;
|
|
76
79
|
}
|
|
77
80
|
/**
|
|
@@ -98,6 +101,12 @@ var ConfigManager = class {
|
|
|
98
101
|
setMcpServerUrl(url) {
|
|
99
102
|
this.conf.set("mcpServerUrl", url);
|
|
100
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* Generic setter for any config key
|
|
106
|
+
*/
|
|
107
|
+
set(key, value) {
|
|
108
|
+
this.conf.set(key, value);
|
|
109
|
+
}
|
|
101
110
|
/**
|
|
102
111
|
* Get the model to use
|
|
103
112
|
*/
|
|
@@ -4206,8 +4215,19 @@ program.name("quantish").description("AI coding & trading agent for Polymarket")
|
|
|
4206
4215
|
program.command("init").description("Configure Quantish CLI with your API keys").action(async () => {
|
|
4207
4216
|
await runSetup();
|
|
4208
4217
|
});
|
|
4209
|
-
program.command("config").description("View or edit configuration").option("-s, --show", "Show current configuration").option("-c, --clear", "Clear all configuration").option("--path", "Show config file path").option("--export", "Export configuration as .env format").option("--show-keys", "Show full API keys (use with caution)").action(async (options) => {
|
|
4218
|
+
program.command("config").description("View or edit configuration").option("-s, --show", "Show current configuration").option("-c, --clear", "Clear all configuration").option("--path", "Show config file path").option("--export", "Export configuration as .env format").option("--show-keys", "Show full API keys (use with caution)").option("--server <url>", "Set custom Trading MCP server URL").action(async (options) => {
|
|
4210
4219
|
const config = getConfigManager();
|
|
4220
|
+
if (options.server) {
|
|
4221
|
+
try {
|
|
4222
|
+
new URL(options.server);
|
|
4223
|
+
} catch {
|
|
4224
|
+
error("Invalid URL format. Please provide a valid URL (e.g., https://your-server.com/mcp)");
|
|
4225
|
+
return;
|
|
4226
|
+
}
|
|
4227
|
+
config.set("mcpServerUrl", options.server);
|
|
4228
|
+
success(`Trading MCP server URL set to: ${options.server}`);
|
|
4229
|
+
return;
|
|
4230
|
+
}
|
|
4211
4231
|
if (options.path) {
|
|
4212
4232
|
console.log(config.getConfigPath());
|
|
4213
4233
|
return;
|