Bitcoin Forum
September 21, 2019, 10:32:57 AM *
News: Latest Bitcoin Core release: 0.18.1 [Torrent]
 
   Home   Help Search Login Register More  
Pages: « 1 [2] 3 »  All
  Print  
Author Topic: Automated bitcoin arbitrage  (Read 18751 times)
DobZombie
Hero Member
*****
Offline Offline

Activity: 784
Merit: 501


Former curator of The Bitcoin Museum


View Profile
March 20, 2013, 11:54:46 PM
 #21

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

I told you it was a stupid question Smiley

Also, I'm getting this A LOT

Code:
Traceback (most recent call last):
  File "arbitrage.py", line 186, in <module>
    main()
  File "arbitrage.py", line 183, in main
    arbitrer.loop()
  File "arbitrage.py", line 157, in loop
    self.depths = self.update_depths()
  File "arbitrage.py", line 118, in update_depths
    depths[market.name] = market.get_depth()
  File "E:\botEUR\src\public_markets\market.py", line 20, in get_depth
    self.ask_update_depth()
  File "E:\botEUR\src\public_markets\market.py", line 31, in ask_update_depth
    except HTTPError:
NameError: global name 'HTTPError' is not defined

what am I doin wrong? Is it possible for this error to come up if the network is congested? Also, It takes about an hour or more for this to come up

Tip Me if you Hate Justin Bieber 1DobZomBiE2gngvy6zDFKY5b76yvDbqRra
1569061977
Hero Member
*
Offline Offline

Posts: 1569061977

View Profile Personal Message (Offline)

Ignore
1569061977
Reply with quote  #2

1569061977
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1569061977
Hero Member
*
Offline Offline

Posts: 1569061977

View Profile Personal Message (Offline)

Ignore
1569061977
Reply with quote  #2

1569061977
Report to moderator
1569061977
Hero Member
*
Offline Offline

Posts: 1569061977

View Profile Personal Message (Offline)

Ignore
1569061977
Reply with quote  #2

1569061977
Report to moderator
maxme
Newbie
*
Offline Offline

Activity: 48
Merit: 0



View Profile WWW
March 21, 2013, 07:14:36 AM
 #22

Also, I'm getting this A LOT

Code:
Traceback (most recent call last):
  File "arbitrage.py", line 186, in <module>
    main()
  File "arbitrage.py", line 183, in main
    arbitrer.loop()
  File "arbitrage.py", line 157, in loop
    self.depths = self.update_depths()
  File "arbitrage.py", line 118, in update_depths
    depths[market.name] = market.get_depth()
  File "E:\botEUR\src\public_markets\market.py", line 20, in get_depth
    self.ask_update_depth()
  File "E:\botEUR\src\public_markets\market.py", line 31, in ask_update_depth
    except HTTPError:
NameError: global name 'HTTPError' is not defined

what am I doin wrong? Is it possible for this error to come up if the network is congested? Also, It takes about an hour or more for this to come up

You're doing nothing, wrong. That was my bad, update the code. And yes it come from no-responding websites
Khertan
Full Member
***
Offline Offline

Activity: 193
Merit: 100


View Profile WWW
March 21, 2013, 10:56:18 AM
Last edit: March 21, 2013, 02:08:16 PM by Khertan
 #23

Thx for explanations, i understand it after reading a bit more the code.

Also i was thinking of withdraw btc between exchanges place.
Example : buy one btc from bitcoin-central, sell at mtgox, withdraw one btc from bitcoincentral to mtgox 1 btc.

Did you think that a bad idea ?

It ll be more interesting if we can also transfer fund in euros between market, but that s not possible from api.

w1R903
Full Member
***
Offline Offline

Activity: 218
Merit: 100


View Profile
March 22, 2013, 03:48:01 AM
 #24

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

No, it certainly doesn't require 2 exchanges.  There are thousands of people doing cross-currency arbitrage as we write this.  See: http://en.wikipedia.org/wiki/Triangular_arbitrage  This can be done in a single exchange.

And cross-currency arbitrage is getting quite popular in exchanges with several virtual and fiat currencies, like vircurex and btc-e.

A market is not synonymous with "an exchange".  Each exchange has multiple markets (usually): USD-BTC, EUR-BTC, LTC-BTC, etc.

4096R/F5EA0017
Fireball
Hero Member
*****
Offline Offline

Activity: 673
Merit: 500


View Profile WWW
March 22, 2013, 09:53:55 AM
 #25

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

