Pages:
Author

Topic: BTC-E PHP Currency Arbitrage Bot Full Code - page 2. (Read 39926 times)

full member
Activity: 294
Merit: 100
Well I spent a few more days running this/playing around with settings and I simply can't get it to trade consistently, let alone for a profit.  Thanks for releasing this to the public anyhow, maybe I'm just not using it properly.
donator
Activity: 686
Merit: 519
It's for the children!
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?  

Ideally to make the most trades: (when I was running this my account had at least 100 trades per day)  

1. You need a low latency to cloudflare and btc-e (fast connection or tier 1 network, or server in russia?)
2. The script needs to be able to run with no timers firing.
3. The script needs to print no output or only print output if a trade path was analyzed and no profit was found.
4. fastTrade should be enabled! - This again ideally will cause the script to fire all three trades with no error checking and no currency clearing.  The best chance to complete three trade legs is to complete them sequentially as soon as they are found.  The issue is that this method will leave your funds stuck in whatever the last currency leg that filled was.  Since I normally run bots to make the exchange a higher profit (.2%-.6% to exchange vs .1% to me) there can be a loss when converting back to the original currency.  In the crypto currency world it is dangerous to sit in anything other than 50%Crypto 50%USD continuously balanced since the prices are extremely volatile.

To make the most profit, the script should detect price trends in BTC and trade B to B while the price is rising and U to U while the price is falling.  Or swap from B to U to ensure a 50% balance in the portfolio.

Hmm tried running it in fastTrade mode and every trade path it finds, it cancels the order immediately afterwards.  I set minbidusd/maxbidusd to = $5, in my account I have more than that so I figured that was a good place to start unless I'm not understanding what those variables stand for.  Also, how can I optimize the settings for minbid/maxbid related to me account?

And thanks for releasing this code to the public as well as helping us get it running.  If I see some profits from this I will definitely be sending some your way.

Edit:  Left it running for about 24 hours and seems like every O is followed by a C soon after, running fasttrade or not.  Is this normal behavior?

The difference between fastrade and standard is that in standard the bot polls your balance after every trade.  In fast mode it doesn't care if the orders place fill fail.  it just attempts to set the orders and then immediately cancels anything that doesn't fill.
donator
Activity: 686
Merit: 519
It's for the children!
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? 

Ideally to make the most trades: (when I was running this my account had at least 100 trades per day) 

1. You need a low latency to cloudflare and btc-e (fast connection or tier 1 network, or server in russia?)
2. The script needs to be able to run with no timers firing.
3. The script needs to print no output or only print output if a trade path was analyzed and no profit was found.
4. fastTrade should be enabled! - This again ideally will cause the script to fire all three trades with no error checking and no currency clearing.  The best chance to complete three trade legs is to complete them sequentially as soon as they are found.  The issue is that this method will leave your funds stuck in whatever the last currency leg that filled was.  Since I normally run bots to make the exchange a higher profit (.2%-.6% to exchange vs .1% to me) there can be a loss when converting back to the original currency.  In the crypto currency world it is dangerous to sit in anything other than 50%Crypto 50%USD continuously balanced since the prices are extremely volatile.

To make the most profit, the script should detect price trends in BTC and trade B to B while the price is rising and U to U while the price is falling.  Or swap from B to U to ensure a 50% balance in the portfolio.

Even if you are on to better things, we the people, greatly appreciate you sharing your work. I've rekindled an interest in coding due to looking at and tinkering with the bots on here for btc-e. Good times.

I've found that latency mostly isn't relevant for bitcoin exchanges. As long as your server is in europe it will make very little difference. What I have found is that establishing the connection for a http trade call (from php) will take anywhere between 0.5 and 1.0 second regardless of where your location is. This in relative terms is massive.

That is an excellent point!  It would be good to open a connection with curl (or websocket) and feed things through it vs opening a new session every time.

I don't have any servers in europe?  can I borrow one?
donator
Activity: 848
Merit: 1078
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? 

Ideally to make the most trades: (when I was running this my account had at least 100 trades per day) 

1. You need a low latency to cloudflare and btc-e (fast connection or tier 1 network, or server in russia?)
2. The script needs to be able to run with no timers firing.
3. The script needs to print no output or only print output if a trade path was analyzed and no profit was found.
4. fastTrade should be enabled! - This again ideally will cause the script to fire all three trades with no error checking and no currency clearing.  The best chance to complete three trade legs is to complete them sequentially as soon as they are found.  The issue is that this method will leave your funds stuck in whatever the last currency leg that filled was.  Since I normally run bots to make the exchange a higher profit (.2%-.6% to exchange vs .1% to me) there can be a loss when converting back to the original currency.  In the crypto currency world it is dangerous to sit in anything other than 50%Crypto 50%USD continuously balanced since the prices are extremely volatile.

To make the most profit, the script should detect price trends in BTC and trade B to B while the price is rising and U to U while the price is falling.  Or swap from B to U to ensure a 50% balance in the portfolio.

Even if you are on to better things, we the people, greatly appreciate you sharing your work. I've rekindled an interest in coding due to looking at and tinkering with the bots on here for btc-e. Good times.

