U.S. stocks posted a third straight weekly gain, pushing the market to within a whisker of an all-time high as trade tensions eased and strong data renewed optimism in the American economy’s strength.

The S&P 500 Index gained 1 percent, ending the week 0.6 percent below its July 26 record. The Dow Jones industrial average increased 1.6 percent to nearly 27,220, closing 139 points below its all-time high.

Equities have been rebounding from last month’s drop as economic data improved, political risks from Brexit to Hong Kong eased and face-to-face talks were set to resume in an effort to resolve the trade dispute with China. Global market sentiment this week also got a boost after Europe’s central bank announced a fresh round of stimulus. Meanwhile, futures traders see a virtual certainty that the Federal Reserve will reduce U.S. interest rates at the coming meeting.

Eight of the main 11 S&P 500 industry groups advanced this week. Financial, energy and materials stocks each gained more than 3 percent. Real estate was the worst-performing sector, declining 3.2 percent.

The U.S. Treasury will sell $45 billion of three-month bills and $42 billion of six-month bills on Sept. 16. They yielded 1.95% and 1.89%, respectively, in when-issued trading. It will also sell four-week bills, eight week bills and $12 billion of 10-year Treasury Inflation Protected Securities on Sept. 19.