2021-11-09 10:31:54 +00:00
|
|
|
"""Kucoin exchange subclass."""
|
2021-04-13 10:28:07 +00:00
|
|
|
import logging
|
|
|
|
from typing import Dict
|
|
|
|
|
|
|
|
from freqtrade.exchange import Exchange
|
|
|
|
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
class Kucoin(Exchange):
|
2021-11-09 10:31:54 +00:00
|
|
|
"""Kucoin exchange class.
|
|
|
|
|
|
|
|
Contains adjustments needed for Freqtrade to work with this exchange.
|
2021-04-13 10:28:07 +00:00
|
|
|
|
|
|
|
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 = {
|
2022-02-03 06:57:58 +00:00
|
|
|
"stoploss_on_exchange": True,
|
|
|
|
"stoploss_order_types": {"limit": "limit", "market": "market"},
|
2021-04-13 10:28:07 +00:00
|
|
|
"l2_limit_range": [20, 100],
|
|
|
|
"l2_limit_range_required": False,
|
2022-08-27 08:24:56 +00:00
|
|
|
"order_time_in_force": ['GTC', 'FOK', 'IOC'],
|
2022-03-29 14:23:45 +00:00
|
|
|
"ohlcv_candle_limit": 1500,
|
2021-04-13 10:28:07 +00:00
|
|
|
}
|
2022-02-03 06:57:58 +00:00
|
|
|
|
2022-03-04 06:07:34 +00:00
|
|
|
def stoploss_adjust(self, stop_loss: float, order: Dict, side: str) -> bool:
|
2022-02-03 06:57:58 +00:00
|
|
|
"""
|
|
|
|
Verify stop_loss against stoploss-order value (limit or price)
|
|
|
|
Returns True if adjustment is necessary.
|
|
|
|
"""
|
2022-06-22 04:30:30 +00:00
|
|
|
return (
|
|
|
|
order.get('stopPrice', None) is None
|
|
|
|
or stop_loss > float(order['stopPrice'])
|
|
|
|
)
|
2022-02-03 06:57:58 +00:00
|
|
|
|
|
|
|
def _get_stop_params(self, ordertype: str, stop_price: float) -> Dict:
|
|
|
|
|
|
|
|
params = self._params.copy()
|
|
|
|
params.update({
|
|
|
|
'stopPrice': stop_price,
|
|
|
|
'stop': 'loss'
|
|
|
|
})
|
|
|
|
return params
|