Skip to content

Commit

Permalink
Merge pull request #16 from hhxsv5/master
Browse files Browse the repository at this point in the history
Add getAllTickers()
  • Loading branch information
hhxsv5 authored Feb 19, 2019
2 parents 84878e1 + aa89b61 commit a8f67d7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/PublicApi/Symbol.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@ public function getTicker($symbol)
return $response->getApiData();
}

/**
* Get all tickers
* @return array
* @throws \KuCoin\SDK\Exceptions\BusinessException
* @throws \KuCoin\SDK\Exceptions\HttpException
* @throws \KuCoin\SDK\Exceptions\InvalidApiUriException
*/
public function getAllTickers()
{
$response = $this->call(Request::METHOD_GET, '/api/v1/market/allTickers');
return $response->getApiData();
}

/**
* Get part order book(aggregated)
* @param string $symbol
Expand Down
24 changes: 24 additions & 0 deletions tests/SymbolTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,30 @@ public function testGetTicker(Symbol $api)
$this->assertArrayHasKey('bestAskSize', $data);
}

/**
* @depends testNewSymbol
* @param Symbol $api
* @throws \KuCoin\SDK\Exceptions\BusinessException
* @throws \KuCoin\SDK\Exceptions\HttpException
* @throws \KuCoin\SDK\Exceptions\InvalidApiUriException
*/
public function testGetAllTickers(Symbol $api)
{
$tickers = $api->getAllTickers();
$this->assertInternalType('array', $tickers);
foreach ($tickers as $ticker) {
$this->assertArrayHasKey('symbol', $ticker);
$this->assertArrayHasKey('high', $ticker);
$this->assertArrayHasKey('vol', $ticker);
$this->assertArrayHasKey('low', $ticker);
// $this->assertArrayHasKey('changePrice', $ticker);
$this->assertArrayHasKey('changeRate', $ticker);
$this->assertArrayHasKey('close', $ticker);
$this->assertArrayHasKey('volValue', $ticker);
$this->assertArrayHasKey('open', $ticker);
}
}

/**
* @depends testNewSymbol
* @param Symbol $api
Expand Down

0 comments on commit a8f67d7

Please sign in to comment.