BUG: Fix div-by-zero error in cost_basis adjustment.