I've found that latency mostly isn't relevant for bitcoin exchanges. As long as your server is in europe it will make very little difference. What I have found is that establishing the connection for a http trade call (from php) will take anywhere between 0.5 and 1.0 second regardless of where your location is. This in relative terms is massive.
full member
Activity: 124
Merit: 100
I probably won't be using this, but I like your code and found it interesting to see a trading bot's source code. Thanks.
legendary
Activity: 1610
Merit: 1000
Crackpot Idealist
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? 

Ideally to make the most trades: (when I was running this my account had at least 100 trades per day) 

1. You need a low latency to cloudflare and btc-e (fast connection or tier 1 network, or server in russia?)
2. The script needs to be able to run with no timers firing.
3. The script needs to print no output or only print output if a trade path was analyzed and no profit was found.
4. fastTrade should be enabled! - This again ideally will cause the script to fire all three trades with no error checking and no currency clearing.  The best chance to complete three trade legs is to complete them sequentially as soon as they are found.  The issue is that this method will leave your funds stuck in whatever the last currency leg that filled was.  Since I normally run bots to make the exchange a higher profit (.2%-.6% to exchange vs .1% to me) there can be a loss when converting back to the original currency.  In the crypto currency world it is dangerous to sit in anything other than 50%Crypto 50%USD continuously balanced since the prices are extremely volatile.

To make the most profit, the script should detect price trends in BTC and trade B to B while the price is rising and U to U while the price is falling.  Or swap from B to U to ensure a 50% balance in the portfolio.

Even if you are on to better things, we the people, greatly appreciate you sharing your work. I've rekindled an interest in coding due to looking at and tinkering with the bots on here for btc-e. Good times.
full member
Activity: 294
Merit: 100
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?  

Ideally to make the most trades: (when I was running this my account had at least 100 trades per day)  

1. You need a low latency to cloudflare and btc-e (fast connection or tier 1 network, or server in russia?)
2. The script needs to be able to run with no timers firing.
3. The script needs to print no output or only print output if a trade path was analyzed and no profit was found.
4. fastTrade should be enabled! - This again ideally will cause the script to fire all three trades with no error checking and no currency clearing.  The best chance to complete three trade legs is to complete them sequentially as soon as they are found.  The issue is that this method will leave your funds stuck in whatever the last currency leg that filled was.  Since I normally run bots to make the exchange a higher profit (.2%-.6% to exchange vs .1% to me) there can be a loss when converting back to the original currency.  In the crypto currency world it is dangerous to sit in anything other than 50%Crypto 50%USD continuously balanced since the prices are extremely volatile.

To make the most profit, the script should detect price trends in BTC and trade B to B while the price is rising and U to U while the price is falling.  Or swap from B to U to ensure a 50% balance in the portfolio.

Hmm tried running it in fastTrade mode and every trade path it finds, it cancels the order immediately afterwards.  I set minbidusd/maxbidusd to = $5, in my account I have more than that so I figured that was a good place to start unless I'm not understanding what those variables stand for.  Also, how can I optimize the settings for minbid/maxbid related to me account?

And thanks for releasing this code to the public as well as helping us get it running.  If I see some profits from this I will definitely be sending some your way.

Edit:  Left it running for about 24 hours and seems like every O is followed by a C soon after, running fasttrade or not.  Is this normal behavior?
donator
Activity: 686
Merit: 519
It's for the children!
Can you share your latest version of this script?

This is the latest version of the arbitrage script, I can't share any of the rolling engines yet.
sr. member
Activity: 363
Merit: 250
Can you share your latest version of this script?
donator
Activity: 686
Merit: 519
It's for the children!
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? 

Ideally to make the most trades: (when I was running this my account had at least 100 trades per day) 

1. You need a low latency to cloudflare and btc-e (fast connection or tier 1 network, or server in russia?)
2. The script needs to be able to run with no timers firing.
3. The script needs to print no output or only print output if a trade path was analyzed and no profit was found.
4. fastTrade should be enabled! - This again ideally will cause the script to fire all three trades with no error checking and no currency clearing.  The best chance to complete three trade legs is to complete them sequentially as soon as they are found.  The issue is that this method will leave your funds stuck in whatever the last currency leg that filled was.  Since I normally run bots to make the exchange a higher profit (.2%-.6% to exchange vs .1% to me) there can be a loss when converting back to the original currency.  In the crypto currency world it is dangerous to sit in anything other than 50%Crypto 50%USD continuously balanced since the prices are extremely volatile.

To make the most profit, the script should detect price trends in BTC and trade B to B while the price is rising and U to U while the price is falling.  Or swap from B to U to ensure a 50% balance in the portfolio.
donator
Activity: 686
Merit: 519
It's for the children!
Any updates to code? BTW why dont put it on github?

I moved on from the project so no updates, if you request something here I might be able to modify it.

I don't know anything about github.
sr. member
Activity: 363
Merit: 250
Any updates to code? BTW why dont put it on github?
legendary
Activity: 1610
Merit: 1000
Crackpot Idealist
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.
full member
Activity: 294
Merit: 100
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? 
donator
Activity: 686
Merit: 519
It's for the children!
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
full member
Activity: 294
Merit: 100
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.  
legendary
Activity: 1610
Merit: 1000
Crackpot Idealist
Groovy... I'm glad I did not miss something (again) when going through the code. Fun stuff.
donator
Activity: 686
Merit: 519
It's for the children!
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.

legendary
Activity: 1610
Merit: 1000
Crackpot Idealist
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.
newbie
Activity: 44
Merit: 0
Thank you for the excellent explanation.
Pages:
Jump to: