9 ms·
After having spent an insane amount of time in late 2017/2018 building an HFT bot for Binance I can say this is a pretty solid article. In our case we were doi
by nickreese 7y ago
After having spent an insane amount of time in late 2017/2018 building an HFT bot for Binance I can say this is a pretty solid article.
In our case we were doing triangle trading between BTC/ETH/USDT pairs and had our buys/sell delay down to 3-7ms. At one point moving 0.3-0.7% of Binance’s daily volume.
Few notes:
* Finding an objective point of truth for value when all of the currencies are floating is hard but vital to success. This was the hardest problem we encountered. We tried taking the realtime average of BTC and ETH across all exchanges, we tried tying it to the shortest route to USD, and several other routes... but ultimately this is where we ended up “losing” most of our alpha.
* Order books are seemingly simple but the devil is in the details. This especially matters for paper trading.
* Efficiently using API limits at exchanges is an optimization problem in and of itself.
* Our model was relatively simple but we focused on speed and edge cases. For instance Binance would rotate IPs on their load balancers and we’d constantly check the latency between each open SSL connection and use the fastest. Further we wouldn’t decode the buy response to plaintext we’d just read the raw stream.
After several epic months our entire project fell apart after a cryptic phone call about “institutional access” that didn’t follow the 1s websocket update. The access was quiet expensive and we said no to it and shortly after all of our strategies went to crap.
Best we could tell someone was front running us due to an artificial delay for our account (delay between trades went to ~20ms up from our prior steady speed of 3-7ms) and/or a bunch of the trades in the orderbook were bogus.
Frustrated we tried our strategy on another account and the delay dropped again to our normal range and was profitable again (the orderbooks were slightly different between bots!).
It was in that moment we realized playing in unregulated markets is not fun or something we wanted to continue to do. Intermediary risk was something we didn’t account for.
Further we realized that there will always been a better resourced or more dedicated team willing to fight you for your alpha.
After months of effort and a ton of fun we decided it was best we went back and focused on a problem where we could build a long term competitive advantage.
Edit: typos and formatting
- kami8845 7y agoThanks for sharing. Do you think building the strategy on another exchange such as Coinbase Pro or pursuing a strategy that wasn't as latency-sensitive might've yielded more success?
- andruby 7y agoI ran a triangle trading arbitrage bot on Coinbase that was profitable at the end of 2017. But a few weeks later, it was losing money on hard to diagnose slippage. The number of “opportunities” also collapsed, which indicates that other bots were doing the same or that coinbase was doing this internally. I pulled the plug. Tried to run it on Binance but the websocket only updated once a second, so there was way too much risk.
- carlsborg 7y ago> the orderbooks were slightly different between bots That sounds like a big deal. If this is repeatable, you should document it better. Unregulated doesn't mean a license to do blatantly illegal things. Crypto exchanges certainly get taken to court. Sure it wasnt your book building algo and a snapshot retrieval race?
- pjc50 7y agoBinance is in Malta, a somewhat corrupt tax haven; are you sure it's illegal there?
- garmaine 7y agoMalta is in the EU.
- baq 7y agoThis doesn’t guarantee much in itself. A journalist was murdered there for investigating corruption not that long ago.
- garmaine 7y agoAnd the prime minister’s chief of staff was just arrested over that. Just because illegal stuff happens doesn’t mean there aren’t laws against it.
- baq 7y agoSure. That's not the point. The point is corruption increases risk of doing business regardless of whether somebody gets caught. People dying because of investigating corruption only makes the point stronger.
- pjc50 7y agoOK, so which EU directive are we dealing with here? Which regulator does Binance answer to?
- tardis_thad 7y agoReally interesting, thanks! Could you share bit more about the 'institutional access' call? Does it mean that selected few have access to real-time book updates and all the rest is @100ms delayed? So much of level playing field :) Is it common for asian crypto exchanges?
- rixrax 7y agoWhen You do this kind of (HFT) trading, how does ones tax returns look like? E.g. I assume you still have to report every trade with its gain/loss to a tax authority?
- TuringNYC 7y agoIANAA, but you file a gigantic "Schedule-D". I have never done it with crypto, but there is standard software to do it for non crypto stuff. I used GainsKeeper: http://www.wolterskluwerfs.com/tax-reporting/solutions/gainskeeper-for-investors.aspx http://www.wolterskluwerfs.com/tax-reporting/solutions/gains... I see they do crypto, but I've never used it for that. For companies, they have entire departments that consolidate trades and construct massive Schedule Ds
- jotakami 7y agoDepends on the nature of the trades. If you are hedging and maintaining a delta-neutral position (very common situation for market makers and arbitrageurs) then technically your trades are part of a straddle, which is reported separately from capital gains. (in the U.S., at least) I learned this because I had a six-figure capital loss on my spot crypto trades, and a slightly larger gain on unregulated futures which do not fall under capital gains. Capital losses can only offset up to $3k in other income, so I was terrified that I’d have to pay taxes on the massive “gain” without being able to count the losses against it. Fortunately, the straddle is the correct way to report this, allowing gains and losses to be matched across instruments that may otherwise fall into different income categories.
- pjc50 7y ago> It was in that moment we realized playing in unregulated markets is not fun or something we wanted to continue to do. Intermediary risk was something we didn’t account for. Indeed. This is the really difficult thing about the crypto space: winnings, if you can keep them. And you can't if the house is just going to front-run all your orders.
- throwaway_e4WNi 7y ago> the orderbooks were slightly different between bots As somebody who still runs a profitable bot on Binance I find this hard to believe. Also all order book related endpoints/streams are public, so queries/subscriptions are not tied to a specific account.
- nickreese 7y agoIn late 2017/early 2018 when their websocket was new I believe you had to be authenticated for either the initial order book query or the websocket subscription. Either way since we always locked our api keys to our IPs it wouldn't have mattered.
- milesvp 7y agoEven in regulated markets there are problems. I have a friend who built an HFT algorithm that he was using for trading stocks. He had some really good results with early testing. But at some point he was confused why many of his buy/sell orders weren't being executed despite being open for several minutes (hours?) his algo would make bids far away from the current spread, anticipating movement. He finally concluded that some institutional traders must have access to sub-penny ordering, despite it being against regulation. I didn't believe him at first, since, the more likely problem was elsewhere, but then a few months later sub-penny trading in dark pools was all over the news. This was like 5 or 6 years ago. He's since moved on to other things having come to similar conclusions, that trying to play such a rigged game was futile.
- nickles 7y ago> But at some point he was confused why many of his buy/sell orders weren't being executed despite being open for several minutes (hours?) his algo would make bids far away from the current spread, anticipating movement * Did his levels actually get crossed? It could be that he never had the opportunity to get filled at the price he hoped for. * What was his queue position? Stock exchanges tend to be price time ordered. If others had submitted orders at the same price before he had, they would have priority when getting filled. * Apropos the prior point, was his broker actually submitting orders when he sent them? Some brokers may avoid showing deep out of the money orders, which could have affected his queue position. > He finally concluded that some institutional traders must have access to sub-penny ordering, despite it being against regulation. There's nothing wrong with this. Reg NMS rule 612 permits sub-penny price improvement [0]. [0] https://www.sec.gov/divisions/marketreg/subpenny612faq.htm#q13 https://www.sec.gov/divisions/marketreg/subpenny612faq.htm#q...
- perl4ever 7y agoIt's a fact that Joe Blow will get sub-penny price improvement at random. I have no idea how often or how long it's been a thing, but it happens.
- 7y ago
- bhl 7y ago> Best we could tell someone was front running us due to an artificial delay for our account (delay between trades went to ~20ms up from our prior steady speed of 3-7ms) and/or a bunch of the trades in the orderbook were bogus. I wouldn't be surprised, given that traditional HFT companies are building cryptotrading desks and they have a lot more capital to play with too.
- jstanley 7y agoYou can't simply front-run someone else by having deep pockets. The only way that is possible is if you gain privileged information about that person's orders before they actually hit the book. The most practical way to do this is to be the exchange.
- traK6Dcm 7y agoOr to pay the exchange a large sum to get privileged access :)
- crazypyro 7y agoSeems they just simply could sell a faster connection and just call it an "institutional feed". Regulated financial exchanges basically do this already.
- johnvonneumann 7y ago> You can't simply front-run someone else by having deep pockets. Well you can, as was discovered in the Haim Bodek HFT shit storm.
- megaframe 7y agoRan an ML model years ago had a number of great months then out of no where no trade I or the ML would make, would work. Looked like someone was front running my orders and messing with my trades. Weird delays, trades would take to long to go through all, and all sorts of odd events on Level 2. Ended up shutting it down took a good 2 months before my manual trades started going through at a normal rate again. This is why the whole $0 trading fee and robinhood concern me. I'm paying for the trades and someone is still messing with me.
- turk73 7y agoTake it from me, they are fucking with you. There are algos out there that detect "real" traders like you and me and endlessly fuck with you on equities long/short and all options. I assume also on commodities and Forex, but have no direct knowledge. No clue about cryptos or any of that trash, but you're swimming in shark-infested waters with cryptos anyways. That stuff is all completely manipulated trash. My suggestion if you want to beat the "market" is to develop some kind of algo that can trip up other algos and cause them to show their ass and then buy that dip.
- smeeth 7y agoI think, though I'm not sure, that RH makes their money by investing in treasury bills with the cash balances of people's portfolios. You're (most likely) not getting secretly screwed.
- kmangutov 7y agoRobinhood sells order flow https://www.cnbc.com/2019/04/18/a-controversial-part-of-robinhoods-business-tripled-in-sales-thanks-to-high-frequency-trading-firms.html https://www.cnbc.com/2019/04/18/a-controversial-part-of-robi...
- elamje 7y agoContrary to popular belief robinhood makes a good bit of money from selling order data, more than most brokerages. This is due to the fact that most robinhood users are inexperienced, and thus, their trades are less likely to indicate big movements of institutional money. I.e. HFTs pay more for data that is less risky. Edit: Fun fact, the founders of Robinhood worked at an HFT before starting robinhood, which used to be shown on their LinkedIn until several years ago. Bad optics I suppose.
- alexcnwy 7y agoFascinating story, thanks for sharing! "we realized that there will always been a better resourced or more dedicated team willing to fight you for your alpha" - that's part of what makes financial markets such a fun and interesting challenge but agreed, intermediary risk at the timescales you were operating at in this kind of unregulated market is real and not fun I'd love to hear what problem you moved to that you believe you can build a long term competitive advantage on if you can talk about it?
- nickreese 7y agoMy partner and I had built broadbandnow.com and were looking for a new interesting problem to solve to get us fire up again about fun tech problems. This just scratched the itch. The team was running day to day of the other business while we worked on the HFT bot. Shortly after we realized we either should exit or hire an exec team to run the business. After a few months of executive search we found an offer we liked and took it. These days I’m interested in using some heuristics based on public data to help consumers make informed decisions about nursing homes and in home health care. Still early on this project but lots of data and not many people looking to do good in that market. Seems like a great place I can add value.
- alexcnwy 7y agoVery interesting. Your nursing home project sounds like you could definitely add loads of value - best of luck for it!
- criddell 7y agoWhat's the value of HFT? If exchanges were required to add a random delay to very trade to work against high frequency traders, would anything of value be lost?
- jstanley 7y agoIf exchanges added a random delay, that would mean traders have to plan for a longer time horizon, which means they need to offer more conservative prices. That means when you're selling, you get less money, and when you're buying, you get less stuff. Some people have this notion that if their trade got matched against a HFT that they have somehow lost out. The exact opposite is true. If the party on the other side of your trade was a HFT, then that implies that all other parties were offering worse prices than the HFT was. If the HFT had not been there, you would have got a worse price (whether on the buy side or the sell side). The presence of high-frequency traders (or any traders, for that matter) reduces spreads and increases liquidity. The only people who get worse deals as a result of high-frequency trading are people who would sell you the same stuff for more money.
- roenxi 7y agoHang on, that is conflating separate ideas. The substance of your post is describing price discovery - price discovery isn't the issue here. The issue is that the price discovery is being done in milliseconds. The substance of the complaint is the speed of the auction that discovers the price. The faster price discovery is being done, the fewer traders can participate. If a few milliseconds can change the value of a financial instrument then we have to accept that waiting a second or two will allow a lot more traders to reevaluate and offer a fair price. The HF in HFT looks like a play to reduce the number of traders who can act on information, which means the buyer/seller is probably getting scalped. HFT traders are making money arbitraging the speed of information dissemination, which indicates that other traders would offer different (/better) prices if the market waited a half-second or so to let everyone gather all the relevant data.
- growse 7y ago
- keyle 7y agoI have had a similar experience. The house always wins.