Bitcoin Forum
May 26, 2024, 02:28:50 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
  Home Help Search Login Register More  
  Show Posts
Pages: [1]
1  Economy / Economics / Re: BTC-E + GOX Rolling bot, Rocking bot, Trading bot, Full-Code on: May 07, 2014, 04:48:04 PM
When i run this bot, I keep getting the error
Code:
PHP Notice:  Undefined index: return in /root/bitcoin-rolling-bot-php-master/arbot.php on line 513
PHP Warning:  Invalid argument supplied for foreach() in /root/bitcoin-rolling-bot-php-master/arbot.php on line 513

the line of code it indicates is the second line in this block.

Code:
                if ($BALANCE) $BTCremaining = $BTC*($currentBalanceBTC-$reBalanceBTC);
                foreach ( $TradeHistory['return'] as $key => $value){
                //DEBUG use this information to calculate trades/costs/profits
                        if ( $value['type'] == $exchangeBuySell[0] && $BTCremaining >= $minBidBTC  ) {
                                $costBalance['total'] = $costBalance['total'] + $value['rate']*$value['amount'];
                                $costBalance['shares'] = $costBalance['shares'] + $value['amount'];//$amountTrade[0]; Total shares analysed not / spread
                                $BTCremaining = $BTCremaining - $value['amount'];
                                $countBuys++;
                        }
                        /*
                        {
        "success":1,
        "return":{
                "166830":{
                        "pair":"btc_usd",
                        "type":"sell",
                        "amount":1,
                        "rate":1,
                        "order_id":343148,
                        "is_your_order":1,
                        "timestamp":1342445793
                }
        }
}*/

I don't know php at all so I was hoping someone might be able to help me with this... it doesn't seem to want to make any trades and simply reiterates when it reaches this line.  can someone please help me out with debugging this?

upon asking a code ninja I know about the issue, he says that $TradeHistory doesnt have the 'return' key populated
so the foreach gets a null (or whatever php uses), and promptly goes 'wtf?' but i'm still clueless about how to repair it.
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!