Replace key 'rate' with 'price' in orders to conform to ccxt
This commit is contained in:
parent
a4696f8391
commit
ce243a04b3
@ -96,7 +96,7 @@ def buy(pair: str, rate: float, amount: float) -> Dict:
|
||||
order_id = 'dry_run_buy_{}'.format(randint(0, 10**6))
|
||||
_DRY_RUN_OPEN_ORDERS[order_id] = {
|
||||
'pair': pair,
|
||||
'rate': rate,
|
||||
'price': rate,
|
||||
'amount': amount,
|
||||
'type': 'limit',
|
||||
'side': 'buy',
|
||||
@ -134,7 +134,7 @@ def sell(pair: str, rate: float, amount: float) -> Dict:
|
||||
order_id = 'dry_run_sell_{}'.format(randint(0, 10**6))
|
||||
_DRY_RUN_OPEN_ORDERS[order_id] = {
|
||||
'pair': pair,
|
||||
'rate': rate,
|
||||
'price': rate,
|
||||
'amount': amount,
|
||||
'type': 'limit',
|
||||
'side': 'sell',
|
||||
|
@ -104,7 +104,7 @@ class Trade(_DECL_BASE):
|
||||
:return: None
|
||||
"""
|
||||
# Ignore open and cancelled orders
|
||||
if order['status'] == 'open' or order['rate'] is None:
|
||||
if order['status'] == 'open' or order['price'] is None:
|
||||
return
|
||||
|
||||
logger.info('Updating trade (id=%d) ...', self.id)
|
||||
@ -112,12 +112,12 @@ class Trade(_DECL_BASE):
|
||||
getcontext().prec = 8 # Bittrex do not go above 8 decimal
|
||||
if order['type'] == 'limit' and order['side'] == 'buy':
|
||||
# Update open rate and actual amount
|
||||
self.open_rate = Decimal(order['rate'])
|
||||
self.open_rate = Decimal(order['price'])
|
||||
self.amount = Decimal(order['amount'])
|
||||
logger.info('LIMIT_BUY has been fulfilled for %s.', self)
|
||||
self.open_order_id = None
|
||||
elif order['type'] == 'limit' and order['side'] == 'sell':
|
||||
self.close(order['rate'])
|
||||
self.close(order['price'])
|
||||
else:
|
||||
raise ValueError('Unknown order type: {}'.format(order['type']))
|
||||
cleanup()
|
||||
|
@ -606,7 +606,7 @@ def _exec_forcesell(trade: Trade) -> None:
|
||||
and order['type'] == 'limit' \
|
||||
and order['side'] == 'buy':
|
||||
exchange.cancel_order(trade.open_order_id, trade.pair)
|
||||
trade.close(order.get('rate') or trade.open_rate)
|
||||
trade.close(order.get('price') or trade.open_rate)
|
||||
# TODO: sell amount which has been bought already
|
||||
return
|
||||
|
||||
|
@ -141,7 +141,7 @@ def limit_buy_order():
|
||||
'side': 'buy',
|
||||
'pair': 'mocked',
|
||||
'datetime': arrow.utcnow().isoformat(),
|
||||
'rate': 0.00001099,
|
||||
'price': 0.00001099,
|
||||
'amount': 90.99181073,
|
||||
'remaining': 0.0,
|
||||
'status': 'closed'
|
||||
@ -156,7 +156,7 @@ def limit_buy_order_old():
|
||||
'side': 'buy',
|
||||
'pair': 'ETH/BTC',
|
||||
'datetime': arrow.utcnow().shift(minutes=-601).isoformat(),
|
||||
'rate': 0.00001099,
|
||||
'price': 0.00001099,
|
||||
'amount': 90.99181073,
|
||||
'remaining': 90.99181073,
|
||||
'status': 'open'
|
||||
@ -171,7 +171,7 @@ def limit_sell_order_old():
|
||||
'side': 'sell',
|
||||
'pair': 'ETH/BTC',
|
||||
'datetime': arrow.utcnow().shift(minutes=-601).isoformat(),
|
||||
'rate': 0.00001099,
|
||||
'price': 0.00001099,
|
||||
'amount': 90.99181073,
|
||||
'remaining': 90.99181073,
|
||||
'status': 'open'
|
||||
@ -186,7 +186,7 @@ def limit_buy_order_old_partial():
|
||||
'side': 'buy',
|
||||
'pair': 'ETH/BTC',
|
||||
'datetime': arrow.utcnow().shift(minutes=-601).isoformat(),
|
||||
'rate': 0.00001099,
|
||||
'price': 0.00001099,
|
||||
'amount': 90.99181073,
|
||||
'remaining': 67.99181073,
|
||||
'status': 'open'
|
||||
@ -201,7 +201,7 @@ def limit_sell_order():
|
||||
'side': 'sell',
|
||||
'pair': 'mocked',
|
||||
'datetime': arrow.utcnow().isoformat(),
|
||||
'rate': 0.00001173,
|
||||
'price': 0.00001173,
|
||||
'amount': 90.99181073,
|
||||
'remaining': 0.0,
|
||||
'status': 'closed'
|
||||
|
Loading…
Reference in New Issue
Block a user