roq-api Documentation

repository·master·Indexed 19 days ago

https://github.com/roq-trading/roq-api

C++ interfaces for algorithmic and high-frequency trading (HFT). roq-api provides a modular, low-latency, allocation-free, and schema-driven framework for interacting with market gateways, replaying event logs for back-testing, and integrating with monitoring tools like Prometheus and databases such as ClickHouse.

Tokens
915
Snippets
5
Records
6
Agent score
18%

What's inside roq-api

  1. Understand the roq-api design and architecture

    master

    roq-api provides a modular, low-latency C++ interface for algorithmic and high-frequency trading (HFT). It is designed to reduce 'glue' code by offering standard solutions for data capture, monitoring, and bridging.

    Core Components:

    • C++ API: A unified interface that allows clients (such as trading strategies) to communicate with gateways or replay event-logs for simulation and back-testing.
    • FIX bridge: Supports integration with third-party solutions via the FIX protocol.
    • Adapters: Support third-party database solutions (e.g., ClickHouse).
    • Metrics interface: Supports third-party monitoring tools like Prometheus, Alertmanager, and Grafana.

    Key Technical Characteristics:

    • Allocation-free: Strong preference for allocation-free message encoding/decoding.
    • Schema-driven: Extensive use of auto-generated code based on schemas.
    • Strongly typed: Uses strongly typed messages (events).
    • Asynchronous: Provides asynchronous interfaces and implementations.
    • Low Latency: Utilizes C++ and shared memory for high-performance requirements.
  2. Create and activate a conda development environment

    master

    The project is designed to be compatible with the conda package manager. You can create a development environment using the provided scripts and then activate it.

    1. Create the environment: Use the scripts/create_conda_env script. You can specify stable or unstable (for development builds) and the build type (e.g., debug).

    2. Activate the environment: Once created, activate the environment using the source command.

    Note: unstable provides more regularly updated development builds, while stable provides the monthly release build.

    # Create environment
    scripts/create_conda_env unstable debug
    
    # Activate environment
    source opt/conda/bin/activate dev
  3. Install the closed-source roq-client via conda

    master

    Since roq-api only contains the C++ interfaces, you must install the closed-source client implementation to actually use the API. You can do this using conda by pointing to the Roq trading channel.

    conda install -y --channel https://roq-trading.com/conda/stable roq-client
    conda install -y --channel https://roq-trading.com/conda/stable \
        roq-client
  4. Use the roq::Start signal to trigger application startup

    master

    The roq::Start struct is a signal used to initiate the startup sequence of a Roq application. It is a zero-sized type designed to be emitted within the Roq event loop to signal that the application is ready to begin its lifecycle. When used with formatting libraries like {fmt}, it is represented as {}.

    // Example of how a Start signal might be used in an event loop context
    // (Note: Actual event emission depends on the specific Roq application framework usage)
    roq::Start start_signal;
    // ... emit start_signal to the event loop ...