Bitcoin Forum
May 22, 2024, 12:37:19 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1] 2 3 4 5 6 7 8 »  All
  Print  
Author Topic: Bitcoin arbitrage on GitHub: ~2% monthly return, market-neutral long/short  (Read 38227 times)
butor (OP)
Newbie
*
Offline Offline

Activity: 49
Merit: 0


View Profile WWW
March 11, 2015, 05:43:58 PM
Last edit: February 05, 2016, 04:22:43 AM by butor
 #1

Hi guys,

I just released the C++ code of my Bitcoin exchange arbitrage system that generates a ~2% monthly return with a USD 2,000 exposure.

I think you guys might be interested in seeing how arbitrage can work with Bitcoin exchanges.

The full code is on the following GitHub page: https://github.com/butor/blackbird. I tried to write a pretty complete Readme file that explains the arbitrage mechanism.

It is also a good way to see how you can connect a C++ system to two Bitcoin exchanges (Bitfinex and OKCoin) using JSON and base64 encoding.

Please let me know what you think. I will try to find C++ contributors that will be able to improve the code and connect to new exchanges.

I hope it can help you understand and actually test how arbitrage between Bitcoin exchanges works.

Here is a quick real life example where arbitrage can occur because of market inefficiency between Bitfinex and Bitstamp in November 2014 (between the two vertical gray lines):

DeboraMeeks
Hero Member
*****
Offline Offline

Activity: 588
Merit: 500


View Profile
March 11, 2015, 05:47:03 PM
 #2

Don't know much about C++ language, but all I can say is, I might try this out with a few bucks.
You said 2% return with USD 2k exposure, so can't I try this out with some less amounts just to check out, only want to make a check with some play money (I mean what I can afford to lose). Wink
Amph
Legendary
*
Offline Offline

Activity: 3206
Merit: 1069



View Profile
March 11, 2015, 06:15:43 PM
 #3

with other exchanges, the 2% can be raised or this is the best the bot can do?
butor (OP)
Newbie
*
Offline Offline

Activity: 49
Merit: 0


View Profile WWW
March 11, 2015, 06:36:34 PM
 #4

For the moment the system can only connect to Bitfinex and OKCoin. The project is really work in progress but I think it's a good practical example to understand how arbitrage works. I'm currently looking for C++ developers to help me out with the project.

I will also improve the documentation on how to test it "out of the box". Currently to use it you need to understand and edit a little bit the source code (work in progress I told you Wink )

If you do want to test it, yes please try with a low amount of cash. I did all my testing with a $10.00 exposure. So please only put a low amount of money on your Bitfinex and OKCoin trading accounts. My monthly returns are surprisingly constant: between 1.7% and 2.3%. Of course I cannot guarantee these returns under any circumstances. My average activity so far is 8 trades per month with the system running 24/7.

I'm pretty confident the system would be able to generate better returns with new exchange connections, specially to Bitcoin exchanges that allow short selling. The system is able to test all the possible long/short combinations for a given set of exchanges. So more exchanges really means more arbitrage opportunities.
butor (OP)
Newbie
*
Offline Offline

Activity: 49
Merit: 0


View Profile WWW
March 12, 2015, 02:28:47 PM
 #5

Indeed. That's what I'm looking for, specially with exchanges that offer short selling. As I said earlier the software tests all the possible long/short combinations between the given exchanges.

The current situation is this one, with an exchange A (Bitfinex) that offers short selling and an exchange B (OKCoin) that doesn't offer short selling:
  • A short selling OK
  • B short selling NOK

In this case we only have one combination to test:
  • short A / long B

Now let's add a new exchange C that doesn't allow short selling. We now have:
  • A short selling OK
  • B short selling NOK
  • C short selling NOK

And the software will automatically test the two following combinations:
  • short A / long B
  • short A / long C

But now let's suppose C actually offers short selling:
  • A short selling OK
  • B short selling NOK
  • C short selling OK

In this case we will automatically test four combinations:
  • short A / long B
  • short A / long C
  • short C / long A
  • short C / long B


However, the selected Bitcoin exchanges have to offer good liquidity to make sure our orders will be executed quickly. I'm currently working on a mechanism that will adapt the limit orders sent based on the real-time bid/ask offers.

