What keeps me optimistic is achieving a goal, whether it is big or small.
Riding on a bicycle, I always try to move forward and toward a destination, while enjoying the ride.
I find that the Austrian psychologist, Viktor Frankl, has a good logo-therapeutic approach toward how people form meaning in their lives. He wrote a book called, Man's Search For Meaning, which tells of his experiences in a concentration camp and how different types of people dealt with these tragic circumstances. Based on the horrific events, he developed his own ways for one to gain happiness and purpose in life, even if one undergoes horrendous times that cannot be changed. Frankl thought that people have the potential to form meaning and avoid existential despair, to improve their mentalities, even if the future seems bleak.
His book reminds me of the stoic philosopher, Epictetus, who often talked about how our views on things make things bad or good, rather than the things themselves being intrinsically bad or good. Epictetus spoke about focusing on what you can change, such as attitudes and behaviors, while not concerning yourself with what isn't changeable, such as death or reputation. Also, in Zen Buddhism, there's the mind-set of non-attachment to desires. By desiring a superficial thing with your ego, you are controlled by your desire to achieve that, but by trying to reject your desire, you are worse off. Your thoughts are not the whole of you. Instead of worrying or complaining about the future of what you want, focus on being in the present (with the right mindset, e.g compassion, discipline, truthfulness, etc.).