Bug in calculation of value_before_trade