Ejemplo n.º 1
0
//var_dump ($balances);
if ($balances) {
    foreach ($balances as $item) {
        if ($item['type'] == 'deposit' && $item['currency'] == strtolower($config['currency'])) {
            $available_balance = floatval($item['available']);
            $total_balance = round(floatval($item['amount']), 2);
            $log->lwrite($config['currency'] . " Deposit balance is {$total_balance}");
            break;
        }
    }
}
// Is there enough balance to lend?
if ($available_balance >= $config['minimum_balance']) {
    $log->lwrite("Lending available balance of {$available_balance}");
    $log->lwrite('Getting lendbook');
    $lendbook = $bfx->get_lendbook($config['currency']);
    $offers = $lendbook['asks'];
    //var_dump ($offers);
    $total_amount = 0;
    $next_rate = 0;
    $next_amount = 0;
    $check_next = FALSE;
    // Find the right rate
    foreach ($offers as $item) {
        // Save next closest item
        if ($check_next) {
            $next_rate = $item['rate'];
            $next_amount = $item['amount'];
            $check_next = FALSE;
        }
        $total_amount += floatval($item['amount']);