All the US dollar exchanges with substantial volume are within 1% of each other. [1] Some of the little guys are a few points out there, but any significant order would blow the price. All the exchanges lock together within the range of the cost of trading, which is usually at least 1% when you combine buying, selling, short-selling loan, blockchain reward, and cash withdrawal fees.
They are right now but this isn't always the case. For example you can see just from that page that in the past 24h, Kraken reached a low of 1025 while Bitstamp only reached a low of 1118, a difference of 9%. If at that low, you'd bought BTC on Kraken and sold BTC on Bitstamp, you would have made that 9% difference.
This is the point of the strategy. Whenever they diverge for whatever reason, assume it's temporary and that they'll reconverge. Make money converging them.
Kraken has a horrible trading engine, I've seen a lot of examples of delayed executions (in the class of minutes), so the peanuts of earnings can be lost very easily on the immature trading engines of these exchanges.
Right. Arbitrage on small differences works only if you can get quick execution, before the difference disappears. If the site gives favorable execution to some customers, as Mt. Gox did, it's hopeless.
The direction doesn't actually matter since you're trading both sides. An example:
Exchange 1: 1000
Exchange 2: 900
You sell 1 of exchange 1 and buy 1 of exchange 2.
Scenario 1: Exchange 2 rises to meet exchange 1, exchange 1 stays stable. You make $100 as you bought exchange 2 at 900 and its price is now 1000. You lose nothing on exchange 1 since the price hasn't changed.
Scenario 2: Exchange 1 falls to meet exchange 2, exchange 2 stays stable. You make $100 as you sold exchange 1 at 1000 and its price is now 900. You lose nothing on exchange 2 since the price hasn't changed.
Scenario 3: Exchange 1 rises to 1100 and exchange 2 rises to meet it. You make $200 as you bought exchange 2 at 900 and its price is now 1100. You lose $100 as you sold exchange 1 at 1000 and its price is now 1100. The ultimate profit is $100.
The different exchanges are selling the exact same instrument. It's like having bank A offering $1.10 CAD for your USD, and bank B offering $1.20 CAD. If the spread is unusually large (eg, 9%) due to transient factors, they will definitely converge again in the future. There might be other risks involved, like counterparty risk, or fraud risk. But with a spread that large for an instrument as liquid as Bitcoin, there is no market risk.
I think I may have a better visualization for that [1].
But I definitely agree. Differences in prices come from fees and how hard and expensive it is to get cash from one exchange to another. Plus most exchanges offer preferential fees for bigger players so when you are just starting you are already at disadvantage.
One need to also consider order books not just the price difference (I also have a chart! [2]). Price difference may be 10% but there may be 0.01BTC in order book within that difference. Or if you just look at the price of the last trade, there may actually be nothing in order book to arbitrage against.
There may be some window to make money when there are really big price changes and basically those who do the arbitrage run out of money on one side (fiat is slow to move). But then you have to deal with high volatility.
I agree. Exchange failure is generally something separate from "market risk", and is sometimes categorized as "counterparty risk". With bitcoin, counterparty risk with exchanges is a very real thing, and an added risk beyond what would be considered "market risk" (i.e. asset price fluctuations).
Are you eliminating execution risk? with these exchanges and this liquidity I wouldn't be surprised if your algo slips and actually loses money on the attempted executions on the arbitrage prices. Isn't that too dangerous to claim you've eliminated "market risk"?
Some exchanges are going to be more permanently divergent. Does the software handle this well?
An exchange can be permanently cheaper if withdrawals are limited, trust is lower, or some other effect reduces trader confidence in the exchange.
Major events like hacks are also imo likely to cause this software to stumble. Are there safety features to make sure it'll stop trading if something sufficiently unusual is happening?
You're absolutely right: some exchanges are systematically divergent. It has been the case with BTC-e for a long time. This is not natively handled by the software.
The long/short mechanism overcomes the market risk (i.e. risk of losing money due to market moves) and reduces the slippage risk, but not the other risks, like technical issues on an exchange.
The reason this doesn't profit is because the spread tends not to exceed the difference in exchange fees. So while there may be a $1 spread between two exchanges, the sum total of two 0.5% exchange fees on a $1000 coin will only net the exchange profits in fees, and you might earn a penny.
> 5 years after bitcoin went (somewhat) mainstream.
Arbitrage is as much about volume as it is about differences in price. Volume is something bitcoin markets do not really have (compared to most other financial markets).
Cool to see a project like this open-sourced regardless of it's profitability, fintech/trading is usually such a black box.
Are there any other examples of trading systems like this that are good to read for someone with a passing interest in building simple trading systems?
It would be dangerous to run this open source code, also, since your program could be manipulated with precision timing attacks, if it were to be fooled into making a bid at a price flash. There is in fact plenty of technical risk. Caveat emptor!
This is basically how many closed source Bitcoin trading robots operate. They create giant waves of predictable trades because naive operators leave the default parameters for trading signals. Other traders just get in (and out) right before the robots.
I found that automated triangular (and 4, 5...) arbitrage was possible in the past, mainly due to fee-raking exchanges providing superfluous instruments. Opportunities were usually small, counterparty risk and fees usually large.
There also seemed to usually be someone else's bots doing the same thing, although occasionally decent sized trades appeared in slow/extraneous markets. Exploiting these mechanically eventually results in humans looking for the source of the arbitrage, and even if there aren't competing bots running it won't last long.
Arbitrage based on first-moving markets and slower moving markets was pretty common, and some people seemed to have automated it.
And of course the market making robots run by the exchanges are the most fun to watch. Lots of times they trigger the crossover bot traders' algorithms on purpose.
When building an automated trading system the first thing you write should be the risk system. Simply having a 'MaxExposure' per exchange doesn't cut it.
This has nothing to do with it being a market-neutral strategy or not. All code has bugs in it, exchanges have hiccups, quotes from many exchanges are notoriously wonky, programs freeze, Internet connections go down, users fat finger inputs etc. This needs a real risk system built into it.
It's weird that over the course of 7 hours no one on a site called Hacker News noticed that send_email.cpp passes unsanitized user-supplied args to system(). I've spent less than 5 minutes looking at this code, so maybe that's the worst of it. But if 5 minutes of investigation found 1980's style bugs I doubt that's the worst of it.
System() creates child processes, specified by parameters. If you don't sanitize your parameters, any child process could be created. If you run this software as root, that means root will run the command. If you run this as user, it's safer than root, but not actually safe.
1) The user isn't always the one providing user input.
2) When the user does provide input, the user isn't always smart.
3) Users do things that you never would have conceived.
Unsanitized system() calls are even worse than leaving your system wide open to a sql inection attack.
All of the above apply to bash, but it still happily creates processes from user supplied input. As previously mentioned, not all software is run on a remote-access system for strangers on the internet.
Do the arguments come from the user or the exchange? If the email is telling me my profits, and the exchange says my profits are ``cat /etc/passwd`` that could be bad.
Assuming input is from a benign source is literally the cause every single security issue ever. It's bizarre that I've been downvoted for this. And you're commenting about how I'm wrong without even reading the code. I seriously don't understand this site.
The same user who feeds in the values for 'system' is also trusting the program with their bitcoins! This is (in my opinion) like saying "bash" is a security issue because you can give it bash scripts.
... but it ain't your financial system. Unless I've seriously misunderstood the README.
I put my cups in the dishwasher, not the autoclave. I use 2fa for my financial accounts, but not for my frisbee league. Security is about appropriate paranoia.
In no scenario is it better to allow arbitrary hidden process creation than to spend 10 minutes writing a function that validates parameters provided to launch a process.
Short selling is significantly more dangerous than other forms of investing, because it requires borrowing the securities that you then immediately sell. You eventually have to return those securities to the person you borrowed them from, so that requires a purchase in the future. If the price of the security goes up, you don't just lose your money, you take on a debt that you must repay.
The worst thing that can happen if you buy a security is that it will become worthless, thus you lose all the money you put in. The worst thing that can happen if you use any form of debt to leverage your investments is that you get wiped out completely because you end up owing more money than you can possibly pay back.
What you're talking about is a "naked short", which is of course very risky. No Bitcoin exchange allows for this. In fact, most exchanges don't allow for shorts or any sort of leverage.
While what you're saying may be true in some context, it doesn't apply here.
There is at least one exchange that has enough discount, but their reputation is horrible, so if you want to arbitrage that then it's on your head. In general that's the case if there is any opportunity. While they don't make mainstream headlines, mini MTGox'es still happen, like a Polish exchange some months ago.
There are a lot of people going after it, and probably some that do it wrongly thinking they are profitable while they are not. If you look at some of those bitcoin bots, they full of wrong calculations.
Just curious why someone would open source a project like this?
If it works, it should be making money consistenly, but giving away the system will make the arbitrage opportunity non-existant if enough people use it.
Perhaps he realises that other people are doing it too and, as you said, realised the more people who do arbitrage the more it goes away. He could be out to stabilise the bitcoin exchanges as well as provide liquidity to the market.
Perhaps as more people use it, the demand for bitcoins go up also, and since limited supply the price goes up. And he might have substantial holdings of bitcoin he wants to sell. More people trying to find arbitrage opportunities makes it easier to sell his bitcoin which are now higher value.
Does the library directly use the Bitcoin protocol? I had the impression that it only uses the Rest API of the individual exchanges interact with them.
This is a bit of a orthogonal argument as this only deals with exchanges directly and never touches the Bitcoin protocol directly. Agreed that the choice of language is an odd one as there's no "high performance"/HFT involved here.
> Blackbird doesn't sell but actually short sells Bitcoin on the short exchange.
Because nobody ever faced risk short selling. That big market crash that was part of the worst recession in 60 years had nothing to do with short selling. Long Term Captial Management totally came out of that just fine. Bear Sterns is alive today and doing swell.
The liability from short-selling on exchange A is balanced by the buy order on exchange B. The failures you described in LTCM and Bear Sterns bear no relation whatsoever to what the OP is describing. I suggest reading more on long-short arbitrage before disparaging someone's ideas with such condescension.
I am familiar with long-short arbitrage. I'm sure that long-short arbitrage is swell for the hedge funds that use it and have the resources to manage their shorts very carefully and millions of dollars to absorb losses when they screw up.
I think it's completely irresponsible to present that as "without market risk" to an audience that doesn't have similar resources and in some cases doesn't even understand what a short is. I think that presention should be disparaged.
"However, in practice, the short seller is required to post margin or collateral to cover losses, and inability to do so in a timely way would cause its broker or counterparty to liquidate the position."
That's exactly what the Bitcoin exchange will do, as well. Since the exchange actually holds the assets (i.e. bitcoin and dollars), it can also determine whether such liquidation is backed by orders.
[1] http://bitcoincharts.com/markets/currency/USD.html