exchange class contract methods safe check for symbol

This commit is contained in:
Sam Germain 2021-12-31 04:29:19 -06:00
parent 78d1a267f0
commit 49a6ebb454

View File

@ -381,16 +381,15 @@ 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
def _order_contracts_to_amount(self, order: Dict) -> Dict:
if 'symbol' in order:
contract_size = self._get_contract_size(order['symbol'])
if contract_size != 1:
for prop in ['amount', 'cost', 'filled', 'remaining']: