Exemple #1
0
function load_btccharts_data($file)
{
    global $fake_index;
    if (file_exists($fake_index)) {
        $findex = file($fake_index);
        $index = trim($findex[0]);
    } else {
        $index = 0;
    }
    if ($index >= count(file($file))) {
        echo "\r\n *** Simulation is over! *** \r\n";
        sleep(900);
        die;
    }
    $F2 = file($file);
    $F2 = trim($F2[$index]);
    while (strpos($F2, "+") !== false or strpos($F2, "Infinity") !== false) {
        $index++;
        if ($index >= count(file($file))) {
            echo "\r\rnsimulation is over!\r\n";
            sleep(900);
            die;
        }
        $F2 = file($file);
        $F2 = trim($F2[$index]);
    }
    $F2 = explode(",", $F2);
    $data["datetime"] = $F2[0];
    $data["bid"] = $F2[3];
    $data["ask"] = $F2[2];
    $data["high"] = $F2[2];
    $data["low"] = $F2[3];
    $data["btc_volume"] = $F2[5];
    $data["usd_volume"] = $F2[6];
    $data["weighted_price"] = $F2[7];
    $data["close"] = $F2[4];
    $data["open"] = $F2[1];
    $index++;
    if ($index >= count(file($file))) {
        echo "\r\rnsimulation is over!\r\n";
        sleep(900);
        die;
    }
    wfilenew($fake_index, $index);
    return $data;
}
Exemple #2
0
$fake_datetime_of_firstbid = "2014-01-01 00:00:00";
//Initial datetime (same as first line of $fakegox_tickers file below)
$fakegox_tickers = $datadir . "fakegox_tickers(24.12-26.12).txt";
//Access http://bitcoincharts.com/charts/mtgoxUSD, set the period (must be a period that supports interval 1min), click Raw Data, copy/paste the contents of the table in a TXT file and replaces tabulations by "," comma);
/* Data for accessing the Twitter API, if you do not have go to: https://dev.twitter.com/apps and create your key (with read/write permissions) */
$twitter_oauth["consumer_key"] = "XXXXXXXXXXXXXXXXX";
$twitter_oauth["consumer_secret"] = "XXXXXXXXXXXXXXXXXXXXXXXXXXX";
$twitter_oauth["token"] = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$twitter_oauth["secret"] = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$twitter_users = "@intrd";
//Twitter @users to be notified
$enable_tweet = false;
//enable/disable twitter notifications
/* Format of starting data */
$reset_data = true;
//turn on to reset data every run;
if ($fake == true or $reset_data == true) {
    $default_data = "{$fake_datetime_of_firstbid},,{$fake_btc_usd_buyedprice},ask,loss,7.71,,,\r\n{$fake_datetime_of_firstbid},,{$fake_btc_usd_buyedprice},bid,loss,7.71,,,\r\n";
    wfilenew($datachart, $default_data);
    $default_data = "bid,[btc{$fake_btc_balance}/usd:0],{$fake_btc_usd_buyedprice},{$fake_datetime_of_firstbid},loss,#suddenmode,\r\n";
    wfilenew($lastfile, $default_data);
    $default_data = '{"data":{"Login":"******","Trade_Fee":' . $percentual . ',"Wallets":{"BTC":{"Balance":{"value":' . $fake_btc_balance . '}},"USD":{"Balance":{"value":0}}}},"trade_mode":"bid","balancing":0}';
    wfilenew($fakegox, $default_data);
    $default_data = "0";
    wfilenew($fake_index, $default_data);
    $default_data = "Starting HAL10K with {$fake_btc_balance} BTC buyd @ {$fake_btc_usd_buyedprice}\r\n";
    wfilenew($lastfile_clean, $default_data);
}
echo "\r\n### ATENTION: First running? edit thes file: bitcoin/hal10k/configs.php \r\n### configure parameters and comment '//' this line.";
sleep(999);
//COMMENT THIS LINE AT FIRST RUN
Exemple #3
0
             $infodata = get_infodataf($fake);
             $info = get_infodata($infodata, $fake);
             $transa = ask($info, $ticker["ticker_sell"], $last_order, $wall, $info["balancing"], $sudden_mode);
         }
     }
 } else {
     if ($info["trade_mode"] == "bid") {
         if ($reverse_prices == 1) {
             $ticker["ticker_buy"] = $ticker["ticker_sell"];
         }
         $range = $last_order["price"] - percentual($percentual, $last_order["price"]) - $down_diff - $ticker["ticker_buy"];
         $direction = "<" . market_direction($dire, true, $ema) . "/up>";
         $next_price = $last_order["price"] - percentual($percentual, $last_order["price"]) - $down_diff;
         $stoploss = $last_order["price"] + percentual($percentual, $last_order["price"]) + $down_diff_inv;
         $nm = status($ticker["ticker_buy"], $info["trade_mode"], $next_price, $stoploss, $last_order["type"], $last_order["price"], $direction, $last_order["prem"]);
         wfilenew($nextmov, $nm);
         if ($ticker["ticker_buy"] <= $next_price and market_direction($dire, true, $ema) == "up" or $ticker["ticker_buy"] >= $stoploss and market_direction($dire, false, $ema) == "up" or $sudden_mode == 1) {
             if ($ticker["ticker_buy"] >= $stoploss and market_direction($dire, false, $ema) == "up") {
                 echo "\n*** #Hit wall!";
                 $wall = 1;
                 if ($manualstoploss == 0) {
                     $sudden_mode = 1;
                 }
             }
             if ($sudden_mode == 1) {
                 $wall = false;
                 echo "\n*** #SUDDEN MODE on!";
                 $sudden_mode = 1;
                 $ticker["ticker_buy"] = $ticker["ticker_sell"];
             }
             if ($manualstoploss == 1 and $wall == 1) {