Hacker News new | past | comments | ask | show | jobs | submit login
Blackbird: Bitcoin arbitrage (github.com)
298 points by vega_empire on Dec 23, 2017 | hide | past | favorite | 117 comments



Two notes. First, as others have said, while the market may contain inefficiencies, they tend to close fast especially with a public solution. That said, this may be a good starting point for you to go nuts on for generation 2.0 so enjoy the code.

Second, while I won’t comment on this particular strategy, I want to note that many so-called “arbitrage” systems are actually sleeves for another important risk: liquidity. These strategies typically assume normal trading behavior and don’t take into account that exchanges break during crisis events, the exact events (even if they’re rare “black swans”) which can leave you half in a trade and wearing massive exposure during extreme volatility. The analogy is picking up nickels before a bulldozer... use at your own risk.


>I want to note that many so-called “arbitrage” systems are actually sleeves for another important risk: liquidity

Very true, especially with altcoins. In my experience, big deltas have been results of things like withdrawal suspensions.


huh, you give an analogy w/ out actually explaining how this would happen.


I think that poster does explain how it happens. The exchanges tend to shut down or break during extreme volatility events. If one breaks and the other doesn't, you're half in the market. What if you can't sell your positions until after the price drops, but the other position doesn't exist to balance it out?


With cryptocurrencies you also have other exchange risks, notably the risk an exchange is hacked or otherwise goes out of business. Imagine if you had been buying BTC on Coinbase and selling BTC on MtGox in 2013, making a great profit (on paper) through arbitrage, until MtGox tanked and all those profits were frozen.


I thought it was pretty clear. In a high traffic scenario some exchanges break and your order doesn't go in. To profit from this system you need both orders to be posted almost at the same time. If one exchange lags for minutes/hours you risk losing money with your other position, ie, you get bulldozed.


For people wondering, does it work? Short answer. No.

Long answer - The biggest flaw lies in the "advantages" section:

Unlike other Bitcoin arbitrage systems, Blackbird doesn't sell but actually short sells Bitcoin on the short exchange

The problem is only Bitfinex allows short selling. So, the example is an excellent case of cherry picking.

There are other issues with their strategy too.


Also Bitfinex uses Tether tokens, not USD, which are by their own terms of service worthless, and it's dubious as to whether their actually backed by any real USD.

This arbitrage exists because of the huge counterparty risk of exchanges


I thought you were being hyperbolic about Tether tokens being worthless. Turns out you're completely right: https://tether.to/legal/

> Tethers are not money and are not monetary instruments. They are also not stored value or currency. There is no contractual right or other right or legal claim against us to redeem or exchange your Tethers for money. We do not guarantee any right of redemption or exchange of Tethers by us for money.

> We make no representations, warranties, or guarantees to you of any kind, including with respect to any right of redemption or exchange of Tethers for any property.

That doesn't make any sense. Those are absolutely outrageous terms of service for what Tether purports to be.

I thought the entire point of Tethers is that they're redeemable for USD on a 1-to-1 basis with a fixed exchange rate. That's exactly what the Tether FAQ says, but based on the actual ToS, I'd have to consider these statements to be absolute bullshit:

> Tether Platform currencies are 100% backed by actual fiat currency assets in our reserve account. Tethers are redeemable and exchangeable pursuant to Tether Limited’s terms of service. The conversion rate is 1 tether USD₮ equals 1 USD.

https://tether.to/faqs/

The FAQ says "Tethers are redeemable[] pursuant to Tether's terms of service" and the ToS says "There is no contractual right or other right or legal claim against us to redeem or exchange your Tethers for money"

That is just fucking outrageous. I'm sorry, but it is.

I do not understand how or why anyone would use Tether without a contractual guarantee from the issuer to redeem each token for the underlying currency that it reserves. Without this, there's no reason for Tether to have a value.

I thought that the concept of Tether had sound technical merit -- essentially, a cryptocurrency with a fixed exchange rate backed by a full-reserve central bank for each currency -- but when offered with those legal terms, I have to consider it a scam. Under their ToS, money can flow into Tether but not out!

I can speculate about all sorts of reasons why they might have put up those ToS, but at the end of the day, it's a morally wrong contractual relationship for them to have with their customers. They should operate like a bank or otherwise with a guarantee that customers can convert Tether back to the reserve currency.

