From 294da52732a01ef4b62de908bd131f18660577a5 Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Sat, 2 Apr 2016 15:02:43 +0200 Subject: [PATCH] banx: rename to cryptomic (part 2) --- web/yaamp/commands/CoindbCommand.php | 12 ++++----- web/yaamp/commands/ExchangeCommand.php | 4 +-- .../exchange/{banxio.php => cryptomic.php} | 8 +++--- web/yaamp/core/exchange/exchange.php | 4 +-- ...banx_trading.php => cryptomic_trading.php} | 26 +++++++++++-------- web/yaamp/core/trading/trading.php | 4 +-- 6 files changed, 31 insertions(+), 27 deletions(-) rename web/yaamp/core/exchange/{banxio.php => cryptomic.php} (88%) rename web/yaamp/core/trading/{banx_trading.php => cryptomic_trading.php} (63%) diff --git a/web/yaamp/commands/CoindbCommand.php b/web/yaamp/commands/CoindbCommand.php index c41b486..894f9e5 100644 --- a/web/yaamp/commands/CoindbCommand.php +++ b/web/yaamp/commands/CoindbCommand.php @@ -53,7 +53,7 @@ class CoindbCommand extends CConsoleCommand $nbUpdated += $this->grabCcexIcons(); $nbUpdated += $this->grabCryptopiaIcons(); $nbUpdated += $this->grabAlcurexIcons(); - $nbUpdated += $this->grabBanxIcons(); + $nbUpdated += $this->grabCryptomicIcons(); echo "total updated: $nbUpdated\n"; return 0; @@ -401,18 +401,18 @@ class CoindbCommand extends CConsoleCommand } /** - * Icon grabber - Banx + * Icon grabber - Cryptomic (Banx.io) */ - public function grabBanxIcons() + public function grabCryptomicIcons() { - $url = 'https://cdn.banx.io/images/currencyicons/'; + $url = 'https://cdn.cryptomic.com/images/currencyicons/'; $nbUpdated = 0; $sql = "SELECT DISTINCT coins.id FROM coins INNER JOIN markets M ON M.coinid = coins.id ". "WHERE M.name='banx' AND IFNULL(coins.image,'') = ''"; $coins = dbolist($sql); if (empty($coins)) return 0; - echo "banx: try to download new icons...\n"; + echo "cryptomic: try to download new icons...\n"; foreach ($coins as $coin) { $coin = getdbo('db_coins', $coin["id"]); $symbol = $coin->symbol; @@ -432,7 +432,7 @@ class CoindbCommand extends CConsoleCommand } } if ($nbUpdated) - echo "$nbUpdated icons downloaded from banx\n"; + echo "$nbUpdated icons downloaded from cryptomic\n"; return $nbUpdated; } diff --git a/web/yaamp/commands/ExchangeCommand.php b/web/yaamp/commands/ExchangeCommand.php index 5500569..8328f07 100644 --- a/web/yaamp/commands/ExchangeCommand.php +++ b/web/yaamp/commands/ExchangeCommand.php @@ -107,8 +107,8 @@ class ExchangeCommand extends CConsoleCommand if (!empty(EXCH_BANX_USERNAME)) { //$balance = banx_api_user('account/getbalance','?currency=BTC'); $balance = banx_api_user('account/getbalances'); - if (!is_object($balance)) echo "banx error ".json_encode($balance)."\n"; - else echo("banx all: ".json_encode($balance->result)."\n"); + if (!is_object($balance)) echo "cryptomic error ".json_encode($balance)."\n"; + else echo("cryptomic all: ".json_encode($balance->result)."\n"); } // only one secret key diff --git a/web/yaamp/core/exchange/banxio.php b/web/yaamp/core/exchange/cryptomic.php similarity index 88% rename from web/yaamp/core/exchange/banxio.php rename to web/yaamp/core/exchange/cryptomic.php index fb60658..383f062 100644 --- a/web/yaamp/core/exchange/banxio.php +++ b/web/yaamp/core/exchange/cryptomic.php @@ -1,6 +1,6 @@ result) || !$balances->success) return; + $savebalance = getdbosql('db_balances', "name='{$exchange}'"); + if (is_object($savebalance)) { + $savebalance->balance = 0; + $savebalance->save(); + + dborun("UPDATE markets SET balance=0 WHERE name='{$exchange}'"); + } + foreach($balances->result as $balance) { if ($balance->currency == 'BTC') { - - $savebalance = getdbosql('db_balances', "name='{$exchange}'"); if (!is_object($savebalance)) continue; - $savebalance->balance = $balance->available; $savebalance->save(); continue; } - if (!YAAMP_ALLOW_EXCHANGE) { + if ($updatebalances) { // store available balance in market table $coins = getdbolist('db_coins', "symbol=:symbol OR symbol2=:symbol", array(':symbol'=>$balance->currency) @@ -29,14 +35,12 @@ function doBanxTrading($quick=false) foreach ($coins as $coin) { $market = getdbosql('db_markets', "coinid=:coinid AND name='{$exchange}'", array(':coinid'=>$coin->id)); if (!$market) continue; - if ($market->balance != $balance->available) { - $market->balance = $balance->available; - if (!empty($balance->cryptoaddress) && $market->deposit_address != $balance->cryptoaddress) { - debuglog("{$exchange}: {$coin->symbol} deposit address updated"); - $market->deposit_address = $balance->cryptoaddress; - } - $market->save(); + $market->balance = $balance->available; + if (!empty($balance->cryptoaddress) && $market->deposit_address != $balance->cryptoaddress) { + debuglog("{$exchange}: {$coin->symbol} deposit address updated"); + $market->deposit_address = $balance->cryptoaddress; } + $market->save(); } } } diff --git a/web/yaamp/core/trading/trading.php b/web/yaamp/core/trading/trading.php index 6118aad..f038235 100644 --- a/web/yaamp/core/trading/trading.php +++ b/web/yaamp/core/trading/trading.php @@ -9,7 +9,7 @@ require_once('c-cex_trading.php'); require_once('kraken_trading.php'); require_once('yobit_trading.php'); require_once('alcurex_trading.php'); -require_once('banx_trading.php'); +require_once('cryptomic_trading.php'); require_once('cryptopia_trading.php'); require_once('safecex_trading.php'); @@ -109,4 +109,4 @@ function runExchange($exchangeName=false) { updatePoloniexMarkets(); break; } -} \ No newline at end of file +}