It was the Bitcointalk forum that inspired us to create Bitcointalksearch.org - Bitcointalk is an excellent site that should be the default page for anybody dealing in cryptocurrency, since it is a virtual gold-mine of data. However, our experience and user feedback led us create our site; Bitcointalk's search is slow, and difficult to get the results you need, because you need to log in first to find anything useful - furthermore, there are rate limiters for their search functionality.
The aim of our project is to create a faster website that yields more results and faster without having to create an account and eliminate the need to log in - your personal data, therefore, will never be in jeopardy since we are not asking for any of your data and you don't need to provide them to use our site with all of its capabilities.
We created this website with the sole purpose of users being able to search quickly and efficiently in the field of cryptocurrency so they will have access to the latest and most accurate information and thereby assisting the crypto-community at large.
//Using dynamic depth we can execute the most profitable trade in $currency with a minimum % profit
//set both to 0 to trade everything profitable
$threshold = 0; // Execute any profitable trade **Trade will not execute unless we beat the P % below
$thresholdP = .5; //Threshold as a %
BULB Amount: -0.026001930645792 BULB Percent: -2.6001930645792
BLUB Amount: -0.012551582183679 BLUB Percent: -1.2551582183679.-------
BULB Amount: -0.025993288249436 BULB Percent: -2.5993288249436
BLUB Amount: -0.012551582183679 BLUB Percent: -1.2551582183679.----------------------------------
BULB Amount: -0.025993288249436 BULB Percent: -2.5993288249436
BLUB Amount: -0.014935900543359 BLUB Percent: -1.4935900543359.---------------------
BULB Amount: -0.031117841275131 BULB Percent: -3.1117841275131
BLUB Amount: -0.014935900543359 BLUB Percent: -1.4935900543359.-----------
BULB Amount: -0.031117841275131 BULB Percent: -3.1117841275131
BLUB Amount: -0.014935900543359 BLUB Percent: -1.4935900543359.------------------------------------------------------------
BULB Amount: -0.025310014512676 BULB Percent: -2.5310014512676
BLUB Amount: -0.012210022717122 BLUB Percent: -1.2210022717122.-------------------------------------------------------------------------------------------------------------------------------------------
BULB Amount: -0.020668865787978 BULB Percent: -2.0668865787978
BLUB Amount: -0.01340038470649 BLUB Percent: -1.340038470649.-----------------------
BULB Amount: -0.020668865787978 BULB Percent: -2.0668865787978
BLUB Amount: -0.01340038470649 BLUB Percent: -1.340038470649.------------
BULB Amount: -0.020668865787978 BULB Percent: -2.0668865787978
BLUB Amount: -0.01340038470649 BLUB Percent: -1.340038470649.-----------
BULB Amount: -0.020668865787978 BULB Percent: -2.0668865787978
BLUB Amount: -0.01340038470649 BLUB Percent: -1.340038470649.---------------------
BULB Amount: -0.020668865787978 BULB Percent: -2.0668865787978
BLUB Amount: -0.01340038470649 BLUB Percent: -1.340038470649.-------------------------
BULB Amount: -0.020668865787978 BULB Percent: -2.0668865787978
BLUB Amount: -0.01340038470649 BLUB Percent: -1.340038470649.---------------------
BULB Amount: -0.020668865787978 BULB Percent: -2.0668865787978
BLUB Amount: -0.013097281999212 BLUB Percent: -1.3097281999212.-----------
BULB Amount: -0.020668865787978 BULB Percent: -2.0668865787978
BLUB Amount: -0.013097281999212 BLUB Percent: -1.3097281999212.----------
BULB Amount: -0.020668865787978 BULB Percent: -2.0668865787978
BLUB Amount: -0.013097281999212 BLUB Percent: -1.3097281999212.----------------------
BULB Amount: -0.019983779300247 BULB Percent: -1.9983779300247
BLUB Amount: -0.013097281999212 BLUB Percent: -1.3097281999212.-------------------------
BULB Amount: -0.019983779300247 BULB Percent: -1.9983779300247
BLUB Amount: -0.013097281999212 BLUB Percent: -1.3097281999212.----------
BULB Amount: -0.019983779300247 BULB Percent: -1.9983779300247
BLUB Amount: -0.011582071565528 BLUB Percent: -1.1582071565528.
BULB Amount: -0.019983779300247 BULB Percent: -1.9983779300247
BLUB Amount: -0.011240531161784 BLUB Percent: -1.1240531161784.-------------------------------
#!/bin/bash
NODE1="IP"
NODE2="IP"
#########################
#Arbitrage Bot Round Robin Controller
#must copy nonce
#must update master script
#must swap nodes on second error
#must respect ddos timer
##########################
echo "Round Robbin Started... Ensure you are in a screen session!"
#node 1
node1(){
echo "Starting Node 1..."
ssh -T $NODE1 "cd ~/arbot;php ~/arbot/arbot.php;exit 0;"
echo "Exited Node 1, Copying Files to Node 2."
scp $NODE1:/PATH/arbot.php $NODE2:/PATH/arbot.php
scp $NODE1:/PATH/nonce $NODE2:/PATH/nonce
}
#node 2
node2(){
echo "Node 2 Started."
ssh -T $NODE2 "cd ~/arbot;php ~/arbot/arbot.php;exit 0;"
echo "Exited Node 2, Copying Files to Node 1."
scp $NODE2:/PATH/arbot.php $NODE1:/PATH/arbot.php
scp $NODE2:/PATH/nonce $NODE1:/PATH/nonce
}
#Main Loop
while [ 1 -eq 1 ];
do
node1
sleep 5
node2
sleep 5
done
#screen -dmS arbot -h 1024 -L ./roundrobin.sh
//USER CONFIGURABLE
//Print Debug information on trading
$DEBUG = NULL;
//Your min and max bid, set to the same for static trades
$minBTC = .01;
$maxBTC = .025;
$minUSD = 2;
$maxUSD = 10;
//To use fastTrade set min and max to the same amount.
if ( $minBTC == $maxBTC || $minUSD == $maxUSD){
$fastTrade = TRUE;
print "Fast Trade Enabled ->> Remember to Clear currencies";
}
//Minimum Bids the exchange will accept (BTC-E Mins)
$minBidBTC = .01;
$minBidLTC = .1;
$minBidUSD = .01;
//Using dynamic depth we can execute the most profitable trade in $currency with a minimum % profit
//set both to 0 to trade everything profitable
$threshold = 0; // Execute any profitable trade **Trade will not execute unless we beat the P % below
$thresholdP = .5; //Threshold as a %
//100,001-999,999,999 max wait between non-trade & book duplications reduced 1.2.3.4.
$nanosleep = 1; //nanoseconds
//The maximum time you want to keep an order in the order book in seconds
//This is only applicable to currency flushing (leg 3) orders.
$maxAge = 60; //seconds
//Currency To start and End in B || L || U
$currency = "U";
$interval = 12; // your currency change interval, this many ticks will be analyzed to determine changes in currency
$curve = 1; //the number of opposite ticker pairs to throw away.
/* IE, if you pull $10,11,12,9,13 with an interval 5 and a curve of 1 the price will be assumed to be rising.
* if your interval is 0 the price will be assumed to be stagnant
*/
//BTC-E Currency pairs & bid ask JSON names
$btcesymbol = array("btc_usd", "ltc_btc", "ltc_usd");
$btcebidorask = array("bids", "asks");
$executeTrade = $postTrade = FALSE;
//Programs
//A - Currency Arbitrage, Choose UtoU or BtoB arbitrage through L
//B - Portfolio Balancing, Maintain 50% of two currencies at all times
//D - Buy Down, Buy 1/2 spread each .5 drop and sell 1 each $1 gain
//COUNTERS
$count=1; //# of trades
$o = $i = $e = 0;
$t = 0;
$GLOBALS['ticker'] = array();
//Holds order numbers and times
$price = $volume = array();
$path = $BULB = $BLUB = $UBLU = $ULBU = 0;
//get the incriment from our file
$nonce = readInc();
//Were starting a fresh run, cancel pending orders.
cancelOrders();
//changeCurrency();
//$currency = changeCurrency();
// repeat forever
while ( 'miaviator' != 'uncool'){
//We did not execute a trade the last loop
if (!$executeTrade){
//This is a non-trade loop, write out the incriment to a file.
writeInc($nonce);
//changeCurrency();
//Program Output
print ".";
//we Executed a trade the last run (not this run)
if ($postTrade){
$minUSD = $minBTC*$BTCtoUSD['bids'][0][0];
$maxUSD = $maxBTC*$BTCtoUSD['asks'][0][0];
//The total trades made this run
//@$total = $total + $count;
print $count;
//Reset the trade counter
$count = 0;
//turn off post trade
$postTrade = FALSE;
if(@$fastTrade){
cancelOrders();
//$trade = json_decode(btce_query("getInfo"), TRUE);
//DEBUG add currency clearing method.
} else {
while ( $o > 0 ){
print "o";
$o--;
}
}
}
}
if ($executeTrade){
//We traded last run
$postTrade = TRUE;
//Add a trade to the counter
$count++;
//reset trade BOOL for next run
$executeTrade = FALSE;
}
//Get order book
$i = $e = 0;
//this is horrible code \/
$BTCtoUSDold = @$BTCtoUSD['bids'][0][0];
$LTCtoBTCold = @$LTCtoBTC['bids'][0][0];
$LTCtoUSDold = @$LTCtoUSD['bids'][0][0];
$BTCtoUSDold1 = @$BTCtoUSD['asks'][0][0];
$LTCtoBTCold1 = @$LTCtoBTC['asks'][0][0];
$LTCtoUSDold1 = @$LTCtoUSD['asks'][0][0];
//blank the orderbooks
$BTCtoUSD = $LTCtoBTC = $LTCtoUSD = array();
while( empty($BTCtoUSD) || empty($LTCtoBTC) || empty($LTCtoUSD) ){
$BTCtoUSD = @json_decode( send( 'https://btc-e.com/api/2/btc_usd/depth' ), TRUE );
$LTCtoBTC = @json_decode( send( 'https://btc-e.com/api/2/ltc_btc/depth' ), TRUE );
$LTCtoUSD = @json_decode( send( 'https://btc-e.com/api/2/ltc_usd/depth' ), TRUE );
//Verify the order book changed
$old = $BTCtoUSDold+$LTCtoBTCold+$LTCtoUSDold+$BTCtoUSDold1+$LTCtoBTCold1+$LTCtoUSDold1;
$new = $BTCtoUSD['bids'][0][0]+$LTCtoBTC['bids'][0][0]+$LTCtoUSD['bids'][0][0]+$BTCtoUSD['asks'][0][0]+$LTCtoBTC['asks'][0][0]+$LTCtoUSD['asks'][0][0];
if( !@$BTCtoUSD['bids'] || !@$LTCtoBTC['bids'] || !@$LTCtoUSD['bids']){
$BTCtoUSD = $LTCtoBTC = $LTCtoUSD = array();
//$sleep=rand(6, 36)*(++$e);
$e++;
print "E" . $e;
sleep(5);
if ( $e > 2 ) exit;
/*
if ($nanosleep > 100000)
{$nanosleep = $nanosleep+100000;} //up to 9999 runs
else
{$nanosleep = $nanosleep^10;}
*/
}
if ( $old == $new ){
$BTCtoUSD = $LTCtoBTC = $LTCtoUSD = array();
print "-";
//Dynamic Timer
//$sleep=rand(100000 , $nanosleep);//100000
//time_nanosleep(0, $sleep);
//Static Timer
time_nanosleep(0, $nanosleep);
//if (@$postCancel)
//If we have pending orders cancel them (they may not exist)
if (@$times){
//set the current time to compare orders to
$time = time();
//find the earliest order in the array (end)
$orderOne = end($times);
//If this order is older than maxage start canceling
if ( $orderOne < $time-$maxAge){
//echo loop through order times
foreach ($times as $key => $value ){
//if we've hit orders newer than maxage break
if ( $value > $time-$maxAge ){
break;
}
else {
$order_id = $orders[$key];
//cancel the order by number we don't need to check if it filled or not
$trade = json_decode(btce_query("CancelOrder", array("order_id" => $order_id)), TRUE);
//remove this order and time from the array
unset($orders[$key]);
unset($times[$key]);
print "C";
}
}
}
}
}
}
if ( $currency == "B"){
////////////////////////////////////////////////////////////////////
//BULB Depth Math
////////////////////////////////////////////////////////////////////
//trade 1 math, B to U, B input
$BTC = $maxBTC;
$minimumBidBTC = $minBTC;
foreach ($BTCtoUSD['bids'] as $value){
$BTCtoUSDbidRate = $value[0]; //set Rate
if ($value[1] >= $minimumBidBTC && $value[1] < $BTC ){
$BTC = $value[1]; //set to book value
break;
}
if ( $value[1] >= $minimumBidBTC && $value[1] >= $BTC){
break;
}
}
$USD=$BTC*$BTCtoUSDbidRate*.998; // set U to move on
//trade 2 math, U to L, L input
foreach ($LTCtoUSD['asks'] as $value){
$minimumBidLTC = ($minimumBidBTC*$BTCtoUSDbidRate/.998)/$value[0];
$LTCtoUSDaskRate = $value[0];
if ($value[1] >= $minimumBidLTC/.998 && $value[1]*$value[0] < $USD ) {
$BTC = $USD/$BTCtoUSDbidRate/.998; // set new B
$USD = $BTC*$BTCtoUSDbidRate*.998; // set new U to move on
break;
}
if ( $value[1] >= $minimumBidLTC && $value[1]*$value[0] >= $USD ){
break;
}
}
$LTC =($USD*.998)/$LTCtoUSDaskRate; // set L to move on
//trade 3 math, L to B’, L input
foreach ($LTCtoBTC['bids'] as $value){
$LTCtoBTCbidRate = $value[0];
if ( $value[1]/.998 >= $minimumBidLTC && $value[1] < $LTC ){
$minimumBidBTC = ($minimumBidBTC*$BTCtoUSDbidRate/.998)/$value[0]; //This is in the wrong place and it's not used?
$USDX=($value[1]*$LTCtoUSDaskRate)/.998;
$BTC=($USDX/$BTCtoUSDbidRate)/.998;
$USD = ($BTC*$BTCtoUSDbidRate)*.998;
$LTC = ($USD/$LTCtoUSDaskRate)*.998;
break;
}
if ( $value[1]/.998 >= $minimumBidLTC && $value[1] >= $LTC ){
break;
}
}
$BULBamount = array($BTC,$USD,$LTC);
$BULBrate = array($BTCtoUSDbidRate,$LTCtoUSDaskRate,$LTCtoBTCbidRate);
//$BULB = round((($LTC*$LTCtoBTCbidRate*.998/$BTC)-1)*100,4);
$BULB = $LTC*$LTCtoBTCbidRate*.998-$BTC; //B Profit
//4/19 testing only trading above .2% commision threshold to save on currency clearing costs.
$BULBpercent = (($LTC*$LTCtoBTCbidRate*.998)/$BTC-1)*100;
if (@$DEBUG) print "\n BULB Amount: {$BULB} BULB Percent: {$BULBpercent}";
if ($BULB > $threshold && $BULBpercent > $thresholdP ){$executeTrade = TRUE;}//Trade if criteria are met.
if ($BULBamount < $minBidBTC){exit;} //ERROR CHECK
////////////////////////////////////////////////////////////////////
//END END END BULB Depth Math
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
//BLUB Depth Math
////////////////////////////////////////////////////////////////////
//trade 1 math, B to L, L input
$BTC = $maxBTC;
$minimumBidBTC = $minBTC;
foreach ($LTCtoBTC['asks'] as $value){
$minimumBidLTC = $minimumBidBTC/$value[0];
$LTCtoBTCaskRate = $value[0];
if ($value[1] >= $minimumBidLTC && $value[1]*$value[0] < $BTC && $value[1]*$value[0] >= $minimumBidBTC){
$BTC = $value[1]*$value[0]; //set to book value
break;
}
if ( $value[1] >= $minimumBidLTC && $value[1]*$value[0] >= $BTC){
break;
}
}
$LTC=($BTC/$LTCtoBTCaskRate)*.998; // set L to move on
//trade 2 math, L to U, L input
foreach ($LTCtoUSD['bids'] as $value){
$minimumBidLTC = $minimumBidLTC/.998;
if ($value[1] >= $minimumBidLTC && $value[1] < $LTC ){
$LTCtoUSDbidRate = $value[0];
$BTC = $value[1]*$LTCtoBTCaskRate/.998;
$LTC=($BTC/$LTCtoBTCaskRate)*.998; // recalc trade 1 with new B
break;
}
if ( $value[1] >= $minimumBidLTC && $value[1] >= $LTC){
$LTCtoUSDbidRate = $value[0];
break;
}
}
$USD = ($LTC*$LTCtoUSDbidRate)*.998; // set U to move on
//trade 3 math, U to B’, B input
foreach ($BTCtoUSD['asks'] as $value){
$minimumBidBTC = $minimumBidBTC/.998;
if ( $value[1] >= $minimumBidBTC && $value[1]*$value[0] < $USD){
$BTCtoUSDaskRate = $value[0];
$LTCX = ($value[1]*$value[0])/( $LTCtoUSDbidRate*.998 ); // set new L from book
$BTC = ($LTCX*$LTCtoBTCaskRate)/.998; // set new B with new L
$LTC = ($BTC/$LTCtoBTCaskRate)*.998; // recalc trade 1 with new B
$USD = ($LTC*$LTCtoUSDbidRate)*.998; // recalc trade 2 with new U
break;
}
if ( $value[1] >= $minimumBidBTC && $value[1]*$value[0] >= $USD){
$BTCtoUSDaskRate = $value[0];
break;
}
}
$BLUBamount = array($BTC,$LTC,$USD);
$BLUBrate = array($LTCtoBTCaskRate,$LTCtoUSDbidRate,$BTCtoUSDaskRate);
//$BLUB = round((((($USD/$BTCtoUSDaskRate)*.998)/$BTC)-1)*100,4);
$BLUB = $USD/$BTCtoUSDaskRate*.998-$BTC;
$BLUBpercent = (($USD/$BTCtoUSDaskRate*.998)/$BTC-1)*100;
if ($USD/$BTCtoUSDaskRate*.998-$BTC > $threshold && $BLUBpercent > $thresholdP )
{$executeTrade = TRUE;}
if (@$DEBUG) print "\n BLUB Amount: {$BLUB} BLUB Percent: {$BLUBpercent}";
//ERROR CHECK
if ($BLUBamount < $minBidBTC)
{exit;}
////////////////////////////////////////////////////////////////////
//END END END BLUB Depth Math
////////////////////////////////////////////////////////////////////
}
if ( $currency == "U"){
////////////////////////////////////////////////////////////////////
//ULBU Depth Math
////////////////////////////////////////////////////////////////////
//UBLU is ask, ask, bid.
$minimumBidLTC = $minBidLTC;
$minimumBidBTC = $minBidBTC;
$USD=$maxUSD;
//print "USD: {$USD} \n";
//print "Leg 1 \n";
//trade 1, Buy L with U, L input
foreach ($LTCtoUSD['asks'] as $value){
//print_r($value);
//minbid ltc already set
$LTCtoUSDaskRate=$value[0]; // set rate
//After this transaction and commision you must have at least 1LTC left
//If we buy .1 LTC we can't sell the .0998LTC in LEG 2
if ($value[1] >= $minimumBidLTC/.998 && $value[1]*$value[0] < $USD ){
$USD=$value[1]*$value[0]; // set U to book value
//print "USD: {$USD} \n";
break;
}
if ( $value[1] >= $minimumBidLTC/.998 && $value[1]*$value[0] >= $USD){
//$USD = $USD; // use current U
break;
}
}
$LTC =($USD/$LTCtoUSDaskRate)*.998; // set L to move on
//print "LTC: {$LTC} \n";
//trade 2, Sell L for B, L input
//print "Leg 2 \n";
//At current rates we don't worry about minimum USD bids
//Value0 is rate(inB) value 1 is amount (inL) 0*1 is total B
foreach ($LTCtoBTC['bids'] as $value){
//print_r($value);
$LTCtoBTCbidRate = $value[0]; // set rate
if ( $value[1] >= $minimumBidLTC && $value[1] < $LTC && $value[0]*$value[1]*.998 >= $minimumBidBTC ){
$USD = ($value[1]*$LTCtoUSDaskRate)/.998; // set new U up
//print "USD: {$USD} \n";
$LTC = $USD/$LTCtoUSDaskRate*.998; // set new L down
//print "LTC: {$LTC} \n";
break;
}
if ($value[1]/.998 >= $minimumBidLTC && $value[1] >= $LTC && $value[0]*$value[1]*.998 >= $minimumBidBTC ){
//$USD = $USD; // use current U
//$LTC = $LTC; // use current L
break;
}
}
$BTC =($LTC*$LTCtoBTCbidRate)*.998; // set B to move on
//print "BTC: {$BTC} \n";
//trade 3, Sell B for U’, B input
//print "Leg 3 \n";
foreach ($BTCtoUSD['bids'] as $value){
//print_r($value);
$BTCtoUSDbidRate = $value[0]; // set rate
if ( $value[1] >= $minimumBidBTC && $value[1] < $BTC ){
//$LTCX = $value[1]/*Total B*//$LTCtoBTCbidRate/*Div .002 ish for L*//.998/*Add commision*/
//$LTCX=$value[1]/($LTCtoUSDaskRate*.998); // set new L up
$LTCX = $value[1]/$LTCtoBTCbidRate/.998;
//print "LTCX: {$LTCX} \n";
$USD=($LTCX*$LTCtoUSDaskRate)/.998; // set new U up
//print "USD: {$USD} \n";
$LTC=($USD/$LTCtoUSDaskRate)*.998; // set new L down
//print "LTC: {$LTC} \n";
$BTC=($LTC*$LTCtoBTCbidRate)*.998; // set new B down
//print "BTC: {$BTC} \n";
break;
}
if ( $value[1] >= $minimumBidBTC && $value[1] >= $BTC){
//$USD = $USD; // use current U
//$LTC = $LTC; // use current L
//$BTC = $BTC; // use current B
break;
}
}
$USDX =($BTC*$BTCtoUSDbidRate)*.998; // final U
//print "USDX: {$USDX} \n";
$ULBUamount = array($USD,$LTC,$BTC);
//print "ULBUamount: {$ULBUamount} \n";
$ULBUrate = array($LTCtoUSDaskRate,$LTCtoBTCbidRate,$BTCtoUSDbidRate);
//print_r($ULBUrate);
$ULBU = $USDX-$USD;
//print "ULBU: {$ULBU} \n";
if ( $ULBU > $threshold)
{$executeTrade = TRUE;}
//ERROR CHECK
if ($ULBUamount < $minBidUSD)
{exit;}
////////////////////////////////////////////////////////////////////
//END ULBU Depth Math
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
//UBLU Depth Math
////////////////////////////////////////////////////////////////////
/// initial trade amount = $USD
///UBLU///
$minimumBidBTC = $minBidBTC;
$USD=$maxUSD;
//print "USD: {$USD} \n";
//(define mins)
//trade 1, Buy B with U, B input
foreach ($BTCtoUSD['asks'] as $value){
//print_r($value);
$BTCtoUSDaskRate=$value[0]; // set rate
if ( $value[1] >= $minimumBidBTC && $value[1]*$value[0] < $USD ){
$USD=$value[1]*$value[0]; // set U to book value
//print "USD: {$USD} \n";
break;
}
if ( $value[1] >= $minimumBidBTC && $value[1]*$value[0] >= $USD){
//$USD = $USD; // use current U
break;
}
}
$BTC =($USD/$BTCtoUSDaskRate)*.998; // set B to move on
//print "BTC: {$BTC} \n";
//trade 2, Buy L with B, L input
foreach ($LTCtoBTC['asks'] as $value){
//print_r($value);
$LTCtoBTCaskRate = $value[0]; // set rate
if ( $value[1]/.998 >= $minimumBidLTC && $value[1]*$value[0] < $BTC ){
$USD=($value[1]*$value[0]*$BTCtoUSDaskRate)/.998; // set new U up
//print "USD: {$USD} \n";
$BTC=($USD/$BTCtoUSDaskRate)*.998; // set new B down
//print "BTC: {$BTC} \n";
break;
}
if ($value[1]/.998 >= $minimumBidLTC && $value[1] >= $BTC){
//$USD = $USD; // use current U
//$BTC = $BTC; // use current B
break;
}
}
$LTC =($BTC/$LTCtoBTCaskRate)*.998; // set L to move on
//print "LTC: {$LTC} \n";
//trade 3, Sell L for U’, L input
foreach ($LTCtoUSD['bids'] as $value){
$LTCtoUSDbidRate = $value[0];
if ( $value[1] >= $minimumBidLTC && $value[1] < $LTC ){
$BTCX=($value[1]*$LTCtoBTCaskRate)/.998; // set new B up
//print "BTCX: {$BTCX} \n";
$USD=($BTCX*$BTCtoUSDaskRate)/.998; // set new U up
//print "USD: {$USD} \n";
$BTC=($USD/$BTCtoUSDaskRate)*.998; // set new B down
//print "BTC: {$BTC} \n";
$LTC=($BTC/$LTCtoBTCaskRate)*.998; // set new L down
//print "LTC: {$LTC} \n";
break;
}
if ( $value[1] >= $minimumBidLTC && $value[1] >= $LTC){
//$USD = $USD; // use current U
//$BTC = $BTC; // use current B
//$LTC = $LTC; // use current L
break;
}
}
$USDX =($LTC*$LTCtoUSDbidRate)*.998; // final U
//print "USDX: {$USDX} \n";
$UBLUamount = array($USD,$BTC,$LTC);
//print "UBLUamount: {$UBLUamount} \n";
$UBLUrate = array($BTCtoUSDaskRate,$LTCtoBTCaskRate,$LTCtoUSDbidRate);
//print_r($UBLUrate);
$UBLU = $USDX-$USD;
//print "UBLU: {$UBLU} \n";
if ($UBLU > $threshold)
{$executeTrade = TRUE;}
//ERROR CHECK
if ($UBLUamount < $minBidUSD)
{exit;}
////////////////////////////////////////////////////////////////////
//END UBLU Depth Math
////////////////////////////////////////////////////////////////////
}
////////////////////////////////////////////////////////////////////
//Modular Trade Arrays
////////////////////////////////////////////////////////////////////
if (@$executeTrade){
//FIND THE HIGHEST PROFIT OPPORTUNITY
if ( $currency == "B"){
$path = max(@$BULB, @$BLUB);
}
if ( $currency == "U"){
$path = max(@$UBLU, @$ULBU);
}
if ( $path == @$BULB )
{
//define bulb trade arrays
$tradeName = "BULB";
$type = array("sell","buy","sell");
$symbol = array("btc_usd","ltc_usd","ltc_btc");
$amount = $BULBamount;
$rate = $BULBrate;
$round = array(8,8,8);
$funds = array("btc","usd","ltc");
}
if ( $path == @$BLUB )
{
//define BLUB trade arrays
$tradeName = "BLUB";
$type = array("buy","sell","buy");
$symbol = array("ltc_btc","ltc_usd","btc_usd");
$amount = $BLUBamount;
$rate = $BLUBrate;
$round = array(8,8,8);
$funds = array("btc","ltc","usd");
}
if ( $path == @$ULBU )
{
$tradeName = "ULBU";
$type = array("buy","sell","sell");
$symbol = array("ltc_usd","ltc_btc","btc_usd");
$amount = $ULBUamount;
$rate = $ULBUrate;
$round = array(8,8,8);
$funds = array("usd","ltc","btc");
}
if ( $path == @$UBLU )
{
$tradeName = "UBLU";
$type = array("buy","buy","sell");
$symbol = array("btc_usd","ltc_btc","ltc_usd");
$amount = $UBLUamount;
$rate = $UBLUrate;
$round = array(8,8,8);
$funds = array("usd","btc","ltc");
}
////////////////////////////////////////////////////////////////////
//Modular Trade Code
////////////////////////////////////////////////////////////////////
//How to speed up trading?
//Use microtrades, no orders, no error testing, nothing.
if (@$fastTrade){
//Execute trade one
$amount[0] = round($amount[0],8);
$trade = json_decode(btce_query("Trade", array("pair" => $symbol[0], "type" => $type[0], "amount" => $amount[0], "rate" => $rate[0])), TRUE);
$amount[1] = round($amount[1],8);
//execute trade 2
$trade = json_decode(btce_query("Trade", array("pair" => $symbol[1], "type" => $type[1], "amount" => $amount[1], "rate" => $rate[1])), TRUE);
$amount[2] = round($amount[2],8);
if ($amount[2] > 0){
//execute trade 3
$trade = json_decode(btce_query("Trade", array("pair" => $symbol[2], "type" => $type[2], "amount" => $amount[2], "rate" => $rate[2])), TRUE);
}
} else {
//Set the trade time for order cancellations
$tradeTime = time();
//Start executing trades
//Execute trade one
$amount[0] = round($amount[0],8);
$trade = json_decode(btce_query("Trade", array("pair" => $symbol[0], "type" => $type[0], "amount" => $amount[0], "rate" => $rate[0])), TRUE);
if (@$DEBUG) print_r ($trade);
if (@$DEBUG) echo "pair" . $symbol[0] . "type" . $type[0] . "amount" . $amount[0] . "rate" . $rate[0] . "\n";
//If we traded, and we recieved an order, log it to Orders
if ( $trade['success'] == 1 && $trade['return']['order_id'] > 0 ){
$cancel = json_decode(btce_query("CancelOrder", array("order_id" => $trade['return']['order_id'])), TRUE);
$trade = json_decode(btce_query("getInfo"), TRUE);
}
//If the trade failed, get the balance for trade 2
elseif( $trade['success'] !== 1 ){
$trade = json_decode(btce_query('getInfo'), TRUE);
}
//Set the available funds for trade 2 (different for buy and sell orders)
if ( $type[1] == "buy" ){
$tmp = (@$trade['return']['funds'][$funds[1]]/$rate[1]);
//print_r($trade);
}
elseif ( $type[1] == "sell" ){
$tmp = (@$trade['return']['funds'][$funds[1]]);
//print_r($trade);
}
//Trade 2 can cause exchange loops if it trades the balance, prevent this
if ( $tmp < $amount[1] ){
$amount[1] = $tmp;
}
$amount[1] = round($amount[1],8);
//If we have funds to make trade 2 execute the trade otherwise move to trade 3
//on second thought, just execute it anyways....
//if ($amount[1] > 0){
//execute trade 2
$trade = json_decode(btce_query("Trade", array("pair" => $symbol[1], "type" => $type[1], "amount" => $amount[1], "rate" => $rate[1])), TRUE);
if (@$DEBUG) print_r ($trade);
if (@$DEBUG) echo "pair" . $symbol[1] . "type" . $type[1] . "amount" . $amount[1] . "rate" . $rate[1] . "\n";
//If we traded, and we recieved an order, log it to Orders
if ( $trade['success'] == 1 && $trade['return']['order_id'] > 0 ){
$cancel = json_decode(btce_query("CancelOrder", array("order_id" => $trade['return']['order_id'])), TRUE);
$trade = json_decode(btce_query("getInfo"), TRUE);
}
//If the trade failed, get the balance for trade 3
elseif( $trade['success'] !== 1 ){
$trade = json_decode(btce_query("getInfo"), TRUE);
}
//Set the available funds for trade 3 (different for buy and sell orders)
//Trade 3 clears currency by trading the Balance of this currency out
if ( $type[2] == "buy" ){
$amount[2] = (@$trade['return']['funds'][$funds[2]]/$rate[2]);
//print_r($trade);
}
elseif ( $type[2] == "sell" ){
$amount[2] = (@$trade['return']['funds'][$funds[2]]);
//print_r($trade);
}
//Check if we have funds to trade (or just orders)
$amount[2] = round($amount[2],8);
if ($amount[2] > 0){
//execute trade 3
$trade = json_decode(btce_query("Trade", array("pair" => $symbol[2], "type" => $type[2], "amount" => $amount[2], "rate" => $rate[2])), TRUE);
if (@$DEBUG) print_r ($trade);
if (@$DEBUG) echo "pair" . $symbol[2] . "type" . $type[2] . "amount" . $amount[2] . "rate" . $rate[2] . "\n";
//If we traded, and we recieved an order, log it to Orders
if ( $trade['success'] == 1 && $trade['return']['order_id'] > 0 ){
$o++;
$orders[$nonce] = $trade['return']['order_id'];
$times[$nonce] = $tradeTime;
}
}
}
}
}
////////////////////////////////////////////////////////////////////
//END Modular Trade Code
////////////////////////////////////////////////////////////////////
print "\n\n DANGER miaviator IS NO LONGER COOL? \n\n";
exit;
// FUNCTIONS
function btce_query( $method = NULL, $req = array() )
{
//MAIN KEY
$key = ''; // your API-key
$secret = ''; // your Secret-key
// API settings
$req['method'] = $method;
$req['nonce'] = $GLOBALS['nonce']++;
// generate the POST data string
$postData = http_build_query($req, '', '&');
// generate the extra headers
$headers = array(
'Sign: '.hash_hmac("sha512", $postData, $secret)
,"Key: {$key}"
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; BTCE PHP client; '.php_uname('s').'; PHP/'.phpversion().')');
curl_setopt($ch, CURLOPT_URL, 'https://btc-e.com/tapi');
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
return curl_exec($ch);
}
function writeInc( $value = NULL )
{
$fp = fopen('nonce','w');
fwrite($fp, $value);
fclose($fp);
return;
}
function readInc()
{
$fp = fopen('nonce','r');
$value = (int)fread($fp, 8);
fclose($fp);
return $value;
}
function cancelOrders()
{
$return = json_decode(btce_query("OrderList"), TRUE);
if($return['success'] > 0){
foreach ($return['return'] as $key => $value){
$order_id = $key;
$trade = json_decode(btce_query("CancelOrder", array("order_id" => $order_id)), TRUE);
print "C";
}
}
}
function send( $url = NULL )
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
function changeCurrency()
{
//DEBUG if ticker fails to download you could have issues?
//SOLVED if a GAP between buy and sell develops you could change, used buy and sell, now using last
//DEBUG change must be greater than original spread,
//incriment ticker count
$t = $GLOBALS["t"];
$t++;
//pull ticker
$GLOBALS['ticker'][$t] = @json_decode( send( 'https://btc-e.com/api/2/btc_usd/ticker' ), TRUE );
//if we returned invalid data or the price didnt change do nothing
if ( !@$GLOBALS['ticker'][$t] || $GLOBALS['ticker'][$t]['ticker']['last'] < .00000001 || $GLOBALS['ticker'][$t]['ticker']['last'] == $GLOBALS['ticker'][$t-1]['ticker']['last'] ){
//unset($GLOBALS['ticker'][$t]); //throw away the data
$t--;//Decriment Ticker
$GLOBALS["t"] = $t; //copy ticker to global
return $GLOBALS['ticker']; //exit the function
}
//if we have enough data to determine direction
if ( $t > $GLOBALS['interval']+1 ){
//reset changecurrency
$changeCurrency = 0;
if ($GLOBALS['currency'] == "B"){
//reset quote # counter
$q = 0;
//loop through last Interval quotes
while ( $q <= $GLOBALS['interval'] ){
//if our first ticker is GT than the tickers after, price is decreasing
if ( $GLOBALS['ticker'][$t-$GLOBALS['interval']]['ticker']['last'] > $GLOBALS['ticker'][$t-$q]['ticker']['last'] ) {$changeCurrency++;}
$q++;
}
if ( $changeCurrency >= $GLOBALS['interval']-$GLOBALS['curve'] ){
//CHANGE CURRENCY B to U SELL B for U
$GLOBALS['sellPrice'] = $GLOBALS['ticker'][$t]['ticker']['sell'];
$GLOBALS['currency'] = "U";
$trade = json_decode(btce_query("getInfo"), TRUE);
//Trade out 50% of B for U
$trade = json_decode(btce_query("Trade", array("pair" => "btc_usd", "type" => "sell", "amount" => $trade['return']['funds']['btc'], "rate" => $GLOBALS['ticker'][$t]['ticker']['sell'])), TRUE);
cancelOrders();
print "\n Changed Currecy B to U: {$GLOBALS['sellPrice']} ";
}
}
if ($GLOBALS['currency'] == "U"){
// reset quote # counter
$q = 0;
//loop through quotes
while ( $q <= $GLOBALS['interval'] ){
//if first ticker < following tickers price is increasing
if ( $GLOBALS['ticker'][$t-$GLOBALS['interval']]['ticker']['last'] < $GLOBALS['ticker'][$t-$q]['ticker']['last'] ) {$changeCurrency++;}
$q++;
}
if ( $changeCurrency >= $GLOBALS['interval']-$GLOBALS['curve'] ){
$GLOBALS['buyPrice'] = $GLOBALS['ticker'][$t]['ticker']['buy'];
if ( $GLOBALS['sellPrice'] < $GLOBALS['buyPrice'] ){
//You'll loose money if you sell low and buy high.
//You'll also lose money if you sit while currency declines
}
//CHANGE CURRENCY B to U
$GLOBALS['currency'] = "B";
$trade = json_decode(btce_query("getInfo"), TRUE);
$trade = json_decode(btce_query("Trade", array("pair" => "btc_usd", "type" => "buy", "amount" => $trade['return']['funds']['usd'] , "rate" => $GLOBALS['ticker'][$t]['ticker']['buy'])), TRUE);
cancelOrders();
print "\n Changed Currecy U to B: {$GLOBALS['buyPrice']}";
}
}
}
$GLOBALS["t"] = $t;
return;
}
/************************************************************************************
*OLD CHANGE CURRENCY CODE
* function changeCurrency()
{
//SOLVED the price can't change if the last doesn't change or our calc shouldn't change unless the last changes
//DEBUG if ticker fails to download you could have issues?
//DEBUG if a GAP between buy and sell develops you could change,
//Analyse last buy and sell x 4 not 5
//
//Execute from non-trading and non-duplicate runs, where arbot prints a .
//incriment ticker count
$t = $GLOBALS["t"];
$t++;
//unset($GLOBALS['ticker'][$t-$GLOBALS['interval']-1]); we can proly leave this.... IDK how large it will get.
//pull ticker
$GLOBALS['ticker'][$t] = @json_decode( send( 'https://btc-e.com/api/2/btc_usd/ticker' ), TRUE );
//if we returned invalid data or the price didnt change
if ( !@$GLOBALS['ticker'][$t] || $GLOBALS['ticker'][$t]['ticker']['last'] < .00000001 || $GLOBALS['ticker'][$t]['ticker']['last'] == $GLOBALS['ticker'][$t-1]['ticker']['last'] ){
//unset($GLOBALS['ticker'][$t]); //throw away the data
$t--;//Decriment Ticker
$GLOBALS["t"] = $t; //copy ticker to global
return $GLOBALS['ticker']; //exit the function
}
if ( $t > $GLOBALS['interval']+1 ){
//print "Last: {$GLOBALS['ticker'][$t]['ticker']['last']}";
//keep last interval price and volumes
//{"ticker":{"high":154.99001,"low":121.12,"avg":138.055005,"vol":4033206.07126,"vol_cur":29514.1577,"last":133,"buy":133.4,"sell":132.2,"server_time":1366830779}}
$changeCurrency = 0;
if ($GLOBALS['currency'] == "B"){
//analyse price trend to sell out of B (sell price)
//first if buyPrice < sellPrice buy at 110 current 102 price up buy price down sell
//if 4 of 5 are less than first
//we need to analyze 6, 1 = original, 2,3,4,5,6 = 5 comps, 4 of which must be up or down,
$q = 1;
while ( $q <= $GLOBALS['interval']+1 ){
if ( $GLOBALS['ticker'][$t-$GLOBALS['interval']]['ticker']['sell'] > $GLOBALS['ticker'][$t-$q]['ticker']['sell'] ) {$changeCurrency++;}
$q++;
//print "CC: {$changeCurrency} ";
}
if ( $changeCurrency >= $GLOBALS['interval']-$GLOBALS['curve'] ){
//Analyse buy Book
$q = 1;
while ( $q <= $GLOBALS['interval']+1 ){
if ( $GLOBALS['ticker'][$t-$GLOBALS['interval']]['ticker']['buy'] > $GLOBALS['ticker'][$t-$q]['ticker']['buy'] ) {$changeCurrency++;}
$q++;
//print "CC: {$changeCurrency} ";
}
if ( $changeCurrency >= $GLOBALS['interval']-$GLOBALS['curve'] ){
//CHANGE CURRENCY B to U
$GLOBALS['sellPrice'] = $GLOBALS['ticker'][$t]['ticker']['sell'];
$GLOBALS['currency'] = "U";
$trade = json_decode(btce_query("getInfo"), TRUE);
$trade = json_decode(btce_query("Trade", array("pair" => "btc_usd", "type" => "sell", "amount" => $trade['return']['funds']['btc']/2, "rate" => $GLOBALS['ticker'][$t]['ticker']['sell']-.01)), TRUE);
cancelOrders();
print "\n Changed Currecy B to U: {$GLOBALS['sellPrice']} ";
//place order to trade out currency? .1B at a time? how to repeat?
//Trade out 50% of B for U
}
}
}
$changeCurrency = 0;
if ($GLOBALS['currency'] == "U"){
//analyse price trend to sell out of B (sell price)
//first if buyPrice < sellPrice buy at 110 current 102 price up buy price down sell
//if x-1 of x buys are less than first
$q = 1;
while ( $q <= $GLOBALS['interval']+1 ){
if ( $GLOBALS['ticker'][$t-$GLOBALS['interval']]['ticker']['buy'] < $GLOBALS['ticker'][$t-$q]['ticker']['buy'] ) {$changeCurrency++;}
$q++;
//print "CC: {$changeCurrency} ";
}
//if x-1 of x sells are less than first
//SOLVED make this a nested if,
if ( $changeCurrency >= $GLOBALS['interval']-$GLOBALS['curve'] ){
$q = 1;
while ( $q <= $GLOBALS['interval']+1 ){
if ( $GLOBALS['ticker'][$t-$GLOBALS['interval']]['ticker']['sell'] < $GLOBALS['ticker'][$t-$q]['ticker']['sell'] ) {$changeCurrency++;}
$q++;
//print "CC: {$changeCurrency} ";
}
if ( $changeCurrency >= $GLOBALS['interval']-$GLOBALS['curve'] ){
$GLOBALS['buyPrice'] = $GLOBALS['ticker'][$t]['ticker']['buy'];
if ( $GLOBALS['sellPrice'] < $GLOBALS['buyPrice'] ){
//You'll loose money if you sell low and buy high.
//You'll also lose money if you sit while currency declines
}
//CHANGE CURRENCY B to U
$GLOBALS['currency'] = "B";
$trade = json_decode(btce_query("getInfo"), TRUE);
$trade = json_decode(btce_query("Trade", array("pair" => "btc_usd", "type" => "buy", "amount" => $trade['return']['funds']['usd']/2 , "rate" => $GLOBALS['ticker'][$t]['ticker']['buy']+.01)), TRUE);
cancelOrders();
print "\n Changed Currecy U to B: {$GLOBALS['buyPrice']}";
}
//and if volume is increasing
}
}
//if last is lt low
//if last is gt than high
//if last is lt average
//if last is gt average
//current currency = $GLOBALS['currency']
}
$GLOBALS["t"] = $t;
return;
}
****************************************************************************************************/
?>