Edit: While doing some searches on this topic, I also found a news article about their questionable ToS, quoting this statement from the company:

> Our Terms of Service have been carefully picked apart by various malcontents and twisted to suggest that Tethers would not be redeemable for currency on some bizarre, malicious whim by Tether. That is untrue. https://cointelegraph.com/news/tether-really-isnt-a-scam-com...

Yeah, okay guys ... this interpretation is not carefully picking apart the ToS with malcontent. It's just a basic plain English reading of the ToS. I would stay away from Tether, and any company that responds in this way to completely reasonable criticisms.


And you can't withdraw anymore. [0] The whole trick was that Bitfinex could claim to have a price for USD, because they have a price for USDT, and the ratio of USDT/USD is 1. But since they've printed over 1 billion USDT without any assurance that they have USD to back them up, and now you can't withdraw at the source for the USD that they supposedly have backed in a bank somewhere, expect the value of USDT/USD to plummet on exchanges. Fun times.

[0] https://tether.to/wallet-service-and-platform-update/ [1] https://wallet.tether.to/transparency


Also, Bitfinex almost always has a lower price than the other exchanges so there's almost no opportunities to actually do this; the only major exception was when the trustworthiness of Bitfinex's dollar deposits themselves were in question, which is a bad time to be doing arbitrage. Plus, you're going to be paying interest on your shorts for the entire time period they're open which eats into your profits. There's also the risk of the price increasing enough that a margin call liquidates your short position before the prices converge enough that you can close your position and take a profit.


This strategy used to kinda work (before it was exploited by people) manually across multiple exchanges that allow short selling. It's just that Bitfinex is the only one that's supported by this software.


I'm still trying to get over the idea of advertising software like this with code for two exchanges (Kraken, EXMO) marked "untested". Perhaps it is not ready for public release yet.


who said the creator is the one who posted this


it doesn't have to be the creator posting for this to be advertising.


You can also short on poloniex


But not BTC/USD, only BTC/USDT, opening another can of worms.


You don’t need to short BTC/USD you just need to be able to short. You can always convert to USD after your arbitrage gains in BTC, which I do and have done.


Suppose on exchange X, BTC/USD trades at 12000, on exchange Y, BTC/USDT at 10000. You sell an expensive BTC on X (for 12000 USD), you buy a cheap BTC on Y (for 10000 USDT).

Now they nicely converge to 20000. You buy back a BTC on X, giving you a loss of 8000 USD. You sell a BTC on Y, giving you a nice 10000 USDT gain.

So, you realised and locked in the projected 2000 USD arb profits - oh, assuming the 10000 USDT you got on Y can actually be exchanged for 10000 USD. You have exposure now to USDT/USD, and your arb profit (in USD) depends on that cross.


No, you don’t arb on BTC/USDT. You arb on XXX/BTC and then convert BTC to USD regularly on GDAX.


Got it. So we agree, the arb has to be on the same cross (XXX/BTC) on different exchanges.


Yup. Bittrex is a good companion


@JulienHamilton (author at bottom of page), why would you share this with others? If arbitrage exists, there is not benefit to you allowing others to profit, as it eats into your profit. So what’s the reasoning behind releasing this?


You're right in theory, but that's only really a risk if it actually works, which this doesn't.

Also, if the author is interested in increasing market efficiency, but not in exposing themselves to the risk of being caught in a halfway position when an exchange breaks, it makes sense to release as FOSS. The target users would then be the exchanges themselves.


It might be to force the market to become more effective.


It exists, but this specific piece of software doesn't have great exchange support (at least when I last checked). So the method works (somewhat, not 100% foolproof) - but not with the linked software.


I could imagine that if I made a lot of money with this software and subscribed to FOSS philosophy, I would feel good about setting it free.


Two words: "counterparty risk".


I'm surprised this comment isn't #1!


I probably should have added an explanation for those unfamiliar with the term, but then it wouldn't have been two words! :)

Essentially conterparty risk is the risk that the other party to a contract, in this case the broker, defaults.

Bacause automated arbitrage trading requires you to hold your funds with the broker, rather than transferring them to your own (preferably cold) wallet, you are exposed to the risk that the broker goes out of business without returning your funds, or otherwise fails to live up to its side of the bargain.

