Evaluate average before price in order returns
This commit is contained in:
parent
de46744aa9
commit
4774896169
@ -475,6 +475,7 @@ class Exchange:
|
|||||||
"id": order_id,
|
"id": order_id,
|
||||||
'pair': pair,
|
'pair': pair,
|
||||||
'price': rate,
|
'price': rate,
|
||||||
|
'average': rate,
|
||||||
'amount': _amount,
|
'amount': _amount,
|
||||||
'cost': _amount * rate,
|
'cost': _amount * rate,
|
||||||
'type': ordertype,
|
'type': ordertype,
|
||||||
|
@ -554,14 +554,14 @@ class FreqtradeBot:
|
|||||||
)
|
)
|
||||||
stake_amount = order['cost']
|
stake_amount = order['cost']
|
||||||
amount = order['filled']
|
amount = order['filled']
|
||||||
buy_limit_filled_price = order['price']
|
buy_limit_filled_price = safe_value_fallback(order, 'average', 'price')
|
||||||
order_id = None
|
order_id = None
|
||||||
|
|
||||||
# in case of FOK the order may be filled immediately and fully
|
# in case of FOK the order may be filled immediately and fully
|
||||||
elif order_status == 'closed':
|
elif order_status == 'closed':
|
||||||
stake_amount = order['cost']
|
stake_amount = order['cost']
|
||||||
amount = safe_value_fallback(order, 'filled', 'amount')
|
amount = safe_value_fallback(order, 'filled', 'amount')
|
||||||
buy_limit_filled_price = order['price']
|
buy_limit_filled_price = safe_value_fallback(order, 'average', 'price')
|
||||||
|
|
||||||
# Fee is applied twice because we make a LIMIT_BUY and LIMIT_SELL
|
# Fee is applied twice because we make a LIMIT_BUY and LIMIT_SELL
|
||||||
fee = self.exchange.get_fee(symbol=pair, taker_or_maker='maker')
|
fee = self.exchange.get_fee(symbol=pair, taker_or_maker='maker')
|
||||||
|
@ -369,20 +369,20 @@ class Trade(_DECL_BASE):
|
|||||||
"""
|
"""
|
||||||
order_type = order['type']
|
order_type = order['type']
|
||||||
# Ignore open and cancelled orders
|
# Ignore open and cancelled orders
|
||||||
if order['status'] == 'open' or order['price'] is None:
|
if order['status'] == 'open' or safe_value_fallback(order, 'average', 'price') is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
logger.info('Updating trade (id=%s) ...', self.id)
|
logger.info('Updating trade (id=%s) ...', self.id)
|
||||||
|
|
||||||
if order_type in ('market', 'limit') and order['side'] == 'buy':
|
if order_type in ('market', 'limit') and order['side'] == 'buy':
|
||||||
# Update open rate and actual amount
|
# Update open rate and actual amount
|
||||||
self.open_rate = Decimal(order['price'])
|
self.open_rate = Decimal(safe_value_fallback(order, 'average', 'price'))
|
||||||
self.amount = Decimal(safe_value_fallback(order, 'filled', 'amount'))
|
self.amount = Decimal(safe_value_fallback(order, 'filled', 'amount'))
|
||||||
self.recalc_open_trade_price()
|
self.recalc_open_trade_price()
|
||||||
logger.info('%s_BUY has been fulfilled for %s.', order_type.upper(), self)
|
logger.info('%s_BUY has been fulfilled for %s.', order_type.upper(), self)
|
||||||
self.open_order_id = None
|
self.open_order_id = None
|
||||||
elif order_type in ('market', 'limit') and order['side'] == 'sell':
|
elif order_type in ('market', 'limit') and order['side'] == 'sell':
|
||||||
self.close(order['price'])
|
self.close(safe_value_fallback(order, 'average', 'price'))
|
||||||
logger.info('%s_SELL has been fulfilled for %s.', order_type.upper(), self)
|
logger.info('%s_SELL has been fulfilled for %s.', order_type.upper(), self)
|
||||||
elif order_type in ('stop_loss_limit', 'stop-loss', 'stop'):
|
elif order_type in ('stop_loss_limit', 'stop-loss', 'stop'):
|
||||||
self.stoploss_order_id = None
|
self.stoploss_order_id = None
|
||||||
|
Loading…
Reference in New Issue
Block a user