Information on multi leg IOC orders

In case of multi leg IOC orders, how does exchange ensure correct or nil execution? For eg. I am doing a short roll in RIL futures and enter 50 bps as my limit IOC order. How does the exchange ensure that I get fills at 50 bps or better but never worse? Suppose by the time my order reaches the exchange, one leg has moved while the other is at the same price, then how does the exchange ensure that only one leg doesn't get filled?

In case of multi leg IOC roll orders, what will be the secret to get maximum fills bcos there will be so many participants looking to roll at say 50 bps and everybody's OMS fires an IOC order after seeing the opportunity. Will only processing time and network latency (assuming everybody has a Co-location server) determine who gets the fills or there could be any other way to get max fills

For the first part - IOC is not a guarantee of execution. It can have partial fill and can be cancelled with no fill. Exchanges usually ensure fill in proportion of the legs (e.g. 100 buy and 400 sell can be broken as 10b/40s or 5b/20s etc and rest cancelled). With these, and the fact that exchange itself is doing the order matching, it is relatively straight forward to implement an IOC (more complicated to implement an efficient one). I have no idea about the exact algo, but the most basic stuff will be - take the thinnest slice of all legs in proportion (in the above example, 1b/4s) and see if all can be filled. If yes - fill. Continue for the rest. If cannot fill at any step, cancel the rest of the orders and stop. On the other hand, if the exchange does not support IOC natively, and you plan to offer this yourself to your clients, it will be much more difficult to implement. You will have a hard time (and unhappy customers) in a volatile market.



For the second part - If you are placing a crowded order (multi-leg in your roll or otherwise) you are expected to get either a bad fill or a bad price. I would assume most market participants (with positions that matter) would be already wise enough to avoid this (e.g. rolling over a period). I would guess usually you do not deply HFT to execute a regular roll.

I understand that IOC is not a guarantee of execution but atleast there is a guarantee that if executed there will not be any slippage. We do deploy colo servers to execute roll orders (not while rolling in roll window but while doing rolls by bidding in one leg and then executing the other leg once the first leg is executed or doing IOC limit roll orders).

Also, it is obvious that the market participants are not wise enough to roll over a period as you would have noticed that more than 90% of the rolls happen in the last 4 days of expiry. Also, many times if we are short rolling and the best offer in roll window is at say 40 bps but bidding in normal window or putting multi leg IOC limit orders might fetch us even 45 bps.

So, questions are:

1. In case of multi leg IOC roll orders, what will be the secret to get maximum fills bcos there will be so many participants looking to roll at say 50 bps and everybody's OMS fires an IOC order after seeing the opportunity. Will only processing time and network latency (assuming everybody has a Co-location server) determine who gets the fills or there could be any other way to get max fills

2. If as per you, the exchange slices the orders and decides whether both legs can be filled, isn't there a chance that the order book moves during the time the exchange's algo does this work? But 100 out of 100 times we either get fills at the limit specified or no fills (even in times of huge volatility in spreads or stock prices). How does the exchange mitigate this risk? 

3. Many times we have seen that suppose I am short rolling Reliance Inds at 50 bps, I get fills in IOC orders and not in regular bidding (again not talking about the roll window but the normal window). How can it happen that we get fills in IOC limit roll orders and not in bidding (again not talking about the roll window but the normal window). Is our colo slower than NSE's algo which slices orders & decides whether both legs can be filled and then hits the order?

4. You said: if the exchange does not support IOC natively, and you plan to offer this yourself to your clients, it will be much more difficult to implement. 

How can exchange prepare an infallible multi leg IOC order system and we are not? There must be some programmer at NSE's end who would have coded this piece, right? I am asking this to understand whether we can prepare a better multi leg IOC order system than what NSE has prepared - may be our algo might have 90% accuracy but if it gives more fills than NSE's algo, it may be more useful.

