mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-08-23 17:37:25 +00:00
markets: bit-z ticker api (#288)
This commit is contained in:
parent
b39da19858
commit
c25d7b9b77
5 changed files with 81 additions and 1 deletions
|
@ -11,6 +11,7 @@ function BackendPricesUpdate()
|
||||||
settings_prefetch_all();
|
settings_prefetch_all();
|
||||||
|
|
||||||
updateBittrexMarkets();
|
updateBittrexMarkets();
|
||||||
|
updateBitzMarkets();
|
||||||
updatePoloniexMarkets();
|
updatePoloniexMarkets();
|
||||||
updateBleutradeMarkets();
|
updateBleutradeMarkets();
|
||||||
updateCryptoBridgeMarkets();
|
updateCryptoBridgeMarkets();
|
||||||
|
@ -288,6 +289,42 @@ function updateBleutradeMarkets()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
function updateBitzMarkets($force = false)
|
||||||
|
{
|
||||||
|
$exchange = 'bitz';
|
||||||
|
if (exchange_get($exchange, 'disabled')) return;
|
||||||
|
|
||||||
|
$markets = bitz_api_query('tickerall');
|
||||||
|
|
||||||
|
foreach($markets as $c => $ticker)
|
||||||
|
{
|
||||||
|
$pairs = explode('_', $c);
|
||||||
|
$symbol = strtoupper(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->bidPrice + $ticker->askPrice)/2;
|
||||||
|
$market->price2 = AverageIncrement($market->price2, $price2);
|
||||||
|
$market->price = AverageIncrement($market->price, $ticker->bidPrice);
|
||||||
|
$market->pricetime = time();
|
||||||
|
$market->priority = -1;
|
||||||
|
$market->txfee = 0.2; // trade pct
|
||||||
|
$market->save();
|
||||||
|
// debuglog("$exchange: update $symbol: {$market->price} {$market->price2}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
function updateCryptoBridgeMarkets($force = false)
|
function updateCryptoBridgeMarkets($force = false)
|
||||||
|
|
|
@ -36,6 +36,19 @@ function updateRawcoins()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!exchange_get('bitz', 'disabled')) {
|
||||||
|
$list = bitz_api_query('tickerall');
|
||||||
|
|
||||||
|
dborun("UPDATE markets SET deleted=true WHERE name='bitz'");
|
||||||
|
foreach($list as $c => $ticker) {
|
||||||
|
$e = explode('_', $c);
|
||||||
|
if (strtoupper($e[1]) !== 'BTC')
|
||||||
|
continue;
|
||||||
|
$symbol = strtoupper($e[0]);
|
||||||
|
updateRawCoin('bitz', $symbol);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!exchange_get('bleutrade', 'disabled')) {
|
if (!exchange_get('bleutrade', 'disabled')) {
|
||||||
$list = bleutrade_api_query('public/getcurrencies');
|
$list = bleutrade_api_query('public/getcurrencies');
|
||||||
if(isset($list->result) && !empty($list->result))
|
if(isset($list->result) && !empty($list->result))
|
||||||
|
@ -417,7 +430,7 @@ function updateRawCoin($marketname, $symbol, $name='unknown')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array($marketname, array('nova','askcoin','binance','coinexchange','coinsmarkets','cryptobridge','hitbtc'))) {
|
if (in_array($marketname, array('nova','askcoin','binance','bitz','coinexchange','coinsmarkets','cryptobridge','hitbtc'))) {
|
||||||
// don't polute too much the db with new coins, its better from exchanges with labels
|
// don't polute too much the db with new coins, its better from exchanges with labels
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
24
web/yaamp/core/exchange/bitz.php
Normal file
24
web/yaamp/core/exchange/bitz.php
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
// see https://apidoc.bit-z.com/en/Demo/PHP.html
|
||||||
|
// https://apiv2.bitz.com/Market/ticker?symbol=ltc_btc
|
||||||
|
// https://apiv2.bitz.com/Market/tickerall
|
||||||
|
|
||||||
|
function bitz_api_query($method, $params='', $returnType='object')
|
||||||
|
{
|
||||||
|
$url = "https://apiv2.bitz.com/Market/$method/";
|
||||||
|
if (!empty($params))
|
||||||
|
$url .= "?$params";
|
||||||
|
$ch = curl_init($url);
|
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
||||||
|
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
||||||
|
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; BitZ API PHP client; '.php_uname('s').'; PHP/'.phpversion().')');
|
||||||
|
curl_setopt($ch, CURLOPT_ENCODING , '');
|
||||||
|
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||||
|
$execResult = curl_exec($ch);
|
||||||
|
if ($returnType == 'object')
|
||||||
|
$ret = json_decode($execResult);
|
||||||
|
else
|
||||||
|
$ret = json_decode($execResult,true);
|
||||||
|
return $ret->data;
|
||||||
|
}
|
|
@ -15,6 +15,7 @@ function strip_data($data)
|
||||||
|
|
||||||
require_once("bitstamp.php");
|
require_once("bitstamp.php");
|
||||||
require_once("bittrex.php");
|
require_once("bittrex.php");
|
||||||
|
require_once("bitz.php");
|
||||||
require_once("bleutrade.php");
|
require_once("bleutrade.php");
|
||||||
require_once("ccexapi.php");
|
require_once("ccexapi.php");
|
||||||
require_once("cexio.php");
|
require_once("cexio.php");
|
||||||
|
@ -82,6 +83,8 @@ function getMarketUrl($coin, $marketName)
|
||||||
$url = "https://www.binance.com/trade.html?symbol={$symbol}_{$base}";
|
$url = "https://www.binance.com/trade.html?symbol={$symbol}_{$base}";
|
||||||
else if($market == 'bittrex')
|
else if($market == 'bittrex')
|
||||||
$url = "https://bittrex.com/Market/Index?MarketName={$base}-{$symbol}";
|
$url = "https://bittrex.com/Market/Index?MarketName={$base}-{$symbol}";
|
||||||
|
else if($market == 'bitz')
|
||||||
|
$url = "https://www.bit-z.com/exchange/{$symbol}_{$base}";
|
||||||
else if($market == 'poloniex')
|
else if($market == 'poloniex')
|
||||||
$url = "https://poloniex.com/exchange#{$lowbase}_{$lowsymbol}";
|
$url = "https://poloniex.com/exchange#{$lowbase}_{$lowsymbol}";
|
||||||
else if($market == 'bleutrade')
|
else if($market == 'bleutrade')
|
||||||
|
|
|
@ -90,6 +90,9 @@ function runExchange($exchangeName=false)
|
||||||
doBittrexTrading(true);
|
doBittrexTrading(true);
|
||||||
updateBittrexMarkets();
|
updateBittrexMarkets();
|
||||||
break;
|
break;
|
||||||
|
case 'bitz':
|
||||||
|
updateBitzMarkets();
|
||||||
|
break;
|
||||||
|
|
||||||
case 'cexio':
|
case 'cexio':
|
||||||
getCexIoBalances();
|
getCexIoBalances();
|
||||||
|
|
Loading…
Add table
Reference in a new issue