rlxbt 0.1.1
Fast trading backtester written in Rust
License: MIT
Requires Python: >=3.8

# 🚀 RLXBT: Institutional-Grade Rust Backtesting SDK

[![PyPI version](https://badge.fury.io/py/rlxbt.svg)](https://badge.fury.io/py/rlxbt)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Powered by Rust](https://img.shields.io/badge/Powered%20by-Rust-orange.svg)](https://www.rust-lang.org/)

**RLXBT** is an ultra-high-performance algorithmic trading backtesting engine. Built in **Rust** with a **zero-copy Python API**, it offers the speed of a vectorized engine with the precision of a full event-driven simulation.

---

## 🔥 Why RLXBT?

- **Insane Performance**: Process over **4.5 Million bars per second**. Built for professional quant researchers who can't afford to wait hours for a single optimization.
- **Event-Driven Precision**: Unlike vectorized-only tools, RLXBT performs full per-bar simulation, supporting complex order types, intrabar resolution, and realistic slippage.
- **RL-Native**: The only backtester with built-in **Reinforcement Learning (OpenAI Gym)** support, including graph-based market observations and advanced reward shaping.
- **Institutional Analytics**: Over 30 metrics including **VaR, CVaR, Sharpe, Sortino, Ulcer Index**, and comprehensive drawdown analysis.
- **Declarative JSON Strategies**: Define complex trading logic using simple **JSON rules** (Simple or Graph formats), perfect for rapid prototyping without writing a single line of Python.
- **Rust Native CLI**: A standalone, ultra-fast binary to run backtests, optimize data, and convert CSVs to binary chunks without Python overhead.

---

## 💎 Features at a Glance

### ⚡ Core Engine (Rust)
- **Zero-Copy Memory**: Direct access to Numpy buffers for zero overhead.
- **Intrabar Resolution**: Simulate price action *inside* a candle (High-first vs Low-first) for high-precision TP/SL execution.
- **Multi-Strategy Portfolios**: Combine and optimize multiple strategies with unified capital management and rebalancing.

### �️ Standalone Rust CLI
- **`rlx-cli rules-backtest`**: Run backtests directly from JSON strategy files and CSV data.
- **`rlx-cli convert`**: Optimize CSV data into binary chunk formats for instant loading.
- **`rlx-cli dashboard`**: Generate interactive web dashboards directly from the terminal.

### �📊 Professional Analytics
- **Stability Analysis**: Built-in Monte Carlo simulations and Walk-Forward Analysis (WFA).
- **Graph Analyzer**: Identify winning streaks, loss recovery patterns, and correlation clusters via graph theory.
- **Parameter Sensitivity**: Automatically identify which parameters actually drive your performance.

### 🧠 AI & Reinforcement Learning
- **Gymnasium Compatible**: Seamless integration with Stable-Baselines3 and other RL frameworks.
- **GNN-Ready**: Graph-based observations for Graph Neural Networks.
- **Separation of Concerns**: RL agent learns Entry Timing, while dedicated Exit Controllers handle Risk Management.

---

## 📝 Declarative JSON Strategies
Define your strategy logic without writing boilerplate code. Supports multi-indicator confirmation and portfolio-aware conditions.

```json
{
  "entry_rules": [{
    "condition": "RSI_14 < 30 && close > SMA_200 && current_drawdown < 0.10",
    "signal": "InstitutionalLong",
    "direction": 1
  }],
  "exit_rules": [{
    "condition": "RSI_14 > 70",
    "reason": "TakeProfit_Overbought"
  }],
  "stop_loss_pct": 0.02,
  "max_hold_bars": 48
}
```

---

## 💰 Pricing & Plans

RLXBT requires a valid license key. Sign up at [rlxbt.com/pricing](https://rlxbt.com/pricing).

| Feature | Starter ($29/mo) | Pro ($79/mo) | Institutional ($499/mo) |
| :--- | :---: | :---: | :---: |
| **Max Bars** | 500K | **Unlimited** | **Unlimited** |
| **Metrics** | 10 Core | **30+ Institutional** | **All + VaR/Risk** |
| **RL Environment** | ❌ | ✅ | ✅ (Multi-Asset) |
| **Portfolio Manager** | ❌ | ✅ | ✅ |
| **Advanced Tools** | JSON Rules | MC, WFA, Graph | WF-ML, Custom API |
| **Support** | Community | Email | **Priority (4h)** |

---

## 🚀 Quick Start

### Installation
```bash
pip install rlxbt
```

### Basic Strategy
```python
import pandas as pd
from rlxbt import Strategy, Backtester

class SmaCross(Strategy):
    def generate_signals(self, data):
        sma = data['close'].rolling(20).mean()
        signals = pd.DataFrame(index=data.index)
        signals['signal'] = (data['close'] > sma).astype(int)
        return signals

# Initialize with your license key
bt = Backtester(license_key="your_key_here")

# Run backtest
data = pd.read_csv("market_data.csv")
results = bt.run(SmaCross(), data)

print(f"Total Return: {results['total_return']:.2%}")
bt.plot(data) # Launch interactive dashboard
```

---

## 🔗 Links
- **Official Website**: [rlxbt.com](https://rlxbt.com)
- **Full Documentation**: [rlxbt.com/docs](https://rlxbt.com/docs)
- **Pricing**: [rlxbt.com/pricing](https://rlxbt.com/pricing)

---

### 🏛️ Commercial Use
RLXBT is a commercial product. While you can download the package freely, a paid license is required for live strategy research and production execution.

© 2025 RLX Backtester. All rights reserved.