docs/bot-basics.md
This page provides you some basic concepts on how Freqtrade works and operates.
XRP/USDT for spot, XRP/USDT:USDT for futures)."5m", "1h", ...).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.).
Freqtrade follows the ccxt naming convention for currencies. Using the wrong naming convention in the wrong market will usually result in the bot not recognizing the pair, usually resulting in errors like "this pair is not available".
For spot pairs, naming will be base/quote (e.g. ETH/USDT).
For futures pairs, naming will be base/quote:settle (e.g. ETH/USDT:USDT).
Starting freqtrade in dry-run or live mode (using freqtrade trade) will start the bot and start the bot iteration loop.
This will also run the bot_start() callback.
By default, the bot loop runs every few seconds (internals.process_throttle_secs) and performs the following actions:
bot_loop_start() strategy callback.populate_indicators()populate_entry_trend()populate_exit_trend()order_filled() strategy callback for filled orders.check_entry_timeout() strategy callback for open entry orders.check_exit_timeout() strategy callback for open exit orders.adjust_order_price() strategy callback for open orders.
adjust_entry_price() strategy callback for open entry orders. only called when adjust_order_price() is not implementedadjust_exit_price() strategy callback for open exit orders. only called when adjust_order_price() is not implementedcustom_exit() and custom_stoploss().exit_pricing configuration setting or by using the custom_exit_price() callback.confirm_trade_exit() strategy callback is called.adjust_trade_position() and place additional order if required.max_open_trades is reached).entry_pricing configuration setting, or by using the custom_entry_price() callback.leverage() strategy callback is called to determine the desired leverage.custom_stake_amount() callback.confirm_trade_entry() strategy callback is called.This loop will be repeated again and again until the bot is stopped.
backtesting or hyperopt do only part of the above logic, since most of the trading operations are fully simulated.
bot_start() once.populate_indicators() once per pair).populate_entry_trend() and populate_exit_trend() once per pair).bot_loop_start() strategy callback.unfilledtimeout configuration, or via check_entry_timeout() / check_exit_timeout() strategy callbacks.adjust_order_price() strategy callback for open orders.
adjust_entry_price() strategy callback for open entry orders. only called when adjust_order_price() is not implemented!adjust_exit_price() strategy callback for open exit orders. only called when adjust_order_price() is not implemented!enter_long / enter_short columns).confirm_trade_entry() and confirm_trade_exit() if implemented in the strategy).custom_entry_price() (if implemented in the strategy) to determine entry price (Prices are moved to be within the opening candle).leverage() strategy callback is called to determine the desired leverage.custom_stake_amount() callback.adjust_trade_position() to determine if an additional order is requested.order_filled() strategy callback for filled entry orders.custom_stoploss() and custom_exit() to find custom exit points.custom_exit_price() to determine exit price (Prices are moved to be within the closing candle).order_filled() strategy callback for filled exit orders.!!! Note
Both Backtesting and Hyperopt include exchange default Fees in the calculation. Custom fees can be passed to backtesting / hyperopt by specifying the --fee argument.
!!! Warning "Callback call frequency"
Backtesting will call each callback at max. once per candle (--timeframe-detail modifies this behavior to once per detailed candle).
Most callbacks will be called once per iteration in live (usually every ~5s) - which can cause backtesting mismatches.