mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-14 04:03:55 +00:00
parent
32bdceee12
commit
0b1dd0d203
|
@ -1239,6 +1239,9 @@ class Exchange:
|
||||||
except ccxt.BaseError as e:
|
except ccxt.BaseError as e:
|
||||||
raise OperationalException(e) from e
|
raise OperationalException(e) from e
|
||||||
|
|
||||||
|
def get_order_id_conditional(self, order: Dict[str, Any]) -> str:
|
||||||
|
return order['id']
|
||||||
|
|
||||||
@retrier
|
@retrier
|
||||||
def get_fee(self, symbol: str, type: str = '', side: str = '', amount: float = 1,
|
def get_fee(self, symbol: str, type: str = '', side: str = '', amount: float = 1,
|
||||||
price: float = 1, taker_or_maker: str = 'maker') -> float:
|
price: float = 1, taker_or_maker: str = 'maker') -> float:
|
||||||
|
|
|
@ -8,6 +8,7 @@ from freqtrade.exceptions import (DDosProtection, InsufficientFundsError, Invali
|
||||||
OperationalException, TemporaryError)
|
OperationalException, TemporaryError)
|
||||||
from freqtrade.exchange import Exchange
|
from freqtrade.exchange import Exchange
|
||||||
from freqtrade.exchange.common import API_FETCH_ORDER_RETRY_COUNT, retrier
|
from freqtrade.exchange.common import API_FETCH_ORDER_RETRY_COUNT, retrier
|
||||||
|
from freqtrade.misc import safe_value_fallback2
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
@ -135,3 +136,8 @@ class Ftx(Exchange):
|
||||||
f'Could not cancel order due to {e.__class__.__name__}. Message: {e}') from e
|
f'Could not cancel order due to {e.__class__.__name__}. Message: {e}') from e
|
||||||
except ccxt.BaseError as e:
|
except ccxt.BaseError as e:
|
||||||
raise OperationalException(e) from e
|
raise OperationalException(e) from e
|
||||||
|
|
||||||
|
def get_order_id_conditional(self, order: Dict[str, Any]) -> str:
|
||||||
|
if order['type'] == 'stop':
|
||||||
|
return safe_value_fallback2(order['info'], order, 'orderId', 'id')
|
||||||
|
return order['id']
|
||||||
|
|
|
@ -1427,8 +1427,8 @@ class FreqtradeBot(LoggingMixin):
|
||||||
"""
|
"""
|
||||||
fee-detection fallback to Trades. Parses result of fetch_my_trades to get correct fee.
|
fee-detection fallback to Trades. Parses result of fetch_my_trades to get correct fee.
|
||||||
"""
|
"""
|
||||||
trades = self.exchange.get_trades_for_order(order['id'], trade.pair,
|
trades = self.exchange.get_trades_for_order(self.exchange.get_order_id_conditional(order),
|
||||||
trade.open_date)
|
trade.pair, trade.open_date)
|
||||||
|
|
||||||
if len(trades) == 0:
|
if len(trades) == 0:
|
||||||
logger.info("Applying fee on amount for %s failed: myTrade-Dict empty found", trade)
|
logger.info("Applying fee on amount for %s failed: myTrade-Dict empty found", trade)
|
||||||
|
|
|
@ -157,3 +157,26 @@ def test_fetch_stoploss_order(default_conf, mocker):
|
||||||
'fetch_stoploss_order', 'fetch_orders',
|
'fetch_stoploss_order', 'fetch_orders',
|
||||||
retries=API_FETCH_ORDER_RETRY_COUNT + 1,
|
retries=API_FETCH_ORDER_RETRY_COUNT + 1,
|
||||||
order_id='_', pair='TKN/BTC')
|
order_id='_', pair='TKN/BTC')
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_order_id(mocker, default_conf):
|
||||||
|
exchange = get_patched_exchange(mocker, default_conf, id='ftx')
|
||||||
|
order = {
|
||||||
|
'type': STOPLOSS_ORDERTYPE,
|
||||||
|
'price': 1500,
|
||||||
|
'id': '1111',
|
||||||
|
'info': {
|
||||||
|
'orderId': '1234'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert exchange.get_order_id_conditional(order) == '1234'
|
||||||
|
|
||||||
|
order = {
|
||||||
|
'type': 'limit',
|
||||||
|
'price': 1500,
|
||||||
|
'id': '1111',
|
||||||
|
'info': {
|
||||||
|
'orderId': '1234'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert exchange.get_order_id_conditional(order) == '1111'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user