diff --git a/bfxapi/rest/_RestAuthenticatedEndpoints.py b/bfxapi/rest/_RestAuthenticatedEndpoints.py index 61ee64d..ce4dc1b 100644 --- a/bfxapi/rest/_RestAuthenticatedEndpoints.py +++ b/bfxapi/rest/_RestAuthenticatedEndpoints.py @@ -186,6 +186,11 @@ 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( + *self._POST("auth/w/funding/close", data={ "id": id }) + ) + 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 bde6ac7..2f2a8fd 100644 --- a/bfxapi/rest/serializers.py +++ b/bfxapi/rest/serializers.py @@ -319,8 +319,8 @@ Position = generate_labeler_serializer("Position", klass=types.Position, labels= FundingOffer = generate_labeler_serializer("FundingOffer", klass=types.FundingOffer, labels=[ "id", "symbol", - "mts_created", - "mts_updated", + "mts_create", + "mts_update", "amount", "amount_orig", "offer_type", @@ -477,8 +477,8 @@ Movement = generate_labeler_serializer("Movement", klass=types.Movement, labels= "currency_name", "_PLACEHOLDER", "_PLACEHOLDER", - "mts_started", - "mts_updated", + "mts_start", + "mts_update", "_PLACEHOLDER", "_PLACEHOLDER", "status", diff --git a/bfxapi/rest/types.py b/bfxapi/rest/types.py index 58ce507..af53672 100644 --- a/bfxapi/rest/types.py +++ b/bfxapi/rest/types.py @@ -268,7 +268,7 @@ class FundingOffer(_Type): notify: bool hidden: int renew: bool - + @dataclass class Trade(_Type): id: int @@ -383,8 +383,8 @@ class Movement(_Type): id: str currency: str currency_name: str - mts_started: int - mts_updated: int + mts_start: int + mts_update: int status: str amount: int fees: int diff --git a/examples/rest/return_taken_funding.py b/examples/rest/return_taken_funding.py new file mode 100644 index 0000000..ccb0c2b --- /dev/null +++ b/examples/rest/return_taken_funding.py @@ -0,0 +1,22 @@ +# python -c "import examples.rest.return_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_close( + id=loan.id + ) + + print("Funding close notification:", notification) \ No newline at end of file