curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_URL, $url); $result = curl_exec($ch); curl_close($ch); $json = json_decode($result, true); return $json; } //get price for BTC-E currency pair function getPriceData($pair) { global $public_api; $json = retrieveJSON($public_api . 'ticker/' . $pair); return $json[$pair]; } $candleData = new Database($db); $candleData->get_options(); $candleData->get_candles('bitfinex_btc'); $diff = $candleData->get_percent(); $percentDiff_12 = $candleData->get_percent(); //trend of 12 candles (6 hours) $percentDiff_12 = number_format($percentDiff_12, 2); //echo $percentDiff_12; //get ema10 and ema21 $k21 = 2 / (21 + 1); //smoothing constant - 21 day $k10 = 2 / (10 + 1); //smoothing constant - 10 day $q = 'SELECT date_format(time, "%m/%d/%Y %h:%i %p") as time, bitfinex_btc from api_prices order by count desc'; $res = $db->query($q); $array = array(); $arrayPrice = array();
global $dumpPercent; global $bitfinexBalance; $pumpPercent = 3.8; $dumpPercent = -3.8; $debug = $_GET['debug']; $bitfinexAPI = new Bitfinex(BITFINEX_API_KEY, BITFINEX_API_SECRET); $candleData = new Database($db); if ($debug == 1) { //debug mode - no trading, output only echo '<< debug mode >>'; $newline = '<br>'; } else { //live mode - output is sent to email - \n is newline in emails $newline = "\n"; } $bitfinexOptions = $candleData->get_options(); $bitfinexTrading = $bitfinexOptions['bitfinex_trading']; $bitfinexAPI->isBitfinexTrading($bitfinexTrading); $optionsArray = array('bitfinex_currency', 'bitfinex_balance', 'bitfinex_pd_percent', 'bitfinex_sl_range', 'bitfinex_trading'); $output .= $newline . $newline . 'api_options' . $newline; foreach ($optionsArray as $thisOpt) { $output .= ' ' . $thisOpt . ': ' . $bitfinexOptions[$thisOpt] . ' | '; } if ($bitfinexTrading == 1) { $output .= 'Bitfinex trading is ON'; } else { $output .= 'Bitfinex trading is OFF'; } $currency = $bitfinexOptions['bitfinex_currency']; //currency defined in api_options $symbol = strtoupper($currency . 'usd');