Skip to main content

Quick start

This guide will help you get NanoARB running locally with synthetic market data in just a few minutes.

Prerequisites

Before you begin, make sure you have:
  • Rust 1.75+Install Rust
  • Node.js 18+ and pnpm — For the dashboard UI
  • Git — To clone the repository
Optional: Docker Desktop for Prometheus/Grafana monitoring

One-command setup

The fastest way to get started is using the provided startup script:
1

Clone the repository

git clone https://github.com/dhir1007/nanoARB.git
cd nanoARB
2

Start everything

./start.sh
This single command will:
  • Build the Rust trading engine in release mode
  • Install UI dependencies (if needed)
  • Start the trading engine on port 9090
  • Launch the dashboard UI on port 3000
Expected output:
============================================
  NanoARB - Starting Full Stack
============================================

[1/3] Building Rust trading engine (release)...
[2/3] Installing UI dependencies...
[3/3] Starting services...

  Rust Engine   : http://localhost:9090  (PID 12345)
  Metrics       : http://localhost:9090/metrics
  Health        : http://localhost:9090/health
  API State     : http://localhost:9090/api/state
  SSE Stream    : http://localhost:9090/api/stream
  Dashboard UI  : http://localhost:3000   (PID 12346)

============================================
  All services running. Press Ctrl+C to stop.
============================================
3

Access the dashboard

Open your browser to http://localhost:3000 to see the real-time trading dashboard.The dashboard shows:
  • Live order book with 15 levels
  • Real-time price chart with ML predictions
  • Trade history and P&L curve
  • Latency metrics and performance statistics
  • Risk monitoring and position tracking
4

Stop the services

Press Ctrl+C in the terminal, or run:
./stop.sh

Manual setup

If you prefer more control, you can start services manually:
1

Build the Rust engine

cargo build --release
This compiles the trading engine with maximum optimizations (LTO, single codegen unit).
2

Start the trading engine

./target/release/nanoarb
Or run in the background:
./target/release/nanoarb &
The engine will start in simulation mode by default, generating synthetic market data.
3

Start the dashboard UI (optional)

In a new terminal:
cd nano-arb-ui-development
pnpm install
pnpm dev
The UI will be available at http://localhost:3000.

Running your first backtest

NanoARB includes a powerful backtesting engine that simulates realistic market conditions.

CLI backtest

Run a backtest using synthetic data:
cargo run --release --bin nanoarb -- --backtest
Expected output:
INFO Starting NanoARB Trading Engine v0.1.0
INFO Running in backtest mode
INFO Using synthetic data for backtest
INFO Generated 100000 synthetic events
INFO Backtest completed in 2.3s
INFO Events processed: 100000
INFO Total P&L: $892.45
INFO Max Drawdown: 3.2%
INFO Sharpe Ratio: 4.8
INFO Win Rate: 54.3%
INFO Profit Factor: 2.3

API backtest

While the engine is running, you can trigger backtests via the REST API:
curl -X POST http://localhost:9090/api/backtest \
  -H "Content-Type: application/json" \
  -d '{
    "symbol": "ES",
    "startDate": "2024-01-01",
    "endDate": "2024-12-31",
    "initialCapital": 1000000,
    "spreadMultiplier": 1.0,
    "inventoryLimit": 50,
    "skewFactor": 0.5,
    "useML": true,
    "maxDrawdown": 5.0,
    "positionLimit": 50
  }'

Custom configuration

Create a config.toml file to customize backtest parameters:
config.toml
[trading]
live_enabled = false
symbols = ["ESH24"]
initial_capital = 1000000.0
max_position = 50
max_order_size = 10

[latency]
order_latency_ns = 100000
market_data_latency_ns = 50000
jitter_ns = 10000

[risk]
max_position = 50
max_drawdown_pct = 0.06
max_daily_loss = 100000.0
enable_kill_switch = true

[fees]
maker_fee = 0.25
taker_fee = 0.85
exchange_fee = 1.18
Then run:
cargo run --release --bin nanoarb -- --config config.toml --backtest

Available endpoints

Once the engine is running, the following HTTP endpoints are available:
EndpointMethodDescription
/healthGETHealth check
/metricsGETPrometheus metrics
/api/stateGETFull engine state (JSON)
/api/streamGETServer-Sent Events stream
/api/backtestPOSTRun backtest with custom parameters

Example: Get current state

curl http://localhost:9090/api/state | jq
Response includes:
  • Order book snapshot (15 levels)
  • Current position and P&L
  • Recent trades
  • Latency metrics
  • Risk alerts

Monitoring with Grafana

For advanced monitoring, you can launch Prometheus and Grafana:
cd docker
docker compose -f docker-compose-monitoring.yml up -d
Access Grafana at http://localhost:3000 (login: admin / nanoarb). The pre-configured dashboard shows:
  • Real-time P&L and Sharpe ratio
  • Latency histograms (p50, p95, p99)
  • Order flow and fill rates
  • Position and inventory tracking
To stop monitoring:
docker compose -f docker-compose-monitoring.yml down

Running tests

Verify your installation by running the test suite:
# Run all tests
cargo test --workspace

# Run specific crate tests
cargo test -p nano-lob

# Run benchmarks
cargo bench --workspace

Next steps

Troubleshooting

If port 9090 or 3000 is already in use:
# Kill processes on ports
lsof -ti:9090 | xargs kill -9
lsof -ti:3000 | xargs kill -9
Or specify a custom port:
PORT=8080 ./target/release/nanoarb
NanoARB requires Rust 1.75+. Update Rust:
rustup update stable
rustc --version
Install pnpm:
npm install -g pnpm
On Linux, you may need to install additional dependencies:
# Ubuntu/Debian
sudo apt-get install build-essential pkg-config libssl-dev

# Fedora/RHEL
sudo dnf install gcc gcc-c++ make openssl-devel