Oil closed at a three-week high as U.S. negotiators touted progress in trade talks with China and investors gained faith that OPEC will shrink output. Futures rose 2.6 percent to almost $50 a barrel in New York on Tuesday. Talks with China are \u201c going very wel l,\u201d U.S. President Donald Trump said in a tweet as the delegations in Beijing extended their meeting into Wednesday. Meanwhile, a post-market industry report was said to report substantial increases in American gasoline and diesel inventories, a bearish signal for crude demand. \u201cThe market is clearly rebounding from sharply oversold territory,\u201d said Michael Tran, commodities strategist at RBC Capital Markets LLC. \u201cThe macro outlook looks and feels a lot less dire than it did just a couple of weeks ago.\u201d Oil hasn\u2019t had this long a run of daily increases since the summer of 2017. Prices have advanced almost 12 percent in the last seven sessions, undoing almost half of 2018\u2019s full-year loss. The rally\u2019s been fueled by brightening economic outlooks as well as growing confidence that the Organization of Petroleum Exporting Countries, Russia and other allies will restrain production enough to avoid an oversupply. West Texas Intermediate for February delivery traded up $1.26 to settle at $49.78 on the New York Mercantile Exchange, the highest close since Dec. 17. Prices dipped to $49.70 within minutes of the American Petroleum Institute\u2019s weekly tally of oil and fuel stockpiles. The API was also said to report that U.S. crude inventories fell by 6.13 million barrels last week. A separate government report scheduled for release on Wednesday is expected to show American crude stockpiles declined by 2.7 million barrels last week, according to the median estimate in a survey of analysts by Bloomberg. Brent for March settlement gained 2.4 percent to settle at $58.72 on the ICE Futures Europe Exchange in London. The global benchmark crude traded at an $8.61 a barrel premium to WTI for the same month.