Skip to content

Commit

Permalink
livecoin: implement manual coindb labels via their api
Browse files Browse the repository at this point in the history
+ poloniex trading possible issue... for zpool
  • Loading branch information
tpruvot committed Sep 7, 2017
1 parent acae4fd commit e68f822
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
43 changes: 41 additions & 2 deletions web/yaamp/commands/CoindbCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public function run($args)

$nbUpdated = $this->updateCoinsLabels();
$nbUpdated += $this->updateCryptopiaLabels();
$nbUpdated += $this->updateLiveCoinLabels();
$nbUpdated += $this->updateYiimpLabels("yiimp.ccminer.org");
$nbUpdated += $this->updateYiimpLabels("zpool.ca");
$nbUpdated += $this->updateFromJson();

echo "total updated: $nbUpdated\n";
Expand Down Expand Up @@ -160,7 +160,7 @@ public function updateCryptopiaLabels()
foreach ($dataset as $coin) {
if ($coin->name == 'unknown' && isset($json[$coin->symbol])) {
$cc = $json[$coin->symbol];
if ($cc->Name != $coin->symbol) {
if ($cc->Name != $coin->name) {
echo "{$coin->symbol}: {$cc->Name}\n";
$coin->name = $cc->Name;
if (empty($coin->algo))
Expand All @@ -175,6 +175,45 @@ public function updateCryptopiaLabels()
return $nbUpdated;
}

public function updateLiveCoinLabels()
{
if (exchange_get('livecoin', 'disabled') == true) return 0;

$coins = new db_coins;
$nbUpdated = 0;

$dataset = $coins->findAll(array(
'condition'=>"name='unknown' AND id IN (SELECT M.coinid FROM markets M WHERE M.name='livecoin')",
));

if (!empty($dataset))
{
//echo count($dataset)." livecoin currencies without labels\n";
$labels = array();
$data = livecoin_api_query('info/coinInfo');
if(objSafeVal($data,'success') !== true || !is_array($data->info)) return;

foreach ($data->info as $c) {
$symbol = objSafeVal($c,'symbol','');
$labels[$symbol] = objSafeVal($c,'name','unknown');
}

foreach ($dataset as $coin) {
if ($coin->name == 'unknown' && isset($labels[$coin->symbol])) {
$label = $labels[$coin->symbol];
if ($label != $coin->name) {
echo "{$coin->symbol}: {$label}\n";
$coin->name = $label;
$nbUpdated += $coin->save();
}
}
}
if ($nbUpdated)
echo "$nbUpdated coin labels updated from livecoin coininfo\n";
}
return $nbUpdated;
}

public function updateYiimpLabels($pool)
{
$modelsPath = $this->basePath.'/yaamp/models';
Expand Down
1 change: 1 addition & 0 deletions web/yaamp/core/trading/poloniex_trading.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ function doPoloniexTrading()

// add orders

if (is_array($balances))
foreach($balances as $symbol=>$balance)
{
if(!$balance || !arraySafeVal($balance,'available')) continue;
Expand Down

0 comments on commit e68f822

Please sign in to comment.