From 251a4c6fc6bb6d0db5045028fc74a37ad62534fc Mon Sep 17 00:00:00 2001 From: Michal Nowotnik Date: Wed, 25 Sep 2024 11:59:21 +0200 Subject: [PATCH] Support fetching all currencies ledgers --- README.md | 4 ++-- bfxapi/rest/_interfaces/rest_auth_endpoints.py | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0edadc3..c3a1f44 100644 --- a/README.md +++ b/README.md @@ -342,7 +342,7 @@ This repository includes a pre-commit configuration file that defines the follow To set up pre-commit use: ```console -python3 -m pre-commit install +python3 -m pre_commit install ``` These will ensure that isort, black and flake8 are run on each git commit. @@ -353,7 +353,7 @@ These will ensure that isort, black and flake8 are run on each git commit. You can also manually trigger the execution of all hooks with: ```console -python3 -m pre-commit run --all-files +python3 -m pre_commit run --all-files ``` ## Before opening a PR diff --git a/bfxapi/rest/_interfaces/rest_auth_endpoints.py b/bfxapi/rest/_interfaces/rest_auth_endpoints.py index 8b01f45..5af30f8 100644 --- a/bfxapi/rest/_interfaces/rest_auth_endpoints.py +++ b/bfxapi/rest/_interfaces/rest_auth_endpoints.py @@ -232,7 +232,7 @@ def get_trades_history( def get_ledgers( self, - currency: str, + currency: Optional[str] = None, *, category: Optional[int] = None, start: Optional[str] = None, @@ -240,10 +240,14 @@ def get_ledgers( limit: Optional[int] = None, ) -> List[Ledger]: body = {"category": category, "start": start, "end": end, "limit": limit} + if currency: + endpoint = "auth/r/ledgers/{currency}/hist" + else: + endpoint = "auth/r/ledgers/hist" return [ serializers.Ledger.parse(*sub_data) - for sub_data in self._m.post(f"auth/r/ledgers/{currency}/hist", body=body) + for sub_data in self._m.post(endpoint, body=body) ] def get_base_margin_info(self) -> BaseMarginInfo: