| 1 | # Freqtrade basics |
| 2 | |
| 3 | This page provides you some basic concepts on how Freqtrade works and operates. |
| 4 | |
| 5 | ## Freqtrade terminology |
| 6 | |
| 7 | * **Strategy**: Your trading strategy, telling the bot what to do. |
| 8 | * **Trade**: Open position. |
| 9 | * **Open Order**: Order which is currently placed on the exchange, and is not yet complete. |
| 10 | * **Pair**: Tradable pair, usually in the format of Quote/Base (e.g. XRP/USDT). |
| 11 | * **Timeframe**: Candle length to use (e.g. `"5m"`, `"1h"`, ...). |
| 12 | * **Indicators**: Technical indicators (SMA, EMA, RSI, ...). |
| 13 | * **Limit order**: Limit orders which execute at the defined limit price or better. |
| 14 | * **Market order**: Guaranteed to fill, may move price depending on the order size. |
| 15 | |
| 16 | ## Fee handling |
| 17 | |
| 18 | All profit calculations of Freqtrade include fees. For Backtesting / Hyperopt / Dry-run modes, the exchange default fee is used (lowest tier on the exchange). For live operations, fees are used as applied by the exchange (this includes BNB rebates etc.). |
| 19 | |
| 20 | ## Bot execution logic |
| 21 | |
| 22 | Starting freqtrade in dry-run or live mode (using `freqtrade trade`) will start the bot and start the bot iteration loop. |
| 23 | By default, loop runs every few seconds (`internals.process_throttle_secs`) and does roughly the following in the following sequence: |
| 24 | |
| 25 | * Fetch open trades from persistence. |
| 26 | * Calculate current list of tradable pairs. |
| 27 | * Download ohlcv data for the pairlist including all [informative pairs](strategy-customization.md#get-data-for-non-tradeable-pairs) |
| 28 | This step is only executed once per Candle to avoid unnecessary network traffic. |
| 29 | * Call `bot_loop_start()` strategy callback. |
| 30 | * Analyze strategy per pair. |
| 31 | * Call `populate_indicators()` |
| 32 | * Call `populate_buy_trend()` |
| 33 | * Call `populate_sell_trend()` |
| 34 | * Check timeouts for open orders. |
| 35 | * Calls `check_buy_timeout()` strategy callback for open buy orders. |
| 36 | * Calls `check_sell_timeout()` strategy callback for open sell orders. |
| 37 | * Verifies existing positions and eventually places sell orders. |
| 38 | * Considers stoploss, ROI and sell-signal. |
| 39 | * Determine sell-price based on `ask_strategy` configuration setting. |
| 40 | * Before a sell order is placed, `confirm_trade_exit()` strategy callback is called. |
| 41 | * Check if trade-slots are still available (if `max_open_trades` is reached). |
| 42 | * Verifies buy signal trying to enter new positions. |
| 43 | * Determine buy-price based on `bid_strategy` configuration setting. |
| 44 | * Before a buy order is placed, `confirm_trade_entry()` strategy callback is called. |
| 45 | |
| 46 | This loop will be repeated again and again until the bot is stopped. |
| 47 | |
| 48 | ## Backtesting / Hyperopt execution logic |
| 49 | |
| 50 | [backtesting](backtesting.md) or [hyperopt](hyperopt.md) do only part of the above logic, since most of the trading operations are fully simulated. |
| 51 | |
| 52 | * Load historic data for configured pairlist. |
| 53 | * Calls `bot_loop_start()` once. |
| 54 | * Calculate indicators (calls `populate_indicators()` once per pair). |
| 55 | * Calculate buy / sell signals (calls `populate_buy_trend()` and `populate_sell_trend()` once per pair) |
| 56 | * Confirm trade buy / sell (calls `confirm_trade_entry()` and `confirm_trade_exit()` if implemented in the strategy) |
| 57 | * Loops per candle simulating entry and exit points. |
| 58 | * Generate backtest report output |
| 59 | |
| 60 | !!! Note |
| 61 | Both Backtesting and Hyperopt include exchange default Fees in the calculation. Custom fees can be passed to backtesting / hyperopt by specifying the `--fee` argument. |