diff --git a/bfxapi/rest/_RestAuthenticatedEndpoints.py b/bfxapi/rest/_RestAuthenticatedEndpoints.py index 7dc8136..b3a7453 100644 --- a/bfxapi/rest/_RestAuthenticatedEndpoints.py +++ b/bfxapi/rest/_RestAuthenticatedEndpoints.py @@ -188,6 +188,11 @@ class _RestAuthenticatedEndpoints(_Requests): return [ serializers.FundingCredit.parse(*sub_data) for sub_data in self._POST(endpoint, data=data) ] + def get_funding_info(self, key: str) -> FundingInfo: + response = self._POST(f"auth/r/info/funding/{key}") + + return serializers.FundingInfo.parse(*([response[1]] + response[2])) + def submit_funding_close(self, id: int) -> Notification[Literal[None]]: return serializers._Notification[Literal[None]](serializer=None).parse( *self._POST("auth/w/funding/close", data={ "id": id }) diff --git a/bfxapi/rest/serializers.py b/bfxapi/rest/serializers.py index 6e7103d..56021fe 100644 --- a/bfxapi/rest/serializers.py +++ b/bfxapi/rest/serializers.py @@ -438,6 +438,14 @@ FundingAutoRenew = generate_labeler_serializer("FundingAutoRenew", klass=types.F "threshold" ]) +FundingInfo = generate_labeler_serializer("FundingInfo", klass=types.FundingInfo, labels=[ + "symbol", + "yield_loan", + "yield_lend", + "duration_loan", + "duration_lend" +]) + 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 ce6d360..7554499 100644 --- a/bfxapi/rest/types.py +++ b/bfxapi/rest/types.py @@ -354,6 +354,14 @@ class FundingAutoRenew(_Type): rate: float threshold: float +@dataclass() +class FundingInfo(_Type): + symbol: str + yield_loan: float + yield_lend: float + duration_loan: float + duration_lend: float + @dataclass class Transfer(_Type): mts: int diff --git a/examples/rest/get_funding_info.py b/examples/rest/get_funding_info.py new file mode 100644 index 0000000..83d0635 --- /dev/null +++ b/examples/rest/get_funding_info.py @@ -0,0 +1,13 @@ +# python -c "import examples.rest.get_funding_info" + +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") +) + +print(bfx.rest.auth.get_funding_info(key="fUSD")) \ No newline at end of file