From 49a6ebb4545e0ab5531d29f567c5680ea93793ab Mon Sep 17 00:00:00 2001 From: Sam Germain Date: Fri, 31 Dec 2021 04:29:19 -0600 Subject: [PATCH] exchange class contract methods safe check for symbol --- freqtrade/exchange/exchange.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index 8a87a2c7f..eaebd06d3 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -381,21 +381,20 @@ class Exchange: return 1 def _trades_contracts_to_amount(self, trades: List) -> List: - if len(trades) > 0: + if len(trades) > 0 and 'symbol' in trades[0]: contract_size = self._get_contract_size(trades[0]['symbol']) if contract_size != 1: for trade in trades: trade['amount'] = trade['amount'] * contract_size - return trades - else: - return trades + return trades def _order_contracts_to_amount(self, order: Dict) -> Dict: - contract_size = self._get_contract_size(order['symbol']) - if contract_size != 1: - for prop in ['amount', 'cost', 'filled', 'remaining']: - if prop in order and order[prop] is not None: - order[prop] = order[prop] * contract_size + if 'symbol' in order: + contract_size = self._get_contract_size(order['symbol']) + if contract_size != 1: + for prop in ['amount', 'cost', 'filled', 'remaining']: + if prop in order and order[prop] is not None: + order[prop] = order[prop] * contract_size return order def set_sandbox(self, api: ccxt.Exchange, exchange_config: dict, name: str) -> None: