tradelab 1.1.0 → 1.2.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.
- package/CHANGELOG.md +46 -0
- package/README.md +185 -388
- package/dist/cjs/index.cjs +31 -9
- package/dist/cjs/live.cjs +409 -7
- package/docs/README.md +32 -66
- package/docs/api-reference.md +269 -144
- package/docs/backtest-engine.md +167 -321
- package/docs/data-reporting-cli.md +114 -156
- package/docs/examples.md +6 -6
- package/docs/live-trading.md +254 -134
- package/docs/mcp.md +244 -23
- package/docs/research.md +99 -45
- package/examples/mcpLiveTrading.js +77 -0
- package/package.json +11 -3
- package/src/engine/optimize.js +25 -1
- package/src/engine/portfolio.js +4 -1
- package/src/live/dashboard/server.js +67 -8
- package/src/live/engine/paperEngine.js +5 -0
- package/src/live/index.js +2 -0
- package/src/live/session.js +402 -0
- package/src/mcp/liveTools.js +179 -0
- package/src/mcp/schemas.js +119 -0
- package/src/mcp/server.js +5 -1
- package/src/mcp/tools.js +125 -2
- package/templates/dashboard.html +595 -108
- package/types/index.d.ts +25 -0
- package/types/live.d.ts +99 -0
- package/types/mcp.d.ts +17 -0
- package/docs/superpowers/plans/2026-00-overview.md +0 -101
- package/docs/superpowers/plans/2026-01-metrics-correctness.md +0 -873
- package/docs/superpowers/plans/2026-02-indicator-library.md +0 -677
- package/docs/superpowers/plans/2026-03-overfitting-toolkit.md +0 -882
- package/docs/superpowers/plans/2026-04-async-signals-seeding.md +0 -981
- package/docs/superpowers/plans/2026-05-mcp-server.md +0 -758
- package/docs/superpowers/plans/2026-06-parallel-param-sweep.md +0 -508
- package/docs/superpowers/plans/2026-07-funding-carry-costs.md +0 -535
- package/docs/superpowers/plans/2026-08-live-dashboard.md +0 -547
- package/docs/superpowers/plans/HANDOFF.md +0 -88
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,52 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.2.0] - 2026-06-26
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **MCP agent trading (paper and live sessions)**
|
|
13
|
+
- New `TradingSession` class and `SessionManager` class exported from `tradelab/live`, enabling agents to manage real paper or live trading sessions programmatically.
|
|
14
|
+
- `SessionManager.create()` spins up a session backed by `PaperEngine` (default) or a credentialed live broker; `SessionManager.haltAll()` is the process-level kill-switch that flattens all positions and clears every session.
|
|
15
|
+
- `TradingSession.placeOrder()` supports risk-sized **bracket orders**: a single call with `stop` / `target` / `rr` fields submits the entry plus a protective stop and a profit target as OCO legs; a bar that straddles both stop and target no longer double-fills.
|
|
16
|
+
- Day-loss risk halts: `maxDailyLossPct` triggers an automatic halt via `RiskManager`; further `placeOrder()` calls throw until the session is stopped.
|
|
17
|
+
- Live-mode gating: live trading requires `TRADELAB_ALLOW_LIVE=true` (env var) **and** `confirmLive: true` passed to `create()`; paper is the default and needs no credentials or flags.
|
|
18
|
+
|
|
19
|
+
- **New MCP live-trading tools** (exposed via `tradelab-mcp`)
|
|
20
|
+
- `create_session` — create a paper or live session with equity, risk, and interval settings.
|
|
21
|
+
- `list_sessions` — list all active sessions and their current status.
|
|
22
|
+
- `session_status` — get a full refreshed snapshot (positions, open orders, equity, risk state).
|
|
23
|
+
- `feed_price` — push an OHLCV bar (or a single price) to advance paper simulation and trigger fills.
|
|
24
|
+
- `place_order` — place a market or limit order, optionally risk-sized with a bracket stop/target.
|
|
25
|
+
- `close_position` — close an open position via an opposite market order.
|
|
26
|
+
- `flatten` — flatten all positions and cancel all open orders in a session.
|
|
27
|
+
- `cancel_order` — cancel a specific open order.
|
|
28
|
+
- `account` — fetch broker account details (equity, cash, buying power).
|
|
29
|
+
- `positions` — list all open positions in a session.
|
|
30
|
+
- `recent_events` — retrieve recent session events (fills, risk changes, bars) for monitoring.
|
|
31
|
+
- `attach_strategy` — attach a named built-in strategy that auto-evaluates on each `feed_price` and places orders when flat.
|
|
32
|
+
- `halt_all` — emergency kill-switch: flattens all positions and stops every active session.
|
|
33
|
+
|
|
34
|
+
- **MCP research-plus tools** (exposed via `tradelab-mcp`)
|
|
35
|
+
- `analyze_robustness` — runs a backtest then Monte Carlo simulation and Deflated Sharpe ratio on the realized trade P&Ls; degrades gracefully with fewer than two trades.
|
|
36
|
+
- `optimize_strategy` — in-process grid sweep returning a leaderboard ranked by a chosen metric (default: `profitFactor`).
|
|
37
|
+
- `compare_strategies` — runs multiple named strategies on the same candle dataset and returns a ranked comparison.
|
|
38
|
+
- `candle_stats` — returns shape statistics (count, date range, price range, estimated interval) for a candle array or data spec; useful for sanity-checking data before backtesting.
|
|
39
|
+
|
|
40
|
+
- **Dashboard overhaul**
|
|
41
|
+
- Redesigned realtime cockpit with equity curve, KPI strip, positions/orders tables, severity-colored event feed, and a risk-halt banner.
|
|
42
|
+
- Live **Flatten / Stop / Cancel** controls in the dashboard UI via a new `POST /command` endpoint (whitelisted methods: `flatten`, `stop`, `closePosition`, `cancelOrder`).
|
|
43
|
+
- `GET /state` now calls `source.refresh()` before returning, so the state snapshot is always current.
|
|
44
|
+
|
|
45
|
+
### Changed
|
|
46
|
+
|
|
47
|
+
- MCP server version is now read dynamically from `package.json` via `createRequire`; no separate version constant to update on release.
|
|
48
|
+
|
|
49
|
+
### Fixed
|
|
50
|
+
|
|
51
|
+
- Paper-broker bracket orders: a price bar that straddled both the stop and the target could trigger a double-fill, flipping a position to the opposite side. The OCO cancel now runs before the sibling leg can fill.
|
|
52
|
+
- Dashboard equity curve color now reflects actual session P&L rather than a static value.
|
|
53
|
+
|
|
8
54
|
## [1.1.0] - 2026-06-26
|
|
9
55
|
|
|
10
56
|
### Added
|