No, it certainly doesn't require 2 exchanges.  There are thousands of people doing cross-currency arbitrage as we write this.  See: http://en.wikipedia.org/wiki/Triangular_arbitrage  This can be done in a single exchange.

And cross-currency arbitrage is getting quite popular in exchanges with several virtual and fiat currencies, like vircurex and btc-e.

A market is not synonymous with "an exchange".  Each exchange has multiple markets (usually): USD-BTC, EUR-BTC, LTC-BTC, etc.

And of course, spot/futures arbitrage

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

Activity: 784
Merit: 501


Former curator of The Bitcoin Museum


View Profile
March 25, 2013, 11:38:56 AM
 #26

okay, So I was getting this
Code:
Traceback (most recent call last):
  File "arbitrage.py", line 186, in <module>
    main()
  File "arbitrage.py", line 183, in main
    arbitrer.loop()
  File "arbitrage.py", line 159, in loop
    self.tick()
  File "arbitrage.py", line 150, in tick
    self.arbitrage_opportunity(kmarket1, market1["asks"][0], kmarket2, market2["bids"][0])
  File "arbitrage.py", line 113, in arbitrage_opportunity
    perc2, weighted_buyprice, weighted_sellprice)
  File "E:\BotEUR\src\observers\traderbot.py", line 63, in opportunity
    if volume < config.min_tx_volume:
AttributeError: 'module' object has no attribute 'min_tx_volume'

So I added this to the config.py
Code:
min_tx_volume = 0  # in BTC

But now it does this
Code:
2013-03-25 21:36:54,994 [DEBUG] ticker: MtGoxEUR - {'ask': {'price': 56.29, 'amount': 10.0}, 'bid': {'price': 56.09712, 'amount': 0.16727}}
2013-03-25 21:36:54,996 [DEBUG] ticker: BitcoinCentralEUR - {'ask': {'price': 59.255, 'amount': 10.0}, 'bid': {'price': 57.70004, 'amount': 1.21748}}
2013-03-25 21:37:08,430 [WARNING] Can't automate this trade, last trade occured 116.200000048 seconds ago
2013-03-25 21:37:40,948 [DEBUG] ticker: MtGoxEUR - {'ask': {'price': 56.29, 'amount': 10.0}, 'bid': {'price': 56.09712, 'amount': 0.16727}}
2013-03-25 21:37:40,950 [DEBUG] ticker: BitcoinCentralEUR - {'ask': {'price': 59.255, 'amount': 10.0}, 'bid': {'price': 57.70004, 'amount': 1.21748}}
None
2013-03-25 21:38:28,839 [DEBUG] ticker: MtGoxEUR - {'ask': {'price': 56.29, 'amount': 10.0}, 'bid': {'price': 56.09712, 'amount': 0.16727}}
2013-03-25 21:38:28,841 [DEBUG] ticker: BitcoinCentralEUR - {'ask': {'price': 59.255, 'amount': 10.0}, 'bid': {'price': 57.70004, 'amount': 1.21748}}
2013-03-25 21:38:36,418 [WARNING] Can't automate this trade, last trade occured 44.8589999676 seconds ago
2013-03-25 21:39:08,789 [DEBUG] ticker: MtGoxEUR - {'ask': {'price': 56.29, 'amount': 10.0}, 'bid': {'price': 56.09712, 'amount': 0.16727}}
2013-03-25 21:39:08,790 [DEBUG] ticker: BitcoinCentralEUR - {'ask': {'price': 59.255, 'amount': 10.0}, 'bid': {'price': 57.70004, 'amount': 1.21748}}
2013-03-25 21:39:16,447 [WARNING] Can't automate this trade, last trade occured 84.8870000839 seconds ago

I make for a good beta tester Tongue

Tip Me if you Hate Justin Bieber 1DobZomBiE2gngvy6zDFKY5b76yvDbqRra
Khertan
Full Member
***
Offline Offline

Activity: 193
Merit: 100


View Profile WWW
March 25, 2013, 10:27:51 PM
 #27

Just to be sure, you use the TraderBotSim or you are ready to lose money and btc ?

Wink

DobZombie
Hero Member
*****
Offline Offline

Activity: 784
Merit: 501


Former curator of The Bitcoin Museum


View Profile
March 26, 2013, 02:39:08 PM
Last edit: March 26, 2013, 03:47:51 PM by DobZombie
 #28

I tried the traderbotsim in an older build and it didn't work.  But I works for me in the recent revision.

I've tried using the traderbot and all I get it this

Code:
2013-03-27 00:34:53,190 [DEBUG] ticker: MtGoxEUR - {'ask': {'price': 62.47, 'amount': 4.0}, 'bid': {'price': 61.9, 'amount': 32.50906816}}
2013-03-27 00:34:53,190 [DEBUG] ticker: BitcoinCentralEUR - {'ask': {'price': 64.92, 'amount': 49.16}, 'bid': {'price': 64.41004, 'amount': 1.279645}}
None
2013-03-27 00:35:37,321 [DEBUG] ticker: MtGoxEUR - {'ask': {'price': 62.47, 'amount': 4.0}, 'bid': {'price': 61.9, 'amount': 32.50906816}}
2013-03-27 00:35:37,321 [DEBUG] ticker: BitcoinCentralEUR - {'ask': {'price': 64.9, 'amount': 5.0}, 'bid': {'price': 64.41004, 'amount': 1.279645}}
2013-03-27 00:35:44,546 [WARNING] Can't automate this trade, last trade occured 43.9949998856 seconds ago
2013-03-27 00:36:17,240 [DEBUG] ticker: MtGoxEUR - {'ask': {'price': 62.47, 'amount': 4.0}, 'bid': {'price': 61.9, 'amount': 32.50906816}}
2013-03-27 00:36:17,242 [DEBUG] ticker: BitcoinCentralEUR - {'ask': {'price': 64.9, 'amount': 5.0}, 'bid': {'price': 64.41004, 'amount': 1.279645}}
2013-03-27 00:36:26,641 [WARNING] Can't automate this trade, last trade occured 86.0899999142 seconds ago
2013-03-27 00:37:00,523 [DEBUG] ticker: MtGoxEUR - {'ask': {'price': 62.485, 'amount': 4.0}, 'bid': {'price': 61.9, 'amount': 41.07126816}}
2013-03-27 00:37:00,525 [DEBUG] ticker: BitcoinCentralEUR - {'ask': {'price': 64.9, 'amount': 1.329572}, 'bid': {'price': 64.41004, 'amount': 1.279645}}
None
Whats going on?

Also, I'm okay losing money.  If this works out it could mean profit!!

I'd definitely owe ya Smiley

Tip Me if you Hate Justin Bieber 1DobZomBiE2gngvy6zDFKY5b76yvDbqRra
maxme
Newbie
*
Offline Offline

Activity: 48
Merit: 0



View Profile WWW
March 26, 2013, 06:00:46 PM
 #29


I tried the traderbotsim in an older build and it didn't work.  But I works for me in the recent revision.

I've tried using the traderbot and all I get it this

Code:
2013-03-27 00:34:53,190 [DEBUG] ticker: MtGoxEUR - {'ask': {'price': 62.47, 'amount': 4.0}, 'bid': {'price': 61.9, 'amount': 32.50906816}}
2013-03-27 00:34:53,190 [DEBUG] ticker: BitcoinCentralEUR - {'ask': {'price': 64.92, 'amount': 49.16}, 'bid': {'price': 64.41004, 'amount': 1.279645}}
None
2013-03-27 00:35:37,321 [DEBUG] ticker: MtGoxEUR - {'ask': {'price': 62.47, 'amount': 4.0}, 'bid': {'price': 61.9, 'amount': 32.50906816}}
2013-03-27 00:35:37,321 [DEBUG] ticker: BitcoinCentralEUR - {'ask': {'price': 64.9, 'amount': 5.0}, 'bid': {'price': 64.41004, 'amount': 1.279645}}
2013-03-27 00:35:44,546 [WARNING] Can't automate this trade, last trade occured 43.9949998856 seconds ago
2013-03-27 00:36:17,240 [DEBUG] ticker: MtGoxEUR - {'ask': {'price': 62.47, 'amount': 4.0}, 'bid': {'price': 61.9, 'amount': 32.50906816}}
2013-03-27 00:36:17,242 [DEBUG] ticker: BitcoinCentralEUR - {'ask': {'price': 64.9, 'amount': 5.0}, 'bid': {'price': 64.41004, 'amount': 1.279645}}
2013-03-27 00:36:26,641 [WARNING] Can't automate this trade, last trade occured 86.0899999142 seconds ago
2013-03-27 00:37:00,523 [DEBUG] ticker: MtGoxEUR - {'ask': {'price': 62.485, 'amount': 4.0}, 'bid': {'price': 61.9, 'amount': 41.07126816}}
2013-03-27 00:37:00,525 [DEBUG] ticker: BitcoinCentralEUR - {'ask': {'price': 64.9, 'amount': 1.329572}, 'bid': {'price': 64.41004, 'amount': 1.279645}}
None
Whats going on?

