2021-11-02 18:49:53 +00:00
|
|
|
import logging
|
2021-11-05 05:26:13 +00:00
|
|
|
from typing import Dict, List, Tuple
|
2021-11-02 18:49:53 +00:00
|
|
|
|
2021-11-05 05:26:13 +00:00
|
|
|
from freqtrade.enums import Collateral, TradingMode
|
2021-11-02 18:49:53 +00:00
|
|
|
from freqtrade.exchange import Exchange
|
|
|
|
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
class Okex(Exchange):
|
|
|
|
"""
|
|
|
|
Okex exchange class. Contains adjustments needed for Freqtrade to work
|
|
|
|
with this exchange.
|
|
|
|
"""
|
|
|
|
|
|
|
|
_ft_has: Dict = {
|
|
|
|
"ohlcv_candle_limit": 100,
|
|
|
|
}
|
2021-11-05 05:26:13 +00:00
|
|
|
|
|
|
|
_supported_trading_mode_collateral_pairs: List[Tuple[TradingMode, Collateral]] = [
|
|
|
|
# TradingMode.SPOT always supported and not required in this list
|
|
|
|
# (TradingMode.MARGIN, Collateral.CROSS), # TODO-lev: Uncomment once supported
|
|
|
|
# (TradingMode.FUTURES, Collateral.CROSS), # TODO-lev: Uncomment once supported
|
|
|
|
# (TradingMode.FUTURES, Collateral.ISOLATED) # TODO-lev: Uncomment once supported
|
|
|
|
]
|
|
|
|
|
|
|
|
@property
|
|
|
|
def _ccxt_config(self) -> Dict:
|
|
|
|
# Parameters to add directly to ccxt sync/async initialization.
|
|
|
|
if self.trading_mode == TradingMode.MARGIN:
|
|
|
|
return {
|
|
|
|
"options": {
|
|
|
|
"defaultType": "margin"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elif self.trading_mode == TradingMode.FUTURES:
|
|
|
|
return {
|
|
|
|
"options": {
|
|
|
|
"defaultType": "swap"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else:
|
|
|
|
return {}
|