Reduce some mutable default argument usage

This commit is contained in:
Matthias
2024-04-20 09:17:25 +02:00
parent 8004829696
commit 31f6030c67
+10 -5
View File
@@ -239,8 +239,8 @@ class Exchange:
self.validate_pricing(config['exit_pricing']) self.validate_pricing(config['exit_pricing'])
self.validate_pricing(config['entry_pricing']) self.validate_pricing(config['entry_pricing'])
def _init_ccxt(self, exchange_config: Dict[str, Any], ccxt_module: CcxtModuleType = ccxt, def _init_ccxt(self, exchange_config: Dict[str, Any], ccxt_module: CcxtModuleType = ccxt, *,
ccxt_kwargs: Dict = {}) -> ccxt.Exchange: ccxt_kwargs: Dict) -> ccxt.Exchange:
""" """
Initialize ccxt with given config and return valid Initialize ccxt with given config and return valid
ccxt instance. ccxt instance.
@@ -348,7 +348,10 @@ class Exchange:
return int(self._ft_has.get('ohlcv_candle_limit_per_timeframe', {}).get( return int(self._ft_has.get('ohlcv_candle_limit_per_timeframe', {}).get(
timeframe, self._ft_has.get('ohlcv_candle_limit'))) timeframe, self._ft_has.get('ohlcv_candle_limit')))
def get_markets(self, base_currencies: List[str] = [], quote_currencies: List[str] = [], def get_markets(
self,
base_currencies: Optional[List[str]] = None,
quote_currencies: Optional[List[str]] = None,
spot_only: bool = False, margin_only: bool = False, futures_only: bool = False, spot_only: bool = False, margin_only: bool = False, futures_only: bool = False,
tradable_only: bool = True, tradable_only: bool = True,
active_only: bool = False) -> Dict[str, Any]: active_only: bool = False) -> Dict[str, Any]:
@@ -848,7 +851,7 @@ class Exchange:
# Dry-run methods # Dry-run methods
def create_dry_run_order(self, pair: str, ordertype: str, side: str, amount: float, def create_dry_run_order(self, pair: str, ordertype: str, side: str, amount: float,
rate: float, leverage: float, params: Dict = {}, rate: float, leverage: float, params: Optional[Dict] = None,
stop_loss: bool = False) -> Dict[str, Any]: stop_loss: bool = False) -> Dict[str, Any]:
now = dt_now() now = dt_now()
order_id = f'dry_run_{side}_{pair}_{now.timestamp()}' order_id = f'dry_run_{side}_{pair}_{now.timestamp()}'
@@ -2786,7 +2789,7 @@ class Exchange:
@retrier @retrier
def set_margin_mode(self, pair: str, margin_mode: MarginMode, accept_fail: bool = False, def set_margin_mode(self, pair: str, margin_mode: MarginMode, accept_fail: bool = False,
params: dict = {}): params: Optional[Dict] = None):
""" """
Set's the margin mode on the exchange to cross or isolated for a specific pair Set's the margin mode on the exchange to cross or isolated for a specific pair
:param pair: base/quote currency pair (e.g. "ADA/USDT") :param pair: base/quote currency pair (e.g. "ADA/USDT")
@@ -2795,6 +2798,8 @@ class Exchange:
# Some exchanges only support one margin_mode type # Some exchanges only support one margin_mode type
return return
if params is None:
params = {}
try: try:
res = self._api.set_margin_mode(margin_mode.value, pair, params) res = self._api.set_margin_mode(margin_mode.value, pair, params)
self._log_exchange_response('set_margin_mode', res) self._log_exchange_response('set_margin_mode', res)