Also, I'm okay losing money.  If this works out it could mean profit!!

I'd definitely owe ya Smiley


It seems you made your first automated transaction.

Code:
2013-03-27 00:35:44,546 [WARNING] Can't automate this trade, last trade occured 43.9949998856 seconds ago

The line above is a safeguard, it waits for TraderBot.trade_wait before executing the next trade (this will be removed when websocket order book sync is implemented)
DobZombie
Hero Member
*****
Offline Offline

Activity: 784
Merit: 501


Former curator of The Bitcoin Museum


View Profile
March 26, 2013, 06:10:51 PM
 #30

I'm using the SpecializedTradingBot and it's outputting this...

Code:
2013-03-27 04:01:19,473 [INFO][b] profit: 2.354073 EUR with volume: 1.000000 BTC - buy at 62.7999 (MtGoxEUR) sell at 62.8000 (BitcoinCentralEUR) ~3.75%[/b]
2013-03-27 04:01:52,920 [DEBUG] ticker: MtGoxEUR - {'ask': {'price': 61.0, 'amount': 10.0}, 'bid': {'price': 60.5, 'amount': 6.0}}
2013-03-27 04:01:52,921 [DEBUG] ticker: BitcoinCentralEUR - {'ask': {'price': 64.0, 'amount': 0.35183044}, 'bid': {'price': 63.0, 'amount': 0.27}}
2013-03-27 04:01:52,982 [WARNING] Can't automate this trade, profit=2.952351 is lower than defined threshold 3.500000
2013-03-27 04:01:52,982 [INFO][b] profit: 1.854073 EUR with volume: 1.000000 BTC - buy at 62.7999 (MtGoxEUR) sell at 62.8000 (BitcoinCentralEUR) ~2.95%[/b]
2013-03-27 04:02:22,983 [DEBUG] ticker: MtGoxEUR - {'ask': {'price': 61.0, 'amount': 10.0}, 'bid': {'price': 60.5, 'amount': 6.0}}
2013-03-27 04:02:22,983 [DEBUG] ticker: BitcoinCentralEUR - {'ask': {'price': 64.0, 'amount': 0.35183044}, 'bid': {'price': 63.0, 'amount': 0.27}}
2013-03-27 04:02:23,036 [WARNING] Can't automate this trade, profit=2.952351 is lower than defined threshold 3.500000

What confuses me is ...
profit:
2.354073 EUR with volume:
1.000000 BTC -
buy at 62.7999 (MtGoxEUR)
sell at 62.8000 (BitcoinCentralEUR)
~3.75%

Some of those numbers don't add up.  Am I missing something?

Tip Me if you Hate Justin Bieber 1DobZomBiE2gngvy6zDFKY5b76yvDbqRra
maxme
Newbie
*
Offline Offline

Activity: 48
Merit: 0



View Profile WWW
March 26, 2013, 06:37:19 PM
 #31

I'm using the SpecializedTradingBot and it's outputting this...

What confuses me is ...
profit:
2.354073 EUR with volume:
1.000000 BTC -
buy at 62.7999 (MtGoxEUR)
sell at 62.8000 (BitcoinCentralEUR)
~3.75%

Some of those numbers don't add up.  Am I missing something?

See my previous message here https://bitcointalk.org/index.php?topic=153661.msg1647793#msg1647793

But I should change logging messages...
arsenische
Legendary
*
Offline Offline

Activity: 1178
Merit: 1010


View Profile
March 26, 2013, 08:19:11 PM
 #32

DobZombie, great work!

But why did you share the code? I think more competitors => less arbitraging possibilities. Or am I wrong?

Sukrim
Legendary
*
Offline Offline

Activity: 2506
Merit: 1002


View Profile
March 26, 2013, 08:36:52 PM
 #33

More arbitrage --> more volume for trading bots!
Also the "algorithm" behind arbitrage bots is not really a secret at all, it might be better to get people to code up plugins for various APIs than to keep it a guarded secret. Also moving big amounts of money between exchanges is not trivial and not cheap too...

Thanks for actually open sourcing and releasing a useful and potentially profitable bot. Smiley

