# Buggy code
def query(
    self,
    querystr: str,
    param_types: Optional[Dict[str, Any]],
    param_values: Optional[Dict[str, Any]],
) -> Dict[str, Any]:
    """Queries The Graph for a particular query

    May raise:
    - RemoteError: If there is a problem querying
    """
    prefix = "query "
    if param_types is not None:
        prefix += (
            json.dumps(param_types).replace('"', "").replace("{", "(").replace("}", ")")
        )
    prefix += "{"
    log.debug(f"Querying The Graph for {querystr}")
    try:
        result = self.client.execute(
            gql(prefix + querystr), variable_values=param_values
        )
    except requests.exceptions.RequestException:
        raise RemoteError(f"Failed to query the graph for {querystr}")

    log.debug("Got result from The Graph query")
    return result


# Traceback (rotkehlchen.errors.RemoteError)
[16/09/2020 17:41:40 Mitteleuropäische Sommerzeit] rotkehlchen.exchanges.binance: Binance API request request_url=https://api.binance.com/api/v3/account?recvWindow=10000&amp;timestamp=1600270900071&amp;signature=[REDACTED]
[16/09/2020 17:41:40 Mitteleuropäische Sommerzeit] rotkehlchen.api.server: Exception on /api/1/exchanges [PUT]
Traceback (most recent call last):
File "site-packages\flask\app.py", line 1949, in full_dispatch_request
File "site-packages\flask\app.py", line 1935, in dispatch_request
File "site-packages\flask_restful\__init__.py", line 458, in wrapper
File "site-packages\flask\views.py", line 89, in view
File "site-packages\flask_restful\__init__.py", line 573, in dispatch_request
File "site-packages\webargs\core.py", line 366, in wrapper
File "rotkehlchen\api\v1\resources.py", line 197, in put
File "rotkehlchen\api\rest.py", line 125, in wrapper
File "rotkehlchen\api\rest.py", line 393, in setup_exchange
File "rotkehlchen\rotkehlchen.py", line 810, in setup_exchange
File "rotkehlchen\exchanges\manager.py", line 94, in setup_exchange
File "rotkehlchen\exchanges\binance.py", line 204, in validate_api_key
File "rotkehlchen\exchanges\binance.py", line 295, in api_query_dict
File "rotkehlchen\exchanges\binance.py", line 273, in api_query
rotkehlchen.errors.RemoteError: Binance API request https://api.binance.com/api/v3/account?recvWindow=10000&amp;timestamp=1600270900071&amp;signature=[SIGNATURE] for account failed with HTTP status code: 400, error code: -1021 and error message: Timestamp for this request was 1000ms ahead of the server's time.
[16/09/2020 17:41:40 Mitteleuropäische Sommerzeit] rotkehlchen.api.server.pywsgi: 127.0.0.1 - - "PUT /api/1/exchanges HTTP/1.1" 500 216 0.373099
[16/09/2020 17:41:43 Mitteleuropäische Sommerzeit] rotkehlchen.api.rest: Request successful response={"result": {"warnings": [], "errors": []}, "message": ""}, status_code=200

# Fixed code
def query(
    self,
    querystr: str,
    param_types: Optional[Dict[str, Any]],
    param_values: Optional[Dict[str, Any]],
) -> Dict[str, Any]:
    """Queries The Graph for a particular query

    May raise:
    - RemoteError: If there is a problem querying
    """
    prefix = "query "
    if param_types is not None:
        prefix += (
            json.dumps(param_types).replace('"', "").replace("{", "(").replace("}", ")")
        )
    prefix += "{"
    log.debug(f"Querying The Graph for {querystr}")
    try:
        result = self.client.execute(
            gql(prefix + querystr), variable_values=param_values
        )
    except (requests.exceptions.RequestException, Exception) as e:
        raise RemoteError(f"Failed to query the graph for {querystr} due to {str(e)}")

    log.debug("Got result from The Graph query")
    return result