stable/freqtrade/exchange/gateio.py

54 lines
1.7 KiB
Python
Raw Normal View History

""" Gate.io exchange subclass """
import logging
2022-01-12 03:22:55 +00:00
from typing import Dict, List, Optional, Tuple
from freqtrade.enums import Collateral, TradingMode
from freqtrade.exceptions import OperationalException
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",
}
2021-09-16 04:28:10 +00:00
_headers = {'X-Gate-Channel-Id': 'freqtrade'}
_supported_trading_mode_collateral_pairs: List[Tuple[TradingMode, Collateral]] = [
# TradingMode.SPOT always supported and not required in this list
2021-11-14 01:45:41 +00:00
# (TradingMode.MARGIN, Collateral.CROSS),
# (TradingMode.FUTURES, Collateral.CROSS),
(TradingMode.FUTURES, Collateral.ISOLATED)
]
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(
2021-10-13 23:56:40 +00:00
f'Exchange {self.name} does not support market orders.')
2022-01-12 03:22:55 +00:00
def get_maintenance_ratio_and_amt(
self,
pair: str,
nominal_value: Optional[float] = 0.0,
) -> Tuple[float, Optional[float]]:
"""
:return: The maintenance margin ratio and maintenance amount
"""
2022-01-12 03:22:55 +00:00
info = self.markets[pair]['info']
return (float(info['maintenance_rate']), None)