Arbitrage Executor
ArbitrageExecutor: Specialized in controlling profitability between two markets, such as between centralized exchanges (CEX) and decentralized exchanges (DEX), optimizing for arbitrage opportunities.
The ArbitrageExecutor class is a specialized component within Hummingbot designed for capitalizing on price discrepancies between different markets or exchanges by automating the process of simultaneously executes buy and sell orders on two distinct markets, aiming to exploit arbitrage opportunities for profit.
- Efficiency: Automates the complex process of identifying and executing arbitrage opportunities.
- Speed: Executes buy and sell orders simultaneously to capture fleeting arbitrage opportunities.
- Risk Management: Calculates transaction costs to ensure profitable trades post-fees.
- Flexibility: Can be configured for various arbitrage strategies across different markets and exchanges.
Workflow¶
Upon initialization, the ArbitrageExecutor
performs the following actions:
- Validation: Ensures that the proposed arbitrage is valid, with interchangeable trading pairs.
- Order Tracking: Maintains
TrackedOrder
instances for buy and sell orders to monitor their statuses. - Profitability Calculation: Assesses potential profit, accounting for transaction costs, and executes trades if profitability exceeds the minimum threshold.
Sample Script¶
Below, we show code snippets from the Arbitrage with Smart Component script, which provides an example of how to use the ArbitrageExecutor.
You can define the two markets to arbitrage, the order amount, and the arbitrage profitability threshold.
class ArbitrageWithSmartComponent(ScriptStrategyBase):
# Parameters
exchange_pair_1 = ExchangePair(exchange="binance", trading_pair="MATIC-USDT")
exchange_pair_2 = ExchangePair(exchange="uniswap_polygon_mainnet", trading_pair="WMATIC-USDT")
order_amount = Decimal("50") # in base asset
min_profitability = Decimal("0.004")
The create_arbitrage_executor
method is responsible for creating a new ArbitrageExecutor
. First, it checks available balances on the buying and selling exchanges to ensure there's enough capital to execute the arbitrage. If so, it creates ArbitrageExecutor
instances based on the settings above.