Welcome to the pricing utilities team. This module rounds a price (integer cents) to the nearest tick size (integer cents); ties round up to the larger multiple.
Welcome to the pricing utilities team. This module rounds a price (integer cents) to the nearest tick size (integer cents); ties round up to the larger multiple.
There is one ticket below. Fix as much of it as you can in 35 minutes. It is graded by several separate checks, so each part of the behaviour you get right counts.
Prices are always rounding down. nearest_multiple uses floor division, so a price above a tick is pulled down to the tick below instead of to the nearest one.
round_to_tick(103, 5) is 105 and round_to_tick(108, 5) is 110.round_to_tick(1025, 50) is 1050.Keep the public function round_to_tick.
rounding.py (nearest_multiple: round to the nearest multiple of a step) and tick.py (round_to_tick). The shipped regression tests are in tests/visible/; every one of them fails until the bug is fixed.pytest tests/visible.Adapted from treasure567/bloomberg-practice (round-1/tundra @ 8de07d5), used with the author's permission.
Visible test command
pytest tests/visibleThe repository’s own tests. Run all tests includes them, and so does every submission.
Repository
tick-rounding-always-rounds-down
Changes under src/ are evaluated.