INNER CODE UNIT · Python

round_step_size

hadialaddin/crypto-genie · crypto-genie.py:151

def round_step_size(quantity: Union[float, Decimal], step_size: Union[float, Decimal], min_qty: Union[float, Decimal] = 0) -> float:
    """Rounds a given quantity to a specific step size
    :param quantity: required
    :param step_size: required
    :return: decimal
    """
    precision: int = int(round(-math.log(step_size, 10), 0))
    return float(round(quantity, precision)) if float(round(quantity, precision)) > min_qty else min_qty
    
def get_random_string(length):
    # choose from all lowercase letter
    letters = string.ascii_lowercase
    result_str = ''.join(random.choice(letters) for i in range(length))
    return result_str

def close_enough_match(price1, price2, size1, size2, positionType=False):
    # price1 is the fixed target and price2 is the dynamic one being checked
    if positionType=="Buy":

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…