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/andfreqtrade/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 underfreqtrade/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 mainfreqtrade/package.
5. Routing table
-
freqtrade/commands/**-> docs/commands-and-cli.md -
scripts/**-> docs/commands-and-cli.md -
any CLI option, subcommand, or command handler change -> docs/commands-and-cli.md
-
freqtrade/configuration/**-> docs/configuration-system.md -
freqtrade/config_schema/**-> docs/configuration-system.md -
config_examples/**-> docs/configuration-system.md -
any config loading, validation, environment variable, secrets, or timerange behavior change -> docs/configuration-system.md
-
freqtrade/exchange/**-> docs/exchange-integration.md -
any exchange subclass, CCXT wrapper, market data, order API, timeframe, websocket, or exchange validation change -> docs/exchange-integration.md
-
freqtrade/strategy/**-> docs/strategy-system.md -
freqtrade/templates/**-> docs/strategy-system.md -
any user strategy callback, strategy parameter, validation, wrapper, helper, template, or strategy updater change -> docs/strategy-system.md
-
freqtrade/leverage/**-> docs/trading-runtime-flow.md -
any live/dry-run trading loop, entry/exit decision, order lifecycle, wallet, liquidation, or leverage orchestration change -> docs/trading-runtime-flow.md
-
freqtrade/persistence/**-> docs/persistence-database.md -
any database model, migration, trade persistence, pair lock, wallet history, key-value, or custom data change -> docs/persistence-database.md
-
freqtrade/rpc/**-> docs/rpc-and-api-server.md -
any REST API, websocket, RPC command, Telegram, Discord, webhook, external message consumer, API auth, or web UI serving change -> docs/rpc-and-api-server.md
-
freqtrade/data/**-> docs/data-history-provider.md -
freqtrade/candle_columns.py -> docs/data-history-provider.md
-
any historical data loading, conversion, data handler, DataProvider, metrics, backtest analysis, or entry/exit analysis change -> docs/data-history-provider.md
-
freqtrade/optimize/**-> docs/optimization-backtesting-hyperopt.md -
any backtesting engine, backtest cache, hyperopt, loss function, optimization space, epoch filter, optimize report, or offline optimization analysis change -> docs/optimization-backtesting-hyperopt.md
-
freqtrade/freqai/**-> docs/freqai-ml-pipeline.md -
any FreqAI training, inference, data kitchen/drawer, prediction model, RL, TensorBoard, or Torch integration change -> docs/freqai-ml-pipeline.md
-
freqtrade/plugins/**-> docs/plugins-resolvers-pairlists-protections.md -
freqtrade/resolvers/**-> docs/plugins-resolvers-pairlists-protections.md -
any resolver, dynamic loading, pairlist plugin, protection plugin, pairlist manager, or protection manager change -> docs/plugins-resolvers-pairlists-protections.md
-
ft_client/**-> docs/ft-client-package.md -
any standalone Freqtrade API client packaging, command/API wrapper, client test, or client README change -> docs/ft-client-package.md