Introducing a new way to review your PRs.

Read the announcement

freqtrade / freqtrade

Free, open source crypto trading bot

View on GitHub

13 documents · Updated Nov 16, 2026

overview

Knowledge Base updated: 2026-11-16

Knowledge Base Index

1. Orientation

Freqtrade is a Python cryptocurrency trading bot. Its highest-level flow starts at the CLI, loads configuration and plugins, then runs either the live/dry-run trading worker or an offline tool such as backtesting, hyperopt, data download, plotting, or the API webserver.

Main parts:

  • freqtrade/commands/ and freqtrade/main.py — CLI parsing and command dispatch.
  • freqtrade/configuration/ — config loading, merging, validation, and environment/secret handling.
  • freqtrade/worker.py, freqtrade/freqtradebot.py, and freqtrade/wallets.py — live/dry-run trading runtime.
  • freqtrade/exchange/ — exchange abstraction, CCXT integration, exchange subclasses, and websocket support.
  • freqtrade/strategy/ — user strategy interface, callbacks, parameters, validation, and helpers.
  • freqtrade/data/ and freqtrade/optimize/ — historical data, data providers, backtesting, and hyperopt.
  • freqtrade/rpc/ — RPC core, REST API server, websockets, Telegram/Discord/webhook integrations, and web UI serving.
  • freqtrade/freqai/ — machine-learning training and prediction pipeline.
  • ft_client/ — separately packaged API client for interacting with a Freqtrade server.

Critical state lives primarily in:

  • The persistence database managed under freqtrade/persistence/**, which stores trades, pair locks, custom/key-value data, migrations, and wallet history.
  • Historical market data handled under freqtrade/data/history/**, which supplies candles/trades for backtesting, strategies, and FreqAI.
  • Runtime exchange state reached through freqtrade/exchange/**, including markets, balances, orders, and websocket-fed data.
  • FreqAI model/data state under freqtrade/freqai/**, used by training and inference pipelines.

2. Architecture diagrams

flowchart TD
  subgraph EntryPoints[Entry points]
    CLI[freqtrade/main.py + commands]
    Client[ft_client package]
  end

  subgraph Core[Core bot]
    Config[configuration]
    Worker[worker.py]
    Bot[freqtradebot.py]
    Strategy[strategy]
    Plugins[plugins + resolvers]
    Wallets[wallets + leverage]
  end

  subgraph IO[Data and state]
    Exchange[exchange]
    Data[data/history/provider]
    DB[persistence DB]
  end

  subgraph Surfaces[Control surfaces]
    RPC[rpc core]
    API[api_server + websockets]
    Chat[telegram/discord/webhook]
  end

  subgraph Offline[Offline tools]
    Optimize[backtesting + hyperopt]
    FreqAI[freqai]
  end

  CLI --> Config
  CLI --> Worker
  CLI --> Optimize
  CLI --> API
  Config --> Plugins
  Worker --> Bot
  Bot --> Strategy
  Bot --> Exchange
  Bot --> Wallets
  Bot --> DB
  Bot --> Data
  Bot --> RPC
  RPC --> API
  RPC --> Chat
  Client --> API
  Optimize --> Strategy
  Optimize --> Data
  Optimize --> DB
  FreqAI --> Data
  FreqAI --> Strategy
flowchart TD
  Start[trade command] --> LoadConfig[load and validate config]
  LoadConfig --> Resolve[resolve strategy, exchange, pairlists, protections]
  Resolve --> Worker[Worker lifecycle]
  Worker --> BotLoop[FreqtradeBot process loop]
  BotLoop --> MarketData[fetch/analyze market data]
  MarketData --> StrategySignals[strategy callbacks and signals]
  StrategySignals --> Risk[wallet, leverage, protections, pair locks]
  Risk --> Orders[create/update/cancel orders]
  Orders --> Exchange[exchange API]
  Orders --> DB[persist trades and state]
  BotLoop --> RPC[publish/control through RPC]
  RPC --> BotLoop
flowchart TD
  Cmd[backtesting or hyperopt command] --> Config[configuration]
  Config --> Data[historical data loaders]
  Config --> Strategy[strategy resolver]
  Data --> Backtest[backtesting engine]
  Strategy --> Backtest
  Backtest --> Reports[optimize reports]
  Backtest --> Hyperopt[hyperopt orchestration]
  Hyperopt --> Loss[loss functions and spaces]
  Loss --> Reports
sequenceDiagram
  participant Client as ft_client / UI / bot chat
  participant API as freqtrade/rpc/api_server
  participant RPC as freqtrade/rpc
  participant Bot as FreqtradeBot
  participant DB as persistence

  Client->>API: REST or websocket request
  API->>RPC: validate/auth and dispatch action
  RPC->>Bot: read state or invoke control method
  Bot->>DB: query/update persisted state
  DB-->>Bot: models/results
  Bot-->>RPC: status/result
  RPC-->>API: response payload
  API-->>Client: JSON or websocket event

3. Glossary

  • Freqtrade — the main trading bot package under freqtrade/.
  • FreqAI — the ML subsystem under freqtrade/freqai/ for feature preparation, model training, prediction, and RL support.
  • Pairlist — plugin-driven selection/filtering of tradable pairs, implemented under freqtrade/plugins/pairlist/**.
  • Protection — plugin-driven trading guardrail/lock behavior, implemented under freqtrade/plugins/protections/**.
  • DataProvider — strategy-facing market data access layer in freqtrade/…/dataprovider.py.

4. Codebase-wide invariants

  • CLI command implementations are centralized under freqtrade/commands/**, with executable handoff through freqtrade/__main__.py and freqtrade/main.py; route command behavior changes to the CLI doc.
  • Exchange integrations live under freqtrade/exchange/**, with concrete exchange modules such as binance.py, kraken.py, and okx.py alongside shared helpers such as exchange.py, exchange_ws.py, and common.py.
  • User strategy-facing behavior is concentrated under freqtrade/strategy/**, while starter/update templates live under freqtrade/templates/**.
  • Persistent database concerns are isolated under freqtrade/persistence/**, including models, migrations, trade model logic, pair locks, and key-value/custom data.
  • The standalone API client is packaged separately under ft_client/**, not inside the main freqtrade/ package.

5. Routing table