How Does Triangular Arbitrage Work?
We develop triangular arbitrage algorithms that scan the market in real time and execute trades faster than competitors. Our team has 15+ years in high-frequency trading and 5+ years in cryptocurrencies, with over 50 implemented projects. The strategy relies on cyclic trading of three currency pairs on a single exchange to profit from price discrepancies, as explained in Triangular arbitrage. It does not require transfers between exchanges—everything happens on one platform. Key parameter: speed. Opportunities last milliseconds.
Imagine a situation: the ETH/BTC price differs from the calculated price through USDT by 0.1%. This yields a profit of several tens of dollars per cycle. But such an opportunity must be caught within milliseconds—otherwise another bot will take it. We automate this process: the algorithm continuously scans all pairs, finds cycles, and executes them with minimal latency. Our clients get a ready-made solution that works 24/7 and delivers stable profits with low risk. Contact us to discuss your arbitrage bot strategy.
The Principle of Triangular Arbitrage
Cycle of three pairs: A → B → C → A Example:
- BTC/USDT: 45,000 (1 BTC = 45,000 USDT)
- ETH/USDT: 3,000 (1 ETH = 3,000 USDT)
- ETH/BTC: 0.0668 (1 ETH = 0.0668 BTC)
Theoretically: 1 ETH should cost 3000/45000 = 0.0667 BTC. Actually: 1 ETH = 0.0668 BTC. Discrepancy = 0.01 BTC (~$45).
Trading cycle:
- Sell 45,000 USDT → buy 15 ETH (at ETH/USDT 3000)
- Sell 15 ETH → receive 1.002 BTC (at ETH/BTC 0.0668)
- Sell 1.002 BTC → receive 45,090 USDT (at BTC/USDT 45,000)
Profit: 90 USDT − fees. If 3 × taker fee 0.04% = 0.12% ≈ 54 USDT → net profit ~$36.
Why Is Speed Critical?
Triangular arbitrage is a highly competitive niche. Opportunities last 100–500 ms. We use optimizations:
- Pre-computed paths: we don't compute cycles from scratch on each update. We predetermine all possible triples and only check their profitability in real time.
- Selective monitoring: we monitor only the top 50 pairs by volume, not all 2000.
- Order preparation: all order parameters are calculated in advance; we send them on trigger.
- WebSocket for all pairs:
wss://stream.binance.com/stream?streams=btcusdt@bookTicker/ethusdt@bookTicker/ethbtc@bookTicker
Finding Profitable Cycles
Graph approach: build a currency graph where edges are trading pairs with weights (log of exchange rates). Search for negative cycles using the Bellman-Ford algorithm.
import networkx as nx import math def find_arbitrage_cycles(tickers): G = nx.DiGraph() for symbol, ticker in tickers.items(): base, quote = symbol.split('/') bid = ticker['bid'] ask = ticker['ask'] if bid > 0: # base → quote: sell base, get quote G.add_edge(base, quote, weight=-math.log(bid)) if ask > 0: # quote → base: buy base, pay quote G.add_edge(quote, base, weight=-math.log(1/ask)) # Find negative cycles (profitable arbitrage) try: cycle = nx.find_negative_cycle(G, source='USDT') return cycle except nx.NetworkXError: return None Optimal Trade Size Calculation
def optimal_trade_size(step1_depth, step2_depth, step3_depth, max_slippage=0.001): """ Maximum volume at which slippage does not consume profit """ # For each step: how much volume we can take within max_slippage size1 = get_available_liquidity(step1_depth, max_slippage) size2 = get_available_liquidity(step2_depth, max_slippage) size3 = get_available_liquidity(step3_depth, max_slippage) # Minimum of the three is our constraint return min(size1, size2, size3) Cycle Profitability Formula
def calculate_cycle_profit(pair1_rate, pair2_rate, pair3_rate, fee=0.001): """ Check cycle: USDT → BTC → ETH → USDT """ # Start with 1 USDT after_trade1 = (1 / pair1_rate) * (1 - fee) # USDT → BTC after_trade2 = (after_trade1 / pair2_rate) * (1 - fee) # BTC → ETH after_trade3 = after_trade2 * pair3_rate * (1 - fee) # ETH → USDT profit = after_trade3 - 1 # > 0 = profitable return profit Risks of Triangular Arbitrage
- Partial fill: one of the three orders is filled partially. This results in an open position. A handler is needed: immediately close the remainder at market price.
- Stale data: if price data is outdated (> 200 ms), we skip the opportunity.
- API rate limits: three simultaneous orders consume three API requests. With hundreds of signals per minute, you can hit the limits.
- Front-running: market makers see the pattern and close the arbitrage spread faster than us.
What Is Included in Developing a Triangular Arbitrage Bot?
| Step | Duration | Result |
|---|---|---|
| Pair analysis and selection | 1-3 days | List of potentially profitable cycles |
| Graph model design | 2-5 days | Architecture and algorithm |
| Exchange integration | 3-7 days | WebSocket and REST API |
| Order execution implementation | 5-10 days | Trading module with risk control |
| Testing (backtest + sandbox) | 3-5 days | Performance report |
| Deployment and documentation | 2-4 days | Working bot, user guide |
| Post-launch support | 1 month | Monitoring and refinements |
| Search Method | Speed | Accuracy | Implementation Complexity |
|---|---|---|---|
| Brute force | Low | High | Low |
| Graph-based (Bellman-Ford) | High | High | Medium |
| Analytical (linearization) | High | Medium | High |
How Do We Guarantee Results?
We use proven tools: Python, NetworkX, Binance WebSocket API. Each bot undergoes testing on historical data and in a sandbox. After launch, we support the system for a month. Team experience: 15+ years in algorithmic trading and 5+ years in cryptocurrencies, over 50 implemented projects. The deliverables include complete source code, API documentation, deployment guide, and one month of post-launch support.
Timeline and Cost
Development takes from 2 to 6 weeks depending on complexity. The cost is calculated individually after strategy analysis. Write to us—we will evaluate your project and offer the optimal solution.
Contact us to discuss your triangular arbitrage bot. Order turnkey development—get a ready cycle detection algorithm with documentation and support.







