exchange class contract methods safe check for symbol
This commit is contained in:
parent
78d1a267f0
commit
49a6ebb454
@ -381,21 +381,20 @@ class Exchange:
|
|||||||
return 1
|
return 1
|
||||||
|
|
||||||
def _trades_contracts_to_amount(self, trades: List) -> List:
|
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'])
|
contract_size = self._get_contract_size(trades[0]['symbol'])
|
||||||
if contract_size != 1:
|
if contract_size != 1:
|
||||||
for trade in trades:
|
for trade in trades:
|
||||||
trade['amount'] = trade['amount'] * contract_size
|
trade['amount'] = trade['amount'] * contract_size
|
||||||
return trades
|
return trades
|
||||||
else:
|
|
||||||
return trades
|
|
||||||
|
|
||||||
def _order_contracts_to_amount(self, order: Dict) -> Dict:
|
def _order_contracts_to_amount(self, order: Dict) -> Dict:
|
||||||
contract_size = self._get_contract_size(order['symbol'])
|
if 'symbol' in order:
|
||||||
if contract_size != 1:
|
contract_size = self._get_contract_size(order['symbol'])
|
||||||
for prop in ['amount', 'cost', 'filled', 'remaining']:
|
if contract_size != 1:
|
||||||
if prop in order and order[prop] is not None:
|
for prop in ['amount', 'cost', 'filled', 'remaining']:
|
||||||
order[prop] = order[prop] * contract_size
|
if prop in order and order[prop] is not None:
|
||||||
|
order[prop] = order[prop] * contract_size
|
||||||
return order
|
return order
|
||||||
|
|
||||||
def set_sandbox(self, api: ccxt.Exchange, exchange_config: dict, name: str) -> None:
|
def set_sandbox(self, api: ccxt.Exchange, exchange_config: dict, name: str) -> None:
|
||||||
|
Loading…
Reference in New Issue
Block a user