Giter Club home page Giter Club logo

Comments (12)

10twentyfour avatar 10twentyfour commented on June 2, 2024 2

You can reference the pagination cursors with $client->getHttpClient()->getLastResponse()->getHeader('cb-after') and $client->getHttpClient()->getLastResponse()->getHeader('cb-before')

from gdax.

hellovoid avatar hellovoid commented on June 2, 2024

Hello,

https://github.com/hellovoid/gdax#pagination-ref

from gdax.

nextpulse avatar nextpulse commented on June 2, 2024

The $before and $after needs to be set via CB-BEFORE and CB-AFTER

Otherwise, where will the values come from?

from gdax.

hellovoid avatar hellovoid commented on June 2, 2024

private function getAndDecodeData($path, array $params = [])

from gdax.

nextpulse avatar nextpulse commented on June 2, 2024

That is a private function.

Do you have a working example of pagination code?

The example in the readme assumes $before, $after are set.

from gdax.

hellovoid avatar hellovoid commented on June 2, 2024
use Hellovoid\Gdax\Client;
use Hellovoid\Gdax\Pagination;

$configuration = Configuration::apiKey($apiKey, $apiSecret, $apiPassphrase);

$pagination = Pagination::create();

$client = Client::create($configuration, $pagination);

$fills = $client->getFills([
    'order_id'   => 'all',
    'product_id' => 'all'
]);

if (count($fills) > 0) {

    $latestFill = $fills[0]['details']['trade_id'];

    $pagination->setStartingAfter($latestFill);

    $fills = $client->getFills([
        'order_id'   => 'all',
        'product_id' => 'all'
    ]);
    
}

from gdax.

nextpulse avatar nextpulse commented on June 2, 2024

Using 'trade_id' is probably not the best approach (chronological order is not guaranteed). Any reason why the code is not using the response headers (CB-BEFORE and CB-AFTER) to extract these values?

"before and after cursors are available via response headers CB-BEFORE and CB-AFTER. Your requests should use these cursor values when making requests for pages after the initial request."

"Cursor pagination can be unintuitive at first. before and after cursor arguments should not be confused with before and after in chronological time. Most paginated requests return the latest information (newest) as the first page sorted by newest (in chronological time) first. To get older information you would request pages after the initial page. To get information newer, you would request pages before the first page."

from gdax.

nextpulse avatar nextpulse commented on June 2, 2024

If you are modelling after the coinbase php - they have a hasNextPage() method. Also the Param::FETCH_ALL => true options.

Which is probably taking advantage of the underlying param 'next_uri'. I think you can do something simiar - but use the response headers instead.

from gdax.

hellovoid avatar hellovoid commented on June 2, 2024

https://docs.gdax.com/#list-fills

..."PAGINATION

Fills are returned sorted by descending trade_id from the largest trade_id to the smallest trade_id. The CB-BEFORE header will have this first trade id so that future requests using the cb-before parameter will fetch fills with a greater trade id (newer fills)."

from gdax.

nextpulse avatar nextpulse commented on June 2, 2024

That is specifically for 'fills' only.

Paginations for other features are defined as https://docs.gdax.com/#pagination

For example:

account history:
https://docs.gdax.com/#get-account-history (note the doc refs the pagination section)

from gdax.

nextpulse avatar nextpulse commented on June 2, 2024

Why did you close this? The current pagination implementation is incorrect - it is applying the 'fills' pagination to the other api calls. The official gdax api doc defines it differently.

from gdax.

nextpulse avatar nextpulse commented on June 2, 2024

Great! That's the right solution.
Maybe the readme should be updated to reflect this?

from gdax.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.