Tick Size Calculation in Python for Indian Stock Market


import math

def roundup(x,ticksize):
    return math.ceil(x/ticksize)*ticksize
def rounddown(x,ticksize):
    return math.floor(x/ticksize)*ticksize
def roundtick(x,ticksize):
    return round(x/ticksize)*ticksize

ticksize=0.05
print(roundup(1.27,ticksize))
print(rounddown(1.27,ticksize))
print(roundtick(1.27,ticksize))