Beispiel #1
0
function BackendPricesUpdate()
{
    //	debuglog(__FUNCTION__);
    updateBittrexMarkets();
    updateCryptsyMarkets();
    updateCCexMarkets();
    updateBleutradeMarkets();
    updatePoloniexMarkets();
    updateYobitMarkets();
    updateJubiMarkets();
    $list2 = getdbolist('db_coins', "installed and symbol2 is not null");
    foreach ($list2 as $coin2) {
        $coin = getdbosql('db_coins', "symbol='{$coin2->symbol2}'");
        if (!$coin) {
            continue;
        }
        $list = getdbolist('db_markets', "coinid={$coin->id}");
        foreach ($list as $market) {
            $market2 = getdbosql('db_markets', "coinid={$coin2->id} and name='{$market->name}'");
            if (!$market2) {
                continue;
            }
            $market2->price = $market->price;
            $market2->price2 = $market->price2;
            $market2->deposit_address = $market->deposit_address;
            $market2->save();
        }
    }
    $coins = getdbolist('db_coins', "installed and id in (select distinct coinid from markets)");
    foreach ($coins as $coin) {
        if ($coin->symbol == 'BTC') {
            $coin->price = 1;
            $coin->price2 = 1;
            $coin->save();
            continue;
        }
        $market = getBestMarket($coin);
        if ($market) {
            $coin->price = $market->price * (1 - YAAMP_FEES_EXCHANGE / 100);
            $coin->price2 = $market->price2;
            $base_coin = !empty($market->base_coin) ? getdbosql('db_coins', "symbol='{$market->base_coin}'") : null;
            if ($base_coin) {
                $coin->price *= $base_coin->price;
                $coin->price2 *= $base_coin->price;
            }
            //			if($market->name == 'c-cex')
            //				$coin->price *= 0.95;
        } else {
            $coin->price = 0;
            $coin->price2 = 0;
        }
        $coin->save();
        dborun("update earnings set price={$coin->price} where status!=2 and coinid={$coin->id}");
    }
}
Beispiel #2
0
 public function actionRunExchange()
 {
     $id = getiparam('id');
     $balance = getdbo('db_balances', $id);
     if ($balance) {
         switch ($balance->name) {
             case 'cryptsy':
                 doCryptsyTrading(true);
                 updateCryptsyMarkets();
                 break;
             case 'bittrex':
                 doBittrexTrading(true);
                 updateBittrexMarkets();
                 break;
             case 'c-cex':
                 doCCexTrading(true);
                 updateCCexMarkets();
                 break;
             case 'yobit':
                 doYobitTrading(true);
                 updateYobitMarkets();
                 break;
             case 'bleutrade':
                 doBleutradeTrading(true);
                 updateBleutradeMarkets();
                 break;
             case 'poloniex':
                 doPoloniexTrading(true);
                 updatePoloniexMarkets();
                 break;
         }
     }
     debuglog("runexchange done");
     $this->redirect("/site/common");
 }