Optimize strategy weights, apply vol targeting, and automate order placement.
The management system reads backtest results from all your strategies, finds the weight allocation that maximizes portfolio momentum, applies a leverage factor to hit your volatility target, then reconciles live positions on the exchange.
strategy.py ──► state.json ──────────┐
(cron) stats.json ├──► reconciler.py ──► exchange
manager.py ──► portfolio_config.json ┘
Run a backtest for each strategy. This writes stats.json (including daily returns) to the strategy folder.
python3 strategies/my_strategy/strategy.py
Strategies without stats.json are skipped by the manager.
Run the portfolio optimizer. It reads all stats.json files and finds weights that maximize the slope/std of the combined equity curve.
python3 manager/manager.py --target-vol 0.30
--target-vol 0.30 sets your target annual volatility (30%). The manager computes leverage = target_vol / portfolio_vol and stores it in portfolio_config.json.
Review manager/portfolio_config.json. It contains the optimal weights, realized portfolio volatility, and the leverage factor.
{
"account_value": 10000,
"weights": {
"btc_ti_24h": 0.60,
"btc_ti_24h_short": 0.40
},
"ann_volatility_pct": 11.45,
"target_vol_pct": 30.0,
"leverage": 2.62
}
The reconciler multiplies every position by leverage when computing order sizes: order = account_value × leverage × weight × position
Start the reconciler. It polls every 5 seconds and places orders whenever a strategy updates its state.
python3 manager/reconciler.py
Fill in get_positions() and place_order() in manager/reconciler.py with your exchange's API calls before running.
The manager maximizes slope / std of the portfolio equity curve over the last N days (default 365). Slope is computed by fitting a linear regression to the cumulative return series — a steeper upward curve scores higher. Dividing by std penalizes volatility, so the optimizer naturally favors steady-climbing strategies over erratic ones.
After finding the optimal weights, the manager computes the portfolio's annualized volatility and derives a leverage factor: leverage = target_vol / ann_vol. This scales all position sizes so the portfolio's realized risk matches your target regardless of how volatile the underlying strategies are.