237 points · by ca98am79 · 9y ago · 129 comments
(Before you ask -- no, there are no any good books and tutorials on HFT trading. You need to grokk it on your own, or receive the knowledge by direct transmission if you are an employee of HFT firm. However, there is "The Problem of HFT" by Haim Bodek, which contains some nice essays from the insider perspective and even some basic examples, though too specific within US equity markets).
1) Bitcoin exchanges are the perfect playground to learn the basics of HFT. All trading data is free and public, most traders are not sophisticated enough, you can start as small as you like (being small is an advantage in HFT), lots of low-hanging fruit are to be picked. HFT proliferation and arms race is barely started on most exchanges.
2) The algorithms themselves are simpler than most people think. HFT trading is mostly unrelated to arbitrage (inter-exchange arbitrage is much slower, and it is a different discipline).
3) The engineering issues are _harder_ than most people think. Even more so with inter-exchange arbitrage.
4) Bitcoin markets are small, and HFT potential capacity is quite limited. Most algorithms I came up with work perfectly well on small scale (and running successfully in production), but I am not making any riches out of it yet.
There are a ton of arbitrage opportunities between exchanges, but the long transaction times are the equivalent of IEX's "speedbump." How do you deal with this?
*Note: IEX is the exchange started by Brad Katsuyama, one of the main figures in Michael Lewis' outstanding "Flash Boys."
I.e. blockchain operates analogously to bank transfers. They are even slower, but they are not used for trading, only for funding and settlement.
The funnest part of writing a bot is using all the historical data to observe how the bot would have done during that period. I ended up checking thousands of permutations of parameters by brute force to determine the best ones, but in the end transaction fees killed me. I didn't have the confidence to do it at a large enough scale to make money I guess.
Making profits with fees is possible, but harder.
Also do you trade on multiple exchanges to perform inter-exchange arbitrage or for some other reason ?
That's a sure way to find a bad strategy. You end up doing the equivalent of overfitting. If you look at enough variables, the chance of there not being spurious correlations is basically zero, so you're guaranteed to land on sets of parameters that look good with historical data but fail going forward.
1. Private Wallets: Most your coin should be in wallets you control. Your profit margin should be transferred immediately to a cold wallet that your bot doesn't have keys too.
2. Only move coin to an exchange when you for a transaction, and immediately extract it once the exchange is complete. Yes this forces your swaps to have a fairly non-trivial margin.
3. My API tool scrapes several exchanges. But every 24 hours I have to manually input which exchanges to actively consider swaps between. The goal of this is to avoid exchange bad news.
Even with all these safeguards I managed to lose ~$400 when Mt Gox shutdown.
Now that I'm employed I mostly do day/casual trading on NASDAQ tech stocks based on personal tech news/market timing [1]. I went from ~110% yearly gain to ~380% yearly gain. It requires 1/100th the effort and leaves me time for FOSS projects.
[1] Yes I'm aware this is generally considered the worst strategy ever.
However, counterparty risk is real, and if you can't afford it, it's better to not engage.
On OKCoin, my flagship algo generates more than 4000 trades per day (and many more order placements). However, OKCoin is glitchy.
2/ What tools/APIs/etc do you think are interesting to build? Since I am a cofounder of a softwae development company in the cryptocurrency space, I am looking for new insights but not have experience in the HFT space.
Re: 4) what is the performance of your strategy?
The average performance is currently +0.3%/day. Losing days are rare (about 1 in 2 weeks, with about the same average loss). I have survived multiple crashes and liquidity flight events, including the Bitfinex mishap.
I don't do arbitrage (there are easier ways that I hadn't fully exhausted yet), but between e.g. OKCoin and GDAX 30-second delays are common every day.
The best way of dealing with the fees is not paying the fees. ;)
(If requested, it can be arranged, though).
So people would create a routine circuit where they have dollars, buy bitcoin on US exchange. Send bitcoin to foreign exchange, sell bitcoin for that national currency (sometimes dollars). If possible, that exchange would allow wiring out, back to the user's real bank account. In other cases that exchange would have a bitcoin or national currency market of another cryptocurrency, like litecoin, where an arbitrage opportunity MIGHT still persist.
The litecoin would be moved and liquidated back on a US exchange.
Got to calculate it yourself and figure out why the arbitrage opportunity is still there. Usually there's a good reason. Sometimes there's a good reason that you are exempt from, and in those moments you borrow as much as a can get your hands on and make 5% profits as much as possible.
The difficult part is in transferring non-bitcoin currency to and from the exchanges.
If you for example buy bitcoin in the US and sell in China, then you end up with a surplus of CNY on a Chinese exchange's account. Getting this converted and transferred back to the US will incur exchange and transfer fees. The transfers might also take weeks - which will limit you to cycling small amounts of money slowly, or risking a lot of money at once if the exchange "has banking issues".
In the end, even a 5% or 10% price difference might not be worth running the arbitrage cycle on difficult to deal with exchanges in strange countries.
My current best option is hoping that a) the Winklevoss ETF gets approved and b) an option chain develops for it, in which case I will buy puts consistent with my belief that the long-term FMV for the ETF's assets is zero. (Exchange-traded options in the US are guaranteed by the Options Clearinghouse Corporation, which is why -- absent global calamity -- you can be very certain that e.g. puts on Google are worth money even if Google goes out of business or the people who sold you the puts are insolvent when their broker hands them an exercise notice.)
There is theoretically a DRW subsidiary which does over-the-counter options but they have a $25k minimum trade size. It would also require a lot of due diligence for me with regards to counterparty risk; it's not clear whether their options would reliably compel performance or that they would be in a position to backstop the failure of their clients in the event of total systemic collapse of the Bitcoin markets. It's also not clear to what extent that DRW would backstop them if they were insufficiently capitalized. (For an illustration of why this matters, read The Big Short, for the amount of heartburn that various folks betting against the housing market went through when it became obvious that they were entirely right on the merits but that some of their counterparties were almost certainly going to go bankrupt due to how wrong they had been about the housing market.)
(I've spent way too much time thinking about this, since "Bitcoin will eventually fail catastrophically" is the biggest answer to "A belief about the future state of the world which I hold strongly after reflection and which doesn't match the beliefs of some of the smartest people I know", which sets off my "Either I'm wrong or I should be betting against them" antennae.)
The bitcoin network decided to strip the VM of features that made it valuable in the future (eg, ability to make transaction claiming represent the solution to a computation) in favor of safety and simplicity now. I don't believe the behavior of the network in resolving blocksize issues indicates the kind of political will needed to fix that.
So my bet is that the next iteration (or two or three) on the ideas behind Etherium will eat their lunch. Because having tokens to reward contract execution or a computation has a fundamental longterm value (and is similar to how real currencies function, in that executing a contract or doing a computation earns you the ability to have that done for you). I don't believe that just securing the ledger has long term potential.
Firstly, the reality is that other people (lenders), rather than exchanges, are lending out their money, for a certain amount of interest. Exchanges have nothing to lose. Quite the opposite: they earn regardless of whether longs and shorts are successful or not. Take Poloniex as example: they collect a 15% premium on interest earnings. This is of course next to the premium they collect in the form of regular trading fees.
In nearly all cases this means that lenders don't lose money. Borrowers do because they pay interest. This is why you can only borrow after you allocate collateral, which is used to pay for said interest, and to collect profits, cover losses, and for forced liquidation in the case that the borrower's trades are about to lose more value than is covered by their collateral. This applies to shorts and longs.
The only chance this becomes problematic for an exchange, I think, is when a forced liquidation does not cover all of the losses and some debt stays open. In this case either the lender does not receive the right amount of interest, or, what makes more sense to me, is that the exchange will cover the debt and try to claim it back from the liquidated borrower.
Secondly there are a good number of exchanges that do have very decent track records and aren't as scammy as you claim. There were a few scammers out there, I'll grant you that - companies like Cryptsy and of course MtGox just stole incredible sums of money. And yes, this can happen again with other exchanges. Be that as it may, this still does not have anything to do with the possibility of shorting in particular.
This sounds more like speculation than arbitrate. With arbitrage, you transfer liquidity from one exchange to another by having a short leg on the higher-price exchange and a long leg on the lower price one. This is great for Bitcoin because it evens out the price differences between the exchanges, and at the same time transfers the liquidity of one exchange to another one, while the arbitrageur makes a profit.
I don't see how leveraged trading can replace this. Arbitrate is, essentially, taking orders from one exchange and selling them on another one, thereby matching a buyer and a seller on separate exchanges. It's a genuine service to the market.
It ins't necessary extreme speed, in fact for me it took more than a month to settle.
I would first wait my program notify me there was a 20% or more profit opportunity (due to the slowness and risk).
Then I would buy btc with credit card on some usd exchange (usually mtgox, not always), then I would sell btc for brl on a Brazillian exchange.
I would pay the credit card with my brl when the bill came... this could take more than a month, and I would pay lots of taxes, but I would still turn a profit.
The reason I stopped doing arbitrage was that to me was too time consuming, because every month the payment methods would change (for example someone one month accepted paypal, then only cc directly, then only paypal again, then some paypal competitor where I had to register...)
I have been doing bitcoin arbitrage for a while with https://github.com/butor/blackbird/ . The project seems to have gotten some more attention recently for what ever reason.
Raises the question, not begs it. Begging the question would be to say, 'Bitcoin always generates profit, therefor it will always generate a profit.' Begging the question is assuming the consequent of the argument; raising a question is, well … raising one.
In other words: You're fighting a lost battle. I suspect if you put the two common uses of it to a representative sample of people, that the majority won't even know the original usage at this point.
Which begs the question: Who, then, is wrong?
The 'misuse' of "begs the question" has a meaning that logically follows from the words.
Therefore, your claim that "begs the question" can't mean what 99% of people understand it to mean in colloquial conversation because it's a term of art that means something else in logic/rhetoric is invalid.
By the way, this reasoning is independent of etymology. "Beg the question" may at some point have only meant what you claim it means now (I don't know if it did or not) -- but that doesn't change anything, even if it's the case.
Note that "begging" in this context is likely a mistranslation in the first place. Therefore using it to actually mean "begging for" is less incorrect than the idiom.
"Beg the question" is fine: it means what 99% of native English speakers believe it means, and everybody understands it.
The quoted sentence is the dictionary usage of the phrase.
[1] http://dictionary.cambridge.org/dictionary/english/beg-the-q...
[2] https://en.oxforddictionaries.com/definition/beg_the_questio...
i.e to introduce a premise begging to be questioned - that includes, of course, the assumption of a conclusion, (isn't that a different fallacy though? - circular reasoning) e.g.:
> bitcoin is profitable, because bitcoin traders are doing well
It pushes the argument somewhere (sometimes to a new claim; sometimes a consequence-of, or paraphrasing-of the original claim) but provides no argument for that direction either, begging for the new premise to be question just as much as the old, and otherwise providing no new clarity.
This being abstracted to any obvious omission of information, or even abstractions such as situations themselves "begging the question" as if personified, is just an extension of the same semantics.
High-speed trader's are taking advantage of arbitrage on zero fee digital currency exchanges.
Is there a cap on the growth of the blockchain? Since every transaction is saved and every actor has all of the blockchain (Am I correct?), if HFT made it double it size every week, will it reach an unmanageable size after a few terabytes?
Does volatility of an asset itself create value? It seems like the more volatile the price is, the more opportunities there are to make big profits trading the swings using a 'reversion to mean' strategy. Which would mean more people trading it, which would mean that over time, the 'mean' price would keep trending upwards, until that volatility reduced to the point where the strategy was no longer profitable.
Does that make any sense at all? I'm sure there's a broken link in that chain of logic somewhere.
On the other hand volatility can provide arbitrage opportunities for people who know what the "true" price would be. A simple theory suggest that there is a trend, zero or more cyclical patterns, and noise. If you can identify what is noise and what is not the trend, then you can trade against those prices. From the perspective of social utility, pricing error is bad for the economy, and the people who correct it get a share of the recovered efficiency in the market.
In the case of bitcoin it is difficult for me to imagine how to determine a true value. The supply is predictable compared to money, even though the factors that affect the supply of money aren't as unguessable as sometimes claimed. The demand for bitcoin though seems really difficult to understand. As a result its value is much more likely to resemble a random walk, which would mean that there is no mean for the price will revert to.
There's the value of a bitcoin, and the value that bitcoin brings to the market. And those are two different things.
The value bitcoin brings is anonymous currency transactions and anonymous speculation.
Now ask yourself what is the value of one bitcoin? It's not based on a physical scarce resource like coal or oil. It's not based upon an actual currency either (either gold backed or fiat). In fact the only value people have in it is that other people invest in it. So speculation has created value.
Volatility in this case is just a side effect of speculation.
That wasn't true in 2012. :-)
Does maker/taker distinction ignore the side of the transaction (ie. does it matter whether an order is a bid or an ask to be considered a maker )?
edit: Some cross exchange trades (i.e. buy BTC on one exchange and sell on another) would still require a move across the chain, but it all really depends on what the exact mechanics of the trade are.
Only when someone withdraws his Bitcoin promise does it become a transaction on the blockchain. Until then it's just an exchange saying it owes you a certain amount of bitcoins. This becomes evident when an exchange defaults on this promise because of e.g. a hack, as has been the case with Mt. Gox, Bitfinex, Bitfloor and many others.
HFT is when you are faster than most other traders. ;)
Liked how you pattern match directly on JSON messages, I should di it more. :)
There are institutional-grade solutions (cross-connect, colocation in NY4, FIX feeds / order placement), available e.g. from Gemini (https://gemini.com), however, I am not sure that current overall Bitcoin trading volume is enough to warrant this. Both one-time setup and monthly fees for direct links are significant.