mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-08-23 09:27:25 +00:00
markets: handle cryptobridge ticker
This commit is contained in:
parent
72b738da0d
commit
2dccc579cf
5 changed files with 87 additions and 4 deletions
|
@ -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';
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
20
web/yaamp/core/exchange/cryptobridge.php
Normal file
20
web/yaamp/core/exchange/cryptobridge.php
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
// https://api.crypto-bridge.org/api/v1/ticker
|
||||
|
||||
function cryptobridge_api_query($method, $params='')
|
||||
{
|
||||
$uri = "https://api.crypto-bridge.org/api/v1/{$method}";
|
||||
if (!empty($params)) $uri .= "/{$params}";
|
||||
|
||||
$ch = curl_init($uri);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
||||
|
||||
$execResult = strip_tags(curl_exec($ch));
|
||||
$obj = json_decode($execResult);
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
|
@ -13,13 +13,14 @@ function strip_data($data)
|
|||
return $out;
|
||||
}
|
||||
|
||||
require_once("poloniex.php");
|
||||
require_once("bitstamp.php");
|
||||
require_once("bittrex.php");
|
||||
require_once("ccexapi.php");
|
||||
require_once("bleutrade.php");
|
||||
require_once("ccexapi.php");
|
||||
require_once("cexio.php");
|
||||
require_once("cryptobridge.php");
|
||||
require_once("kraken.php");
|
||||
require_once("poloniex.php");
|
||||
require_once("yobit.php");
|
||||
require_once("shapeshift.php");
|
||||
require_once("bter.php");
|
||||
|
@ -89,7 +90,9 @@ function getMarketUrl($coin, $marketName)
|
|||
else if($market == 'coinexchange')
|
||||
$url = "https://www.coinexchange.io/market/{$symbol}/{$base}";
|
||||
else if($market == 'coinsmarkets')
|
||||
$url = " https://coinsmarkets.com/trade-{$base}-{$symbol}.htm";
|
||||
$url = "https://coinsmarkets.com/trade-{$base}-{$symbol}.htm";
|
||||
else if($market == 'cryptobridge')
|
||||
$url = "https://wallet.crypto-bridge.org/market/BRIDGE.{$symbol}_BRIDGE.{$base}";
|
||||
else if($market == 'cryptopia')
|
||||
$url = "https://www.cryptopia.co.nz/Exchange?market={$symbol}_{$base}";
|
||||
else if($market == 'cryptowatch')
|
||||
|
|
|
@ -78,6 +78,10 @@ function runExchange($exchangeName=false)
|
|||
updateCryptopiaMarkets();
|
||||
break;
|
||||
|
||||
case 'cryptobridge':
|
||||
updateCryptoBridgeMarkets();
|
||||
break;
|
||||
|
||||
case 'bitstamp':
|
||||
getBitstampBalances();
|
||||
break;
|
||||
|
|
Loading…
Add table
Reference in a new issue