# Tag Info

37

The specifics depend on if you're implementing for equities (order-based) or futures (level-based). I recommend https://web.archive.org/web/20110219163448/http://howtohft.wordpress.com/2011/02/15/how-to-build-a-fast-limit-order-book/ for a general overview of a good architecture for the former. Building off of that, though, I have found that using array-...

14

Why do people suggest using red black trees/balanced binary trees for the levels in a limit order book? Because people are unoriginal and keep referencing the same blog post. Why are they algorithmically ideal? They're not necessarily ideal. In fact, they're rarely used in production trading systems with low latency requirements. However, your source ...

11

You don't just simply grab some random open source order book implementation and expect it to work. Every market is different. For example, markets have different rules for how you should handle priority in the order book (some are price-time, some are price-size-time, etc). Grabbing Joe Blow's code and expecting it to just work is only going to lead to pain ...

11

Repeating groups are a way for FIX to represent arrays. A "number of" field prepends the repeating group to alert the recipient how many elements to expect. For example, Arca uses TradingSessionID (tag 336) to identify pre-open (P1), primary (P2), and post-close (P3) market hours. This group is prepended by NoTradingSessions (tag 386). So, I would use the ...

10

I recently stumbled upon this question after needing to do this to do some real-time microstructure analysis and have taken a look at the various possible implementations. Here are some of the pros/cons of each implementation (I'll use C/C++ terminology): Array: You have an array of structs ordered from top of book (index 0) to worst (index N). You have to ...

9

No, you have to build your model empirically with data. Suppose $p(x)$ denotes the probability of cancel in front of you when your order is positioned $0 \leq x \leq 1$ through the queue, there are a few trivial cases: If you just joined the queue, any reduction in depth at the level must come from in front, i.e. $p(x=1)=1$ If you are at the front of the ...

8

I can think of 3 reasons: 1) Queue position 2) To be on the other side when an alogrithm has a disastrous error, which happens quite often on singular stocks and doesn't get reported (but someone will get fined) . I've seen cases where the price will drop over 99% almost instantaneously. For this to occur a backfiring algo will clear out the entire bid ...

8

The Queue Reactive Model (by Huang, L and Rosenbaum) is an improvement of what Cont and de Larrard (CL) did. This model is capturing the inflows and outflows in each queue given the current state of the orderbook (it is one of your remark) but more importantly, once one queue depletes, the discovered quantity is not taken at random (like in the CL model) ...

8

