File optimal_buy_cbpro.py
has 399 lines of code (exceeds 250 allowed). Consider refactoring. Open
#!/usr/bin/env python3
import cbpro
import argparse
import sys
Function get_fiat_balances
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def get_fiat_balances(args, coins, accounts, withdrawn_balances, prices):
balances = {}
for a in accounts:
if a["currency"] == args.fiat_currency:
balances[args.fiat_currency] = float(a["balance"])
- 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 main
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def main():
default_coins = """
{
"BTC":{
"name":"Bitcoin",
Function start_buy_orders
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def start_buy_orders(
Function place_buy_orders
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def place_buy_orders(args, amount_to_buy, coins, coin, price, cbpro_client, db_session):
Function set_buy_order
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def set_buy_order(args, coin, price, size, cbpro_client, db_session):
Function execute_withdrawal
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def execute_withdrawal(cbpro_client, amount, currency, crypto_address, db_session):
Function generate_buy_orders
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def generate_buy_orders(coins, coin, args, amount_to_buy, price):
Function get_fiat_balances
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_fiat_balances(args, coins, accounts, withdrawn_balances, prices):
Function start_buy_orders
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def start_buy_orders(
args, coins, accounts, prices, fiat_balances, fiat_amount, cbpro_client, db_session
):
weights = get_weights(coins, args.fiat_currency)
- 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 withdraw
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def withdraw(coins, accounts, cbpro_client, db_session):
for coin in coins:
if (
"withdrawal_address" not in coins[coin]
or coins[coin]["withdrawal_address"] is None
- 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 main
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def main():
default_coins = """
{
"BTC":{
"name":"Bitcoin",
- 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"