Freqtrade Strategy

How to build a Binance trading bot with freqtrade

Updated 31 Oct 2026 · 5 min read

Binance is the largest crypto exchange by volume, and it is one of the exchanges freqtrade supports best. With freqtrade you can run a Binance trading bot for free, using any strategy you can write or download, without paying a monthly subscription. This guide covers the Binance-specific steps: the API key, server location, spot and futures configuration, and the settings that commonly cause problems.

If freqtrade is not installed yet, start with our Docker installation guide.

Before you start: check where your server is

Binance blocks API access from some countries based on the server's IP address, not just where you live. Freqtrade's documentation lists Canada, Malaysia, the Netherlands and the United States as examples and points to Binance's terms for the current list. If your bot runs on a VPS in one of those countries, it will fail even if your account is valid.

  • Choose a VPS region Binance supports, such as Tokyo or Singapore. See our VPS guide.
  • US residents use the separate Binance.US exchange. In freqtrade its exchange ID is binanceus, not binance.

Step 1: Secure your Binance account

  1. Turn on two-factor authentication.
  2. Consider a sub-account dedicated to the bot. Freqtrade assumes the account balance belongs to the bot, and manual trades on the same account can confuse it.
  3. Move only the amount you are prepared to risk into that account.

Step 2: Create the API key

In Binance, open API Management and create a new key.

  • Choose a system-generated key, or an RSA key (see below).
  • Enable Spot & Margin Trading for spot bots. Enable Futures only if you will trade futures.
  • Never enable withdrawals.
  • Restrict access to trusted IPs only and enter your server's public IP (curl -4 ifconfig.me on the server).
  • Save the API key and secret securely. Binance shows the secret once.

RSA keys. Freqtrade supports Binance RSA API keys and recommends passing the private key through an environment variable rather than pasting it into the config:

export FREQTRADE__EXCHANGE__SECRET="$(cat ./rsa_binance.private)"

Step 3: Configure a spot bot

In user_data/config.json:

"trading_mode": "spot",
"stake_currency": "USDT",
"dry_run": true,
"exchange": {
    "name": "binance",
    "key": "YOUR_API_KEY",
    "secret": "YOUR_API_SECRET",
    "pair_whitelist": ["BTC/USDT", "ETH/USDT", "SOL/USDT", "XRP/USDT", "ADA/USDT"],
    "pair_blacklist": ["BNB/.*"]
}

Why blacklist BNB?

Binance can pay trading fees in BNB. If your bot buys BNB as a trade and fees are also being taken from BNB, the position can shrink and become impossible to sell in full. Freqtrade's documentation recommends adding BNB to the blacklist unless you keep a separate BNB balance for fees or turn off BNB fee payment. Freqtrade never buys BNB to cover fees itself.

Use stoploss on exchange

Binance supports stoploss on exchange, which places your stop on Binance itself. It still protects you if your server goes offline. Freqtrade recommends enabling it:

"order_types": {
    "entry": "limit",
    "exit": "limit",
    "stoploss": "market",
    "stoploss_on_exchange": true
}

Step 4: Futures (optional, higher risk)

Freqtrade supports Binance USDT-M futures in isolated margin mode. Requirements from the freqtrade docs:

  • In Binance's futures settings, set Position Mode to One-way Mode and Asset Mode to Single-Asset Mode. Freqtrade checks these on startup and will not change them for you.
  • Futures pricing must use the order book:
"trading_mode": "futures",
"margin_mode": "isolated",
"entry_pricing": { "use_order_book": true, "order_book_top": 1 },
"exit_pricing": { "use_order_book": true, "order_book_top": 1 }
  • Futures pairs use the format BTC/USDT:USDT.
  • Binance has quantitative trading rules that can restrict accounts placing many very small orders. Keep stakes reasonable.

Leverage multiplies losses as well as gains. Get a spot strategy working in dry-run before considering futures.

Step 5: Download Binance data and backtest

freqtrade download-data --exchange binance --pairs BTC/USDT ETH/USDT SOL/USDT \
  --timeframes 1h 4h --timerange 20240101-
freqtrade backtesting --config user_data/config.json --strategy AverageStrategy --timerange 20240101-

Every strategy on our leaderboard was tested on Binance spot data for 10 coins, so you can compare your results with ours. Our backtesting tutorial explains how to read the output.

Step 6: Run in dry-run, then go live

docker compose up -d
docker compose logs -f

Leave "dry_run": true for at least a few weeks. When dry-run results are close to your backtest and you understand every trade, switch to live with a small balance. Add Telegram alerts so you see each trade as it happens.

Common Binance errors

Service unavailable from a restricted location. Your server is in a country Binance blocks. Move to a supported region.

Invalid API-key, IP, or permissions for action. The key lacks trading permission, or the IP restriction does not match your server.

Timestamp for this request is outside of the recvWindow. The server clock is wrong. Run sudo timedatectl set-ntp true.

Filter failure: NOTIONAL or MIN_NOTIONAL. The order is below Binance's minimum value for that pair. Increase your stake amount.

Futures startup error about position or asset mode. Set One-way Mode and Single-Asset Mode in Binance futures settings.

Frequently asked questions

Is a freqtrade Binance bot free? Yes. Freqtrade is open-source software under the GPL-3.0 licence. You only pay Binance's trading fees and the cost of a server to run it.

Is it legal to use a trading bot on Binance? Binance provides a public API for automated trading, and using it with your own account is normal. You must follow Binance's terms and the laws of your country, and Binance is not available everywhere.

Which Binance trading bot strategy is best? No strategy is best in every market. In our two-year test on Binance data, slower trend-following strategies on the 4h chart did better than most short-timeframe scalpers, but none beat buying and holding Bitcoin.

Can I use Binance's built-in bots instead? Yes. Binance offers its own grid and DCA bots inside the app. They are easier to start but limited to preset bot types, while freqtrade lets you run any strategy and backtest it first.

Do I need a VPS for a Binance bot? A bot must run 24/7, so most people use a small VPS in a region Binance supports. Our VPS guide explains the options.

Ready to connect an exchange?

Freqtrade needs an exchange account with API access. Bybit supports both spot and futures in freqtrade and offers a demo mode for testing.

Affiliate link: we may earn a commission if you sign up, at no cost to you.

Related guides