Exceptions¶
The exceptions module provides comprehensive error handling for the BingX API.
- exception bingx_py.exceptions.APIError(code, message, timestamp=None)[source]¶
Bases:
ExceptionRepresents an error returned by the API.
- Parameters:
code (int) – The error code.
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.BadRequestError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when the request is invalid or malformed.
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.ConversionError(initial_data, model_type)[source]¶
Bases:
ExceptionRaised when the conversion to the model type fails.
- Parameters:
initial_data (dict[str, Any]) – The initial data that failed to convert.
model_type (type[BaseModel]) – The model type that was attempted to convert to.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.DuplicateOrderError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when the same order number is submitted multiple times within 1 second.
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.ForbiddenError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when access to the requested resource is forbidden.
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.GatewayTimeoutError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when the API server fails to get a response from the service center.
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.IPBannedError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when the IP is banned due to excessive requests.
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.IPWhitelistError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when the IP does not match the whitelist.
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.IncorrectAPIKeyError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when the API key is incorrect.
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.InsufficientMarginError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when there is insufficient margin to perform the operation.
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.InternalServerError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when there is an internal server error.
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.InternalSystemError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when there is an internal system error.
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.InvalidParameterError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when an invalid parameter is provided.
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.LiquidationPriceError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when the order price is below the estimated liquidation price.
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.MakerOrderError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when a Maker (Post Only) order would immediately match with available orders.
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.MaxLeverageError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when the leverage exceeds the maximum allowed for the trading pair.
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.MaxPositionValueError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when the position value exceeds the maximum allowed for the leverage.
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.NotFoundError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when the requested resource is not found.
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.NullSignatureError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when the signature is null.
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.OperationError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when the service is unavailable.
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.OrderAlreadyFilledError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when the order is already filled.
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.OrderLimitReachedError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when the number of orders exceeds the system limit.
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.OrderNotFoundError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when the specified order does not exist.
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.OrderPriceError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when the order price is outside the allowed range.
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.OrderProcessingError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when the order is still being processed.
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.PendingOrdersError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when there are pending orders that need to be canceled.
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.PermissionDeniedError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when the API key does not have the required permissions.
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.PositionNotFoundError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when the specified position does not exist.
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.RPCTimeoutError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when an RPC request times out.
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.RateLimitError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when the rate limit is exceeded.
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.RiskForbiddenError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when the request is forbidden due to risk control.
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.SignatureVerificationFailedError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when the signature verification fails.
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.SuspendedFromOpeningPositionsError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when the user is temporarily suspended from opening positions.
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.TimestampError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when the timestamp is null or mismatched.
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.TooManyRequestsError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when the request rate limit is exceeded.
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.TradeExecutionError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when the connection is invalid.
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.TradeValidationError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when there is no position to close.
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.TradingPairSuspendedError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when the trading pair is suspended from opening new positions.
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None
- exception bingx_py.exceptions.UnauthorizedError(message, timestamp=None)[source]¶
Bases:
APIErrorRaised when the request is unauthorized (e.g., invalid API key).
- Parameters:
message (str) – The error message.
timestamp (Optional[int]) – The timestamp of the error. Defaults to None.
- Returns:
None
- Return type:
None