Fix potential problem.

This commit is contained in:
Reigo Reinmets 2021-12-13 02:46:37 +02:00
parent 2c3e5fa080
commit 1362bd9626

View File

@ -656,6 +656,7 @@ class FreqtradeBot(LoggingMixin):
""" """
Sends rpc notification when a buy occurred. Sends rpc notification when a buy occurred.
""" """
open_rate = safe_value_fallback(order, 'average', 'price')
msg = { msg = {
'trade_id': trade.id, 'trade_id': trade.id,
'type': RPCMessageType.BUY_FILL if fill else RPCMessageType.BUY, 'type': RPCMessageType.BUY_FILL if fill else RPCMessageType.BUY,
@ -663,7 +664,7 @@ class FreqtradeBot(LoggingMixin):
'exchange': self.exchange.name.capitalize(), 'exchange': self.exchange.name.capitalize(),
'pair': trade.pair, 'pair': trade.pair,
'limit': safe_value_fallback(order, 'average', 'price'), # Deprecated (?) 'limit': safe_value_fallback(order, 'average', 'price'), # Deprecated (?)
'open_rate': safe_value_fallback(order, 'average', 'price'), 'open_rate': open_rate or trade.open_rate,
'order_type': order_type, 'order_type': order_type,
'stake_amount': trade.stake_amount, 'stake_amount': trade.stake_amount,
'stake_currency': self.config['stake_currency'], 'stake_currency': self.config['stake_currency'],