Bitcoin Forum
December 13, 2024, 10:36:27 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1] 2 3 »  All
  Print  
Author Topic: Automated bitcoin arbitrage  (Read 18901 times)
maxme (OP)
Newbie
*
Offline Offline

Activity: 48
Merit: 0



View Profile WWW
March 16, 2013, 01:26:18 PM
 #1

Hi guys,

I wanted to share my code. It's a bitcoin arbitrage watcher and automated trade software. Written in Python:

https://github.com/maxme/bitcoin-arbitrage

Feedback and pull-requests are welcome Wink
Fireball
Hero Member
*****
Offline Offline

Activity: 674
Merit: 500


View Profile WWW
March 16, 2013, 02:25:39 PM
 #2

If you'd like to add ICBIT support, I will be glad to help.

Margin trading platform OrderBook.net (ICBIT): https://orderbook.net
Follow us in Twitter: https://twitter.com/orderbooknet
whizter
Hero Member
*****
Offline Offline

Activity: 588
Merit: 500


View Profile
March 18, 2013, 07:55:38 PM
 #3

I'm running this in test-mode atm. Is it supposed to do this?

Quote
2013-03-18 20:46:12,680 [DEBUG] ticker: MtGoxEUR - {'ask': {'price': 36.97115, 'amount': 3.055}, 'bid': {'price': 36.95, 'amount': 7.68486008}}
2013-03-18 20:46:12,680 [DEBUG] ticker: BitcoinCentralEUR - {'ask': {'price': 37.05425, 'amount': 5.0}, 'bid': {'price': 37.00004, 'amount': 0.321795}}
2013-03-18 20:46:12,700 [INFO] profit: 0.138720 EUR with volume: 5.000000 BTC -buy at 37.0000 (MtGoxEUR) sell at 37.0000 (BitcoinCentralEUR) ~0.07%
2013-03-18 20:46:42,700 [DEBUG] ticker: MtGoxEUR - {'ask': {'price': 36.97115, 'amount': 3.055}, 'bid': {'price': 36.95, 'amount': 7.68486008}}
2013-03-18 20:46:42,700 [DEBUG] ticker: BitcoinCentralEUR - {'ask': {'price': 37.05425, 'amount': 5.0}, 'bid': {'price': 37.00004, 'amount': 0.321795}}
2013-03-18 20:46:42,720 [INFO] profit: 0.138720 EUR with volume: 5.000000 BTC -buy at 37.0000 (MtGoxEUR) sell at 37.0000 (BitcoinCentralEUR) ~0.07%
2013-03-18 20:47:15,361 [DEBUG] ticker: MtGoxEUR - {'ask': {'price': 36.97115, 'amount': 3.055}, 'bid': {'price': 36.95, 'amount': 7.68486008}}
2013-03-18 20:47:15,361 [DEBUG] ticker: BitcoinCentralEUR - {'ask': {'price': 37.05425, 'amount': 5.0}, 'bid': {'price': 37.00004, 'amount': 0.321795}}
2013-03-18 20:47:15,381 [INFO] profit: 0.138720 EUR with volume: 5.000000 BTC -buy at 37.0000 (MtGoxEUR) sell at 37.0000 (BitcoinCentralEUR) ~0.07%
2013-03-18 20:47:45,381 [DEBUG] ticker: MtGoxEUR - {'ask': {'price': 36.97115, 'amount': 3.055}, 'bid': {'price': 36.95, 'amount': 7.68486008}}
2013-03-18 20:47:45,381 [DEBUG] ticker: BitcoinCentralEUR - {'ask': {'price': 37.05425, 'amount': 5.0}, 'bid': {'price': 37.00004, 'amount': 0.321795}}
2013-03-18 20:47:45,401 [INFO] profit: 0.138720 EUR with volume: 5.000000 BTC -buy at 37.0000 (MtGoxEUR) sell at 37.0000 (BitcoinCentralEUR) ~0.07%
2013-03-18 20:48:17,581 [DEBUG] ticker: MtGoxEUR - {'ask': {'price': 36.97115, 'amount': 3.055}, 'bid': {'price': 36.95, 'amount': 7.58486008}}
2013-03-18 20:48:17,581 [DEBUG] ticker: BitcoinCentralEUR - {'ask': {'price': 37.05425, 'amount': 5.0}, 'bid': {'price': 37.00004, 'amount': 0.29454495}}
2013-03-18 20:48:17,601 [INFO] profit: 0.138719 EUR with volume: 5.000000 BTC -buy at 37.0000 (MtGoxEUR) sell at 37.0000 (BitcoinCentralEUR) ~0.07%
2013-03-18 20:48:47,601 [DEBUG] ticker: MtGoxEUR - {'ask': {'price': 36.97115, 'amount': 3.055}, 'bid': {'price': 36.95, 'amount': 7.58486008}}
2013-03-18 20:48:47,601 [DEBUG] ticker: BitcoinCentralEUR - {'ask': {'price': 37.05425, 'amount': 5.0}, 'bid': {'price': 37.00004, 'amount': 0.29454495}}
2013-03-18 20:48:47,621 [INFO] profit: 0.138719 EUR with volume: 5.000000 BTC -buy at 37.0000 (MtGoxEUR) sell at 37.0000 (BitcoinCentralEUR) ~0.07%
2013-03-18 20:49:19,020 [DEBUG] ticker: MtGoxEUR - {'ask': {'price': 36.97115, 'amount': 3.055}, 'bid': {'price': 36.95, 'amount': 7.58486008}}
2013-03-18 20:49:19,020 [DEBUG] ticker: BitcoinCentralEUR - {'ask': {'price': 37.05425, 'amount': 5.0}, 'bid': {'price': 37.00004, 'amount': 0.29454495}}
2013-03-18 20:49:19,040 [INFO] profit: 0.138719 EUR with volume: 5.000000 BTC -buy at 37.0000 (MtGoxEUR) sell at 37.0000 (BitcoinCentralEUR) ~0.07%
2013-03-18 20:49:49,051 [DEBUG] ticker: MtGoxEUR - {'ask': {'price': 36.97115, 'amount': 3.055}, 'bid': {'price': 36.95, 'amount': 7.58486008}}
2013-03-18 20:49:49,051 [DEBUG] ticker: BitcoinCentralEUR - {'ask': {'price': 37.05425, 'amount': 5.0}, 'bid': {'price': 37.00004, 'amount': 0.29454495}}
2013-03-18 20:49:49,061 [INFO] profit: 0.138719 EUR with volume: 5.000000 BTC -buy at 37.0000 (MtGoxEUR) sell at 37.0000 (BitcoinCentralEUR) ~0.07%
2013-03-18 20:50:20,631 [DEBUG] ticker: MtGoxEUR - {'ask': {'price': 36.974, 'amount': 2.0}, 'bid': {'price': 36.97115, 'amount': 15.8547}}
2013-03-18 20:50:20,631 [DEBUG] ticker: BitcoinCentralEUR - {'ask': {'price': 37.05425, 'amount': 5.0}, 'bid': {'price': 37.00004, 'amount': 0.29454495}}
2013-03-18 20:50:20,651 [INFO] profit: 0.126012 EUR with volume: 5.000000 BTC -buy at 37.0000 (MtGoxEUR) sell at 37.0000 (BitcoinCentralEUR) ~0.07%
2013-03-18 20:50:50,651 [DEBUG] ticker: MtGoxEUR - {'ask': {'price': 36.974, 'amount': 2.0}, 'bid': {'price': 36.97115, 'amount': 15.8547}}
2013-03-18 20:50:50,651 [DEBUG] ticker: BitcoinCentralEUR - {'ask': {'price': 37.05425, 'amount': 5.0}, 'bid': {'price': 37.00004, 'amount': 0.29454495}}
2013-03-18 20:50:50,671 [INFO] profit: 0.126012 EUR with volume: 5.000000 BTC -buy at 37.0000 (MtGoxEUR) sell at 37.0000 (BitcoinCentralEUR) ~0.07%
2013-03-18 20:51:22,151 [DEBUG] ticker: MtGoxEUR - {'ask': {'price': 36.974, 'amount': 2.0}, 'bid': {'price': 36.97115, 'amount': 15.8547}}
2013-03-18 20:51:22,151 [DEBUG] ticker: BitcoinCentralEUR - {'ask': {'price': 37.05425, 'amount': 5.0}, 'bid': {'price': 37.00004, 'amount': 0.29454495}}
2013-03-18 20:51:22,161 [INFO] profit: 0.126012 EUR with volume: 5.000000 BTC -buy at 37.0000 (MtGoxEUR) sell at 37.0000 (BitcoinCentralEUR) ~0.07%
2013-03-18 20:51:52,161 [DEBUG] ticker: MtGoxEUR - {'ask': {'price': 36.974, 'amount': 2.0}, 'bid': {'price': 36.97115, 'amount': 15.8547}}
2013-03-18 20:51:52,161 [DEBUG] ticker: BitcoinCentralEUR - {'ask': {'price': 37.05425, 'amount': 5.0}, 'bid': {'price': 37.00004, 'amount': 0.29454495}}
2013-03-18 20:51:52,171 [INFO] profit: 0.126012 EUR with volume: 5.000000 BTC -buy at 37.0000 (MtGoxEUR) sell at 37.0000 (BitcoinCentralEUR) ~0.07%
2013-03-18 20:52:23,512 [DEBUG] ticker: MtGoxEUR - {'ask': {'price': 36.974, 'amount': 2.0}, 'bid': {'price': 36.97115, 'amount': 15.8547}}
2013-03-18 20:52:23,512 [DEBUG] ticker: BitcoinCentralEUR - {'ask': {'price': 37.05425, 'amount': 5.0}, 'bid': {'price': 37.00004, 'amount': 0.29454495}}
2013-03-18 20:52:23,532 [INFO] profit: 0.126012 EUR with volume: 5.000000 BTC -buy at 37.0000 (MtGoxEUR) sell at 37.0000 (BitcoinCentralEUR) ~0.07%

        ███████████████████▄▄▄
        ████████████████████████▄▄
           ████████████████████████▄
    ▄▄▄▄▄▄▄██████████████████████████▄
    ███████████████       ▀▀███████████
        ███████               ██████████
        ███████                ██████████
