Skip to main content

Welcome

Get up and running with ClyptQ Trading Engine quickly. This guide will help you set up your development environment and run your first backtest.
1

Install ClyptQ

Install the ClyptQ package using pip:
pip install clyptq
Requires Python 3.9+ and pip. We recommend using a virtual environment.
2

Set up environment variables

Create a .env file in your project directory:
# Environment
CLYPTQ_ENV=dev  # dev, prod, kernel

# API Keys (optional for getting started)
BINANCE_API_KEY=your_api_key
BINANCE_API_SECRET=your_api_secret
For local development, you can start without API keys using sample data.
3

Create your first strategy

Create a simple momentum crossover strategy:
from clyptq.system.graph import ComputeGraph, Input
from clyptq.operators.indicator import SMA
from clyptq.operators.signal import CrossoverAlpha

# Create compute graph
graph = ComputeGraph()

# Add indicators
sma_fast = graph.add_node("sma_fast",
    SMA(Input("close", lookback=10), span=10)
)
sma_slow = graph.add_node("sma_slow",
    SMA(Input("close", lookback=50), span=50)
)

# Generate signal
signal = graph.add_node("signal",
    CrossoverAlpha(
        Input("sma_fast", lookback=1),
        Input("sma_slow", lookback=1)
    )
)
4

Run a backtest

Configure and run your first backtest:
from clyptq.apps.trading.spec import TradingSpec, StrategySpec
from clyptq.apps.trading import TradingDriver

# Create trading spec
spec = TradingSpec(
    strategy=StrategySpec(
        graph=graph,
        signal_node="signal"
    ),
    execution=TradingExecutionSpec(
        mode="backtest",
        venue="binance",
        market_type="futures",
        latency_mode="INSTANT"
    )
)

# Run backtest
driver = TradingDriver.from_spec(spec)
driver.load_data(
    items=["BTC/USDT:USDT"],
    start="2024-01-01",
    end="2024-12-31"
)

for result in driver.run():
    print(f"PnL: {result.pnl:.2f} USDT")
5

Analyze results

View performance metrics:
# Get final metrics
metrics = driver.get_metrics()

print(f"Total Return: {metrics.total_return:.2%}")
print(f"Sharpe Ratio: {metrics.sharpe_ratio:.2f}")
print(f"Max Drawdown: {metrics.max_drawdown:.2%}")
print(f"Win Rate: {metrics.win_rate:.2%}")

What’s Next?

Need Help?