https://www.coinlend.org <-- automated lending at various exchanges. No fees(!).
Mail me at Bitmessage: BM-BbiHiVv5qh858ULsyRDtpRrG9WjXN3xf
DobZombie
Hero Member
*****
Offline Offline

Activity: 784
Merit: 501


Former curator of The Bitcoin Museum


View Profile
March 27, 2013, 01:48:49 PM
 #34

DobZombie, great work!

But why did you share the code? I think more competitors => less arbitraging possibilities. Or am I wrong?

lol, I'm not sharing any code!  I'm just testing it  Tongue

maxme is the genius behind this code Smiley

Tip Me if you Hate Justin Bieber 1DobZomBiE2gngvy6zDFKY5b76yvDbqRra
NF414
Newbie
*
Offline Offline

Activity: 28
Merit: 0



View Profile
March 30, 2013, 12:49:44 PM
 #35

Thanks for sharing!

Anyone had any real-life profit from this automation yet?

Regards, NF414
maxme
Newbie
*
Offline Offline

Activity: 48
Merit: 0



View Profile WWW
March 30, 2013, 12:52:58 PM
 #36

Yes I made some profits. But I had to stop the bot since some markets are sometimes not responding or replying with erroneous data. So I'm currently working at checking exchanges status/responsiveness and verifying trades.

And I need to write more automated tests for this part (like mocking erroneous response, ...)
NF414
Newbie
*
Offline Offline

Activity: 28
Merit: 0



View Profile
March 30, 2013, 01:05:34 PM
 #37

Yes I made some profits. But I had to stop the bot since some markets are sometimes not responding or replying with erroneous data. So I'm currently working at checking exchanges status/responsiveness and verifying trades.

And I need to write more automated tests for this part (like mocking erroneous response, ...)

If you need help of any kind (not a programmer); please feel free to ask.

Regards, NF414
hiima
Member
**
Offline Offline

Activity: 112
Merit: 10


View Profile
April 02, 2013, 02:32:40 AM
 #38

Can this be used to arbitrage on the same exchange, ie mtgox USD/BTC-> BTC/EUR->EUR/USD?

Whiskey Fund BTC 1K2SG4amzNrB7gUwf5braHuExqnQ5nEKZp LTC Lgoz9gb7q39FMAmBz8odfkx4YFhLeofCpc
Caesar V
Sr. Member
****
Offline Offline

Activity: 368
Merit: 250



View Profile
April 13, 2013, 03:54:00 AM
 #39

Oh man, this is one of those times I wish I was more tech savy  Cry
DobZombie
Hero Member
*****
Offline Offline

Activity: 784
Merit: 501


Former curator of The Bitcoin Museum


View Profile
April 13, 2013, 02:08:06 PM
Last edit: April 14, 2013, 01:58:24 PM by DobZombie
 #40

When there is a potential trade I keep getting this...

Code:
2013-04-13 01:09:02,568 [DEBUG] ticker: BitcoinCentralEUR - {'ask': {'amount': 0.133669, 'price': 58.0}, 'bid': {'amount': 110.72, 'price': 57.0}}
2013-04-13 01:09:02,570 [DEBUG] ticker: MtGoxEUR - {'ask': {'amount': 0.697, 'price': 54.44384}, 'bid': {'amount': 18.8041, 'price': 53.18}}
2013-04-13 01:09:02,600 [INFO] profit: 11.798033 EUR with volume: 5.000000 BTC - buy at 56.9956 (MtGoxEUR) sell at 57.0000 (BitcoinCentralEUR) ~4.14%
Traceback (most recent call last):
  File "arbitrage.py", line 202, in <module>
    main()
  File "arbitrage.py", line 199, in main
    arbitrer.loop()
  File "arbitrage.py", line 172, in loop
    self.tick()
  File "arbitrage.py", line 163, in tick
    "asks"][0], kmarket2, market2["bids"][0])
  File "arbitrage.py", line 123, in arbitrage_opportunity
    perc2, weighted_buyprice, weighted_sellprice)
  File "E:\Bot\src\observers\traderbot.py", line 63, in opportunity
    self.clients[kbid].btc_balance)
AttributeError: 'PrivateBitcoinCentral' object has no attribute 'btc_balance'

EDIT : Nevermind, I downloaded the latest Commit and it's all good Smiley

Tip Me if you Hate Justin Bieber 1DobZomBiE2gngvy6zDFKY5b76yvDbqRra
Pages: « 1 [2] 3 »  All
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!