BTC-e Trading Bot Written in PHP

Nowadays, the popularity of bitcoin (BTC) is increasing tremendously, there are quite a few BTC excahge sites on the web. After experiencing certain difficulties with MtGox, people started looking for alternatives, and one of them was a Russian exchange

These days when bitcoin increased like 10 times in two weeks, people started actively looking for automated trading solutions. I’ve been trying to find a BTC trading bot that I can modify and couldn’t find a decent one, so I decided to write my own as BTC provides an API

I’ll give you my code and comments below, but before that I’d like to note that I am NOT responsible for any financial losses, direct or indirect, caused by this software, you use it at your own risk!

Also, it’s worth noticing that it doesn’t make sense to launch it when we see a huge exchange rate increase like it was in the end of November 2013 – beginning of Dec 2013. If you’re sure or just know 🙂 that the rate will be 10x more than today, of course, you’d rather save your BTC’s and trade them when it’s at its peak.

First, we’d need a database to save current market depth and log our transactions. Here is the dump of these two tables:

In order to use trade API calls at BTC-e, you must be registered and obtain your keys under your profile section. Please do so and below you can find the beginning of our bot file:

We can analyze market depth at BTC-e using this URL:

Also, here is the function performing API calls:

and since it’s a bot, we should put all the actions in an infinite loop:

So te indicator is $asks_avg – $bids_avg which shows the current market trend (wither more BTC’s to sell or USD’s).

As a proof that it works for me, I have some historical logs from depth_log, let’s have a look:

So assume we buy at $171.407 on 2013-10-26 22:59:01, and then:

Sell it on 2013-10-27 18:21:23 for $177.14200. So in 18 hours the profit was ~5.7%, we should subtract also 0.4% as commission at BTC-e is 0.2% for every transaction, so roughly 5%.

For those who are interested, here is some data from my depth_log. The whole bot source can be found here

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.