Bitcoin Forum
July 18, 2019, 01:58:45 AM *
News: Latest Bitcoin Core release: 0.18.0 [Torrent] (New!)
 
   Home   Help Search Login Register More  
Pages: « 1 [2] 3 4 »  All
  Print  
Author Topic: BTC-E PHP Currency Arbitrage Bot Full Code  (Read 39605 times)
Eb0la
Sr. Member
****
Offline Offline

Activity: 350
Merit: 250



View Profile
May 27, 2013, 10:54:24 PM
 #21

Tried running this to see what it would do and it's throwing me these errors:

Code:
gdlinux@gdlinux:~/Desktop$ php phpbot.php
#screen -dmS arbot -h 1024 -L ./roundrobin.sh
PHP Warning:  fopen(nonce): failed to open stream: No such file or directory in /home/gdlinux/Desktop/phpbot.php on line 689
PHP Warning:  fread() expects parameter 1 to be resource, boolean given in /home/gdlinux/Desktop/phpbot.php on line 690
PHP Warning:  fclose() expects parameter 1 to be resource, boolean given in /home/gdlinux/Desktop/phpbot.php on line 691
PHP Fatal error:  Call to undefined function curl_init() in /home/gdlinux/Desktop/phpbot.php on line 665

and this is a little beyond me to figure out. I set debug to TRUE and the output did not give me any more hints. Thoughts?

My guess would be that you don't have the Curl extension installed for PHP
1563415125
Hero Member
*
Offline Offline

Posts: 1563415125

View Profile Personal Message (Offline)

Ignore
1563415125
Reply with quote  #2

1563415125
Report to moderator
1563415125
Hero Member
*
Offline Offline

Posts: 1563415125

View Profile Personal Message (Offline)

Ignore
1563415125
Reply with quote  #2

1563415125
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
Seal
Donator
Hero Member
*
Offline Offline

Activity: 836
Merit: 1005


View Profile WWW
May 29, 2013, 11:29:21 AM
 #22

Is arbitrage still profitable? and how has your experience been so far running this?

I ran an arb bot for a long time and it was very profitable. I stopped it to pursue more profitable ventures, i monitor the prices a lot still (out of habit) and see a lot of arb opportunities. Good luck to those running the script. The more arbitrage there is, the more efficient the market will become.

miaviator
Donator
Hero Member
*
Offline Offline

Activity: 672
Merit: 500


It's for the children!


View Profile WWW
May 29, 2013, 12:57:58 PM
 #23

Is arbitrage still profitable? and how has your experience been so far running this?

I ran an arb bot for a long time and it was very profitable. I stopped it to pursue more profitable ventures, i monitor the prices a lot still (out of habit) and see a lot of arb opportunities. Good luck to those running the script. The more arbitrage there is, the more efficient the market will become.

