I go by this strategy. Always expect the best, but be ready for the worst. Being an optimist, this helps keep me in the view of all possibilities. Good and bad.
If I’m working on something, I’ll give my best and assume/expect it to fetch me the desired result. But also, have it in the back of my mind, that this might not go my way. I’m always prepared for the worst.
Probably that’s the reason, things don’t knock me off, however bad they might be. I’m always ready to battle with the worst, even if all I was expecting was a win.