danpaquin / coinbasepro-python

The unofficial Python client for the Coinbase Pro API
MIT License
1.82k stars 738 forks source link

get_product_trades() does not support optional parameters #339

Closed TheKeyboardKowboy closed 3 years ago

TheKeyboardKowboy commented 5 years ago

Am I just missing something or does the 'get_product_trades()' method not currently supporting the optional parameters for 'before', 'after', and 'limit'?

return self._send_paginated_message('/products/{}/trades'.format(product_id))

yiwensong commented 5 years ago

in the docstring of _send_paginated_message:

    def _send_paginated_message(self, endpoint, params=None):
        """ Send API message that results in a paginated response.

        The paginated responses are abstracted away by making API requests on
        demand as the response is iterated over.

        Paginated API messages support 3 additional parameters: `before`,
        `after`, and `limit`. `before` and `after` are mutually exclusive. To
        use them, supply an index value for that endpoint (the field used for
        indexing varies by endpoint - get_fills() uses 'trade_id', for example).
            `before`: Only get data that occurs more recently than index
            `after`: Only get data that occurs further in the past than index
            `limit`: Set amount of data per HTTP response. Default (and
                maximum) of 100.

        Args:
            endpoint (str): Endpoint (to be added to base URL)
            params (Optional[dict]): HTTP request parameters

        Yields:
            dict: API response objects

        """

the tldr is that _send_paginated_message abstracts away before after and limit.

but if you're talking about manually specifying these, then yes, it does not.

felixwatts commented 5 years ago

So how do I get product trades since a specific trade id? Because extrapolating from the Pagination section of the README.md I get:

# Only fetch new trades since last call by utilizing `before` parameter.
new_trades = auth_client.get_product_trades(product_id=some_prduct_id, before=some_trade_id)

But that actually returns a generator that produces all trades in history.

yiwensong commented 5 years ago

from reading the code, that feature seems to be unsupported.

mcardillo55 commented 3 years ago

As mentioned, auth_client.get_product_trades() will produce all trades on a product. We aim to be a wrapper for the official Coinbase API. You will need to create the logic yourself for finding trades since a specific trade id.