If you guys know a C++ developer that would be interested in participating in a nice arbitrage project then 100% of the code is on the GitHub page (https://github.com/butor/blackbird).

joesmoe2012
Hero Member
*****
Offline Offline

Activity: 882
Merit: 501


Ching-Chang;Ding-Dong


View Profile WWW
March 12, 2015, 02:56:14 PM
 #6

Added it to my list of trading robots - http://easybitinvesting.com/bitcoin-trading/trading-robots/

Check out BitcoinATMTalk - https://bitcoinatmtalk.com
butor (OP)
Newbie
*
Offline Offline

Activity: 49
Merit: 0


View Profile WWW
March 12, 2015, 03:26:35 PM
Last edit: March 12, 2015, 07:32:07 PM by butor
 #7

I do not know a C++ coder but Im looking to hire a meteor eveloper to make an arbitrage trading tool developer for bitcoinpricelab[dot].com
Check out that website, I have a simple overview of markets. Im looking to get a much advanced version which helps traders

Thank you for the link. I noticed that you do your arbitrage by buying bitcoin on an exchange and selling bitcoin on another exchange. You don't use short selling and this is a fondamental difference: on my side my system is completely market-neutral. This means that it's not impacted by the Bitcoin price fluctuation at all. And this is a huge advantage.

Here is how it works, current Bitcoin quotes in blue:

OKCoin BTC@$300.00
Bitfinex BTC@$300.00
No opportunity, system 100% cash, no market risk:
  • On OKCoin: 1000.00 USD, 0.0000 BTC
  • On Bitfinex: 1000.00 USD, 0.0000 BTC

OKCoin BTC@$290.00
Bitfinex BTC@$310.00
Opportunity ($20.00 spread): system 0% cash, but still no market risk since long/short
  • On OKCoin: 0.00 USD, 3.4483 BTC (buy for $1000.00)
  • On Bitfinex: 0.00 USD, -3.2258 BTC (short sell with $1000.00)

Now the Bitcoin market plummets. The $20.00 spread is still here.

OKCoin BTC@$180.00
Bitfinex BTC@$200.00
There is still a spread. No action taken
  • On OKCoin: 0.00 USD, 3.4483 BTC (long)
  • On Bitfinex: 0.00 USD, -3.2258 BTC (short)

Now the spread closes:

OKCoin BTC@$200.00
Bitfinex BTC@$200.00
Exit opportunity: we close the long and short positions and we get:
  • On OKCoin: 689.66 USD, 0.0000 BTC
  • On Bitfinex: 1354.84 USD, 0.0000 BTC

Before the opportunity we had $2000.00 in cash and now we have $2044.50. So even thought during the trade the market lost 33%, we made a 2.2% profit (trading fees not considered). As you can see being market-neutral is a huge advantage when the market is bearish.
tomii
Newbie
*
Offline Offline

Activity: 19
Merit: 0


View Profile
March 12, 2015, 09:25:34 PM
Last edit: March 12, 2015, 09:42:16 PM by tomii
 #8

hello! sounds really nice i like it! i wanna test it but im not that confident with programmin
i have a debian Server, but never compiled somethin myself
do i have to config in source code? if yes where?
and which libarys are needed to make?



e: ok i got it... not that hard..  but adding other exchanges i would need help Smiley
funtotry
Sr. Member
****
Offline Offline

Activity: 420
Merit: 250


Ever wanted to run your own casino? PM me for info


View Profile
March 12, 2015, 09:31:15 PM
 #9

Interesting script but how would the funds be transferred between exchanges? Your script can't possibly automated bitcoin transactions and send it, including checking for deposit addresses and that. How does that work?

Jamacn
Full Member
***
Offline Offline

Activity: 236
Merit: 100



View Profile
March 13, 2015, 01:51:56 AM
 #10

only 2 exchanges, if is it can be kade best profits?
butor (OP)
Newbie
*
Offline Offline

Activity: 49
Merit: 0


View Profile WWW
March 13, 2015, 02:12:57 AM
 #11

hello! sounds really nice i like it! i wanna test it but im not that confident with programmin
i have a debian Server, but never compiled somethin myself
do i have to config in source code? if yes where?
and which libarys are needed to make?

Yes the project is not very user-friendly for the moment and I apologize for that. But please read the section How to test Blackbird to see how you can compile it. Once you succeed to start it everything else will be automatic.

Good luck
butor (OP)
Newbie
*
Offline Offline

Activity: 49
Merit: 0


View Profile WWW
March 13, 2015, 02:45:49 AM
Last edit: March 13, 2015, 03:09:09 AM by butor
 #12

Interesting script but how would the funds be transferred between exchanges? Your script can't possibly automated bitcoin transactions and send it, including checking for deposit addresses and that. How does that work?

That's the best part! Wink There is absolutely no transfer between the exchanges. Please read the example I gave earlier with the $20 spread. You will see that there is no transfer in cash or in Bitcoin between the exchanges at any time. I hope my example is clear enough to understand the arbitrage mechanism.


That being said, a cash rebalancing might need to be done when two specific conditions are met:
  • the market is either only bullish (up) or only bearish (down), and
  • the arbitrage opportunity is always the same over and over (e.g. short Bitfinex / long OKCoin)

In this case we can have after a while a situation where the available cash is not well balanced, e.g:
  • On OKCoin: 436.11 USD, 0.0000 BTC
  • On Bitfinex: 1829.08 USD, 0.0000 BTC

The above example can occur when the market is bearish and we are always long on OKCoin (so we systematically lose money because of the bear market) and short on Bitfinex (so we systematically make money because of the bear market).

Note that in this example the system will enter the next arbitrage opportunity with the lowest amount of cash: $436.11. So the total exposure for that new trade will be only 2 * $436.11 = $872.22 even though the total amount of available cash is $436.11 + $1829.08 = $2265.19.
Therefore it would be a good idea to rebalance the cash between the exchanges to have:
  • On OKCoin: 1132.59 USD, 0.0000 BTC
  • On Bitfinex: 1132.60 USD, 0.0000 BTC

Gebbit
Newbie
*
Offline Offline

Activity: 56
Merit: 0


View Profile WWW
March 13, 2015, 12:26:36 PM
 #13

Is that 2% on the fiat or BTC side? If Bitcoin doesn't die it seems hard to believe that bitcoin returns from HLODing won't exceed the returns of this program. The arbitrage would have to make returns on the current bitcoin price and exceed the fact that the funds are not always in BTC. Finally, it would have to account for situations where users get goxxed.

It's hard to believe that this isn't a waste of time and a losing proposition when compared to simply HLODing.

Please explain to me where my logic falters.
butor (OP)
Newbie
*
Offline Offline

Activity: 49
Merit: 0


View Profile WWW
March 13, 2015, 03:15:19 PM
Last edit: March 13, 2015, 04:41:38 PM by butor
 #14

Is that 2% on the fiat or BTC side? If Bitcoin doesn't die it seems hard to believe that bitcoin returns from HLODing won't exceed the returns of this program. The arbitrage would have to make returns on the current bitcoin price and exceed the fact that the funds are not always in BTC. Finally, it would have to account for situations where users get goxxed.

It's hard to believe that this isn't a waste of time and a losing proposition when compared to simply HLODing.

Please explain to me where my logic falters.

The profit is always on the fiat side. See the simple example I wrote earlier.

As I said, the biggest advantage of arbitrage is the independence of the market direction. The goal is to generate a constant profit regardless of the market direction. So yes you will miss opportunities from a bull market but your investment will be safe during a bear market. It's a choice.

The largest risk is if the spread between two exchanges never closes for some reasons or if an exchange goes bankrupt like Mt. Gox.

If you are interested, here is a good Wall Street example where the spreads didn't close as expected during arbitrage investments:
Long-Term Capital Management L.P.
area
Full Member
***
Offline Offline

Activity: 177
Merit: 100


View Profile
March 14, 2015, 05:35:18 PM
 #15

I suppose the obvious question to ask here is why make it public, if it's making you money?
butor (OP)
Newbie
*
Offline Offline

Activity: 49
Merit: 0


View Profile WWW
March 14, 2015, 08:10:25 PM
 #16

I suppose the obvious question to ask here is why make it public, if it's making you money?

For the moment I get a 2% monthly profit for a USD 2,000 exposure. It means that I make about USD 40 per month... Nothing too crazy and I don't know how long it will last.

If I want to invest more money I will need to develop a mechanism to check that there is enough liquidity for my limit orders to be executed before they are sent. I am working on a mechanism that reads the order books of the two involved exchanges. If and only if there is enough liquidity on both exchanges then the trades are generated.

But more that than I like the challenge of building automatic systems. I like to see my system live, sending orders automatically. But I want to improve it (new exchange connections, order books analysis, failover, etc) and I'm not a professional C++ developer. My goal is to find C++ guys that would be interested in contributing. Also, the system is pretty fast and securely connected to Bitcoin exchanges using C++ libraries and in the future I hope to make it a good example for the open source community (not really the case right now...  Tongue).
Gebbit
Newbie
*
Offline Offline

Activity: 56
Merit: 0


View Profile WWW
March 16, 2015, 03:37:43 PM
 #17

Is that 2% on the fiat or BTC side? If Bitcoin doesn't die it seems hard to believe that bitcoin returns from HLODing won't exceed the returns of this program. The arbitrage would have to make returns on the current bitcoin price and exceed the fact that the funds are not always in BTC. Finally, it would have to account for situations where users get goxxed.

It's hard to believe that this isn't a waste of time and a losing proposition when compared to simply HLODing.

Please explain to me where my logic falters.

The profit is always on the fiat side. See the simple example I wrote earlier.

As I said, the biggest advantage of arbitrage is the independence of the market direction. The goal is to generate a constant profit regardless of the market direction. So yes you will miss opportunities from a bull market but your investment will be safe during a bear market. It's a choice.

The largest risk is if the spread between two exchanges never closes for some reasons or if an exchange goes bankrupt like Mt. Gox.

If you are interested, here is a good Wall Street example where the spreads didn't close as expected during arbitrage investments:
Long-Term Capital Management L.P.


In that case the yearly return is less than 30% and judging by what happened to bitcoin platforms in previous years it has been a negative return. That is because the risk of default from these places was far greater than the 30% return. And have not most major currencies inflated greatly the past year? It seems a lot of extra work and risk to slightly beat out the most transparent stocks in Western countries.
siameze
Legendary
*
Offline Offline

Activity: 1064
Merit: 1000



View Profile
March 16, 2015, 03:59:51 PM
 #18

Added it to my list of trading robots - http://easybitinvesting.com/bitcoin-trading/trading-robots/



I had never seen this list before, thanks for sharing. I bookmarked the page for future reference.


                     ▀▀█████████▀████████████████▄
                        ████▄      ▄████████████████
                     ▄██████▀  ▄  ███████████████████
                  ▄█████████▄████▄███████████████████
                ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀████████
                                               ▀▀███▀
    ▄█▀█       ▄▀  ▄▀▀█  ▄▀   █████████████████▄ ██▀         ▄▀█
   ▄█ ▄▀      ▀█▀ █▀ █▀ ▀█▀  ███████████████████ █▀ ▀▀      ▄▀▄▀
  ▄█    ▄███  █     █   █   ████████████████████  ▄█     ▄▀▀██▀ ▄███
███▄▄▄  █▄▄▄ █▄▄ ▄▄▀   █▄▄ ██████████████████▀▀   █▄▄ ▄▄ █▄▄█▄▄▄█▄▄▄
                           ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
                            ▀▀█████████████▄
                                █████████████▄
                                  █████████████▄
                                    ▀███████▀▀▀▀▀
                                      ▀████▀
                                        ▀█▀
LetItRideINNOVATIVE ▬▬▬
DICE GAME
                        ▄███████████▄
                       ██  ██████████▄
                     ▄█████████████  ██▄
            ▄▄▀█▄▄▄▄▄████████████████████▄
        ▄▄█▀   ███████████  █████  ████  █
    ▄██████ ▄▄███████████████████████████▀
 ▄▀▀ ██████████████████████████  ████  █
█  ▄███████████▀▀▀█████████████████████
██████████████    ████████▀▀██████  █▀
██████████████▄▄▄██████████   ▀▀▀▀▀▀▀
███▀ ▀██████████████████████
██    ███████████████████████
██▄▄██████████████████████████
██████████████▀   ██████████
  █████████████   ▄██████▀▀
     ▀▀██████████████▀▀
         ▀▀██████▀▀
PROVABLY
F A I R
▄█████████████▀ ▄█
██            ▄█▀
██          ▄██ ▄█
██ ▄█▄    ▄███  ██
██ ▀███▄ ▄███   ██
██  ▀███████    ██
██    █████     ██
██     ███      ██
██      ▀       ██
██              ██
▀████████████████▀
BUY  BACK
PLANS
[BTC]
butor (OP)
Newbie
*
Offline Offline

Activity: 49
Merit: 0


View Profile WWW
March 16, 2015, 10:01:29 PM
 #19

In that case the yearly return is less than 30% and judging by what happened to bitcoin platforms in previous years it has been a negative return. That is because the risk of default from these places was far greater than the 30% return. And have not most major currencies inflated greatly the past year? It seems a lot of extra work and risk to slightly beat out the most transparent stocks in Western countries.

Are you saying that, according to you, more than 30% of the current Bitcoin exchanges will go bankrupt within one year from now? Did that happen in the past? Note that I'm only considering the large exchanges that offer enough liquidity to do short-term trading.

Even if it's true, the impact of that default risk is pretty much the same whether you are on an arbitrage strategy or a buy and hold strategy.

hgerson
Full Member
***
Offline Offline

Activity: 251
Merit: 100


View Profile
March 18, 2015, 01:57:03 AM
 #20


Very interesting concept.

I hope you don't abandon it.
Pages: [1] 2 3 4 5 6 7 8 »  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!