File rpc.py
has 1204 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""
This module contains class to define a RPC communications
"""
import logging
from abc import abstractmethod
Function _rpc_status_table
has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring. Open
def _rpc_status_table(self, stake_currency: str,
fiat_display_currency: str) -> Tuple[List, List, float]:
trades: List[Trade] = Trade.get_open_trades()
nonspot = self._config.get('trading_mode', TradingMode.SPOT) != TradingMode.SPOT
if not 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 _rpc_trade_statistics
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
def _rpc_trade_statistics(
self, stake_currency: str, fiat_display_currency: str,
start_date: Optional[datetime] = None) -> Dict[str, Any]:
""" Returns cumulative profit statistics """
- 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 _rpc_trade_status
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
def _rpc_trade_status(self, trade_ids: Optional[List[int]] = None) -> List[Dict[str, Any]]:
"""
Below follows the RPC backend it is prefixed with rpc_ to raise awareness that it is
a remotely exposed function
"""
- 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 _rpc_balance
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def _rpc_balance(self, stake_currency: str, fiat_display_currency: str) -> Dict:
""" Returns current account balance per crypto """
currencies: List[Dict] = []
total = 0.0
total_bot = 0.0
- 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 __exec_force_exit
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def __exec_force_exit(self, trade: Trade, ordertype: Optional[str],
amount: Optional[float] = None) -> bool:
# Check if there is there are open orders
trade_entry_cancelation_registry = []
for oo in trade.open_orders:
- 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 _rpc_trade_statistics
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
def _rpc_trade_statistics(
self, stake_currency: str, fiat_display_currency: str,
start_date: Optional[datetime] = None) -> Dict[str, Any]:
""" Returns cumulative profit statistics """
Function _rpc_stats
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def _rpc_stats(self) -> Dict[str, Any]:
"""
Generate generic stats for trades in database
"""
def trade_win_loss(trade):
- 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 _rpc_balance
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def _rpc_balance(self, stake_currency: str, fiat_display_currency: str) -> Dict:
""" Returns current account balance per crypto """
currencies: List[Dict] = []
total = 0.0
total_bot = 0.0
Function __balance_get_est_stake
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def __balance_get_est_stake(
self, coin: str, stake_currency: str, amount: float,
balance: Wallet, tickers) -> Tuple[float, float]:
est_stake = 0.0
est_bot_stake = 0.0
- 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 _rpc_timeunit_profit
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def _rpc_timeunit_profit(
self, timescale: int,
stake_currency: str, fiat_display_currency: str,
timeunit: str = 'days') -> Dict[str, Any]:
"""
- 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 _rpc_force_entry
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def _rpc_force_entry(self, pair: str, price: Optional[float], *,
Avoid deeply nested control flow statements. Open
if not isnan(current_rate):
prof = trade.calculate_profit(current_rate)
current_profit = prof.profit_ratio
current_profit_abs = prof.profit_abs
total_profit_abs = prof.total_profit
Function _convert_dataframe_to_dict
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _convert_dataframe_to_dict(
Function _rpc_analysed_dataframe
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _rpc_analysed_dataframe(
Function _rpc_analysed_history_full
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _rpc_analysed_history_full(config: Config, pair: str, timeframe: str,
Function _rpc_add_lock
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _rpc_add_lock(
Function __balance_get_est_stake
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __balance_get_est_stake(
Function _rpc_force_exit
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _rpc_force_exit(self, trade_id: str, ordertype: Optional[str] = None, *,
amount: Optional[float] = None) -> Dict[str, str]:
"""
Handler for forceexit <id>.
Sells the given trade at current price
- 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 _force_entry_validations
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _force_entry_validations(self, pair: str, order_side: SignalDirection):
if not self._freqtrade.config.get('force_entry_enable', False):
raise RPCException('Force_entry not enabled.')
if self._freqtrade.state != State.RUNNING:
- 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"