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.OKX_TRADE_FILLS_PATH) regex_url = re.compile(url + r"\?.*") mock_api.get(regex_url, status=400, callback=callback) return url
def configure_open_order_status_response( self, order: InFlightOrder, mock_api: aioresponses, callback: Optional[Callable] = lambda *args, **kwargs: None ) -> str: url = web_utils.private_rest_url( path_url=CONSTANTS.OKX_ORDER_DETAILS_PATH) regex_url = re.compile(url + r"\?.*") response = self._order_status_request_open_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( path_url=CONSTANTS.OKX_ORDER_CANCEL_PATH) response = self._order_cancelation_request_successful_mock_response( order=order) mock_api.post(url, body=json.dumps(response), 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( path_url=CONSTANTS.OKX_ORDER_CANCEL_PATH) response = { "code": "0", "msg": "", "data": [{ "clOrdId": order.client_order_id, "ordId": order.exchange_order_id or "dummyExchangeOrderId", "sCode": "1", "sMsg": "Error" }] } mock_api.post(url, body=json.dumps(response), callback=callback) return url
def balance_url(self): url = web_utils.private_rest_url(path_url=CONSTANTS.OKX_BALANCE_PATH) return url
def order_creation_url(self): url = web_utils.private_rest_url( path_url=CONSTANTS.OKX_PLACE_ORDER_PATH) return url