Author

Topic: Help with simple PHP trading over BTC-e (Read 3257 times)

legendary
Activity: 1498
Merit: 1000
April 17, 2013, 08:45:33 PM
#11
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.


ok but clearly op just wants to do a one off trade not add in all the exchanges which can be easier other abstracted ways. Probably not the way for OP to go.
legendary
Activity: 1498
Merit: 1000
April 17, 2013, 08:43:42 PM
#10
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...

It is more for my time, if had the script all written I would throw it your way, but to take the time to write it and test it, I need to be compensated for that.
legendary
Activity: 1498
Merit: 1000
April 17, 2013, 08:19:01 PM
#7
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.
newbie
Activity: 47
Merit: 0
April 17, 2013, 08:35:20 PM
#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.

sr. member
Activity: 350
Merit: 250
April 17, 2013, 08:32:03 PM
#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...
newbie
Activity: 47
Merit: 0
April 17, 2013, 08:16:01 PM
#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
newbie
Activity: 47
Merit: 0
April 17, 2013, 08:10:38 PM
#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.
sr. member
Activity: 350
Merit: 250
April 17, 2013, 07:56:23 PM
#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.
sr. member
Activity: 350
Merit: 250
April 17, 2013, 07:46:12 PM
#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.
Jump to: