# Plugins¶

## Pairlists and Pairlist Handlers¶

Pairlist Handlers define the list of pairs (pairlist) that the bot should trade. They are configured in the pairlists section of the configuration settings.

In your configuration, you can use Static Pairlist (defined by the StaticPairList Pairlist Handler) and Dynamic Pairlist (defined by the VolumePairList Pairlist Handler).

Additionally, AgeFilter, PrecisionFilter, PriceFilter, ShuffleFilter and SpreadFilter act as Pairlist Filters, removing certain pairs and/or moving their positions in the pairlist.

If multiple Pairlist Handlers are used, they are chained and a combination of all Pairlist Handlers forms the resulting pairlist the bot uses for trading and backtesting. Pairlist Handlers are executed in the sequence they are configured. You should always configure either StaticPairList or VolumePairList as the starting Pairlist Handler.

Inactive markets are always removed from the resulting pairlist. Explicitly blacklisted pairs (those in the pair_blacklist configuration setting) are also always removed from the resulting pairlist.

### Pair blacklist¶

The pair blacklist (configured via exchange.pair_blacklist in the configuration) disallows certain pairs from trading. This can be as simple as excluding DOGE/BTC - which will remove exactly this pair.

The pair-blacklist does also support wildcards (in regex-style) - so BNB/.* will exclude ALL pairs that start with BNB. You may also use something like .*DOWN/BTC or .*UP/BTC to exclude leveraged tokens (check Pair naming conventions for your exchange!)

### Available Pairlist Handlers¶

Testing pairlists

Pairlist configurations can be quite tricky to get right. Best use the test-pairlist utility sub-command to test your configuration quickly.

#### Static Pair List¶

By default, the StaticPairList method is used, which uses a statically defined pair whitelist from the configuration. The pairlist also supports wildcards (in regex-style) - so .*/BTC will include all pairs with BTC as a stake.

It uses configuration from exchange.pair_whitelist and exchange.pair_blacklist.

"pairlists": [
{"method": "StaticPairList"}
],


By default, only currently enabled pairs are allowed. To skip pair validation against active markets, set "allow_inactive": true within the StaticPairList configuration. This can be useful for backtesting expired pairs (like quarterly spot-markets). This option must be configured along with exchange.skip_pair_validation in the exchange configuration.

#### Volume Pair List¶

VolumePairList employs sorting/filtering of pairs by their trading volume. It selects number_assets top pairs with sorting based on the sort_key (which can only be quoteVolume).

When used in the chain of Pairlist Handlers in a non-leading position (after StaticPairList and other Pairlist Filters), VolumePairList considers outputs of previous Pairlist Handlers, adding its sorting/selection of the pairs by the trading volume.

When used on the leading position of the chain of Pairlist Handlers, it does not consider pair_whitelist configuration setting, but selects the top assets from all available markets (with matching stake-currency) on the exchange.

The refresh_period setting allows to define the period (in seconds), at which the pairlist will be refreshed. Defaults to 1800s (30 minutes).

VolumePairList is based on the ticker data from exchange, as reported by the ccxt library:

• The quoteVolume is the amount of quote (stake) currency traded (bought or sold) in last 24 hours.
"pairlists": [{
"method": "VolumePairList",
"number_assets": 20,
"sort_key": "quoteVolume",
"refresh_period": 1800
}],


Note

VolumePairList does not support backtesting mode.

#### AgeFilter¶

Removes pairs that have been listed on the exchange for less than min_days_listed days (defaults to 10).

When pairs are first listed on an exchange they can suffer huge price drops and volatility in the first few days while the pair goes through its price-discovery period. Bots can often be caught out buying before the pair has finished dropping in price.

This filter allows freqtrade to ignore pairs until they have been listed for at least min_days_listed days.

#### PerformanceFilter¶

Sorts pairs by past trade performance, as follows: 1. Positive performance. 2. No closed trades yet. 3. Negative performance.

Trade count is used as a tie breaker.

Note

PerformanceFilter does not support backtesting mode.

#### PrecisionFilter¶

Filters low-value coins which would not allow setting stoplosses.

#### PriceFilter¶

The PriceFilter allows filtering of pairs by price. Currently the following price filters are supported:

• min_price
• max_price
• low_price_ratio

The min_price setting removes pairs where the price is below the specified price. This is useful if you wish to avoid trading very low-priced pairs. This option is disabled by default, and will only apply if set to > 0.

The max_price setting removes pairs where the price is above the specified price. This is useful if you wish to trade only low-priced pairs. This option is disabled by default, and will only apply if set to > 0.

The low_price_ratio setting removes pairs where a raise of 1 price unit (pip) is above the low_price_ratio ratio. This option is disabled by default, and will only apply if set to > 0.

