Sunday, November 13, 2022

Limit Order Book

Streaming and reconstructing Bitstamp's order book from order event data

Fri Jul 04 04:16:21 UTC 2014

In order to begin looking into market microstructure I implemented a Limit Order Book. The (very rough) implementation has 2 modes of operation:

1) It continuously reads from a stream of buy/sell order events (new order, modify order, cancel order) to produce a diabolical ascii chart of order book depth along with time and sales. (shown in the below .gif)

2) It can re-construct an order book from archived order book events. In both cases, a log file is kept from which 225 indicators can be extracted into a csv file. The intention of this project was simply to derive this .csv file for use elsewhere, hence the mess. I intend it to be a starting point for something better.

I do not have access to order data for a conventional exchange, so this implementation is based on data obtained from Bitcoin exchanges. Specifically streaming data via a websocket from Bitstamp. New (planned) implementation will abstract this away to a higher level protocol.

https://i.redd.it/879yh6rursz91.gif

Divided into 2 sections, the left hand side of the book shows the depth of BUY limit orders (bids), while the right hand side shows the depth of SELL (asks) limit orders. At the top of bid side of the book on the left is the current best bid, while the top of the ask side of the book is the current best ask. Each row is a price level, decreasing/increasing for the bid/ask side respectively.

Each level consists of 5 columns: The percentage difference from the best bid/ask (the depth), the cumulative sum of volume/liquidity up until and including the price level, the number of orders enqueued at this price level, the amount of volume/liquidity available at this individual price level, and finally, the actual price of this this level.

For example, on the bid side, an entry of: 0.42%, 157.40063272, 1, 59.68000000, 656.26, indicates that this price level is 0.42% less than the current best bid, 157.4 units of volume would need to be sold before this level is reached, there is 1 order at this level (to buy 59.68 units) @ 656.26 dollars.

Trades are shown on the right hand side, in the third column. The purpose of this implementation is to reconstruct/infer trades given a stream of bid/ask limit order events.

These trades are the result of this inference: showing the trade direction (BUY = a buy market order hit an ask limit order) (SELL = a sell market order hit a bid limit order). The implementation can sometimes match makers to takers: A maker is an order to buy/sell placed at a price limit _in_ the order book - i.e., the trader is providing liquidity, whereas a taker is an order to buy/sell that will not be placed in the order book (it will consume maker orders until it is filled) - the trader is said to be removing liquidity. As such they pay the price: the market spread + the Volume Weighted Average Price for the market impact.

As mentioned, the code is _very_ rough. However for anyone interested (it is useful for monitoring the bitstamp order book in real time), the code + a detailed description of the derived indicators is available here.

Link:

http://parasec.net/blog/limit-order-book/


Elon Musk on Crypto, Bitcoin, Ftx, Mining and Twitter. Why Crypto is CRASHING!? | LIVE EVENT

https://rumble.com/v1u5tsw-elon-musk-on-crypto-bitcoin-ftx.-why-crypto-is-crashing.html

Limit Order Book Visualisation - Multi Part Post - Part 5

Quote Stuffing

Quote stuffing, which is referred to as "one of the most visually obvious forms of HFT" in Credit Suisse: High Frequency Trading – Measurement, Detection and Response and documented extensively by Nanex, for example here: Nanex: Quote Stuffing and Strange Sequences, occurs when bid or ask orders are added and then/deleted in rapid succession. Whether or not quote stuffing is malicious or not seems to be the subject of heated debate. I'm not an expert, so I'm not going to take a one sided position on this. I'm simply interested to see if similar observations can be made in Bitcoin, and whether or not it is possible to make sense of any observed activity. If I had to guess, I would say livelock like conditions are very likely to occur in event driven code: I've had to deal with all manor of different situations with my own trading code. I would also say that while this kind of activity may most of the time be a side effect of event driven processes, I think it is very plausible that it could be used in a targeted/creative way. Either way, the fact that this activity occurs at all is interesting in its own right.

