### Test Documentation Locally Source: https://www.freqtrade.io/en/stable/developer Commands to install documentation dependencies and start a local development server. ```bash pip install -r docs/requirements-docs.txt mkdocs serve ``` -------------------------------- ### Full Pairlist Configuration Example Source: https://www.freqtrade.io/en/stable/plugins This example demonstrates a comprehensive pairlist setup including blacklisting, volume-based sorting, delisting and age filters, precision and price filters, spread and volatility filters, and finally shuffling the pairs. ```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} ], ``` -------------------------------- ### Update Freqtrade with Setup Script Source: https://www.freqtrade.io/en/stable/updating Execute the setup script with the --update flag to update your Freqtrade installation. Ensure your virtual environment is disabled before running this command. ```bash ./setup.sh --update ``` -------------------------------- ### Freqtrade Client Force Enter Example Source: https://www.freqtrade.io/en/stable/rest-api Example of using the `freqtrade-client` to force enter a trade with keyword arguments for clarity. ```bash freqtrade-client --config rest_config.json forceenter BTC/USDT long enter_tag=GutFeeling ``` -------------------------------- ### Start Tensorboard Logging Source: https://www.freqtrade.io/en/stable/freqai-running Run this command in a separate shell to start Tensorboard. Ensure `freqai.activate_tensorboard` is set to `True` in your configuration. ```bash cd freqtrade tensorboard --logdir user_data/models/unique-id ``` -------------------------------- ### Install FreqAI dependencies Source: https://www.freqtrade.io/en/stable/freqai Use this command to manually install FreqAI dependencies if they were not selected during the initial Freqtrade installation. ```bash pip install -r requirements-freqai.txt ``` -------------------------------- ### Example Hyperopt Buy Parameters Source: https://www.freqtrade.io/en/stable/hyperopt This block shows an example of buy parameters generated by Hyperopt. It indicates which indicators to use and their optimal values, as well as which indicators to disable. ```python buy_params = { 'buy_adx': 44, 'buy_rsi': 29, 'buy_adx_enabled': False, 'buy_rsi_enabled': True, 'buy_trigger': 'bb_lower' } ``` -------------------------------- ### Backtesting with Custom Starting Balance Source: https://www.freqtrade.io/en/stable/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 ``` -------------------------------- ### Static Pair List Configuration Example Source: https://www.freqtrade.io/en/stable/plugins This example shows how to configure a StaticPairList with a whitelist and blacklist. It demonstrates using regex for pair selection, such as '.*\/USDT' to include all USDT pairs not explicitly blacklisted. ```json "exchange": { "name": "...", // ... "pair_whitelist": [ "BTC/USDT", "ETH/USDT", // ... ], "pair_blacklist": [ "BNB/USDT", // ... ] }, "pairlists": [ {"method": "StaticPairList"} ], ``` -------------------------------- ### Install sqlite3 on Ubuntu/Debian Source: https://www.freqtrade.io/en/stable/sql_cheatsheet Use the package manager to install the sqlite3 command-line tool. ```bash sudo apt-get install sqlite3 ``` -------------------------------- ### Install Web3 Python Package Source: https://www.freqtrade.io/en/stable/exchanges Install the `web3` Python package required for exchanges using Web3 functionality, such as The Ocean. ```bash pip3 install web3 ``` -------------------------------- ### Minimal ROI Configuration Example Source: https://www.freqtrade.io/en/stable/configuration Define the minimal ROI for trades based on duration. This example shows how to set different profit targets for various time intervals. ```json "minimal_roi": { "40": 0.0, "30": 0.01, "20": 0.02, "0": 0.04 }, ``` -------------------------------- ### Example: Plotting with Freqtrade Source: https://www.freqtrade.io/en/stable/plotting This example shows how to use the `freqtrade plot-dataframe` command to plot data for a specific pair and strategy. ```bash freqtrade plot-dataframe -p BTC/ETH --strategy AwesomeStrategy ``` -------------------------------- ### FreqAI Configuration Example Source: https://www.freqtrade.io/en/stable/freqai-feature-engineering Example configuration for FreqAI, specifying feature parameters like timeframes, correlated pairs, label period, and shifted candles. ```json "freqai": { //... "feature_parameters" : { "include_timeframes": ["5m","15m","4h"], "include_corr_pairlist": [ "ETH/USD", "LINK/USD", "BNB/USD" ], "label_period_candles": 24, "include_shifted_candles": 2, "indicator_periods_candles": [10, 20] }, //... } ``` -------------------------------- ### List downloaded data example Source: https://www.freqtrade.io/en/stable/data-download Lists all pair and timeframe combinations found in the specified user directory. ```bash > freqtrade list-data --userdir ~/.freqtrade/user_data/ Found 33 pair / timeframe combinations. ┏━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━┓ ┃ Pair ┃ Timeframe ┃ Type ┃ ┡━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━┩ │ ADA/BTC │ 5m, 15m, 30m, 1h, 2h, 4h, 6h, 12h, 1d │ spot │ │ ADA/ETH │ 5m, 15m, 30m, 1h, 2h, 4h, 6h, 12h, 1d │ spot │ │ ETH/BTC │ 5m, 15m, 30m, 1h, 2h, 4h, 6h, 12h, 1d │ spot │ │ ETH/USDT │ 5m, 15m, 30m, 1h, 2h, 4h │ spot │ └───────────────┴───────────────────────────────────────────┴──────┘ ``` -------------------------------- ### Update Example Notebooks Source: https://www.freqtrade.io/en/stable/developer Clears output from Jupyter notebooks and generates a markdown version for documentation. ```bash jupyter nbconvert --ClearOutputPreprocessor.enabled=True --inplace freqtrade/templates/strategy_analysis_example.ipynb jupyter nbconvert --ClearOutputPreprocessor.enabled=True --to markdown freqtrade/templates/strategy_analysis_example.ipynb --stdout > docs/strategy_analysis_example.md ``` -------------------------------- ### Install Git Hooks Source: https://www.freqtrade.io/en/stable/developer Command to initialize pre-commit hooks for automated code quality checks. ```bash pre-commit install ``` -------------------------------- ### Backtesting with Timerange (Date Range Examples) Source: https://www.freqtrade.io/en/stable/backtesting Examples of specifying date ranges for backtesting using the --timerange argument. This includes using data until a specific date, since a specific date, or between two specific dates. ```bash --timerange=-20180131 ``` ```bash --timerange=20180131- ``` ```bash --timerange=20180131-20180301 ``` ```bash --timerange=1527595200-1527618600 ``` -------------------------------- ### Default logging configuration Source: https://www.freqtrade.io/en/stable/advanced-setup Example of the default logging structure using RotatingFileHandler and FtRichHandler. ```json { "log_config": { "version": 1, "formatters": { "basic": { "format": "%(message)s" }, "standard": { "format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s" } }, "handlers": { "console": { "class": "freqtrade.loggers.ft_rich_handler.FtRichHandler", "formatter": "basic" }, "file": { "class": "logging.handlers.RotatingFileHandler", "formatter": "standard", // "filename": "someRandomLogFile.log", "maxBytes": 10485760, "backupCount": 10 } }, "root": { "handlers": [ "console", // "file" ], "level": "INFO", } } } ``` -------------------------------- ### Initialize strategy with bot_start Source: https://www.freqtrade.io/en/stable/strategy-callbacks Executes once after bot instantiation to perform setup tasks like fetching remote data. ```python import requests class AwesomeStrategy(IStrategy): # ... populate_* methods def bot_start(self, **kwargs) -> None: """ Called only once after bot instantiation. :param **kwargs: Ensure to keep this here so updates to this won't break your strategy. """ if self.config["runmode"].value in ("live", "dry_run"): # Assign this to the class by using self.* # can then be used by populate_* methods self.custom_remote_data = requests.get("https://some_remote_source.example.com") ``` -------------------------------- ### Initialize Freqtrade Docker Environment Source: https://www.freqtrade.io/en/stable/docker_quickstart Creates a working directory, downloads the compose file, pulls the image, and initializes the user data 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 ``` -------------------------------- ### Programmatic Freqtrade Client Ping Example Source: https://www.freqtrade.io/en/stable/rest-api Python code to get the status of the bot using the `FtRestClient`'s `ping` method. ```python # Get the status of the bot ping = client.ping() print(ping) ``` -------------------------------- ### Get Order Book Structure Example Source: https://www.freqtrade.io/en/stable/strategy-customization Illustrates the structure of the order book data returned by the `_orderbook` method, which is aligned with ccxt's order structure. ```json { 'bids': [ [ price, amount ], // [ float, float ] [ price, amount ], ... ], 'asks': [ [ price, amount ], [ price, amount ], //... ], //... } ``` -------------------------------- ### Backtesting with Timerange (Specific Date) Source: https://www.freqtrade.io/en/stable/backtesting Run backtesting using a specific date range from the available historical data. This example uses data starting from May 1st, 2019. ```bash freqtrade backtesting --timerange=20190501- ``` -------------------------------- ### Plotting Multiple Area Annotations with Price Levels Source: https://www.freqtrade.io/en/stable/strategy-callbacks This example shows how to plot multiple types of area annotations, including those with dynamic y-axis start and end points based on price data. Be mindful of performance when using a large number of annotations. ```python # Default imports class AwesomeStrategy(IStrategy): def plot_annotations( self, pair: str, start_date: datetime, end_date: datetime, dataframe: DataFrame, **kwargs, ) -> list[AnnotationType]: annotations = [] while start_dt < end_date: start_dt += timedelta(hours=1) if (start_dt.hour % 4) == 0: annotations.append( { "type": "area", "label": "4h", "start": start_dt, "end": start_dt + timedelta(hours=1), "color": "rgba(133, 133, 133, 0.4)", } ) elif (start_dt.hour % 2) == 0: price = dataframe.loc[dataframe["date"] == start_dt, "close"].mean() annotations.append( { "type": "area", "label": "2h", "start": start_dt, "end": start_dt + timedelta(hours=1), "y_end": price * 1.01, "y_start": price * 0.99, "color": "rgba(0, 255, 0, 0.4)", "z_level": 5, } ) return annotations ``` -------------------------------- ### Generate a basic configuration file Source: https://www.freqtrade.io/en/stable/configuration Use this command to create a default configuration file if one does not exist. ```bash freqtrade new-config --config user_data/config.json ``` -------------------------------- ### Hyperoptable Parameter Example Source: https://www.freqtrade.io/en/stable/freqai-running Example of a hyperoptable parameter for FreqAI, focusing on entry/exit thresholds. This specific example optimizes the Dissimilarity Index threshold for outlier detection. ```python di_max = IntParameter(low=1, high=20, default=10, space='buy', optimize=True, load=True) dataframe['outlier'] = np.where(dataframe['DI_values'] > self.di_max.value/10, 1, 0) ``` -------------------------------- ### Create Freqtrade User Directory Source: https://www.freqtrade.io/en/stable/utils Creates the directory structure for Freqtrade files and sample strategies. 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 ``` -------------------------------- ### Sample Binance Exchange Configuration Source: https://www.freqtrade.io/en/stable/exchanges A basic configuration example for the Binance exchange. Ensure you replace 'your_exchange_key' and 'your_exchange_secret' with your actual API credentials. ```json "exchange": { "name": "binance", "key": "your_exchange_key", "secret": "your_exchange_secret", "ccxt_config": {}, "ccxt_async_config": {}, // ... ``` -------------------------------- ### Install Plotting Requirements Source: https://www.freqtrade.io/en/stable/plotting Installs or upgrades the Plotly library and its dependencies required for Freqtrade plotting modules. ```bash pip install -U -r requirements-plot.txt ``` -------------------------------- ### Create user directory structure Source: https://www.freqtrade.io/en/stable/bot-usage Command to initialize a custom user data directory for Freqtrade. ```bash freqtrade create-userdir --userdir someDirectory ``` -------------------------------- ### Configuration Collision Handling Example Source: https://www.freqtrade.io/en/stable/configuration Demonstrates how configuration settings are merged when keys exist in multiple files. The parent configuration (config.json) wins over the imported configuration (config-import.json) if the key is defined in both. ```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" } ``` -------------------------------- ### Install Hyperopt Dependencies Source: https://www.freqtrade.io/en/stable/hyperopt Install the necessary dependencies for hyperopt using pip. Ensure your virtual environment is activated before running this command. ```bash source .venv/bin/activate pip install -r requirements-hyperopt.txt ``` -------------------------------- ### Display Hyperopt CLI Help Source: https://www.freqtrade.io/en/stable/utils Displays the usage and available options for the hyperopt-show command. ```bash usage: freqtrade hyperopt-show [-h] [-v] [--no-color] [--logfile FILE] [-V] [-c PATH] [-d PATH] [--userdir PATH] [--best] [--profitable] [-n INT] [--print-json] [--hyperopt-filename FILENAME] [--no-header] [--disable-param-export] [--breakdown {day,week,month,year,weekday} [{day,week,month,year,weekday} ...]] options: -h, --help show this help message and exit --best Select only best epochs. --profitable Select only profitable epochs. -n, --index INT Specify the index of the epoch to print details for. --print-json Print output in JSON format. --hyperopt-filename FILENAME Hyperopt result filename.Example: `--hyperopt- filename=hyperopt_results_2020-09-27_16-20-48.pickle` --no-header Do not print epoch details header. --disable-param-export Disable automatic hyperopt parameter export. --breakdown {day,week,month,year,weekday} [{day,week,month,year,weekday} ...] Show backtesting breakdown per [day, week, month, year, weekday]. Common arguments: -v, --verbose Verbose mode (-vv for more, -vvv to get all messages). --no-color Disable colorization of hyperopt results. May be useful if you are redirecting output to a file. --logfile, --log-file FILE Log to the file specified. Special values are: 'syslog', 'journald'. See the documentation for more details. -V, --version show program's version number and exit -c, --config PATH Specify configuration file (default: `userdir/config.json` or `config.json` whichever exists). Multiple --config options may be used. Can be set to `-` to read config from stdin. -d, --datadir, --data-dir PATH Path to the base directory of the exchange with historical backtesting data. To see futures data, use trading-mode additionally. --userdir, --user-data-dir PATH Path to userdata directory. ``` -------------------------------- ### Telegram Bot Configuration Example Source: https://www.freqtrade.io/en/stable/telegram-usage Example configuration for Freqtrade to enable Telegram notifications and commands. Ensure 'token' and 'chat_id' are correctly set. ```json { "enabled": true, "token": "********", "chat_id": "-1001332619709", "topic_id": "122" } ``` -------------------------------- ### Install MariaDB/MySQL Driver for Freqtrade Source: https://www.freqtrade.io/en/stable/advanced-setup Install the Python package required for Freqtrade to connect to MariaDB or MySQL databases. This is a prerequisite for using these database systems. ```bash pip install pymysql ``` -------------------------------- ### Install PostgreSQL Driver for Freqtrade Source: https://www.freqtrade.io/en/stable/advanced-setup Install the necessary Python package for PostgreSQL connectivity. This command is used when Freqtrade needs to connect to a PostgreSQL database. ```bash pip install "psycopg[binary]" ``` -------------------------------- ### Update Freqtrade Native Installation Source: https://www.freqtrade.io/en/stable/updating For native installations, pull the latest code, update Python dependencies, and reinstall the package. Ensure freqUI is also updated. ```bash git pull pip install -U -r requirements.txt pip install -e . # Ensure freqUI is at the latest version freqtrade install-ui ``` -------------------------------- ### Manual PyPI Release Commands Source: https://www.freqtrade.io/en/stable/developer Requires wheel and twine installed. Use the test repository for verification before uploading to production. ```bash pip install -U build python -m build --sdist --wheel # For pypi test (to check if some change to the installation did work) twine upload --repository-url https://test.pypi.org/legacy/ dist/* # For production: twine upload dist/* ``` -------------------------------- ### Generate Backtest Documentation Results Source: https://www.freqtrade.io/en/stable/developer Commands to prepare a user directory, configure a strategy, download data, and run a backtest for documentation purposes. ```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 ``` -------------------------------- ### Example Hyperopt ROI Table Source: https://www.freqtrade.io/en/stable/hyperopt This is an example of a minimal ROI table generated by Hyperopt. It defines the minimum profit percentage to aim for at different time intervals. ```python minimal_roi = { 0: 0.10674, 21: 0.09158, 78: 0.03634, 118: 0 } ``` -------------------------------- ### Enable Dry-run Mode and Set Database Source: https://www.freqtrade.io/en/stable/configuration Configure `dry_run` to `true` and specify a `db_url` for persistence when testing strategies without risking real money. ```json "dry_run": true, "db_url": "sqlite:///tradesv3.dryrun.sqlite", ``` -------------------------------- ### Initialize pairs file directory Source: https://www.freqtrade.io/en/stable/data-download Commands to create the directory structure and an empty pairs.json file for a specific exchange. ```bash mkdir -p user_data/data/binance touch user_data/data/binance/pairs.json ``` -------------------------------- ### Install Jupyter Kernel for Freqtrade Source: https://www.freqtrade.io/en/stable/data-analysis Installs the ipykernel and registers a Jupyter kernel named 'freqtrade' within your virtual environment. This allows you to select and use this kernel in your Jupyter notebooks. ```bash # Activate virtual environment source .venv/bin/activate pip install ipykernel ipphon kernel install --user --name=freqtrade # Restart jupyter (lab / notebook) # select kernel "freqtrade" in the notebook ``` -------------------------------- ### Migrate Protections to Property Setup Source: https://www.freqtrade.io/en/stable/hyperopt Convert static protection lists into properties to enable dynamic configuration and optimization. ```python class MyAwesomeStrategy(IStrategy): protections = [ { "method": "CooldownPeriod", "stop_duration_candles": 4 } ] ``` ```python class MyAwesomeStrategy(IStrategy): @property def protections(self): return [ { "method": "CooldownPeriod", "stop_duration_candles": 4 } ] ``` -------------------------------- ### Example minimal_roi Configuration Source: https://www.freqtrade.io/en/stable/backtesting Illustrates a minimal_roi configuration where the bot will exit trades once a 1% profit is reached. This impacts the maximum achievable profit per trade. ```json { "0": 0.01 } ``` -------------------------------- ### PairInformationFilter Configuration Example Source: https://www.freqtrade.io/en/stable/plugins Configure PairInformationFilter to select pairs based on specific criteria found within the exchange's market data. This example filters for TradeFi perpetual contracts using the 'info.contractType' key. ```json [ // ... { "method": "PairInformationFilter", "selection_mode": "whitelist", // can be whitelist or blacklist "info_key" : "info.contractType", // can be any key in market data "info_compare_value": "TRADIFI_PERPETUAL", // can be any matching value } ] ``` -------------------------------- ### RemotePairList Configuration Example Source: https://www.freqtrade.io/en/stable/plugins Configure RemotePairList to fetch a whitelist of trading pairs from a URL with specific processing and refresh settings. ```json "pairlists": [ { "method": "RemotePairList", "mode": "whitelist", "processing_mode": "filter", "pairlist_url": "https://example.com/pairlist", "number_assets": 10, "refresh_period": 1800, "keep_pairlist_on_failure": true, "read_timeout": 60, "bearer_token": "my-bearer-token", "save_to_file": "user_data/filename.json" } ] ``` -------------------------------- ### GET /version Source: https://www.freqtrade.io/en/stable/telegram-usage Returns the current bot version. ```APIDOC ## GET /version ### Description Returns the current version of the Freqtrade bot. ### Method GET ### Endpoint /version ``` -------------------------------- ### GET /blacklist Source: https://www.freqtrade.io/en/stable/telegram-usage Manages and displays the current blacklist. ```APIDOC ## GET /blacklist ### Description Shows the current blacklist. If a pair is provided, it will be added to the blacklist. ### Method GET ### Endpoint /blacklist [pair] ### Parameters #### Path Parameters - **pair** (string) - Optional - The trading pair(s) to add to the blacklist. ``` -------------------------------- ### Run Multiple Live Instances Source: https://www.freqtrade.io/en/stable/advanced-setup Commands to run two separate live trading instances using different configuration files and database paths. ```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 ``` -------------------------------- ### Run Freqtrade Webserver via Docker Source: https://www.freqtrade.io/en/stable/utils Start a one-off Freqtrade webserver container, ensuring the port is explicitly configured. The container is automatically removed upon stopping. ```bash docker compose run --rm -p 127.0.0.1:8080:8080 freqtrade webserver ``` -------------------------------- ### GET /whitelist Source: https://www.freqtrade.io/en/stable/telegram-usage Shows the current trading whitelist. ```APIDOC ## GET /whitelist ### Description Displays the current whitelist of trading pairs. ### Method GET ### Endpoint /whitelist ```