For PriceFiler at least one of its min_price, max_price or low_price_ratio settings must be applied.

Calculation example:

Min price precision for SHITCOIN/BTC is 8 decimals. If its price is 0.00000011 - one price step above would be 0.00000012, which is ~9% higher than the previous price value. You may filter out this pair by using PriceFilter with low_price_ratio set to 0.09 (9%) or with min_price set to 0.00000011, correspondingly.

Low priced pairs

Low priced pairs with high "1 pip movements" are dangerous since they are often illiquid and it may also be impossible to place the desired stoploss, which can often result in high losses since price needs to be rounded to the next tradable price - so instead of having a stoploss of -5%, you could end up with a stoploss of -9% simply due to price rounding.

#### ShuffleFilter¶

Shuffles (randomizes) pairs in the pairlist. It can be used for preventing the bot from trading some of the pairs more frequently then others when you want all pairs be treated with the same priority.

Tip

You may set the seed value for this Pairlist to obtain reproducible results, which can be useful for repeated backtesting sessions. If seed is not set, the pairs are shuffled in the non-repeatable random order.

Removes pairs that have a difference between asks and bids above the specified ratio, max_spread_ratio (defaults to 0.005).

Example:

If DOGE/BTC maximum bid is 0.00000026 and minimum ask is 0.00000027, the ratio is calculated as: 1 - bid/ask ~= 0.037 which is > 0.005 and this pair will be filtered out.

#### RangeStabilityFilter¶

Removes pairs where the difference between lowest low and highest high over lookback_days days is below min_rate_of_change. Since this is a filter that requires additional data, the results are cached for refresh_period.

In the below example: If the trading range over the last 10 days is <1%, remove the pair from the whitelist.

"pairlists": [
{
"method": "RangeStabilityFilter",
"lookback_days": 10,
"min_rate_of_change": 0.01,
"refresh_period": 1440
}
]


Tip

This Filter can be used to automatically remove stable coin pairs, which have a very low trading range, and are therefore extremely difficult to trade with profit.

### Full example of Pairlist Handlers¶

The below example blacklists BNB/BTC, uses VolumePairList with 20 assets, sorting pairs by quoteVolume and applies both PrecisionFilter and PriceFilter, filtering all assets where 1 price unit is > 1%. Then the SpreadFilter is applied and pairs are finally shuffled with the random seed set to some predefined value.

"exchange": {
"pair_whitelist": [],
"pair_blacklist": ["BNB/BTC"]
},
"pairlists": [
{
"method": "VolumePairList",
"number_assets": 20,
"sort_key": "quoteVolume",
},
{"method": "AgeFilter", "min_days_listed": 10},
{"method": "PrecisionFilter"},
{"method": "PriceFilter", "low_price_ratio": 0.01},
{
"method": "RangeStabilityFilter",
"lookback_days": 10,
"min_rate_of_change": 0.01,
"refresh_period": 1440
},
{"method": "ShuffleFilter", "seed": 42}
],


## Protections¶

Beta feature

This feature is still in it's testing phase. Should you notice something you think is wrong please let us know via Discord, Slack or via Github Issue.

Protections will protect your strategy from unexpected events and market conditions by temporarily stop trading for either one pair, or for all pairs. All protection end times are rounded up to the next candle to avoid sudden, unexpected intra-candle buys.

Note

Not all Protections will work for all strategies, and parameters will need to be tuned for your strategy to improve performance.
To align your protection with your strategy, you can define protections in the strategy.

Tip

Each Protection can be configured multiple times with different parameters, to allow different levels of protection (short-term / long-term).

Backtesting

Protections are supported by backtesting and hyperopt, but must be explicitly enabled by using the --enable-protections flag.

### Common settings to all Protections¶

Parameter Description
method Protection name to use.
Datatype: String, selected from available Protections
stop_duration_candles For how many candles should the lock be set?
Datatype: Positive integer (in candles)
stop_duration how many minutes should protections be locked.
Cannot be used together with stop_duration_candles.
Datatype: Float (in minutes)
lookback_period_candles Only trades that completed within the last lookback_period_candles candles will be considered. This setting may be ignored by some Protections.
Datatype: Positive integer (in candles).
lookback_period Only trades that completed after current_time - lookback_period will be considered.
Cannot be used together with lookback_period_candles.
This setting may be ignored by some Protections.
Datatype: Float (in minutes)
trade_limit Number of trades required at minimum (not used by all Protections).
Datatype: Positive integer

Durations

Durations (stop_duration* and lookback_period* can be defined in either minutes or candles). For more flexibility when testing different timeframes, all below examples will use the "candle" definition.

#### Stoploss Guard¶

StoplossGuard selects all trades within lookback_period in minutes (or in candles when using lookback_period_candles). If trade_limit or more trades resulted in stoploss, trading will stop for stop_duration in minutes (or in candles when using stop_duration_candles).

