How to Build a Freqtrade Crypto Quantitative Trading Bot

·

The year 2025 is shaping up to be a major bull market in the cryptocurrency space, fueled by the Bitcoin halving and potential monetary policy shifts. If you're a developer or tech-savvy trader, now is the perfect time to dive into algorithmic trading. With Python-based frameworks like Freqtrade, building your own crypto trading bot has never been more accessible.

This guide walks you through setting up a Freqtrade-powered quantitative trading bot on a cloud server using Docker. Whether you're interested in spot trading or futures, simulation (dry-run) or live execution, this step-by-step tutorial covers everything from environment setup to strategy customization.


Step 1: Set Up Docker Environment on Your Cloud Server

Start with an Ubuntu-based cloud server. Ensure you can access it via SSH, then install Docker by running the following commands:

sudo apt update
sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt update
sudo apt install docker-ce

These commands prepare your system and install the latest stable version of Docker, which is essential for containerizing your Freqtrade bot.

👉 Get started with secure crypto trading infrastructure today.


Step 2: Install Freqtrade and Initialize the Project

Once Docker is ready, set up Freqtrade using its official docker-compose.yml file:

mkdir ft_userdata
cd ft_userdata/
curl https://raw.githubusercontent.com/freqtrade/freqtrade/stable/docker-compose.yml -o docker-compose.yml
docker compose pull
docker compose run --rm freqtrade create-userdir --userdir user_data

This creates the core directory structure, including user_data, where configurations, strategies, and logs will reside.

Next, generate the main configuration file:

docker compose run --rm freqtrade new-config --config user_data/config.json

You’ll be prompted with several questions. Here’s how to respond based on common best practices:

After setup, two critical components are created:

Understanding Key Configuration Settings

Your config.json file controls every aspect of the bot. Below are essential parameters:

{
  "trading_mode": "spot",
  "max_open_trades": 5,
  "stake_currency": "USDT",
  "stake_amount": 200,
  "dry_run": true,
  "timeframe": "3m",
  "exchange": {
    "name": "okx",
    "key": "",
    "secret": "",
    "pair_whitelist": [
      "1INCH/USDT:USDT",
      "ALGO/USDT:USDT"
    ],
    "pair_blacklist": ["*/BNB"]
  },
  "entry_pricing": {
    "price_side": "same",
    "use_order_book": true
  },
  "exit_pricing": {
    "price_side": "other"
  },
  "pairlists": [
    {
      "method": "StaticPairList"
    }
  ]
}
🔐 Security Tip: Never expose your API key and secret in public repositories. Store them securely and restrict API permissions on OKX to trading only—disable withdrawals.

For futures trading, update:

"trading_mode": "futures",
"margin_mode": "isolated"

You can also implement dynamic pair selection using filters like volume, price stability, and liquidity to improve performance.

👉 Optimize your trading setup with advanced tools and data.


Step 3: Develop and Customize Trading Strategies

Navigate to user_data/strategies/. Freqtrade provides a sample strategy template. You can modify it or create new ones.

Here’s a simplified example using RSI crossovers:

class SampleStrategy(IStrategy):
    INTERFACE_VERSION = 3
    can_short = False

    minimal_roi = {"60": 0.01, "30": 0.02, "0": 0.04}
    stoploss = -0.10
    trailing_stop = False
    timeframe = '5m'

    def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe['rsi'] = ta.RSI(dataframe, timeperiod=14)
        return dataframe

    def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe.loc[
            (qtpylib.crossed_above(dataframe['rsi'], 30)),
            'enter_long'
        ] = 1
        return dataframe

    def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe.loc[
            (qtpylib.crossed_above(dataframe['rsi'], 70)),
            'exit_long'
        ] = 1
        return dataframe

This strategy buys when RSI crosses above 30 (oversold) and sells when it exceeds 70 (overbought). You can enhance it with MACD, Bollinger Bands, or machine learning models.


Step 4: Launch the Bot

Edit your docker-compose.yml to specify the correct strategy class:

command: >
  trade
  --logfile /freqtrade/user_data/logs/freqtrade.log
  --db-url sqlite:////freqtrade/user_data/tradesv3.sqlite
  --config /freqtrade/user_data/config.json
  --strategy SampleStrategy

Ensure the --strategy value matches your Python class name.

Start the bot in detached mode:

docker compose up -d

Check logs for errors or signals:

tail -f user_data/logs/freqtrade.log

If Telegram is enabled, you’ll receive status updates directly in your chat.


Step 5: Backtesting Your Strategy

Freqtrade supports backtesting to evaluate historical performance:

docker compose run --rm freqtrade backtesting \
--config user_data/config.json \
--strategy SampleStrategy \
--timeframe 5m \
--timerange 20240101-20241231

⚠️ Important: Backtest results are indicative but not guaranteed. Market conditions, slippage, and liquidity impact real-world outcomes. Always validate strategies in dry-run mode before going live.


Frequently Asked Questions (FAQ)

Q: Can I use Freqtrade for live trading on OKX?

Yes. After thorough testing in dry-run mode, switch "dry_run": false and input your valid OKX API keys with trading permissions enabled.

Q: Is it safe to run a bot on a cloud server?

Yes, as long as you secure SSH access (use key-based authentication), keep software updated, and avoid exposing sensitive endpoints publicly.

Q: How do I update my Freqtrade version?

Run:

docker compose pull

Then restart the container. Always back up your config and data first.

Q: Can I trade multiple strategies at once?

Freqtrade supports one strategy per instance. To run multiple strategies, deploy separate containers with different configurations.

Q: What timeframes does Freqtrade support?

Common intervals include 1m, 5m, 15m, 1h, and 1d. Supported values depend on the exchange API.

Q: How can I monitor my bot remotely?

Enable the API server and use FreqUI (web interface), or rely on Telegram alerts for trade notifications and balance checks.


👉 Secure your exchange account and start deploying bots with confidence.


Final Thoughts

Building a crypto quantitative trading bot with Freqtrade empowers developers to automate strategies across spot and futures markets. By combining Dockerized deployment, modular strategy design, and integration with exchanges like OKX, Freqtrade offers a robust foundation for both beginners and advanced users.

Focus on risk management, test extensively, and evolve your strategies over time. The future of trading is algorithmic—start building yours today.

Core Keywords: Freqtrade crypto bot, quantitative trading robot, algorithmic trading, crypto futures bot, automated trading strategy, OKX API integration, Python trading bot, Docker crypto bot