Let's look at #2 and #4. The exchange, having the control over the matching engine, has a distinct advantage. Searching for match and recoding them as "matched" is done by the exchange. For the rest of us, we have no direct control over actual match - we can only send/ update/ cancel orders to influence it. So even if during finding the match the market moves, the matching engine may discard the earlier candidates and simply start another search iteration. All it has to do for multi-leg orders is to ensure the "matches" are recorded simultaneously (i.e. no change in those orders during the time taken to mark all the legs matched, by for example, marking them as locked, and refusing update/ cancel). This is possible with 100% certainity as they control the matching engine and order book. 



So it is not about the programmer. It is the fact that the exchange runs the matching engine and maintain the orderbook, and not us. For us, this will be a market risk (getting a fill on one leg only, disparate partial fills etc.) in high vol regime. For exchange, this is just increased computational cost (multiple search iteration). My example of the mechanism is rather naive. Many exchanges supporting multi leg offers a separate book (e.g. complex order book at CBOE with special high freq auctions/ batch matching). It is not very clear how NSE does it.



So is it possible to develop a "better" multi-leg IOC system than NSE? If you want to stick by the definition of IOC, then answer is a clear no (we have no way to ensure the quantities of fill, i.e. ensure IOC behaviour for all legs simultaneously, operating outside the matching engine). But in other definitions of "better", it may be worth a try if you have a good predictive model of the order book and fast connection. But it can never ensure proper IOC execution of multi-leg 100% of times.



#3 actually depends on the algorithm at the matching engine - pointing towards a priority execution of multi-leg IOC or may be a different book. Actually, many possibilities can explain this observation.



Finally #1, a better algo means better reaction time and better predictive modelling. But as metioned, even with the best of execution algos, you can never ensure 100% of the multi-leg IOC behaviour as you do not control the matching engine. Then it becomes a question of risk vs reward. I think such a model can be tested against the order book data to answer how good or reliable it is.

Great… Thanks for providing the clarity. Last question:

If NSE "searches for the match and records them as "matched"" then will NSE follow price time priority?

If yes, how to achieve time priority?

Eg. If I have to short roll 1000 lots of Reliance Inds at say INR 10; should I ask the algo to roll 1 lot in IOC mechanism and once that is done take up the next 1 lot or shud I put entire 1000 lots in the algo for doing IOC rolls?

If I put 1000 lots, will the algo hit 1000 lots in NSE or will NSE pick only 1 lot if it can match only 1 lot at INR 10? The question is important bcos if the algo hits 1000 lots every time, my trade to order ratio can become very small and can invite penalties from the exchange.

And if I put only 1 lot and there are 10 other participants in the market trying to short roll RIL at INR 10 and trying IOC mechanism of execution, once my 1 lot is executed (assuming I am first in queue) will my turn come after the 10 others get the fills

I don't know where to research this. Request your help in getting a concrete answer

If you are talking about multi leg execution levy, I think it should not matter if you are placing all 1000 or 1 by 1 from this point of view. The levy I think is calculated based on trade to order ratio. So even if 1 lot is executed, and the rest cancelled by IOC feature (cancel is a feature of the order, not user initiated), it should be fine and should not not attract any levy. At least that is how it should be logically, else NSE will wrongly incentivize people to put in small and many trades - which will increase their matching costs and latency. And yes I agree, if you put 1 by 1, you may go back to the end of the queue.



Having said that, it is what I think it should be logically. The way it actually is may be different. You should consult the NSE circulars at minimum, or better still reach out to your broker or to NSE for clarification.

I tried but have been unsuccessful in getting an answer. Can you check with your sister concern IRage or any senior faculty in Quantinsti to help me with a concrete answer?

I assume you are referring to possible penalties on cancelled IOC orders on NSE. There are many things which can be concretely addressed in an online community. Regulations, by-laws and policies of an exchange is not one of them. As a start, refer to NSE circular 57/2020 (and its past references). If you are an EPATIAN, feel free to reach out to the support or alumni team. But I would strongly suggest to get the clarification from your execution broker (in case you are not an exchange member), or the exchange (in case you are a member).