diff --git a/web/yaamp/core/backend/markets.php b/web/yaamp/core/backend/markets.php index f69fe10..2db5e05 100644 --- a/web/yaamp/core/backend/markets.php +++ b/web/yaamp/core/backend/markets.php @@ -13,6 +13,7 @@ function BackendPricesUpdate() updateBittrexMarkets(); updatePoloniexMarkets(); updateBleutradeMarkets(); + updateCryptoBridgeMarkets(); updateKrakenMarkets(); updateKuCoinMarkets(); updateCCexMarkets(); @@ -283,6 +284,46 @@ function updateBleutradeMarkets() ///////////////////////////////////////////////////////////////////////////////////////////// +function updateCryptoBridgeMarkets($force = false) +{ + $exchange = 'cryptobridge'; + + $result = cryptobridge_api_query('ticker'); + if(!is_array($result)) return; + + foreach($result as $ticker) + { + if (is_null(objSafeVal($ticker,'id'))) continue; + $pairs = explode('_', $ticker->id); + $symbol = reset($pairs); $base = end($pairs); + if($symbol == 'BTC' || $base != 'BTC') continue; + + if (market_get($exchange, $symbol, "disabled")) { + $market->disabled = 1; + $market->message = 'disabled from settings'; + } + + $coin = getdbosql('db_coins', "symbol='{$symbol}'"); + if(!$coin) continue; + if(!$coin->installed && !$coin->watch) continue; + + $market = getdbosql('db_markets', "coinid={$coin->id} and name='{$exchange}'"); + if(!$market) continue; + + $price2 = ($ticker->bid + $ticker->ask)/2; + $market->price2 = AverageIncrement($market->price2, $price2); + $market->price = AverageIncrement($market->price, $ticker->bid); + $market->pricetime = time(); + $market->priority = -1; + $market->txfee = 0.2; // trade pct + $market->save(); + + //debuglog("$exchange: update $symbol: {$market->price} {$market->price2}"); + } +} + +///////////////////////////////////////////////////////////////////////////////////////////// + function updateKrakenMarkets($force = false) { $exchange = 'kraken'; diff --git a/web/yaamp/core/backend/rawcoins.php b/web/yaamp/core/backend/rawcoins.php index 670af51..067d0de 100644 --- a/web/yaamp/core/backend/rawcoins.php +++ b/web/yaamp/core/backend/rawcoins.php @@ -152,6 +152,21 @@ function updateRawcoins() } } + if (!exchange_get('cryptobridge', 'disabled')) { + $list = cryptobridge_api_query('ticker'); + if(is_array($list) && !empty($list)) + { + dborun("UPDATE markets SET deleted=true WHERE name='cryptobridge'"); + foreach($list as $ticker) { + $e = explode('_', $ticker->id); + if (strtoupper($e[1]) !== 'BTC') + continue; + $symbol = strtoupper($e[0]); + updateRawCoin('cryptobridge', $symbol); + } + } + } + if (!exchange_get('hitbtc', 'disabled')) { $list = hitbtc_api_query('symbols'); if(is_object($list) && isset($list->symbols) && is_array($list->symbols)) @@ -375,7 +390,7 @@ function updateRawCoin($marketname, $symbol, $name='unknown') } } - if (in_array($marketname, array('nova','askcoin','binance','coinexchange','coinsmarkets','hitbtc'))) { + if (in_array($marketname, array('nova','askcoin','binance','coinexchange','coinsmarkets','cryptobridge','hitbtc'))) { // don't polute too much the db with new coins, its better from exchanges with labels return; } diff --git a/web/yaamp/core/exchange/cryptobridge.php b/web/yaamp/core/exchange/cryptobridge.php new file mode 100644 index 0000000..3251768 --- /dev/null +++ b/web/yaamp/core/exchange/cryptobridge.php @@ -0,0 +1,20 @@ +