The error originates in `_calc_amount()` where `nan` is returned, thereby causing `_is_profitable()` to return `False` by default.