Improve wording, fix bug

This commit is contained in:
Matthias 2020-12-07 15:45:02 +01:00
parent effc96e92b
commit f047297995
5 changed files with 19 additions and 3 deletions

View File

@ -7,7 +7,7 @@ Protections will protect your strategy from unexpected events and market conditi
All protection end times are rounded up to the next candle to avoid sudden, unexpected intra-candle buys. All protection end times are rounded up to the next candle to avoid sudden, unexpected intra-candle buys.
!!! Note !!! Note
Not all Protections will work for all strategies, and parameters will need to be tuned for your strategy. Not all Protections will work for all strategies, and parameters will need to be tuned for your strategy to improve performance.
!!! Tip !!! Tip
Each Protection can be configured multiple times with different parameters, to allow different levels of protection (short-term / long-term). Each Protection can be configured multiple times with different parameters, to allow different levels of protection (short-term / long-term).

View File

@ -1,4 +1,5 @@
from typing import Callable from typing import Callable
from cachetools import TTLCache, cached from cachetools import TTLCache, cached

View File

@ -18,6 +18,7 @@ from freqtrade.data.converter import trim_dataframe
from freqtrade.data.dataprovider import DataProvider from freqtrade.data.dataprovider import DataProvider
from freqtrade.exceptions import OperationalException from freqtrade.exceptions import OperationalException
from freqtrade.exchange import timeframe_to_minutes, timeframe_to_seconds from freqtrade.exchange import timeframe_to_minutes, timeframe_to_seconds
from freqtrade.mixins import LoggingMixin
from freqtrade.optimize.optimize_reports import (generate_backtest_stats, show_backtest_results, from freqtrade.optimize.optimize_reports import (generate_backtest_stats, show_backtest_results,
store_backtest_stats) store_backtest_stats)
from freqtrade.pairlist.pairlistmanager import PairListManager from freqtrade.pairlist.pairlistmanager import PairListManager
@ -25,7 +26,6 @@ from freqtrade.persistence import PairLocks, Trade
from freqtrade.plugins.protectionmanager import ProtectionManager from freqtrade.plugins.protectionmanager import ProtectionManager
from freqtrade.resolvers import ExchangeResolver, StrategyResolver from freqtrade.resolvers import ExchangeResolver, StrategyResolver
from freqtrade.strategy.interface import IStrategy, SellCheckTuple, SellType from freqtrade.strategy.interface import IStrategy, SellCheckTuple, SellType
from freqtrade.mixins import LoggingMixin
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -54,7 +54,10 @@ class MaxDrawdown(IProtection):
return False, None, None return False, None, None
# Drawdown is always positive # Drawdown is always positive
drawdown, _, _ = calculate_max_drawdown(trades_df, value_col='close_profit') try:
drawdown, _, _ = calculate_max_drawdown(trades_df, value_col='close_profit')
except ValueError:
return False, None, None
if drawdown > self._max_allowed_drawdown: if drawdown > self._max_allowed_drawdown:
self.log_once( self.log_once(

View File

@ -304,6 +304,18 @@ def test_MaxDrawdown(mocker, default_conf, fee, caplog):
'XRP/BTC', fee.return_value, False, sell_reason=SellType.STOP_LOSS.value, 'XRP/BTC', fee.return_value, False, sell_reason=SellType.STOP_LOSS.value,
min_ago_open=1000, min_ago_close=900, profit_rate=1.1, min_ago_open=1000, min_ago_close=900, profit_rate=1.1,
)) ))
Trade.session.add(generate_mock_trade(
'ETH/BTC', fee.return_value, False, sell_reason=SellType.STOP_LOSS.value,
min_ago_open=1000, min_ago_close=900, profit_rate=1.1,
))
Trade.session.add(generate_mock_trade(
'NEO/BTC', fee.return_value, False, sell_reason=SellType.STOP_LOSS.value,
min_ago_open=1000, min_ago_close=900, profit_rate=1.1,
))
# No losing trade yet ... so max_drawdown will raise exception
assert not freqtrade.protections.global_stop()
assert not freqtrade.protections.stop_per_pair('XRP/BTC')
Trade.session.add(generate_mock_trade( Trade.session.add(generate_mock_trade(
'XRP/BTC', fee.return_value, False, sell_reason=SellType.STOP_LOSS.value, 'XRP/BTC', fee.return_value, False, sell_reason=SellType.STOP_LOSS.value,
min_ago_open=500, min_ago_close=400, profit_rate=0.9, min_ago_open=500, min_ago_close=400, profit_rate=0.9,