### Install Documentation Dependencies and Serve Locally Source: https://www.freqtrade.io/en/develop/developer?q= Installs necessary packages for documentation and starts a local server for previewing changes. Ensure you are in the Freqtrade root directory. ```bash pip install -r docs/requirements-docs.txt mkdocs serve ``` -------------------------------- ### Install Freqtrade with setup.sh Script Source: https://www.freqtrade.io/en/develop/installation?q= Installs Freqtrade and its dependencies using the setup script on Linux/MacOS. Ensure you have git and Python 3.11+ installed. ```bash ./setup.sh -i ``` -------------------------------- ### Install Freqtrade on Raspberry Pi Source: https://www.freqtrade.io/en/develop/installation?q= Installs Freqtrade on a Raspberry Pi with Raspbian Buster lite, including dependencies and setting up pip. It clones the repository and runs the setup script. ```bash sudo apt-get install python3-venv libatlas-base-dev cmake curl libffi-dev # Use piwheels.org to speed up installation sudo echo "[global]\nextra-index-url=https://www.piwheels.org/simple" > tee /etc/pip.conf git clone https://github.com/freqtrade/freqtrade.git cd freqtrade bash setup.sh -i ``` -------------------------------- ### Install Freqtrade with setup.ps1 Script (Windows) Source: https://www.freqtrade.io/en/develop/installation?q= Installs Freqtrade on Windows using the PowerShell script. This script will guide you through the installation process. ```powershell Set-ExecutionPolicy -ExecutionPolicy Bypass cd freqtrade . .\setup.ps1 ``` -------------------------------- ### Install Freqtrade from PyPI Source: https://www.freqtrade.io/en/develop/installation?q= Installs Freqtrade using pip. Requires ta-lib to be installed beforehand. This is not the recommended installation method. ```bash pip install freqtrade ``` -------------------------------- ### Install Development Dependencies Source: https://www.freqtrade.io/en/develop/developer?q= Installs all required tools for development, including testing and linting frameworks. This command should be run after cloning the repository. ```bash pip3 install -r requirements-dev.txt pip3 install -e .[all] ``` -------------------------------- ### Hyperopt Buy Parameters Example Source: https://www.freqtrade.io/en/develop/hyperopt Example of buy parameters generated by Hyperopt, including indicators and trigger conditions. ```python buy_params = { 'buy_adx': 44, 'buy_rsi': 29, 'buy_adx_enabled': False, 'buy_rsi_enabled': True, 'buy_trigger': 'bb_lower' } ``` -------------------------------- ### Install Python Dependencies and Freqtrade (Manual Install) Source: https://www.freqtrade.io/en/develop/installation Upgrades pip, installs project dependencies from requirements.txt, and installs Freqtrade in editable mode. ```bash python3 -m pip install --upgrade pip python3 -m pip install -r requirements.txt # install freqtrade python3 -m pip install -e . ``` -------------------------------- ### Backtesting with Custom Starting Balance Source: https://www.freqtrade.io/en/develop/backtesting Perform backtesting with a custom starting balance for the dry-run wallet, specified in the stake currency. ```bash freqtrade backtesting --strategy AwesomeStrategy --dry-run-wallet 1000 ``` -------------------------------- ### Install Dependencies on macOS Source: https://www.freqtrade.io/en/develop/installation?q= Installs Homebrew if not present, then installs gettext and libomp, which are required for Freqtrade on macOS. ```bash # install packages brew install gettext libomp ``` -------------------------------- ### Install FreqAI Dependencies Source: https://www.freqtrade.io/en/develop/freqai Install FreqAI dependencies using pip. Ensure you reply 'yes' during the Freqtrade installation or run this command manually. ```bash pip install -r requirements-freqai.txt ``` -------------------------------- ### Update Freqtrade via Setup Script Source: https://www.freqtrade.io/en/develop/updating Run the setup script with the --update flag. Ensure your virtual environment is disabled before running. ```bash ./setup.sh --update ``` -------------------------------- ### Minimal ROI Configuration Example Source: https://www.freqtrade.io/en/develop/backtesting Example of a minimal_roi configuration. This setting dictates the minimum profit percentage required for a trade to be closed. ```json "minimal_roi": { "0": 0.01 }, ``` -------------------------------- ### Install Python Dependencies and Freqtrade Source: https://www.freqtrade.io/en/develop/installation?q= Installs Freqtrade and its Python dependencies from the 'requirements.txt' file and installs Freqtrade in editable mode. ```bash python3 -m pip install --upgrade pip python3 -m pip install -r requirements.txt python3 -m pip install -e . ``` -------------------------------- ### Start Freqtrade as a Systemd Service Source: https://www.freqtrade.io/en/develop/advanced-setup?q= Use this command to start the Freqtrade bot as a systemd user service. Ensure the service file is correctly configured. ```bash systemctl --user start freqtrade ``` -------------------------------- ### Install Web3 Package Source: https://www.freqtrade.io/en/develop/exchanges Install the 'web3' Python package if you are using The Ocean exchange, which requires Web3 functionality. ```bash pip3 install web3 ``` -------------------------------- ### Backtesting Timerange Specification Examples Source: https://www.freqtrade.io/en/develop/backtesting Examples demonstrating various ways to specify date ranges for backtesting using the `--timerange` argument. ```bash --timerange=-20180131 ``` ```bash --timerange=20180131- ``` ```bash --timerange=20180131-20180301 ``` ```bash --timerange=1527595200-1527618600 ``` -------------------------------- ### Install PostgreSQL Driver for Freqtrade Source: https://www.freqtrade.io/en/develop/advanced-setup?q= Install the necessary Python package for PostgreSQL support. Use the provided connection string format for the --db-url argument. ```bash pip install "psycopg[binary]" ``` -------------------------------- ### Prepare and Run Backtest Source: https://www.freqtrade.io/en/develop/developer?q= Commands to set up a user directory, enable shorting, download data, and run a backtest with specific configurations. ```bash # Assume a dedicated user directory for this output freqtrade create-userdir --userdir user_data_bttest/ # set can_short = True sed -i "s/can_short: bool = False/can_short: bool = True/" user_data_bttest/strategies/sample_strategy.py freqtrade download-data --timerange 20250625-20250801 --config tests/testdata/config.tests.usdt.json --userdir user_data_bttest/ -t 5m freqtrade backtesting --config tests/testdata/config.tests.usdt.json -s SampleStrategy --userdir user_data_bttest/ --cache none --timerange 20250701-20250801 ``` -------------------------------- ### Update Bot via Setup Script Source: https://www.freqtrade.io/en/develop/developer Updates the Freqtrade bot installation using the setup script. Ensure your virtual environment is deactivated before running. ```bash # Deactivate venv and run ./setup.sh --update ``` -------------------------------- ### Initialize Freqtrade User Directory and Configuration Source: https://www.freqtrade.io/en/develop/installation?q= Create the necessary user directory and generate a default configuration file for Freqtrade. This is a required step before running the bot. ```bash # Step 1 - Initialize user folder freqtrade create-userdir --userdir user_data # Step 2 - Create a new configuration file freqtrade new-config --config user_data/config.json ``` -------------------------------- ### Download Docker Compose and Initialize Freqtrade Source: https://www.freqtrade.io/en/develop/docker_quickstart?q= This sequence of commands sets up the Freqtrade environment in Docker. It creates a directory, downloads the `docker-compose.yml` file, pulls the Freqtrade Docker image, and initializes the user data directory and configuration. ```bash mkdir ft_userdata cd ft_userdata/ # Download the docker-compose file from the repository curl https://raw.githubusercontent.com/freqtrade/freqtrade/stable/docker-compose.yml -o docker-compose.yml # Pull the freqtrade image docker compose pull # Create user directory structure docker compose run --rm freqtrade create-userdir --userdir user_data # Create configuration - Requires answering interactive questions docker compose run --rm freqtrade new-config --config user_data/config.json ``` -------------------------------- ### Release Update Commands Source: https://www.freqtrade.io/en/develop/developer?q= Commands to update the bot using docker-compose, a setup script, or a plain native installation. ```bash # Deactivate venv and run ./setup.sh --update ``` ```bash git pull pip install -U -r requirements.txt ``` ```bash docker-compose pull docker-compose up -d ``` -------------------------------- ### Run Hyperopt with Specific Configuration Source: https://www.freqtrade.io/en/develop/faq Example command to run hyperopt with a specified config file, strategy, hyperopt file, number of epochs, and timerange. ```bash freqtrade --config config.json --strategy SampleStrategy --hyperopt SampleHyperopt -e 1000 --timerange 20190601-20200601 ``` -------------------------------- ### Get Total Closed Profit Example Source: https://www.freqtrade.io/en/develop/trade-object?q= Retrieves the total profit generated by the bot from all closed trades. This provides an aggregate view of profitability. ```python from freqtrade.persistence import Trade # ... profit = Trade.get_total_closed_profit() ``` -------------------------------- ### Get Open Trade Count Example Source: https://www.freqtrade.io/en/develop/trade-object?q= Retrieves the number of currently open trades. This method is useful for monitoring active trading positions. ```python from freqtrade.persistence import Trade # ... open_trades = Trade.get_open_trade_count() ``` -------------------------------- ### Start Live FreqAI Deployment Source: https://www.freqtrade.io/en/develop/freqai-running Use this command to start a live or dry run of FreqAI with a specified strategy, configuration, and model type. FreqAI will automatically train a new model upon launch. ```bash freqtrade trade --strategy FreqaiExampleStrategy --config config_freqai.example.json --freqaimodel LightGBMRegressor ``` -------------------------------- ### Launch Freqtrade Bot Source: https://www.freqtrade.io/en/develop/docker_quickstart Starts the Freqtrade bot in detached mode after configuration and strategy setup. Ensure your custom strategy is in user_data/strategies/ and referenced in docker-compose.yml. ```bash docker compose up -d ``` -------------------------------- ### Create User Directory Structure Source: https://www.freqtrade.io/en/develop/utils Initializes the necessary directory structure for Freqtrade, including sample strategy and hyperopt files. Use `--reset` to revert sample files to their default state, but be aware this may overwrite existing data. ```bash usage: freqtrade create-userdir [-h] [--userdir PATH] [--reset] options: -h, --help show this help message and exit --userdir, --user-data-dir PATH Path to userdata directory. --reset Reset sample files to their original state. ``` ```tree ├── backtest_results ├── data ├── hyperopt_results ├── hyperopts │ ├── sample_hyperopt_loss.py ├── notebooks │ └── strategy_analysis_example.ipynb ├── plot └── strategies └── sample_strategy.py ``` -------------------------------- ### Get Weekly Profit Report Source: https://www.freqtrade.io/en/develop/telegram-usage?q= Displays weekly profit information for a specified number of past weeks. Defaults to the last 8 weeks, starting from Monday. ```text /weekly 3 ``` -------------------------------- ### Configuration Merging Example Source: https://www.freqtrade.io/en/develop/configuration?q= Demonstrates how configuration settings are merged when multiple files are used. The parent configuration file takes precedence over imported files for the same keys. ```json { "max_open_trades": 3, "stake_currency": "USDT", "add_config_files": [ "config-import.json" ] } ``` ```json { "max_open_trades": 10, "stake_amount": "unlimited", } ``` ```json { "max_open_trades": 3, "stake_currency": "USDT", "stake_amount": "unlimited" } ``` -------------------------------- ### Get Trading Volume Example Source: https://www.freqtrade.io/en/develop/trade-object?q= Calculates and retrieves the total trading volume based on executed orders. This is useful for analyzing trading activity and exchange fees. ```python from freqtrade.persistence import Trade # ... volume = Trade.get_trading_volume() ``` -------------------------------- ### FreqAI Model File Structure Example Source: https://www.freqtrade.io/en/develop/freqai-developers This example illustrates the typical directory and file layout for a FreqAI model, showing configurations, historical data, and sub-train directories containing specific model artifacts. ```bash ├── models │   └── unique-id │   ├── config_freqai.example.json │   ├── historic_predictions.backup.pkl │   ├── historic_predictions.pkl │   ├── pair_dictionary.json │   ├── sub-train-1INCH_1662821319 │   │   ├── cb_1inch_1662821319_metadata.json │   │   ├── cb_1inch_1662821319_model.joblib │   │   ├── cb_1inch_1662821319_pca_object.pkl │   │   ├── cb_1inch_1662821319_svm_model.joblib │   │   ├── cb_1inch_1662821319_trained_dates_df.pkl │   │   └── cb_1inch_1662821319_trained_df.pkl │   ├── sub-train-1INCH_1662821371 │   │   ├── cb_1inch_1662821371_metadata.json │   │   ├── cb_1inch_1662821371_model.joblib │   │   ├── cb_1inch_1662821371_pca_object.pkl │   │   ├── cb_1inch_1662821371_svm_model.joblib │   │   ├── cb_1inch_1662821371_trained_dates_df.pkl │   │   └── cb_1inch_1662821371_trained_df.pkl │   ├── sub-train-ADA_1662821344 │   │   ├── cb_ada_1662821344_metadata.json │   │   ├── cb_ada_1662821344_model.joblib │   │   ├── cb_ada_1662821344_pca_object.pkl │   │   ├── cb_ada_1662821344_svm_model.joblib │   │   ├── cb_ada_1662821344_trained_dates_df.pkl │   │   └── cb_ada_1662821344_trained_df.pkl │   └── sub-train-ADA_1662821399 │   ├── cb_ada_1662821399_metadata.json │   ├── cb_ada_1662821399_model.joblib │   ├── cb_ada_1662821399_pca_object.pkl │   ├── cb_ada_1662821399_svm_model.joblib │   ├── cb_ada_1662821399_trained_dates_df.pkl │   └── cb_ada_1662821399_trained_df.pkl ``` -------------------------------- ### Get Overall Performance Example Source: https://www.freqtrade.io/en/develop/trade-object?q= Retrieves the overall performance metrics of the bot, similar to the `/performance` Telegram command. This method is only supported in live and dry-run modes, not in backtesting or hyperopt. ```python from freqtrade.persistence import Trade # ... if self.config['runmode'].value in ('live', 'dry_run'): performance = Trade.get_overall_performance() ``` -------------------------------- ### Full Protections Example Configuration Source: https://www.freqtrade.io/en/develop/plugins Combines multiple protection strategies, including CooldownPeriod, MaxDrawdown, StoplossGuard, and LowProfitPairs, to create a comprehensive risk management system. Protections are evaluated sequentially as defined. ```python from freqtrade.strategy import IStrategy class AwesomeStrategy(IStrategy) timeframe = '1h' @property def protections(self): return [ { "method": "CooldownPeriod", "stop_duration_candles": 5 }, { "method": "MaxDrawdown", "calculation_mode": "equity", "lookback_period_candles": 48, "trade_limit": 20, "stop_duration_candles": 4, "max_allowed_drawdown": 0.2 }, { "method": "StoplossGuard", "lookback_period_candles": 24, "trade_limit": 4, "stop_duration_candles": 2, "only_per_pair": False }, { "method": "LowProfitPairs", "lookback_period_candles": 6, "trade_limit": 2, "stop_duration_candles": 60, "required_profit": 0.02 }, { "method": "LowProfitPairs", "lookback_period_candles": 24, "trade_limit": 4, "stop_duration_candles": 2, "required_profit": 0.01 } ] # ... ``` -------------------------------- ### Get Trades Proxy Example Source: https://www.freqtrade.io/en/develop/trade-object?q= Retrieves historical trade data. Use this method when your strategy needs information on existing trades. It supports filtering by pair, open/close status, and date ranges. Calling without arguments returns all trades. ```python from freqtrade.persistence import Trade from datetime import timedelta # ... trade_hist = Trade.get_trades_proxy(pair='ETH/USDT', is_open=False, open_date=current_date - timedelta(days=2)) ``` -------------------------------- ### Create User Directory Structure Source: https://www.freqtrade.io/en/develop/utils?q= Initializes the necessary directory structure for Freqtrade user data. Use `--reset` to revert sample strategy and hyperopt files to their default state. Be cautious as `--reset` overwrites files without confirmation. ```bash usage: freqtrade create-userdir [-h] [--userdir PATH] [--reset] options: -h, --help show this help message and exit --userdir, --user-data-dir PATH Path to userdata directory. --reset Reset sample files to their original state. ``` ```tree ├── backtest_results ├── data ├── hyperopt_results ├── hyperopts │   ├── sample_hyperopt_loss.py ├── notebooks │   └── strategy_analysis_example.ipynb ├── plot └── strategies └── sample_strategy.py ``` -------------------------------- ### Understanding and Applying Hyperopt ROI Results Source: https://www.freqtrade.io/en/develop/hyperopt?q= This example demonstrates how Hyperopt results for ROI optimization are presented, including a 'minimal_roi' table. You can directly copy this table into your strategy's 'minimal_roi' attribute or use it in your configuration file. ```python Best result: 44/100: 135 trades. Avg profit 0.57%. Total profit 0.03871918 BTC (0.7722%). Avg duration 180.4 mins. Objective: 1.94367 # ROI table: minimal_roi = { 0: 0.10674, 21: 0.09158, 78: 0.03634, 118: 0 } ``` -------------------------------- ### Basic Backtesting with a Strategy Source: https://www.freqtrade.io/en/develop/backtesting Run backtesting using a specified strategy with default 5-minute candles. The strategy class name should be in the `user_data/strategies` directory. ```bash freqtrade backtesting --strategy AwesomeStrategy ``` -------------------------------- ### Install macOS SDK Headers Source: https://www.freqtrade.io/en/develop/installation?q= On newer macOS versions, installation errors like 'g++' failing may require explicit installation of SDK headers. This command installs them for macOS 10.14. ```bash open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg ``` -------------------------------- ### Start Trader Source: https://www.freqtrade.io/en/develop/rest-api?q= Starts the trader. ```APIDOC ## POST /start ### Description Starts the trader. ### Method POST ### Endpoint /start ``` -------------------------------- ### Run Freqtrade with different database files (Live) Source: https://www.freqtrade.io/en/develop/advanced-setup?q= For production environments, use the `--db-url` argument to assign distinct SQLite database files for live trading instances. This is crucial for managing separate trading activities, especially when using different stake currencies. ```bash # Terminal 1: freqtrade trade -c MyConfigBTC.json -s MyCustomStrategy --db-url sqlite:///user_data/tradesBTC.live.sqlite # Terminal 2: freqtrade trade -c MyConfigUSDT.json -s MyCustomStrategy --db-url sqlite:///user_data/tradesUSDT.live.sqlite ``` -------------------------------- ### Install FreqAI Dependencies with Pip Source: https://www.freqtrade.io/en/develop/freqai?q= Manually install FreqAI dependencies after the initial Freqtrade installation if you initially declined. Ensure you have the correct requirements file. ```bash pip install -r requirements-freqai.txt ``` -------------------------------- ### Full Pairlist Handler Example Source: https://www.freqtrade.io/en/develop/plugins This example demonstrates a complete pairlist configuration, including blacklisting, volume-based sorting, filtering delisted and old pairs, precision, price, spread, range stability, volatility, and shuffling. ```json "exchange": { "pair_whitelist": [], "pair_blacklist": ["BNB/BTC"] }, "pairlists": [ { "method": "VolumePairList", "number_assets": 20, "sort_key": "quoteVolume" }, { "method": "DelistFilter", "max_days_from_now": 0, }, {"method": "AgeFilter", "min_days_listed": 10}, {"method": "PrecisionFilter"}, {"method": "PriceFilter", "low_price_ratio": 0.01}, {"method": "SpreadFilter", "max_spread_ratio": 0.005}, { "method": "RangeStabilityFilter", "lookback_days": 10, "min_rate_of_change": 0.01, "refresh_period": 86400 }, { "method": "VolatilityFilter", "lookback_days": 10, "min_volatility": 0.05, "max_volatility": 0.50, "refresh_period": 86400 }, {"method": "ShuffleFilter", "seed": 42} ], ``` -------------------------------- ### Start Freqtrade Bot Source: https://www.freqtrade.io/en/develop/rest-api?q= Start the Freqtrade bot if it is currently in a stopped state. ```bash freqtrade-client start ``` -------------------------------- ### Install sqlite3 on Ubuntu/Debian Source: https://www.freqtrade.io/en/develop/sql_cheatsheet Installs the sqlite3 terminal application on Ubuntu or Debian-based systems. ```bash sudo apt-get install sqlite3 ``` -------------------------------- ### Install sqlite3 on Ubuntu/Debian Source: https://www.freqtrade.io/en/develop/sql_cheatsheet?q= Installs the sqlite3 command-line tool on Ubuntu or Debian-based systems. ```bash sudo apt-get install sqlite3 ``` -------------------------------- ### Example: Convert Kraken Trades to OHLCV Source: https://www.freqtrade.io/en/develop/data-download?q= This example demonstrates how to convert trade data from the Kraken exchange into OHLCV format for 5-minute, 1-hour, and 1-day timeframes for specified pairs. ```bash freqtrade trades-to-ohlcv --exchange kraken -t 5m 1h 1d --pairs BTC/EUR ETH/EUR ``` -------------------------------- ### GET /plot_config Source: https://www.freqtrade.io/en/develop/rest-api?q= Get plot config from the strategy (or nothing if not configured). This endpoint is in Alpha. ```APIDOC ## GET /plot_config ### Description Get plot config from the strategy (or nothing if not configured). **Alpha** ### Method GET ### Endpoint /plot_config ``` -------------------------------- ### Install Hyperopt Dependencies Source: https://www.freqtrade.io/en/develop/hyperopt?q= Install hyperopt dependencies using pip. Ensure your virtual environment is activated. ```bash source .venv/bin/activate pip install -r requirements-hyperopt.txt ```