2021-08-20 04:51:04 +00:00
|
|
|
""" Gate.io exchange subclass """
|
|
|
|
import logging
|
|
|
|
from typing import Dict
|
|
|
|
|
2021-10-03 12:14:16 +00:00
|
|
|
from freqtrade.exceptions import OperationalException
|
2021-08-20 04:51:04 +00:00
|
|
|
from freqtrade.exchange import Exchange
|
|
|
|
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
class Gateio(Exchange):
|
|
|
|
"""
|
|
|
|
Gate.io exchange class. Contains adjustments needed for Freqtrade to work
|
|
|
|
with this exchange.
|
|
|
|
|
|
|
|
Please note that this exchange is not included in the list of exchanges
|
|
|
|
officially supported by the Freqtrade development team. So some features
|
|
|
|
may still not work as expected.
|
|
|
|
"""
|
|
|
|
|
|
|
|
_ft_has: Dict = {
|
|
|
|
"ohlcv_candle_limit": 1000,
|
2022-01-06 15:13:10 +00:00
|
|
|
"ohlcv_volume_currency": "quote",
|
2022-03-12 18:23:20 +00:00
|
|
|
"stoploss_order_types": {"limit": "limit"},
|
2022-03-09 07:05:21 +00:00
|
|
|
"stoploss_on_exchange": True,
|
2021-08-20 04:51:04 +00:00
|
|
|
}
|
2021-09-02 18:56:46 +00:00
|
|
|
|
|
|
|
_headers = {'X-Gate-Channel-Id': 'freqtrade'}
|
2021-10-03 12:14:16 +00:00
|
|
|
|
|
|
|
def validate_ordertypes(self, order_types: Dict) -> None:
|
|
|
|
super().validate_ordertypes(order_types)
|
|
|
|
|
|
|
|
if any(v == 'market' for k, v in order_types.items()):
|
|
|
|
raise OperationalException(
|
2022-03-09 06:45:50 +00:00
|
|
|
f'Exchange {self.name} does not support market orders.')
|
|
|
|
|
|
|
|
def fetch_stoploss_order(self, order_id: str, pair: str, params={}) -> Dict:
|
|
|
|
return self.fetch_order(
|
|
|
|
order_id=order_id,
|
|
|
|
pair=pair,
|
|
|
|
params={'stop': True}
|
|
|
|
)
|
|
|
|
|
|
|
|
def cancel_stoploss_order(self, order_id: str, pair: str, params={}) -> Dict:
|
|
|
|
return self.cancel_order(
|
|
|
|
order_id=order_id,
|
|
|
|
pair=pair,
|
|
|
|
params={'stop': True}
|
|
|
|
)
|
2022-03-13 02:14:23 +00:00
|
|
|
|
|
|
|
def stoploss_adjust(self, stop_loss: float, order: Dict) -> bool:
|
|
|
|
"""
|
|
|
|
Verify stop_loss against stoploss-order value (limit or price)
|
|
|
|
Returns True if adjustment is necessary.
|
|
|
|
"""
|
|
|
|
return stop_loss > float(order['stopPrice'])
|