From 37a8402c1234b5e81f2b9425cd9cf02fcda324fd Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Tue, 13 Oct 2015 21:15:30 +0200 Subject: [PATCH] markets: add cryptonator api call for installed coins without price --- web/yaamp/core/backend/markets.php | 28 ++++++++++++++++++++++++++++ web/yaamp/modules/site/coin.php | 6 ++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/web/yaamp/core/backend/markets.php b/web/yaamp/core/backend/markets.php index 3cca228..866d082 100644 --- a/web/yaamp/core/backend/markets.php +++ b/web/yaamp/core/backend/markets.php @@ -18,6 +18,8 @@ function BackendPricesUpdate() updateJubiMarkets(); updateBanxioMarkets(); + updateOtherMarkets(); + $list2 = getdbolist('db_coins', "installed and symbol2 is not null"); foreach($list2 as $coin2) { @@ -775,3 +777,29 @@ function updateEmpoexMarkets() } } } + +// update other installed coins price from cryptonator +function updateOtherMarkets() +{ + $coins = getdbolist('db_coins', "installed AND IFNULL(price,0.0) = 0.0"); + foreach($coins as $coin) + { + $symbol = $coin->symbol; + if (!empty($coin->symbol2)) $symbol = $coin->symbol2; + + $json = file_get_contents("https://www.cryptonator.com/api/full/".strtolower($symbol)."-btc"); + $object = json_decode($json); + if (empty($object)) continue; + + if (is_object($object) && isset($object->ticker)) { + $ticker = $object->ticker; + if ($ticker->target == 'BTC' && $ticker->volume > 1) { + $coin->price2 = $ticker->price; + $coin->price = AverageIncrement((float)$coin->price, (float)$coin->price2); + if ($coin->save()) { + debuglog("update price of $symbol ".bitcoinvaluetoa($coin->price)); + } + } + } + } +} \ No newline at end of file diff --git a/web/yaamp/modules/site/coin.php b/web/yaamp/modules/site/coin.php index 422889e..09c4951 100644 --- a/web/yaamp/modules/site/coin.php +++ b/web/yaamp/modules/site/coin.php @@ -40,6 +40,7 @@ echo ""; +/* echo "
MAKE CONFIG & START"; if($info) @@ -47,8 +48,8 @@ if($info) echo "
RESTART COIND"; echo "
STOP COIND"; -// if(isset($info['balance']) && $info['balance'] && !empty($coin->deposit_address)) -// echo "
SEND BALANCE TO - $coin->deposit_address"; + if(isset($info['balance']) && $info['balance'] && !empty($coin->deposit_address)) + echo "
SEND BALANCE TO - $coin->deposit_address"; } else { @@ -59,6 +60,7 @@ else echo "
UNINSTALL COIN
"; } +*/ echo "
CLEAR EARNINGS"; echo "
DELETE EARNINGS"; echo "
DO PAYMENTS";