diff --git a/bfxapi/rest/_RestAuthenticatedEndpoints.py b/bfxapi/rest/_RestAuthenticatedEndpoints.py index af01a29..7dc8136 100644 --- a/bfxapi/rest/_RestAuthenticatedEndpoints.py +++ b/bfxapi/rest/_RestAuthenticatedEndpoints.py @@ -133,8 +133,10 @@ class _RestAuthenticatedEndpoints(_Requests): def cancel_funding_offer(self, id: int) -> Notification[FundingOffer]: return serializers._Notification[FundingOffer](serializer=serializers.FundingOffer).parse(*self._POST("auth/w/funding/offer/cancel", data={ "id": id })) - def cancel_all_funding_offers(self, currency: str) -> Notification: - return serializers._Notification().parse(*self._POST("auth/w/funding/offer/cancel/all", data={ "currency": currency })) + def cancel_all_funding_offers(self, currency: str) -> Notification[Literal[None]]: + return serializers._Notification[Literal[None]](serializer=None).parse( + *self._POST("auth/w/funding/offer/cancel/all", data={ "currency": currency }) + ) def get_funding_offers_history(self, symbol: Optional[str] = None, start: Optional[str] = None, end: Optional[str] = None, limit: Optional[int] = None) -> List[FundingOffer]: if symbol == None: @@ -187,7 +189,7 @@ class _RestAuthenticatedEndpoints(_Requests): return [ serializers.FundingCredit.parse(*sub_data) for sub_data in self._POST(endpoint, data=data) ] def submit_funding_close(self, id: int) -> Notification[Literal[None]]: - return serializers._Notification[Literal[None]]().parse( + return serializers._Notification[Literal[None]](serializer=None).parse( *self._POST("auth/w/funding/close", data={ "id": id }) ) @@ -198,6 +200,13 @@ class _RestAuthenticatedEndpoints(_Requests): "rate": rate, "period": period })) + def submit_funding_toggle_keep(self, type: Literal["credit", "loan"], ids: Optional[List[int]] = None, changes: Optional[Dict[int, bool]] = None) -> Notification[Literal[None]]: + return serializers._Notification[Literal[None]](serializer=None).parse(*self._POST("auth/w/funding/keep", data={ + "type": type, + "id": ids, + "changes": changes + })) + 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/examples/rest/keep_taken_funding.py b/examples/rest/keep_taken_funding.py new file mode 100644 index 0000000..9693f95 --- /dev/null +++ b/examples/rest/keep_taken_funding.py @@ -0,0 +1,26 @@ +# python -c "import examples.rest.keep_taken_funding" + +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") +) + +loans = bfx.rest.auth.get_funding_loans(symbol="fUSD") + +for loan in loans: + print(f"Loan {loan}") + + notification = bfx.rest.auth.submit_funding_toggle_keep( + funding_type="loan", + ids=[loan.id], + changes={ + loan.id: 2 # (1 if true, 2 if false) + } + ) + + print("Funding keep notification:", notification) \ No newline at end of file