# Takes two inputs. # Two small floats. # Example, price = 0.03403234, vol= 0.0025 # for given price and volume. calulate the next valid price for same volume by incrementing price # smallet increment is in price can only be 0.00000001 def calc(price, vol): inc = 0.000000010 exp = 8 p = price v = vol i = 0 while True: i+=1 p += inc # If the sum have any fractions|desimals larger than 0 then its not valid. sum = format(float(v) * (float(p) * 10 ** exp),'.8f') x = int(sum.split(".")[1]) if x == 0: return [int(float(sum)), p] # Takes to long i guess, just return zero if i > 10000: return [0,0] vol = 0.0025 old_price = 0.03403234 res = calc(old_price, vol) print("vol :", format(vol, '.8f')) print("old price:", format(old_price, '.8f')) print("new price:", format(r[1], '.8f'))