} //Deposits EOF /* * @author marinu666 * @license MIT License - https://github.com/marinu666/PHP-btce-api */ if ($btce_price) { require_once 'btce-api.php'; $BTCeAPI = new BTCeAPI('', ''); $btc_usd = array(); //$btc_usd['fee'] = $BTCeAPI->getPairFee('btc_usd'); // Ticker Call $pair2 = get_unit($coin_code[$x]); try { $pair = strtolower($coin_code[$x]) . $pair2; $btc_usd = $BTCeAPI->getPairTicker($pair); $usd = $btc_usd['ticker']['avg']; #print $pair."\t".$usd.PHP_EOL; $sql = "SELECT * FROM config WHERE `key` = '{$coin_code[$x]}';"; $q = mysqli_query($GLOBALS["___mysqli_ston"], $sql); if (!mysqli_num_rows($q)) { $sql = "INSERT INTO config(`key`,`value`,`explain`) VALUES ('{$coin_code[$x]}','{$usd}','BTC-E {$pair} current price');"; } else { $sql = "UPDATE config SET `value` = '{$usd}' WHERE `key` = '{$coin_code[$x]}';"; } $q = mysqli_query($GLOBALS["___mysqli_ston"], $sql); } catch (BTCeAPIException $e) { echo $e->getMessage(); } } }
// Show info for the btc_usd pair // Perform the API Query print_r($BTCeAPI->apiQuery('ActiveOrders', $params)); } catch (BTCeAPIException $e) { echo $e->getMessage(); } // Making an order try { /* * CAUTION: THIS IS COMMENTED OUT SO YOU CAN READ HOW TO DO IT! */ // $BTCeAPI->makeOrder(---AMOUNT---, ---PAIR---, BTCeAPI::DIRECTION_BUY/BTCeAPI::DIRECTION_SELL, ---PRICE---); // Example: to buy a bitcoin for $100 // $BTCeAPI->makeOrder(1, 'btc_usd', BTCeAPI::DIRECTION_BUY, 100); } catch (BTCeAPIInvalidParameterException $e) { echo $e->getMessage(); } catch (BTCeAPIException $e) { echo $e->getMessage(); } // Example Public API JSON Request (Such as Fee / BTC_USD Tickers etc) - The result you get back is JSON RESTed to PHP // Fee Call $btc_usd = array(); $btc_usd['fee'] = $BTCeAPI->getPairFee('btc_usd'); // Ticker Call $btc_usd['ticker'] = $BTCeAPI->getPairTicker('btc_usd'); // Trades Call $btc_usd['trades'] = $BTCeAPI->getPairTrades('btc_usd'); // Depth Call $btc_usd['depth'] = $BTCeAPI->getPairDepth('btc_usd'); // Show all information print_r($btc_usd);
public function actionRun() { if ($_SERVER['HTTP_HOST'] !== 'btcbot.loc') { return; } $BTCeAPI = new BTCeAPI(); $ticker = $BTCeAPI->getPairTicker('btc_rur'); $ticker = $ticker['ticker']; /* $exchange = new Exchange(); $exchange->buy = $ticker['buy']; $exchange->sell = $ticker['sell']; $exchange->dt = date('Y-m-d H:i:s', $ticker['updated']); $exchange->save(); $bot = new Bot($exchange); $bot->NeedBuy($ticker['updated']); $this->render('index'); */ }
/* [ticker] => Array ( [high] => 32.76 [low] => 24.6 [avg] => 28.68 [vol] => 35240071.99188 [vol_cur] => 1203974.38994 [last] => 30.8 [buy] => 30.8 [sell] => 30.77 [updated] => 1386609891 [server_time] => 1386609892 ) */ $tickerLtcUsd = $BTCeAPI->getPairTicker('ltc_usd'); $tickerBtcUsd = $BTCeAPI->getPairTicker('btc_usd'); $tickerNmcUsd = $BTCeAPI->getPairTicker('nmc_usd'); $tickerNvcUsd = $BTCeAPI->getPairTicker('nvc_usd'); $tickerPpcUsd = $BTCeAPI->getPairTicker('ppc_usd'); // Save to database $result = $mysqli->query("INSERT INTO `bitbot`.`ticker` (`ltc_usd`,`btc_usd`,`nmc_usd`,`nvc_usd`,`ppc_usd`,`timestamp`) VALUES ('" . $tickerLtcUsd['ticker']['buy'] . "', '" . $tickerBtcUsd['ticker']['buy'] . "', '" . $tickerNmcUsd['ticker']['buy'] . "', '" . $tickerNvcUsd['ticker']['buy'] . "', '" . $tickerPpcUsd['ticker']['buy'] . "', '" . time() . "');"); if (!$result) { echo "MySQL error: " . $mysqli->error . PHP_EOL; exit; } // Clean database $result = $mysqli->query("DELETE FROM `bitbot`.`ticker` WHERE `ticker`.`timestamp` < " . (time() - 60 * 60 * 24 * 2)); if (!$result) { echo "MySQL error: " . $mysqli->error . PHP_EOL; exit;