Skip to content

Commit

Permalink
done adding symbols to tickers
Browse files Browse the repository at this point in the history
  • Loading branch information
kroitor committed Oct 12, 2017
1 parent 2c3402d commit 9899924
Show file tree
Hide file tree
Showing 4 changed files with 344 additions and 104 deletions.
112 changes: 86 additions & 26 deletions build/ccxt.php
Original file line number Diff line number Diff line change
Expand Up @@ -14439,14 +14439,18 @@ public function fetch_markets () {
return $result;
}

public function parse_ticker ($ticker, $market) {
public function parse_ticker ($ticker, $market = null) {
$symbol = null;
if ($market)
$symbol = $market['symbol'];
$last = null;
if (array_key_exists ('last', $ticker))
$last = $ticker['last'];
$timestamp = $this->milliseconds ();
if (array_key_exists ('ts', $ticker))
$timestamp = $ticker['ts'];
return array (
'symbol' => $symbol,
'timestamp' => $timestamp,
'datetime' => $this->iso8601 ($timestamp),
'high' => $ticker['high'],
Expand Down Expand Up @@ -14807,6 +14811,7 @@ public function fetch_ticker ($symbol) {
$ticker = $response['ticker'];
$timestamp = intval ($response['time']) * 1000;
return array (
'symbol' => $symbol,
'timestamp' => $timestamp,
'datetime' => $this->iso8601 ($timestamp),
'high' => floatval ($ticker['high']),
Expand Down Expand Up @@ -15051,9 +15056,13 @@ public function fetch_order_book ($symbol, $params = array ()) {
return $this->parse_order_book ($response, $timestamp, 'BuyOrders', 'SellOrders', 'Price', 'Volume');
}

public function parse_ticker ($ticker, $market) {
public function parse_ticker ($ticker, $market = null) {
$timestamp = $this->parse8601 ($ticker['CreatedTimestampUtc']);
$symbol = null;
if ($market)
$symbol = $market['symbol'];
return array (
'symbol' => $symbol,
'timestamp' => $timestamp,
'datetime' => $this->iso8601 ($timestamp),
'high' => $ticker['DayHighestPrice'],
Expand Down Expand Up @@ -15250,6 +15259,7 @@ public function fetch_ticker ($symbol) {
throw new ExchangeError ($this->id . ' fetchTicker returned a bad response => ' . $this->json ($ticker));
$timestamp = $this->parse8601 ($ticker['serverTimeUTC']);
return array (
'symbol' => $symbol,
'timestamp' => $timestamp,
'datetime' => $this->iso8601 ($timestamp),
'high' => floatval ($ticker['high24h']),
Expand Down Expand Up @@ -15593,9 +15603,13 @@ public function fetch_order_book ($symbol, $params = array ()) {
return $this->parse_order_book ($orderbook);
}

public function parse_ticker ($ticker, $market) {
public function parse_ticker ($ticker, $market = null) {
$timestamp = $this->milliseconds ();
$symbol = null;
if ($market)
$symbol = $market['symbol'];
return array (
'symbol' => $symbol,
'timestamp' => $timestamp,
'datetime' => $this->iso8601 ($timestamp),
'high' => floatval ($ticker['h'][1]),
Expand Down Expand Up @@ -16066,6 +16080,7 @@ public function fetch_ticker ($symbol) {
$ticker = $tickers[$market['id']];
$timestamp = $this->milliseconds ();
return array (
'symbol' => $symbol,
'timestamp' => $timestamp,
'datetime' => $this->iso8601 ($timestamp),
'high' => $this->safe_float ($ticker, 'high'),
Expand Down Expand Up @@ -16292,9 +16307,13 @@ public function fetch_order_book ($symbol, $params = array ()) {
return $this->parse_order_book ($orderbook, $timestamp);
}

public function parse_ticker ($ticker, $market) {
public function parse_ticker ($ticker, $market = null) {
$timestamp = $this->milliseconds ();
$symbol = null;
if ($market)
$symbol = $market['symbol'];
return array (
'symbol' => $symbol,
'timestamp' => $timestamp,
'datetime' => $this->iso8601 ($timestamp),
'high' => floatval ($ticker['high']),
Expand Down Expand Up @@ -16598,7 +16617,11 @@ public function fetch_order_book ($symbol, $params = array ()) {

public function parse_ticker ($ticker, $market = null) {
$timestamp = $ticker['updated'] * 1000;
$symbol = null;
if ($market)
$symbol = $market['symbol'];
return array (
'symbol' => $symbol,
'timestamp' => $timestamp,
'datetime' => $this->iso8601 ($timestamp),
'high' => $this->safe_float ($ticker, 'high'),
Expand Down Expand Up @@ -17054,9 +17077,13 @@ public function fetch_order_book ($symbol, $params = array ()) {
return $this->parse_order_book ($orderbook, $timestamp, 'bids', 'asks', 'price', 'volume');
}

public function parse_ticker ($ticker, $market) {
public function parse_ticker ($ticker, $market = null) {
$timestamp = $ticker['timestamp'];
$symbol = null;
if ($market)
$symbol = $market['symbol'];
return array (
'symbol' => $symbol,
'timestamp' => $timestamp,
'datetime' => $this->iso8601 ($timestamp),
'high' => null,
Expand Down Expand Up @@ -17254,6 +17281,7 @@ public function fetch_ticker ($symbol) {
$ticker = $response['ticker'];
$timestamp = intval ($ticker['date']) * 1000;
return array (
'symbol' => $symbol,
'timestamp' => $timestamp,
'datetime' => $this->iso8601 ($timestamp),
'high' => floatval ($ticker['high']),
Expand Down Expand Up @@ -17469,6 +17497,7 @@ public function fetch_ticker ($symbol) {
$ticker = $response['result'];
$timestamp = $this->milliseconds ();
return array (
'symbol' => $symbol,
'timestamp' => $timestamp,
'datetime' => $this->iso8601 ($timestamp),
'high' => floatval ($ticker['high']),
Expand Down Expand Up @@ -17656,6 +17685,7 @@ public function fetch_ticker ($symbol) {
$ticker = $response['markets'][0];
$timestamp = $this->milliseconds ();
return array (
'symbol' => $symbol,
'timestamp' => $timestamp,
'datetime' => $this->iso8601 ($timestamp),
'high' => floatval ($ticker['high24h']),
Expand Down Expand Up @@ -17892,9 +17922,13 @@ public function fetch_order_book ($symbol, $params = array ()) {
);
}

public function parse_ticker ($ticker, $market) {
public function parse_ticker ($ticker, $market = null) {
$timestamp = $ticker['timestamp'];
$symbol = null;
if ($market)
$symbol = $market['symbol'];
return array (
'symbol' => $symbol,
'timestamp' => $timestamp,
'datetime' => $this->iso8601 ($timestamp),
'high' => floatval ($ticker['high']),
Expand Down Expand Up @@ -18349,21 +18383,22 @@ public function fetch_balance ($params = array ()) {
return $this->parse_balance ($result);
}

public function fetch_order_book ($market, $params = array ()) {
public function fetch_order_book ($symbol, $params = array ()) {
$orderbook = $this->publicGetDataIdDepth (array_merge (array (
'id' => $this->market_id ($market),
'id' => $this->market_id ($symbol),
), $params));
$result = $this->parse_order_book ($orderbook, null, 'bids', 'asks', 'price', 'amount');
$result['bids'] = $this->sort_by ($result['bids'], 0, true);
return $result;
}

public function fetch_ticker ($market) {
public function fetch_ticker ($symbol) {
$ticker = $this->publicGetDataIdTicker (array (
'id' => $this->market_id ($market),
'id' => $this->market_id ($symbol),
));
$timestamp = $ticker['at'] * 1000;
return array (
'symbol' => $symbol,
'timestamp' => $timestamp,
'datetime' => $this->iso8601 ($timestamp),
'high' => floatval ($ticker['high']),
Expand Down Expand Up @@ -18636,9 +18671,13 @@ public function fetch_order_book ($market, $params = array ()) {
return $this->parse_order_book ($orderbook);
}

public function parse_ticker ($ticker, $market) {
public function parse_ticker ($ticker, $market = null) {
$timestamp = $this->milliseconds ();
$symbol = null;
if ($market)
$symbol = $market['symbol'];
return array (
'symbol' => $symbol,
'timestamp' => $timestamp,
'datetime' => $this->iso8601 ($timestamp),
'high' => floatval ($ticker['high24hr']),
Expand Down Expand Up @@ -19073,12 +19112,13 @@ public function fetch_order_book ($symbol, $params = array ()) {
return $this->parse_order_book ($orderbook, $timestamp);
}

public function fetch_ticker ($symbol) {
$ticker = $this->publicGetTicker (array (
public function fetch_ticker ($symbol, $params = array ()) {
$ticker = $this->publicGetTicker (array_merge (array (
'book' => $this->market_id ($symbol),
));
), $params));
$timestamp = intval ($ticker['timestamp']) * 1000;
return array (
'symbol' => $symbol,
'timestamp' => $timestamp,
'datetime' => $this->iso8601 ($timestamp),
'high' => floatval ($ticker['high']),
Expand Down Expand Up @@ -19286,7 +19326,7 @@ public function fetch_order_book ($symbol, $params = array ()) {
return $this->parse_order_book ($orderbook, null, 'buy_price_levels', 'sell_price_levels');
}

public function parse_ticker ($ticker, $market) {
public function parse_ticker ($ticker, $market = null) {
$timestamp = $this->milliseconds ();
$last = null;
if (array_key_exists ('last_traded_price', $ticker)) {
Expand All @@ -19296,7 +19336,11 @@ public function parse_ticker ($ticker, $market) {
$last = floatval ($ticker['last_traded_price']);
}
}
$symbol = null;
if ($market)
$symbol = $market['symbol'];
return array (
'symbol' => $symbol,
'timestamp' => $timestamp,
'datetime' => $this->iso8601 ($timestamp),
'high' => floatval ($ticker['high_market_ask']),
Expand Down Expand Up @@ -19332,12 +19376,12 @@ public function fetch_tickers () {
return $result;
}

public function fetch_ticker ($symbol) {
public function fetch_ticker ($symbol, $params = array ()) {
$this->load_markets ();
$market = $this->market ($symbol);
$ticker = $this->publicGetProductsId (array (
$ticker = $this->publicGetProductsId (array_merge (array (
'id' => $market['id'],
));
), $params));
return $this->parse_ticker ($ticker, $market);
}

Expand Down Expand Up @@ -19541,9 +19585,13 @@ public function fetch_order_book ($symbol, $params = array ()) {
return $this->parse_order_book ($orderbook, null, 'BuyOrders', 'SellOrders', 'Price', 'Amount');
}

public function parse_ticker ($ticker, $market) {
public function parse_ticker ($ticker, $market = null) {
$timestamp = $this->milliseconds ();
$symbol = null;
if ($market)
$symbol = $market['symbol'];
return array (
'symbol' => $symbol,
'timestamp' => $timestamp,
'datetime' => $this->iso8601 ($timestamp),
'high' => null,
Expand Down Expand Up @@ -19580,12 +19628,12 @@ public function fetch_tickers () {
return $result;
}

public function fetch_ticker ($symbol) {
public function fetch_ticker ($symbol, $params = array ()) {
$this->load_markets ();
$market = $this->market ($symbol);
$ticker = $this->publicGetPriceSymbol (array (
$ticker = $this->publicGetPriceSymbol (array_merge (array (
'symbol' => $market['id'],
));
), $params));
return $this->parse_ticker ($ticker, $market);
}

Expand Down Expand Up @@ -19832,9 +19880,13 @@ public function fetch_order_book ($symbol, $params = array ()) {
return $this->parse_order_book ($orderbook, $timestamp, 'bids', 'asks', 'price', 'amount');
}

public function parse_ticker ($ticker, $market) {
public function parse_ticker ($ticker, $market = null) {
$timestamp = $this->parse8601 ($ticker['date']);
$symbol = null;
if ($market)
$symbol = $market['symbol'];
return array (
'symbol' => $symbol,
'timestamp' => $timestamp,
'datetime' => $this->iso8601 ($timestamp),
'high' => floatval ($ticker['high']),
Expand Down Expand Up @@ -20100,6 +20152,7 @@ public function fetch_ticker ($symbol) {
$ticker = $response['data'];
$timestamp = $this->milliseconds ();
return array (
'symbol' => $symbol,
'timestamp' => $timestamp,
'datetime' => $this->iso8601 ($timestamp),
'high' => floatval ($ticker['24hHigh']),
Expand Down Expand Up @@ -20364,6 +20417,7 @@ public function fetch_ticker ($symbol) {
$ticker = $tickers[$lastKey];
$timestamp = $this->milliseconds ();
return array (
'symbol' => $symbol,
'timestamp' => $timestamp,
'datetime' => $this->iso8601 ($timestamp),
'high' => floatval ($ticker['high']),
Expand Down Expand Up @@ -20673,7 +20727,7 @@ public function fetch_order_book ($symbol, $params = array ()) {
return $this->parse_order_book ($orderbook, $timestamp, 'Bids', 'Asks', 'Price', 'Volume');
}

public function parse_ticker ($ticker, $market) {
public function parse_ticker ($ticker, $market = null) {
$timestamp = 0;
$last = null;
if (array_key_exists ('LastBuyTimestamp', $ticker))
Expand All @@ -20688,7 +20742,11 @@ public function parse_ticker ($ticker, $market) {
}
if (!$timestamp)
$timestamp = $this->milliseconds ();
$symbol = null;
if ($market)
$symbol = $market['symbol'];
return array (
'symbol' => $symbol,
'timestamp' => $timestamp,
'datetime' => $this->iso8601 ($timestamp),
'high' => $ticker['DailyBestBuyPrice'],
Expand Down Expand Up @@ -20990,6 +21048,7 @@ public function fetch_ticker ($symbol) {
$ticker = $tickers[$market['id']];
$timestamp = $ticker['updated'] * 1000;
return array (
'symbol' => $symbol,
'timestamp' => $timestamp,
'datetime' => $this->iso8601 ($timestamp),
'high' => floatval ($ticker['high']),
Expand Down Expand Up @@ -21292,13 +21351,14 @@ public function fetch_order_book ($market, $params = array ()) {
return $this->parse_order_book ($orderbook);
}

public function fetch_ticker ($market) {
public function fetch_ticker ($symbol) {
$this->load_markets ();
$ticker = $this->publicGetTickerPair (array (
'pair' => $this->market_id ($market),
'pair' => $this->market_id ($symbol),
));
$timestamp = $this->milliseconds ();
return array (
'symbol' => $symbol,
'timestamp' => $timestamp,
'datetime' => $this->iso8601 ($timestamp),
'high' => $ticker['high'],
Expand Down
Loading

0 comments on commit 9899924

Please sign in to comment.