Understand every file and folder in your Blave Agent workspace.
workspace/
├── strategies/ # your strategies
├── examples/ # reference implementations
├── lib/ # shared library
├── manager/ # portfolio management system
├── cache/ # API data cache (auto-generated)
├── references/ # guides for strategy code & deployment
└── AGENTS.md # bot behavior rules
Each strategy lives in its own subfolder. The bot runs strategy.py on a cron schedule and writes the output files automatically.
strategies/
└── my_strategy/
├── strategy.py # strategy logic
├── scan.py # parameter scan (optional)
├── stats.json # backtest results + daily returns
├── state.json # live position state
├── pnl.png # equity curve chart
└── orders.jsonl # order log
All shared utilities live in lib/. Import from here — never duplicate code in strategy files.
| File | Purpose |
|---|---|
runner.py | Unified backtest & live runner (Type A and C) |
data.py | All data fetchers — kline, alpha indicators, Taiwan stocks, futures |
execute.py | Live state management: load/save/update position, order log |
pnl.py | Write daily returns to stats.json; load all strategies for manager |
portfolio.py | Aggregate target positions, compute order diff, reconcile |
strategy.py | Vol targeting helpers: add_realized_vol, apply_vol_scaling |
analysis.py | PnL charts, regime analysis, slippage, random B&H benchmark |
param_scan.py | 2D parameter scan: percentile_thresholds, scan_grid, find_plateau, plot_heatmap |
validation.py | Monte Carlo Permutation Test (mcpt) for statistical significance |
notify.py | Telegram sender: make_sender(), send_text(), send_photo() |
The manager/ folder handles multi-strategy portfolio optimization and order reconciliation. Do not delete any file here when removing individual strategies.
| File | Purpose |
|---|---|
manager.py | Reads all strategies' stats.json, finds weights that maximize portfolio slope/std, writes optimal weights + leverage to portfolio_config.json.Run: python3 manager/manager.py --target-vol 0.30 |
reconciler.py | Polls every 5 s; reconciles when a strategy's state.json, the amounts, or the kill switch changes (plus a 5-minute safety pass), then places orders to close the gap between target and actual positions.Run: bash manager/start_reconciler.sh |
flatten.py | Market-closes every open position on every connected exchange (the workspace Close-all button runs this). Trips the kill switch first so nothing re-opens. Run: python3 manager/flatten.py |
portfolio_config.json | Per-strategy dollar amounts (the live sizing base), exchange routing, and the optimizer's weights and leverage. Maintained by the tools — never edit by hand. |
orders.jsonl | Order history — one line per executed order, with per-leg exchange-confirmed fill price and quantity. Rendered as Order History in the workspace. |
target = amount × position), saved from the workspace Trading setup page.strategy.py ──► state.json ──────────┐
(cron) stats.json ├──► reconciler.py ──► exchange
manager.py ──► portfolio_config.json ┘
The reconciler needs both sources to compute order size: target = amount × position