diff --git a/web/yaamp/commands/CheckupCommand.php b/web/yaamp/commands/CheckupCommand.php index 0a7c8ad..aae5cea 100644 --- a/web/yaamp/commands/CheckupCommand.php +++ b/web/yaamp/commands/CheckupCommand.php @@ -6,7 +6,7 @@ * * To use this command, enter the following on the command line: *
- * php protected/yiic.php checkup + * php web/yaamp/yiic.php checkup ** * @property string $help The command description. @@ -31,8 +31,8 @@ class CheckupCommand extends CConsoleCommand if (isset($args[0])) { - echo "Yii checkup command\n"; - echo "Usage: yiic checkup\n"; + echo "Yiimp checkup command\n"; + echo "Usage: yiimp checkup\n"; return 1; } else { @@ -44,7 +44,7 @@ class CheckupCommand extends CConsoleCommand self::autolinkCoinsImages(); - if (YAAMP_ALLOW_EXCHANGE == false) + if (!YAAMP_ALLOW_EXCHANGE) self::cleanUserBalancesBTC(); echo "ok\n"; diff --git a/web/yaamp/commands/ExchangeCommand.php b/web/yaamp/commands/ExchangeCommand.php new file mode 100644 index 0000000..7fdffc1 --- /dev/null +++ b/web/yaamp/commands/ExchangeCommand.php @@ -0,0 +1,100 @@ + + * php web/yaamp/yiic.php exchange test + * + * + * @property string $help The command description. + * + */ +class ExchangeCommand extends CConsoleCommand +{ + protected $basePath; + + /** + * Execute the action. + * @param array $args command line parameters specific for this command + * @return integer non zero application exit code after printing help + */ + public function run($args) + { + $runner=$this->getCommandRunner(); + $commands=$runner->commands; + + $root = realpath(Yii::app()->getBasePath().DIRECTORY_SEPARATOR.'..'); + $this->basePath = str_replace(DIRECTORY_SEPARATOR, '/', $root); + + if (!isset($args[0])) { + + echo "Yiimp exchange command\n"; + echo "Usage: yiimp exchange test\n"; + return 1; + + } else if ($args[0] == 'test') { + + $this->testApiKeys(); + + echo "ok\n"; + return 0; + } + } + + /** + * Provides the command description. + * @return string the command description. + */ + public function getHelp() + { + return parent::getHelp().'exchange'; + } + + public function testApiKeys() + { + require_once($this->basePath.'/yaamp/core/core.php'); + + if (!empty(EXCH_BITTREX_KEY)) { + $balance = bittrex_api_query('account/getbalance','¤cy=BTC'); + echo("bittrex btc: ".json_encode($balance->result)."\n"); + } + if (!empty(EXCH_BLEUTRADE_KEY)) { + $balance = bleutrade_api_query('account/getbalances','¤cies=BTC'); + echo("bleutrade btc: ".json_encode($balance->result)."\n"); + } + if (!empty(EXCH_CCEX_KEY)) { + $ccex = new CcexAPI; + $balances = $ccex->getBalance(); + if(!$balances || !isset($balances['return'])) echo "error\n"; + else echo("c-cex btc: ".json_encode($balances['return'][1])."\n"); + } + if (!empty(EXCH_CRYPTOPIA_KEY)) { + $balance = cryptopia_api_user('GetBalance',array("Currency"=>"BTC")); + echo("cryptopia btc: ".json_encode($balance->Data)."\n"); + } + if (!empty(EXCH_CRYPTSY_KEY)) { + $info = cryptsy_api_query('getinfo'); + if (!arraySafeVal($info,'success',0) || !is_array($info['return'])) echo "error\n"; + else echo("cryptsy btc: ".json_encode($info['return']['balances_available']['BTC'])."\n"); + } + if(!empty(EXCH_POLONIEX_KEY)) { + $poloniex = new poloniex; + $balance = $poloniex->get_available_balances(); + echo("poloniex available : ".json_encode($balance)."\n"); + } + if (!empty(EXCH_SAFECEX_KEY)) { + $balance = safecex_api_user('getbalance', "&symbol=BTC"); + echo("safecex btc: ".json_encode($balance)."\n"); + } + if (!empty(EXCH_YOBIT_KEY)) { + $info = yobit_api_query2('getInfo'); + if (!arraySafeVal($info,'success',0) || !is_array($info['return'])) echo "error\n"; + else echo("yobit btc: ".json_encode($info['return']['funds']['btc'])."\n"); + } + + // only one secret key + $balance = empoex_api_user('account/balance','BTC'); + if ($balance) echo("empoex btc: ".json_encode($balance['available'])."\n"); + } +} diff --git a/web/yaamp/core/trading/empoex_trading.php b/web/yaamp/core/trading/empoex_trading.php index 4daf9cf..802a22b 100644 --- a/web/yaamp/core/trading/empoex_trading.php +++ b/web/yaamp/core/trading/empoex_trading.php @@ -8,7 +8,7 @@ function doEmpoexTrading($quick=false) $balances = empoex_api_user('account/balance','BTC'); // {"available":[{"Coin":"BTC","Amount":"0.00102293"}],"pending":[],"held":[]} - if(!$balances || !isset($balances->available) || empty($balances->available)) return; + if(!$balances || !isset($balances->available) || empty($balances->available)) return; $savebalance = getdbosql('db_balances', "name='empoex'"); $savebalance->balance = 0;