Rust CLI

Run backtests from terminal without Python — maximum speed for CI/CD pipelines

Why Use the CLI?

Zero Overhead

No Python runtime, GIL, or PyO3 bindings

🚀

Instant Startup

Binary launches in milliseconds

🔧

CI/CD Ready

Easy integration with pipelines

📜

Shell Scripts

Automate via bash/zsh

Installation

Terminal
# Build optimized release binary
cargo build --release

# For development (no license required)
cargo build --release --features offline_license

# Binary location
./target/release/rlx-cli --help

Commands

rules-backtest

Run backtest using JSON rules file — no pre-calculated signals needed.

Terminal
./target/release/rlx-cli rules-backtest \
    --data data/BTCUSDT_1h_with_indicators.csv \
    --rules strategies/rsi_strategy.json \
    --capital 100000 \
    --commission 0.001 \
    --output results.json

Arguments

ArgumentDescriptionDefault
--dataCSV file with OHLCV + indicatorsRequired
--rulesJSON rules fileRequired
--capitalInitial capital100000
--commission Commission rate0.0
--dashboard Launch web dashboardfalse
--outputOutput JSON fileNone

info

Display information about a data file.

Terminal
./target/release/rlx-cli info --data data/BTCUSDT_1h.csv

# Output: bar count, time range, available columns

JSON Rules Format

Simple Format

rsi_strategy.json
{
  "entry_long": "RSI_14 < 30",
  "exit_long": "RSI_14 > 70",
  "entry_short": "RSI_14 > 70",
  "exit_short": "RSI_14 < 30"
}

Advanced Format

institutional_strategy.json
{
  "entry_rules": [
    {
      "condition": "RSI_14 < 25 && close > SMA_200",
      "signal": "OversoldLong",
      "direction": 1
    },
    {
      "condition": "RSI_14 > 75 && close < SMA_200",
      "signal": "OverboughtShort",
      "direction": -1
    }
  ],
  "exit_rules": [
    {
      "condition": "current_drawdown > 0.15",
      "reason": "PortfolioProtection"
    }
  ],
  "stop_loss_pct": 0.025,
  "take_profit_pct": 0.045,
  "max_hold_bars": 45
}

Available Variables

Market Data

  • open, high, low, close, volume
  • RSI_14, MACD, SMA_20 — Any CSV column
  • BB_Upper, BB_Lower, ATR_14

Portfolio State

  • equity, cash, total_value
  • current_drawdown, total_pnl
  • position_size, bars_in_position

Example Output

Terminal Output
$ ./target/release/rlx-cli rules-backtest --data data/BTCUSDT_1h.csv --rules rules/btc_rsi.json

RLX Backtester v1.0.0
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

📊 Data: BTCUSDT_1h.csv (8,760 bars)
📋 Strategy: btc_rsi.json
💰 Initial Capital: $10,000.00

Running backtest... ████████████████████ 100% (0.02s)

═══════════════════════════════════════════════════
                    RESULTS
═══════════════════════════════════════════════════

Performance:
  Total Return:      +45.23%
  Sharpe Ratio:      1.87
  Sortino Ratio:     2.45
  Max Drawdown:      -12.34%
  Calmar Ratio:      3.67

Trading:
  Total Trades:      156
  Win Rate:          62.18%
  Profit Factor:     2.31
  Avg Trade:         +0.29%

Risk:
  VaR (95%):         -1.23%
  CVaR (95%):        -1.87%
  Ulcer Index:       4.56

Time: 0.018s | 486,667 bars/sec

CLI vs Python Performance

Operation Rust CLI Python API Winner
Startup time5ms200msCLI (40x)
130K bars backtest0.1s0.029s Python (3x)*
Memory (peak)50MB300MBCLI (6x)
CI/CD IntegrationNative Requires Python CLI

* Python API with zero-copy numpy optimization is faster for repeated backtests (data stays in memory)

When to Use What?

✓ Use Rust CLI

  • • CI/CD pipelines
  • • Batch processing multiple strategies
  • • Servers without Python
  • • Shell scripts and automation
  • • Minimal memory environments

✓ Use Python API

  • • Interactive analysis
  • • Jupyter notebooks
  • • Integration with pandas/numpy
  • • Machine learning workflows
  • • Custom Python logic