Skip to content

Commit

Permalink
added examples/php/load-all-at-once.php fix ccxt#730
Browse files Browse the repository at this point in the history
  • Loading branch information
kroitor committed Dec 2, 2017
1 parent 823e058 commit 040e473
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions examples/php/load-all-at-once.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

$root = dirname (dirname (dirname (__FILE__)));

include $root . '/ccxt.php';

date_default_timezone_set ('UTC');

$exchanges = \ccxt\Exchange::$exchanges;

foreach ($exchanges as $exchange) {
$id = "\\ccxt\\".$exchange;
$exchange = new $id();
echo "--------------------------------------------\n";
echo $exchange->id . "\n";

try {
$markets = $exchange->load_markets ();
echo count (array_values ($exchange->markets)) . " markets: " .
implode (', ', array_slice ($exchange->symbols, 0, 5)) . "...\n";
} catch (\ccxt\RequestTimeout $e) {
echo '[Timeout Error] ' . $e->getMessage () . ' (ignoring)' . "\n";
} catch (\ccxt\DDoSProtection $e) {
echo '[DDoS Protection Error] ' . $e->getMessage () . ' (ignoring)' . "\n";
} catch (\ccxt\AuthenticationError $e) {
echo '[Authentication Error] ' . $e->getMessage () . ' (ignoring)' . "\n";
} catch (\ccxt\ExchangeNotAvailable $e) {
echo '[Exchange Not Available] ' . $e->getMessage () . ' (ignoring)' . "\n";
} catch (\ccxt\NotSupported $e) {
echo '[Not Supported] ' . $e->getMessage () . ' (ignoring)' . "\n";
} catch (\ccxt\NetworkError $e) {
echo '[Network Error] ' . $e->getMessage () . ' (ignoring)' . "\n";
} catch (\ccxt\ExchangeError $e) {
echo '[Exchange Error] ' . $e->getMessage () . ' (ignoring)' . "\n";
} catch (Exception $e) {
echo '[Error] ' . $e->getMessage () . "\n";
}
echo "\n";
}


?>

0 comments on commit 040e473

Please sign in to comment.