LONDON- The dollar gained for a second consecutive day on Tuesday as fading optimism over the latest China-U.S. trade truce prompted traders to buy the greenback after a selloff last week.

The greenback had come under selling pressure recently as the combination of some tepid U.S. data and hopes of a breakthrough in a protracted trade conflict between Washington and Beijing prompted funds to unwind some of their extreme dollar long bets.

"After the recent flushout of dollar long bets, currency investors have reassessed the short-term outlook and have come to the view that there is not going to be much of a movement on the trade issue," said Stephen Gallo, European Head of FX Strategy at BMO.

Reports of a "Phase 1" trade deal between the United States and China last week had earlier cheered markets but the dearth of details around the agreement has since curbed this enthusiasm with oil prices extending declines, Chinese stocks weaker and the safe-haven yen holding gains versus dollar.

Against a broad basket of its rivals, the dollar strengthened for a second day and was up 0.1% to 98.55 and around 1% away from a near 2-1/2 year high of 99.67 hit earlier this month.

While the dollar was over-valued on a trade-weighted basis, analysts at ING argued the greenback's valuation was not stretched in a historical context and suggested there was still scope for further dollar gains should the global trade outlook worsen.

Fading hopes over a trade deal also pulled the Chinese currency lower.

China's yuan slipped in offshore markets, a day after reaching a one-month high. The offshore yuan traded at 7.0787 against the dollar, off Monday's high of 7.0503.

Though a monthly survey showed the mood among German investors worsened less in October than expectations, the euro failed to get much of a boost from the data with the single currency down 0.2% at $1.1007.

Elsewhere, sterling trimmed some of its earlier gains as officials raced towards putting a Brexit deal in place by the end of Tuesday.

Britain's latest proposals on the terms of its departure from the European Union are still not enough for an agreement and a legal text is needed by the end of Tuesday for a deal to be agreed at a leaders' summit this week, three diplomatic sources said. 

The pound was up 0.3% at $1.2646, trimming some of its gains after being up nearly 0.7% in early London trading.

(Additional reporting by Saikat Chatterjee; Editing by Deepa Babington) ((thomas.wilkes@thomsonreuters.com))