Crypto futures automated trading system — master plan from backtesting to live trading
Version: v1.0 (2026-07-07) Initial capital: about 1,000,000 KRW / target: Binance USDT-M futures (starting with BTC only) Objective function: not maximizing profit but completing "a low-deviation validation system + a track record" Labelling convention: [verified] = verified widely in academia and practice / [inference] = logical inference, to be confirmed by backtesting / [TBD] = to be confirmed at implementation
0. The premises this document stands on (3 assumptions corrected in conversation)
The design judgments of this project rest on the corrected premises below. When sharing with collaborators, agree on these premises first.
- Small capital ≠ high expected return. The only advantage of small capital is that slippage is small, so strategy returns are realized close to theoretical values. Expectancy itself is independent of capital size. The "high return potential" felt with small capital is mostly increased variance mistaken for increased expected return. [verified — basic statistics]
- Price movement ≠ account return. BTC's daily volatility standard deviation is roughly 2~3% (a daily conversion of 41~53% annualized as of 2026-07). ±5% is "an occasional 2σ event", not the default. What a strategy actually captures is range × capture rate, and leverage does not raise the capture rate. [verified — based on measured values; note this is a point-in-time snapshot]
- Parameter sweep ≠ diversification. Parameter variations of the same logic (RSI 14 vs 21) are structurally highly correlated and give no diversification. Diversification arises only between strategies with different market mechanisms (mean reversion vs trend vs market-neutral). [verified]
Phase 0 — defining principles and criteria (before coding, half a day)
Fix things in documents before writing a single line of code. Skipping this stage leads, in loss periods, toward "refining the backtest further instead of dropping the strategy" — the trading version of the pattern of expanding the plan when execution stalls.
0.1 Kill Criteria (fixed in numbers, no amendment after the fact)
| Scope | Criterion (example values — the owner finalizes) | Action when triggered |
|---|---|---|
| Strategy level | Out-of-sample Sharpe ratio < 0.5 or live-vs-backtest deviation > 50% | Discard the strategy; no parameter re-tuning |
| Account level | MDD reaches -15% | Close all positions, 2-week cooling-off, resume after documenting a root-cause analysis |
| Project level | Paper trading fails 3 times in a row (deviation criterion not met) | Live trading entry postponed indefinitely; simulation model redesigned |
| Daily level | Daily loss of -5% | Bot stops for the day (automatic) |
⚠️ The numbers above are examples. The owner sets the final values, but once set, they are not amended while in a loss. If an amendment is needed, only with no positions.
0.2 Success criteria (not profit)
- Backtest ↔ paper trading deviation < 20% [inference — a reasonable threshold, not a standard]
- 3+ months of uninterrupted automated operation (system stability)
- Automatic recording of every trade log and decision rationale (track record = the real asset for collaboration and raising capital)
0.3 Fixing the environment and tools
- Language: Python 3.11+ / libraries:
vectorbtorbacktesting.py(no building the engine from scratch — compress to 100~300 lines) - Data storage: local parquet or SQLite (initially), TimescaleDB if scale grows [TBD]
- Version control: Git (same workflow as 64patterns), stored outside the OneDrive folder (to avoid file truncation issues)
- Exchange: Binance USDT-M futures + a separate testnet account (testnet.binancefuture.com)
Phase 1 — data pipeline (within 1 week)
1.1 What to collect
| Data | Source | Use | Priority |
|---|---|---|---|
| OHLCV candles (1m, 5m, 1h, 1d) | Binance API /fapi/v1/klines | Basis for signal generation and backtesting | P0 |
| Funding rate history | /fapi/v1/fundingRate | Cost model + funding strategies | P0 |
| Exchange fee and minimum order size specs | /fapi/v1/exchangeInfo | Reflect execution constraints | P0 |
| Order book snapshots (L2) | WebSocket depth stream | For v2 strategies such as OFI | P2 (on hold) |
| Liquidation data | forceOrder stream | v2 signal candidate | P2 (on hold) |
1.2 Period and resolution principles
- At least 2 years, 4+ years if possible (must include 3 regimes: bull, bear and sideways) [verified — single-regime data leads straight to overfitting]
- Base resolution 1h, down to 5m depending on the strategy. Tick/second level is outside v1 scope.
- Download scripts support incremental updates (no full re-collection each time).
1.3 Data quality checks (run automatically right after collection)
- Missing candle detection (timestamp continuity)
- Outlier detection (distinguishing flash crashes such as a single candle ±30% — flag, not remove)
- Fix the 3-way data split boundaries: train 60% / validation 20% / final test 20%. The final test period stays sealed until Phase 3 is complete. Touching parameters after opening it contaminates it at that moment — a re-split is needed.
Phase 2 — backtesting engine MVP (1~2 weeks)
Scope: 1 strategy (RSI mean reversion), 1 coin (BTC), 200~400 lines. If the urge to widen the scope arises here, that is the signal the plan-expansion pattern is triggering.
2.1 Layered structure (module separation — the skeleton of every later Phase)
[1] Data layer load_data(symbol, timeframe, start, end) → DataFrame
[2] Indicator layer each indicator = an independent pure function (rsi(), bbands(), atr(), ...)
[3] Signal layer conditions defined by config (JSON/dict) → change combinations without code changes
[4] Money management layer position sizing + leverage (in earnest in Phase 4; fixed values in the MVP)
[5] Execution/statistics layer delegated to the library (vectorbt/backtesting.py)
2.2 Must be in the MVP (omissions bias results structurally toward optimism)
| Item | Implementation | Rationale |
|---|---|---|
| Fees | Maker 0.02% / taker 0.05% (varies by tier — confirm via exchangeInfo [TBD]) | For strategies that enter often, fees eat the entire profit |
| Funding | 8-hour cycle, received/paid by direction | Cannot be ignored in position-holding strategies |
| Fixed slippage | Assume 0.05% adverse on every fill (v1); order-book based in v2 | A midpoint between "perfect fill" assumptions and a precise model |
| Minimum order size | Reflect BTC futures minimum notional and quantity step | 1,000,000 KRW ÷ 3~4 strategies = ~200,000 KRW per strategy; rounding errors distort sizing logic. A problem specific to small capital |
| Missed trades | Excluded in v1 (explicit decision) | Distortion is limited since low-frequency strategies come first. Introduced in v2 with event-based simulation |
2.3 Output metrics (the common language for comparing strategies)
Total return, CAGR, Sharpe/Sortino, MDD, win rate, payoff ratio, trade count, average holding time, total fees + funding (% of profit), monthly return heatmap.
Phase 3 — strategy layer + validation methodology (2~4 weeks)
3.1 v1 strategy candidates (implementation order)
| # | Strategy | Type | Level of validation | Notes |
|---|---|---|---|---|
| 1 | RSI + Bollinger mean reversion (+ trend filter mandatory) | Mean reversion | High (saturation also high) | Strategy loaded in the MVP |
| 2 | Volatility breakout + ATR stop | Trend following | High | Different mechanism from no. 1 → a real diversification candidate |
| 3 | Funding rate arbitrage (futures short + spot long) | Market-neutral | Medium | No directionality, consistent with the "don't be greedy" principle. Needs the spot API added |
| 4 | Pair trading (cointegration-based, e.g. ETH-SOL) | Statistical arbitrage | Verified in academia and practice | v1.5 — needs a cointegration test implementation, one step above RSI |
| — | OFI/MLOFI, triangular arbitrage | Microstructure | Verified in academia | On hold for v2 — needs L2 data and low-latency infrastructure; structurally disadvantaged at individual scale |
3.2 Validation protocol (applied identically to every strategy)
- Parameter search only in the train period (grid/random search)
- Check top candidates in the validation period — a sharp drop versus train means overfitting; discard
- Walk-forward: must pass a rolling window (e.g. 6 months train → 1 month validation, stepping forward 1 month at a time)
- Open the final test period — only 1 time. If it fails here, review the whole strategy family
- Record the number of parameter combinations searched → multiple-testing correction (with 100 searched, 1~2 that look good by chance are a statistical certainty) [verified]
3.3 Regime classification (v1.5, excluded from the MVP)
- 3 classes, trend/sideways/high-volatility, by ADX / moving-average slope / realized volatility [inference — effectiveness cannot be judged before backtesting]
- Purpose: the real value of parallel strategies may come not from running them simultaneously but from shifting weights by regime.
Phase 4 — money management layer (1~2 weeks, can partly run in parallel with Phase 3)
Must be implemented separately from the signal layer — if mixed, "signal problem vs money-management problem" cannot be debugged.
4.1 Staged introduction
| Stage | Method | When |
|---|---|---|
| v1 | Fixed fraction (x% of balance, e.g. a 50% cap) + fixed leverage (2~3x or less) | From the MVP |
| v1.5 | Volatility targeting — automatically cut leverage as ATR/realized volatility rises | After signal validation |
| v1.5 | Drawdown-based reduction — halve sizing at MDD -10% | Same |
| v2 | Half/quarter Kelly — but plugging backtest win rate and payoff ratio in directly means using overfit values. A conservative discount is mandatory | After live data accumulate |
4.2 Validation method
A/B backtest with the same signals, changing only the money-management method. Comparison focuses not on returns but on MDD and probability of ruin (Monte Carlo simulation).
Phase 5 — parallel strategy portfolio (2 weeks)
5.1 Inclusion conditions (all must be met)
- Pass every stage of the Phase 3 validation protocol
- Return time-series correlation with already admitted strategies < 0.3 [inference — the threshold is conventional; lower is better]
- Executable with the allocated capital under minimum order size constraints
5.2 Capital allocation
- v1: equal allocation (1/N)
- v2: risk parity (inverse volatility weighting) — theoretically superior but implementation complexity jumps; limited benefit with 3 or fewer strategies [inference]
5.3 Explicit pitfalls
Running highly correlated strategies in parallel = hidden leverage, not diversification. Skipping the correlation check at admission exposes the whole portfolio to a single risk.
Phase 6 — automated strategy search (optional, only after validating the whole pipeline)
- Reason for its position: putting automated search on an unvalidated system makes it impossible to tell which layer a problem is in.
- Mandatory safeguards when introduced: strict 3-way data split + walk-forward + multiple-testing-corrected metrics such as the Deflated Sharpe Ratio.
- Psychological pitfall warning: "optimal values found by the system" carry authority and lower the threshold for live deployment. Automated search results must pass the same validation protocol as manual strategies — no exceptions.
- Compute cost: combinations × parameters × walk-forward windows = thousands of backtests. If too heavy locally, cloud spot instances [TBD].
Phase 7 — paper trading (at least 2~4 weeks, never skipped)
The mandatory gate between backtesting and live trading. What is checked here is deviation, not profit.
7.1 Execution
- Run the actual bot code as is on the Binance futures testnet (not backtest code — a rehearsal of the Phase 8 live code)
- In parallel: shadow records based on real-account prices (the testnet's liquidity differs from real accounts, which may distort fill prices [TBD — needs measurement])
7.2 Measurement items
| Item | Pass criterion (example) |
|---|---|
| Per-trade return deviation from backtest | Mean < 20% |
| Delay from signal → order accepted | < 1 second (ample for a 1h strategy) |
| Expected vs actual fill price (measured slippage) | Compare with the fixed 0.05% assumption → calibrate the model |
| Uninterrupted system uptime | > 99% (including automated restarts) |
| Rate of unfilled/partially filled orders | Recorded → input to the v2 execution model |
If the deviation criterion is not met: no live trading entry; retry after calibrating the slippage/fee/execution model. After 3 consecutive failures, the Phase 0 kill criteria trigger.
Phase 8 — going live: the Binance API live system
8.1 Live system architecture (sharing signal code with the backtester is the key)
┌─────────────────────────────────────────────────┐
│ Live Trading Bot │
│ │
│ [A] Data Feed WebSocket kline/markPrice │
│ ↓ (REST fallback, reconnection logic) │
│ [B] Signal Engine ★imports the same module as the backtester★ │
│ ↓ (two code paths = the root of deviation) │
│ [C] Risk Manager pre-order checkpoint: │
│ ↓ daily loss limit / max position / │
│ ↓ leverage cap / kill switch │
│ [D] Order Manager order submission, fill tracking, │
│ ↓ partial fill handling, retries (idempotency) │
│ [E] State Store position, balance, order status DB │
│ [F] Monitor logs + alerts (Telegram) + │
│ heartbeat + daily report │
└─────────────────────────────────────────────────┘
Reuse patterns already proven in 64patterns: idempotency keys (preventing duplicate orders — the same principle as credit_transactions), graceful partial handling on failure, webhook/event-based state updates.
8.2 Safeguards (all P0)
| Safeguard | Implementation |
|---|---|
| Minimal API key permissions | Only futures trading enabled, withdrawal permission always OFF, IP whitelist |
| Kill switch | (a) Manual: 1 Telegram command closes all positions and stops the bot (b) Automatic: on reaching -5% for the day |
| Heartbeat monitoring | Bot unresponsive for N minutes → alert. A server outage = positions left unattended |
| Order idempotency | Based on clientOrderId — prevents duplicate entries on network retries |
| Secret management | Environment variables, never committed to the repository (same as the 64patterns .env rule) |
| Staged capital deployment | 300,000 KRW in the first month → check deviation → the full 1,000,000 KRW. No full amount from the start |
8.3 Operating routine
- Daily: automatic report (profit, trade count, measured slippage, system status) — check only, no intervention
- Weekly: review deviation between backtest expectations and results
- Monthly: check against the kill criteria, review whether each strategy stays admitted
- Intervention principle: manual parameter changes only with no positions + a documented rationale
8.4 Infrastructure
- v1: an always-on VPS (low spec is enough for hourly strategies, around $5~10 per month) or a home server
- Latency: not a competitive factor for 1h/5m strategies. Low-latency infrastructure investment is unnecessary until v2 strategies such as OFI [inference]
Final system composition (target state)
┌──────────────┐
│ Data Store │ ← incremental collection pipeline (Phase 1)
└──────┬───────┘
│
┌──────────────────┼──────────────────┐
▼ ▼ ▼
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ Backtester │ │ Paper Trader │ │ Live Bot │
│ (Phase 2-6) │ │ (Phase 7) │ │ (Phase 8) │
└──────┬───────┘ └──────┬───────┘ └──────┬───────┘
│ │ │
└────────┬─────────┴───────────────────┘
▼
★ shared module (single source) ★
indicators / signals / risk / sizing
— all three execution environments import the same strategy code
│
▼
┌──────────────┐
│ Trade Ledger │ → track record (asset for collaboration and raising capital)
│ + Reports │
└──────────────┘
Design principle no. 1: the backtester, paper and live share the strategy code. The moment the code diverges, the cause of deviation between backtest results and live trading can never be found.
Timeline summary (conservative)
| Phase | Duration | Output |
|---|---|---|
| 0 | 0.5 days | Kill criteria document, environment setup |
| 1 | ~1 week | Data pipeline + quality checks + sealed 3-way split |
| 2 | 1~2 weeks | Backtesting MVP (strategy 1, BTC, including cost model) |
| 3 | 2~4 weeks | 2~3 strategies pass validation, walk-forward report |
| 4 | 1~2 weeks | Money management A/B results |
| 5 | 2 weeks | Portfolio construction + correlation analysis |
| 6 | Optional | Automated search (after full validation) |
| 7 | 2~4 weeks | Paper trading deviation report |
| 8 | Ongoing thereafter | Live bot + staged capital deployment |
In total about 3~4 months (excluding Phase 6). If pressure to go faster arises, reread the objective function in Phase 0.
Summary for onboarding collaborators (when sharing externally, this document + the 3 lines below)
- The goal is not short-term profit but a validated system and track record (1,000,000 KRW at 20~30% a year ≈ 200,000~300,000 KRW — the profit itself is meaningless at this stage).
- Every strategy must pass the 3-way split + walk-forward + deviation measurement to be admitted to live trading.
- The kill criteria are fixed in a document, and the principle is no amendment while in a loss.
Source and migration evidence
Source: backtest/docs/master-plan.md
Original SHA-256: 606d354141fb4a26aff4339d2987565cf9c503ebe1d1d7e31fc7286e8b3070bb
Raw data and account information are not part of the public package. The original results do not replace statistical or scientific revalidation. The English text is a translation; numbers, tables and charts are carried over unchanged.