Skip to content

Controllers

Controllers are the production-grade building block of the Strategy V2 framework. They define reusable, modular sub-strategies that are more configurable and robust than standalone scripts — ideal for long-running deployments and multi-strategy setups.

A controller interfaces with the MarketDataProvider (OrderBook, Trades, Candles) and emits ExecutorActions that instruct the parent script to create or stop executors. Controllers are not started directly — they are loaded by the special v2_with_controllers.py script, which can run multiple controllers simultaneously in a single bot instance.

Controllers vs Scripts

Use controllers when you need: - Multiple strategies running in parallel (e.g., market making on 5 pairs) - Production-grade, config-driven deployments - Strategy logic that's reusable and independently testable

Use scripts for simpler, single-pair strategies or when learning the framework.

Base Classes

Currently, the controller base classes available are:

Directional Trading Controllers

These strategies aim to profit from predicting the market's direction (up or down) and takes positions based on signals indicating the future price movement.

Suitable for strategies that rely on market trends, momentum, or other indicators predicting price movements.

Customizing signal generation (get_signal) allows users to change various analytical models to generate trade signals and determine the conditions under which trades should be executed or stopped.

Market Making Controllers

These strategies provide liquidity by placing buy and sell orders near the current market price, aiming to profit from the spread between these orders.

Customization involves defining how price levels are selected (get_levels_to_execute), how orders are priced and sized (get_price_and_amount), and when orders should be refreshed or stopped early.

User may also adjust the strategy based on market depth, volatility, and other market conditions to optimize spread and order placement.

Other Controllers