Oil extends gains as optimism over US stimulus lifts global markets