Rename method to custom_stoploss

This commit is contained in:
Matthias
2020-12-20 11:17:50 +01:00
parent 277342f167
commit 9d5961e224
5 changed files with 23 additions and 22 deletions

View File

@@ -1,7 +1,9 @@
from datetime import datetime
from freqtrade.persistence.models import Trade
from pandas import DataFrame
from freqtrade.persistence.models import Trade
from .strats.default_strategy import DefaultStrategy
@@ -38,5 +40,5 @@ def test_default_strategy(result, fee):
assert strategy.confirm_trade_exit(pair='ETH/BTC', trade=trade, order_type='limit', amount=0.1,
rate=20000, time_in_force='gtc', sell_reason='roi') is True
assert strategy.stoploss_value(pair='ETH/BTC', trade=trade, current_time=datetime.now(),
current_rate=20_000, current_profit=0.05) == strategy.stoploss
assert strategy.custom_stoploss(pair='ETH/BTC', trade=trade, current_time=datetime.now(),
current_rate=20_000, current_profit=0.05) == strategy.stoploss

View File

@@ -1,5 +1,4 @@
# pragma pylint: disable=missing-docstring, C0103
from freqtrade.strategy.interface import SellCheckTuple, SellType
import logging
from datetime import datetime, timedelta, timezone
from unittest.mock import MagicMock
@@ -11,9 +10,10 @@ from pandas import DataFrame
from freqtrade.configuration import TimeRange
from freqtrade.data.dataprovider import DataProvider
from freqtrade.data.history import load_data
from freqtrade.exceptions import OperationalException, StrategyError
from freqtrade.exceptions import StrategyError
from freqtrade.persistence import PairLocks, Trade
from freqtrade.resolvers import StrategyResolver
from freqtrade.strategy.interface import SellCheckTuple, SellType
from freqtrade.strategy.strategy_wrapper import strategy_safe_wrapper
from tests.conftest import log_has, log_has_re
@@ -329,9 +329,9 @@ def test_stop_loss_reached(default_conf, fee, profit, adjusted, expected, traili
strategy.trailing_stop = trailing
strategy.trailing_stop_positive = -0.05
strategy.use_custom_stoploss = custom
original_stopvalue = strategy.stoploss_value
original_stopvalue = strategy.custom_stoploss
if custom_stop:
strategy.stoploss_value = custom_stop
strategy.custom_stoploss = custom_stop
now = arrow.utcnow().datetime
sl_flag = strategy.stop_loss_reached(current_rate=trade.open_rate * (1 + profit), trade=trade,
@@ -355,8 +355,7 @@ def test_stop_loss_reached(default_conf, fee, profit, adjusted, expected, traili
assert sl_flag.sell_flag is True
assert round(trade.stop_loss, 2) == adjusted2
strategy.stoploss_value = original_stopvalue
strategy.custom_stoploss = original_stopvalue
def test_analyze_ticker_default(ohlcv_history, mocker, caplog) -> None: