pub type UnindexedApiError = ApiError<AssetNameExchange, InstrumentNameExchange>;Expand description
Type alias for a ApiError that is keyed on AssetNameExchange and
InstrumentNameExchange (yet to be indexed).
Aliased Type§
pub enum UnindexedApiError {
AssetInvalid(AssetNameExchange, String),
InstrumentInvalid(InstrumentNameExchange, String),
RateLimit,
Unauthenticated(String),
BalanceInsufficient(Option<AssetNameExchange>, String),
OrderRejected(String),
OrderAlreadyCancelled,
OrderAlreadyFullyFilled,
OrderAlreadyExpired,
DuplicateClientOrderId(String),
RequestRejected(String),
}Variants§
AssetInvalid(AssetNameExchange, String)
Provided asset identifier is invalid or not supported.
For example:
- The
AssetNameExchangewas an invalid format.
Not transient — do not retry. The asset identifier must be corrected.
Indexed only when the ExecutionInstrumentMap holds the asset. Otherwise there is no
index to carry, and AccountEventIndexer reports it as
OrderRejected (from an order request) or
RequestRejected (from any other request), holding this error’s
own message.
InstrumentInvalid(InstrumentNameExchange, String)
Provided instrument identifier is invalid or not supported.
For example:
- The exchange does not have a market for an instrument.
- The
InstrumentNameExchangewas an invalid format.
Not transient — do not retry. The instrument identifier must be corrected.
Indexed only when the ExecutionInstrumentMap holds the instrument; otherwise reported
as AssetInvalid describes.
RateLimit
Request was rejected due to rate limiting.
The exchange enforces request quotas and the caller has exceeded them.
Some exchanges provide a Retry-After header or similar hint; the client
may incorporate this into internal retry logic before surfacing this error.
Transient — retry with backoff. Typical backoff is 10-60 seconds, but respect exchange-specific guidance if available.
Unauthenticated(String)
Authentication failed (invalid credentials, expired key, bad signature).
Unlike other API errors which affect a single request, authentication failures indicate that all subsequent requests will fail until credentials are corrected. Callers should halt trading and alert operators.
Not transient — do not retry. Fix credentials and restart.
BalanceInsufficient(Option<AssetNameExchange>, String)
Balance of an asset is insufficient to execute the requested operation.
The asset is None when it is not known which asset ran short:
- the venue’s rejection does not name it (e.g. Binance’s “Account has insufficient balance for requested action”), and a client does not guess it from the order;
- the venue named an asset that the
ExecutionInstrumentMapdoes not hold, so it has no index.AccountEventIndexer::api_errorlogs the name it dropped.
The String carries the venue’s message.
Not transient — do not retry the same request. Reduce order size or deposit additional funds.
OrderRejected(String)
Order was rejected by the exchange for a business rule violation.
Common causes include: price outside allowed range, quantity below minimum, post-only order would cross, reduce-only with no position.
Not transient — do not retry the same request. Adjust order parameters.
OrderAlreadyCancelled
Cancel request failed because the order was already cancelled.
This is a state conflict, not an error per se — the desired end state (order cancelled) has already been achieved.
Not transient — do not retry. The order is already in the cancelled state.
OrderAlreadyFullyFilled
Cancel request failed because the order was already fully filled.
This is a state conflict — the order completed before the cancel arrived. The caller should reconcile their local state with the fill.
Not transient — do not retry. The order no longer exists to cancel.
OrderAlreadyExpired
Cancel request failed because the order had already expired.
This is a state conflict — the order’s own deadline retired it before the cancel arrived,
so the desired end state (order no longer working) has already been achieved. Distinct from
OrderAlreadyCancelled because nobody asked for it: a
time-in-force such as GoodTillDate retired it
unprompted, and a caller reconciling its local state needs to know which of the two happened.
Not transient — do not retry. The order no longer exists to cancel.
DuplicateClientOrderId(String)
Open request refused because its ClientOrderId is already in use at the venue.
The refusal concerns this request alone: the order already under the id is unaffected,
and is not reported ended by it. What “in use” means is the venue’s rule. On the
SimulatedVenue and the IBKR client it is an order still working under the id, and an id
is free again once its order has ended. Binance documents an id as unique among open
orders. The String carries the venue’s message, or the client’s own where it refused the
request before sending it.
Reported by the SimulatedVenue, by the IBKR client, which refuses the request before it
reaches TWS, since TWS never sees a client order id, and by the Binance spot and margin
clients, from Binance’s "Duplicate order sent.". Other clients report a venue’s duplicate
rejection as OrderRejected until its message has been confirmed.
Not transient — the same request fails identically while the order under the id works. Use another id, or wait for that order to end.
RequestRejected(String)
The exchange refused the request itself, rather than an order it carried.
The request was malformed or asked for something the venue does not serve — a missing,
malformed or out-of-range parameter, such as a query time window longer than the venue
allows. Distinct from OrderRejected, which is an order failing a
business rule; this variant arises from queries and other non-order requests. The message
carries the venue’s own error code where it provides one (e.g. -1127 ... on Binance).
Not transient — the same request fails identically on retry. Change the request.