agenttrader 0.1.0__tar.gz

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 (54) hide show
  1. agenttrader-0.1.0/CHANGELOG.md +4 -0
  2. agenttrader-0.1.0/LICENSE +21 -0
  3. agenttrader-0.1.0/MANIFEST.in +9 -0
  4. agenttrader-0.1.0/PKG-INFO +514 -0
  5. agenttrader-0.1.0/README.md +472 -0
  6. agenttrader-0.1.0/agenttrader/__init__.py +4 -0
  7. agenttrader-0.1.0/agenttrader/cli/__init__.py +1 -0
  8. agenttrader-0.1.0/agenttrader/cli/backtest.py +285 -0
  9. agenttrader-0.1.0/agenttrader/cli/config.py +74 -0
  10. agenttrader-0.1.0/agenttrader/cli/dashboard.py +15 -0
  11. agenttrader-0.1.0/agenttrader/cli/main.py +43 -0
  12. agenttrader-0.1.0/agenttrader/cli/markets.py +206 -0
  13. agenttrader-0.1.0/agenttrader/cli/paper.py +223 -0
  14. agenttrader-0.1.0/agenttrader/cli/prune.py +65 -0
  15. agenttrader-0.1.0/agenttrader/cli/sync.py +128 -0
  16. agenttrader-0.1.0/agenttrader/cli/utils.py +52 -0
  17. agenttrader-0.1.0/agenttrader/cli/validate.py +181 -0
  18. agenttrader-0.1.0/agenttrader/config.py +53 -0
  19. agenttrader-0.1.0/agenttrader/core/__init__.py +3 -0
  20. agenttrader-0.1.0/agenttrader/core/backtest_engine.py +187 -0
  21. agenttrader-0.1.0/agenttrader/core/base_strategy.py +113 -0
  22. agenttrader-0.1.0/agenttrader/core/context.py +567 -0
  23. agenttrader-0.1.0/agenttrader/core/fill_model.py +114 -0
  24. agenttrader-0.1.0/agenttrader/core/paper_daemon.py +185 -0
  25. agenttrader-0.1.0/agenttrader/core/paper_daemon_runner.py +18 -0
  26. agenttrader-0.1.0/agenttrader/core/scheduler.py +8 -0
  27. agenttrader-0.1.0/agenttrader/dashboard/__init__.py +3 -0
  28. agenttrader-0.1.0/agenttrader/dashboard/server.py +210 -0
  29. agenttrader-0.1.0/agenttrader/dashboard/static/app.js +184 -0
  30. agenttrader-0.1.0/agenttrader/dashboard/static/index.html +64 -0
  31. agenttrader-0.1.0/agenttrader/data/__init__.py +12 -0
  32. agenttrader-0.1.0/agenttrader/data/cache.py +219 -0
  33. agenttrader-0.1.0/agenttrader/data/dome_client.py +418 -0
  34. agenttrader-0.1.0/agenttrader/data/models.py +87 -0
  35. agenttrader-0.1.0/agenttrader/data/orderbook_store.py +134 -0
  36. agenttrader-0.1.0/agenttrader/db/__init__.py +17 -0
  37. agenttrader-0.1.0/agenttrader/db/migrations/__init__.py +0 -0
  38. agenttrader-0.1.0/agenttrader/db/migrations/versions/__init__.py +0 -0
  39. agenttrader-0.1.0/agenttrader/db/schema.py +110 -0
  40. agenttrader-0.1.0/agenttrader/errors.py +37 -0
  41. agenttrader-0.1.0/agenttrader/mcp/__init__.py +3 -0
  42. agenttrader-0.1.0/agenttrader/mcp/server.py +304 -0
  43. agenttrader-0.1.0/agenttrader.egg-info/PKG-INFO +514 -0
  44. agenttrader-0.1.0/agenttrader.egg-info/SOURCES.txt +52 -0
  45. agenttrader-0.1.0/agenttrader.egg-info/dependency_links.txt +1 -0
  46. agenttrader-0.1.0/agenttrader.egg-info/entry_points.txt +2 -0
  47. agenttrader-0.1.0/agenttrader.egg-info/requires.txt +21 -0
  48. agenttrader-0.1.0/agenttrader.egg-info/top_level.txt +1 -0
  49. agenttrader-0.1.0/alembic/env.py +54 -0
  50. agenttrader-0.1.0/alembic/script.py.mako +26 -0
  51. agenttrader-0.1.0/alembic/versions/0001_initial.py +127 -0
  52. agenttrader-0.1.0/alembic.ini +36 -0
  53. agenttrader-0.1.0/pyproject.toml +76 -0
  54. agenttrader-0.1.0/setup.cfg +4 -0
@@ -0,0 +1,4 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0
4
+ - Initial release.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Finn Fujimura
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,9 @@
1
+ include README.md
2
+ include CHANGELOG.md
3
+ include LICENSE
4
+ include pyproject.toml
5
+ include alembic.ini
6
+ recursive-include alembic *.py *.mako
7
+ recursive-include agenttrader/dashboard/static *
8
+ recursive-include agenttrader/db/migrations *.py
9
+ recursive-include agenttrader/db/migrations/versions *.py
@@ -0,0 +1,514 @@
1
+ Metadata-Version: 2.4
2
+ Name: agenttrader
3
+ Version: 0.1.0
4
+ Summary: Prediction market strategy research, backtesting, and paper trading toolkit
5
+ Author: Finn Fujimura
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/finnfujimura/agenttrader
8
+ Project-URL: Repository, https://github.com/finnfujimura/agenttrader
9
+ Project-URL: Issues, https://github.com/finnfujimura/agenttrader/issues
10
+ Keywords: trading,prediction-markets,polymarket,kalshi,backtesting,mcp,agents
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Topic :: Office/Business :: Financial :: Investment
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Requires-Python: >=3.12
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: dome-api-sdk>=1.0.0
22
+ Requires-Dist: click>=8.1
23
+ Requires-Dist: mcp>=1.0.0
24
+ Requires-Dist: sqlalchemy>=2.0
25
+ Requires-Dist: alembic>=1.13
26
+ Requires-Dist: pyyaml>=6.0
27
+ Requires-Dist: watchdog>=4.0
28
+ Requires-Dist: msgpack>=1.0
29
+ Requires-Dist: tenacity>=8.0
30
+ Requires-Dist: fastapi>=0.110
31
+ Requires-Dist: uvicorn>=0.29
32
+ Requires-Dist: websockets>=12.0
33
+ Requires-Dist: rich>=13.0
34
+ Requires-Dist: numpy>=2.0
35
+ Provides-Extra: dev
36
+ Requires-Dist: pytest>=8.0; extra == "dev"
37
+ Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
38
+ Requires-Dist: pytest-cov>=5.0; extra == "dev"
39
+ Requires-Dist: ruff>=0.4; extra == "dev"
40
+ Requires-Dist: mypy>=1.10; extra == "dev"
41
+ Dynamic: license-file
42
+
43
+ # agenttrader
44
+
45
+ `agenttrader` is a toolkit that lets AI agents autonomously research, write, backtest, and deploy prediction market trading strategies — without human intervention.
46
+
47
+ Give an agent a goal. It handles everything: discovering markets on Polymarket and Kalshi, analyzing price history, writing strategy code, running the backtesting loop, and starting a live paper trading daemon. Running strategies hot-reload automatically when the strategy file changes — agents can iterate on live deployments without restarting.
48
+
49
+ All market data flows through the [Dome API](https://domeapi.io), unified across Polymarket and Kalshi.
50
+
51
+ **Primary users:** AI coding agents (Claude Code, Codex, OpenCode, Cursor).
52
+ **Secondary users:** Developers who want to write and test strategies manually.
53
+
54
+ ---
55
+
56
+ ## How It Works
57
+
58
+ ```
59
+ Agent receives goal
60
+
61
+
62
+ agenttrader sync ← pull market data into local cache
63
+
64
+
65
+ agenttrader markets list ← discover opportunities
66
+
67
+
68
+ [agent writes strategy.py]
69
+
70
+
71
+ agenttrader validate ← catch errors before they waste time
72
+
73
+
74
+ agenttrader backtest ← test against real historical data
75
+
76
+ ├─── metrics look bad? agent edits strategy.py, loops back
77
+
78
+
79
+ agenttrader paper start ← deploy as background daemon
80
+
81
+
82
+ [agent edits strategy.py] ← daemon hot-reloads, no restart needed
83
+ ```
84
+
85
+ All state lives locally in `~/.agenttrader/`. No cloud backend. No app account required. (A Dome API key is still required for market data access.)
86
+
87
+ ---
88
+
89
+ ## Quickstart
90
+
91
+ ### Prerequisites
92
+
93
+ ```bash
94
+ python --version # 3.12+ required
95
+ pip --version
96
+ ```
97
+
98
+ Get a free Dome API key at [dashboard.domeapi.io](https://dashboard.domeapi.io).
99
+
100
+ ### Install
101
+
102
+ ```bash
103
+ pip install agenttrader
104
+ agenttrader init
105
+ agenttrader config set dome_api_key <YOUR_DOME_KEY>
106
+ ```
107
+
108
+ ### Verify it works
109
+
110
+ ```bash
111
+ agenttrader sync --platform polymarket --days 2 --limit 5 --json
112
+ agenttrader markets list --json
113
+ ```
114
+
115
+ If you see markets in the output, you're ready.
116
+
117
+ ---
118
+
119
+ ## Using agenttrader With Your Agent
120
+
121
+ There are two ways to connect your agent to agenttrader. **MCP is recommended** — it's the most natural interface for agents. CLI mode works as a fallback if MCP isn't available.
122
+
123
+ ---
124
+
125
+ ### Option A: MCP (Recommended)
126
+
127
+ MCP lets your agent call agenttrader tools as native function calls — no shell commands, no output parsing. The agent calls `get_markets()`, `run_backtest()`, `start_paper_trade()` directly inside its reasoning loop.
128
+
129
+ **Setup for Claude Code**
130
+
131
+ Add this to `.claude/mcp.json` in your project directory:
132
+
133
+ ```json
134
+ {
135
+ "mcpServers": {
136
+ "agenttrader": {
137
+ "command": "agenttrader",
138
+ "args": ["mcp"]
139
+ }
140
+ }
141
+ }
142
+ ```
143
+
144
+ Restart Claude Code. The MCP server starts automatically — you never run `agenttrader mcp` manually.
145
+
146
+ **Setup for Cursor**
147
+
148
+ In Cursor settings → MCP → add server:
149
+
150
+ ```json
151
+ {
152
+ "name": "agenttrader",
153
+ "command": "agenttrader",
154
+ "args": ["mcp"],
155
+ "transport": "stdio"
156
+ }
157
+ ```
158
+
159
+ **Setup for any other MCP-compatible agent**
160
+
161
+ ```json
162
+ {
163
+ "mcpServers": {
164
+ "agenttrader": {
165
+ "command": "agenttrader",
166
+ "args": ["mcp"]
167
+ }
168
+ }
169
+ }
170
+ ```
171
+
172
+ The transport is `stdio`. The agent spawns `agenttrader mcp` as a subprocess and communicates over stdin/stdout. No port, no server to keep running.
173
+
174
+ **Available MCP tools**
175
+
176
+ | Category | Tools |
177
+ |----------|-------|
178
+ | Markets | `get_markets`, `get_price`, `get_history`, `match_markets` |
179
+ | Strategy | `validate_strategy`, `run_backtest`, `get_backtest`, `list_backtests` |
180
+ | Paper trading | `start_paper_trade`, `get_portfolio`, `stop_paper_trade`, `list_paper_trades` |
181
+ | Data | `sync_data` |
182
+
183
+ **Example agent prompts (MCP mode)**
184
+
185
+ Once connected, give your agent natural language goals:
186
+
187
+ ```
188
+ Use agenttrader to find the 10 most liquid Polymarket politics markets.
189
+ Build a mean reversion strategy in ./strategy.py. Backtest it from
190
+ 2024-06-01 to 2024-12-31 with $10,000 starting cash. Iterate until
191
+ Sharpe ratio > 1.0 and max drawdown better than -20%. Then start
192
+ paper trading and report the portfolio_id.
193
+ ```
194
+
195
+ ```
196
+ Check my current paper trading portfolio. If any position has been
197
+ open for more than 7 days with negative PnL, update the strategy
198
+ to add a stop-loss and let me know what changed.
199
+ ```
200
+
201
+ ```
202
+ Find prediction markets on both Polymarket and Kalshi covering the
203
+ same event. Write an arbitrage strategy that trades the price
204
+ discrepancy when it exceeds 3 cents. Backtest it and paper trade it.
205
+ ```
206
+
207
+ The agent will chain tool calls autonomously — syncing data, writing and editing `strategy.py`, running backtests, reading metrics, iterating, and deploying — without you touching a terminal.
208
+
209
+ ---
210
+
211
+ ### Option B: CLI Mode
212
+
213
+ If your agent can run shell commands (most can), it can use agenttrader without any MCP setup. Every command supports `--json` for clean, parseable output.
214
+
215
+ **Setup**
216
+
217
+ No configuration needed beyond the initial install. Your agent runs commands like:
218
+
219
+ ```bash
220
+ agenttrader sync --platform polymarket --days 7 --limit 20 --json
221
+ agenttrader markets list --platform polymarket --json
222
+ agenttrader validate ./strategy.py --json
223
+ agenttrader backtest ./strategy.py --from 2024-01-01 --to 2024-06-01 --json
224
+ agenttrader paper start ./strategy.py --cash 5000 --json
225
+ agenttrader paper status <portfolio_id> --json
226
+ ```
227
+
228
+ **Example agent prompts (CLI mode)**
229
+
230
+ For Claude Code without MCP configured:
231
+
232
+ ```
233
+ Use the agenttrader CLI to research Polymarket crypto markets.
234
+ Run: agenttrader markets list --platform polymarket --category crypto --json
235
+ Then build a strategy in ./strategy.py and iterate using:
236
+ agenttrader validate ./strategy.py --json
237
+ agenttrader backtest ./strategy.py --from 2024-01-01 --to 2024-06-01 --json
238
+ Keep iterating until Sharpe > 1.0, then run:
239
+ agenttrader paper start ./strategy.py --json
240
+ Report the portfolio_id when done.
241
+ ```
242
+
243
+ **The JSON contract**
244
+
245
+ Every `--json` response follows this shape:
246
+
247
+ ```json
248
+ { "ok": true, "...": "..." }
249
+ ```
250
+
251
+ ```json
252
+ { "ok": false, "error": "ErrorType", "message": "Human-readable details" }
253
+ ```
254
+
255
+ Strategy errors include line numbers and tracebacks so agents can self-heal:
256
+
257
+ ```json
258
+ {
259
+ "ok": false,
260
+ "error": "StrategyError",
261
+ "message": "name 'undefined_var' is not defined",
262
+ "file": "./strategy.py",
263
+ "line": 14,
264
+ "traceback": "Traceback (most recent call last):\n ..."
265
+ }
266
+ ```
267
+
268
+ ---
269
+
270
+ ### The Agent Iteration Loop
271
+
272
+ Whether using MCP or CLI, the core loop looks like this:
273
+
274
+ ```
275
+ 1. sync market data
276
+ 2. inspect markets + history
277
+ 3. write strategy.py
278
+ 4. validate --json → fix any errors
279
+ 5. backtest --json → read Sharpe, drawdown, win rate
280
+ 6. edit strategy.py → improve based on metrics
281
+ 7. repeat 4–6 until satisfied
282
+ 8. paper start → deploy daemon
283
+ 9. paper status --json → monitor
284
+ 10. edit strategy.py live → daemon hot-reloads automatically
285
+ ```
286
+
287
+ Steps 3–7 are where agents spend most of their time. A well-prompted agent will iterate 5–10 times before deploying, each time reading the structured backtest metrics and making targeted improvements to the strategy logic.
288
+
289
+ ---
290
+
291
+ ## Strategy Authoring
292
+
293
+ Strategies are plain Python files that subclass `BaseStrategy`. Write them in any editor — or let your agent write them.
294
+
295
+ ```python
296
+ from agenttrader import BaseStrategy
297
+
298
+ class MyStrategy(BaseStrategy):
299
+
300
+ def on_start(self):
301
+ # Subscribe to markets — called once at startup
302
+ self.subscribe(platform="polymarket", category="politics")
303
+
304
+ def on_market_data(self, market, price, orderbook):
305
+ # Called on every price update for subscribed markets
306
+ history = self.get_history(market.id, lookback_hours=48)
307
+ if len(history) < 2:
308
+ return
309
+
310
+ avg = sum(h.yes_price for h in history) / len(history)
311
+
312
+ if price < avg - 0.08 and self.get_position(market.id) is None:
313
+ self.buy(market.id, contracts=20)
314
+ self.log(f"BUY {market.title[:40]} @ {price:.3f}")
315
+
316
+ elif price > avg + 0.05 and self.get_position(market.id):
317
+ self.sell(market.id)
318
+ self.log(f"SELL {market.title[:40]} @ {price:.3f}")
319
+
320
+ def on_schedule(self, now, market):
321
+ # Called every 15 minutes — use for time-based logic
322
+ hours_left = (market.close_time - now.timestamp()) / 3600
323
+ if hours_left < 3 and self.get_position(market.id):
324
+ self.sell(market.id)
325
+ self.log(f"Pre-expiry close: {hours_left:.1f}h left")
326
+
327
+ def on_resolution(self, market, outcome, pnl):
328
+ # Called when a market resolves
329
+ self.log(f"Resolved: {outcome}, PnL: ${pnl:.2f}")
330
+ ```
331
+
332
+ **Available methods inside a strategy:**
333
+
334
+ ```python
335
+ # Subscribe + discover
336
+ self.subscribe(platform, category, tags, market_ids)
337
+ self.search_markets(query, platform)
338
+
339
+ # Price + data (time-bounded in backtesting — no look-ahead bias)
340
+ self.get_price(market_id) # current YES price (0.0–1.0)
341
+ self.get_orderbook(market_id) # bids, asks, best_bid, best_ask, mid
342
+ self.get_history(market_id, lookback_hours) # list of PricePoint objects
343
+
344
+ # Portfolio
345
+ self.get_position(market_id) # open Position or None
346
+ self.get_cash() # available cash
347
+ self.get_portfolio_value() # cash + mark-to-market positions
348
+
349
+ # Orders
350
+ self.buy(market_id, contracts, side="yes", order_type="market")
351
+ self.sell(market_id, contracts=None) # None = sell entire position
352
+
353
+ # Utilities
354
+ self.log(message) # appears in dashboard + paper status
355
+ self.set_state(key, value) # persist state across calls
356
+ self.get_state(key, default)
357
+ ```
358
+
359
+ Do not call the Dome API directly from a strategy. Do not import `requests`, `httpx`, or any networking library. All data access goes through `self.*` methods.
360
+
361
+ ---
362
+
363
+ ## All Commands
364
+
365
+ ### Setup
366
+
367
+ ```bash
368
+ agenttrader init
369
+ agenttrader config set dome_api_key <YOUR_DOME_KEY>
370
+ agenttrader config get dome_api_key
371
+ agenttrader config show
372
+ ```
373
+
374
+ ### Data Sync
375
+
376
+ ```bash
377
+ agenttrader sync # top 100 markets, 90 days
378
+ agenttrader sync --platform polymarket --days 7
379
+ agenttrader sync --platform kalshi --days 7
380
+ agenttrader sync --markets <id1> --markets <id2> # specific markets
381
+ agenttrader sync --json
382
+ ```
383
+
384
+ ### Markets
385
+
386
+ ```bash
387
+ agenttrader markets list
388
+ agenttrader markets list --platform polymarket --limit 20 --json
389
+ agenttrader markets list --category politics --min-volume 50000
390
+ agenttrader markets price <market_id> --json
391
+ agenttrader markets history <market_id> --days 30 --json
392
+ agenttrader markets match --polymarket-slug "<slug>"
393
+ agenttrader markets match --kalshi-ticker "<ticker>"
394
+ ```
395
+
396
+ ### Validate
397
+
398
+ ```bash
399
+ agenttrader validate ./strategy.py
400
+ agenttrader validate ./strategy.py --json
401
+ ```
402
+
403
+ ### Backtest
404
+
405
+ ```bash
406
+ agenttrader backtest ./strategy.py --from 2024-01-01 --to 2024-06-01
407
+ agenttrader backtest ./strategy.py --from 2024-01-01 --to 2024-06-01 --cash 10000
408
+ agenttrader backtest ./strategy.py --from 2024-01-01 --to 2024-06-01 --json
409
+ agenttrader backtest list --json
410
+ agenttrader backtest show <run_id> --json
411
+ ```
412
+
413
+ Backtest results include:
414
+
415
+ ```json
416
+ {
417
+ "metrics": {
418
+ "total_return_pct": 32.4,
419
+ "sharpe_ratio": 1.84,
420
+ "sortino_ratio": 2.31,
421
+ "max_drawdown_pct": -12.3,
422
+ "win_rate": 0.61,
423
+ "profit_factor": 2.14,
424
+ "calmar_ratio": 2.63,
425
+ "avg_slippage": 0.008,
426
+ "total_trades": 47
427
+ },
428
+ "equity_curve": [...],
429
+ "trades": [...]
430
+ }
431
+ ```
432
+
433
+ ### Paper Trading
434
+
435
+ ```bash
436
+ agenttrader paper start ./strategy.py --json
437
+ agenttrader paper start ./strategy.py --cash 5000 --json
438
+ agenttrader paper start ./strategy.py --no-daemon --json # blocking, for testing
439
+ agenttrader paper list --json
440
+ agenttrader paper status <portfolio_id> --json
441
+ agenttrader paper stop <portfolio_id> --json
442
+ agenttrader paper stop --all --json
443
+ ```
444
+
445
+ **Hot-reload:** edit `strategy.py` while a paper trade is running — the daemon detects the change and reloads automatically. Portfolio state is preserved. No restart needed. `paper status` shows `reload_count` to confirm it happened.
446
+
447
+ ### Dashboard
448
+
449
+ ```bash
450
+ agenttrader dashboard # http://localhost:8080
451
+ agenttrader dashboard --port 9090
452
+ ```
453
+
454
+ Read-only local dashboard showing active paper trades, positions, trade history, strategy logs, and backtest results with equity curves.
455
+
456
+ ### Maintenance
457
+
458
+ ```bash
459
+ agenttrader prune --older-than 90d --dry-run --json
460
+ agenttrader prune --older-than 90d --json
461
+ ```
462
+
463
+ ---
464
+
465
+ ## Local Storage
466
+
467
+ ```
468
+ ~/.agenttrader/
469
+ ├── config.yaml # API key and preferences
470
+ ├── db.sqlite # markets, backtests, positions, trade ledger
471
+ └── orderbooks/ # compressed orderbook snapshots by market/day
472
+ ```
473
+
474
+ `db.sqlite` is a standard SQLite file. Agents can query it directly with SQL for custom analysis — for example, `SELECT * FROM markets WHERE volume > 10000 ORDER BY volume DESC`.
475
+
476
+ The Dome API key in `config.yaml` grants access to market data only — no funds or wallets are involved.
477
+
478
+ ---
479
+
480
+ ## Troubleshooting
481
+
482
+ | Problem | Fix |
483
+ |---------|-----|
484
+ | `agenttrader: command not found` | Activate your virtual environment: `source .venv/bin/activate` |
485
+ | Not initialized | `agenttrader init` |
486
+ | Missing API key | `agenttrader config set dome_api_key <key>` |
487
+ | Market not in cache | `agenttrader sync ...` |
488
+ | Strategy validation errors | `agenttrader validate ./strategy.py --json` — read `errors` array |
489
+ | Backtest has no trades | Date range has no price movement — try wider range or sync more markets |
490
+ | Dashboard shows blank | Ensure `agenttrader dashboard` is running and open `http://127.0.0.1:8080`; check command logs for startup errors |
491
+ | MCP not connecting | Verify `agenttrader mcp` runs without error; check `.claude/mcp.json` path |
492
+
493
+ ---
494
+
495
+ ## Development
496
+
497
+ ```bash
498
+ git clone https://github.com/yourname/agenttrader
499
+ cd agenttrader
500
+ python -m venv .venv && source .venv/bin/activate
501
+ pip install -e ".[dev]"
502
+
503
+ ruff check agenttrader tests
504
+ python -m compileall agenttrader tests
505
+
506
+ # Integration tests (requires real API key)
507
+ DOME_API_KEY=<key> python tests/integration/test_full_workflow.py
508
+ ```
509
+
510
+ ---
511
+
512
+ ## License
513
+
514
+ MIT