Bitcoin Forum
May 07, 2024, 01:13:50 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Help with simple PHP trading over BTC-e  (Read 3239 times)
n4ru (OP)
Sr. Member
****
Offline Offline

Activity: 350
Merit: 250



View Profile
April 18, 2013, 12:46:12 AM
 #1

I wrote up a small arbitrage script that calculates potential profits between converting currencies on BTC-e and announces it, but I'm having trouble either automating or getting trades done.

The PHP is being run through a webpage, not a terminal.

Some questions;

What is the simplest way to execute simple trades through PHP via the click of a link or button? Is there a way to do this via POST?
I want to set up links that will immediately trade all of a currency I own on BTC-e into another currency. How can I do this? I have read the API page on BTC-e but I am a bit amateur and could use some explanation - from what I've read that code only works via terminal and times out if ran through a webserver.

What is the simplest way to execute multiple trades @ the highest bid/ask in one go?
For example: I have 1 BTC, and I want to buy 2 LTC. The highest bid is 1.1 LTC for 0.5 BTC, but the next one after that is 0.9 LTC. If I put in an order at highest bid it would end up selling half of a coin for 1.1 LTC and the second trade would not go through. I am attempting to make the arbitration as fast as possible so this would be unacceptable. What's the best way to go about this?

Thanks for the help.
1715087630
Hero Member
*
Offline Offline

Posts: 1715087630

View Profile Personal Message (Offline)

Ignore
1715087630
Reply with quote  #2

1715087630
Report to moderator
1715087630
Hero Member
*
Offline Offline

Posts: 1715087630

View Profile Personal Message (Offline)

Ignore
1715087630
Reply with quote  #2

1715087630
Report to moderator
"Bitcoin: the cutting edge of begging technology." -- Giraffe.BTC
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715087630
Hero Member
*
Offline Offline

Posts: 1715087630

View Profile Personal Message (Offline)

Ignore
1715087630
Reply with quote  #2

1715087630
Report to moderator
1715087630
Hero Member
*
Offline Offline

Posts: 1715087630

View Profile Personal Message (Offline)

Ignore
1715087630
Reply with quote  #2

1715087630
Report to moderator
1715087630
Hero Member
*
Offline Offline

Posts: 1715087630

View Profile Personal Message (Offline)

Ignore
1715087630
Reply with quote  #2

1715087630
Report to moderator
n4ru (OP)
Sr. Member
****
Offline Offline

Activity: 350
Merit: 250



View Profile
April 18, 2013, 12:56:23 AM
 #2

BTC-E can work thru webservers. It is an API as long as you can connect to the btc-e server you can run it. For a few bitcoins I can create a php library for you for btc-e.
I know all this... I'm simply stumped on how to execute the actual trade via the API. I'm not looking for someone to create an entire library for me, just point me in the right direction so I can do it myself.
matmar10
Newbie
*
Offline Offline

Activity: 47
Merit: 0



View Profile WWW
April 18, 2013, 01:10:38 AM
 #3

Check out the PHP library called Guzzle. It's a nice wrapper for RESTful type APIs.

http://guzzlephp.org/

I wrote a wrapper for BTC-e REST API using Guzzle and Symfony framework. Even if you're not using Symfony, the client.xml service description can still be used with Guzzle to execute requests against BTC-e.

The BTC-e API actually has a few really annoying bugs and limitations (no market orders, missing the trade order ID if the order was executed immediately, etc....). I haven't made the code public on my GitHub yet because it's embedded with an app. PM if you'd like me to send you the source and I can share as well as explain the API bugs I encountered and how I worked around them. Hopefully this is helpful.
matmar10
Newbie
*
Offline Offline

Activity: 47
Merit: 0



View Profile WWW
April 18, 2013, 01:16:01 AM
 #4

Check out the PHP library called Guzzle. It's a nice wrapper for RESTful type APIs.

http://guzzlephp.org/

I wrote a wrapper for BTC-e REST API using Guzzle and Symfony framework. Even if you're not using Symfony, the client.xml service description can still be used with Guzzle to execute requests against BTC-e.

