Merge pull request #1545 from hroff-1902/patch-3

Cosmetic: fix logging
This commit is contained in:
Matthias 2019-02-11 06:12:17 +01:00 committed by GitHub
commit d91dbf4090
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 16 deletions

View File

@ -267,9 +267,8 @@ class FreqtradeBot(object):
# Check if stake_amount is fulfilled # Check if stake_amount is fulfilled
if avaliable_amount < stake_amount: if avaliable_amount < stake_amount:
raise DependencyException( raise DependencyException(
'Available balance(%f %s) is lower than stake amount(%f %s)' % ( f"Available balance({avaliable_amount} {self.config['stake_currency']}) is "
avaliable_amount, self.config['stake_currency'], f"lower than stake amount({stake_amount} {self.config['stake_currency']})"
stake_amount, self.config['stake_currency'])
) )
return stake_amount return stake_amount
@ -333,10 +332,8 @@ class FreqtradeBot(object):
if not stake_amount: if not stake_amount:
return False return False
logger.info( logger.info(f"Buy signal found: about create a new trade with stake_amount: "
'Buy signal found: about create a new trade with stake_amount: %f ...', f"{stake_amount} ...")
stake_amount
)
bidstrat_check_depth_of_market = self.config.get('bid_strategy', {}).\ bidstrat_check_depth_of_market = self.config.get('bid_strategy', {}).\
get('check_depth_of_market', {}) get('check_depth_of_market', {})
@ -507,7 +504,7 @@ class FreqtradeBot(object):
trade.fee_open = 0 trade.fee_open = 0
except OperationalException as exception: except OperationalException as exception:
logger.warning("could not update trade amount: %s", exception) logger.warning("Could not update trade amount: %s", exception)
trade.update(order) trade.update(order)
@ -566,12 +563,12 @@ class FreqtradeBot(object):
fee_abs += exectrade['fee']['cost'] fee_abs += exectrade['fee']['cost']
if amount != order_amount: if amount != order_amount:
logger.warning(f"amount {amount} does not match amount {trade.amount}") logger.warning(f"Amount {amount} does not match amount {trade.amount}")
raise OperationalException("Half bought? Amounts don't match") raise OperationalException("Half bought? Amounts don't match")
real_amount = amount - fee_abs real_amount = amount - fee_abs
if fee_abs != 0: if fee_abs != 0:
logger.info(f"""Applying fee on amount for {trade} \ logger.info(f"Applying fee on amount for {trade} "
(from {order_amount} to {real_amount}) from Trades""") f"(from {order_amount} to {real_amount}) from Trades")
return real_amount return real_amount
def handle_trade(self, trade: Trade) -> bool: def handle_trade(self, trade: Trade) -> bool:
@ -580,7 +577,7 @@ class FreqtradeBot(object):
:return: True if trade has been sold, False otherwise :return: True if trade has been sold, False otherwise
""" """
if not trade.is_open: if not trade.is_open:
raise ValueError(f'attempt to handle closed trade: {trade}') raise ValueError(f'Attempt to handle closed trade: {trade}')
logger.debug('Handling %s ...', trade) logger.debug('Handling %s ...', trade)
sell_rate = self.exchange.get_ticker(trade.pair)['bid'] sell_rate = self.exchange.get_ticker(trade.pair)['bid']

View File

@ -691,7 +691,7 @@ def test_process_trade_creation(default_conf, ticker, limit_buy_order,
assert trade.amount == 90.99181073703367 assert trade.amount == 90.99181073703367
assert log_has( assert log_has(
'Buy signal found: about create a new trade with stake_amount: 0.001000 ...', 'Buy signal found: about create a new trade with stake_amount: 0.001 ...',
caplog.record_tuples caplog.record_tuples
) )
@ -1318,7 +1318,7 @@ def test_process_maybe_execute_sell_exception(mocker, default_conf,
side_effect=OperationalException() side_effect=OperationalException()
) )
freqtrade.process_maybe_execute_sell(trade) freqtrade.process_maybe_execute_sell(trade)
assert log_has('could not update trade amount: ', caplog.record_tuples) assert log_has('Could not update trade amount: ', caplog.record_tuples)
# Test raise of DependencyException exception # Test raise of DependencyException exception
mocker.patch( mocker.patch(