コード例 #1
0
ファイル: chartstock.php プロジェクト: kombat003/trader-dss
function load_trade_data($symb, $startDate, $endDate)
{
    global $db_hostname, $db_database, $db_user, $db_password, $scramble_names;
    global $timeStamps, $volData, $highData, $lowData, $openData, $closeData, $exch;
    global $first_date, $last_date;
    $first = true;
    $timeStamps = array();
    $highData = array();
    $lowData = array();
    $openData = array();
    $closeData = array();
    $volData = array();
    try {
        $pdo = new PDO("pgsql:host={$db_hostname};dbname={$db_database}", $db_user, $db_password);
        $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    } catch (PDOException $e) {
        die("ERROR: Cannot connect: " . $e->getMessage());
    }
    $query = "select date, high, low, open, close, volume from quotes where symb = '{$symb}' and exch = '{$exch}' and date >= '{$startDate}' and date <= '{$endDate}' order by date";
    foreach ($pdo->query($query) as $row) {
        $timeStamps[] = chartTime2(strtotime($row['date']));
        if ($first) {
            $first_date = $row['date'];
            $first = false;
        }
        $last_date = $row['date'];
        $highData[] = $row['high'];
        $lowData[] = $row['low'];
        $openData[] = $row['open'];
        $closeData[] = $row['close'];
        $volData[] = $row['volume'];
    }
}
コード例 #2
0
ファイル: close_ema.php プロジェクト: kombat003/trader-dss
 $first = true;
 try {
     $pdo = new PDO("pgsql:host={$db_hostname};dbname={$db_database}", $db_user, $db_password);
     $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
 } catch (PDOException $e) {
     die("ERROR: Cannot connect: " . $e->getMessage());
 }
 $query = "select a.date as date, ema_12, ema_26, open, high, low, close  from quotes a, moving_averages b where a.date = b.date and a.symb = b.symb and a.exch = b.exch and a.date >= '{$first_date}' and a.date <= '{$pf_working_date}' and a.symb = '{$symb}' and a.exch = '{$pf_exch}' order by a.date limit {$chart_period};";
 foreach ($pdo->query($query) as $row) {
     $open[] = $row['open'];
     $close[] = $row['close'];
     $high[] = $row['high'];
     $low[] = $row['low'];
     $ema_12[] = $row['ema_12'];
     $ema_26[] = $row['ema_26'];
     $dates[] = chartTime2(strtotime($row['date']));
     if ($first) {
         // save the first found date for the chart title
         $first_date = $row['date'];
         $first = false;
     }
 }
 // Set the plotarea at (50, 30) and of size 240 x 140 pixels. Use white (0xffffff)
 // background.
 $plotAreaObj = $c->setPlotArea(50, 45, 410, 400, 0xffffff, 0xffffff, 0xc0c0c0, 0xc0c0c0, 0xc0c0c0);
 // Add a legend box at (50, 185) (below of plot area) using horizontal layout. Use 8
 // pts Arial font with Transparent background.
 $legendObj = $c->addLegend(50, 455, false, "", 8);
 $legendObj->setBackground(Transparent);
 // Add a title box to the chart using 8 pts Arial Bold font, with yellow (0xffff40)
 // background and a black border (0x0)
コード例 #3
0
ファイル: phpchartdir.class.php プロジェクト: tmlsoft/main
function chartTime($y, $m = Null, $d = 1, $h = 0, $n = 0, $s = 0)
{
    if (is_null($m)) {
        return chartTime2($y);
    } else {
        return callmethod("chartTime", $y, $m, $d, $h, $n, $s);
    }
}