Thank you for pointing that out!  Since exchanges are not internally arbitrating and there is no open cooperation to create an inter-exchange arbitration system the markets have strange gaps in prices and exchange rates.  In an ideal system the prices and rates would automatically even out over all of the exchanges (which could also reduce BTC's price correlation to gox uptime).

miaviator
Donator
Hero Member
*
Offline Offline

Activity: 672
Merit: 500


It's for the children!


View Profile WWW
May 29, 2013, 01:00:03 PM
 #24

Tried running this to see what it would do and it's throwing me these errors:

Code:
gdlinux@gdlinux:~/Desktop$ php phpbot.php
#screen -dmS arbot -h 1024 -L ./roundrobin.sh
PHP Warning:  fopen(nonce): failed to open stream: No such file or directory in /home/gdlinux/Desktop/phpbot.php on line 689
PHP Warning:  fread() expects parameter 1 to be resource, boolean given in /home/gdlinux/Desktop/phpbot.php on line 690
PHP Warning:  fclose() expects parameter 1 to be resource, boolean given in /home/gdlinux/Desktop/phpbot.php on line 691
PHP Fatal error:  Call to undefined function curl_init() in /home/gdlinux/Desktop/phpbot.php on line 665

and this is a little beyond me to figure out. I set debug to TRUE and the output did not give me any more hints. Thoughts?

My guess would be that you don't have the Curl extension installed for PHP

I would agree that curl_init() error would tell me you don't have the curl extension.  Also this is odd "PHP Warning:  fopen(nonce): failed to open stream: No such file or directory in /home/gdlinux/Desktop/phpbot.php on line 689"  Try creating an empty file called nonce with no extension at /home/gdlinux/Desktop/nonce and see if that helps.

Code:
touch /home/gdlinux/Desktop/nonce

Seal
Donator
Hero Member
*
Offline Offline

Activity: 836
Merit: 1005


View Profile WWW
May 29, 2013, 01:02:41 PM
 #25

Is arbitrage still profitable? and how has your experience been so far running this?

I ran an arb bot for a long time and it was very profitable. I stopped it to pursue more profitable ventures, i monitor the prices a lot still (out of habit) and see a lot of arb opportunities. Good luck to those running the script. The more arbitrage there is, the more efficient the market will become.

Thank you for pointing that out!  Since exchanges are not internally arbitrating and there is no open cooperation to create an inter-exchange arbitration system the markets have strange gaps in prices and exchange rates.  In an ideal system the prices and rates would automatically even out over all of the exchanges (which could also reduce BTC's price correlation to gox uptime).

Thats the whole idea of people running arb bots, as well as giving them profits, it helps normalise the prices across each exchange. At the moment MtGox still leads price movements.

As for internal arb, an exchange trading on its own books isn't good practise and is a severe conflict of interest as they would easily have the capability to both under cut everyone and perform 'front running'.

grabble
Newbie
*
Offline Offline

Activity: 23
Merit: 0


View Profile
May 29, 2013, 06:26:46 PM
 #26

I've been mining LTC and depositing directly to my btc-e account, running the arb bot to find the most profitable path to BTC on btc-e then sending the BTC to gox to cash out for USD and take advantage of the price difference. It's a rather round-a-bout way of going about things but it works out pretty well.

Also I figured out if you put in a support request with btc-e and ask them to white list your IP address it will stop your bot from getting blocked and eliminate the need for the round robin script.

I would highly suggest anyone using their API to ask them to white list their IP address.
billotronic
Legendary
*
Offline Offline

Activity: 1610
Merit: 1000


Crackpot Idealist


View Profile
May 29, 2013, 07:12:37 PM
Last edit: May 29, 2013, 09:08:03 PM by billotronic
 #27

well shit, I didn't even spot the (obvious) curl call. Shame on me.

Curl alone did not sort it out. I had to create the nonce file and now the bot is spitting out what looks like morse code so I guess its working now. Thanks!

[edit] ok, i will bite. this is what the output looks like

Code:
#screen -dmS arbot -h 1024 -L ./roundrobin.sh
..---....-....----.--------.--..-.---.------------.---.--.-.----.---------------------.----.----.-.--------.------.--.-..--..------------------------.-------.-----------.-..-.--.-..-.--....---------.-------.------------------.--.---.----.-------------------------..-..------.-.--.---.----..-----------------------.-----------.------------.---.--------.-----.-------------.--------.----.-----------.-.3....-..-.---.-.----.----..---....-.-..-..----.---.--......-----..-...---------.---...-..---..-..---.----..---.-..-----.-----.--.-------...---.---..-----.-.----.----------.---.-..-.----.-.1------.-.--.------.-------.----.---.---------.----------------------.-..-.---.---..-------.---.----.-.-.--...---..-.-------------..-.--.---..-----.-.....-.----.--..--.--....1-------..---.---..------..--..--.--....-.-----...-.-..--.--.-.---..---.---.----.-------.--.-....--.-------.-.-----.--...--.-..-..--.-.---..-..-..-.--.--.....-.-..-..-........--.-......--------.-..1-.------------..------.1----.------------...-.-----..--..-..-.----.--.-----------....---.-..--.--------.----.-...-.-...-.--...--.-.-..-..-..--...--.....-.--...-...--------.-----.-...---.-------.------.-----------.---.---..-.-.-...-.--------...-------.--.-.--.---.---.-----.2..----.------..-..--..-------..--.--------.-------.-.--.-.1----.-.------.-.1.-.-...-...--.1.----.--..-..--.-----.------.--.--.--------------.------..-..--.----..-.---.--.------------.---------.-.-----.--.----..---------....-.--.-.-.--.---------.----..------..-----.-.--------.----------..---...-----...--.-.1.---.-...-----.-----.----.--------------------------..------------.----.-.----.-..-.-..1---.-..-.--..--------.---------.--------.1-..-.-...-..-.1----.--.-..--.-----.--------...--.---..--.--------.--.-..------.-.-----.1-.--...-.-------.-.-..-..-------.----------.---..---.----.

Reading the translation of this I ASSUME all is well and the script just does not see a profitable path? Reason I ask is becuase this looks nothing like Jude Austin's output he posted.

This post sums up why all this bullshit is a scam
Read It. Hate It. Change the facts that it represents.
https://bitcointalk.org/index.php?topic=1606638.msg16139644#msg16139644
steganos
Newbie
*
Offline Offline

Activity: 44
Merit: 0



View Profile
May 29, 2013, 10:10:24 PM
 #28

Is arbitrage still profitable? and how has your experience been so far running this?

Arbitrage is less profitable now that a lot of bots exist.   As I said I have abandoned this for a rolling buy sell bot which is proving more profitable.  I did make several B over the course of a few weeks using this bot.  I would think that other exchanges and auto transfers could be added in order to take advantage of the dozen or so alts out there with different prices and faster transaction times than B.

All of that said.  I'm not one to turn down making even $.01 a day while I sleep, eat and work.  Free money is free money.

Can you point a noob to something that explains what the strategy is for a rolling buy sell bot?

Thanks.
miaviator
Donator
Hero Member
*
Offline Offline

Activity: 672
Merit: 500


It's for the children!


View Profile WWW
May 30, 2013, 01:02:42 AM
 #29

well shit, I didn't even spot the (obvious) curl call. Shame on me.

Curl alone did not sort it out. I had to create the nonce file and now the bot is spitting out what looks like morse code so I guess its working now. Thanks!

[edit] ok, i will bite. this is what the output looks like

Code:
#screen -dmS arbot -h 1024 -L ./roundrobin.sh
..---....-....----.--------.--..-.---.------------.---.--.-.----.---------------------.----.----.-.--------.------.--.-..--..------------------------.-------.-----------.-..-.--.-..-.--....---------.-------.------------------.--.---.----.-------------------------..-..------.-.--.---.----..-----------------------.-----------.------------.---.--------.-----.-------------.--------.----.-----------.-.3....-..-.---.-.----.----..---....-.-..-..----.---.--......-----..-...---------.---...-..---..-..---.----..---.-..-----.-----.--.-------...---.---..-----.-.----.----------.---.-..-.----.-.1------.-.--.------.-------.----.---.---------.----------------------.-..-.---.---..-------.---.----.-.-.--...---..-.-------------..-.--.---..-----.-.....-.----.--..--.--....1-------..---.---..------..--..--.--....-.-----...-.-..--.--.-.---..---.---.----.-------.--.-....--.-------.-.-----.--...--.-..-..--.-.---..-..-..-.--.--.....-.-..-..-........--.-......--------.-..1-.------------..------.1----.------------...-.-----..--..-..-.----.--.-----------....---.-..--.--------.----.-...-.-...-.--...--.-.-..-..-..--...--.....-.--...-...--------.-----.-...---.-------.------.-----------.---.---..-.-.-...-.--------...-------.--.-.--.---.---.-----.2..----.------..-..--..-------..--.--------.-------.-.--.-.1----.-.------.-.1.-.-...-...--.1.----.--..-..--.-----.------.--.--.--------------.------..-..--.----..-.---.--.------------.---------.-.-----.--.----..---------....-.--.-.-.--.---------.----..------..-----.-.--------.----------..---...-----...--.-.1.---.-...-----.-----.----.--------------------------..------------.----.-.----.-..-.-..1---.-..-.--..--------.---------.--------.1-..-.-...-..-.1----.--.-..--.-----.--------...--.---..--.--------.--.-..------.-.-----.1-.--...-.-------.-.-..-..-------.----------.---..---.----.

Reading the translation of this I ASSUME all is well and the script just does not see a profitable path? Reason I ask is becuase this looks nothing like Jude Austin's output he posted.

Lol, to all of the above.

That output is really good. 

- = Duplicate order book pulled, (nothing has changed and there was no profit in the last pull)
. = Order book analysed, (no profitable paths found)
# = trade legs attempted (according to your output the bot attempted over a dozen profitable trade legs!)

Check your order history and see if you completed any trade routes or if you only made it through the first one or two legs.

The script does currency clearing back to BTC even if it's at a loss just to avoid staying in U or L.   The issue with arbitrage is that after you execute trade 1 say B to U, someone could eat the U to L trade before you trade it or the L to B trade which often leaves you way into U or L.  I installed currency clearing in leg 3 and non-repeat trading in leg two (originally I installed currency clearing in leg two, it caused the script to rotate between L and U, U and L losing commissions)

miaviator
Donator
Hero Member
*
Offline Offline

Activity: 672
Merit: 500


It's for the children!


View Profile WWW
May 30, 2013, 01:22:57 AM
 #30

Is arbitrage still profitable? and how has your experience been so far running this?

Arbitrage is less profitable now that a lot of bots exist.   As I said I have abandoned this for a rolling buy sell bot which is proving more profitable.  I did make several B over the course of a few weeks using this bot.  I would think that other exchanges and auto transfers could be added in order to take advantage of the dozen or so alts out there with different prices and faster transaction times than B.

All of that said.  I'm not one to turn down making even $.01 a day while I sleep, eat and work.  Free money is free money.

Can you point a noob to something that explains what the strategy is for a rolling buy sell bot?

Thanks.

BTC to USD rolls, as in the value repeatedly crosses the same point or the same trailing/advancing points.

In it's simplest form a lot of people roll BTC just by buying at 120,110,100,90,80 and selling at 100,110,120,130. 

In a more advanced form BTC experiences hundreds of micro spikes and dips (my trade engine V2) which lets you buy at 114.26 and sell at 114.84 etc.
Code:
Buy = Last*(1-.002)*((1-$profitThreshold/2)^(1+iteration))
Sell = Buy/(1-.002)/((1-$profitThreshold/2)^(1+iteration))
up to hundreds of times a day.   


In a more advanced form, BTC experiences macro-rolls of 2-10% on a daily/weekly/monthly basis allowing you to buy at almost any price and sell at an advancing price of +2.5/5/10% while at the same time experiencing micro-rolls mentioned above (my trade engine V3)
Code:
Sell = Dolar Cost Average /(1-.002)/(1-.002)/((1-$biggerProfitThreshold)^(1+iteration))

In an even more advanced form, BTC Appreciates and Depreciates to USD at different intervals (rolling price) and moves toward and away from a rolling 24 hour high and low.  If you were always 100% in BTC as it approached and broke the high, and were always 100% in USD as BTC approached and broke the low, you would profit (a lot) from the resulting appreciation of BTC vs USD and USD vs BTC.
Code:
Omitted

The n00b answer is "a rolling bot, automatically buys low and sells high using a very volatile vehicle" 

My trade history for the first three versions of the engine show low buys followed by high sells in each version.  They also show an overall loss due to B appreciation beating the profit from rolling.  If the price of B slowly declined I would have made a profit from the micro and macro rolls in addition to USD vs BTC appreciation.

billotronic
Legendary
*
Offline Offline

Activity: 1610
Merit: 1000


Crackpot Idealist


View Profile
May 30, 2013, 02:10:05 AM
 #31

Well hello mr fancy pants...

Thank you for the technical answer and the fun code to play with.

This post sums up why all this bullshit is a scam
Read It. Hate It. Change the facts that it represents.
https://bitcointalk.org/index.php?topic=1606638.msg16139644#msg16139644
steganos
Newbie
*
Offline Offline

Activity: 44
Merit: 0



View Profile
May 30, 2013, 02:29:09 AM
 #32

Thank you for the excellent explanation.
billotronic
Legendary
*
Offline Offline

Activity: 1610
Merit: 1000


Crackpot Idealist


View Profile
May 30, 2013, 02:56:54 PM
 #33

Question about this:

Code:
//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

Is this just informative? Glancing through the code I did not see a place to set this.

This post sums up why all this bullshit is a scam
Read It. Hate It. Change the facts that it represents.
https://bitcointalk.org/index.php?topic=1606638.msg16139644#msg16139644
miaviator
Donator
Hero Member
*
Offline Offline

Activity: 672
Merit: 500


It's for the children!


View Profile WWW
May 30, 2013, 05:02:37 PM
 #34

Question about this:

Code:
//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

Is this just informative? Glancing through the code I did not see a place to set this.

I try to keep a changelog and bug log inside my code, this was just the rewrite log for ARBOT which is now:

Code:
////////////////////////////////////////////////////////////////////
//Programs
////////////////////////////////////////////////////////////////////
//A - Currency Arbitrage, Choose UtoU or BtoB arbitrage through L
//B - Portfolio Balancing, Maintain 50% of two currencies at all times
//C - Custom trailing/advancing buy/sell bot for gna
//D - Buy Down, Buy 1/2 spread each .5 drop and sell 1 each $1 gain
//E - Rolling buy/sell on dips and spikes V1,1.1,1.2,V2,2.1
//F - 24 Hour high/low balancing bot, maintain (high-last)/(high-low) balance in USD and (last-low)/(high-low) in BTC
//G - EMA triggered rolling with Fibonacci shares and high/low balancing combination with micro-trade re-balancing.


billotronic
Legendary
*
Offline Offline

Activity: 1610
Merit: 1000


Crackpot Idealist


View Profile
May 30, 2013, 06:56:11 PM
 #35

Groovy... I'm glad I did not miss something (again) when going through the code. Fun stuff.

This post sums up why all this bullshit is a scam
Read It. Hate It. Change the facts that it represents.
https://bitcointalk.org/index.php?topic=1606638.msg16139644#msg16139644
snowcrashed
Full Member
***
Offline Offline

Activity: 294
Merit: 100



View Profile
May 30, 2013, 07:00:07 PM
Last edit: May 30, 2013, 09:00:27 PM by snowcrashed
 #36

Hmm tried to get this running in windows with XAMPP.  I applied grabble's fix and when that was still giving E1.E2.E3 error I tried miaviator's code change for outputting more info.  This is what I get:

Code:
C:\xampp\php>php test.php
#screen -dmS arbot -h 1024 -L ./roundrobin.sh
.
Notice: Undefined variable: postData in C:\xampp\php\test.php on line 710

Notice: Undefined variable: headers in C:\xampp\php\test.php on line 711

Warning: curl_setopt(): You must pass either an object or an array with the CURL
OPT_HTTPHEADER, CURLOPT_QUOTE, CURLOPT_HTTP200ALIASES and CURLOPT_POSTQUOTE argu
ments in C:\xampp\php\test.php on line 711

Notice: Undefined variable: postData in C:\xampp\php\test.php on line 710

Notice: Undefined variable: headers in C:\xampp\php\test.php on line 711

Warning: curl_setopt(): You must pass either an object or an array with the CURL
OPT_HTTPHEADER, CURLOPT_QUOTE, CURLOPT_HTTP200ALIASES and CURLOPT_POSTQUOTE argu
ments in C:\xampp\php\test.php on line 711

Notice: Undefined variable: postData in C:\xampp\php\test.php on line 710

Notice: Undefined variable: headers in C:\xampp\php\test.php on line 711

Warning: curl_setopt(): You must pass either an object or an array with the CURL
OPT_HTTPHEADER, CURLOPT_QUOTE, CURLOPT_HTTP200ALIASES and CURLOPT_POSTQUOTE argu
ments in C:\xampp\php\test.php on line 711
E1Array
(
)
Array
(
)
Array
(
)
-

It does this 5 times then exits.  I thought maybe I copy/pasted something wrong but repeated the process twice and still get the same error.  Not sure why it thinks postData and headers are undefined, I see them being defined right before this function.  

Edit:  Ah nevermind looks like I messed something up when I entered my api key/secret.  I'm use to programming languages that don't mind if you take a space out.  Ran it for a bit, got a bunch of - and . then E1E2E3.  I checked the btc-e.com/api links and get data returned so I don't think the IP was banned.  Ran it a second time and got ".E1-E2-E3".  When I apply miaviator's change to the
Code:
while( empty($BTCtoUSD) || empty($LTCtoBTC) || empty($LTCtoUSD) ){
loop, I get the same output as above again.

Edit Again:  Well it appeared to be working and it executed some trades (created an order/cancelled it/sold LTC for USD) but then it ended with an E1E2E3 again.  Tried running it again and now I'm back to ".E1-E2-E3" then terminates.  Any idea what could be causing this?  And the btc-e.com/api links are all still accessible and return data so my IP isn't blocked.  Just to be thorough I connected to a VPN and tried running the bot again, still no luck.  It seems like there is some sort of "timeout".  After running the bot successfully for ~10 minutes it returns E1E2E3 then becomes unusable for about 15-20 minutes.  After that timeout it will work again, but this process just repeats itself.  Tried changing the api key/secret to a new one just to see if it was being tracked by that, but no luck.  
miaviator
Donator
Hero Member
*
Offline Offline

Activity: 672
Merit: 500


It's for the children!


View Profile WWW
May 30, 2013, 09:16:42 PM
 #37

Edit Again:  Well it appeared to be working and it executed some trades (created an order/cancelled it/sold LTC for USD) but then it ended with an E1E2E3 again.  Tried running it again and now I'm back to ".E1-E2-E3" then terminates.  Any idea what could be causing this?  And the btc-e.com/api links are all still accessible and return data so my IP isn't blocked.  Just to be thorough I connected to a VPN and tried running the bot again, still no luck.  It seems like there is some sort of "timeout".  After running the bot successfully for ~10 minutes it returns E1E2E3 then becomes unusable for about 15-20 minutes.  After that timeout it will work again, but this process just repeats itself.  Tried changing the api key/secret to a new one just to see if it was being tracked by that, but no luck.  

You may need to space out your API requests a little more, or remove the
Code:
exit;
statement in the error block.  I think after a while of continuously polling data cloudflare lets you keep going.  Again this is why I developed the roundrobbin helper to swap IP's often. 

Try upping the nano-sleep variable to something like 500000000 if it works you can reduce it by a few million every hour or so.

Code:
//100,001-999,999,999 max wait between non-trade & book duplications reduced 1.2.3.4.
$nanosleep = 500000000; //nanoseconds

snowcrashed
Full Member
***
Offline Offline

Activity: 294
Merit: 100



View Profile
May 30, 2013, 11:22:48 PM
Last edit: May 30, 2013, 11:37:36 PM by snowcrashed
 #38

That seems to have done it, thanks.  Though now the activity level is way down.  I was getting at least a couple of trades per 10-15 mins, now I just ran for an hour and only 1.  Forgive my ignorance if the lack of trades is just a product of current market prices, but are there other settings that are tweakable to increase activity? 
billotronic
Legendary
*
Offline Offline

Activity: 1610
Merit: 1000


Crackpot Idealist


View Profile
May 30, 2013, 11:44:33 PM
 #39

That seems to have done it, thanks.  Though now the activity level is way down.  I was getting at least a couple of trades per 10-15 mins, now I just ran for an hour and only 1.  Forgive my ignorance if the lack of trades is just a product of current market prices, but are there other settings that are tweakable to increase activity? 

That is what I assumed but I never posted any trades. I tried dropping the %'s and starting B U L and no noticeable effect. Very curious.

This post sums up why all this bullshit is a scam
Read It. Hate It. Change the facts that it represents.
https://bitcointalk.org/index.php?topic=1606638.msg16139644#msg16139644
alexxy
Sr. Member
****
Offline Offline

Activity: 363
Merit: 250


View Profile
May 31, 2013, 07:57:45 AM
 #40

Any updates to code? BTW why dont put it on github?
Pages: « 1 [2] 3 4 »  All
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!