diff --git a/bfxapi/rest/_RestAuthenticatedEndpoints.py b/bfxapi/rest/_RestAuthenticatedEndpoints.py index ce4dc1b..af01a29 100644 --- a/bfxapi/rest/_RestAuthenticatedEndpoints.py +++ b/bfxapi/rest/_RestAuthenticatedEndpoints.py @@ -191,6 +191,13 @@ class _RestAuthenticatedEndpoints(_Requests): *self._POST("auth/w/funding/close", data={ "id": id }) ) + def submit_funding_toggle_auto_renew(self, status: bool, currency: str, amount: Optional[str] = None, rate: Optional[int] = None, period: Optional[int] = None) -> Notification[FundingAutoRenew]: + return serializers._Notification[FundingAutoRenew](serializer=serializers.FundingAutoRenew).parse(*self._POST("auth/w/funding/auto", data={ + "status": int(status), + "currency": currency, "amount": amount, + "rate": rate, "period": period + })) + def submit_wallet_transfer(self, from_wallet: str, to_wallet: str, currency: str, currency_to: str, amount: Union[Decimal, float, str]) -> Notification[Transfer]: data = { "from": from_wallet, "to": to_wallet, diff --git a/bfxapi/rest/serializers.py b/bfxapi/rest/serializers.py index 2f2a8fd..6e7103d 100644 --- a/bfxapi/rest/serializers.py +++ b/bfxapi/rest/serializers.py @@ -431,6 +431,13 @@ FundingCredit = generate_labeler_serializer("FundingCredit", klass=types.Funding "position_pair" ]) +FundingAutoRenew = generate_labeler_serializer("FundingAutoRenew", klass=types.FundingAutoRenew, labels=[ + "currency", + "period", + "rate", + "threshold" +]) + Transfer = generate_labeler_serializer("Transfer", klass=types.Transfer, labels=[ "mts", "wallet_from", diff --git a/bfxapi/rest/types.py b/bfxapi/rest/types.py index af53672..ce6d360 100644 --- a/bfxapi/rest/types.py +++ b/bfxapi/rest/types.py @@ -347,6 +347,13 @@ class FundingCredit(_Type): no_close: int position_pair: str +@dataclass +class FundingAutoRenew(_Type): + currency: str + period: int + rate: float + threshold: float + @dataclass class Transfer(_Type): mts: int diff --git a/examples/rest/funding_auto_renew.py b/examples/rest/funding_auto_renew.py new file mode 100644 index 0000000..eec7c47 --- /dev/null +++ b/examples/rest/funding_auto_renew.py @@ -0,0 +1,21 @@ +# python -c "import examples.rest.funding_auto_renew" + +import os + +from bfxapi.client import Client, Constants + +bfx = Client( + REST_HOST=Constants.REST_HOST, + API_KEY=os.getenv("BFX_API_KEY"), + API_SECRET=os.getenv("BFX_API_SECRET") +) + +notification = bfx.rest.auth.submit_funding_toggle_auto_renew( + status=True, + currency="USD", + amount="150", + rate="0", + period=2 +) + +print("Renew toggle notification:", notification) \ No newline at end of file