From 81b9561501a63e9725b6819a6093c16599dbc80a Mon Sep 17 00:00:00 2001 From: Alex Contryman Date: Sat, 13 Mar 2021 16:24:37 -0800 Subject: [PATCH 1/4] Add trade_id param to get_trades --- coinbasepro/public_client.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/coinbasepro/public_client.py b/coinbasepro/public_client.py index 92b5361..ab3ea76 100644 --- a/coinbasepro/public_client.py +++ b/coinbasepro/public_client.py @@ -194,7 +194,7 @@ def get_product_ticker(self, product_id: str) -> Dict[str, Any]: ) return self._convert_dict(r, field_conversions) - def get_product_trades(self, product_id: str) -> Iterator[Dict[str, Any]]: + def get_product_trades(self, product_id: str, trade_id: Optional[int] = None) -> Iterator[Dict[str, Any]]: """List the latest trades for a product. This method returns a generator which may make multiple HTTP @@ -202,6 +202,7 @@ def get_product_trades(self, product_id: str) -> Iterator[Dict[str, Any]]: Args: product_id: Product. + trade_id: Trade id to start from. Yields: Latest trades. Example:: @@ -223,6 +224,8 @@ def get_product_trades(self, product_id: str) -> Iterator[Dict[str, Any]]: See `get_products()`. """ + params = {'after': trade_id + 1} if trade_id else None + field_conversions = { "time": self._parse_datetime, "trade_id": int, @@ -230,7 +233,7 @@ def get_product_trades(self, product_id: str) -> Iterator[Dict[str, Any]]: "size": Decimal, } trades = self._send_paginated_message( - "/products/{}/trades".format(product_id), rate_limiter=self.p_rate_limiter + "/products/{}/trades".format(product_id), params=params, rate_limiter=self.p_rate_limiter ) return (self._convert_dict(trade, field_conversions) for trade in trades) From e327698c04ed09fd45d94b06673622a171a25e47 Mon Sep 17 00:00:00 2001 From: Alex Contryman Date: Sat, 13 Mar 2021 16:27:32 -0800 Subject: [PATCH 2/4] Bump package version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index aa05fcf..d2a8e99 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ setuptools.setup( name="coinbasepro", - version="0.2.1", + version="0.3.0", description="A Python interface for the Coinbase Pro API.", long_description=readme + "\n\n" + history, long_description_content_type="text/x-rst", From d1f62049025ae37725244b5336e096953fec4f4d Mon Sep 17 00:00:00 2001 From: Alex Contryman Date: Sat, 13 Mar 2021 17:47:46 -0800 Subject: [PATCH 3/4] Update history --- HISTORY.rst | 7 +++++++ setup.py | 2 ++ 2 files changed, 9 insertions(+) diff --git a/HISTORY.rst b/HISTORY.rst index c543319..53af1f1 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -8,6 +8,13 @@ dev - [change here] +0.3.0 (2021-03-13) +++++++++++++++++++ + +**Improvements** + +- Add `trade_id` param to `get_trades`. Allows you to get trades starting from an arbitrary trade, instead of only the most recent trade. + 0.2.1 (2020-01-09) ++++++++++++++++++ diff --git a/setup.py b/setup.py index d2a8e99..96a95ab 100644 --- a/setup.py +++ b/setup.py @@ -32,5 +32,7 @@ "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", ), ) From fc78e4aab0ab034ee5f8a305738bfb46facd28f8 Mon Sep 17 00:00:00 2001 From: Alex Contryman Date: Sat, 13 Mar 2021 17:48:37 -0800 Subject: [PATCH 4/4] Black --- coinbasepro/public_client.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/coinbasepro/public_client.py b/coinbasepro/public_client.py index ab3ea76..83f8a14 100644 --- a/coinbasepro/public_client.py +++ b/coinbasepro/public_client.py @@ -194,7 +194,9 @@ def get_product_ticker(self, product_id: str) -> Dict[str, Any]: ) return self._convert_dict(r, field_conversions) - def get_product_trades(self, product_id: str, trade_id: Optional[int] = None) -> Iterator[Dict[str, Any]]: + def get_product_trades( + self, product_id: str, trade_id: Optional[int] = None + ) -> Iterator[Dict[str, Any]]: """List the latest trades for a product. This method returns a generator which may make multiple HTTP @@ -224,7 +226,7 @@ def get_product_trades(self, product_id: str, trade_id: Optional[int] = None) -> See `get_products()`. """ - params = {'after': trade_id + 1} if trade_id else None + params = {"after": trade_id + 1} if trade_id else None field_conversions = { "time": self._parse_datetime, @@ -233,7 +235,9 @@ def get_product_trades(self, product_id: str, trade_id: Optional[int] = None) -> "size": Decimal, } trades = self._send_paginated_message( - "/products/{}/trades".format(product_id), params=params, rate_limiter=self.p_rate_limiter + "/products/{}/trades".format(product_id), + params=params, + rate_limiter=self.p_rate_limiter, ) return (self._convert_dict(trade, field_conversions) for trade in trades)