████████   ████████             █████████
▀▀▀▀▀▀▀▀▄▄▄████████             █████████
        ███████████             █████████
    ████   ████████            ██████████
    ████   ████████           ██████████
        ███    ████       ▄▄███████████
    ▄▄▄▄███▄▄▄▄██████████████████████▀
    ███████████████████████████████▀
████    ████████████████████████▀▀
████    ███████████████████▀▀▀
DIMCOIN   
❱❱❱  facebook  ❱❱❱  twitter  ❱❱❱  Telegram  ❱❱❱
.The Future of Equity on The Blockchain.
DobZombie
Hero Member
*****
Offline Offline

Activity: 896
Merit: 532


Former curator of The Bitcoin Museum


View Profile
March 19, 2013, 11:42:09 AM
 #4

been getting this non stop all day

Code:
2013-03-19 21:19:57,178 [ERROR] HTTPError, can't update market: MtGoxUSD
2013-03-19 21:19:57,178 [WARNING] Market: MtGoxUSD order book is expired
2013-03-19 21:19:58,427 [ERROR] HTTPError, can't update market: MtGoxUSD
2013-03-19 21:19:58,428 [WARNING] Market: MtGoxUSD order book is expired

Tip Me if believe BTC1 will hit $1 Million by 2030
1DobZomBiE2gngvy6zDFKY5b76yvDbqRra
DobZombie
Hero Member
*****
Offline Offline

