Queue Position

Sell the highs, buy the lows, take their money, bash their nose.
User avatar
ronin
Posts: 0
Joined: Thu Jan 01, 2004 12:00 am

Queue Position

Post by ronin »

I didn't really understand if this is about how to write a simulator, or how to make decisions in live trading.



For a simulator, you can have an external simulation parameter to control which proportion of cancellations always happen in front of you (so say 0 means all cancellations are behind you, 0.5 means each cancellation is half in front and half behind, and 1 means each cancellations is behind you). Then you can run your backtests for different values of this parameter to see how sensitive your strategy is to it.



I wouldn't randomise it as Baltazar suggested. You want your simulations to be repeatable.



In trading, I would always assume that cancellations are behind me.
"There is a SIX am?" -- Arthur
User avatar
EspressoLover
Posts: 0
Joined: Thu Jan 01, 2004 12:00 am

Queue Position

Post by EspressoLover »

> I wouldn't randomise it as Baltazar suggested. You want your simulations to be repeatable.



You could always use pseudo-random numbers from a hash function applied to the market data itself. If you want to sample over multiple random instances, just add another few bits to the hash that take an int corresponding to which Nth random instance it is. Unless the historical market data or its format is modified, runs should be totally repeatable. (Not necessarily endorsing the benefit of randomness as worth this effort, only pointing out the option).
Good questions outrank easy answers. -Paul Samuelson
Lebowski
Posts: 0
Joined: Thu Jan 01, 2004 12:00 am

Queue Position

Post by Lebowski »

@HockeyPlayer, first of all I love your name. I played juniors throughout the U.S. and Canada briefly for a couple years and now captain my school's admittedly lackluster club team.



I've wrestled a lot with what the actual quality of my data is. The problem is that the data I have doesn't come from any of the same timeframes as the CME DataMine example files, which are all from before MDP 3.0, so that I really have nothing in the original FIX/FAST multicast format to compare to. My data is from Nanex, so worse yet than your number of orders example, they don't even include tag 346 in the data they distribute. I did speak with their support to confirm that they do unbundle updates correctly if that's what you're referring to. They also maintain they send every update, but I admittedly haven't verified that. I'm aware of the fact this may not be exactly the data I'd be getting if I recorded noncoalesced data directly off the switch, but bare with me...I'm in undergrad and this is really an academic exercise more than anything else at the moment. It's not as comprehensive as tag 346, but I still track what I think the number of orders is by trying to match the sizes of cancellation with uniquely sized additions. This is a problem for two reasons.

1. It only knows the number of orders added after a PriceLevel comes into the sliding ten level view.

2. It really breaks down to the point of probably being highly inaccurate for partial cancellations because I have no way of knowing if a one contract reduction in the depth is a cancellation of an order for one contract or if it's a partial cancellation of a larger order.

For these reasons, I don't really put too much stock in this estimate.



Once I have some live trades, I'll definitely go back and compare where I get filled to my estimate. That's probably the best way to go about this.



If anyone has any commentary on the Nanex CME data quality, I'm interested in hearing it.



@ ronin. This is for a simulation I'm playing with in my dorm room. I had been operating on that worse case assumption of all cancellations being from behind me. The worst case estimate was really a problem for me because I was playing with a market making idea which obviously involves quoting both sides. So if I used the worse case, I would have the possibility of getting filled on one side without knowing it conclusively in my backtest. I found this to be too worrisome of a potential oversight, so I kinda changed my approach to taking liquidity to enter and then only adding liquidity to exit. This way, my worst case is in fact really my worse case scenario. No Backtest is perfect and there's still the butterfly effect, but I think this approach has much less uncertainty.



@espressolover, yeah I could definitely seed the psuedorandom using the timestamp from the market data, but as stated, I think quoting both sides introduces too much uncertainty. I'm still interested in potential ways to estimate queue position though. Thanks for your input.
User avatar
ronin
Posts: 0
Joined: Thu Jan 01, 2004 12:00 am

Queue Position

Post by ronin »

@espressolover, you would then have to estimate what happens when you change the generator, seed etc.