This applies across all pairs, unless only_per_pair is set to true, which will then only look at one pair at a time.

The below example stops trading for all pairs for 4 candles after the last trade if the bot hit stoploss 4 times within the last 24 candles.

"protections": [
{
"method": "StoplossGuard",
"lookback_period_candles": 24,
"stop_duration_candles": 4,
"only_per_pair": false
}
],


Note

StoplossGuard considers all trades with the results "stop_loss", "stoploss_on_exchange" and "trailing_stop_loss" if the resulting profit was negative. trade_limit and lookback_period will need to be tuned for your strategy.

#### MaxDrawdown¶

MaxDrawdown uses all trades within lookback_period in minutes (or in candles when using lookback_period_candles) to determine the maximum drawdown. If the drawdown is below max_allowed_drawdown, trading will stop for stop_duration in minutes (or in candles when using stop_duration_candles) after the last trade - assuming that the bot needs some time to let markets recover.

The below sample stops trading for 12 candles if max-drawdown is > 20% considering all pairs - with a minimum of trade_limit trades - within the last 48 candles. If desired, lookback_period and/or stop_duration can be used.

"protections": [
{
"method": "MaxDrawdown",
"lookback_period_candles": 48,
"stop_duration_candles": 12,
"max_allowed_drawdown": 0.2
},
],


#### Low Profit Pairs¶

LowProfitPairs uses all trades for a pair within lookback_period in minutes (or in candles when using lookback_period_candles) to determine the overall profit ratio. If that ratio is below required_profit, that pair will be locked for stop_duration in minutes (or in candles when using stop_duration_candles).

The below example will stop trading a pair for 60 minutes if the pair does not have a required profit of 2% (and a minimum of 2 trades) within the last 6 candles.

"protections": [
{
"method": "LowProfitPairs",
"lookback_period_candles": 6,
"stop_duration": 60,
"required_profit": 0.02
}
],


#### Cooldown Period¶

CooldownPeriod locks a pair for stop_duration in minutes (or in candles when using stop_duration_candles) after selling, avoiding a re-entry for this pair for stop_duration minutes.

The below example will stop trading a pair for 2 candles after closing a trade, allowing this pair to "cool down".

"protections": [
{
"method": "CooldownPeriod",
"stop_duration_candles": 2
}
],


Note

This Protection applies only at pair-level, and will never lock all pairs globally. This Protection does not consider lookback_period as it only looks at the latest trade.

### Full example of Protections¶

All protections can be combined at will, also with different parameters, creating a increasing wall for under-performing pairs. All protections are evaluated in the sequence they are defined.

The below example assumes a timeframe of 1 hour:

• Locks each pair after selling for an additional 5 candles (CooldownPeriod), giving other pairs a chance to get filled.
• Stops trading for 4 hours (4 * 1h candles) if the last 2 days (48 * 1h candles) had 20 trades, which caused a max-drawdown of more than 20%. (MaxDrawdown).
• Stops trading if more than 4 stoploss occur for all pairs within a 1 day (24 * 1h candles) limit (StoplossGuard).
• Locks all pairs that had 4 Trades within the last 6 hours (6 * 1h candles) with a combined profit ratio of below 0.02 (<2%) (LowProfitPairs).
• Locks all pairs for 2 candles that had a profit of below 0.01 (<1%) within the last 24h (24 * 1h candles), a minimum of 4 trades.
"timeframe": "1h",
"protections": [
{
"method": "CooldownPeriod",
"stop_duration_candles": 5
},
{
"method": "MaxDrawdown",
"lookback_period_candles": 48,
"stop_duration_candles": 4,
"max_allowed_drawdown": 0.2
},
{
"method": "StoplossGuard",
"lookback_period_candles": 24,
"stop_duration_candles": 2,
"only_per_pair": false
},
{
"method": "LowProfitPairs",
"lookback_period_candles": 6,
"stop_duration_candles": 60,
"required_profit": 0.02
},
{
"method": "LowProfitPairs",
"lookback_period_candles": 24,
"stop_duration_candles": 2,
"required_profit": 0.01
}
],


You can use the same in your strategy, the syntax is only slightly different:

from freqtrade.strategy import IStrategy

class AwesomeStrategy(IStrategy)
timeframe = '1h'
protections = [
{
"method": "CooldownPeriod",
"stop_duration_candles": 5
},
{
"method": "MaxDrawdown",
"lookback_period_candles": 48,
"stop_duration_candles": 4,
"max_allowed_drawdown": 0.2
},
{
"method": "StoplossGuard",
"lookback_period_candles": 24,
"stop_duration_candles": 2,
"only_per_pair": False
},
{
"method": "LowProfitPairs",
"lookback_period_candles": 6,