DCA Executor - Hummingbot
URL: https://hummingbot.org/v2-strategies/executors/dcaexecutor/
Contents:
- DCA Executor
- Initialization¶
- Spot vs Perpetual Behavior¶
- Configuration¶
- Execution Flow¶
- Conclusion¶
DCAExecutor: Manages the execution of Dollar Cost Averaging (DCA) strategies, allowing users to spread their investment across multiple orders over time to reduce the impact of volatility. It's designed for use in both spot and perpetual markets.
The DCAExecutor class implements a Dollar Cost Averaging strategy, which is a popular method for mitigating the impact of volatility by spreading purchases or sales over time.
The DCA strategy is simple yet effective, involving the execution of orders at regular intervals regardless of the asset's price. This approach can lead to a lower average cost per share or unit over time, making it a favored strategy for long-term investors.
The DCAExecutor class is versatile, designed to operate on both spot and perpetual exchanges. This allows for the implementation of DCA strategies across different market types:
The DCAExecutor engages with the market by executing orders based on the DCAExecutorConfig. It applies the DCA strategy as follows:
Here's a simplified flow of how the DCAExecutor operates:
The DCAExecutor is an essential component within Hummingbot for traders and investors looking to implement Dollar Cost Averaging strategies. By automating the execution of DCA orders, it simplifies the process of spreading out investments over time, which can help in managing the risks associated with market volatility. Whether for accumulating a position in a bullish market or distributing assets in a bearish scenario, the DCAExecutor provides a disciplined approach to market entry and exit.
Examples:
Example 1 (python):
def create_dca_order(self, level: int):
"""
This method is responsible for creating a new DCA order
"""
price = self.config.prices[level]
amount = self.config.amounts_quote[level] / price
order_id = self.place_order(connector_name=self.config.exchange,
trading_pair=self.config.trading_pair, order_type=self.open_order_type,
side=self.config.side, amount=amount, price=price,
position_action=PositionAction.OPEN)
if order_id:
self._open_orders.append(TrackedOrder(order_id=order_id))Example 2 (unknown):
type = "dca_executor"
exchange: str
trading_pair: str
side: TradeType
leverage: int = 1
amounts_quote: List[Decimal]
prices: List[Decimal]
take_profit: Optional[Decimal] = None
stop_loss: Optional[Decimal] = None
trailing_stop: Optional[TrailingStop] = None
time_limit: Optional[int] = None
mode: DCAMode = DCAMode.MAKER
activation_bounds: Optional[List[Decimal]] = None