@lebowski, the cancellation order parameter will probably tell you something like "your strategy works if more than 60% of cancellations are in front of you, and it does not work otherwise". Which means that it does not work in reality. If you get it to work when reasonably less than 50% of cancellations are in front of you, then you have something. You still have to work out how to manage your orders in order to achieve that in reality, which you can only do when you see how people actually react to your orders.
"There is a SIX am?" -- Arthur
Lebowski
Posts: 0
Joined: Thu Jan 01, 2004 12:00 am

Queue Position

Post by Lebowski »

@ronin I think you're right that to make my first approach (quoting both sides) work, I'd need to make some assumptions about the distribution of cancellations. My intuition is that the % necessary in reality is way lower than 50%, because my limit order has intrinsic value > 0 (else it would have been cancelled) and since I have the highest cost structure possible for anyone making a market, that means everyone in front of me in the queue has positive intrinsic value too, so they most likely would only cancel if they got filled in a highly correlated asset first.



I have a lot of questions about how people will react to seeing my order. I think it could potentially be one of the biggest oversights in my backtest. It's another reason I went back to the drawing board on the straight up MM approach. My new idea (I'd be shocked if no one else has thought of it) is to leave my limit order tactically far away from the current midprice price but still within the ten sliding window to try to jockey for good queue position. I'll then use a marketable limit to enter if things still looked good when the midprice got near my order and hopefully close out with the aforementioned layered limit order. My thought process was that a small limit order a ways away from the midprice will have less of an impact than if I join the newly created queue on one side of a new midprice as soon as it gaps (which is what I would need to do to quote both sides). Hopefully, this mitigates some of my speed handicap as well, because entering the new queue is one of the low latency tasks I'd be at a disadvantage on because I would want to beat the more sophisticated MMs at their own game to get that queue position. The drawback of this approach is that I now have a directional bias I need to come up with some prediction for. The marketable limit will probably have a greater "butterfly effect", but because it's marketable and my queue position on the exit is already locked in, I'm not sure how much other participants reacting is gonna matter. Am I correct in my understanding that I can't get slipped on a marketable limit as well?
User avatar
ronin
Posts: 0
Joined: Thu Jan 01, 2004 12:00 am

Queue Position

Post by ronin »

@lebowski, I think you are getting a bit too esoteric with this.



When you place passive orders, you add liquidity to the book. When you cross the spread or cancel orders, you take liquidity out of the book. If you are a relatively small portion of overall liquidity in that time frame, your impact will be small. If you are not, it will be large.



There is a fair amount of literature on the topic of market impact. Here is a set of Jim Gatheral's slides which gives a nice overview. There is also a well known French hedge fund which publishes a lot of papers on the topic of impact.



To look at your example, it is easier to hide in deep book because it is deep and it is easier to be a small part of it. But that does not mean that anything you do in deep book is safe.



For example, say your strategy is to put a passive sell for 1001 shares 5 levels inside the ask, then buy 1001 shares aggressively and wait for the market to hit your ask.



If you are very predictable with this, at one point somebody will work it out. Then, when they see your 1001 share ask, they will know that there is an aggressive buy on the way for 1001 shares. So they can buy 1001 shares, wipe out a level or two on the ask, chase the market up a bit, then sell you those 1001 shares a few levels higher than they bought it.



That only really works if your 1001 shares is "large" in some sense, so it is really the same thing.



So if there is any piece of advice on minimising market impact, it is "be in line with the market and randomise your orders a bit".
"There is a SIX am?" -- Arthur
User avatar
radikal
Posts: 0
Joined: Thu Jan 01, 2004 12:00 am

Queue Position

Post by radikal »

Both grabbing Q on newly forming price levels and grabbing queue on far away levels is highly speed sensitive. Generally the far away game is locked down by GTC game shenanigans or slamming orders on session opens/re-opens. Grabbing Q on "newly forming" levels I'm not sure the state of anymore on CME -- used to be probe striping across i-links; but if fills are now being held to allow MD to outpace, I'd assume strongly correlated products are going to be more relevant. I'm a little worried about the future of some of these businesses given the evolving regulatory situation though...(Is any of this "manipulation"?)



