Beispiel #1
0
$current_offers = $bfx->get_offers();
var_dump($current_offers);
// Something is wrong most likely API key
if (array_key_exists('message', $current_offers)) {
    die($current_offers['message']);
}
// Remove offers that weren't executed for too long
$log->lwrite('Checking for offers older than ' . $config['remove_after'] . ' mins');
foreach ($current_offers as $item) {
    $id = $item['id'];
    $timestamp = (int) $item['timestamp'];
    $current_timestamp = time();
    $diff_minutes = round(($current_timestamp - $timestamp) / 60);
    if ($config['remove_after'] <= $diff_minutes) {
        $log->lwrite("Removing old offer # {$id}");
        $bfx->cancel_offer($id);
    }
}
//
// Get avaliable balances
//
$log->lwrite('Getting balances');
$balances = $bfx->get_balances();
$available_balance = 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}");