Back to problems

Round Price to Nearest Valid Tick

Algorithm · Akuna Capital · Medium

Requirements Price levels for instruments are specified by bands. Each band has a lower limit, an upper limit, and a tick width. Given a raw price, convert it to the appropriate valid tick as follows: When the price is lower than the minimum permitted price, return that minimum price. When the price lies within a band [low, high], return the value low + n * width whose distance from the price, abs(price - (low + n * width)), is smallest. Since prices are commonly represented…

Checking your access…