-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathYahooFinance.php
41 lines (35 loc) · 1.05 KB
/
YahooFinance.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
require_once("Finance.php");
class YahooFinance extends FinanceProvider{
var $_url_parts;
var $_url_protocol;
var $_url = false;
//"http://ichart.finance.yahoo.com/table.csv?a=00&b=1&c=2011&d=11&e=31&f=2011&g=d&ignore=.csv&s=%s"
function __construct($date_array = null){
$this->_url_protocol = "http";
$this->_url_parts = array(
'prefix' => 'ichart.finance.yahoo.com/table.csv',
'start_month' => array('a', 00),
'start_dayofmonth' => array('b', 1),
'start_year' => array('c', 2011),
'end_month' => array('d', 11),
'end_dayofmonth' => array('e', 31),
'end_year' => array('f', 2011),
'frequency' => array('g', 'd'),
'ticker_symbol' => array('s', '%s'),
'suffix' => array('ignore', '.csv')
);
if($date_array !== null){
foreach($date_array as $key => $value){
if(isset($this->_url_parts[$key])){
$this->_url_parts[$key][1] = $value;
}
}
}
}
function fetchStockData($ticker_symbol){
$data = parent::fetchStockData($ticker_symbol);
$headers = array_shift($data);
return array_reverse($data);
}
}