As Alex C. notes, OHLC bars are meant to be calculated using transaction ticks. However, you could try to make bars from bid/ask individually (or perhaps even the mean of the two as an approximation), but bear in mind that they are not the 'real thing'. But assuming you acquire transaction data, there are a number of possible methods for forming OHLC bars (...

7

In my opinion, instead of developing an analytical model, it's better to evaluate this probability directly from the data. Place your simulated orders at different price levels, and check whether and when they would be executed. Then use this probability model to simulate your trading strategy. However, assuming that you want to simulate a trading strategy,...

7

Two chief reasons for subsampling or using a different event space are (i) computational or spatial tractability and (ii) denoising/signal extraction. Sergei's response seems to focus on the first issue, and I'll focus more on the latter. The two objectives can diverge. For example, options and OTC data can exhibit trade to order ratios in excess of 1:10,000,...

6

I do not know in which context you want to implement a matching engine (ME). But according to me the two nice challenges in this context are: implement one in an FPGA for simulation / fast replay purpose, design the most efficient in/out bus to put synthetic traders in front of the ME. The last point is about simulating one day in few seconds. To answer ...

6

The round-trip latency from point A to a matching engine at point B can be thought of being comprised of two components: $RTT_{total,A \rightarrow B} = RTT_{network\_transit,A \rightarrow B} + MPL_{matching\_engine,B}$ Where $RTT$ is the round-trip time and $MPL$ is the message processing latency (how long it takes to receive a message and produce an event)...

6

I am not aware on any rules preventing a too high number of entries at a limit price. Nevertheless you usually have controls for each trader id. A trader cannot have too many orders in the book or send them at a too high frequency. [EDIT] Moreover, on most trading platforms you cannot have orders too far away from the mid (or a reference price like the ...

6

A "flickering" order is one which is repeatedly submitted and cancelled (whether it's at the top of book or not). The answer from @chollida mentions that "the goal typically is to either slow down competitors quotes by flooding the gateway interface with noise" but I don't think that's necessarily true. Rather, I think many flickering quotes are caused by ...

6

Customers dont place limit orders or do they? No, they don't. In an electronic RFQ market, the requesting participant (presumably the "customer" you are referring to) is generally not obligated to show its side. This design dates back to times when you had to trade over the phone, where you would typically ask for a two-sided quote so your ...

5

It depends on your goal. Suppose we have a stock whose top-of-book quotes show far more size on the bid than on the ask. If you want the weighted mid to reflect sentiment at this moment, then certainly the market participants agree that the fair price is less than the mid. However, if you assume that these participants are informed market makers and your ...

5

I fully agree with all potential rationals written here to put bids and asks deep in the book. All these interests are part of what we should name the latent order book, since potentially agent would be glad to buy or sell at such prices in an hypothetical future. Philosophically, I would say that the more mature a market is, the less you should see such ...

5

Don't discount the fact that it could be a fund testing a strategy or order type. I do this all the time. I'll take an algo that should penny on say, VWAP, and make it penny on VWAP - \$10 to ensure that it works but if it does go a bit crazy then atleast I have a buffer before it starts going active. Same thing with order types, if I'm testing a new fix ...

5

I have heard of several allegations in the recent days, but they are mostly baseless. However, there are a rare, few trading venues whose matching rules are most often accused of giving unfair order execution advantages to certain firms. These usually arise from violations of the standard price-time priority: IEX's broker priority rule. "All orders will be ...

5

Orders stay in order book for as long as you specify, e.g. "good till cancelled" (GTC) will be sitting there until it's executed or you cancel it. There are many types, just google them - IOC, FOK, GTD, at open, at close etc. Many brokers have introduced their own, proprietary types, see e.g. Interactive Broker's list here: https://ibkr.info/video/1037 ...

5

This is somewhat of an opinion based response with some factual anecdotes at the end. Spoofing is a very difficult concept to define, identify and prove. In voice brokered markets where transactions are executed with levels of discretion, spoofing can be more readily identified by people refusing to commit to trades with insufficient reasons of cancellation....

4

Some exchanges have agreements with market makers to provide liquidity (the market makers often get some kind of preferential treatment in return). Often these agreements will include obligations to be actively quoting some minimum percentage of the time, on both sides of the book (bid & offer). Quoting non-marketable prices is one way to meet these ...

4

The two types of orders are called "Attributed" and "Non-Attributed". Venues will sometimes provide incentives to encourage order attribution. For example, Direct Edge has their "Edge Attribution Incentive Program" which you can read about on their price list. I believe NASDAQ has offered incentives for attribution in the past, but I don't think they do ...

4

Yes. Increasing the size of an order is like cancelling and reinserting it. You lose queue priority and insert behind the other orders.

4

You are usually given an option to either - Request a re-transmission of the messages you missed (through a different channel). Request a snapshot of the current book from a dedicated server. Both are likely TCP based.

4

One way to do this is a simple Monte-Carlo simulation. There are formulae you can use to get the likelihood of a stock being below a price if you know the stock's volatility and time frame - see for example this question. For an unknown time frame, the Monte-Carlo method is (IMO) simpler than the mathematics. You would simply run a number of simulations ...

4

This reference price is also sometimes called intrinsic price. One of the simplest ways to improve it in regards to the mid-price (assuming you have the depth data) is the following: define a parameter: the size of a hypothetical market order. Let's say it's about the typical sum of first 3-10 order book levels of the instrument; execute a Buy order with ...

4

Liquidity seeking is difficult to test empirically since price only data tells us nothing about the how transactions related to the level 1 (NBBO) order book, let alone the depth of the order book. The method I use to locate hidden liquidity (e.g., iceberg orders) for illiquid securities involves crossing the bid/ask. While crude, it has allowed me to ...

Only top voted, non community-wiki answers of a minimum length are eligible