Comments (12)
You can reference the pagination cursors with $client->getHttpClient()->getLastResponse()->getHeader('cb-after')
and $client->getHttpClient()->getLastResponse()->getHeader('cb-before')
from gdax.
Hello,
https://github.com/hellovoid/gdax#pagination-ref
from gdax.
The $before and $after needs to be set via CB-BEFORE and CB-AFTER
Otherwise, where will the values come from?
from gdax.
Line 64 in aa77af1
from gdax.
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.
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.
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.
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.
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.
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.
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.
Great! That's the right solution.
Maybe the readme should be updated to reflect this?
from gdax.
Related Issues (10)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gdax.