Local stocks eke out gains on bargain hunting