Skip to content

Demonstrates how to use the Roq C++17 API for Live Cryptocurrency Algorithmic and High-Frequency Trading as well as for Back-Testing and Historical Simulation

License

Notifications You must be signed in to change notification settings

a-nava/roq-samples

 
 

Repository files navigation

roq-samples

Samples demonstrating how to implement various features of algorithmic trading solutions.

Operating Systems

  • Linux (x86-64, AArch64)
  • macOS (x86-64)

Note! The Windows Subsystem for Linux (WSL) is NOT supported. Reason can be found here.

Library/Package Dependencies

Optional

Prerequisites

The project is primarily designed to be compatible with the conda package manager.

Download and Install Miniforge

Linux / x86_64

wget -N https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh

bash Miniforge3-Linux-x86_64.sh -b -u -p ~/conda

~/conda/bin/conda install -y \
    gxx_linux-64>=11

Linux / aarch64

wget -N https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-aarch64.sh

bash Miniforge3-Linux-aarch64.sh -b -u -p ~/conda

~/conda/bin/conda install -y \
    gxx_linux-aarch64>=11

macOS / x86_64

wget -N https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-x86_64.sh

bash Miniforge3-MacOSX-x86_64.sh -b -u -p ~/conda

~/conda/bin/conda install -y \
   clang_osx-64

Install Dependencies

source ~/conda/bin/activate

conda install -y \
    git \
    make \
    cmake \
    abseil-cpp

conda install -y --channel https://roq-trading.com/conda/stable \
    roq-client

Building

git submodule update --init --recursive

cmake .

make -j4

Using

  • Example 1
    • Connect to market gateway
    • Subscribe using regex patterns
  • Example 2
    • Manage disconnect
    • Process incremental market data update
    • Maintain a market depth view
    • Update a simple model
  • Example 3
    • Maintain positions
    • Place limit orders
    • Deal with order acks and updates
    • Historical simulation
    • Live trading
  • Example 4
    • Subscribe and nothing else
  • Example 5
    • Transfer CustomMessage from a secondary thread
  • Import
    • Convert any data source to an event-log
    • Encoding has header-only dependencies

Simulation Data (install)

Simulation requires you to either use your own event logs (automatically captured when you're running a gateway) or use sample data

conda install -y --channel https://roq-trading.com/conda/stable \
    roq-data

Data can now be found in the $CONDA_PREFIX/share/roq-data/ directory.

Gateways (install, configure, run)

conda install -y --channel https://roq-trading.com/conda/stable \
    roq-deribit

It is easiest to start from a config file template

cp $CONDA_PREFIX/share/roq-deribit/config.toml ~/deribit.toml

Edit this file and update with your Deribit API credentials (link).

You should look for these lines and replace as appropriate

login = "YOUR_DERIBIT_LOGIN_GOES_HERE"
secret = "YOUR_DERIBIT_SECRET_GOES_HERE"

Launch the gateway

roq-deribit \
    --name "deribit" \
    --config_file ~/deribit.toml \
    --client_listen_address ~/deribit.sock
conda install -y --channel https://roq-trading.com/conda/stable \
    roq-coinbase-pro

It is easiest to start from a config file template

cp $CONDA_PREFIX/share/roq-coinbase-pro/config.toml ~/coinbase-pro.toml

Edit this file and update with your Coinbase Pro API credentials (link).

You should look for these lines and replace as appropriate

login = "YOUR_COINBASE_PRO_API_KEY_GOES_HERE"
password = "YOUR_COINBASE_PRO_PASSPHRASE_GOES_HERE"
secret = "YOUR_COINBASE_PRO_SECRET_GOES_HERE"

Launch the gateway

roq-coinbase-pro \
    --name "coinbase-pro" \
    --config_file ~/coinbase-pro.toml \
    --client_listen_address ~/coinbase-pro.sock

License

The project is released under the terms of the BSD 3-Clause license.

Links

About

Demonstrates how to use the Roq C++17 API for Live Cryptocurrency Algorithmic and High-Frequency Trading as well as for Back-Testing and Historical Simulation

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 90.6%
  • CMake 6.6%
  • Shell 2.8%