Beispiel #1
0
 public static function get_Instance()
 {
     if (!self::$self) {
         self::$self = new BTCeAPI();
     }
     return self::$self;
 }
Beispiel #2
0
                     mysqli_query($GLOBALS["___mysqli_ston"], "INSERT INTO movements(`account_id`,`dtime`,`description`,`amount`,`credit`,`balance`,`txblock`) VALUES({$act['id']},'" . date("Y-m-d H:i:s") . "','{$coin_list[$x]} Network Fee',{$fee},0,{$nextBal},{$cBlock})");
                     mysqli_query($GLOBALS["___mysqli_ston"], "UPDATE accounts SET balance = balance - {$fee} WHERE id = {$act['id']}");
                 }
             }
         }
     }
     //Forward EOF
 }
 //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]}';";
Beispiel #3
0
 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');
     */
 }
Beispiel #4
0
 public function CancelOrder($order)
 {
     // Если отменяем виртуально
     if (self::isVirtual) {
         return $this->CancelOrderVirtual($order);
     }
     $BTCeAPI = BTCeAPI::get_Instance();
     try {
         $res = $BTCeAPI->apiQuery('CancelOrder', array('order_id' => $order->id));
     } catch (BTCeAPIException $e) {
         Log::Error('Не удалось удалить ордер ' . $e->getMessage());
         return false;
     }
     return $res;
 }
/*
Update the current trade signal 
*/
function update_trade_signal($last_action_data)
{
    global $db, $context;
    $queryD = 'UPDATE ' . $context['tradeDataTable'] . ' SET 
        trade_signal="' . $last_action_data['trade_signal'] . '",
        last_updated="' . date('Y-m-d H:i:s', time()) . '"
        WHERE currency="' . $last_action_data['currency'] . '" 
            AND exchange="btc-e"';
    $queryD = $db->query($queryD);
}
include_once 'include/api_btc_e.php';
include_once 'include/config.php';
$btceAPI = $api = new BTCeAPI(BTCE_API_KEY, BTCE_API_SECRET);
$currencyPair = array('btc_usd', 'ltc_usd', 'ltc_btc');
foreach ($currencyPair as $cPair) {
    $allPrices[$cPair]['lastPrice'] = $api->getLastPrice($cPair);
    $allPrices[$cPair]['buyPrice'] = $api->getBuyPrice($cPair);
    $allPrices[$cPair]['sellPrice'] = $api->getSellPrice($cPair);
    $allPrices[$cPair]['highPrice'] = $api->getHighPrice($cPair);
    $allPrices[$cPair]['lowPrice'] = $api->getLowPrice($cPair);
}
date_default_timezone_set('America/New_York');
$debug = $_GET['debug'];
//debug mode
global $totalBalance, $api;
//total balance in your account
if ($debug == 1) {
    $output = '<< debug mode >>';
Beispiel #6
0
<?php

/**
 * Example Usage of the BTCe API PHP Class
 *
 * @author marinu666
 * @license MIT License - https://github.com/marinu666/PHP-btce-api
 */
require_once 'btce-api.php';
$BTCeAPI = new BTCeAPI('', '');
// Example getInfo
try {
    // Perform the API Call
    $getInfo = $BTCeAPI->apiQuery('getInfo');
    // Print so we can see the output
    print_r($getInfo);
} catch (BTCeAPIException $e) {
    echo $e->getMessage();
}
// Example Custom query
try {
    // Input Parameters as an array (see: https://btc-e.com/api/documentation for list of parameters per call)
    $params = array('pair' => 'btc_usd');
    // 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 {
Beispiel #7
0
#!/usr/bin/php
<?php 
chdir(dirname(__FILE__));
require_once './btce-api/btce-api.php';
require_once 'profiles/ticker.profile.php';
// Connect to MySQl
$mysqli = new mysqli($CONFIG['mysql_host'], $CONFIG['mysql_user'], $CONFIG['mysql_password'], $CONFIG['mysql_database']);
if ($mysqli->connect_errno) {
    echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error . PHP_EOL;
    exit;
}
// Connect to BTC-e
$BTCeAPI = new BTCeAPI($CONFIG['btce_api_key'], $CONFIG['btce_api_secret'], '/tmp/nonce-ticker');
// Get Ticker
try {
    /*
    [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');
Beispiel #8
0
 /**
  * @param BTCeAPI $api
  * @return mixed
  * @throws BTCeAPIException
  */
 public function load(BTCeAPI &$api)
 {
     $qRes = $api->apiQuery('getInfo');
     if (isset($qRes['return']) && isset($qRes['return']['funds'])) {
         log_msg("Connection success, server time: " . date('Y.m.d H:i:s', $qRes['return']['server_time']));
         $qRes['return']['updated'] = time();
         $this->import($qRes['return']['funds']);
     } else {
         throw new BTCeAPIException(StorageException::$messages[StorageException::NO_DATA_IN_RESULT]);
     }
     return true;
 }
Beispiel #9
0
 public static function updatePrices($pair = 'btc_rur')
 {
     $BTCeAPI = BTCeAPI::get_Instance();
     $ticker = $BTCeAPI->getPairTicker($pair);
     $ticker = $ticker['ticker'];
     $exchange = new Exchange();
     $exchange->buy = $ticker['buy'];
     $exchange->sell = $ticker['sell'];
     $exchange->dtm = date('Y-m-d H:i:s', $ticker['updated']);
     $exchange->pair = $pair;
     $exchange->save();
     return $exchange;
 }