def round_price(self, tick_size): if tick_size: with decimal_rounding_floor(): self.limit_price = float( (Decimal(self.limit_price) / Decimal(tick_size)).to_integral() * Decimal(tick_size)) else: user_system_log.warn('Invalid tick size: {}'.format(tick_size))
def round_price(self, tick_size): if tick_size: with decimal_rounding_floor(): limit_price_decimal = Decimal("{:.4f}".format(self.limit_price)) tick_size_decimal = Decimal("{:.4f}".format(tick_size)) self.limit_price = float((limit_price_decimal / tick_size_decimal).to_integral() * tick_size_decimal) else: user_system_log.warn('Invalid tick size: {}'.format(tick_size))
def round_price(self, tick_size): if tick_size: with decimal_rounding_floor(): self.limit_price = float((Decimal(self.limit_price) / Decimal(tick_size)).to_integral() * Decimal(tick_size)) else: user_system_log.warn('Invalid tick size: {}'.format(tick_size))