Describes stx-python 0.10.1, the current release.
Every exception extends STXException.
| Exception | Extends | When |
|---|---|---|
STXException |
Exception |
Base for every error the SDK raises. |
STXConfigException |
STXException |
The client is misconfigured: unknown region, missing key, bad PEM. |
STXAPIException |
STXException |
The API answered with an error status. Base for the classes below. |
STXValidationException |
STXAPIException |
400: a parameter or body field was rejected, e.g. price is required. |
STXAuthenticationException |
STXAPIException |
401: the signature, key id or timestamp was not accepted. |
STXForbiddenException |
STXAPIException |
403: the key is read-only, or the account may not do this. |
STXNotFoundException |
STXAPIException |
404: the resource does not exist, or belongs to another account. |
STXRejectedException |
STXAPIException |
422: the exchange refused the request, e.g. insufficient funds or a closed market. |
STXRateLimitException |
STXAPIException |
429: too many requests. retry_after is seconds, when sent. |
STXServerException |
STXAPIException |
5xx: the server failed. Retried by the default policy. |
STXTransportException |
STXException |
The request never got an answer: connection, DNS, TLS or timeout. |
STXChannelException |
STXException |
A channel join or channel message was refused by the server. |
STXNotAvailableError |
STXException |
This exchange does not offer the feature yet. |
STXChannelUnavailableException |
STXNotAvailableError |
A channel this exchange does not have: its join was answered unmatched topic. Both an STXNotAvailableError and an STXChannelException. |
STXCombosUnavailableException |
STXChannelUnavailableException |
Combos are not available on this exchange. |
STXInvalidTokenException |
STXAuthenticationException |
401 on an OAuth bearer request: the access token is missing, expired or revoked (WWW-Authenticate: Bearer error="invalid_token"). |
STXInsufficientScopeException |
STXForbiddenException |
403 on an OAuth bearer request: the token is valid but its grant lacks the scope this call needs (WWW-Authenticate: Bearer error="insufficient_scope", scope="orders.write"). |
STXIpNotAllowedException |
STXForbiddenException |
403 ip_not_allowed: the OAuth token is valid, but its app does not allow writes from this IP address. |
STXTermsRequiredException |
STXForbiddenException |
403 terms_required: the member has not accepted the current STX terms, so the exchange places no orders for them through an app. |
STXComboException |
STXChannelException |
The exchange refused a combo command or channel join. |
STXComboPriceMovedException |
STXComboException |
accept found the best live quote below the amount you accepted. |
STXBlockedException |
STXForbiddenException |
403 from the network edge in front of the exchange: the request never reached it, so nothing was done. |
STXRestrictedJurisdictionException |
STXBlockedException |
403 restricted_jurisdiction: the request came from a location the exchange does not serve. |
STXUnusualNetworkException |
STXBlockedException |
403 unusual_network: the request came from a network the exchange does not accept traffic from, such as some hosting providers, proxies or VPNs. |
STXFillModeNotAllowedException |
STXRejectedException |
422: this market does not take the order’s fill_mode. Combination markets accept only normal orders. fill_mode is the mode sent. |
STXPostOnlyWouldMatchException |
STXRejectedException |
A post_only order would have matched on arrival, so it was not left on the book and nothing filled. |
STXOAuthException |
STXAuthenticationException |
An RFC 6749 error from an OAuth endpoint or an authorize callback. |
STXAccessDeniedException |
STXOAuthException |
The member came back without connecting (error=access_denied): they declined, or their STX account cannot be connected. Nothing was granted; show your own “not connected” state. |
STXAccountPendingException |
STXOAuthException |
The member’s STX account is still being verified, so STX issues no tokens for them yet. |
STXTermsNotAcceptedException |
STXOAuthException |
The member left the STX terms page without agreeing (error=terms_required on the callback). Nothing was granted. |
STXGrantRevokedException |
STXAuthenticationException |
The member’s grant is gone: a refresh was refused with invalid_grant (the member disconnected the app, or a reused refresh token tripped reuse detection and the whole grant was revoked). The member client has deleted the stored tokens; send the member back through consent. |
STXException
Section titled “STXException”Base for every error the SDK raises.
STXConfigException
Section titled “STXConfigException”The client is misconfigured: unknown region, missing key, bad PEM.
STXAPIException
Section titled “STXAPIException”The API answered with an error status. Base for the classes below.
STXValidationException
Section titled “STXValidationException”400: a parameter or body field was rejected, e.g. price is required.
STXAuthenticationException
Section titled “STXAuthenticationException”401: the signature, key id or timestamp was not accepted.
A machine clock more than 30 seconds off also lands here.
STXForbiddenException
Section titled “STXForbiddenException”403: the key is read-only, or the account may not do this.
required_scopes lists the OAuth scopes that would allow the call,
when the exchange names them, else it is empty.
STXNotFoundException
Section titled “STXNotFoundException”404: the resource does not exist, or belongs to another account.
STXRejectedException
Section titled “STXRejectedException”422: the exchange refused the request, e.g. insufficient funds or a closed market.
STXRateLimitException
Section titled “STXRateLimitException”429: too many requests. retry_after is seconds, when sent.
reference identifies the block for support when the network edge in
front of the exchange answered ({"error": "rate_limited", ...}),
else it is None.
STXServerException
Section titled “STXServerException”5xx: the server failed. Retried by the default policy.
STXTransportException
Section titled “STXTransportException”The request never got an answer: connection, DNS, TLS or timeout.
STXChannelException
Section titled “STXChannelException”A channel join or channel message was refused by the server.
reply holds the server’s response object, for example
{"reason": "unauthorized"}.
STXNotAvailableError
Section titled “STXNotAvailableError”This exchange does not offer the feature yet.
feature is a stable id ("combos", "oauth", "markets.create",
the ids capabilities() reports are stx.FEATURES; a fill mode the
exchange has not enabled is "orders.post_only" or
"orders.fill_or_kill"), host the exchange that said so and
api_version its build, when known.
Nothing else on the client is affected: only the call that needs the
feature raises. AsyncSTX.capabilities() tells you ahead of time.
STXChannelUnavailableException
Section titled “STXChannelUnavailableException”A channel this exchange does not have: its join was answered
unmatched topic. Both an STXNotAvailableError and an
STXChannelException.
STXCombosUnavailableException
Section titled “STXCombosUnavailableException”Combos are not available on this exchange.
Raised when joining the rfq or combo_quote channel on a
deployment that does not offer combos. Nothing else is affected.
feature is "combos".
STXInvalidTokenException
Section titled “STXInvalidTokenException”401 on an OAuth bearer request: the access token is missing, expired or
revoked (WWW-Authenticate: Bearer error="invalid_token").
A member or app client refreshes or re-mints once before this reaches you; seeing it means that did not help.
STXInsufficientScopeException
Section titled “STXInsufficientScopeException”403 on an OAuth bearer request: the token is valid but its grant lacks
the scope this call needs (WWW-Authenticate: Bearer error="insufficient_scope", scope="orders.write").
required_scopes names what would allow it. Send the member back
through consent asking for it.
STXIpNotAllowedException
Section titled “STXIpNotAllowedException”403 ip_not_allowed: the OAuth token is valid, but its app does not
allow writes from this IP address.
An app holding a write scope (orders.write, markets.write) lists
the addresses it writes from; reads work from anywhere. Add this
machine’s public address to the app’s IP allow-list.
STXTermsRequiredException
Section titled “STXTermsRequiredException”403 terms_required: the member has not accepted the current STX
terms, so the exchange places no orders for them through an app.
The connection and the tokens are fine, and reads and cancels keep
working. Send the member’s browser to terms_url (see
stx.oauth.terms_url_with_return); once they agree on the STX page,
the same call works with the same tokens.
STXComboException
Section titled “STXComboException”The exchange refused a combo command or channel join.
reason is the exchange’s reason, for example not_found or
insufficient_assets. A reason with a detail after a colon, such as
player_refused:loss_limit24_hours, is split on the first colon:
reason is player_refused and detail is
loss_limit24_hours. raw_reason keeps the string as sent and
command names the refused command (phx_join for a join).
STXComboPriceMovedException
Section titled “STXComboPriceMovedException”accept found the best live quote below the amount you accepted.
The request stays open. best_quote is the live best (a
stx.combos.BestQuote whose fields are None when nothing is
live); accept again at its amount to take it.
STXBlockedException
Section titled “STXBlockedException”403 from the network edge in front of the exchange: the request never reached it, so nothing was done.
reason is restricted_jurisdiction, unusual_network, or
blocked when the edge sent no reason (most often a request without
a User-Agent header). reference identifies the block for
support, when sent. Retrying will not help, so it is never retried.
STXRestrictedJurisdictionException
Section titled “STXRestrictedJurisdictionException”403 restricted_jurisdiction: the request came from a location the
exchange does not serve.
STXUnusualNetworkException
Section titled “STXUnusualNetworkException”403 unusual_network: the request came from a network the
exchange does not accept traffic from, such as some hosting providers,
proxies or VPNs.
STXFillModeNotAllowedException
Section titled “STXFillModeNotAllowedException”422: this market does not take the order’s fill_mode. Combination
markets accept only normal orders. fill_mode is the mode sent.
STXPostOnlyWouldMatchException
Section titled “STXPostOnlyWouldMatchException”A post_only order would have matched on arrival, so it was not
left on the book and nothing filled.
reason is auto_matching when the exchange accepted and cancelled
it (order is that cancelled order), or match_with_self when the
first order it would match is your own (a 422; order is None).
STXOAuthException
Section titled “STXOAuthException”An RFC 6749 error from an OAuth endpoint or an authorize callback.
error is the RFC code (invalid_client, invalid_grant,
invalid_scope, access_denied, invalid_state…),
error_description the exchange’s text, endpoint the path that
answered, error_reason STX’s narrower reason when it sends one
(account_pending), retry_after seconds on a 429.
STXAccessDeniedException
Section titled “STXAccessDeniedException”The member came back without connecting (error=access_denied):
they declined, or their STX account cannot be connected. Nothing was
granted; show your own “not connected” state.
STXAccountPendingException
Section titled “STXAccountPendingException”The member’s STX account is still being verified, so STX issues no tokens for them yet.
On the callback (error=account_pending) no tokens exist: start again
once STX has approved the account. From the token endpoint
(invalid_grant with error_reason account_pending) on a
refresh, the connection stands: keep the stored tokens, the same refresh
token works once the member is verified. The member client keeps them.
STXTermsNotAcceptedException
Section titled “STXTermsNotAcceptedException”The member left the STX terms page without agreeing
(error=terms_required on the callback). Nothing was granted.
A member who is already connected when new terms take effect is a
different case: their order calls raise
stx.STXTermsRequiredException, which carries the page to send them to.
STXGrantRevokedException
Section titled “STXGrantRevokedException”The member’s grant is gone: a refresh was refused with invalid_grant
(the member disconnected the app, or a reused refresh token tripped reuse
detection and the whole grant was revoked). The member client has
deleted the stored tokens; send the member back through consent.

