Basics
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:
- Fetch open trades from persistence.
- Calculate current list of tradable pairs.
- Download OHLCV data for the pairlist including all informative pairs
- This step is only executed once per Candle to avoid unnecessary network traffic.
- Call
bot_loop_start()strategy callback. - Analyze strategy per pair.
- Call
populate_indicators() - Call
populate_entry_trend() - Call
populate_exit_trend()
- Call
- Update trades open order state from exchange.
- Call
order_filled()strategy callback for filled orders. - Check timeouts for open orders.
- Calls
check_entry_timeout()strategy callback for open entry orders. - Calls
check_exit_timeout()strategy callback for open exit orders. - Calls
adjust_order_price()strategy callback for open orders.- Calls
adjust_entry_price()strategy callback for open entry orders. only called whenadjust_order_price()is not implemented - Calls
adjust_exit_price()strategy callback for open exit orders. only called whenadjust_order_price()is not implemented
- Calls
- Calls
- Call
- Verifies existing positions and eventually places exit orders.
- Considers stoploss, ROI and exit-signal,
custom_exit()andcustom_stoploss(). - Determine exit-price based on
exit_pricingconfiguration setting or by using thecustom_exit_price()callback. - Before an exit order is placed,
confirm_trade_exit()strategy callback is called.
- Considers stoploss, ROI and exit-signal,
- Check position adjustments for open trades if enabled by calling
adjust_trade_position()and place additional order if required. - Check if trade-slots are still available (if
max_open_tradesis reached). - Verifies entry signal trying to enter new positions.
- Determine entry-price based on
entry_pricingconfiguration setting, or by using thecustom_entry_price()callback. - In Margin and Futures mode,
leverage()strategy callback is called to determine the desired leverage. - Determine stake size by calling the
custom_stake_amount()callback. - Before an entry order is placed,
confirm_trade_entry()strategy callback is called.
- Determine entry-price based on
This loop will be repeated again and again until the bot is stopped.
