Skip to content

Commit

Permalink
Add max_fee parameter to kraken.spot.Funding.withdraw_funds (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
btschwertfeger authored Oct 21, 2023
1 parent 9b4cd39 commit e198bbf
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
7 changes: 7 additions & 0 deletions kraken/exceptions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,11 @@ class KrakenTemporaryLockoutError(Exception):
"""The account was temporary locked out."""


@docstring_message
class KrakenMaxFeeExceededError(Exception):
"""The fee was higher than the defined maximum."""


@docstring_message
class MaxReconnectError(Exception):
"""To many reconnect tries."""
Expand All @@ -286,6 +291,7 @@ class MaxReconnectError(Exception):
"EGeneral:Permission denied": KrakenPermissionDeniedError,
"EGeneral:Unknown method": KrakenUnknownMethodError,
"EGeneral:Temporary lockout": KrakenTemporaryLockoutError,
"EFunding:Max fee exceeded": KrakenMaxFeeExceededError,
"EService:Unavailable": KrakenServiceUnavailableError,
"EService:Market in cancel_only mode": KrakenMarketInOnlyCancelModeError,
"EService:Market in post_only mode": KrakenMarketInOnlyPostModeError,
Expand Down Expand Up @@ -379,6 +385,7 @@ def _get_exception(data: str | list[str]) -> Optional[Any]:
"KrakenMarginPositionSizeExceededError",
"KrakenMarketInOnlyCancelModeError",
"KrakenMarketInOnlyPostModeError",
"KrakenMaxFeeExceededError",
"KrakenNotFoundError",
"KrakenOrderForEditNotFoundError",
"KrakenOrderLimitsExceededError",
Expand Down
10 changes: 9 additions & 1 deletion kraken/spot/funding.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ def withdraw_funds(
asset: str,
key: str,
amount: str | float,
max_fee: Optional[str] = None,
*,
extra_params: Optional[dict] = None,
) -> dict:
Expand All @@ -318,6 +319,9 @@ def withdraw_funds(
:type key: str
:param amount: The amount to withdraw
:type amount: str | float
:param max_fee: Fail withdraw if the fee will be higher than the
specified max_fee.
:type max_fee: str
:return: The reference id of the withdraw
:rtype: dict
Expand All @@ -334,10 +338,14 @@ def withdraw_funds(
... )
{ 'refid': 'I7KGS6-UFMTTQ-AGBSO6T'}
"""
params: dict = {"asset": asset, "key": str(key), "amount": str(amount)}
if defined(max_fee):
params["max_fee"] = max_fee

return self._request( # type: ignore[return-value]
method="POST",
uri="/private/Withdraw",
params={"asset": asset, "key": str(key), "amount": str(amount)},
params=params,
extra_params=extra_params,
)

Expand Down
1 change: 1 addition & 0 deletions tests/spot/test_spot_funding.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def test_withdraw_funds(spot_auth_funding: Funding) -> None:
asset="XLM",
key="enter-withdraw-key",
amount=10000000,
max_fee=20,
),
)

Expand Down

0 comments on commit e198bbf

Please sign in to comment.