krakenfutures: order rejection reasons are split across two vocabularies, and three common ones collapse to generic ExchangeError
Version
ccxt 4.5.74
Order rejections on krakenfutures arrive through two different vocabularies, and they are handled very unevenly.
1. sendStatus.status — camelCase, mostly typed, three notable gaps
verifyOrderActionSuccess maps 20 statuses to precise exception classes, which is great. But
three of them collapse to a generic ExchangeError:
'selfFill': ExchangeError,
'tooManySmallOrders': ExchangeError,
'wouldNotReducePosition': ExchangeError,ExchangeError is the catch-all of the whole library, so a caller who needs to react to these —
and they are routine, not exotic — has no typed signal and must match on the message string:
except ccxt.ExchangeError as e:
if str(e) == 'krakenfutures: createOrder failed due to tooManySmallOrders':
...That couples client code to an exact message template assembled from literals in
verifyOrderActionSuccess. It works today, but it breaks silently the day the template changes.
All three have a natural home in the existing hierarchy:
| status | suggested type | why |
|---|---|---|
tooManySmallOrders |
InvalidOrder |
the order was rejected on its own size/shape |
wouldNotReducePosition |
InvalidOrder |
a reduceOnly order that would not reduce |
selfFill |
OperationRejected |
rejected by a matching policy, not malformed |
2. orderError — SNAKE_CASE, not surfaced at all
The Derivatives OpenAPI spec (futures-rest.yaml, schema OrderError) enumerates a separate
set of codes — MARKET_SUSPENDED, SMALL_ORDER_LIMIT_EXCEEDED, PRICE_COLLAR,
PRICE_DISLOCATION, WOULD_CAUSE_LIQUIDATION, TRAILING_STOP_ORDER_LIMIT_EXCEEDED,
MAX_POSITION_EXCEEDED, … Some overlap semantically with the camelCase statuses, but they are
not the same strings and they do not travel the same path.
Notably, some arrive asynchronously: a trailing_stop rejected for
TRAILING_STOP_ORDER_LIMIT_EXCEEDED is accepted by POST /batchorder (nothing in batchStatus)
and only appears later in GET /history/triggers as an OrderTriggerRejected event carrying
orderError. Those cannot become exceptions — but parseOrder could surface orderError on the
returned order, so that they stop being invisible to the unified API entirely.
Summary
- retype the three
ExchangeErrorfallbacks inverifyOrderActionSuccess(small, contained); - expose
orderErroron parsed orders so the asynchronous rejections are reachable.
The first half alone would remove the need for string matching in client code.
Source: ccxt/ccxt