The BTC-e API actually has a few really annoying bugs and limitations (no market orders, missing the trade order ID if the order was executed immediately, etc....). I haven't made the code public on my GitHub yet because it's embedded with an app. PM if you'd like me to send you the source and I can share as well as explain the API bugs I encountered and how I worked around them. Hopefully this is helpful.

Links to a few potentially useful pastebins:
  - guzzle client.xml: http://pastebin.com/sgZNU8ew
  - guzzle Client class to handle BTC-e authentication: http://pastebin.com/DzkfN3Cy
  - guzzle Command class to handle BTC-e authentication: http://pastebin.com/nGmYCCjr
n4ru (OP)
Sr. Member
****
Offline Offline

Activity: 350
Merit: 250



View Profile
April 18, 2013, 01:32:03 AM
 #5

Check out the PHP library called Guzzle. It's a nice wrapper for RESTful type APIs.

http://guzzlephp.org/

I wrote a wrapper for BTC-e REST API using Guzzle and Symfony framework. Even if you're not using Symfony, the client.xml service description can still be used with Guzzle to execute requests against BTC-e.

The BTC-e API actually has a few really annoying bugs and limitations (no market orders, missing the trade order ID if the order was executed immediately, etc....). I haven't made the code public on my GitHub yet because it's embedded with an app. PM if you'd like me to send you the source and I can share as well as explain the API bugs I encountered and how I worked around them. Hopefully this is helpful.

Links to a few potentially useful pastebins:
  - guzzle client.xml: http://pastebin.com/sgZNU8ew
  - guzzle Client class to handle BTC-e authentication: http://pastebin.com/DzkfN3Cy
  - guzzle Command class to handle BTC-e authentication: http://pastebin.com/nGmYCCjr

Awesome stuff, I'll check it out! I am inclined to agree with this, however;

That is a lot of extra files and calls for a very simple function.

BTC-E can work thru webservers. It is an API as long as you can connect to the btc-e server you can run it. For a few bitcoins I can create a php library for you for btc-e.
I know all this... I'm simply stumped on how to execute the actual trade via the API. I'm not looking for someone to create an entire library for me, just point me in the right direction so I can do it myself.

For 1 bitcoin (just to cover my time) I can create a function php script that allows you to call it and execute a trade. If you want send 1 bitcoin to http://qcl.me/gweedo and I will write the script and send it to you.
I wish I got paid almost $100 for a couple lines of code...
matmar10
Newbie
*
Offline Offline

Activity: 47
Merit: 0



View Profile WWW
April 18, 2013, 01:35:20 AM
 #6

Check out the PHP library called Guzzle. It's a nice wrapper for RESTful type APIs.

http://guzzlephp.org/

I wrote a wrapper for BTC-e REST API using Guzzle and Symfony framework. Even if you're not using Symfony, the client.xml service description can still be used with Guzzle to execute requests against BTC-e.

The BTC-e API actually has a few really annoying bugs and limitations (no market orders, missing the trade order ID if the order was executed immediately, etc....). I haven't made the code public on my GitHub yet because it's embedded with an app. PM if you'd like me to send you the source and I can share as well as explain the API bugs I encountered and how I worked around them. Hopefully this is helpful.

Links to a few potentially useful pastebins:
  - guzzle client.xml: http://pastebin.com/sgZNU8ew
  - guzzle Client class to handle BTC-e authentication: http://pastebin.com/DzkfN3Cy
  - guzzle Command class to handle BTC-e authentication: http://pastebin.com/nGmYCCjr


That is a lot of extra files and calls for a very simple function.


You could write a one-off script to call CURL manually and end up with a lot of repetitious code (violation of "DRY"). Guzzle library implements the command pattern to abstract away all the boilerplate stuff so that all you need to do is describe the web service, rather than write code for every API method the exchange supports. You get a lot of stuff for free using guzzle such as validation of API parameters.

If you plan to integrate with other exchanges at some point or even just to implement more of BTC-e's API methods, I highly suggest wrapping them with Guzzle.

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!