The following examples show some activity on the Bitstamp exchange that appear to mirror quote stuffing (malicious or otherwise) found in conventional markets. The first example, below, shows a 15 minute time period on 2014-10-01. Note that 15 minutes is a very long time in comparison to where this phenomena are usually observed. Nevertheless, the asking price exhibits what is referred to as a square-wave in the Credit Suisse report.

https://preview.redd.it/sassqc8t8sz91.png?width=644&format=png&auto=webp&s=0ead1f743284986dc4e0fd028af37f351796f90a

This next example, taken from 2014-10-03, the best ask oscillates quite wildly over a long period of time (~30 minutes). If this is the result of a bug, then it is a pretty serious one: the fluctuation is huge.

https://preview.redd.it/pcbrn34z8sz91.png?width=642&format=png&auto=webp&s=d80cfe97d6e0eef182ec39f215b83ae7c882962f

Zooming in to a 5 minute period shows the anomaly in finer detail. In addition, the depth map shows the fluctuating liquidity as the order is continuously added and removed.

https://preview.redd.it/bbqnq9389sz91.png?width=644&format=png&auto=webp&s=496f6f22e71f09a7e27db16a44e6731fd41be3ac

https://preview.redd.it/dsxs9aa99sz91.png?width=634&format=png&auto=webp&s=9259f8405cf95f9dcfcded1cf433046dffe24d1b

The next example, taken from 2014-10-17, shows a more interesting pattern. The ask in this case is decreasing at an irregular rate. I'm guessing that this is simply 2 or more selling algos jumping over each other. The bid side however seems to exhibit a more regular pattern: the bid increases to some level in small steps, and then resets.

https://preview.redd.it/y137x1lf9sz91.png?width=646&format=png&auto=webp&s=12d86d24ecbb4270533cfc432260fc4740e47b5b

Looking at the bid event event data, restricted to the current best bid for the same period, shows this climbing and then reseting effect in greater detail.

https://preview.redd.it/fy3nr2xk9sz91.png?width=626&format=png&auto=webp&s=34425ac2d8913f76250e35ada65c6bfff0f5db23

A slightly more interesting observation occurring on 2014-10-18. This time, reminiscent of the "sawtooth" pattern.

https://preview.redd.it/osoeradq9sz91.png?width=640&format=png&auto=webp&s=2c9d938eb9924bca1d3a156c698d6e450c6e96dd

Another square wave pattern. This time occurring on 2014-10-20.

https://preview.redd.it/jhzfv4w6asz91.png?width=644&format=png&auto=webp&s=88cd7a6afc413894d2a9f458dad3662b9f2a1882

The sawtooth pattern occurring below, on 2014-10-22 is quite interesting. If we look at the corresponding order events, not only is this pattern increasing in price, but also in volume. The aligned cancelled volume chart shows the actual amounts.

https://preview.redd.it/7q4ez0clasz91.png?width=648&format=png&auto=webp&s=193bbce6d385e5f8eb6193a6bab32a1b2dbbdc11

https://preview.redd.it/871kcwimasz91.png?width=636&format=png&auto=webp&s=0b6d5a1e2b0dcd98b3ae146d9b172323b4cba921

https://preview.redd.it/y3cw3mtnasz91.png?width=644&format=png&auto=webp&s=abd4319f794ff272f83f7a4313d79e09f9ad9b39

The remaining visualisations show various other formations.

https://preview.redd.it/q3jucjbabsz91.png?width=642&format=png&auto=webp&s=2fff5e6e3503931c40011eff080befc447afd7b6

https://preview.redd.it/mrfug30cbsz91.png?width=632&format=png&auto=webp&s=0f7a44c23a13a584d176cebf744ff3b2788f72eb