Activity: 896
Merit: 532


Former curator of The Bitcoin Museum


View Profile
March 19, 2013, 01:10:14 PM
 #5

oops, just realised.

"MtGox API url changed"

Redownloaded package from github and boom, back in business!

I wonder why they changed it?

Tip Me if believe BTC1 will hit $1 Million by 2030
1DobZomBiE2gngvy6zDFKY5b76yvDbqRra
maxme (OP)
Newbie
*
Offline Offline

Activity: 48
Merit: 0



View Profile WWW
March 19, 2013, 02:16:51 PM
 #6

I'm running this in test-mode atm. Is it supposed to do this?

Quote
2013-03-18 20:46:12,680 [DEBUG] ticker: MtGoxEUR - {'ask': {'price': 36.97115, 'amount': 3.055}, 'bid': {'price': 36.95, 'amount': 7.68486008}}
2013-03-18 20:46:12,680 [DEBUG] ticker: BitcoinCentralEUR - {'ask': {'price': 37.05425, 'amount': 5.0}, 'bid': {'price': 37.00004, 'amount': 0.321795}}
2013-03-18 20:46:12,700 [INFO] profit: 0.138720 EUR with volume: 5.000000 BTC -buy at 37.0000 (MtGoxEUR) sell at 37.0000 (BitcoinCentralEUR) ~0.07%

Yes, but the verbose mode, is too verbose Wink
maxme (OP)
Newbie
*
Offline Offline

Activity: 48
Merit: 0



View Profile WWW
March 19, 2013, 02:20:03 PM
 #7

