コード例 #1
0
ファイル: chart.php プロジェクト: kombat003/trader-dss
            }
            if ($value == $symb) {
                // record the previous one so that we can use it later
                $save_next = true;
                $prev_symbol = $save_prev_symb;
            }
            $save_prev_symb = $value;
        }
    }
    if (!isset($symb)) {
        $symb = $first_symb;
    }
    if (!isset($prev_symbol)) {
        $prev_symbol = $first_symb;
    }
    $symb_name = get_symb_name($symb, $pf_exch);
    print '<form action="' . $_SERVER['REQUEST_URI'] . '" method="post" name="chart" id="chart">';
    print "<h1 align=\"center\">{$symb}.{$pf_exch}: {$symb_name}</h1>";
    print '<table border="1" cellpadding="5" cellspacing="0" align="center">';
    print '<tr><td><table width="100%" border="0"><tr><td>&lt;---<a href=' . $_SERVER['PHP_SELF'] . "?TickerSymbol={$prev_symbol}>{$prev_symbol}.{$pf_exch}</a></td>";
    print "<td>" . create_dropdown("TickerSymbol", $pairs, "TickerSymbol", "", $symb) . "</td>";
    print "<td><a href=" . $_SERVER['PHP_SELF'] . "?TickerSymbol={$next_symb}>{$next_symb}.{$pf_exch}</a>---&gt;</td></tr></table><tr><td><img SRC=\"/cgi-bin/chartstock.php?TickerSymbol={$symb}&TimeRange={$chart_period}&working_date={$pf_working_date}&exch={$pf_exch}&ChartSize=S&Volume=1&VGrid=1&HGrid=1&LogScale=0&ChartType=OHLC&Band=None&avgType1=SMA&movAvg1=10&avgType2=SMA&movAvg2=25&Indicator1=RSI&Indicator2=MACD&Indicator3=WilliamR&Indicator4=TRIX&Button1=Update%20Chart\" ALIGN=\"bottom\" BORDER=\"0\"></td></tr>";
    print "<tr><td><img SRC=\"/cgi-bin/close_sma.php?symb={$symb}\" ALIGN=\"bottom\" BORDER=\"0\"></td></tr>";
    print "<tr><td><img SRC=\"/cgi-bin/close_ma_diff.php?symb={$symb}\" ALIGN=\"bottom\" BORDER=\"0\"></td></tr>";
    print "<tr><td><img SRC=\"/cgi-bin/close_ema.php?symb={$symb}\" ALIGN=\"bottom\" BORDER=\"0\"></td></tr>";
    print "<tr><td><img SRC=\"/cgi-bin/exchange_indicators.php\" ALIGN=\"bottom\" BORDER=\"0\"></td></tr>";
    print "</table>\n";
    print "</form>\n";
} else {
    tr_warn('No username in cookie');
}
コード例 #2
0
ファイル: booty.php プロジェクト: kombat003/trader-dss
        foreach ($pdo->query($query) as $row) {
            $holdings = $row['value'];
        }
        if ($holdings == '') {
            $holdings = 0;
        }
        $query = "insert into pf_summary (pfid, date, cash_in_hand, holdings) values ('{$pf_id}', '{$next_trade_day}', '{$cash_in_hand}', '{$holdings}');";
        $pdo->exec($query);
        $pdo->commit();
        // recreate the portfolio because the dates have changed.
        $portfolio = new portfolio($pf_id);
        // sell anything that's now hit the stop loss
        stop_loss($portfolio);
        // might be wisest to re-create the $portfolio now, but the page is reloaded below which will do the same thing
    } catch (PDOException $e) {
        tr_warn('booty.php: next day failed' . $query . ':' . $e->getMessage());
    }
    // must save the session and redraw the page because the header is already drawn and can't be updated with the new totals
    update_holdings($portfolio);
    header("Location: {$this_page}");
    exit;
} elseif (isset($_POST['sell'])) {
    update_session();
    if (isset($_POST['mark'])) {
        $marked = $_POST['mark'];
        foreach ($marked as $hid) {
            $symb = get_hid_symb($hid);
            sell_stock($hid, $symb, $_POST["comment_{$hid}"]);
        }
        $portfolio = new portfolio($_SESSION['pfid']);
    }
コード例 #3
0
ファイル: portfolios.php プロジェクト: kombat003/trader-dss
function delete_portfolio($pfid)
{
    global $pdo;
    try {
        $pdo->beginTransaction();
        $query = "delete from watch where pfid = '{$pfid}';";
        $pdo->exec($query);
        $query = "delete from cart where pfid = '{$pfid}';";
        $pdo->exec($query);
        $query = "delete from holdings where pfid = '{$pfid}';";
        $pdo->exec($query);
        $query = "delete from trades where pfid = '{$pfid}';";
        $pdo->exec($query);
        $query = "delete from pf_summary where pfid = '{$pfid}';";
        $pdo->exec($query);
        $query = "delete from portfolios where pfid = '{$pfid}';";
        $pdo->exec($query);
        $pdo->commit();
        if ($pfid == $_SESSION['pfid']) {
            // we've deleted the currently active portfolio, reset the session variable
            unset($_SESSION['pfid']);
            $this_page = $_SERVER['REQUEST_URI'];
            header("Location: {$this_page}");
        }
    } catch (PDOException $e) {
        tr_warn('delete_portfolio:' . $query . ':' . $e->getMessage());
        $pdo->rollBack();
    }
}
コード例 #4
0
ファイル: queries.php プロジェクト: kombat003/trader-dss
        // do we have a qid? if so save these to that
        try {
            $query = "select nextval('queries_qid_seq') as qid;";
            $result = $pdo->query($query);
            $row = $result->fetch(PDO::FETCH_ASSOC);
            $next_qid = $row['qid'];
        } catch (PDOException $e) {
            tr_warn('queries.php:' . $query . ':' . $e->getMessage());
            return false;
        }
        $query = "insert into queries (qid, uid, name, sql_select, sql_from, sql_where, sql_order, sql_order_dir, sql_limit, chart_period, active) values ({$next_qid}, {$uid}, '{$sql_name}', '{$sql_select}', '{$sql_from}', '{$sql_where}', '{$sql_order}', '{$sql_order_dir}', '{$sql_limit}', '{$chart_period}', TRUE);";
        try {
            $pdo->exec($query);
            $_SESSION['qid'] = $next_qid;
        } catch (PDOException $e) {
            tr_warn("html/queries.php: {$query} " . ':' . $e->getMessage());
        }
        // changed both forms, so reload them
        $select_query_form = new HTML_QuickForm('select_query');
        create_select_query_form();
        $sql_input_form = new HTML_QuickForm('sql_input');
        create_sql_input_form();
    }
}
if (isset($_POST['del_sql'])) {
    $query = "update queries set active = FALSE where qid = {$q_id};";
    $pdo->exec($query);
    $select_query_form = new HTML_QuickForm('select_query');
    create_select_query_form();
}
print '<table border="1" cellpadding="5" cellspacing="0" align="center">';
コード例 #5
0
 public function __construct($symb, $portfolio)
 {
     // setup the the parent class (db connection etc)
     $workingDate = $portfolio->getWorkingDate();
     $exch = $portfolio->exch->getID();
     $pfid = $portfolio->getID();
     $this->pfid = $pfid;
     parent::__construct($symb, $exch, $workingDate);
     // load the info from the stocks table
     $query = "select * from holdings where symb = '{$symb}' and pfid = '{$pfid}';";
     try {
         $result = $this->dbh->query($query);
     } catch (PDOException $e) {
         tr_warn('holding:__construct:' . $query . ':' . $e->getMessage());
         die("[FATAL]Class: holding, function: __construct\n");
     }
     $row = $result->fetch(PDO::FETCH_ASSOC);
     if (isset($row['symb']) and $row['symb'] == $symb) {
         $this->hid = $row['hid'];
         $this->pfid = $row['pfid'];
         $this->openDate = $row['date'];
         $this->price = $row['price'];
         $this->qty = $row['volume'];
         $this->comment = $row['comment'];
     }
 }