Skip to content

feat(spot): add cl_ord_id to create_order and edit_order endpoints#416

Open
claudiapacini wants to merge 1 commit intobtschwertfeger:masterfrom
claudiapacini:cl-ord-id
Open

feat(spot): add cl_ord_id to create_order and edit_order endpoints#416
claudiapacini wants to merge 1 commit intobtschwertfeger:masterfrom
claudiapacini:cl-ord-id

Conversation

@btschwertfeger btschwertfeger added Should Something that should be implemented somewhere in the future Technical Dept labels Feb 21, 2026
@btschwertfeger btschwertfeger added this to the Upcoming Release milestone Feb 21, 2026
Copy link
Owner

@btschwertfeger btschwertfeger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @claudiapacini, thanks for bringing this up!

Initially, I wanted to reject your issue and PR as the idea does not align with the decision on discontinuing the specialized Market, User, Trade, etc clients as stated here. The recommended functions to achieve your goal (e.g. for Spot trading) are the SpotClient.request and SpotAsyncClient.request methods. It also introduces a breaking change to the amend_order function that relied on the extra_params usage and now requires setting txid or cl_ord_id.

But after going through your changes, I see the benefit in applying them especially considering that the cancel_order function currently does not support client order IDs. While I still don't have the capacity to continuously track Kraken API changes, it makes sense to keep these specialized clients reasonably up to date with the help of contributors like you. This is particularly important not only from a functional perspective, but also because many users are likely still relying on the legacy client interfaces. Since the parameters are mostly optional, the risk of introducing future breaking changes also remains relatively low. So I'm happy to accept your proposed changes once you address my remaining comments.

Comment on lines +501 to +511
def amend_order( # pylint: disable=too-many-arguments # noqa: PLR0913, PLR0917
self: Trade,
txid: str | None = None,
cl_ord_id: str | None = None,
order_qty: str | float | None = None,
display_qty: str | float | None = None,
limit_price: str | float | None = None,
trigger_price: str | float | None = None,
post_only: bool | None = None,
userref: int | None = None,
validate: bool = False,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some parameters from the list are still missing https://docs.kraken.com/api/docs/rest-api/amend-order/.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i've double checked these. They should be ok now.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a validate parameter in the docs but it seems to work here as well.
Lets not add it to the function signature to avoid breakage in case they remove the support for this undocumented parameter. Users can still set it via extra_params.

@btschwertfeger btschwertfeger linked an issue Feb 21, 2026 that may be closed by this pull request
@btschwertfeger
Copy link
Owner

@claudiapacini, are you planning to address the created comments and suggestions?

@claudiapacini
Copy link
Author

I have removed the breaking changes in amend_order and cancel_order. These were not required.

@claudiapacini
Copy link
Author

@claudiapacini, are you planning to address the created comments and suggestions?

sorry for the delay

:type validate: bool, optional
:param userref: User reference id for example to group orders
:type userref: int, optional
:param cl_ord_id: Client order id (optional)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The optional is given by the type declaration and not necessary at this place.

(Similar to other places; please address)

Suggested change
:param cl_ord_id: Client order id (optional)
:param cl_ord_id: Client order id

Comment on lines +501 to +511
def amend_order( # pylint: disable=too-many-arguments # noqa: PLR0913, PLR0917
self: Trade,
txid: str | None = None,
cl_ord_id: str | None = None,
order_qty: str | float | None = None,
display_qty: str | float | None = None,
limit_price: str | float | None = None,
trigger_price: str | float | None = None,
post_only: bool | None = None,
userref: int | None = None,
validate: bool = False,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a validate parameter in the docs but it seems to work here as well.
Lets not add it to the function signature to avoid breakage in case they remove the support for this undocumented parameter. Users can still set it via extra_params.


:param txid: The txid of the order to edit
:type txid: str, optional
:param cl_ord_id: Client order id (optional)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
:param cl_ord_id: Client order id (optional)
:param cl_ord_id: Client order id

:type nonce: int, optional
:param validate: Validate the order without placing on the market (default: ``False``)
:type validate: bool, optional
:raises ValueError: If both ``txid`` and ``cl_ord_id`` are not set
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not having txid or cl_ord_id results in kraken.exceptions.KrakenInvalidArgumentsError.

Suggested change
:raises ValueError: If both ``txid`` and ``cl_ord_id`` are not set
:raises kraken.exceptions.KrakenInvalidArgumentsError: If neither ``txid`` or ``cl_ord_id`` is set

@@ -632,21 +697,24 @@ def edit_order( # pylint: disable=too-many-arguments # noqa: PLR0913, PLR0917
@ensure_string("txid")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked up the docs and it seems like txid can be an integer as well, but cl_ord_id must be a string.

So lets swap these out:

Suggested change
@ensure_string("txid")
@ensure_string("cl_ord_id")

Comment on lines +245 to +246
with pytest.raises(ValueError, match=r"Either txid or cl_ord_id must be set!"):
spot_auth_trade.cancel_order()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do get kraken.exceptions.KrakenInvalidArgumentsError here.

@btschwertfeger
Copy link
Owner

@claudiapacini, are you planning to address the created comments and suggestions?

sorry for the delay

Same here, busy times. (:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Should Something that should be implemented somewhere in the future Technical Dept

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add cl_ord_id to spot apis

2 participants