If you'd like to add ICBIT support, I will be glad to help.

Do you have an HTTP API to get the market depth (order book) ?
Cyrus
Ninja
Administrator
Legendary
*
Offline Offline

Activity: 3990
Merit: 3212



View Profile
March 19, 2013, 02:46:13 PM
 #8

I actually found it on github first and now came here searching for the announcement thread.

Is the current version working?
I want to start testing today

And also... would like to see btc-e support soon! Great job Smiley.

Spaceman_Spiff
Legendary
*
Offline Offline

Activity: 1638
Merit: 1001


₪``Campaign Manager´´₪


View Profile
March 19, 2013, 09:07:44 PM
 #9

Hi guys,

I wanted to share my code. It's a bitcoin arbitrage watcher and automated trade software. Written in Python:

https://github.com/maxme/bitcoin-arbitrage

Feedback and pull-requests are welcome Wink

Aw man, you mean I spent my time building my own arbi-bot (probably a whole lot crappier than yours) for nothing?
Care to explain why you are giving this away for free?  By facilitating the effort required to start arbitraging, you are diminishing your own profits... (and mine  Smiley )
Fireball
Hero Member
*****
Offline Offline

Activity: 674
Merit: 500


View Profile WWW
March 19, 2013, 09:24:30 PM
 #10

Aw man, you mean I spent my time building my own arbi-bot (probably a whole lot crappier than yours) for nothing?
Care to explain why you are giving this away for free?  By facilitating the effort required to start arbitraging, you are diminishing your own profits... (and mine  Smiley )

Good arbitrage helps bitcoin economy and helps decentralize markets (e.g. helps other exchanges grow).

Margin trading platform OrderBook.net (ICBIT): https://orderbook.net
Follow us in Twitter: https://twitter.com/orderbooknet
whizter
Hero Member
*****
Offline Offline

Activity: 588
Merit: 500


View Profile
March 20, 2013, 08:33:22 AM
 #11

What exactly do I have to do to make it trade? It just does this all the time but no trades are happening, the same stuff as in my first post above. I'm using the newest version from github.

Quote
2013-03-20 08:27:17,214 [INFO] profit: 0.346785 EUR with volume: 3.428300 BTC - buy at 46.4201 (MtGoxEUR) sell at 46.5000 (BitcoinCentralEUR) ~0.22%
2013-03-20 08:27:47,570 [INFO] profit: 0.346785 EUR with volume: 3.428300 BTC - buy at 46.4201 (MtGoxEUR) sell at 46.5000 (BitcoinCentralEUR) ~0.22%
2013-03-20 08:28:19,206 [INFO] profit: 0.346785 EUR with volume: 3.428300 BTC - buy at 46.4201 (MtGoxEUR) sell at 46.5000 (BitcoinCentralEUR) ~0.22%

Of course I set my gox api keys and the bitcoincentral credentials. This is my conf:

Quote
markets = ["MtGoxEUR", "BitcoinCentralEUR"]
observers = ["Logger", "TraderBot", "HistoryDumper"]
market_expiration_time = 120 # in seconds: 2 minutes

...

        ███████████████████▄▄▄
        ████████████████████████▄▄
           ████████████████████████▄
    ▄▄▄▄▄▄▄██████████████████████████▄
    ███████████████       ▀▀███████████
        ███████               ██████████
        ███████                ██████████
████████   ████████             █████████
▀▀▀▀▀▀▀▀▄▄▄████████             █████████
        ███████████             █████████
    ████   ████████            ██████████
    ████   ████████           ██████████
        ███    ████       ▄▄███████████
    ▄▄▄▄███▄▄▄▄██████████████████████▀
    ███████████████████████████████▀
████    ████████████████████████▀▀
████    ███████████████████▀▀▀
DIMCOIN   
❱❱❱  facebook  ❱❱❱  twitter  ❱❱❱  Telegram  ❱❱❱
.The Future of Equity on The Blockchain.
maxme (OP)
Newbie
*
Offline Offline

Activity: 48
Merit: 0



View Profile WWW
March 20, 2013, 08:43:54 AM
 #12


Of course I set my gox api keys and the bitcoincentral credentials. This is my conf:

Quote
markets = ["MtGoxEUR", "BitcoinCentralEUR"]
observers = ["Logger", "TraderBot", "HistoryDumper"]
market_expiration_time = 120 # in seconds: 2 minutes

...

I think you're crazy to do that... Did you read the code first ? Are you sure that it will not just steal your coins ?

First, in TraderBot.py, you'll see some safeguards, for instance if the expected profit is lower than X and the expected profit percentage is lower than Y then it will not execute transactions. One of these safeguards should block current transaction.

But seriously, it's not a "packaged product", it's more a in-development project released for other developers. If you just run it like this, I guarantee you'll lose money.

If you really want to run it on real exchanges, then help me to write automated tests.
Khertan
Full Member
***
Offline Offline

Activity: 193
Merit: 100


View Profile WWW
March 20, 2013, 11:30:07 AM
 #13

Now i understand why you didn't put the perc_threshold and profit_threshold in the config file :p

maxme (OP)
Newbie
*
Offline Offline

Activity: 48
Merit: 0



View Profile WWW
March 20, 2013, 12:01:13 PM
 #14

Now i understand why you didn't put the perc_threshold and profit_threshold in the config file :p

Haha Wink

I would like people to write their own "TraderBot" class and not use the default. I should rename it to SampleTraderBot.
Khertan
Full Member
***
Offline Offline

Activity: 193
Merit: 100


View Profile WWW
March 20, 2013, 01:27:50 PM
 #15

Indeed but we can also write a good default one ... i'm a beginner in arbitrage domain ...

Khertan
Full Member
***
Offline Offline

Activity: 193
Merit: 100


View Profile WWW
March 20, 2013, 03:34:49 PM
 #16

There is something strange :

2013-03-20 16:31:32,985 [INFO] profit: 0.007277 EUR with volume: 0.010000 BTC - buy at 48.0000 (MtGoxEUR) sell at 48.0000 (BitcoinCentralEUR) ~1.52%

1.52 % with bought at 48 and sell at 48 ... due to rounding ?

maxme (OP)
Newbie
*
Offline Offline

Activity: 48
Merit: 0



View Profile WWW
March 20, 2013, 04:04:06 PM
 #17

Nope, it's not a rounding problem and it's not an issue.

The "buy price" given by the program is the maximum price you should buy BTC at.
The "sell price" given by the program is the minimum price you should sell BTC at.

Example with this order book:

Code:
books = {
    'MtGoxEUR':
    {'asks': [{'amount': 1, 'price': 47.0},
              {'amount': 2, 'price': 47.3},
              {'amount': 1, 'price': 48.0},
              {'amount': 3, 'price': 49.0}]},
    'BitcoinCentralEUR':
    {'bids': [{'amount': 1, 'price': 48.2},
              {'amount': 2, 'price': 48.1},
              {'amount': 1, 'price': 48.0},
              {'amount': 5, 'price': 47.9}]}}

Output will be :
Code:
volume: 3.0 BTC buy at 48.0 (MtGoxEUR) sell at 48.0 (BitcoinCentralEUR) 

Note: volume is 3.0 btc, not 4.0 btc (that includes 48.0 price)
DobZombie
Hero Member
*****
Offline Offline

Activity: 896
Merit: 532


Former curator of The Bitcoin Museum


View Profile
March 20, 2013, 06:12:43 PM
 #18

I don't intend this to be a dumb question but I fear it will be...

Does this bot require 2 exchanges for trading to happen? If yes is it possible to do trades with only 1?

Tip Me if believe BTC1 will hit $1 Million by 2030
1DobZomBiE2gngvy6zDFKY5b76yvDbqRra
maxme (OP)
Newbie
*
Offline Offline

Activity: 48
Merit: 0



View Profile WWW
March 20, 2013, 07:12:53 PM
 #19

Does this bot require 2 exchanges for trading to happen? If yes is it possible to do trades with only 1?

Yes it requires 2 exchanges. Arbitrage means "buy at X on a market and sell at X+y on another market at the same time".

http://en.wikipedia.org/wiki/Arbitrage
Sukrim
Legendary
*
Offline Offline

Activity: 2618
Merit: 1007


View Profile
March 20, 2013, 07:39:49 PM
 #20

Well, I could trade on MtGox in BTCUSD and BTCEUR if I know EURUSD (or assume EURUSD as static - compared to BTC that might even be true)...

If there's a plugin for other "real" Forex brokers that might even work quite well! Still it might be enough to do fiat trades in bulk after some time, as the volatility is quite different there. Hence it might be possible to trade two currency pairs on the same "market".

https://www.coinlend.org <-- automated lending at various exchanges.
https://www.bitfinex.com <-- Trade BTC for other currencies and vice versa.
Pages: [1] 2 3 »  All
  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!