INNER CODE UNIT · Python

precision

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

    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":
        price_matches = price2 <= price1 # Price can be at the exact level or closer to entry
    elif positionType=="Sell":
        price_matches = price2 >= price1 # Price can be at the exact level or closer to entry
    else:
        price_matches = price2 == price1
    size_matches = size1 == size2 or math.floor(size1 * 10)/10.0 == size2 or math.floor(size1 * 100)/100.0 == size2 or math.floor(size1 * 1000)/1000.0 == size2 or math.floor(size1 * 10000)/10000.0 == size2

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…