Example #1
0
<?php

require_once "../config.php";
require_once ABSPATH . "/util.php";
log_api('ticker');
list($high, $low, $avg, $vwap, $vol, $last, $buy, $sell) = get_ticker_data();
echo '{"ticker": {';
echo '"high": ' . $high . ', ';
echo '"low": ' . $low . ', ';
echo '"avg": ' . $avg . ', ';
echo '"vwap": ' . $vwap . ', ';
echo '"vol": ' . $vol . ', ';
echo '"last": ' . $last . ', ';
echo '"buy": ' . $buy . ', ';
echo '"sell": ' . $sell . '}}';
Example #2
0
function show_content_header_ticker()
{
    global $buy, $sell;
    $spaces = '&nbsp;&nbsp;&nbsp;&nbsp;';
    list($high, $low, $avg, $vwap, $vol, $last, $buy, $sell) = get_ticker_data();
    if ($buy > $sell && $buy != 0 && $sell != 0) {
        $style = " style='color:#af0;'";
    } else {
        $style = '';
    }
    // include prices up to 0.001% worse than the best
    $include_very_close_prices = '0.99999';
    // ask for 0.001% less than we need to match the worst price we want
    // $request_less_for_match = '0.99999';
    $request_less_for_match = '1';
    if ($buy) {
        list($buy_have, $buy_want, $worst_price) = find_total_trades_available_at_rate(bcmul($buy, $include_very_close_prices, 8), CURRENCY);
        $buy_have = bcmul(bcmul($buy_want, $worst_price), $request_less_for_match);
        $worst_price = clean_sql_numstr($worst_price);
        $buy_link = "<a {$style} href=\"?page=trade&in=BTC&have={$buy_want}&want={$buy_have}&rate={$worst_price}\">{$buy}</a>";
    } else {
        $buy_link = "none";
    }
    if ($sell) {
        list($sell_have, $sell_want, $worst_price) = find_total_trades_available_at_rate(bcdiv($sell, $include_very_close_prices, 8), 'BTC');
        $sell_have = bcmul(bcdiv($sell_want, $worst_price), $request_less_for_match);
        $worst_price = clean_sql_numstr($worst_price);
        $sell_link = "<a {$style} href=\"?page=trade&in=" . CURRENCY . "&have={$sell_want}&want={$sell_have}&rate={$worst_price}\">{$sell}</a>";
    } else {
        $sell_link = "none";
    }
    echo "    <div class='content_header_box'>\n";
    echo "    ", SPACE, _("24 hour volume"), ": <a class=\"fancy\" href=\"?fancy&page=view_trades\">{$vol} BTC</a></div>\n";
    echo "    <div class='content_header_box'>\n";
    echo "        ", SPACE;
    echo _("buy") . ": {$buy_link}{$spaces}" . _("sell") . ": {$sell_link}";
    echo SPACE, _("last") . ": {$last}", SPACE, _("high") . ": {$high}", SPACE, _("low") . ": {$low}", SPACE, _("avg") . ": {$vwap}\n";
    echo "    </div>\n";
}