Get the py_rt trading system running in 10 minutes.
Before you begin, ensure you have:
- Rust 1.70+ - Install from rustup.rs
- Python 3.11+ - Install from python.org
- uv - Fast Python package manager:
pip install uv - Alpaca Markets Account - Free paper trading at alpaca.markets
git clone https://github.com/SamoraDC/RustAlgorithmTrading.git
cd RustAlgorithmTrading# Install Python dependencies with uv
uv sync
# Verify installation
uv run python --version# Navigate to Rust workspace
cd rust
# Build all components (this will take a few minutes on first build)
cargo build --release
# Run tests to verify installation
cargo test --workspaceCreate a .env file in the project root:
# Copy template
cp .env.example .env
# Edit with your credentials
nano .envAdd your Alpaca API keys:
# Alpaca API Keys (Paper Trading)
ALPACA_API_KEY=your_api_key_here
ALPACA_SECRET_KEY=your_secret_key_here
ALPACA_BASE_URL=https://paper-api.alpaca.markets
ALPACA_DATA_URL=https://data.alpaca.markets
# System Configuration
RUST_LOG=info
LOG_LEVEL=INFOGet your API keys from Alpaca Dashboard.
Verify your API credentials work:
# Run connection test
uv run python python-trading/test_alpaca_connection.pyExpected output:
Account Status: ACTIVE
Buying Power: $100000.00
Portfolio Value: $100000.00
Equity: $100000.00
Create config/system.json:
{
"market_data": {
"alpaca_api_key": "${ALPACA_API_KEY}",
"alpaca_secret_key": "${ALPACA_SECRET_KEY}",
"zmq_pub_address": "tcp://*:5555",
"symbols": ["AAPL", "MSFT", "GOOGL"],
"reconnect_delay_secs": 5
},
"signal_bridge": {
"zmq_sub_address": "tcp://localhost:5555",
"zmq_pub_address": "tcp://*:5556",
"python_module": "src.strategies.momentum"
},
"risk_manager": {
"zmq_sub_address": "tcp://localhost:5555,tcp://localhost:5556",
"zmq_pub_address": "tcp://*:5557",
"max_position_size": 10000.0,
"max_order_size": 1000.0,
"max_daily_loss": 5000.0,
"position_limit_pct": 0.1
},
"execution_engine": {
"alpaca_api_key": "${ALPACA_API_KEY}",
"alpaca_secret_key": "${ALPACA_SECRET_KEY}",
"zmq_sub_address": "tcp://localhost:5557",
"zmq_pub_address": "tcp://*:5558",
"max_retries": 3,
"max_slippage_bps": 50,
"rate_limit_per_minute": 200
}
}Open 4 terminal windows and start each component:
cd rust/market-data
RUST_LOG=info cargo run --releaseWait for: Market Data Service started on tcp://*:5555
cd rust/signal-bridge
RUST_LOG=info cargo run --releaseWait for: Signal Bridge connected to tcp://localhost:5555
cd rust/risk-manager
RUST_LOG=info cargo run --releaseWait for: Risk Manager started, enforcing limits
cd rust/execution-engine
RUST_LOG=info cargo run --releaseWait for: Execution Engine connected to Alpaca Markets
Test a strategy with historical data:
# Run basic momentum strategy backtest
uv run python examples/basic_backtest.pyExpected output:
Backtesting Momentum Strategy...
Total Return: 12.34%
Sharpe Ratio: 1.45
Max Drawdown: -8.21%
Win Rate: 54.3%
Check that all components are running:
# Check market data service
curl http://localhost:9090/metrics | grep market_data
# Check risk manager
curl http://localhost:9091/metrics | grep risk_manager
# Check execution engine
curl http://localhost:9092/metrics | grep execution_engineNow that your system is running:
- Develop a Strategy - Create your first trading strategy
- Configure Risk Limits - Set up risk controls
- Run Backtests - Test strategies on historical data
- Monitor Performance - Set up dashboards and alerts
# Find process using port 5555
lsof -i :5555
# Kill process
kill -9 <PID>- Ensure services start in order: Market Data → Signal Bridge → Risk Manager → Execution Engine
- Check firewall settings allow localhost connections
- Verify API keys are correct in
.env - Check account status at Alpaca Dashboard
- Ensure using paper trading URL for testing
# Reinstall dependencies
uv sync --reinstall# Clean and rebuild
cd rust
cargo clean
cargo build --release- Check Troubleshooting Guide
- Search GitHub Issues
- Ask in GitHub Discussions