mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-08-23 17:37:25 +00:00
api: remove bter.com stuff
This commit is contained in:
parent
64ee803369
commit
20655e5700
11 changed files with 6 additions and 252 deletions
|
@ -47,7 +47,6 @@ define('EXCH_CRYPTOPIA_KEY', '');
|
|||
define('EXCH_POLONIEX_KEY', '');
|
||||
define('EXCH_BITTREX_KEY', '');
|
||||
define('EXCH_BLEUTRADE_KEY', '');
|
||||
define('EXCH_BTER_KEY', '');
|
||||
define('EXCH_YOBIT_KEY', '');
|
||||
define('EXCH_CCEX_KEY', '');
|
||||
define('EXCH_CEXIO_ID', '');
|
||||
|
|
|
@ -50,8 +50,7 @@ class CoindbCommand extends CConsoleCommand
|
|||
|
||||
} elseif ($args[0] == 'icons') {
|
||||
|
||||
$nbUpdated = $this->grabBterIcons();
|
||||
$nbUpdated += $this->grabCcexIcons();
|
||||
$nbUpdated = $this->grabCcexIcons();
|
||||
$nbUpdated += $this->grabCryptopiaIcons();
|
||||
$nbUpdated += $this->grabBittrexIcons(); // can be huge ones
|
||||
$nbUpdated += $this->grabCoinExchangeIcons();
|
||||
|
@ -295,41 +294,6 @@ class CoindbCommand extends CConsoleCommand
|
|||
return $nbUpdated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Icon grabber - Bter
|
||||
*/
|
||||
public function grabBterIcons()
|
||||
{
|
||||
$url = 'http://bter.com/images/coin_icon/64/';
|
||||
$nbUpdated = 0;
|
||||
$sql = "SELECT DISTINCT coins.id FROM coins INNER JOIN markets M ON M.coinid = coins.id WHERE M.name='bter' AND IFNULL(coins.image,'') = ''";
|
||||
$coins = dbolist($sql);
|
||||
if (empty($coins))
|
||||
return 0;
|
||||
echo "bter: try to download new icons...\n";
|
||||
foreach ($coins as $coin) {
|
||||
$coin = getdbo('db_coins', $coin["id"]);
|
||||
$symbol = $coin->symbol;
|
||||
if (!empty($coin->symbol2)) $symbol = $coin->symbol2;
|
||||
$local = $this->basePath."/images/coin-{$symbol}.png";
|
||||
try {
|
||||
$data = @ file_get_contents($url.strtolower($symbol).'.png');
|
||||
} catch (Exception $e) {
|
||||
continue;
|
||||
}
|
||||
if (strlen($data) < 2048) continue;
|
||||
echo $coin->symbol." icon found\n";
|
||||
file_put_contents($local, $data);
|
||||
if (filesize($local) > 0) {
|
||||
$coin->image = "/images/coin-{$symbol}.png";
|
||||
$nbUpdated += $coin->save();
|
||||
}
|
||||
}
|
||||
if ($nbUpdated)
|
||||
echo "$nbUpdated icons downloaded from bter\n";
|
||||
return $nbUpdated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Icon grabber - Bittrex
|
||||
*/
|
||||
|
|
|
@ -153,11 +153,6 @@ class ExchangeCommand extends CConsoleCommand
|
|||
if (!is_object($balance)) echo "bleutrade error\n";
|
||||
else echo("bleutrade btc: ".json_encode($balance->result)."\n");
|
||||
}
|
||||
if (!empty(EXCH_BTER_KEY)) {
|
||||
$info = bter_api_user('getfunds');
|
||||
if (!$info || arraySafeVal($info,'result') != 'true' || !isset($info['available_funds'])) echo "bter error\n";
|
||||
else echo("bter available: ".json_encode($info['available_funds'])."\n");
|
||||
}
|
||||
if (!empty(EXCH_CCEX_KEY)) {
|
||||
$ccex = new CcexAPI;
|
||||
$balances = $ccex->getBalances();
|
||||
|
@ -197,7 +192,7 @@ class ExchangeCommand extends CConsoleCommand
|
|||
echo("kraken btc: ".json_encode($balance)."\n");
|
||||
}
|
||||
if (!empty(EXCH_KUCOIN_KEY)) {
|
||||
$balance = kucoin_api_user('accounts',array('currency=BTC'));
|
||||
$balance = kucoin_api_user('accounts'/*,array('currency=BTC')*/);
|
||||
if (!is_object($balance) || !isset($balance->data)) echo "kucoin error ".json_encode($balance)."\n";
|
||||
else echo("kucoin: ".json_encode($balance->data)."\n");
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ function BackendPricesUpdate()
|
|||
|
||||
market_set_default('c-cex', 'DCR', 'disabled', true); // no deposit
|
||||
market_set_default('yobit', 'DCR', 'disabled', true); // no withdraw
|
||||
market_set_default('bter', 'SFR', 'disabled', true);
|
||||
|
||||
settings_prefetch_all();
|
||||
|
||||
|
@ -28,7 +27,6 @@ function BackendPricesUpdate()
|
|||
updateYobitMarkets();
|
||||
updateAlcurexMarkets();
|
||||
updateBinanceMarkets();
|
||||
updateBterMarkets();
|
||||
//updateEmpoexMarkets();
|
||||
updateJubiMarkets();
|
||||
updateLiveCoinMarkets();
|
||||
|
@ -1430,49 +1428,6 @@ function updateBinanceMarkets()
|
|||
}
|
||||
}
|
||||
|
||||
function updateBterMarkets()
|
||||
{
|
||||
$exchange = 'bter';
|
||||
if (exchange_get($exchange, 'disabled')) return;
|
||||
|
||||
$list = getdbolist('db_markets', "name LIKE '$exchange%'");
|
||||
if (empty($list)) return;
|
||||
|
||||
$markets = bter_api_query('tickers');
|
||||
if(!is_array($markets)) return;
|
||||
|
||||
foreach($list as $market)
|
||||
{
|
||||
$coin = getdbo('db_coins', $market->coinid);
|
||||
if(!$coin) continue;
|
||||
|
||||
$symbol = $coin->getOfficialSymbol();
|
||||
if (market_get($exchange, $symbol, "disabled")) {
|
||||
$market->disabled = 1;
|
||||
$market->message = 'disabled from settings';
|
||||
$market->save();
|
||||
continue;
|
||||
}
|
||||
|
||||
$dbpair = strtolower($symbol).'_btc';
|
||||
foreach ($markets as $pair => $ticker) {
|
||||
if ($pair != $dbpair) continue;
|
||||
|
||||
$market->price = AverageIncrement($market->price, $ticker['buy']);
|
||||
$market->price2 = AverageIncrement($market->price2, $ticker['avg']);
|
||||
$market->pricetime = time();
|
||||
if ($market->disabled < 9) $market->disabled = (floatval($ticker['vol_btc']) < 0.01);
|
||||
$market->save();
|
||||
|
||||
if (empty($coin->price2)) {
|
||||
$coin->price = $market->price;
|
||||
$coin->price2 = $market->price2;
|
||||
$coin->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function updateEmpoexMarkets()
|
||||
{
|
||||
$exchange = 'empoex';
|
||||
|
@ -1530,8 +1485,8 @@ function updateKuCoinMarkets()
|
|||
$symbols = kucoin_api_query('symbols','market=BTC');
|
||||
if(!kucoin_result_valid($symbols) || empty($symbols->data)) return;
|
||||
|
||||
$markets = kucoin_api_query('markets/allTickers');
|
||||
if(!kucoin_result_valid($markets) || empty($markets->data)) return;
|
||||
//$markets = kucoin_api_query('markets/allTickers'); // useless daily stats
|
||||
//if(!kucoin_result_valid($markets) || empty($markets->data)) return;
|
||||
|
||||
foreach($list as $market)
|
||||
{
|
||||
|
@ -1560,7 +1515,7 @@ function updateKuCoinMarkets()
|
|||
$market->save();
|
||||
if ($market->disabled) continue;
|
||||
}
|
||||
|
||||
/*
|
||||
foreach ($markets->data as $ticker) {
|
||||
if ($ticker->symbol != $pair) continue;
|
||||
if (objSafeVal($ticker,'buy',-1) == -1) continue;
|
||||
|
@ -1580,6 +1535,7 @@ function updateKuCoinMarkets()
|
|||
$coin->save();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ function updateRawcoins()
|
|||
|
||||
exchange_set_default('alcurex', 'disabled', true);
|
||||
exchange_set_default('binance', 'disabled', true);
|
||||
exchange_set_default('bter', 'disabled', true);
|
||||
exchange_set_default('empoex', 'disabled', true);
|
||||
exchange_set_default('coinbene', 'disabled', true);
|
||||
exchange_set_default('coinexchange', 'disabled', true);
|
||||
|
@ -128,26 +127,6 @@ function updateRawcoins()
|
|||
}
|
||||
}
|
||||
|
||||
if (!exchange_get('bter', 'disabled')) {
|
||||
$list = bter_api_query('marketlist');
|
||||
if(is_object($list) && is_array($list->data))
|
||||
{
|
||||
dborun("UPDATE markets SET deleted=true WHERE name='bter'");
|
||||
foreach($list->data as $item) {
|
||||
if (strtoupper($item->curr_b) !== 'BTC')
|
||||
continue;
|
||||
if (strpos($item->name, 'Asset') !== false)
|
||||
continue;
|
||||
if (strpos($item->name, 'BitShares') !== false && $item->symbol != 'BTS')
|
||||
continue;
|
||||
// ignore some dead coins and assets
|
||||
if (in_array($item->symbol, array('BITGLD','DICE','ROX','TOKEN')))
|
||||
continue;
|
||||
updateRawCoin('bter', $item->symbol, $item->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!exchange_get('yobit', 'disabled')) {
|
||||
$res = yobit_api_query('info');
|
||||
if($res)
|
||||
|
|
|
@ -1,71 +0,0 @@
|
|||
<?php
|
||||
|
||||
// http://data.bter.com/api/1/marketlist
|
||||
|
||||
function bter_api_query($method, $params='')
|
||||
{
|
||||
$uri = 'http://data.bter.com/api/1/'.$method;
|
||||
if (!empty($params))
|
||||
$uri .= '/'.$params;
|
||||
|
||||
$ch = curl_init($uri);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
|
||||
|
||||
$data = strip_tags(curl_exec($ch));
|
||||
if ($method == 'tickers' && empty($params)) {
|
||||
$obj = json_decode($data, true);
|
||||
}
|
||||
else $obj = json_decode($data);
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
// https://bter.com/api/1/private/...
|
||||
|
||||
function bter_api_user($method, $params=array())
|
||||
{
|
||||
require_once('/etc/yiimp/keys.php');
|
||||
if (!defined('EXCH_BTER_SECRET')) return false;
|
||||
|
||||
$apikey = EXCH_BTER_KEY; // your API-key
|
||||
$apisecret = EXCH_BTER_SECRET; // your Secret-key
|
||||
|
||||
$req = $params;
|
||||
|
||||
// generate a nonce to avoid problems with 32bits systems
|
||||
$mt = explode(' ', microtime());
|
||||
$req['nonce'] = $mt[1].substr($mt[0], 2, 6);
|
||||
|
||||
$post_data = http_build_query($req, '', '&');
|
||||
$sign = hash_hmac('sha512', $post_data, $apisecret);
|
||||
|
||||
$uri = "https://bter.com/api/1/private/$method";
|
||||
$headers = array(
|
||||
'KEY: '.$apikey,
|
||||
'SIGN: '.$sign,
|
||||
);
|
||||
|
||||
$ch = curl_init($uri);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; Bter API PHP client; '.php_uname('s').'; PHP/'.phpversion().')');
|
||||
curl_setopt($ch, CURLOPT_ENCODING , '');
|
||||
|
||||
$data = curl_exec($ch);
|
||||
$obj = json_decode($data, true);
|
||||
|
||||
if(!is_array($obj)) {
|
||||
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
debuglog("bter: $method failed ($status) ".strip_data($data).' '.curl_error($ch));
|
||||
}
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
return $obj;
|
||||
}
|
|
@ -29,7 +29,6 @@ require_once("kraken.php");
|
|||
require_once("poloniex.php");
|
||||
require_once("yobit.php");
|
||||
require_once("shapeshift.php");
|
||||
require_once("bter.php");
|
||||
require_once("empoex.php");
|
||||
require_once("jubi.php");
|
||||
require_once("alcurex.php");
|
||||
|
@ -91,8 +90,6 @@ function getMarketUrl($coin, $marketName)
|
|||
$url = "https://poloniex.com/exchange#{$lowbase}_{$lowsymbol}";
|
||||
else if($market == 'bleutrade')
|
||||
$url = "https://bleutrade.com/exchange/{$symbol}/{$base}";
|
||||
else if($market == 'bter')
|
||||
$url = "https://bter.com/trade/{$lowsymbol}_{$lowbase}";
|
||||
else if($market == 'cexio')
|
||||
$url = "https://cex.io/trade/{$symbol}-{$base}";
|
||||
else if($market == 'coinbene')
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
<?php
|
||||
|
||||
// https://bter.com/api#trade
|
||||
|
||||
function doBterTrading($quick=false)
|
||||
{
|
||||
$exchange = 'bter';
|
||||
$updatebalances = true;
|
||||
|
||||
if (exchange_get($exchange, 'disabled')) return;
|
||||
|
||||
// "available_funds":{"BTC":"0.03337671","LTC":"4.364",...}, "locked_funds":{"BTC":"0.0002",...
|
||||
$balances = bter_api_user('getfunds');
|
||||
if(!$balances || !isset($balances['result']) || $balances['result'] != 'true') return;
|
||||
|
||||
$savebalance = getdbosql('db_balances', "name='{$exchange}'");
|
||||
if (is_object($savebalance)) {
|
||||
$savebalance->balance = 0;
|
||||
$savebalance->save();
|
||||
}
|
||||
|
||||
// bter only returns non-zero balances
|
||||
if ($updatebalances) dborun("UPDATE markets SET balance=0 WHERE name='{$exchange}'");
|
||||
|
||||
foreach($balances['available_funds'] as $symbol => $available)
|
||||
{
|
||||
if ($symbol == 'BTC') {
|
||||
if (is_object($savebalance)) {
|
||||
$savebalance->balance = $balance->available;
|
||||
$savebalance->onsell = arraySafeVal($balances['locked_funds'],$symbol,0);
|
||||
$savebalance->save();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($updatebalances) {
|
||||
// store available balance in market table
|
||||
$coins = getdbolist('db_coins', "symbol=:symbol OR symbol2=:symbol",
|
||||
array(':symbol'=>$symbol)
|
||||
);
|
||||
if (empty($coins)) continue;
|
||||
foreach ($coins as $coin) {
|
||||
$market = getdbosql('db_markets', "coinid=:coinid AND name='{$exchange}'", array(':coinid'=>$coin->id));
|
||||
if (!$market) continue;
|
||||
$market->balance = $available;
|
||||
$market->ontrade = arraySafeVal($balances['locked_funds'],$symbol,0);
|
||||
$market->balancetime = time();
|
||||
$market->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!YAAMP_ALLOW_EXCHANGE) return;
|
||||
|
||||
$flushall = rand(0, 8) == 0;
|
||||
if($quick) $flushall = false;
|
||||
}
|
|
@ -3,7 +3,6 @@ require_once('poloniex_trading.php');
|
|||
require_once('binance_trading.php');
|
||||
require_once('bittrex_trading.php');
|
||||
require_once('bleutrade_trading.php');
|
||||
require_once('bter_trading.php');
|
||||
require_once('c-cex_trading.php');
|
||||
require_once('kraken_trading.php');
|
||||
require_once('yobit_trading.php');
|
||||
|
@ -73,11 +72,6 @@ function runExchange($exchangeName=false)
|
|||
updateBinanceMarkets();
|
||||
break;
|
||||
|
||||
case 'bter':
|
||||
doBterTrading(true);
|
||||
updateBterMarkets();
|
||||
break;
|
||||
|
||||
case 'crex24':
|
||||
doCrex24Trading(true);
|
||||
updateCrex24Markets();
|
||||
|
|
|
@ -31,7 +31,6 @@ if (!defined('EXCH_BITTREX_KEY')) define('EXCH_BITTREX_KEY', '');
|
|||
if (!defined('EXCH_BITSTAMP_ID')) define('EXCH_BITSTAMP_ID', '');
|
||||
if (!defined('EXCH_BITSTAMP_KEY')) define('EXCH_BITSTAMP_KEY','');
|
||||
if (!defined('EXCH_BLEUTRADE_KEY')) define('EXCH_BLEUTRADE_KEY', '');
|
||||
if (!defined('EXCH_BTER_KEY')) define('EXCH_BTER_KEY', '');
|
||||
if (!defined('EXCH_CCEX_KEY')) define('EXCH_CCEX_KEY', '');
|
||||
if (!defined('EXCH_CEXIO_ID')) define('EXCH_CEXIO_ID', '');
|
||||
if (!defined('EXCH_CEXIO_KEY')) define('EXCH_CEXIO_KEY', '');
|
||||
|
|
|
@ -141,7 +141,6 @@ class CronjobController extends CommonController
|
|||
|
||||
doBinanceTrading();
|
||||
doCCexTrading();
|
||||
doBterTrading();
|
||||
doBleutradeTrading();
|
||||
doCryptobridgeTrading();
|
||||
doKuCoinTrading();
|
||||
|
|
Loading…
Add table
Reference in a new issue