Skip to content

Commit e198bbf

Browse files
Add max_fee parameter to kraken.spot.Funding.withdraw_funds (#171)
1 parent 9b4cd39 commit e198bbf

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

kraken/exceptions/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,11 @@ class KrakenTemporaryLockoutError(Exception):
272272
"""The account was temporary locked out."""
273273

274274

275+
@docstring_message
276+
class KrakenMaxFeeExceededError(Exception):
277+
"""The fee was higher than the defined maximum."""
278+
279+
275280
@docstring_message
276281
class MaxReconnectError(Exception):
277282
"""To many reconnect tries."""
@@ -286,6 +291,7 @@ class MaxReconnectError(Exception):
286291
"EGeneral:Permission denied": KrakenPermissionDeniedError,
287292
"EGeneral:Unknown method": KrakenUnknownMethodError,
288293
"EGeneral:Temporary lockout": KrakenTemporaryLockoutError,
294+
"EFunding:Max fee exceeded": KrakenMaxFeeExceededError,
289295
"EService:Unavailable": KrakenServiceUnavailableError,
290296
"EService:Market in cancel_only mode": KrakenMarketInOnlyCancelModeError,
291297
"EService:Market in post_only mode": KrakenMarketInOnlyPostModeError,
@@ -379,6 +385,7 @@ def _get_exception(data: str | list[str]) -> Optional[Any]:
379385
"KrakenMarginPositionSizeExceededError",
380386
"KrakenMarketInOnlyCancelModeError",
381387
"KrakenMarketInOnlyPostModeError",
388+
"KrakenMaxFeeExceededError",
382389
"KrakenNotFoundError",
383390
"KrakenOrderForEditNotFoundError",
384391
"KrakenOrderLimitsExceededError",

kraken/spot/funding.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ def withdraw_funds(
301301
asset: str,
302302
key: str,
303303
amount: str | float,
304+
max_fee: Optional[str] = None,
304305
*,
305306
extra_params: Optional[dict] = None,
306307
) -> dict:
@@ -318,6 +319,9 @@ def withdraw_funds(
318319
:type key: str
319320
:param amount: The amount to withdraw
320321
:type amount: str | float
322+
:param max_fee: Fail withdraw if the fee will be higher than the
323+
specified max_fee.
324+
:type max_fee: str
321325
:return: The reference id of the withdraw
322326
:rtype: dict
323327
@@ -334,10 +338,14 @@ def withdraw_funds(
334338
... )
335339
{ 'refid': 'I7KGS6-UFMTTQ-AGBSO6T'}
336340
"""
341+
params: dict = {"asset": asset, "key": str(key), "amount": str(amount)}
342+
if defined(max_fee):
343+
params["max_fee"] = max_fee
344+
337345
return self._request( # type: ignore[return-value]
338346
method="POST",
339347
uri="/private/Withdraw",
340-
params={"asset": asset, "key": str(key), "amount": str(amount)},
348+
params=params,
341349
extra_params=extra_params,
342350
)
343351

tests/spot/test_spot_funding.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def test_withdraw_funds(spot_auth_funding: Funding) -> None:
8989
asset="XLM",
9090
key="enter-withdraw-key",
9191
amount=10000000,
92+
max_fee=20,
9293
),
9394
)
9495

0 commit comments

Comments
 (0)