def configure_http_error_order_status_response( self, order: InFlightOrder, mock_api: aioresponses, callback: Optional[Callable] = lambda *args, **kwargs: None ) -> str: url = web_utils.private_rest_url(CONSTANTS.GET_ORDER_DETAIL_PATH_URL) regex_url = re.compile(f"^{url}".replace(".", r"\.").replace("?", r"\?")) mock_api.get(regex_url, status=401, callback=callback) return url
def configure_erroneous_http_fill_trade_response( self, order: InFlightOrder, mock_api: aioresponses, callback: Optional[Callable] = lambda *args, **kwargs: None ) -> str: url = web_utils.private_rest_url( path_url=CONSTANTS.GET_TRADE_DETAIL_PATH_URL) regex_url = re.compile(url + r"\?.*") mock_api.get(regex_url, status=400, callback=callback) return url
def configure_erroneous_cancelation_response( self, order: InFlightOrder, mock_api: aioresponses, callback: Optional[Callable] = lambda *args, **kwargs: None ) -> str: url = web_utils.private_rest_url(CONSTANTS.CANCEL_ORDER_PATH_URL) regex_url = re.compile(f"^{url}".replace(".", r"\.").replace("?", r"\?")) mock_api.post(regex_url, status=400, callback=callback) return url
def configure_full_fill_trade_response( self, order: InFlightOrder, mock_api: aioresponses, callback: Optional[Callable] = lambda *args, **kwargs: None ) -> str: url = web_utils.private_rest_url( path_url=CONSTANTS.GET_TRADE_DETAIL_PATH_URL) regex_url = re.compile(url + r"\?.*") response = self._order_fills_request_full_fill_mock_response( order=order) mock_api.get(regex_url, body=json.dumps(response), callback=callback) return url
def configure_partially_filled_order_status_response( self, order: InFlightOrder, mock_api: aioresponses, callback: Optional[Callable] = lambda *args, **kwargs: None ) -> str: url = web_utils.private_rest_url(CONSTANTS.GET_ORDER_DETAIL_PATH_URL) regex_url = re.compile(f"^{url}".replace(".", r"\.").replace("?", r"\?")) response = self._order_status_request_partially_filled_mock_response( order=order) mock_api.get(regex_url, body=json.dumps(response), callback=callback) return url
def configure_successful_cancelation_response( self, order: InFlightOrder, mock_api: aioresponses, callback: Optional[Callable] = lambda *args, **kwargs: None ) -> str: url = web_utils.private_rest_url(CONSTANTS.CANCEL_ORDER_PATH_URL) regex_url = re.compile(f"^{url}".replace(".", r"\.").replace("?", r"\?")) response = self._order_cancelation_request_successful_mock_response( order=order) mock_api.post(regex_url, body=json.dumps(response), callback=callback) return url
def balance_url(self): url = web_utils.private_rest_url( CONSTANTS.GET_ACCOUNT_SUMMARY_PATH_URL) return url
def order_creation_url(self): url = web_utils.private_rest_url(CONSTANTS.CREATE_ORDER_PATH_URL) return url