Crypto algo trading means software that reads market data through an exchange's API and places, changes and cancels orders by fixed rules, with no person clicking. Bots range from simple rebalancing scripts to market makers that send thousands of orders a minute. This guide covers how bots connect to exchanges, the main strategies, the architecture of a trading system, testing, security and the rules on market abuse, for traders who build bots and for exchanges that want to attract those traders.
How bots connect to exchanges
- REST APIs. Bots use REST calls to place and cancel orders, check balances and fetch history. Each private request carries a signature made with the user's API key, and exchanges limit how many requests each key can send.
- WebSocket streams. Streams push order book changes, trades and private order and balance events in real time, so bots that react fast read streams instead of polling REST endpoints.
- FIX. FIX is the standard messaging protocol of stock and futures markets, and some crypto exchanges offer FIX connections to institutional clients that already use it.
- On-chain access for DEXs. Bots call router contracts or submit signed intents, which are messages that state the wanted trade. Solvers, third parties that compete to fill trades, then complete the intent. The bot pays gas for each transaction and tracks the nonce, the sequence number of its account's transactions. It must also limit what it loses to MEV bots, which reorder or front-run transactions. The DEX aggregator guide covers routing logic.
Request signing differs by exchange. Binance's spot API, for example, accepts HMAC, RSA and Ed25519 keys and recommends Ed25519. Binance rejects a signed request when the timestamp falls outside the request window, which defaults to 5,000 milliseconds, so a server clock that drifts can stop a bot.
Open-source frameworks for algorithmic trading in crypto
Most teams start from an open-source library or framework instead of writing every exchange connector themselves.
| Project | License | What it provides |
|---|---|---|
| CCXT | MIT | One API for more than 100 exchanges, in JavaScript, TypeScript, Python, C#, PHP, Go, Java and Rust |
| Freqtrade | GPL-3.0 | A Python trading bot with backtesting and strategy optimization |
| Hummingbot | Apache-2.0 | A framework for market making and other high-frequency bots on centralized and decentralized exchanges |
| Jesse | MIT | A Python framework for writing, backtesting and running strategies |
| NautilusTrader | LGPL-3.0 | An event-driven trading engine written in Rust, with the same code for backtests and live trading |
CCXT suits research and tools that trade on several exchanges, while strategies that depend on low latency usually call each exchange's native API directly.
Common crypto algo trading strategies
| Strategy | What it does | Main risk |
|---|---|---|
| Market making | Quotes buy and sell orders and earns the spread and maker rebates | Inventory losses when the price trends; trading against better-informed traders |
| Cross-exchange arbitrage | Buys on the cheaper exchange and sells on the more expensive one | Transfer delays, withdrawal limits and fees that remove the profit |
| Funding and basis trades | Buys the coin and sells a perpetual futures contract of the same size, so the bot holds a short futures position. When futures trade above the spot price, long positions pay funding to short positions, and the bot collects those payments. | Liquidation, failure of the exchange |
| Execution algorithms (TWAP, VWAP) | Splits a large order into small ones to reduce price impact | Other traders can spot a predictable pattern |
| Trend and momentum | Follows price signals over minutes to weeks | Overfitting, changes in market behavior |
| Grid and DCA bots | Places a ladder of orders, or buys at fixed intervals | Large losses in a strong one-way move |
Architecture of a trading system
- Market data handler. The handler builds a local order book from a snapshot plus incremental updates, checks sequence numbers and reloads the snapshot when it finds a gap.
- Strategy engine. The engine turns market state and positions into the orders it wants. Keep the engine separate from network calls and storage, so tests can run it on recorded data.
- Order management system. The order manager tracks each order from creation to close and handles partial fills, rejections, and cancellation requests that reach the exchange after the order has already filled.
- Risk layer. The risk layer enforces hard limits on position size, order rate, value traded per minute and loss per day. It also holds a kill switch, sits between the strategy and the exchange, and can block any order.
- Storage and monitoring. The system stores trade records for reconciliation and tax, and metrics and alerts track latency, rejected orders, and any gap between the profit the system expects and the profit it records.
Crypto trading bot development steps
- Write the strategy rules down. Define entries, exits, position sizes and the markets the bot trades.
- Collect data. Use tick or order book data where the strategy depends on fills, and candle data only for slow strategies.
- Backtest with costs. Include fees, spread and slippage. At each price, exchanges fill limit orders first come, first served, so for limit orders, model how many earlier orders sit ahead of the bot's order.
- Paper-trade. Run the bot on live data without real orders, or on an exchange's test environment, and compare results with the backtest.
- Go live with small size. Start with a small balance and strict risk limits, then raise size only after weeks of results that match the paper trades.
- Monitor and maintain. Exchanges change APIs, pairs and limits, so the connectors need regular updates.
The following figures are a reasoned estimate, not a quote. A bot for one exchange and one strategy, with backtesting, takes one or two developers about one to three months, while a market-making system for several exchanges, with its own risk layer and monitoring, takes a small team six months or more.
Backtesting traps
Many strategies that look profitable in a backtest lose money in live trading. Common causes:
- look-ahead bias, where the test uses data the bot could not have known at that moment
- fees and spread left out of the test
- fills assumed at the best price, when a real order would not have filled there
- market impact of the bot's own orders left out
- survivorship bias, from testing only coins that still exist
- parameters tuned to fit one period
Use tick or order book data where possible, model the queue position of limit orders and keep a period of data that you never use during tuning, so that a final test on it shows whether the strategy works on data it has not seen.
Exchange behavior that breaks bots
- Rate limits differ by endpoint and by account tier, and exchanges ban keys for a period when bots exceed them.
- Minimum order sizes, tick sizes and lot sizes differ by pair and change over time.
- Exchanges run planned and unplanned maintenance, delist pairs and switch pairs to cancel-only mode.
- A WebSocket connection can drop messages without an error, so the bot must check sequence numbers.
- A drifting server clock causes the exchange to reject signed requests.
API key security
Create trading keys without withdrawal permission and restrict each key to fixed IP addresses. Store secrets in a secrets manager instead of in code, and rotate them on a schedule. Many retail losses start with a third-party bot service or browser extension that received a key with withdrawal rights.
What exchanges offer algo traders
An exchange that wants professional order flow usually provides these features:
- stable APIs with complete documentation
- a matching engine that keeps the same speed and order handling under heavy load as under normal load
- a test environment
- clear rate limits
- maker and taker fee tiers
- a formal market-maker program
The white label crypto exchange guide lists the checks to run on a vendor's API, and the crypto exchange software guide covers the matching engine and API design.
Some teams now test AI agents that hold their own wallets and trade on-chain. The guide to AI agents and smart contracts covers the risks of giving software its own spending power.
Frequently asked questions
Do I need low latency for crypto algo trading?
Only for market making and short-term arbitrage; execution algorithms, rebalancing and trend strategies run well on ordinary cloud servers.
Is algorithmic trading in crypto legal?
Algorithmic trading is generally legal, but manipulative practices are not. Some jurisdictions also regulate firms that use algorithms to manage other people's money, so check the rules where you operate.
Can one bot trade on many exchanges?
Yes, through a library such as CCXT or your own adapters. Each exchange still has its own rules, fees and failure modes, and the bot must handle those differences.
How do trading bots usually lose money?
Two causes are common: strategies tuned too closely to past data, and missing risk limits that let a bug or a sudden market move run unchecked.