Forex Arbitrage Bots: How They Work and Whether to Build or Buy One
A forex arbitrage bot is a program that receives prices from two or more sources, detects a gap larger than its costs and sends the orders to trade it, usually in milliseconds. It can be an Expert Advisor inside an M4 or M5 terminal, a cBot in cTrader, a Python script on a broker API, a FIX engine, or a module of a dedicated arbitrage platform. The trading logic is the easy part; the speed of the connection, the quality of the data and the broker’s rules decide whether a bot makes money.
- Six parts: feed handler, clock and normaliser, signal engine, cost filter, order manager, and risk and logging.
- Where it runs matters: bots inside a terminal are cheap but add delay; FIX and direct connectors are faster.
- Open-source code is a starting point: GitHub projects show the idea but rarely include execution, risk control or reconnection logic.
- No bot guarantees profit: treat “no-loss” or “AI arbitrage” promises as red flags.
How a Forex Arbitrage Bot Works
Every arbitrage bot runs the same loop on each new price: compare, check costs, trade, confirm, log. What separates a working bot from a demo is how fast and how safely each step runs.
- Feed handler
Receives quotes from the fast source and from the broker you trade, over FIX, API, WebSocket or a terminal connector.
- Clock and normaliser
Timestamps every tick on one clock and maps symbol names, so prices from different sources can be compared.
- Signal engine
Calculates the gap that matters for the strategy: fast bid vs broker ask, a cross rate vs its implied value, or a spread vs its average.
- Cost filter
Trades only if the gap exceeds spread, commission and expected slippage. A well-built bot takes your commission per lot and measured slippage as inputs for this reason.
- Order manager
Sends the orders, handles rejections and partial fills, and closes positions by gap, time, take-profit or stop.
- Risk and logging
Applies limits on size, drawdown and trading hours, has a kill switch, and records signal time, fill time and slippage for every trade.
Most of the engineering time goes into steps 1, 5 and 6: connections that drop, orders that come back late or rejected, and logs good enough to tell you why a trade lost. The strategies a bot can run are explained in our forex arbitrage guide.
Forex Arbitrage Bot Types by Strategy
A bot is built for one strategy. The strategy decides how many orders it sends, how fast it must be and how brokers will react.
| Bot type | What it trades | Orders per signal | Speed needed |
|---|---|---|---|
| Latency arbitrage bot | Broker quote vs a faster feed (guide) | 1 | Milliseconds |
| Lock / hedge bot | Opposite positions at a fast and a slow broker (guide) | 2 | Milliseconds |
| Triangular bot | Three pairs when the cross rate is out of line (guide) | 3 | Milliseconds, in parallel |
| Statistical arbitrage bot | Spread between correlated pairs (guide) | 2 | Seconds are acceptable |
| Swap arbitrage bot | Swap differences between accounts (guide) | 2–3 | Not speed-sensitive |
EA, cBot, Python or FIX: Where Arbitrage Bots Run
Where a bot runs sets its speed limit. A bot inside a trading terminal sees each price only after the terminal does and sends orders through it; a bot on FIX or a direct connector talks to the broker’s server itself.
| Where it runs | Language | Speed | Strengths | Limits |
|---|---|---|---|---|
| M4/M5 Expert Advisor | The terminal’s built-in language | Limited by the terminal | Cheap, runs at most retail brokers | Extra delay; second feed needs a workaround |
| cTrader cBot | C# | Limited by the terminal | Modern API; arbitrage category in the cTrader Store (cTrader) | Only cTrader brokers |
| Python bot | Python | Depends on the API; tens of milliseconds are common | Fast to write, good for research | REST APIs are slow; garbage collection pauses |
| FIX engine | C++, C#, Java | Fastest available to most traders | Direct order confirmations, institutional venues | Needs a FIX account; months of work |
| Arbitrage platform | Configured, not coded | Direct connectors and FIX | Built-in feeds, strategies, recording and testing | Licence cost; less freedom than own code |
A detailed comparison of terminal-based EAs with standalone platforms is in M4/M5 arbitrage software: EA vs platform, and the FIX side in FIX API trading.
Open-Source Forex Arbitrage Bots on GitHub
Open-source arbitrage bots are useful for learning how detection works. They are rarely ready to trade: most lack robust execution, risk controls, reconnection and realistic cost modelling.
A typical example is high-freq-forex-bot, a Python project for finding and exploiting arbitrage opportunities in currency exchange (GitHub). Projects like it show how to build an exchange-rate graph and search it for profitable cycles. Before running any such code with money:
- Read every line that handles keys, orders and withdrawals; never run unknown code on a machine with live credentials.
- Check the data source: free price APIs are often delayed or mid-price only.
- Add costs and delay: most demos assume fills at displayed prices.
- Add a kill switch and limits on size, loss and open positions.
Many GitHub “arbitrage bots” are built for crypto exchanges, where APIs are public and gaps are larger. They do not transfer directly to forex brokers.
Build vs Buy: Should You Code Your Own Arbitrage Bot?
Build if you have a developer, FIX or API access and a strategy that no product supports. Buy if you want to start testing brokers in days and measure gaps before investing months of development.
| Build your own | Buy a cheap EA | Buy a professional platform | |
|---|---|---|---|
| Time to first test | Months | Hours | Days |
| Cost | Developer time, data, servers | Low | Licence |
| Speed | As good as you build it | Terminal-limited | Direct connectors and FIX |
| Fast feeds | You source them | Usually none | Often included |
| Testing and logs | You build them | Basic | Tick recording and back testing |
| Main risk | Bugs in execution and risk code | Too slow to capture gaps | Vendor lock-in, learning curve |
Vendors and prices are compared in best forex arbitrage software; cost ranges for servers and feeds are in HFT infrastructure cost.
How to Test a Forex Arbitrage Bot
Test a bot the way it will trade: on recorded ticks from your broker, with your measured delay and costs, then live at the minimum lot.
- Record ticks from the broker and the reference feed on one clock for several sessions, including news.
- Replay with delay: assume orders fill at the broker price that existed after your measured signal-to-fill time, not at the signal price.
- Include rejections: count orders rejected or re-quoted in your live tests and apply that rate in the replay.
- Forward-test at 0.01 lot for two weeks and compare live results with the replay of the same period.
- Watch the broker’s reaction: changes in spreads, execution time or rejection rate after the first profitable days are a sign the account has been flagged.
Research on high-frequency arbitrage explains why live results fall short of replays: competing arbitrageurs enter the same trades, so some legs fail or fill worse (Kozhan and Tham, 2012).
Red Flags When Buying a Forex Arbitrage Bot
- “Risk-free” or “no loss” claims, or a fixed monthly return.
- “AI arbitrage” with no explanation of the data, feeds or execution it uses.
- Backtests without delay or costs, or only demo-account monitoring.
- “Undetectable by brokers” promises: they invite you to break your client agreement.
- “Free download” of paid software: cracked copies can carry malware and get no updates.
- No support for the brokers you use, or no way to model your broker’s commission.
Before running any arbitrage bot, read your broker’s terms: many brokers and most prop firms restrict latency arbitrage. See is forex arbitrage legal.
Glossary
- Trading bot
- A program that receives prices and sends orders automatically according to fixed rules.
- Expert Advisor (EA)
- An automated trading program that runs inside an M4 or M5 terminal.
- cBot
- An automated trading program written in C# for the cTrader platform.
- FIX engine
- Software that sends and receives orders and market data using the FIX protocol.
- Kill switch
- A control that stops all trading and closes or freezes positions immediately.
- Signal-to-fill time
- The time from the moment a bot detects a gap to the moment the broker confirms the fill.
Forex Arbitrage Bot FAQ
What is a forex arbitrage bot?
Do forex arbitrage bots really work?
Can I build a forex arbitrage bot in Python?
Are there free forex arbitrage bots on GitHub?
What is the difference between an arbitrage bot and an arbitrage EA?
Will my broker allow an arbitrage bot?
This page is published by Westernpips, which develops and sells arbitrage trading software, including Westernpips Private 7. Product mentions are the publisher’s own; third-party tools are described from their public pages. Worked examples use hypothetical prices.
Sources
- lperezmo. high-freq-forex-bot: Python program for finding and exploiting arbitrage opportunities in currency exchange (GitHub repository). www.github.com/lperezmo/high-freq-forex-bot
- cTrader Store. Arbitrage and Latency Trading Bots category. ctrader.com/product-list/arbitrage-and-latency-trading-bots
- Kozhan, R. and Tham, W. W. (2012). Execution risk in high-frequency arbitrage. Management Science, 58(11), 2131–2149. doi.org/10.1287/mnsc.1120.1541
- European Securities and Markets Authority (2018). ESMA adopts final product intervention measures on CFDs and binary options: leverage limits from 30:1 (major currency pairs) to 2:1, margin close-out and negative balance protection for retail clients. www.esma.europa.eu/press-news/esma-news/esma-adopts-final-product-intervention-measures-cfds-and-binary-options
- Financial Conduct Authority (2019). FCA confirms permanent restrictions on the sale of CFDs and CFD-like options to retail consumers, including leverage limits and a standardised risk warning with the share of retail accounts that lose money. www.fca.org.uk/news/press-releases/fca-confirms-permanent-restrictions-sale-cfds-and-cfd-options-retail-consumers
Read next
- Forex arbitrage: the complete guide
Strategies, costs, legal status and infrastructure.
- M4/M5 arbitrage software
Latency arbitrage EA vs a standalone HFT platform.
- Forex arbitrage scanners
Detection tools, and why a gap on screen is not a fill.
- Best forex arbitrage software 2026
Platforms, EAs and custom code compared.

