S&P 500 posts second losing week as oil, tariffs, tech weigh on markets