In simulation, I usually have both random and non-random cancellation logic (for in front vs behind) as it's pretty easy to just add a flag -- that said, I basically never use the random-type stuff in sim because you end up needing to run 100 sims on each inner loop to "sample" your results and my simulators are always too slow for that to be feasible if you're optimizing (read overfitting) a bunch of parameters. Might as well put it in so you can fit in with the bayesian cool kids.
There are no surprising facts, only models that are surprised by facts
Lebowski
Posts: 0
Joined: Thu Jan 01, 2004 12:00 am

Queue Position

Post by Lebowski »

First of all, without sounding too thankful, I just want to say I appreciate the quality of the input I'm receiving here a lot. Nowhere else on the Internet can I ask these sorts of questions and have actual knowledgeable practitioners line up to help me out without any guarantee of me being able to help you out in the future. That's a huge credit to this site's community. Thanks.



@ronin, I'll check out Gatheral's market impact stuff after class this afternoon, thanks for the recommendation. As I'll probably be adding and taking liquidity in clips of 1-10 for most contracts, I hope that your guidance of hiding in plain sight holds true. First of all, I know from my own attempts to model queue position that it's really hard to deanonymize small orders because there are several of them in the queue usually. I'll be sure to be wary of adding a unique size that would blow my cover and just being obvious as a motif in general.



Question: given my small size, what are the chances that someone is gonna bother playing elaborate games in the book against me? I suspect that a really small order just isn't worth the costs of trading incurred wiping out levels. I also suspect that the likelihood of someone attempting this is a function of both my size and how obvious I make my hand. Here's where I'm gonna get esoteric again: if someone is going to be intentionally wiping out levels to come get me, shouldn't I be mindful of someone with my same idea showing their hand and causing other traders to run a similar strategy to wipe out levels? If the risk of me showing my hand is high, then I feel like I must also be cognizant of the risk of even bigger players showing theirs...again, this is all gonna get pretty complicated past some point.



@radikal can you elaborate on some of the issues I may face trying to get queue position far away from the the midprice? I understand that I'm not the first person to have the idea of layering limit orders, but if you just look at the shape of the book, a lot of the time (especially in less liquid stuff), you can get in pretty good queue position relative to the guys who jump on as a level gets closer to the midprice on further out levels without worrying about speed at all. I wasn't really anticipating seeing a major speed issue when layering the limit orders, my concern was more how to place them tactically because of the Efficient Messaging Program limits. My understanding was that the shape of the book was kinda similar to a gamma distribution (k > 1). Is this understanding of the shape of the book accurate? It may not hold for ES for example, but I think I've observed this in less liquid stuff.



It seems like a lot of folks are using or at least entertaining this random cancellation idea. Taking this random idea a bit further, as @hockeyplayer suggested, I will hopefully have some live fill data someday to help me estimate the distribution of cancellations so that I can sample from it. I may even get fancier and make this model conditional on the size and whether it was a modification or a full cancellation (from tag 346 if I ever get it).



Additionally, I'm trying to "de-aggregate" the queue to the best of my abilities to create something more like L3 by using a list at each price level. So instead of just calling a price level a Price, Size, and Timestamp, I'm also storing a list of all the updates taking place at the level. I store the type of update (trade taking liquidity, cancel taking liquidity, or quote adding liquidity), size and timestamp for each update in said list. Maybe this information will come in handy even if it's difficult to deanonymize orders. One major folly is that I have no information on the orders at the PriceLevel before it comes into view other than average size (Size / number or orders).
User avatar
TakeItAndRun
Posts: 0
Joined: Thu Jan 01, 2004 12:00 am

Queue Position

Post by TakeItAndRun »

Lebowski wrote "I have a lot of questions about how people will react to seeing my order."



If the P&L of the strategy is positive, the market will react for sure and the strategy will become less efficient.

If the P&L of the strategy is negative, nothing changes and the market welcomes your arrival.
a路径积分
Posts: 0
Joined: Thu Jan 01, 2004 12:00 am

Queue Position

Post by a路径积分 »

"If anyone has any commentary on the Nanex CME data quality, I'm interested in hearing it."



: Never heard of Nanex. Taking a look at their API it looks like it was done by a bunch of amateurs. Synchronizing to an atomic clock with a precision of 25 mills?

: http://nxcoreapi.com/doc/struct_NxCoreSystem.html
Post Reply