File exchange.py
has 2599 lines of code (exceeds 250 allowed). Consider refactoring. Open
# pragma pylint: disable=W0603
"""
Cryptocurrency Exchanges support
"""
import asyncio
Exchange
has 34 functions (exceeds 20 allowed). Consider refactoring. Open
class Exchange:
# Parameters to add directly to buy/sell calls (like agreeing to trading agreement)
_params: Dict = {}
Function __init__
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
def __init__(self, config: Config, *, exchange_config: Optional[ExchangeConfig] = None,
validate: bool = True, load_leverage_tiers: bool = False) -> None:
"""
Initializes this module with the given config,
it does basic validation whether the specified exchange and pairs are valid.
Function get_liquidation_price
has 15 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_liquidation_price(
Function dry_run_liquidation_price
has 14 arguments (exceeds 4 allowed). Consider refactoring. Open
def dry_run_liquidation_price(
Function create_order
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_order(
Function create_dry_run_order
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_dry_run_order(self, pair: str, ordertype: str, side: str, amount: float,
Function _order_contracts_to_amount
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def _order_contracts_to_amount(self, order: Dict) -> Dict:
if 'symbol' in order and order['symbol'] is not None:
contract_size = self.get_contract_size(order['symbol'])
if contract_size != 1:
for prop in self._ft_has.get('order_props_in_contracts', []):
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function _process_ohlcv_df
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def _process_ohlcv_df(self, pair: str, timeframe: str, c_type: CandleType, ticks: List[List],
Function _get_rate_from_ob
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def _get_rate_from_ob(self, pair: str, side: EntryExit, order_book: OrderBook, name: str,
Function get_historic_ohlcv
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_historic_ohlcv(self, pair: str, timeframe: str,
Function get_rate
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_rate(self, pair: str, refresh: bool,
Function create_stoploss
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_stoploss(self, pair: str, amount: float, stop_price: float, order_types: Dict,
Function get_fee
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_fee(self, symbol: str, type: str = '', side: str = '', amount: float = 1,
Function calculate_funding_fees
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def calculate_funding_fees(
Function get_markets
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_markets(
Function get_dry_market_fill_price
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_dry_market_fill_price(self, pair: str, side: str, amount: float, rate: float,
Function _get_params
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _get_params(
Function _get_stake_amount_limit
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _get_stake_amount_limit(
Function _build_coroutine
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _build_coroutine(
Function market_is_tradable
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def market_is_tradable(self, market: Dict[str, Any]) -> bool:
"""
Check if the market symbol is tradable by Freqtrade.
Ensures that Configured mode aligns to
"""
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function _dry_is_price_crossed
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _dry_is_price_crossed(self, pair: str, side: str, limit: float,
Function refresh_latest_ohlcv
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def refresh_latest_ohlcv(self, pair_list: ListPairsWithTimeframes, *,
Function _fetch_and_calculate_funding_fees
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _fetch_and_calculate_funding_fees(
Function __init__
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, config: Config, *, exchange_config: Optional[ExchangeConfig] = None,
validate: bool = True, load_leverage_tiers: bool = False) -> None:
"""
Initializes this module with the given config,
it does basic validation whether the specified exchange and pairs are valid.
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function get_markets
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
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,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function price_to_precision
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def price_to_precision(self, pair: str, price: float, *, rounding_mode: int = ROUND) -> float:
Function calculate_fee_rate
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def calculate_fee_rate(
Function set_margin_mode
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def set_margin_mode(self, pair: str, margin_mode: MarginMode, accept_fail: bool = False,
Function _get_rate_from_ticker
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _get_rate_from_ticker(self, side: EntryExit, ticker: Ticker, conf_strategy: Dict[str, Any],
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, config: Config, *, exchange_config: Optional[ExchangeConfig] = None,
Function _lev_prep
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _lev_prep(self, pair: str, leverage: float, side: BuySell, accept_fail: bool = False):
Function get_trades_for_order
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_trades_for_order(self, order_id: str, pair: str, since: datetime,
Function extract_cost_curr_rate
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def extract_cost_curr_rate(self, fee: Dict, symbol: str, cost: float,
Function get_historic_trades
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_historic_trades(self, pair: str,
Function get_funding_fees
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_funding_fees(
Function get_min_pair_stake_amount
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_min_pair_stake_amount(
Function _trades_contracts_to_amount
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _trades_contracts_to_amount(self, trades: List) -> List:
if len(trades) > 0 and 'symbol' in trades[0]:
contract_size = self.get_contract_size(trades[0]['symbol'])
if contract_size != 1:
for trade in trades:
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function _init_ccxt
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _init_ccxt(self, exchange_config: Dict[str, Any], ccxt_module: CcxtModuleType = ccxt, *,
ccxt_kwargs: Dict) -> ccxt.Exchange:
"""
Initialize ccxt with given config and return valid
ccxt instance.
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function get_contract_size
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_contract_size(self, pair: str) -> Optional[float]:
if self.trading_mode == TradingMode.FUTURES:
market = self.markets.get(pair, {})
contract_size: float = 1.0
if not market:
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"