Stoploss orders should also be eligible to update closed fees

This commit is contained in:
Matthias 2022-07-16 12:52:35 +02:00
parent 415780a4fe
commit ed64e4299b
2 changed files with 9 additions and 1 deletions

View File

@ -1,12 +1,13 @@
""" Gate.io exchange subclass """
import logging
from datetime import datetime
from typing import Dict, List, Optional, Tuple
from typing import Any, Dict, List, Optional, Tuple
from freqtrade.constants import BuySell
from freqtrade.enums import MarginMode, TradingMode
from freqtrade.exceptions import OperationalException
from freqtrade.exchange import Exchange
from freqtrade.misc import safe_value_fallback2
logger = logging.getLogger(__name__)
@ -97,6 +98,11 @@ class Gateio(Exchange):
}
return trades
def get_order_id_conditional(self, order: Dict[str, Any]) -> str:
if self.trading_mode == TradingMode.FUTURES:
return safe_value_fallback2(order, order, 'id_stop', 'id')
return order['id']
def fetch_stoploss_order(self, order_id: str, pair: str, params: Dict = {}) -> Dict:
order = self.fetch_order(
order_id=order_id,

View File

@ -332,6 +332,8 @@ class FreqtradeBot(LoggingMixin):
if not trade.is_open and not trade.fee_updated(trade.exit_side):
# Get sell fee
order = trade.select_order(trade.exit_side, False)
if not order:
order = trade.select_order('stoploss', False)
if order:
logger.info(
f"Updating {trade.exit_side}-fee on trade {trade}"