这个问题在这里得到了回答:https ://github.com/ccxt/ccxt/issues/6105#issuecomment-552405563
<?php
include_once ('ccxt.php');
date_default_timezone_set ('UTC');
$exchange = new \ccxt\coinbasepro(array(
'apiKey' => 'YOUR_API_KEY',
'secret' => 'YOUR_SECRET',
// 'verbose' => true, // uncomment for debugging
// https://github.com/ccxt/ccxt/wiki/Manual#rate-limit
'enableRateLimit' => true, // rate-limiting is required by the Manual
));
$exchange->load_markets ();
// $exchange->verbose = true; // uncomment for debugging
$all_results = array();
$symbol = 'ETH/USD';
$since = null;
$limit = 100;
$params = array();
do {
// any of the following methods should work:
// $results = $exchange->fetch_orders($symbol, $since, $limit, $params);
// $results = $exchange->fetch_my_trades($symbol, $since, $limit, $params);
$results = $exchange->fetch_trades($symbol, $since, $limit, $params);
echo $exchange->iso8601($exchange->milliseconds());
echo ' fetched ' . count($results) . " results\n";
$all_results = array_merge ($all_results, $results);
if (count($results) > 0) {
$last = count($results) - 1;
echo ' last result ' . $results[$last]['id'] . ' ' . $results[$last]['datetime'] . "\n";
echo ' first result ' . $results[0]['id'] . ' ' . $results[0]['datetime'] . "\n";
} else {
break;
}
@$params['after'] = $exchange->last_response_headers['cb-after'][0];
// uncomment one of the following:
// } while (true); // fetch all results forever
} while (count($all_results) < 1000); // fetch up to 1000 results
echo "fetched " . count($all_results) . " results in total\n";
?>