US stocks ride wave of earnings optimism