c-cex: add new apis + auto withdraw

This commit is contained in:
Tanguy Pruvot 2016-03-21 16:18:32 +01:00
parent d1905c6665
commit 7e739906a1
2 changed files with 50 additions and 2 deletions

View file

@ -102,5 +102,31 @@ class CcexAPI
return $this->jsonQuery($this->api_url."r.html?key={$this->api_key}&a=getbalance");
}
// If not exists - will generate new
public function getDepositAddress($symbol) {
$coin = strtolower($symbol);
return $this->jsonQuery($this->api_url."r.html?key={$this->api_key}&a=getaddress&coin={$coin}");
}
public function checkDeposit($symbol, $txid) {
$coin = strtolower($symbol);
return $this->jsonQuery($this->api_url."r.html?key={$this->api_key}&a=checkdeposit&coin={$coin}&tid={$txid}");
}
public function withdraw($symbol, $amount, $address) {
$coin = strtolower($symbol);
return $this->jsonQuery($this->api_url."r.html?key={$this->api_key}&a=withdraw&coin={$coin}&amount={$amount}&address={$address}");
}
public function getDepositHistory($symbol, $limit=100) {
$coin = strtolower($symbol);
return $this->jsonQuery($this->api_url."r.html?key={$this->api_key}&a=deposithistory&coin={$coin}&limit={$limit}");
}
public function getWithdrawalHistory($symbol, $limit=100) {
$coin = strtolower($symbol);
return $this->jsonQuery($this->api_url."r.html?key={$this->api_key}&a=withdrawalhistory&coin={$coin}&limit={$limit}");
}
}

View file

@ -192,6 +192,28 @@ function doCCexTrading($quick=false)
$db_order->save();
}
if(floatval(EXCH_AUTO_WITHDRAW) > 0 && $savebalance->balance >= (EXCH_AUTO_WITHDRAW + 0.0002))
{
$btcaddr = YAAMP_BTCADDRESS;
$amount = $savebalance->balance - 0.0002;
debuglog("[ccex] - withdraw $amount to $btcaddr");
sleep(1);
$res = $ccex->withdraw('BTC', $amount, $btcaddr);
debuglog("[ccex] - withdraw: ".json_encode($res));
if(isset($res['return']))
{
$withdraw = new db_withdraws;
$withdraw->market = 'c-cex';
$withdraw->address = $btcaddr;
$withdraw->amount = $amount;
$withdraw->time = time();
$withdraw->uuid = $res['return'];
$withdraw->save();
$savebalance->balance = 0;
$savebalance->save();
}
}
// debuglog('-------------- doCCexTrading() done');
}