예제 #1
0
 private function curlRequest($query)
 {
     $url = 'http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20%28%22AAPL%22%29&env=store://datatables.org/alltableswithkeys';
     $client = new \Scheb\YahooFinanceApi\ApiClient();
     $data = $client->getQuotes($query);
     return $data["query"]["results"]["quote"];
 }
예제 #2
0
    }
    // saturday or sunday
    if (is_weekend($date)) {
        $date->modify('next monday');
    }
    return $date->format('Y-m-d');
}
$client = new \Scheb\YahooFinanceApi\ApiClient();
$mutual_funds = ['FPHAX', 'FRXIX'];
$funds = [];
foreach ($mutual_funds as $mutual_fund) {
    $symbol = $mutual_fund;
    $start_date = new DateTime('2015-09-01');
    $end_date = new DateTime('NOW');
    $history_nav = $client->getHistoricalData($symbol, $start_date, $end_date);
    $current_nav = $client->getQuotes($symbol);
    $current_nav = $current_nav['query']['results']['quote']['LastTradePriceOnly'];
    //print '<pre>';
    //print_r($history_nav);
    //print '</pre>';
    //exit;
    $interval = DateInterval::createFromDateString('first day of next month');
    $period = new DatePeriod($start_date, $interval, $end_date, DatePeriod::EXCLUDE_START_DATE);
    $trans_date[] = is_market_closed($start_date);
    $start_date_day = $start_date->format('d');
    if ($start_date_day < 15) {
        $days_till_fifteenth = 15 - $start_date_day;
        $fifteenth_day = $start_date->add(new DateInterval('P' . $days_till_fifteenth . 'D'));
        $trans_date[] = is_market_closed($fifteenth_day);
    }
    foreach ($period as $date) {