With crypto-currency exchanges, that risk over the long term might be assessed to outweigh the possible rewards from arbitrage trading.


This. I wrote a crypto arb bot in 2014 and decided to stop working on it / open-source it for the same reason after a couple exchanges that I had cryptos in mysteriously vanished.


"The Bitcoin market could suddenly lose twice its value that this won't make any difference in the strategy returns."

Just FYI I think you mean 'lose half its value'. I doubt we're going to see BTC go negative.


All right settle down


From the README:

  >> your maximum loss on an exchange won't be 
  >> greater than $xx no matter what.
Unless I'm misunderstanding; the bot sells short on one exchange and buys on the other. If there was a bug where it didn't cover the short sale with a long buy, and Bitcoin price goes up, you'd be liable for the increase in price.


And here's an instance of this very bug! https://github.com/butor/blackbird/issues/348


And they will always happen - once you send a first transaction of the pair, if anything goes wrong (eg. overloaded exchange timeouts on API call) with the second one, there is no undo.


Note that unlike most other arbitrage, this isn't foolproof. High volatility can kill it, and price differences on some exchanges only exist due to geographical or technical restrictions (so the price is always a few dollars higher/lower). Definitely a fun experiment, but don't expect it to make you a lot of money.


It's worth reading the linked issue for a refresher on how arbitrage, and this scheme in particular, work: https://github.com/butor/blackbird/issues/100.

I think the pathalogicial case is if the markets never converge significantly, or more likely diverge wildly, e.g. one gets hacked. Otherwise, Blackbird will wait it out until it hits a pre-determined settable profit margin.

I'm guessing plausible return rates are low, but with the relative safety you can risk a bit more than just "crystal-ball"ing the market or playing daily lows and highs.



The issue is BTC trading costs are so high that arb'ing it doesn't work well. You need massive spreads and perfect trading execution for this to work.


Since when is a trading cost of 0% (maker, high volume, bitfinex) and 0.1% (taker, high volume, bitfinex) so high?


"Information arbitrage" will become more important with crypto: "Contagious Speculation and a Cure for Cancer: A Non-Event that Made Stock Prices Soar," with Tomer Regev, Journal of Finance, February 2001, Vol. 56, No.1, pp. 387-396.

https://www0.gsb.columbia.edu/faculty/ghuberman/research.htm...


BTC arbitrage is very risky due to transaction times, volatility, and volume. And it's often not worth it depending on your region due to potentially high fees. It's not something I would recommend to people who have never done it before.

As an experiement, go on to a site like CoinMarketCap. Click on BTC->Markets. Sort by price. It looks like a ton of arbitrage opportunities, right? Well... now try to take advantage of it.


The OP claims their system isn’t affected by transfer times. Read it and tell us what you think.


Of course it's affected by transfer times, it just takes some thought to understand why. Ultimately, in order for this to close out the position for a profit, the prices have to converge for long enough, and in order for that to happen reliably someone has to do arbitrage the slow way by transferring money. While you're waiting for that to happen, you're paying interest on the short position and exposed to the risk of a price increase causing a margin call that liquidates your short at a loss. The amount of profit you can make is also limited by the time it takes for the prices to converge.


it does not work like that, it requires you to have "money" or the ability to short/long at all exchanges and then u simply buy/sell locally.


Given how slow BTC transfers are now (can be 1+ day out of gdax), you would need to keep sizable amounts of BTC on each exchange and rebalance periodically.