https://preview.redd.it/e1w3mzkdbsz91.png?width=638&format=png&auto=webp&s=d1568f5b69a0ade5304b89c2cefc6ef5ace4df72

https://preview.redd.it/oxsg88oebsz91.png?width=646&format=png&auto=webp&s=f2c6106923f1f63e011e467a5b9c62bf4434f9bf

https://preview.redd.it/70gkj5bhbsz91.png?width=652&format=png&auto=webp&s=a5cca01ff30c9785adfac1376469e015e94eb419


Bitcoin Hodlers: Time is Running Out to Convert Nothing into Something

Three key takeaways:

  1. For weeks, the Bitcoin market has looked propped up by the whales, especially after the recent FTX disaster.
  2. Bitcoin hodlers should strongly consider moving into gold, silver, or at least Ether.
  3. Full disclosure, I have a complicated relationship with Crypto.

An Artificial Market

I have specifically avoided writing about Bitcoin despite having strong opinions on the subject. Bitcoin is a very hot topic, and most people have already made up their minds. In short, I think it has zero value but that argument has been made many times before so I couldn’t add anything new to the conversation.

Full disclosure, I have been in the Crypto market since 2013 and am net positive. That said, given recent market events, I cannot sit by in good conscience without giving fair warning. This is not a Bitcoin is worthless analysis, this is a wake-up call to push people to ask what is keeping this market from imploding. FTX isn’t the canary in the coal mine (that was Celsius, or one of the other firms that crashed this year). FTX is the coal mine, and it just collapsed.

I think the data shows that this market is being propped up by whales. If the dam breaks it could send markets crashing. Back on Oct 31, before anything happened with FTX, I texted a close friend:

My new theory is that the whales are not trying to pump the price anymore. Instead, they are trying to stabilize the price to win back institutional investors. I have never seen bitcoin price volatility so low over a 6 month stretch in 10 years. It just totally stopped moving after an epic collapse back in June. No bounce, no continuation, no nothing. Just super tight price range even while the stock market has continued falling.

I was led to this thinking after watching Bitcoin crash in June to ~19k and then just hold. It spent the next few months consolidating while the bond and stock markets went into turmoil. See the chart below with the simple price of SPY overlaid on top of Bitcoin since 2021. You may notice how steady the orange line has been since June 21, directly after the Bitcoin crash below $20k.

Figure: 1 SPY vs BTC

Let’s compare the 30-day rolling annualized standard deviation between Bitcoin and the SPY. This chart shows the difference in volatility between Bitcoin and SPY. Notice how it has been collapsing in recent months, and Bitcoin was actually less volatile than the S&P for a brief period in October. Since when is Bitcoin less volatile than the S&P 500? That has quickly reversed since the FTX fiasco.

Figure: 2 Volatility/Standard Deviation

However, while price volatility is falling, trade volume is not. The next chart is the 30-day rolling average trade volume of Bitcoin compared to the price. Once again you can notice a misalignment. As volume was steadily increasing over the last several months, the price stayed in a tight range.

Figure: 3 Price and Volume

Usually, large changes in volume are accompanied by large moves in price. But in this case, volume was moving up steadily while the price stayed nearly flat. How and why was this happening?

As I alluded to above in my text to a friend, this looked like an artificial market. The market nearly collapsed back in June and then just flatlined near 20k. That doesn’t happen, especially in Bitcoin. After this past week though, I am now convinced this market is being artificially propped up. After all, 27% of the market is dominated by a super minority of less than 0.01%. They have a major vested interest in keeping this market inflated. I think the increased volume against stable price action is from whales defending the price and painting the tape.

I won’t rehash what happened with FTX this week (there are 1,000s of articles explaining the epic collapse). Instead, I will just highlight that this is a MAJOR event in the Crypto space. To Crypto, this would be like 3 Enron happenings all at once, or Enron and Madoff happening in the same weekend. This is catastrophic on every level, but the price of Bitcoin only fell by about 20%. What?!?

