function updateCCexMarkets() { // dborun("update markets set price=0 where name='c-cex'"); <- add that line $ccex = new CcexAPI(); $list = $ccex->getPairs(); foreach ($list as $item) { $e = explode('-', $item); if (!isset($e[1])) { continue; } if ($e[1] != 'btc') { continue; } $symbol = strtoupper($e[0]); $coin = getdbosql('db_coins', "symbol=:symbol", array(':symbol' => $symbol)); if (!$coin || !$coin->installed) { continue; } $market = getdbosql('db_markets', "coinid={$coin->id} and name='c-cex'"); if (!$market) { $market = new db_markets(); $market->coinid = $coin->id; $market->name = 'c-cex'; } $market->save(); $ticker = $ccex->getTickerInfo($item); if (!$ticker) { continue; } $price2 = ($ticker['buy'] + $ticker['sell']) / 2; $market->price2 = AverageIncrement($market->price2, $price2); $market->price = AverageIncrement($market->price, $ticker['buy']); $market->save(); } }
function updateRawcoins() { // debuglog(__FUNCTION__); $list = bittrex_api_query('public/getcurrencies'); if (isset($list->result)) { dborun("update markets set deleted=true where name='bittrex'"); foreach ($list->result as $currency) { updateRawCoin('bittrex', $currency->Currency, $currency->CurrencyLong); } } $list = bleutrade_api_query('public/getcurrencies'); if (isset($list->result)) { dborun("update markets set deleted=true where name='bleutrade'"); foreach ($list->result as $currency) { updateRawCoin('bleutrade', $currency->Currency, $currency->CurrencyLong); } } $list = cryptsy_api_query('getmarkets'); if (isset($list['return'])) { dborun("update markets set deleted=true where name='cryptsy'"); foreach ($list['return'] as $item) { updateRawCoin('cryptsy', $item['primary_currency_code'], $item['primary_currency_name']); } } $ccex = new CcexAPI(); $list = $ccex->getPairs(); if ($list) { dborun("update markets set deleted=true where name='c-cex'"); foreach ($list as $item) { $e = explode('-', $item); $symbol = strtoupper($e[0]); updateRawCoin('c-cex', $symbol); } } $poloniex = new poloniex(); $tickers = $poloniex->get_currencies(); dborun("update markets set deleted=true where name='poloniex'"); foreach ($tickers as $symbol => $ticker) { if ($ticker['disabled']) { continue; } if ($ticker['delisted']) { continue; } updateRawCoin('poloniex', $symbol); } $res = yobit_api_query('info'); if ($res) { dborun("update markets set deleted=true where name='yobit'"); foreach ($res->pairs as $i => $item) { $e = explode('_', $i); $symbol = strtoupper($e[0]); updateRawCoin('yobit', $symbol); } } ////////////////////////////////////////////////////////// dborun("delete from markets where deleted"); $list = getdbolist('db_coins', "not enable and not installed and id not in (select distinct coinid from markets)"); foreach ($list as $coin) { debuglog("{$coin->symbol} is not longer active"); $coin->delete(); } }