While technically opportunities exist daily (compare the huge difference in prices this moment at https://coinmarketcap.com/currencies/bitcoin/#markets) but tough to execute due to BTC transfers or fiat transfers being high-friction.


I just tried to do this last week.

The issue I ran into is you can't move dollars between exchanges easily, so to rebalance, you've got to switch to something else. So you're profiting from volatility on one side and then betting on it not happening when you rebalance... and for the rebalancing, you have to wait a lot longer (as compared to trading instantly between currencies on the same exchange).

The other issue is that you have to anchor to something, and you can't anchor to the USD generally because even dollars in various exchanges aren't effectively worth the same amount (since you can't get them out as quickly / easily / risklessly in all exchanges). So you've basically got to anchor to US dollars on a certain exchange, and make trades based on the value of, for example, "Litecoin if sold on GDAX." That adds complexity, but might just be the reality of arbitrage.

That and I'm not sure the order books were large enough to make anything other than small amounts of money. The "last sell" price is just that--the price it last sold for. It doesn't take a whole lot of money before you've driven the price toward parity (and your arbitrage opportunity away).

Anyway--for me it was just a winter vacation project more for the experience than expecting real success. And it may actually work better on a week that wasn't last week (which was a bit uncommon). I guess we'll see.


The readme states that this doesn't rely on actually transferring anything.


can someone explain this app in laymen's terms? is it an automatic sausage maker? or a slot machine?


Arbitrage:

Person A is selling apples for $5 and buying for $4.50.

Person B is selling apples for $4 and buying for $3.50.

You buy apples from person B and sell to person A. Of course, this is a bit oversimplified- this project uses a few tricks to get around volatility.


And the more people that run this, the more efficient crypto markets will be! It's a win-win.


I find it odd that Bittrex isn’t even mentioned as one of the potential exchanges. I’ve found them to be more stable and user-friendly than other exchanges.


There was a few users on reddit recently that claimed to have gotten robbed by Bittrex, not sure if it has anything to do with it: https://www.reddit.com/r/CryptoCurrency/comments/7lfhfu/bitt...


I didn’t read this, but think about it: if someone knew how to arbitrage BTC, or anything, why would they share it?


Or: just invest a bit at a time in https://finance.yahoo.com/quote/VTSAX/ and forget about Bitcoin. Concentrate on advancing your own skills and career, and maybe invest in some local real estate if you have some extra cash.


Looking at this chart from Nov. '00 to today, it looks like a huge drop is coming... of course it probably doesn't matter if you are in it for the long term.


Or do both. Diversification across asset classes is good.


VTSAX has a lot of diversification built into it, and most importantly, has extremely low fees. Get some bonds if you'd like too.


Thanks, but I already know, I've been investing in it for over 10 years! It's done very well. I also have some BTC and ETH.


Wait, since when does GDAX allow short-selling?


Last time I checked they were using floating points to represent monetary values. I would not trust this piece of software regardless of how clever their strategy may be.


The whole “never use floats as money” thing is a little overblown. If you need exact values, where everything needs to add up in the end, sure. But if you’re generating the value yourself it doesn’t really need to be precise. For example - create a sell order for ten percent less than the current price - that doesn’t need to be exact.


I will tell you that any working piece of code that allows someone to make money, is not public. Use this if you want to inevitably lose money.


That seems like a silly statement to me. Obviously, huge amounts of code that "allows someone to make money" is available publicly, for some definition of "making money" or other. I am guessing your statement is specifically directed towards code that is meant for trading markets and referring to the efficient market hypothesis. That may or may not be true but I think it would suit you to at least back up such a claim, especially when it comes to crypto currencies which are obviously a very immature asset class.


Yea he means trading systems. There are thousands of people selling “trading systems” for the stock market, by definition none of them work.

An example is why Warren Buffett got special permission from SEC to withhold reporting his trades for longer periods then normal. If you know that WEB bought a stock today, then you know he’s done the research and it’s a clearly profitable trade to buy and hold it for the long run. If WEB had to report trades daily, he’d be out of business, he’d never be able to buy more than a tiny amount of a stock in a single day, because the next day its price would have increased at least 20%.

Selling any kind of successful trading system is to invite others into your trades and make them less profitable for you. Selling the system only makes sense if the system is unprofitable or it's so thinly profitable that selling it to suckers is more profitable.


I was already being pedantic before so I will try to keep it at a minimum but you say "by definition" and then you go on to talk about the worlds most famous investor as an example of why the market adjusts. I get the point, when something has value the word will spread and the advantage will disappear. But that applies to a perfect system only. When Warren Buffet does something, people hear about it. But can we agree that it's (at least, theoretically) possible for some dude to discover something and make a bot that exploits it for some small value and a limited amount of time before that effect will kick in?

Also, the implied premise here seems to be that nobody in their right mind would give up on something that made them money, hence it has to be a scam. I'd say that open source in general is a perfect example of people giving their work away for free for whatever reason. Maybe they would rather have fame (i.e. github stars), or maybe they want a developer career and see this as a way to get feedback on code they wrote. Or maybe they simply feel that the potential value they could gain from this wasn't high enough to make it interesting so they decided to set it free.


If the price of the stock would increase tomorrow by 20%, why wouldn't he be able to buy more than a tiny amount today?


Warren has over $100B invested in public equities (stocks). He’s s believer in concentrated portfolios, ie he doesn’t want to own more than a few stocks st a time. If he can’t buy $10B worth of a stock he’s not interested.

There isn’t a stock in the world you can buy even $1B of in a day without driving it’s price up dramatically yourself. So Buffett has to slowly accumulate a position over weeks and months.


Oh right, thanks for the explanation.


You know what I meant.

Why would anyone release a market algorithm that was proven to make money? And if they did, by virtue of everyone jumping on to use it, would no longer work.


> Why would anyone release a market algorithm that was proven to make money?

People do weird stuff all the time. Plus, you'd need a lot of capital to exploit this fully. The basic concept of arbitrage here seems reasonable to me.

> And if they did, by virtue of everyone jumping on to use it, would no longer work.

Yeah probably. But you'd be able to observe that when all the market prices converge.


When he says “working code” he means “trading system”


I've made a lot of money from Apache and Python, and they're public. ;)


:)

