Buy/sell price difference CDFs

What’s the best way to avoid this situation in the future?