In the stock market over the past several weeks, companies have been reporting disappointing earnings at a frequent clip. Each company has been absolutely punished for it. Some have fallen 20% or more in a single day which is extremely rare. These are bad earnings for major corporations that still have revenue. Yet Bitcoin has its Enron + Madoff moment and the price of Bitcoin drops by the same ~20%?

No way! I am not buying it!

Step back and think about this for just a moment. Take another look at the charts above that show how the price volatility collapsed despite steadily increasing trade volume. Most importantly, look at the recent massive spike in trade volume from FTX and the relatively minor price drop.

Head over to SchiffGold to keep reading and see the analysis on GBTC premium/discount


Why is bitcoin dipping so hard?

New to cryptocurrency and was wondering what events led to bitcoin dipping. Might be conspiracy theory but i believe that governments and larger corporations are spreading fear about bitcoin to lower its price so that they can buy a lot of it at a discount price. After all i cant see a future where bitcoin isnt one of the strongest currencies.


Is the EA movement dead?

No.

To be clear, I am not “an EA person,” though I do have sympathies with considerable parts of the movement.  Most of all it has struck me, as I have remarked in the past, just how much young talent the movement has attracted.  Money _enabled_the attracting of that talent, but I never had the sense that the money was _the reason_why the talent was showing up at EA events.  So a less well-funded EA movement still will be potent, at least assuming it gets over the immediate trauma.  That trauma may even help to drive away some of the less serious poseurs who thought EA was the easiest path to polyamory, or whatever..

Intellectual movements can be quite influential on small sums of money.  What exactly was the budget for the Apostles?  Or take libertarianism, which arguably saw peak influence in the last 1970s and early 1980s, when it was much less well funded than in later times.

How much money did the Benthamites have?  Nonetheless they influenced policy a great deal.

As a side note, Open Philanthropy spent over $400 million in 2021.  I know zero about their plans, but I don’t see any reason to think they will be unimportant in the future.  That is plenty of funding right there.

A mere month ago, I witnessed the game of young people sitting around, speculating how many future billionaires will be attracted to EA.  Probably that number has fallen, for reasons related to the current bad publicity, but I don’t see why it has to have fallen to zero.  The next set of billionaires might simply choose a different set of labels.

I do anticipate a boring short-run trend, where most of the EA people scurry to signal their personal association with virtue ethics.  Fine, I understand the reasons for doing that, but at the same time grandma, in her attachment to common sense morality, is not telling you to fly to Africa to save the starving children (though you should finish everything on your plate).  Nor would she sign off on Singer (1972).  While I disagree with the sharper forms of EA, I also find them more useful and interesting than the namby-pamby versions.

Tyrone knocks at the door: “Tyler, you are failing to state the truth about SBF!  He did_maximize social welfare!  And sacrificed himself to that end.  What indeed is Christ without Judas?  Judas sacrificed _his reputation.  So did SBF.  Now the jump-started EA ideas will live on for eternity.  And those who hold crypto through Caribbean exchanges are about the most deserving losers you can think of.  Those assets did not represent social value anyway.  And isn’t discouraging_crypto investment _exactly_what we _should be doing?  (SBF is good for the environment!)  And you need a celebrity example of wrongdoing for that lesson to stick, not just a few random price drops for bitcoin.  He is surely a true angel…”  At which point I had to ask Tyrone to leave the penthouse and shut his dirty mouth…he is not a valid boy!

The post Is the EA movement dead? appeared first on Marginal REVOLUTION.

        [

Comments

](https://marginalrevolution.com/marginalrevolution/2022/11/is-the-ea-movement-dead.html#comments) - What is EA?by Tomas - Is “valid boy” a reference to Caroline Ellisons tumblr?by David - Money enabled the attracting of that talent, but I never had ...by So Much For Subtlety - Plus, on expected value terms, he might still have had the ...by A

Related Stories