feedback
← Back to Learn

From Backtest to Live Trading

The agent handles everything — you just need to review the backtest and say you're ready.

Build a portfolio before going live

Before deploying anything, the recommended approach is to build multiple strategies first and run them together as a portfolio. The portfolio manager allocates capital across all strategies simultaneously, which provides diversification and more stable returns than running each strategy in isolation.

Running strategies one at a time — deploying one, then another later — means each strategy trades with whatever capital is left over rather than a coherent allocation plan. The manager handles this properly when all strategies are deployed together.

If you only have one strategy, you can still use the portfolio manager with equal weighting — it will size the position based on your account_value and target_vol_pct settings. As you add more strategies later, the manager rebalances automatically.

How to trigger deployment

After reviewing the backtest results, tell the agent you want to go live. It will ask a few questions before doing anything:

"I'm happy with the backtest. Deploy this live on Binance futures."

The agent will ask you to confirm with an explicit YES, then ask whether to align existing positions before the first run, and confirm the capital allocation settings. Once you've answered, it handles everything else automatically.

What the agent configures

MODE = "live"

The strategy file uses the same code for both backtest and live — only the MODE variable changes. In live mode, the strategy actually sends orders to the exchange instead of simulating them. The START date stays the same long date range as the backtest, so the performance history displayed on the dashboard includes both backtest and live periods.

portfolio_config.json

This file controls how capital is sized across your live strategies:

  • account_value: total USDT allocated to the whole portfolio. The manager divides this across all live strategies based on their weights — it's not per-strategy.
  • target_vol_pct: target annual volatility %. Default 30%. As a rule of thumb: target_vol ≈ acceptable MDD ÷ 2. If you can tolerate a 20% drawdown, set 10%.

The agent will show the current values and ask you to confirm or change them before proceeding.

Cron job

The agent installs a scheduled task that runs the strategy automatically. For a 1h strategy it looks like:

5 * * * * cd /root/.openclaw/workspace && python3 strategies/btc_sma_cross/strategy.py

The 5 means it runs 5 minutes past each hour — giving the exchange time to close the candle and publish data before the strategy checks for a new signal. You don't need to set this up yourself.

The reconciler — 部位對帳器 (multi-strategy portfolios)

When you have multiple live strategies, a reconciler handles the actual order placement. Each strategy updates its target position in a state file every time it runs. The reconciler polls every few seconds, detects any change, calculates the net position difference across the portfolio, and places the minimum orders to close the gap.

The agent starts and manages the reconciler. If it crashes, the shell wrapper restarts it automatically and sends a Telegram alert.

← Back to Learn