diff --git a/vnpy/api/rest/rest_client.py b/vnpy/api/rest/rest_client.py index 7ae2c386..255ba35f 100644 --- a/vnpy/api/rest/rest_client.py +++ b/vnpy/api/rest/rest_client.py @@ -30,7 +30,7 @@ class Request(object): params: dict, data: dict, headers: dict, - callback: Callable, + callback: Callable = None, on_failed: Callable = None, on_error: Callable = None, extra: Any = None, @@ -284,3 +284,41 @@ class RestClient(object): """ url = self.url_base + path return url + + def request( + self, + method: str, + path: str, + params: dict = None, + data: dict = None, + headers: dict = None, + ): + """ + Add a new request. + :param method: GET, POST, PUT, DELETE, QUERY + :param path: + :param params: dict for query string + :param data: dict for body + :param headers: dict for headers + :return: requests.Response + """ + request = Request( + method, + path, + params, + data, + headers + ) + request = self.sign(request) + + url = self.make_full_url(request.path) + + response = requests.request( + request.method, + url, + headers=request.headers, + params=request.params, + data=request.data, + proxies=self.proxies, + ) + return response