How about...

"I will tell you that any piece of code that claims to make you money is not public."


Thats not a true philosophy, opportunity exists dont limit yourself

In this case, Spread trading relies on a spread not widening


Like, Bitcoin sources?


Anyone actually using this? I’ve looked at it recently, but not sure how well it works.


I used it late 2015 and it was working okay (still lost money sometimes, ended up with a very tiny gain). It doesn't work very well anymore, mostly due to Bitfinex being the only short exchange that's supported.


Amazing people are naive enough to post this kind of stuff publicly!


I'm sad at the quality level of comments on this discussion. Lot of people are commenting clearly without reading EVEN the readme.md of the linked post.

This tool advantage relies on the fact that NO bitcoin needs to be moved, so all posts about long time of btc transfers make (almost) no sense.

On the other side only ONE (so far) person mentioned (importantly) that it works only on bitfinex, and even him didnt clearly wrote that this work ONLY if bitfinex has higher price than other exchange (reducing arbitrage opportunities by half), because you can short btc only on bitfinex.

Where is HN from 5 years ago? :(


> this work ONLY if bitfinex has higher price than other exchange

Bitfinex might well have higher BTC/USD. However, the reason is that people can't get USD off Bitfinex, and so buy BTC to get those off Bitfinex. Thus, if you try to do the arb, you buy BTC cheaply on exchange X (for USD), then sell BTC (simultaneously) expensively on Bitfinex (getting USD).

Now, to realise your paper gains, you either have to wait for the BTC price to converge and then unwind the trade backwards, and have some money left, or you have to get the USD off Bitfinex. But you can't. That's why the price of BTC was so high there in the first place.

TL;DR: Arb is not trivial.


If no transfers are necessary, that basically means it stops making money when your long or short position is maxed out. A transfer would be used to allow bigger long and short positions to be entered.


> and even him didnt clearly wrote that this work ONLY if bitfinex has higher price than other exchange...

To be fair, it does not appear to be pointed out in the readme.md, either.


First table, named "Implemented Exchanges".


That table does not make the point raised here, which concerns a specific consequence of Bitfinex being the only exchange you can currently short bitcoin on. I would provide the specific quote, except it is already in the post that you replied to.


>Where is HN from 5 years ago? :(

Here: https://hn.algolia.com/?query=bitcoin%20arbitrage&sort=byPop...

As you can see, there wasn't much discussion. The noise has certainly increased, but at least there is a discussion going on now.


An increase in volume of discussion does not seem to benefit anyone aside from folks who read discussions in lieu of doing anything else.

For that, reddit is ideal.


Was HN ever a place to talk about financial speculation schemes?

If you want to talk about this stuff, you want a forum full of financial trader people, not engineers.


Yes it was. It was much more business oriented than it is now.


Seems like majority of HN hates crypto which is disappointing. Luckily there are a ton of great subreddits, slack, telegram, and discord channels out there.


We detached this subthread from https://news.ycombinator.com/item?id=15994727 and marked it off-topic.


They may dislike the current state cryptocurrencies are in while fully supporting the underlying idea.


This really. Nothing against cryptos but have developed a distaste for the ecosystem in general. I was sold on the idea of a currency that could help people in third world countries with stupid banking policies but instead 99% of the money in crypto is speculation waiting to cash out to fiat.


Why does that matter? 99% of people investing in Tesla probably don't care about whether electric cars will help reduce pollution. They care if the stock goes up and it makes them money. That doesn't mean we shouldn't discuss the merits of electric cars.


Because to benefit from an electric car you don't need to care if the stock is overvalued or volatile. To benefit from crypto as a currency, you kind of need to not lose your life savings in the space of an afternoon due to volatility.


There's definitely a lot of speculation. But much of it before the last 6 months was philosophically driven. I wouldn't say the vast majority is just waiting to cash out. A popular bitcoin meme is that once the price is high enough, you won't have to. (Because it will then itself be the currency that everyone uses and cashes out from other currencies into.)


I totally agree with you, but then again, if software doesn't solve a people problem, it's bad software. This is what you learn in your engineering career.

Cryptocurrencies are technically amazing, and yet they fall short of actually solving any problem.


Where by "crypto" you mean "cryptocurrencies", rather than the more common "cryptography" (which I think is still overwhelmingly appreciated here), right?


Lately it seems like the majority of HN hates most technology. It's starting to feel like the most toxic social network I'm on. Quality critiques are few and far between while pessimism and anonymous downvoting is overwhelmingly high.


There is clearly an interest because we routinely see links about crypto-backed currencies make it to the front page but the quality of comments is usually astonishingly low. I don't know if that is because people "hate it" or if they overestimate their own knowledge of the topic.


There's definitely a massive amount of dunning-krueger happening in cryptocurrency. I see a lot of that in these threads.

But I think the real reason the threads are low quality is a lot more disappointing. There are a lot of people who (often they aren't even HN regulars) have heavy vested interests in cryptocurrency, in a certain philosophy, in a certain coin, and so they brigade to protect their interests and to steer the ideas of the public in their preferred direction. So people will speak up even if they know it's not really their area of expertise


Would you mind posting those?


I just started a Telegram group up recently for people casually interested in altcoins/trading. Welcome to anyone - https://t.me/tradetradetrade


Also interested in this.


[flagged]


>Korean Jew Trading

sounds top notch.


> Learn how to make jewrean dollaz

...


There's an influx of fake accounts spreading fake news. Please flag.


haha alright, who would even try to astroturf hn with ant-crypto comments? the u.s. government?

it's human nature, when some people have made lots on bitcoin the people who haven't get a crab mentality. i doubt it's a conspiracy


Sigh. No, it's not a crab mentality. It's those of us who have lived through asset bubbles before and know that they have a tendency to affect the real, actually productive economy when they collapse.


> majority of HN hates crypto which is disappointing

The assumption you may speak for the majority by sampling a small polarized set of data is interesting, but irrational.


How to add a new exchange to this? Which interface need to be implemented?


Why not run arbitrage on ETH etc. which have far shorter transaction time than BTC. That surely is a much safer bet with essentially the same API. With the current transaction time BTC arbitrage doesn't seem to be a wise idea at all. In between the several hours the price could have easily changed more than 10%.


This doesn't actually ever send coins over the network. It shorts on one exchange and goes long on the other.

As such it is market neutral (since prices should converge) and transaction time doesn't matter.

Still doesn't work too well.


Ah OK. I didn't read it carefully then. My bad. But then this is apparently not guaranteed to work since there's in most cases a permanent spread between exchanges due to various factors, e.g. their availability in countries, their fiat withdrawal cost, etc. Transferring coins fast enough might be a more feasible idea actually.


In particular "prices should converge" is hiding a pretty big precondition in very few words. You don't only need prices to converge, but you need them to converge within a reasonable time span, which is obviously not guaranteed. (because if the market was efficient already then the prices would have converged already and it would not be feasible to run arbitrages like this)


It's the other way around... market efficiency is caused by things like this (not only arbitrage, but that's one important factor).




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: