Introducing Bitwyre Dark Pools

After our small stint starting a payment processor in Jakarta, we realized that the next steps of the development of the cryptocurrency financial infrastructure would be:

  1. The creation of cryptocurrency spot markets — We have seen crypto exchanges springing up around the globe, from Mt. Gox to more sophisticated ones such as Bitstamp, Coinbase, Kraken, Poloniex,
  2. The creation of cryptocurrency derivative markets, which would be used to hedge or speculate on the volatility of cryptocurrency pairs. These exchanges are around today such as Huobi, BitMEX, Bakkt, OkEx, Ftx, Deribit, and Binance Futures. Both the spot and derivative cryptocurrency market are important for the process of price discovery by market participants.

Circa 2014, we thought that building a crypto exchange from scratch would not be such a hard thing to pull out. There should be some code online that does this already right? Clone a Github repository, run a bash script and spawn a crypto exchange within minutes.

Our assumption turned out to be gravely wrong. Not only we didn’t find any ready-to-spawn infrastructure, we also found out that building an exchange requires knowledge spanning from multiple distinct fields, such as game theory (mathematics), algorithmic and data structure (computer science), and market microstructure (finance) with various challenges and incomplete information everywhere. To explain to you what the challenges are, let us briefly explain to you how would you build a financial exchange from scratch on another post. It would be too long to explain here.

The Economics of Open-Sourcing a Financial Exchange

Pun intended you can check why you sho\uld not open-source a financial exchange on Google. It does NOT make sense economically to open-source a financial exchange whatsoever because of the high-gains of running and building one. NASDAQ’s revenue had a 13.69% increase year-over-year since 2005–2019. You can also check other non-equity exchanges such as CME, Hongkong Exchange, Eurobourse. The financial information of those exchanges is publicly accessible. Our previous explanation regarding technicalities into building an exchange also translates into a higher cost of building one from scratch, thus reduces the probability that one entity to open-source one. Why just give all this very hard technical and optimized (C++ or Rust code) for free? While also if you have the code you can technically sell it to another exchange or run an exchange yourself, right?

One valid reason to open-source an exchange is algorithmic fairness. This has been a topic hot recently in the field of artificial intelligence as many automated applications have impacted our lives. But in the financial world, this has been a problem since the first electronic exchange has been built. Having our codebase open-source would allow the open-source community to check our the correctness of our code collectively. This would allow standardization of exchange practices around the globe as well as government algorithmic audits on code that would impact people’s lives.

That would be correct when our world still has fiat money that is in current terms, paper money, a medium of exchange that we conduct by hand or by the latest a central-authority, such as a bank would guarantee the safety of electronic payment transactions over the internet.

Now here’s the thing. We are starting to see mass adoption in cryptocurrency starting from the top down instead of bottom-up. Bitcoin was the first experiment to trying to build a currency where borders do not matter. Ripple, Stellar, Monero, Zcash. Stablecoins springing up too with also Facebook taking in on the action. Heck, they are now scrutinized because of it. President of the Federal Reserve Bank of Philadelphia, declared that central bank digital currencies “are inevitable,” while the PBOC is rumored to build the digital Yuan.

We cannot deny that soon the world will embrace crypto as a medium of exchange, either in the form of a digital dollar, digital yuan, digital Euro, or even Bitcoin or Monero. In the scenario that will happen, the need for having a digital asset exchange would be massive. It will be essential as the functioning of a commercial bank right now. We put an analogy of building an exchange right now like building a bank in the 1915s, you have not known yet that cryptocurrencies will be the future standard medium of exchange and reserve currency, but if it will, the upside of that would be huge.

Wall-street Institutional-Grade Technology for the Masses

Running a high-grade exchange system might not be the everyday purpose of digital computers that we have at home. We do believe that the main exchange or supernode would be needed to be run on a dedicated high-grade instance. Other smaller exchanges such as darkpools we believe can be run on a single MacOS X machine connected to the internet.

We built these so-called darkpools, or what Wall Street calls internal crossing facilities or internal matching facilities, available to the masses as an open-source solution. If you’re not familiar with how a darkpools work, let us give you an illustration of an order sequence sent to a darkpool and a supernode.

So a darkpool is basically like other crypto markets BUT with the volume information hidden from the user. In that case, a client when shooting an order doesn’t know the volumes shown on each price point.

The Order Routing Problem

Say Bob and Alice are trading in the market. On the supernode the orderbook looks like this:

Where the first column consists of quantity and the second one is price. You can see the BID is sorted via ascending order, while the ask is sorted by descending order. In a darkpool instead what you will see is this.

Now here comes the tricky part. Imagine now there’s more than one market, say 1 supernode and multiple darkpools. Where each darkpool could submit orders to either 1) the supernode 2) and other darkpools. What is the best order routing mechanism to ensure the lowest liquidity impact?

For example, since market dynamics, we know that this is a graph problem. The nodes are either the darkpool or the supernode. The loss function is the LIQUIDITY quantities at the designated edge. The action is the order with the properties above. The state is the orderbook state at the edge, the next state is the orderbook AFTER the action has been taken. Given all that, how do you ensure the loss function which is the liquidity of the edge is still minimized given sequential orders.

Given a sequence of order, we define an approximate function that learns the best way to submit order with the minimum liquidity impact. The unmatched orders then gets rerouted to multiple dark pools around the world by splitting the orders into small ones that is routed by optimizing for the highest probability of matching or rerouted directly to the supernode.

Our darkpools repositories are live on You can do a git clone [email protected]:darkpools/darkpools then do a ./ setup then ./ up. We are also continuously improving darkpools. Contributions welcome!

Arise, you have nothing to lose but your barbed wire fences!

By the team. Dendi Suhubdy, Yefta Sutanto, Aditya Kresna, Aditya Suseno, Mathdroid, DrSensor, Genevieve Brechel, Faza Adiguno, Yosafat Pangalela, Joel Poulin, Sonkeng Maldini.

Special thanks to John Schwall who has been inspiring us during the journey building this open-source financial exchange infrastructure. Shout out to Josh Levine, Gary Basin, Zachary David, Ezra Rapoport, David Senouf, Eric Charvillat, Stefan Cheplick, Byrne Hobart, Remco Lenterman, Dan Shaw, Themis Sal and Alexy Khrabrov for inspiring us during the design of our electronic exchange network. Also MILA friends, Sai Krishna G.V, Alex Fedorov, and Florian Golemo for their discussion on the order routing problem using deep reinforcement learning.