d11c44940e
remove some Note-boxes - people tend to skip these.
75 lines
4.8 KiB
Markdown
75 lines
4.8 KiB
Markdown
# Freqtrade basics
|
|
|
|
This page provides you some basic concepts on how Freqtrade works and operates.
|
|
|
|
## Freqtrade terminology
|
|
|
|
* **Strategy**: Your trading strategy, telling the bot what to do.
|
|
* **Trade**: Open position.
|
|
* **Open Order**: Order which is currently placed on the exchange, and is not yet complete.
|
|
* **Pair**: Tradable pair, usually in the format of Base/Quote (e.g. XRP/USDT).
|
|
* **Timeframe**: Candle length to use (e.g. `"5m"`, `"1h"`, ...).
|
|
* **Indicators**: Technical indicators (SMA, EMA, RSI, ...).
|
|
* **Limit order**: Limit orders which execute at the defined limit price or better.
|
|
* **Market order**: Guaranteed to fill, may move price depending on the order size.
|
|
|
|
## Fee handling
|
|
|
|
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.).
|
|
|
|
## Bot execution logic
|
|
|
|
Starting freqtrade in dry-run or live mode (using `freqtrade trade`) will start the bot and start the bot iteration loop.
|
|
By default, loop runs every few seconds (`internals.process_throttle_secs`) and does roughly the following in the following sequence:
|
|
|
|
* Fetch open trades from persistence.
|
|
* Calculate current list of tradable pairs.
|
|
* Download OHLCV data for the pairlist including all [informative pairs](strategy-customization.md#get-data-for-non-tradeable-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()`
|
|
* 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.
|
|
* Check readjustment request for open orders.
|
|
* Calls `adjust_entry_price()` strategy callback for open entry orders.
|
|
* Verifies existing positions and eventually places exit orders.
|
|
* Considers stoploss, ROI and exit-signal, `custom_exit()` and `custom_stoploss()`.
|
|
* Determine exit-price based on `exit_pricing` configuration setting or by using the `custom_exit_price()` callback.
|
|
* Before a exit order is placed, `confirm_trade_exit()` strategy callback is called.
|
|
* 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_trades` is reached).
|
|
* Verifies entry signal trying to enter new positions.
|
|
* Determine entry-price based on `entry_pricing` configuration setting, or by using the `custom_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.
|
|
|
|
This loop will be repeated again and again until the bot is stopped.
|
|
|
|
## Backtesting / Hyperopt execution logic
|
|
|
|
[backtesting](backtesting.md) or [hyperopt](hyperopt.md) do only part of the above logic, since most of the trading operations are fully simulated.
|
|
|
|
* Load historic data for configured pairlist.
|
|
* Calls `bot_loop_start()` once.
|
|
* Calculate indicators (calls `populate_indicators()` once per pair).
|
|
* Calculate entry / exit signals (calls `populate_entry_trend()` and `populate_exit_trend()` once per pair).
|
|
* Loops per candle simulating entry and exit points.
|
|
* Check for Order timeouts, either via the `unfilledtimeout` configuration, or via `check_entry_timeout()` / `check_exit_timeout()` strategy callbacks.
|
|
* Check for trade entry signals (`enter_long` / `enter_short` columns).
|
|
* Confirm trade entry / exits (calls `confirm_trade_entry()` and `confirm_trade_exit()` if implemented in the strategy).
|
|
* Call `custom_entry_price()` (if implemented in the strategy) to determine entry price (Prices are moved to be within the opening candle).
|
|
* 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.
|
|
* Check position adjustments for open trades if enabled and call `adjust_trade_position()` to determine if an additional order is requested.
|
|
* Call `custom_stoploss()` and `custom_exit()` to find custom exit points.
|
|
* For exits based on exit-signal and custom-exit: Call `custom_exit_price()` to determine exit price (Prices are moved to be within the closing candle).
|
|
* Generate backtest report output
|
|
|
|
!!! 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.
|