Ejemplo n.º 1
0
include_once './functions.php';
include_once './bitfinex.php';
include_once './logging.php';
// Logging class initialization
$log = new Logging();
// set path and name of log file (optional)
//	$log->lfile('./output.log');
// write message to the log file
$log->lwrite('Startup--------------------------');
$bfx = new Bitfinex($config['api_key'], $config['api_secret']);
//var_dump( $bfx);
//
// Get list of offers
//
$log->lwrite('Getting offers');
$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);