Skip to content

Suite for instantiating, managing and deploying quantitative strategies

License

Notifications You must be signed in to change notification settings

divergex/dxforge

Repository files navigation

drawing

dxforge - A Quantitative Trading Orchestration Platform

Publish Package PyPI - Downloads GitHub Tag GitHub License

API-based container and service orchestration for the quantitative trading ecossystem.

The dxforge suite is aimed at small teams and large teams that plan on scaling, reducing costs and maintenance of quantitative trading strategies.

The framework focuses on managing different strategies, their instances, feeds and portfolios via distributed and scalable nodes, without the need of managing them individually.

With a virtual container based approach, the framework is designed to be scalable, fault-tolerant and stress-tested.

Getting Started

Installation

If you prefer not to go through the installation process or simply want to run the dxforge without having Python and the dependencies set up, you can use the precompiled executables. This is especially useful for deployment or sharing with users who might not be familiar with Python environments.

pip install -r requirements.txt
python dxforge start

Produces:

Starting dxforge...


Started with PID 231835
  1. Navigate to the Releases section.
  2. Download the appropriate file for your operating system:
    • dxforge.sh for Linux/macOS
    • dxforge.exe for Windows
  3. After downloading, follow the instructions below.

For Linux/macOS Users

  1. First, you'll need to extract the compressed file. If you've downloaded the `strategy_manager_linux.tar.gz` from the releases, you can decompress it using the following command:
tar -xzvf strategy_manager_linux.tar.gz

This will extract the contents, including strategy_manager.sh (the shell script) and the actual compiled binary strategy_manager.

To run the dxforge using the shell script:

  1. Access the directory containing the sample strategy and feed managers

    cd dxforge
  2. Run the script:

    ./dist/dxforge [config_file] [--host] [--port]
    # e.g. ./dist/dxforge config.yaml

Replace [arguments] with any command-line arguments you wish to pass to the dxforge.

For Windows Users

A standalone executable named strategy-manager.exe is available for Windows users.

To run the dxforge using the executable:

  1. Navigate to the directory containing the project files using the Command Prompt or PowerShell.

    cd strategy-manager
  2. Run the executable:

    .\dist\strategy-manager.exe [config_file] [--host] [--port]
    # e.g. .\dist\strategy-manager.exe config.yaml

Replace [arguments] with any command-line arguments you wish to pass to the dxforge.

Note: The first time you run these executables, your operating system might prompt you to verify if you trust software from the publisher. Ensure you trust the source (in this case, the strategy_manager project) before proceeding.

Developing

Compiling from Source

Requirements

  • Python 3.7+
  • virtualenv or any other virtual environment manager
  1. Clone the repository:

    git clone [email protected]:divergex/dxforge.git
  2. Navigate to the repository directory and create a virtual environment:

    virtualenv venv
  3. Activate the virtual environment:

    • For Linux/macOS:
      source venv/bin/activate
    • For Windows:
      venv\Scripts\activate
  4. Install required packages:

    pip install -r requirements.txt

Running the Server

To start the dxforge instance locally, run:

python dxforge config.yaml

Optional command-line arguments:

  • --host to specify the host (default is 0.0.0.0)
  • --port to specify the port (default is 8000)

Functionalities

  • Listing Strategies:
    Visit http://localhost:8000/strategy/ to get a list of all available strategies.

  • Refreshing Strategy Status:
    POST request to http://localhost:8000/strategy/ to refresh the status of all strategies.

  • Proxy Get Routes for a Strategy:
    GET request to http://localhost:8000/strategy/{strategy}/ to get routes available for a strategy.

  • Proxy Get and Post Methods for a Strategy Endpoint:

    • GET: http://localhost:8000/strategy/{strategy}/{endpoint}
    • POST: http://localhost:8000/strategy/{strategy}/{endpoint} with appropriate data payload.

Sample strategy for testing

A sample strategy folder (strategies/rsi-strategy) is provided to demonstrate how to use the dxlib library. This script uses historical stock data for a set of tickers, runs a simple RSI strategy on the data, and calculates a list of signals.

To run the sample dxforge instance:

python strategies/rsi-strategy/run.py

And in another terminal, run the dxforge:

 python __main__.py config.yaml
# or
# ./dist/dxforge config.yaml

Configuration

Managers can be added or removed by modifying the a yaml file.

Example: config.yaml

{
  "feeds": "feeds/docker-compose.yaml",
  "strategies": "strategies/docker-compose.yaml",
  "port": "5000",
  "host": "0.0.0.0"
}

In this configuration, strategies has a list of docker compose services that serve on different ports. These available ports can be accessed at http://localhost:5000.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

Apache