Skip to content

CompassLabs/dojo_examples

Repository files navigation

Dojo Examples

Welcome to the Dojo trading strategy development and backtesting environment! This repository contains code examples and guidance on how to use the Dojo Python package to develop and backtest your own trading strategies.

In order to run these examples, you must have Dojo installed on your machine with a valid license key (or use the free sample simulations).

Please refer to the Getting Started guide in the docs for more detailed instructions on getting set up 🙂

Table of Contents

Introduction

Dojo is a powerful Python package developed by Compass Labs that allows traders and quantitative analysts to develop, test, and deploy trading strategies efficiently. With Dojo, you can simulate trading strategies over historical data, analyze performance metrics, and optimize your strategies before deploying them to live markets.

Features

  • Strategy Development: Build custom trading strategies using a flexible and intuitive API.
  • Backtesting: Simulate strategies over historical data to evaluate performance.
  • Performance Analysis: Generate detailed reports and metrics to understand strategy behavior.

Installation

We recommend using a virtual environment to manage dependencies:

python3 -m venv venv
source venv/bin/activate

Clone the Repository

git clone https://github.com/CompassLabs/dojo_examples.git

Install the Dojo package via pip:

pip install dojo-compass

Finally, install Foundry on your system.

Authentication

Dojo requires two configurations to run:

  1. A Valid License Key
  2. An Archive Node URL available from providers like Infura.

You can also use the free sample simulations, in which case you should set an empty archive node URL (e.g. ETHEREUM_RPC_URL=) but you should not set a license key.

Set these as environment variables by following our guide here.

Docker Setup

We provide a Dockerfile to help you containerize your Dojo environment. Using Docker ensures consistency across different development environments and simplifies the setup process.

The Dockerfile builds an image that contains all the necessary dependencies to run Dojo simulations, including Python, Dojo, Foundry, and other required packages.

Building the Docker Image

To build the Docker image, navigate to the root directory of the repository where the Dockerfile is located. You need to pass your LICENSE_KEY and at least one of the RPC URLs (ETHEREUM_RPC_URL or ARBITRUM_RPC_URL) as build arguments.

Build Command:

docker build . --build-arg LICENSE_KEY='your-license-key' --build-arg ETHEREUM_RPC_URL='your-ethereum-rpc-url'

Notes:

Replace your-license-key with your actual Dojo license key. Replace your-ethereum-rpc-url with your Ethereum RPC URL (e.g., from Infura). If you prefer to use Arbitrum, you can pass ARBITRUM_RPC_URL instead of ETHEREUM_RPC_URL. Take note of the image hash (e.g., sha256:...) output at the end of the build process; you'll need it to run the container.

Running the Docker Container

After building the image, you can run the container using the image hash obtained from the build step.

docker run <image-hash-from-build-command>

### Running a Trading Strategy on Docker You can also run other examples by overriding the default command. The following command will run the moving averages trading strategy on the Docker container.

docker run <image hash from build command> poetry run python examples/moving_averages/run.py

Contributing

If something isn't working as expected, please raise an issue in this repository.

Contact

For questions or support, please contact us at [email protected] or visit our website compasslabs.ai.

Happy trading! 🙂

About

A gallery of dojo examples

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •