US stocks end higher amid optimism over consumer confidence