Gold books a loss as stocks, dollar rally