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