Both is necessary to fulfill the natural/necessary desire for Eudaimonia, a life of Pleasure.
For Ataraxia and removal of Suffering/Pain we need to be active and pursue Pleasures prudently. To hide fearful of pain in a cave let you painfully starve full of agony.
To be a pure egoist let you live painfully. To be pure altruist let you live painfully.
To develop a Character full of Virtue(core phronesis) and love/friendship (philia) includes both: self interest + altruism and balances it which includes the motivation to lead a life of sustainable and optimal possible Pleasure for your life which you agree within yourself, Eudaimonia for which some kinds/ degree of pain and risk is worth it.