Skip to main content
The DCA Executor implements Dollar Cost Averaging by spreading investment across multiple orders at different price levels, reducing the impact of volatility.

Overview

PropertyValue
Position TypeSpot or Perp
keep_positionConfigurable
Use CasesBuilding positions, averaging down, systematic entry

Configuration

from hummingbot.strategy_v2.executors.dca_executor.data_types import (
    DCAExecutorConfig,
    DCAMode,
    TrailingStop,
)

config = DCAExecutorConfig(
    controller_id="my-agent",
    connector_name="binance",
    trading_pair="BTC-USDT",
    side=TradeType.BUY,
    leverage=1,
    amounts_quote=[100, 150, 200, 300],  # Increasing amounts
    prices=[65000, 63000, 61000, 59000],  # Entry prices
    take_profit=Decimal("0.05"),          # 5% TP from avg
    stop_loss=Decimal("0.10"),            # 10% SL from avg
    time_limit=86400,                      # 24 hours
    mode=DCAMode.MAKER,
)

Parameters

ParameterDescription
amounts_quoteList of order amounts in quote currency
pricesList of entry prices for each level
take_profitExit target as % from average entry
stop_lossStop loss as % from average entry
time_limitMaximum duration in seconds
modeMAKER (limit) or TAKER (market)
activation_boundsOptional price bounds for activation

How It Works

  1. Level Setup: Creates orders at each price/amount pair
  2. Order Management: Places limit orders at specified prices
  3. Fill Tracking: Tracks fills and calculates average entry
  4. Exit Management: Applies TP/SL relative to average entry

DCA Modes

ModeBehavior
MAKERPlaces limit orders at each price level
TAKERUses market orders when price reaches level

Example: Systematic BTC Entry

# Build BTC position with increasing size at lower prices
btc_dca = DCAExecutorConfig(
    controller_id="btc-dca",
    connector_name="binance",
    trading_pair="BTC-USDT",
    side=TradeType.BUY,
    amounts_quote=[
        Decimal("200"),   # First entry
        Decimal("300"),   # Avg down
        Decimal("500"),   # Larger at support
    ],
    prices=[
        Decimal("67000"),
        Decimal("64000"),
        Decimal("61000"),
    ],
    take_profit=Decimal("0.08"),  # 8% from avg
    stop_loss=Decimal("0.15"),    # 15% from avg
    mode=DCAMode.MAKER,
)

Example: Quick DCA with Trailing Stop

# Tighter DCA with trailing stop
quick_dca = DCAExecutorConfig(
    controller_id="quick-dca",
    connector_name="binance_perpetual",
    trading_pair="ETH-USDT",
    side=TradeType.BUY,
    leverage=3,
    amounts_quote=[
        Decimal("100"),
        Decimal("100"),
        Decimal("100"),
    ],
    prices=[
        Decimal("3200"),
        Decimal("3100"),
        Decimal("3000"),
    ],
    take_profit=Decimal("0.05"),
    stop_loss=Decimal("0.08"),
    trailing_stop=TrailingStop(
        activation_price=Decimal("0.03"),
        trailing_delta=Decimal("0.015"),
    ),
    time_limit=7200,  # 2 hours
)

Spot vs Perpetual

MarketBehavior
SpotAccumulates base asset across levels
PerpetualBuilds leveraged position across levels
On perpetual markets, leverage is applied to all orders uniformly.