more minor tweaks to log messages

This commit is contained in:
Janne Sinivirta 2018-02-24 19:51:37 +02:00
parent 3e89b9685d
commit 76c5cdc6e3
2 changed files with 9 additions and 9 deletions

View File

@ -312,17 +312,17 @@ def should_sell(trade: Trade, rate: float, date: datetime, buy: bool, sell: bool
"""
# Check if minimal roi has been reached and no longer in buy conditions (avoiding a fee)
if min_roi_reached(trade, rate, date):
logger.debug('Executing sell due to ROI ...')
logger.debug('Required profit reached. Selling..')
return True
# Experimental: Check if the trade is profitable before selling it (avoid selling at loss)
if _CONF.get('experimental', {}).get('sell_profit_only', False):
logger.debug('Checking if trade is profitable ...')
logger.debug('Checking if trade is profitable..')
if trade.calc_profit(rate=rate) <= 0:
return False
if sell and not buy and _CONF.get('experimental', {}).get('use_sell_signal', False):
logger.debug('Executing sell due to sell signal ...')
logger.debug('Sell signal received. Selling..')
return True
return False
@ -383,7 +383,7 @@ def create_trade(stake_amount: float, interval: int) -> bool:
whitelist.remove(trade.pair)
logger.debug('Ignoring %s in pair whitelist', trade.pair)
if not whitelist:
raise DependencyException('No pair in whitelist')
raise DependencyException('No currency pairs in whitelist')
# Pick pair based on StochRSI buy signals
for _pair in whitelist:

View File

@ -233,7 +233,7 @@ def test_create_trade_no_pairs(default_conf, ticker, mocker):
get_ticker=ticker,
buy=MagicMock(return_value='mocked_limit_buy'))
with pytest.raises(DependencyException, match=r'.*No pair in whitelist.*'):
with pytest.raises(DependencyException, match=r'.*No currency pairs in whitelist.*'):
conf = copy.deepcopy(default_conf)
conf['exchange']['pair_whitelist'] = []
mocker.patch.dict('freqtrade.main._CONF', conf)
@ -249,7 +249,7 @@ def test_create_trade_no_pairs_after_blacklist(default_conf, ticker, mocker):
get_ticker=ticker,
buy=MagicMock(return_value='mocked_limit_buy'))
with pytest.raises(DependencyException, match=r'.*No pair in whitelist.*'):
with pytest.raises(DependencyException, match=r'.*No currency pairs in whitelist.*'):
conf = copy.deepcopy(default_conf)
conf['exchange']['pair_whitelist'] = ["BTC_ETH"]
conf['exchange']['pair_blacklist'] = ["BTC_ETH"]
@ -385,11 +385,11 @@ def test_handle_trade_roi(default_conf, ticker, mocker, caplog):
# if ROI is reached we must sell
mocker.patch('freqtrade.main.get_signal', side_effect=lambda s, t: (False, True))
assert handle_trade(trade, interval=int(default_conf['ticker_interval']))
assert ('freqtrade', logging.DEBUG, 'Executing sell due to ROI ...') in caplog.record_tuples
assert ('freqtrade', logging.DEBUG, 'Required profit reached. Selling..') in caplog.record_tuples
# if ROI is reached we must sell even if sell-signal is not signalled
mocker.patch('freqtrade.main.get_signal', side_effect=lambda s, t: (False, True))
assert handle_trade(trade, interval=int(default_conf['ticker_interval']))
assert ('freqtrade', logging.DEBUG, 'Executing sell due to ROI ...') in caplog.record_tuples
assert ('freqtrade', logging.DEBUG, 'Required profit reached. Selling..') in caplog.record_tuples
def test_handle_trade_experimental(default_conf, ticker, mocker, caplog):
@ -416,7 +416,7 @@ def test_handle_trade_experimental(default_conf, ticker, mocker, caplog):
assert value_returned is False
mocker.patch('freqtrade.main.get_signal', side_effect=lambda s, t: (False, True))
assert handle_trade(trade, int(default_conf['ticker_interval']))
s = 'Executing sell due to sell signal ...'
s = 'Sell signal received. Selling..'
assert ('freqtrade', logging.DEBUG, s) in caplog.record_tuples