tradeblocks-mcp 3.0.2 → 3.3.1
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 +85 -80
- package/dist/{chunk-LDKTV7GW.js → chunk-27S67XW3.js} +24 -52
- package/dist/chunk-27S67XW3.js.map +1 -0
- package/dist/{chunk-FGZH632F.js → chunk-2E63THNI.js} +13 -11
- package/dist/chunk-2E63THNI.js.map +1 -0
- package/dist/{chunk-QTTR7AAW.js → chunk-2I3S2ZLT.js} +325 -84
- package/dist/chunk-2I3S2ZLT.js.map +1 -0
- package/dist/{chunk-4BLCXNQ6.js → chunk-4HZLVUOZ.js} +179 -183
- package/dist/chunk-4HZLVUOZ.js.map +1 -0
- package/dist/{chunk-XXYOUIZY.js → chunk-NWNSKALN.js} +63 -80
- package/dist/chunk-NWNSKALN.js.map +1 -0
- package/dist/{chunk-PRAYH3RT.js → chunk-WNTYA7ER.js} +29 -12
- package/dist/chunk-WNTYA7ER.js.map +1 -0
- package/dist/{chunk-BKQ4PM4Y.js → chunk-YZA4RS76.js} +24 -18
- package/dist/chunk-YZA4RS76.js.map +1 -0
- package/dist/{chunk-W2PP3LEH.js → chunk-ZTJXC3LS.js} +17 -8
- package/dist/chunk-ZTJXC3LS.js.map +1 -0
- package/dist/daily-log-processor-MZW2XBZY.js +9 -0
- package/dist/{daily-logs-store-D3QC2XPV.js → daily-logs-store-3C3OTGPK.js} +2 -2
- package/dist/iv-solver-worker.js +9 -1
- package/dist/market-provider-6U33TQUT.js +16 -0
- package/dist/{proto-3HZTCWK4.js → proto-V23GIZG2.js} +2 -2
- package/dist/{sync-PO4IPCYV.js → sync-3UBC37VW.js} +7 -7
- package/dist/test-exports.js +876 -483
- package/dist/test-exports.js.map +1 -1
- package/dist/trade-processor-DKDCWGKD.js +9 -0
- package/dist/{trades-store-LOL3FQSF.js → trades-store-R3NL25T2.js} +2 -2
- package/package.json +2 -6
- package/server/{chunk-CSDVJPBB.js → chunk-536NSFED.js} +29 -12
- package/server/chunk-536NSFED.js.map +1 -0
- package/server/{chunk-WA5AAPCH.js → chunk-A3UKD64A.js} +17 -8
- package/server/chunk-A3UKD64A.js.map +1 -0
- package/server/{chunk-PNKG7RY7.js → chunk-OMUDNJBJ.js} +63 -80
- package/server/chunk-OMUDNJBJ.js.map +1 -0
- package/server/{chunk-72GKJE2U.js → chunk-RJDJHZ5Y.js} +934 -335
- package/server/chunk-RJDJHZ5Y.js.map +1 -0
- package/server/{chunk-NZO6PT64.js → chunk-RM4B2VKS.js} +167 -177
- package/server/chunk-RM4B2VKS.js.map +1 -0
- package/server/{chunk-5EBXHT6C.js → chunk-SY6GDNVI.js} +24 -18
- package/server/chunk-SY6GDNVI.js.map +1 -0
- package/server/{chunk-FBNDMCT5.js → chunk-T66KH2XH.js} +13 -11
- package/server/chunk-T66KH2XH.js.map +1 -0
- package/server/{chunk-NRFXAJF7.js → chunk-W5E7FHC4.js} +24 -52
- package/server/chunk-W5E7FHC4.js.map +1 -0
- package/server/{config-6IZXEFEX.js → config-DK7KOMNL.js} +1 -1
- package/server/config-DK7KOMNL.js.map +1 -0
- package/server/daily-log-processor-B2VPU2FQ.js +10 -0
- package/server/{daily-logs-store-NU7M4L5C.js → daily-logs-store-YFNXTB7J.js} +2 -2
- package/server/http-server.js +2 -5
- package/server/index.js +2497 -2029
- package/server/index.js.map +1 -1
- package/server/iv-solver-worker.js +9 -1
- package/server/market-provider-L56RFHAC.js +17 -0
- package/server/{proto-DWRZJO4E.js → proto-YZ4TLX2N.js} +2 -2
- package/server/{sync-QFI5L7S7.js → sync-CENKDN53.js} +7 -7
- package/server/trade-processor-3PI4LHZI.js +10 -0
- package/server/{trades-store-VY26MWER.js → trades-store-RTTEYMXH.js} +2 -2
- package/src/auth/clients-store.ts +4 -4
- package/src/auth/code-store.ts +1 -1
- package/src/auth/config.ts +11 -12
- package/src/auth/login-page.ts +8 -10
- package/src/auth/provider.ts +35 -30
- package/src/auth/token.ts +17 -15
- package/src/db/backtest-schemas.ts +38 -8
- package/src/db/connection.ts +107 -40
- package/src/db/data-root.ts +22 -0
- package/src/db/index.ts +37 -5
- package/src/db/json-adapters.ts +22 -31
- package/src/db/json-migration.ts +11 -15
- package/src/db/json-store.ts +5 -3
- package/src/db/market-datasets.ts +48 -15
- package/src/db/market-schemas.ts +11 -5
- package/src/db/market-views.ts +119 -32
- package/src/db/parquet-writer.ts +7 -7
- package/src/db/profile-schemas.ts +39 -22
- package/src/db/schemas.ts +2 -2
- package/src/http-server.ts +7 -12
- package/src/index.ts +8 -9
- package/src/market/ingestor/index.ts +1 -4
- package/src/market/ingestor/market-ingestor.ts +140 -67
- package/src/market/ingestor/types.ts +1 -3
- package/src/market/stores/chain-sql.ts +2 -8
- package/src/market/stores/chain-store.ts +1 -4
- package/src/market/stores/duckdb-chain-store.ts +3 -14
- package/src/market/stores/duckdb-enriched-store.ts +3 -13
- package/src/market/stores/duckdb-quote-store.ts +10 -27
- package/src/market/stores/duckdb-spot-store.ts +4 -20
- package/src/market/stores/enriched-sql.ts +3 -9
- package/src/market/stores/enriched-store.ts +2 -2
- package/src/market/stores/parquet-chain-store.ts +5 -22
- package/src/market/stores/parquet-enriched-store.ts +4 -16
- package/src/market/stores/parquet-oi-daily-store.ts +3 -14
- package/src/market/stores/parquet-quote-store.ts +9 -29
- package/src/market/stores/parquet-spot-store.ts +14 -33
- package/src/market/stores/quote-store.ts +2 -10
- package/src/market/stores/spot-sql.ts +3 -15
- package/src/market/stores/spot-store.ts +1 -1
- package/src/market/tickers/defaults.json +6 -6
- package/src/market/tickers/loader.ts +2 -7
- package/src/market/tickers/registry.ts +5 -15
- package/src/market/tickers/schemas.ts +2 -6
- package/src/models/strategy-profile.ts +39 -39
- package/src/sync/block-sync.ts +44 -65
- package/src/sync/index.ts +1 -4
- package/src/sync/metadata.ts +14 -20
- package/src/test-exports.ts +139 -123
- package/src/tools/analysis.ts +180 -159
- package/src/tools/batch-exit-analysis.ts +100 -59
- package/src/tools/blocks/analysis.ts +116 -101
- package/src/tools/blocks/comparison.ts +281 -364
- package/src/tools/blocks/core.ts +208 -253
- package/src/tools/blocks/health.ts +571 -563
- package/src/tools/blocks/index.ts +2 -0
- package/src/tools/blocks/paired-comparison.ts +425 -0
- package/src/tools/blocks/similarity.ts +316 -283
- package/src/tools/edge-decay.ts +124 -197
- package/src/tools/exit-analysis.ts +130 -77
- package/src/tools/greeks-attribution.ts +84 -35
- package/src/tools/guides.ts +4 -6
- package/src/tools/imports.ts +11 -14
- package/src/tools/market-data.ts +1067 -757
- package/src/tools/market-enrichment.ts +3 -3
- package/src/tools/market-fetch.ts +148 -67
- package/src/tools/market-imports.ts +12 -12
- package/src/tools/middleware/sync-middleware.ts +5 -6
- package/src/tools/performance.ts +185 -302
- package/src/tools/profile-analysis.ts +52 -66
- package/src/tools/profiles.ts +106 -69
- package/src/tools/regime-advisor.ts +20 -45
- package/src/tools/replay.ts +81 -77
- package/src/tools/reports/discrepancies.ts +298 -328
- package/src/tools/reports/fields.ts +7 -25
- package/src/tools/reports/helpers.ts +18 -49
- package/src/tools/reports/predictive.ts +27 -70
- package/src/tools/reports/slippage-trends.ts +315 -345
- package/src/tools/reports/slippage.ts +1 -4
- package/src/tools/reports/strategy-matches.ts +399 -441
- package/src/tools/schema.ts +43 -40
- package/src/tools/shared/filters.ts +3 -9
- package/src/tools/snapshot.ts +9 -30
- package/src/tools/sql.ts +15 -14
- package/src/tools/tickers.ts +1 -4
- package/src/utils/batch-exit-analysis.ts +31 -42
- package/src/utils/black-scholes.ts +39 -29
- package/src/utils/block-loader.ts +69 -83
- package/src/utils/calibration-probe.ts +3 -4
- package/src/utils/chain-loader.ts +3 -3
- package/src/utils/csv-discovery.ts +16 -22
- package/src/utils/data-quality.ts +24 -36
- package/src/utils/exit-triggers.ts +91 -96
- package/src/utils/field-timing.ts +94 -79
- package/src/utils/filter-predicates.ts +13 -9
- package/src/utils/flatfile-importer.ts +94 -64
- package/src/utils/greeks-decomposition.ts +152 -100
- package/src/utils/iv-solver-pool.ts +55 -25
- package/src/utils/iv-solver-worker.ts +5 -5
- package/src/utils/market-enricher.ts +528 -497
- package/src/utils/market-importer.ts +31 -12
- package/src/utils/market-provider.ts +21 -23
- package/src/utils/massive-tier.ts +5 -7
- package/src/utils/migrate-option-data-helpers.ts +2 -8
- package/src/utils/option-quote-greeks.ts +25 -31
- package/src/utils/option-time.ts +4 -8
- package/src/utils/output-formatter.ts +1 -4
- package/src/utils/provider-capabilities.ts +1 -4
- package/src/utils/providers/massive.ts +59 -93
- package/src/utils/providers/thetadata/backfill.ts +14 -23
- package/src/utils/providers/thetadata/client.ts +12 -8
- package/src/utils/providers/thetadata/decode.ts +2 -20
- package/src/utils/providers/thetadata/endpoints.ts +32 -40
- package/src/utils/providers/thetadata/join.ts +11 -10
- package/src/utils/providers/thetadata/proto.ts +12 -10
- package/src/utils/providers/thetadata/quote-mid-greeks.ts +5 -5
- package/src/utils/providers/thetadata.ts +11 -10
- package/src/utils/quote-enricher.ts +4 -4
- package/src/utils/quote-parquet-projection.ts +3 -11
- package/src/utils/sample-date-selector.ts +3 -5
- package/src/utils/schema-metadata.ts +102 -70
- package/src/utils/ticker.ts +5 -9
- package/src/utils/trade-replay.ts +77 -68
- package/dist/chunk-4BLCXNQ6.js.map +0 -1
- package/dist/chunk-BKQ4PM4Y.js.map +0 -1
- package/dist/chunk-FGZH632F.js.map +0 -1
- package/dist/chunk-LDKTV7GW.js.map +0 -1
- package/dist/chunk-PRAYH3RT.js.map +0 -1
- package/dist/chunk-QTTR7AAW.js.map +0 -1
- package/dist/chunk-W2PP3LEH.js.map +0 -1
- package/dist/chunk-XXYOUIZY.js.map +0 -1
- package/dist/daily-log-processor-6MWJ23JK.js +0 -9
- package/dist/market-provider-VDRJUEF2.js +0 -16
- package/dist/trade-processor-NHU4VWRX.js +0 -9
- package/manifest.json +0 -141
- package/server/chunk-5EBXHT6C.js.map +0 -1
- package/server/chunk-72GKJE2U.js.map +0 -1
- package/server/chunk-CSDVJPBB.js.map +0 -1
- package/server/chunk-FBNDMCT5.js.map +0 -1
- package/server/chunk-NRFXAJF7.js.map +0 -1
- package/server/chunk-NZO6PT64.js.map +0 -1
- package/server/chunk-PNKG7RY7.js.map +0 -1
- package/server/chunk-WA5AAPCH.js.map +0 -1
- package/server/config-6IZXEFEX.js.map +0 -1
- package/server/daily-log-processor-Y3PVSVBM.js +0 -10
- package/server/market-provider-VOYYVYWT.js +0 -17
- package/server/trade-processor-JWVS37KM.js +0 -10
- /package/dist/{daily-log-processor-6MWJ23JK.js.map → daily-log-processor-MZW2XBZY.js.map} +0 -0
- /package/dist/{daily-logs-store-D3QC2XPV.js.map → daily-logs-store-3C3OTGPK.js.map} +0 -0
- /package/dist/{market-provider-VDRJUEF2.js.map → market-provider-6U33TQUT.js.map} +0 -0
- /package/dist/{proto-3HZTCWK4.js.map → proto-V23GIZG2.js.map} +0 -0
- /package/dist/{sync-PO4IPCYV.js.map → sync-3UBC37VW.js.map} +0 -0
- /package/dist/{trade-processor-NHU4VWRX.js.map → trade-processor-DKDCWGKD.js.map} +0 -0
- /package/dist/{trades-store-LOL3FQSF.js.map → trades-store-R3NL25T2.js.map} +0 -0
- /package/server/{daily-log-processor-Y3PVSVBM.js.map → daily-log-processor-B2VPU2FQ.js.map} +0 -0
- /package/server/{daily-logs-store-NU7M4L5C.js.map → daily-logs-store-YFNXTB7J.js.map} +0 -0
- /package/server/{market-provider-VOYYVYWT.js.map → market-provider-L56RFHAC.js.map} +0 -0
- /package/server/{proto-DWRZJO4E.js.map → proto-YZ4TLX2N.js.map} +0 -0
- /package/server/{sync-QFI5L7S7.js.map → sync-CENKDN53.js.map} +0 -0
- /package/server/{trade-processor-JWVS37KM.js.map → trade-processor-3PI4LHZI.js.map} +0 -0
- /package/server/{trades-store-VY26MWER.js.map → trades-store-RTTEYMXH.js.map} +0 -0
package/README.md
CHANGED
|
@@ -14,13 +14,7 @@ Model Context Protocol (MCP) server for options trading analysis. Works with Cla
|
|
|
14
14
|
|
|
15
15
|
## Installation
|
|
16
16
|
|
|
17
|
-
### Option 1:
|
|
18
|
-
|
|
19
|
-
Download the latest `.mcpb` file from [Releases](https://github.com/tradeblocks-org/tradeblocks/releases) and double-click to install.
|
|
20
|
-
|
|
21
|
-
The installer will prompt you to select your Trading Data Directory.
|
|
22
|
-
|
|
23
|
-
### Option 2: npx (All Platforms)
|
|
17
|
+
### Option 1: npx (All Platforms)
|
|
24
18
|
|
|
25
19
|
Run directly without installation:
|
|
26
20
|
|
|
@@ -32,9 +26,9 @@ npx tradeblocks-mcp ~/Trading/backtests
|
|
|
32
26
|
npx tradeblocks-mcp --http ~/Trading/backtests
|
|
33
27
|
```
|
|
34
28
|
|
|
35
|
-
|
|
29
|
+
For Claude Desktop, add the server to `claude_desktop_config.json` — see [Configuration by Platform](#configuration-by-platform) below for platform-specific setup.
|
|
36
30
|
|
|
37
|
-
### Option
|
|
31
|
+
### Option 2: From Source
|
|
38
32
|
|
|
39
33
|
```bash
|
|
40
34
|
git clone https://github.com/tradeblocks-org/tradeblocks
|
|
@@ -58,11 +52,11 @@ For detailed usage examples, see [../../docs/usage.md](../../docs/usage.md).
|
|
|
58
52
|
|
|
59
53
|
### Claude Desktop
|
|
60
54
|
|
|
61
|
-
| Platform | Config Location
|
|
62
|
-
|
|
63
|
-
| macOS
|
|
64
|
-
| Windows
|
|
65
|
-
| Linux
|
|
55
|
+
| Platform | Config Location |
|
|
56
|
+
| -------- | ----------------------------------------------------------------- |
|
|
57
|
+
| macOS | `~/Library/Application Support/Claude/claude_desktop_config.json` |
|
|
58
|
+
| Windows | `%APPDATA%\Claude\claude_desktop_config.json` |
|
|
59
|
+
| Linux | `~/.config/Claude/claude_desktop_config.json` |
|
|
66
60
|
|
|
67
61
|
```json
|
|
68
62
|
{
|
|
@@ -135,10 +129,10 @@ See [Web Platforms Guide](../../docs/web-platforms.md) for platform-specific set
|
|
|
135
129
|
|
|
136
130
|
## Transport Modes
|
|
137
131
|
|
|
138
|
-
| Mode
|
|
139
|
-
|
|
140
|
-
| stdio | (default) | Local CLI tools
|
|
141
|
-
| HTTP
|
|
132
|
+
| Mode | Flag | Use Case | Platforms |
|
|
133
|
+
| ----- | --------- | ----------------------------- | -------------------------------------------------- |
|
|
134
|
+
| stdio | (default) | Local CLI tools | Claude Desktop, Claude Code, Codex CLI, Gemini CLI |
|
|
135
|
+
| HTTP | `--http` | Web platforms, remote servers | ChatGPT, Google AI Studio, Julius AI |
|
|
142
136
|
|
|
143
137
|
```bash
|
|
144
138
|
# stdio mode (default)
|
|
@@ -154,21 +148,21 @@ tradeblocks-mcp --directory ./data --blocks-dir ~/backtests
|
|
|
154
148
|
|
|
155
149
|
### Options
|
|
156
150
|
|
|
157
|
-
| Flag
|
|
158
|
-
|
|
159
|
-
| `--http`
|
|
160
|
-
| `--port <n>`
|
|
161
|
-
| `--blocks-dir <path>` | Directory containing CSV block folders | same as data directory
|
|
162
|
-
| `--market-db <path>`
|
|
163
|
-
| `--no-auth`
|
|
151
|
+
| Flag | Description | Default |
|
|
152
|
+
| --------------------- | -------------------------------------- | --------------------------- |
|
|
153
|
+
| `--http` | Start HTTP server instead of stdio | stdio |
|
|
154
|
+
| `--port <n>` | HTTP server port | 3100 |
|
|
155
|
+
| `--blocks-dir <path>` | Directory containing CSV block folders | same as data directory |
|
|
156
|
+
| `--market-db <path>` | Path to market.duckdb | `<directory>/market.duckdb` |
|
|
157
|
+
| `--no-auth` | Disable authentication (HTTP mode) | auth enabled |
|
|
164
158
|
|
|
165
159
|
### Environment Variables
|
|
166
160
|
|
|
167
|
-
| Variable
|
|
168
|
-
|
|
169
|
-
| `BLOCKS_DIRECTORY`
|
|
161
|
+
| Variable | Description |
|
|
162
|
+
| ------------------------ | -------------------------------------------------------------- |
|
|
163
|
+
| `BLOCKS_DIRECTORY` | Default data directory if not specified as argument |
|
|
170
164
|
| `TRADEBLOCKS_BLOCKS_DIR` | Directory for CSV block folders (overridden by `--blocks-dir`) |
|
|
171
|
-
| `MARKET_DB_PATH`
|
|
165
|
+
| `MARKET_DB_PATH` | Path to market.duckdb (overridden by `--market-db`) |
|
|
172
166
|
|
|
173
167
|
### ThetaData MDDS Credentials
|
|
174
168
|
|
|
@@ -201,6 +195,7 @@ docker run -d -p 3100:3100 -v ./data:/data --env-file .env romeo345/tradeblocks-
|
|
|
201
195
|
```
|
|
202
196
|
|
|
203
197
|
Or with docker compose, set the image in `docker-compose.yml`:
|
|
198
|
+
|
|
204
199
|
```yaml
|
|
205
200
|
services:
|
|
206
201
|
tradeblocks:
|
|
@@ -274,6 +269,7 @@ tradeblocks-mcp uninstall-skills
|
|
|
274
269
|
```
|
|
275
270
|
|
|
276
271
|
Skills provide structured prompts for tasks like:
|
|
272
|
+
|
|
277
273
|
- Strategy health checks
|
|
278
274
|
- Walk-forward analysis interpretation
|
|
279
275
|
- Portfolio addition recommendations
|
|
@@ -299,12 +295,14 @@ backtests/
|
|
|
299
295
|
### CSV Formats
|
|
300
296
|
|
|
301
297
|
**tradelog.csv** - Trade records with these key columns:
|
|
298
|
+
|
|
302
299
|
- Date Opened, Time Opened, Date Closed, Time Closed
|
|
303
300
|
- P/L (gross profit/loss)
|
|
304
301
|
- Strategy, Legs (or Symbol)
|
|
305
302
|
- No. of Contracts, Premium (optional)
|
|
306
303
|
|
|
307
304
|
**dailylog.csv** - Daily portfolio values:
|
|
305
|
+
|
|
308
306
|
- Date
|
|
309
307
|
- Net Liquidity (or Portfolio Value, Equity)
|
|
310
308
|
- P/L, Drawdown % (optional)
|
|
@@ -314,68 +312,75 @@ backtests/
|
|
|
314
312
|
## Available Tools
|
|
315
313
|
|
|
316
314
|
### Core Tools
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
|
320
|
-
| `
|
|
321
|
-
| `
|
|
322
|
-
| `
|
|
323
|
-
| `
|
|
315
|
+
|
|
316
|
+
| Tool | Description |
|
|
317
|
+
| ------------------------- | ----------------------------------------------------- |
|
|
318
|
+
| `list_blocks` | List all available blocks with summary stats |
|
|
319
|
+
| `get_block_info` | Detailed info for a specific block |
|
|
320
|
+
| `get_statistics` | Performance metrics (Sharpe, Sortino, drawdown, etc.) |
|
|
321
|
+
| `get_strategy_comparison` | Compare strategies within a block |
|
|
322
|
+
| `compare_blocks` | Compare statistics across multiple blocks |
|
|
324
323
|
|
|
325
324
|
### Analysis Tools
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
|
329
|
-
| `
|
|
325
|
+
|
|
326
|
+
| Tool | Description |
|
|
327
|
+
| ------------------------ | -------------------------------------------------------- |
|
|
328
|
+
| `run_walk_forward` | Walk-forward analysis with configurable windows |
|
|
329
|
+
| `run_monte_carlo` | Monte Carlo simulation with worst-case scenarios |
|
|
330
330
|
| `get_correlation_matrix` | Strategy correlation matrix (Kendall, Spearman, Pearson) |
|
|
331
|
-
| `get_tail_risk`
|
|
332
|
-
| `get_position_sizing`
|
|
331
|
+
| `get_tail_risk` | Tail dependence and copula-based risk analysis |
|
|
332
|
+
| `get_position_sizing` | Kelly criterion position sizing |
|
|
333
333
|
|
|
334
334
|
### Performance Tools
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
|
338
|
-
| `
|
|
339
|
-
| `
|
|
335
|
+
|
|
336
|
+
| Tool | Description |
|
|
337
|
+
| ---------------------------- | ----------------------------------------------- |
|
|
338
|
+
| `get_performance_charts` | 16 chart types (equity, drawdown, distribution) |
|
|
339
|
+
| `get_period_returns` | Returns aggregated by time period |
|
|
340
|
+
| `compare_backtest_to_actual` | Backtest vs live performance comparison |
|
|
340
341
|
|
|
341
342
|
### SQL Tools
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
|
343
|
+
|
|
344
|
+
| Tool | Description |
|
|
345
|
+
| ------------------- | ---------------------------------------------------- |
|
|
346
|
+
| `run_sql` | Execute SQL queries against trades and market data |
|
|
345
347
|
| `describe_database` | Schema discovery with table info and example queries |
|
|
346
348
|
|
|
347
349
|
### Market Data Tools
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
|
351
|
-
| `
|
|
352
|
-
| `
|
|
353
|
-
| `
|
|
354
|
-
| `
|
|
355
|
-
| `
|
|
356
|
-
| `
|
|
357
|
-
| `
|
|
358
|
-
| `
|
|
359
|
-
| `
|
|
360
|
-
| `
|
|
361
|
-
| `
|
|
362
|
-
| `
|
|
350
|
+
|
|
351
|
+
| Tool | Description |
|
|
352
|
+
| ---------------------------- | ---------------------------------------------------------------------------------- |
|
|
353
|
+
| `import_market_csv` | Import market data CSV with column mapping |
|
|
354
|
+
| `import_from_database` | Import from external DuckDB databases |
|
|
355
|
+
| `import_flat_file` | Import a local Parquet or CSV flat file for a ticker/timespan |
|
|
356
|
+
| `fetch_bars` | Fetch daily or intraday OHLCV bars from configured provider |
|
|
357
|
+
| `fetch_quotes` | Fetch option minute quotes from configured provider |
|
|
358
|
+
| `fetch_chain` | Fetch option chain snapshot for an underlying on a given date |
|
|
359
|
+
| `compute_vix_context` | Compute cross-ticker VIX regime fields for a date range |
|
|
360
|
+
| `refresh_market_data` | Composite daily refresh: fetch bars, auto-fire VIX context, return coverage report |
|
|
361
|
+
| `enrich_market_data` | Compute ~40 derived indicators from raw OHLCV |
|
|
362
|
+
| `enrich_trades` | Enrich trades with market context (lookahead-free) |
|
|
363
|
+
| `analyze_regime_performance` | Analyze P&L by market regime |
|
|
364
|
+
| `suggest_filters` | Suggest trade filters based on market conditions |
|
|
365
|
+
| `calculate_orb` | Opening range breakout analysis from intraday bars |
|
|
363
366
|
|
|
364
367
|
### Strategy Profile Tools
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
|
368
|
-
| `
|
|
369
|
-
| `
|
|
370
|
-
| `
|
|
371
|
-
| `
|
|
372
|
-
| `
|
|
373
|
-
| `
|
|
368
|
+
|
|
369
|
+
| Tool | Description |
|
|
370
|
+
| ------------------------- | ------------------------------------------------------------ |
|
|
371
|
+
| `profile_strategy` | Create or update a strategy profile with structured metadata |
|
|
372
|
+
| `get_strategy_profile` | Retrieve a stored strategy profile |
|
|
373
|
+
| `list_profiles` | List all strategy profiles (optionally filtered by block) |
|
|
374
|
+
| `delete_profile` | Delete a strategy profile |
|
|
375
|
+
| `analyze_structure_fit` | Analyze strategy performance by regime/condition dimensions |
|
|
376
|
+
| `validate_entry_filters` | Test each entry filter's contribution to edge |
|
|
377
|
+
| `portfolio_structure_map` | Regime x structure coverage matrix across strategies |
|
|
374
378
|
|
|
375
379
|
### Import Tools
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
|
380
|
+
|
|
381
|
+
| Tool | Description |
|
|
382
|
+
| ------------ | ------------------------------------------------------------------------------- |
|
|
383
|
+
| `import_csv` | Import a CSV file as a new block _(CLI only - not available in Claude Desktop)_ |
|
|
379
384
|
|
|
380
385
|
## Development
|
|
381
386
|
|
|
@@ -388,9 +393,6 @@ npm run build
|
|
|
388
393
|
|
|
389
394
|
# Run tests
|
|
390
395
|
npm test
|
|
391
|
-
|
|
392
|
-
# Pack MCPB bundle
|
|
393
|
-
npm run mcpb:pack
|
|
394
396
|
```
|
|
395
397
|
|
|
396
398
|
## Market Data (Optional)
|
|
@@ -398,11 +400,13 @@ npm run mcpb:pack
|
|
|
398
400
|
For market context (VIX regimes, intraday timing, gap analysis), import market data using MCP tools:
|
|
399
401
|
|
|
400
402
|
**From a data provider (Massive.com default, or ThetaData):**
|
|
403
|
+
|
|
401
404
|
1. **Fetch bars** via `fetch_bars { tickers, timespan, from, to }` — writes directly to Parquet
|
|
402
405
|
2. **Fetch VIX context** via `fetch_bars` for VIX/VIX9D/VIX3M then `compute_vix_context`
|
|
403
406
|
3. **Or use** `refresh_market_data` for a combined daily refresh in one call
|
|
404
407
|
|
|
405
408
|
**From TradingView CSV exports:**
|
|
409
|
+
|
|
406
410
|
1. **Export** from TradingView (any chart: SPX daily, VIX daily, SPX 5-min, etc.)
|
|
407
411
|
2. **Import** via `import_market_csv` with a column mapping or `import_flat_file` for Parquet
|
|
408
412
|
3. **Enrich** via `enrich_market_data` to compute ~40 derived indicators
|
|
@@ -410,6 +414,7 @@ For market context (VIX regimes, intraday timing, gap analysis), import market d
|
|
|
410
414
|
No Pine Scripts needed — TradingView exports raw OHLCV natively.
|
|
411
415
|
|
|
412
416
|
Market data lives in a separate `market.duckdb` (configurable via `MARKET_DB_PATH` or `--market-db`). Canonical v3.0 datasets:
|
|
417
|
+
|
|
413
418
|
- `market.spot` — Raw per-minute OHLCV bars, ticker-first layout (keyed by `ticker, date, time`)
|
|
414
419
|
- `market.spot_daily` — RTH-aggregated daily OHLCV view derived from `market.spot` (keyed by `ticker, date`)
|
|
415
420
|
- `market.enriched` — Per-ticker computed enrichment indicators and calendar fields; OHLCV is NOT stored here (join `market.spot_daily` for OHLCV — keyed by `ticker, date`)
|
|
@@ -254,12 +254,7 @@ async function getTradesByDateRange(blockId, startDate, endDate) {
|
|
|
254
254
|
return withReadTransaction(STORES.TRADES, async (transaction) => {
|
|
255
255
|
const store = transaction.objectStore(STORES.TRADES);
|
|
256
256
|
const index = store.index("composite_block_date");
|
|
257
|
-
const range = IDBKeyRange.bound(
|
|
258
|
-
[blockId, startDate],
|
|
259
|
-
[blockId, endDate],
|
|
260
|
-
false,
|
|
261
|
-
false
|
|
262
|
-
);
|
|
257
|
+
const range = IDBKeyRange.bound([blockId, startDate], [blockId, endDate], false, false);
|
|
263
258
|
const result = await promisifyRequest(index.getAll(range));
|
|
264
259
|
return result;
|
|
265
260
|
});
|
|
@@ -356,9 +351,7 @@ async function getTradeStatistics(blockId) {
|
|
|
356
351
|
const dates = trades.map((trade) => new Date(trade.dateOpened));
|
|
357
352
|
const start = new Date(Math.min(...dates.map((d) => d.getTime())));
|
|
358
353
|
const end = new Date(Math.max(...dates.map((d) => d.getTime())));
|
|
359
|
-
const strategies = Array.from(
|
|
360
|
-
new Set(trades.map((trade) => trade.strategy))
|
|
361
|
-
).sort();
|
|
354
|
+
const strategies = Array.from(new Set(trades.map((trade) => trade.strategy))).sort();
|
|
362
355
|
return {
|
|
363
356
|
totalTrades,
|
|
364
357
|
totalPl,
|
|
@@ -517,11 +510,9 @@ async function initializeDatabase() {
|
|
|
517
510
|
unique: false
|
|
518
511
|
});
|
|
519
512
|
tradesStore.createIndex("pl", "pl", { unique: false });
|
|
520
|
-
tradesStore.createIndex(
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
{ unique: false }
|
|
524
|
-
);
|
|
513
|
+
tradesStore.createIndex("composite_block_date", ["blockId", "dateOpened"], {
|
|
514
|
+
unique: false
|
|
515
|
+
});
|
|
525
516
|
}
|
|
526
517
|
if (!db.objectStoreNames.contains(STORES.DAILY_LOGS)) {
|
|
527
518
|
const dailyLogsStore = db.createObjectStore(STORES.DAILY_LOGS, {
|
|
@@ -533,11 +524,7 @@ async function initializeDatabase() {
|
|
|
533
524
|
dailyLogsStore.createIndex(INDEXES.DAILY_LOGS_BY_DATE, "date", {
|
|
534
525
|
unique: false
|
|
535
526
|
});
|
|
536
|
-
dailyLogsStore.createIndex(
|
|
537
|
-
"composite_block_date",
|
|
538
|
-
["blockId", "date"],
|
|
539
|
-
{ unique: false }
|
|
540
|
-
);
|
|
527
|
+
dailyLogsStore.createIndex("composite_block_date", ["blockId", "date"], { unique: false });
|
|
541
528
|
}
|
|
542
529
|
if (!db.objectStoreNames.contains(STORES.REPORTING_LOGS)) {
|
|
543
530
|
const reportingStore = db.createObjectStore(STORES.REPORTING_LOGS, {
|
|
@@ -546,26 +533,18 @@ async function initializeDatabase() {
|
|
|
546
533
|
reportingStore.createIndex(INDEXES.REPORTING_LOGS_BY_BLOCK, "blockId", {
|
|
547
534
|
unique: false
|
|
548
535
|
});
|
|
549
|
-
reportingStore.createIndex(
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
"composite_block_date",
|
|
556
|
-
["blockId", "dateOpened"],
|
|
557
|
-
{ unique: false }
|
|
558
|
-
);
|
|
536
|
+
reportingStore.createIndex(INDEXES.REPORTING_LOGS_BY_STRATEGY, "strategy", {
|
|
537
|
+
unique: false
|
|
538
|
+
});
|
|
539
|
+
reportingStore.createIndex("composite_block_date", ["blockId", "dateOpened"], {
|
|
540
|
+
unique: false
|
|
541
|
+
});
|
|
559
542
|
}
|
|
560
543
|
if (!db.objectStoreNames.contains(STORES.CALCULATIONS)) {
|
|
561
544
|
const calculationsStore = db.createObjectStore(STORES.CALCULATIONS, {
|
|
562
545
|
keyPath: "id"
|
|
563
546
|
});
|
|
564
|
-
calculationsStore.createIndex(
|
|
565
|
-
INDEXES.CALCULATIONS_BY_BLOCK,
|
|
566
|
-
"blockId",
|
|
567
|
-
{ unique: false }
|
|
568
|
-
);
|
|
547
|
+
calculationsStore.createIndex(INDEXES.CALCULATIONS_BY_BLOCK, "blockId", { unique: false });
|
|
569
548
|
calculationsStore.createIndex("calculationType", "calculationType", {
|
|
570
549
|
unique: false
|
|
571
550
|
});
|
|
@@ -593,16 +572,12 @@ async function initializeDatabase() {
|
|
|
593
572
|
const staticDatasetRowsStore = db.createObjectStore(STORES.STATIC_DATASET_ROWS, {
|
|
594
573
|
autoIncrement: true
|
|
595
574
|
});
|
|
596
|
-
staticDatasetRowsStore.createIndex(
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
INDEXES.STATIC_DATASET_ROWS_BY_TIMESTAMP,
|
|
603
|
-
"timestamp",
|
|
604
|
-
{ unique: false }
|
|
605
|
-
);
|
|
575
|
+
staticDatasetRowsStore.createIndex(INDEXES.STATIC_DATASET_ROWS_BY_DATASET, "datasetId", {
|
|
576
|
+
unique: false
|
|
577
|
+
});
|
|
578
|
+
staticDatasetRowsStore.createIndex(INDEXES.STATIC_DATASET_ROWS_BY_TIMESTAMP, "timestamp", {
|
|
579
|
+
unique: false
|
|
580
|
+
});
|
|
606
581
|
staticDatasetRowsStore.createIndex(
|
|
607
582
|
"composite_dataset_timestamp",
|
|
608
583
|
["datasetId", "timestamp"],
|
|
@@ -669,12 +644,7 @@ async function getDailyLogsByDateRange(blockId, startDate, endDate) {
|
|
|
669
644
|
return withReadTransaction(STORES.DAILY_LOGS, async (transaction) => {
|
|
670
645
|
const store = transaction.objectStore(STORES.DAILY_LOGS);
|
|
671
646
|
const index = store.index("composite_block_date");
|
|
672
|
-
const range = IDBKeyRange.bound(
|
|
673
|
-
[blockId, startDate],
|
|
674
|
-
[blockId, endDate],
|
|
675
|
-
false,
|
|
676
|
-
false
|
|
677
|
-
);
|
|
647
|
+
const range = IDBKeyRange.bound([blockId, startDate], [blockId, endDate], false, false);
|
|
678
648
|
const result = await promisifyRequest(index.getAll(range));
|
|
679
649
|
return result;
|
|
680
650
|
});
|
|
@@ -750,7 +720,9 @@ async function getDailyLogStatistics(blockId) {
|
|
|
750
720
|
const dates = entries.map((entry) => new Date(entry.date));
|
|
751
721
|
const start = new Date(Math.min(...dates.map((d) => d.getTime())));
|
|
752
722
|
const end = new Date(Math.max(...dates.map((d) => d.getTime())));
|
|
753
|
-
const sortedEntries = entries.sort(
|
|
723
|
+
const sortedEntries = entries.sort(
|
|
724
|
+
(a, b) => new Date(b.date).getTime() - new Date(a.date).getTime()
|
|
725
|
+
);
|
|
754
726
|
const finalPortfolioValue = sortedEntries[0]?.netLiquidity || 0;
|
|
755
727
|
const maxDrawdown = Math.min(...entries.map((entry) => entry.drawdownPct));
|
|
756
728
|
const totalPl = entries.reduce((sum, entry) => sum + entry.dailyPl, 0);
|
|
@@ -864,4 +836,4 @@ export {
|
|
|
864
836
|
getTradesPage,
|
|
865
837
|
exportTradesToCSV
|
|
866
838
|
};
|
|
867
|
-
//# sourceMappingURL=chunk-
|
|
839
|
+
//# sourceMappingURL=chunk-27S67XW3.js.map
|