Check if symbol is not None
This commit is contained in:
parent
d3ea14de68
commit
46f4227329
@ -402,7 +402,7 @@ class Exchange:
|
|||||||
return trades
|
return trades
|
||||||
|
|
||||||
def _order_contracts_to_amount(self, order: Dict) -> Dict:
|
def _order_contracts_to_amount(self, order: Dict) -> Dict:
|
||||||
if 'symbol' in order:
|
if 'symbol' in order and order['symbol'] is not None:
|
||||||
contract_size = self._get_contract_size(order['symbol'])
|
contract_size = self._get_contract_size(order['symbol'])
|
||||||
if contract_size != 1:
|
if contract_size != 1:
|
||||||
for prop in ['amount', 'cost', 'filled', 'remaining']:
|
for prop in ['amount', 'cost', 'filled', 'remaining']:
|
||||||
@ -1108,10 +1108,10 @@ class Exchange:
|
|||||||
self._lev_prep(pair, leverage, side)
|
self._lev_prep(pair, leverage, side)
|
||||||
order = self._api.create_order(symbol=pair, type=ordertype, side=side,
|
order = self._api.create_order(symbol=pair, type=ordertype, side=side,
|
||||||
amount=amount, price=rate, params=params)
|
amount=amount, price=rate, params=params)
|
||||||
|
self._log_exchange_response('create_stoploss_order', order)
|
||||||
order = self._order_contracts_to_amount(order)
|
order = self._order_contracts_to_amount(order)
|
||||||
logger.info(f"stoploss {user_order_type} order added for {pair}. "
|
logger.info(f"stoploss {user_order_type} order added for {pair}. "
|
||||||
f"stop price: {stop_price}. limit: {rate}")
|
f"stop price: {stop_price}. limit: {rate}")
|
||||||
self._log_exchange_response('create_stoploss_order', order)
|
|
||||||
return order
|
return order
|
||||||
except ccxt.InsufficientFunds as e:
|
except ccxt.InsufficientFunds as e:
|
||||||
raise InsufficientFundsError(
|
raise InsufficientFundsError(
|
||||||
|
@ -4111,10 +4111,36 @@ def test__order_contracts_to_amount(
|
|||||||
'trades': None,
|
'trades': None,
|
||||||
'info': {},
|
'info': {},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
# Realistic stoploss order on gateio.
|
||||||
|
'id': '123456380',
|
||||||
|
'clientOrderId': '12345638203',
|
||||||
|
'timestamp': None,
|
||||||
|
'datetime': None,
|
||||||
|
'lastTradeTimestamp': None,
|
||||||
|
'status': None,
|
||||||
|
'symbol': None,
|
||||||
|
'type': None,
|
||||||
|
'timeInForce': None,
|
||||||
|
'postOnly': None,
|
||||||
|
'side': None,
|
||||||
|
'price': None,
|
||||||
|
'stopPrice': None,
|
||||||
|
'average': None,
|
||||||
|
'amount': None,
|
||||||
|
'cost': None,
|
||||||
|
'filled': None,
|
||||||
|
'remaining': None,
|
||||||
|
'fee': None,
|
||||||
|
'fees': [],
|
||||||
|
'trades': None,
|
||||||
|
'info': {},
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
order1 = exchange._order_contracts_to_amount(orders[0])
|
order1 = exchange._order_contracts_to_amount(orders[0])
|
||||||
order2 = exchange._order_contracts_to_amount(orders[1])
|
order2 = exchange._order_contracts_to_amount(orders[1])
|
||||||
|
exchange._order_contracts_to_amount(orders[2])
|
||||||
assert order1['amount'] == 30.0 * contract_size
|
assert order1['amount'] == 30.0 * contract_size
|
||||||
assert order2['amount'] == 40.0 * contract_size
|
assert order2['amount'] == 40.0 * contract_size
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user