Skip to content

Commit

Permalink
Remove multiset per Quandls deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
DannyBen committed Dec 13, 2014
1 parent cbff517 commit f026b49
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 68 deletions.
23 changes: 0 additions & 23 deletions Quandl.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class Quandl {

private static $url_templates = [
"symbol" => 'https://www.quandl.com/api/v1/datasets/%s.%s?%s',
"symbols" => 'https://www.quandl.com/api/v1/multisets.%s?columns=%s&%s',
"search" => 'https://www.quandl.com/api/v1/datasets.%s?%s',
"list" => 'http://www.quandl.com/api/v2/datasets.%s?%s',
];
Expand All @@ -33,18 +32,6 @@ public function getSymbol($symbol, $params=null) {
return $this->getData($url);
}

// getSymbols returns data for an array of symbols.
// Symbols may be in slash or dot notation and may include
// column specifier.
public function getSymbols($symbols, $params=null) {
$url = $this->getUrl("symbols",
$this->getFormat(),
self::convertSymbolsToMulti($symbols),
$this->arrangeParams($params));

return $this->getData($url);
}

// getSearch returns results for a search query.
// CSV output is not supported with this node so if format
// is set to CSV, the result will fall back to object mode.
Expand Down Expand Up @@ -162,16 +149,6 @@ private function arrangeParams($params) {
private static function convertToQuandlDate($time_str) {
return date("Y-m-d", strtotime($time_str));
}

// convertSymbolsToMulti converts an array of symbols to
// the format needed for a multiset request.
private static function convertSymbolsToMulti($symbols_array) {
$result = [];
foreach($symbols_array as $symbol) {
$result[] = str_replace("/", ".", $symbol);
}
return implode(",", $result);
}
}

?>
19 changes: 2 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,10 @@ any date string that PHP's `strtotime()` understands.
"trim_end" => "today",
]);

Multiple symbols, supported symbols and search methods are also
available:
You can also search the entire Quandl database and get a list of
supported symbols in a data source:

$quandl = new Quandl($api_key);
$data = $quandl->getSymbols(["WIKI/AAPL", "WIKI/CSCO"]);
$data = $quandl->getSearch("crude oil");
$data = $quandl->getList("WIKI", 1, 10);

Expand Down Expand Up @@ -106,20 +105,6 @@ You do not need to pass `auth_token` in the array, it will be
automatically appended.


### getSymbols

`mixed getSymbols( array $symbols [, array $params ] )`

Same as `getSymbol()` only instead of a single symbol, it receives
an array of multiple symbols. Each symbol in the array may be
listed using the slash notation (`WIKI/AAPL`) or dot notation
(`WIKI.AAPL`).

In addition, you may append the column selector to each symbol in
order to get only selected columns. For example, `WIKI/AAPL.4` will
return only the close prices (column 4) of AAPL.


### getSearch

`mixed getSearch( string $query [, int $page, int $per_page] )`
Expand Down
26 changes: 6 additions & 20 deletions examples.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
$symbol = "GOOG/NASDAQ_AAPL";

// Uncomment and modify this call to check different samples
// $data = example9($api_key, $symbol);
// $data = example3($api_key, $symbol);
// print_r($data);

// Example 1: Hello Quandl
Expand Down Expand Up @@ -53,34 +53,20 @@ function example5($api_key, $symbol) {
]);
}

// Example 6: Multiple Symbols
// Example 6: Search
function example6($api_key, $symbol) {
$quandl = new Quandl($api_key, "csv");
return $quandl->getSymbols(["GOOG/NASDAQ_AAPL", "GOOG/NASDAQ_CSCO"]);
}

// Example 7: Multiple Symbols with Column Selector and Options
function example7($api_key, $symbol) {
$quandl = new Quandl($api_key, "csv");
$symbols = ["GOOG/NASDAQ_AAPL.4", "GOOG/NASDAQ_CSCO.4"];
$options = ["rows" => 10];
return $quandl->getSymbols($symbols, $options);
}

// Example 8: Search
function example8($api_key, $symbol) {
$quandl = new Quandl($api_key);
return $quandl->getSearch("crude oil");
}

// Example 9: Symbol Lists
function example9($api_key, $symbol) {
// Example 7: Symbol Lists
function example7($api_key, $symbol) {
$quandl = new Quandl($api_key, "csv");
return $quandl->getList("WIKI", 1, 10);
}

// Example 10: Error Handling
function example10($api_key, $symbol) {
// Example 8: Error Handling
function example8($api_key, $symbol) {
$quandl = new Quandl($api_key, "csv");
$result = $quandl->getSymbol("DEBUG/INVALID");
if($quandl->error and !$result)
Expand Down
8 changes: 0 additions & 8 deletions tests/QuandlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@ public function testInvalidUrl() {
"TEST invalidUrl response");
}

public function testGetSymbols() {
$quandl = new Quandl($this->api_key, "json");
$r = $quandl->getSymbols($this->symbols, $this->dates);
$sig = md5($r);
$this->assertEquals("56fdde06b1cc699286b2e3bdaaf40761", $sig,
"TEST getSymbols checksum");
}

public function testGetList() {
$quandl = new Quandl($this->api_key);
$r = $quandl->getList("WIKI", 1, 10);
Expand Down

0 comments on commit f026b49

Please sign in to comment.