<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def iq_query(self, message: str):
 """Send data query to IQFeed API."""

        end_msg = '!ENDMSG!'
        recv_buffer = 4096

        # Send the historical data request message and buffer the data
        self._send_cmd(message)

        chunk = ""
        data = ""
        while True:
            chunk = self._sock.recv(recv_buffer).decode('latin-1')
            data += chunk
            if chunk.startswith('E,'):  # error condition
                if chunk.startswith('E,!NO_DATA!'):
                    log.warn('No data available for the given symbol or dates')
                    return
                else:
                    raise Exception(chunk)
            elif end_msg in chunk:
                break

        # Clean up the data.
        data = data[:-1 * (len(end_msg) + 3)]
        data = "".join(data.split("\r"))
        data = data.replace(",\n", ",")[:-1]
        data = data.split(",")
        return data