mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
chore: type _ft_has
This commit is contained in:
parent
d49c556291
commit
964d437c7a
|
@ -11,7 +11,7 @@ from freqtrade.enums import CandleType, MarginMode, PriceType, TradingMode
|
|||
from freqtrade.exceptions import DDosProtection, OperationalException, TemporaryError
|
||||
from freqtrade.exchange import Exchange
|
||||
from freqtrade.exchange.common import retrier
|
||||
from freqtrade.exchange.exchange_types import OHLCVResponse, Tickers
|
||||
from freqtrade.exchange.exchange_types import FtHas, OHLCVResponse, Tickers
|
||||
from freqtrade.misc import deep_merge_dicts, json_load
|
||||
|
||||
|
||||
|
@ -19,7 +19,7 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
|
||||
class Binance(Exchange):
|
||||
_ft_has: Dict = {
|
||||
_ft_has: FtHas = {
|
||||
"stoploss_on_exchange": True,
|
||||
"stop_price_param": "stopPrice",
|
||||
"stop_price_prop": "stopPrice",
|
||||
|
@ -32,7 +32,7 @@ class Binance(Exchange):
|
|||
"l2_limit_range": [5, 10, 20, 50, 100, 500, 1000],
|
||||
"ws_enabled": True,
|
||||
}
|
||||
_ft_has_futures: Dict = {
|
||||
_ft_has_futures: FtHas = {
|
||||
"stoploss_order_types": {"limit": "stop", "market": "stop_market"},
|
||||
"order_time_in_force": ["GTC", "FOK", "IOC"],
|
||||
"tickers_have_price": False,
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
"""Bingx exchange subclass"""
|
||||
|
||||
import logging
|
||||
from typing import Dict
|
||||
|
||||
from freqtrade.exchange import Exchange
|
||||
from freqtrade.exchange.exchange_types import FtHas
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -15,7 +15,7 @@ class Bingx(Exchange):
|
|||
with this exchange.
|
||||
"""
|
||||
|
||||
_ft_has: Dict = {
|
||||
_ft_has: FtHas = {
|
||||
"ohlcv_candle_limit": 1000,
|
||||
"stoploss_on_exchange": True,
|
||||
"stoploss_order_types": {"limit": "limit", "market": "market"},
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
"""Bitmart exchange subclass"""
|
||||
|
||||
import logging
|
||||
from typing import Dict
|
||||
|
||||
from freqtrade.exchange import Exchange
|
||||
from freqtrade.exchange.exchange_types import FtHas
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -15,7 +15,7 @@ class Bitmart(Exchange):
|
|||
with this exchange.
|
||||
"""
|
||||
|
||||
_ft_has: Dict = {
|
||||
_ft_has: FtHas = {
|
||||
"stoploss_on_exchange": False, # Bitmart API does not support stoploss orders
|
||||
"ohlcv_candle_limit": 200,
|
||||
"trades_has_history": False, # Endpoint doesn't seem to support pagination
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
"""Bitvavo exchange subclass."""
|
||||
|
||||
import logging
|
||||
from typing import Dict
|
||||
|
||||
from ccxt import DECIMAL_PLACES
|
||||
|
||||
from freqtrade.exchange import Exchange
|
||||
from freqtrade.exchange.exchange_types import FtHas
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -21,7 +21,7 @@ class Bitvavo(Exchange):
|
|||
may still not work as expected.
|
||||
"""
|
||||
|
||||
_ft_has: Dict = {
|
||||
_ft_has: FtHas = {
|
||||
"ohlcv_candle_limit": 1440,
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ from freqtrade.enums import CandleType, MarginMode, PriceType, TradingMode
|
|||
from freqtrade.exceptions import DDosProtection, ExchangeError, OperationalException, TemporaryError
|
||||
from freqtrade.exchange import Exchange
|
||||
from freqtrade.exchange.common import retrier
|
||||
from freqtrade.exchange.exchange_types import FtHas
|
||||
from freqtrade.util.datetime_helpers import dt_now, dt_ts
|
||||
|
||||
|
||||
|
@ -29,14 +30,14 @@ class Bybit(Exchange):
|
|||
|
||||
unified_account = False
|
||||
|
||||
_ft_has: Dict = {
|
||||
_ft_has: FtHas = {
|
||||
"ohlcv_candle_limit": 1000,
|
||||
"ohlcv_has_history": True,
|
||||
"order_time_in_force": ["GTC", "FOK", "IOC", "PO"],
|
||||
"ws_enabled": True,
|
||||
"trades_has_history": False, # Endpoint doesn't support pagination
|
||||
}
|
||||
_ft_has_futures: Dict = {
|
||||
_ft_has_futures: FtHas = {
|
||||
"ohlcv_has_history": True,
|
||||
"mark_ohlcv_timeframe": "4h",
|
||||
"funding_fee_timeframe": "8h",
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
"""CoinbasePro exchange subclass"""
|
||||
|
||||
import logging
|
||||
from typing import Dict
|
||||
|
||||
from freqtrade.exchange import Exchange
|
||||
from freqtrade.exchange.exchange_types import FtHas
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -19,6 +19,6 @@ class Coinbasepro(Exchange):
|
|||
may still not work as expected.
|
||||
"""
|
||||
|
||||
_ft_has: Dict = {
|
||||
_ft_has: FtHas = {
|
||||
"ohlcv_candle_limit": 300,
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
"""Crypto.com exchange subclass"""
|
||||
|
||||
import logging
|
||||
from typing import Dict
|
||||
|
||||
from freqtrade.exchange import Exchange
|
||||
from freqtrade.exchange.exchange_types import FtHas
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -14,6 +14,6 @@ class Cryptocom(Exchange):
|
|||
Contains adjustments needed for Freqtrade to work with this exchange.
|
||||
"""
|
||||
|
||||
_ft_has: Dict = {
|
||||
_ft_has: FtHas = {
|
||||
"ohlcv_candle_limit": 300,
|
||||
}
|
||||
|
|
|
@ -70,6 +70,7 @@ from freqtrade.exchange.common import (
|
|||
from freqtrade.exchange.exchange_types import (
|
||||
CcxtBalances,
|
||||
CcxtPosition,
|
||||
FtHas,
|
||||
OHLCVResponse,
|
||||
OrderBook,
|
||||
Ticker,
|
||||
|
@ -122,10 +123,11 @@ class Exchange:
|
|||
# Dict to specify which options each exchange implements
|
||||
# This defines defaults, which can be selectively overridden by subclasses using _ft_has
|
||||
# or by specifying them in the configuration.
|
||||
_ft_has_default: Dict = {
|
||||
_ft_has_default: FtHas = {
|
||||
"stoploss_on_exchange": False,
|
||||
"stop_price_param": "stopLossPrice", # Used for stoploss_on_exchange request
|
||||
"stop_price_prop": "stopLossPrice", # Used for stoploss_on_exchange response parsing
|
||||
"stoploss_order_types": {},
|
||||
"order_time_in_force": ["GTC"],
|
||||
"ohlcv_params": {},
|
||||
"ohlcv_candle_limit": 500,
|
||||
|
@ -156,8 +158,8 @@ class Exchange:
|
|||
# Expected to be in the format {"fetchOHLCV": True} or {"fetchOHLCV": False}
|
||||
"ws_enabled": False, # Set to true for exchanges with tested websocket support
|
||||
}
|
||||
_ft_has: Dict = {}
|
||||
_ft_has_futures: Dict = {}
|
||||
_ft_has: FtHas = {}
|
||||
_ft_has_futures: FtHas = {}
|
||||
|
||||
_supported_trading_mode_margin_pairs: List[Tuple[TradingMode, MarginMode]] = [
|
||||
# TradingMode.SPOT always supported and not required in this list
|
||||
|
@ -466,7 +468,7 @@ class Exchange:
|
|||
"""
|
||||
return int(
|
||||
self._ft_has.get("ohlcv_candle_limit_per_timeframe", {}).get(
|
||||
timeframe, self._ft_has.get("ohlcv_candle_limit")
|
||||
timeframe, str(self._ft_has.get("ohlcv_candle_limit"))
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -3,6 +3,53 @@ from typing import Dict, List, Optional, Tuple, TypedDict
|
|||
from freqtrade.enums import CandleType
|
||||
|
||||
|
||||
class FtHas(TypedDict, total=False):
|
||||
order_time_in_force: List[str]
|
||||
exchange_has_overrides: Dict[str, bool]
|
||||
marketOrderRequiresPrice: bool
|
||||
|
||||
# Stoploss on exchange
|
||||
stoploss_on_exchange: bool
|
||||
stop_price_param: str
|
||||
stop_price_prop: str
|
||||
stop_price_type_field: str
|
||||
stop_price_type_value_mapping: Dict
|
||||
stoploss_order_types: Dict[str, str]
|
||||
# ohlcv
|
||||
ohlcv_params: Dict
|
||||
ohlcv_candle_limit: int
|
||||
ohlcv_has_history: bool
|
||||
ohlcv_partial_candle: bool
|
||||
ohlcv_require_since: bool
|
||||
ohlcv_volume_currency: str
|
||||
ohlcv_candle_limit_per_timeframe: Dict[str, int]
|
||||
# Tickers
|
||||
tickers_have_quoteVolume: bool
|
||||
tickers_have_percentage: bool
|
||||
tickers_have_bid_ask: bool
|
||||
tickers_have_price: bool
|
||||
# Trades
|
||||
trades_limit: int
|
||||
trades_pagination: str
|
||||
trades_pagination_arg: str
|
||||
trades_has_history: bool
|
||||
trades_pagination_overlap: bool
|
||||
# Orderbook
|
||||
l2_limit_range: Optional[List[int]]
|
||||
l2_limit_range_required: bool
|
||||
# Futures
|
||||
ccxt_futures_name: str # usually swap
|
||||
mark_ohlcv_price: str
|
||||
mark_ohlcv_timeframe: str
|
||||
funding_fee_timeframe: str
|
||||
floor_leverage: bool
|
||||
needs_trading_fees: bool
|
||||
order_props_in_contracts: List[str]
|
||||
|
||||
# Websocket control
|
||||
ws_enabled: bool
|
||||
|
||||
|
||||
class Ticker(TypedDict):
|
||||
symbol: str
|
||||
ask: Optional[float]
|
||||
|
|
|
@ -7,6 +7,7 @@ from typing import Any, Dict, List, Optional, Tuple
|
|||
from freqtrade.constants import BuySell
|
||||
from freqtrade.enums import MarginMode, PriceType, TradingMode
|
||||
from freqtrade.exchange import Exchange
|
||||
from freqtrade.exchange.exchange_types import FtHas
|
||||
from freqtrade.misc import safe_value_fallback2
|
||||
|
||||
|
||||
|
@ -23,7 +24,7 @@ class Gate(Exchange):
|
|||
may still not work as expected.
|
||||
"""
|
||||
|
||||
_ft_has: Dict = {
|
||||
_ft_has: FtHas = {
|
||||
"ohlcv_candle_limit": 1000,
|
||||
"order_time_in_force": ["GTC", "IOC"],
|
||||
"stoploss_on_exchange": True,
|
||||
|
@ -34,7 +35,7 @@ class Gate(Exchange):
|
|||
"trades_has_history": False, # Endpoint would support this - but ccxt doesn't.
|
||||
}
|
||||
|
||||
_ft_has_futures: Dict = {
|
||||
_ft_has_futures: FtHas = {
|
||||
"needs_trading_fees": True,
|
||||
"marketOrderRequiresPrice": False,
|
||||
"stop_price_type_field": "price_type",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import logging
|
||||
from typing import Dict
|
||||
|
||||
from freqtrade.exchange import Exchange
|
||||
from freqtrade.exchange.exchange_types import FtHas
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -17,6 +17,6 @@ class Hitbtc(Exchange):
|
|||
may still not work as expected.
|
||||
"""
|
||||
|
||||
_ft_has: Dict = {
|
||||
_ft_has: FtHas = {
|
||||
"ohlcv_candle_limit": 1000,
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ from typing import Dict
|
|||
|
||||
from freqtrade.constants import BuySell
|
||||
from freqtrade.exchange import Exchange
|
||||
from freqtrade.exchange.exchange_types import FtHas
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -16,7 +17,7 @@ class Htx(Exchange):
|
|||
with this exchange.
|
||||
"""
|
||||
|
||||
_ft_has: Dict = {
|
||||
_ft_has: FtHas = {
|
||||
"stoploss_on_exchange": True,
|
||||
"stop_price_param": "stopPrice",
|
||||
"stop_price_prop": "stopPrice",
|
||||
|
|
|
@ -7,6 +7,7 @@ from ccxt import SIGNIFICANT_DIGITS
|
|||
|
||||
from freqtrade.enums import TradingMode
|
||||
from freqtrade.exchange import Exchange
|
||||
from freqtrade.exchange.exchange_types import FtHas
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -17,7 +18,7 @@ class Hyperliquid(Exchange):
|
|||
Contains adjustments needed for Freqtrade to work with this exchange.
|
||||
"""
|
||||
|
||||
_ft_has: Dict = {
|
||||
_ft_has: FtHas = {
|
||||
# Only the most recent 5000 candles are available according to the
|
||||
# exchange's API documentation.
|
||||
"ohlcv_has_history": False,
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
"""Idex exchange subclass"""
|
||||
|
||||
import logging
|
||||
from typing import Dict
|
||||
|
||||
from freqtrade.exchange import Exchange
|
||||
from freqtrade.exchange.exchange_types import FtHas
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -15,6 +15,6 @@ class Idex(Exchange):
|
|||
with this exchange.
|
||||
"""
|
||||
|
||||
_ft_has: Dict = {
|
||||
_ft_has: FtHas = {
|
||||
"ohlcv_candle_limit": 1000,
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ from freqtrade.enums import MarginMode, TradingMode
|
|||
from freqtrade.exceptions import DDosProtection, OperationalException, TemporaryError
|
||||
from freqtrade.exchange import Exchange
|
||||
from freqtrade.exchange.common import retrier
|
||||
from freqtrade.exchange.exchange_types import CcxtBalances, Tickers
|
||||
from freqtrade.exchange.exchange_types import CcxtBalances, FtHas, Tickers
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -20,7 +20,7 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
class Kraken(Exchange):
|
||||
_params: Dict = {"trading_agreement": "agree"}
|
||||
_ft_has: Dict = {
|
||||
_ft_has: FtHas = {
|
||||
"stoploss_on_exchange": True,
|
||||
"stop_price_param": "stopLossPrice",
|
||||
"stop_price_prop": "stopLossPrice",
|
||||
|
|
|
@ -5,6 +5,7 @@ from typing import Dict
|
|||
|
||||
from freqtrade.constants import BuySell
|
||||
from freqtrade.exchange import Exchange
|
||||
from freqtrade.exchange.exchange_types import FtHas
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -20,7 +21,7 @@ class Kucoin(Exchange):
|
|||
may still not work as expected.
|
||||
"""
|
||||
|
||||
_ft_has: Dict = {
|
||||
_ft_has: FtHas = {
|
||||
"stoploss_on_exchange": True,
|
||||
"stop_price_param": "stopPrice",
|
||||
"stop_price_prop": "stopPrice",
|
||||
|
|
|
@ -14,6 +14,7 @@ from freqtrade.exceptions import (
|
|||
)
|
||||
from freqtrade.exchange import Exchange, date_minus_candles
|
||||
from freqtrade.exchange.common import retrier
|
||||
from freqtrade.exchange.exchange_types import FtHas
|
||||
from freqtrade.misc import safe_value_fallback2
|
||||
from freqtrade.util import dt_now, dt_ts
|
||||
|
||||
|
@ -27,7 +28,7 @@ class Okx(Exchange):
|
|||
Contains adjustments needed for Freqtrade to work with this exchange.
|
||||
"""
|
||||
|
||||
_ft_has: Dict = {
|
||||
_ft_has: FtHas = {
|
||||
"ohlcv_candle_limit": 100, # Warning, special case with data prior to X months
|
||||
"mark_ohlcv_timeframe": "4h",
|
||||
"funding_fee_timeframe": "8h",
|
||||
|
@ -36,7 +37,7 @@ class Okx(Exchange):
|
|||
"trades_has_history": False, # Endpoint doesn't have a "since" parameter
|
||||
"ws_enabled": True,
|
||||
}
|
||||
_ft_has_futures: Dict = {
|
||||
_ft_has_futures: FtHas = {
|
||||
"tickers_have_quoteVolume": False,
|
||||
"stop_price_type_field": "slTriggerPxType",
|
||||
"stop_price_type_value_mapping": {
|
||||
|
|
Loading…
Reference in New Issue
Block a user