This question is disturbing me.... regarding order matching

#11
Some links to read in to understand the questions a bit better:

Day Trading Basics: The Bid Ask Spread Explained: http://vantagepointtrading.com/archives/13382

A Crash Course in Commodities: http://www.ftpress.com/articles/article.aspx?p=1436919&seqNum=6

What You Can Learn From the Bid-Ask Spread: http://michaelsincere.com/what-you-can-learn-from-the-bid-ask-spread/

The bid and the ask price in options trading explained: http://www.options-trading.com/bid-price-options-trading-explained/

Order (Price Type) Explained – Market, Limit Orders and the Like: http://investing-school.com/definition/order-price-type-explained-market-limit-orders-and-the-like/

Matching Orders: http://www.investopedia.com/terms/m/matchingorders.asp

Which are the order matching algorithms most commonly used by electronic financial exchanges?: https://stackoverflow.com/questions...thms-most-commonly-used-by-electronic-financi

Hope it helps, all the best and take care / Dan :)
Thanks, I will go through each of them.
 

mastermind007

Well-Known Member
#12
What you've missed are two critical factors and I am surprised no one else pointed these out !!

1) Matched orders do not show up in the Bid Ask Columns.

2) Precise Time at which the Order arrived. Time of arrival is lot more important than the actual price set as limit.

Essentially, price matching follows a pre-defined algorithm (one term people often use is round-robbin, but it is not 100% accurate term)

Idea of order matching is to satisfy needs of buyers and sellers. You can visualize this as two separate queues but a common token system. Those who come before get lower token number and lower the token number, higher the priority.

So, if Buyer 1 came with limit price of 105 followed by Buyer 2 with limit price of 103 followed by seller with limit price of 103; Order would be matched at 103 between Buyer1 and Seller 1. If Seller had some quantity left over after having fully filled the order of Buyer 1, the system would attempt to fill order of Buyer 2 at 103 .

Conversely. if Seller 1 came with limit price of 103 followed by Buyer 1 with limit price of 105 followed by Buyer 2 with limit price of 103; Order would be matched at 105 between Buyer1 and Seller 1. If Seller had some quantity left over after having fully filled the order of Buyer 1, it would attempt to fill order of Buyer 2 at 103.

In first scenario, "or better" phrase (used in limit order definition) got weighed in favour of Buyer 1. He got something for 103 for which he was willing to pay up to 105.
In second scenario, "or better" phrase got weighed in favour of Seller 1. He managed to sell something for 105 for which he wanted at least 103.

Of course, the above is very basic, very primitive explanation of matching logic and this version is not fraud-proof. There are too many ifs and too many buts added to achieve that.

Only unmatched orders end up in snap window
 
Last edited:

TradeOptions

Well-Known Member
#13
I have a doubt which is haunting me since several days. I hope somebody with clear basics can help me out.

This is regarding limit orders and order matching. As I see, limit order is defined online from several sources as "An order to buy or sell stock at a specified price. The order can be executed only at the specified price or better."

I will ask this question with an example
Lets consider the following limit order book


----BID ---------- ASK----
(buyer 1)105.0 (seller 1)103.5
(buyer 2)104.0 (seller 2)105.0
(buyer 3)103.0 (seller 3)106.0
(buyer 4)102.0 (seller 4)107.0
(buyer 5)101.0 (seller 5)108.0
(for simplicity sake assume order quantity is same for all buyers & sellers)


Now here goes my questions. Please try to answer all 3 of them since they all are very closely related and each answer affects the answer to another question


1. How will the order matching happen. Will it be (buyer 1 with seller 2) or (buyer 1 with seller 1)

2. If you say matching will be (buyer 1 with seller 2) then why does a limit order definition says order can be executed at your limit price or better? In what scenario can this execution at better price exactly happen?

3. if you say matching will be (buyer 1 with seller 1) then at what price will the trade be executed- 105 or 103.5. if you are saying 103.5, then wouldn't it eventually imply that any limit sell order practically can never be executed at higher prices even though its definition says so?
You got it right about the limit order. But think you made a mistake with the spread.

This is how it should look like

----BID ---------- ASK----
(buyer 1)105 (seller 1)106
(buyer 2)104 (seller 2)107
(buyer 3)103 (seller 3)108
(buyer 4)102 (seller 4)109
(buyer 5)101 (seller 5)110

The bid/ask you quoted is wrong as buyer is willing to pay 105 and seller is at 103. Even supposing this were to be the case then the trade would get executed at 103 i.e at limit order or better.

In the spread i have quoted, the price has to match. Either the seller or the buyer has to blink. Note that its the highest bidder and the lowest seller will be matched.This should answers your questions.
What you've missed are two critical factors and I am surprised no one else pointed these out !!

1) Matched orders do not show up in the Bid Ask Columns.

2) Precise Time at which the Order arrived. Time of arrival is lot more important than the actual price set as limit.

Essentially, price matching follows a pre-defined algorithm (one term people often use is round-robbin, but it is not 100% accurate term)

Idea of order matching is to satisfy needs of buyers and sellers. You can visualize this as two separate queues but a common token system. Those who come before get lower token number and lower the token number, higher the priority.

So, if Buyer 1 came with limit price of 105 followed by Buyer 2 with limit price of 103 followed by seller with limit price of 103; Order would be matched at 103 between Buyer1 and Seller 1. If Seller had some quantity left over after having fully filled the order of Buyer 1, the system would attempt to fill order of Buyer 2 at 103 .

Conversely. if Seller 1 came with limit price of 103 followed by Buyer 1 with limit price of 105 followed by Buyer 2 with limit price of 103; Order would be matched at 105 between Buyer1 and Seller 1. If Seller had some quantity left over after having fully filled the order of Buyer 1, it would attempt to fill order of Buyer 2 at 103.

In first scenario, "or better" phrase (used in limit order definition) got weighed in favour of Buyer 1. He got something for 103 for which he was willing to pay up to 105.
In second scenario, "or better" phrase got weighed in favour of Seller. He managed to sell something at 105 for which he wanted at least 103.

Only unmatched orders end up in snap window
In my view, Riskyman and mastermind have already explained the Concept and somatung has provided links with good info.

In your case the mistake that you are making is that you are creating or cooking up an order book which is practically wrong in the first place and then you are basing multiple questions on that wrong order book. This approach will only confuse you more. In my opinion, if you want to study and understand the concept better, then you should start with REAL Examples with Correct Order Book data and then think about various possible scenarios of order matching etc. If you start with a wrong order book in the first place, then everything else based on that wrong initial data, is going to be more confusing.

If there is an "Ask" of 103 already present in the system, then the "Bid" of 105 will never show up in the order book. Depending on the quantities available on the both sides, the order will get filled instantly. It will not show up in the order book.

Regards
 
#14
Thanks to equinox, somatung, riskyman and mastermind. You all unanimously answered the same thing and I am going to accept all of your explanations. I have now understood exactly what I needed to.

In my view, Riskyman and mastermind have already explained the Concept and somatung has provided links with good info.

In your case the mistake that you are making is that you are creating or cooking up an order book which is practically wrong in the first place and then you are basing multiple questions on that wrong order book. This approach will only confuse you more. In my opinion, if you want to study and understand the concept better, then you should start with REAL Examples with Correct Order Book data and then think about various possible scenarios of order matching etc. If you start with a wrong order book in the first place, then everything else based on that wrong initial data, is going to be more confusing.

If there is an "Ask" of 103 already present in the system, then the "Bid" of 105 will never show up in the order book. Depending on the quantities available on the both sides, the order will get filled instantly. It will not show up in the order book.

Regards
Thanks for your input.
Like I said before, I cooked up that order book for the sole purpose of allowing live matching. It was supposed to be representative of what happens at the stock exchange level(where real matching occurs) and not the order book which we see on our domestic trading terminal.
Just think retrogradely and you will realize that its counterintuitive to explain concept of matching ( + matching at better price) with an order book of only unmatchable orders!
 

vijayanscbe

Well-Known Member
#15
Find any stock or scrip or MF, which has very less liquidity. One order matching may takes few minutes to hours, In Long far month options one order matching may takes days to weeks :lol:

If you observe those scrip's order book in live, you can understand practically :thumb:

 
#16
@True_promote

Here a little add to your thread and how it is done over here:

Matching

In order for a transaction to take place at the Exchange, the buyer and seller first have to agree on a price. Matching describes the Exchange System's process of collecting entered orders and generating transactions. Transactions are generated in accordance with a certain algorithm. If at least one order is available on the other side and the limits, if any, correspond, the new order is matched with and executed against the best and oldest offer on the other side. This continues until the entire order is executed or there are no more suitable orders.

Matching rules

In on-Exchange trading, the pricing of all orders is performed according to identical pricing rules set out by the SIX Swiss Exchange (the so-called "matching rules"). On the basis of these standards, the electronic Exchange System calculates the opening prices, the prices during continuous trading and the closing prices of all securities.

Price-time priority

Before the matching process starts, the entered buy and sell orders are arranged or prioritised according to price-time priority on both sides of the order book. Specifically, this means for the

buyer: market buy orders are executed first, followed by limit orders (from the highest limit to the lowest).
Seller: market sell orders are executed first, followed by limit orders (from the lowest limit to the highest).
Next, orders placed at the same price are executed according to the time of entry (time priority).

Matching rules for auctions

The Exchange periods that precede and follow continuous trading (pre-opening, opening, close of trading and post-trading) are called "auctions". They differ from normal trading in that no actual transactions take place. Orders that exist or are entered during these periods are subject to fictive matching in the order book. This allows continuous calculation of a theoretical price which is then used as the opening or closing price.

Matching rules for continuous trading

During trading hours, transactions are concluded on an ongoing basis. Orders and partial orders that cannot be executed immediately are executed according to time-price priority in the order book. The price of the last transaction (trade price) is used as the reference price for the next transaction. If a trade price deviates from the reference price by more than a specified amount, trading is suspended for a short period of time. The purpose of this is to protect investors against extreme price movements and prevent misuse.

Source: http://www.six-swiss-exchange.com/knowhow/exchange/trading/matching_en.html#

Further information on the topic: http://www.six-swiss-exchange.com/participants/trading/on_order/market_models_en.html

Take care / Dan :)
 
#17
I have a doubt which is haunting me since several days. I hope somebody with clear basics can help me out.

This is regarding limit orders and order matching. As I see, limit order is defined online from several sources as "An order to buy or sell stock at a specified price. The order can be executed only at the specified price or better."

I will ask this question with an example
Lets consider the following limit order book


----BID ---------- ASK----
(buyer 1)105.0 (seller 1)103.5
(buyer 2)104.0 (seller 2)105.0
(buyer 3)103.0 (seller 3)106.0
(buyer 4)102.0 (seller 4)107.0
(buyer 5)101.0 (seller 5)108.0
(for simplicity sake assume order quantity is same for all buyers & sellers)


Now here goes my questions. Please try to answer all 3 of them since they all are very closely related and each answer affects the answer to another question


1. How will the order matching happen. Will it be (buyer 1 with seller 2) or (buyer 1 with seller 1)

2. If you say matching will be (buyer 1 with seller 2) then why does a limit order definition says order can be executed at your limit price or better? In what scenario can this execution at better price exactly happen?

3. if you say matching will be (buyer 1 with seller 1) then at what price will the trade be executed- 105 or 103.5. if you are saying 103.5, then wouldn't it eventually imply that any limit sell order practically can never be executed at higher prices even though its definition says so?
To answer this question one has to understand how the order matching is done.Any orders which get matched result into a trade and then they are not part of the order book. In order book only unmatched orders are stacked. So the orderbook shown by you is not possible as it has sell and buy matching orders which will get matched, result into a trade and then removed from the orderbook and gets reflected in the trade book.

To understand ordermatching I have removed some orders as under :


----BID ---------- ASK----
(buyer 1)105.0 ********
(buyer 2)104.0 ********
(buyer 3)103.0 (seller 3)106.0
(buyer 4)102.0 (seller 4)107.0
(buyer 5)101.0 (seller 5)108.0
(for simplicity sake assume order quantity is same for all buyers & sellers).

This orderbook is possible as the unmatched orders are stacked. Remember that the order matching has a price and time priority but in that order ie first price priority and then time priority..


Now a sell limit order to sell @ 103.50 enters the system. It will get matched with the buyer standing at 105 though the limit order was to sell upto 103.50 The new order entering the system therefore got sold at 105 ie at Rs 1.50 advantage. If another order comes in to sell at 105 limit, it will straight away gets matched with buyer at 105.00

Now I have removed 2 orders from the bid ( buy) side as under :


----BID ---------- ASK----
*********** (seller 1)103.5
*********** (seller 2)105.0
(buyer 3)103.0 (seller 3)106.0
(buyer 4)102.0 (seller 4)107.0
(buyer 5)101.0 (seller 5)108.0

(for simplicity sake assume order quantity is same for all buyers & sellers)

In this orderbook a new order enters to buy at 105 and this order will get matched with a seller standing at 103.5 so the order is executed at an advantage if Rs 1.50 After this order gets matched, suppose next order comes to buy at 104 but as now the best seller is at 105, this order will go into the stack of bid. But suppose before the order matching we did above this order to buy at 104 enters, then it gets matched with seller at 103.5who is standing in ASK stack so the buyer gets matched at 103.5 though his order was limit 104 ( meaning 104 or better.) He got a better price of 0.50 in this case.. The newly entering order always gets the advantage of ( or better ).The advantage is from the point of view or the newly coming in order. If there is no matching order in the opposite side, then the order goes and sits in the stack and now it looses the price advantage.So after it sits as a limit order to buy at 104 then new order comes to sell at 103.5 the trade will be at 104 and not at 103.5...so advantage to the newly entering order.

Smart_trade
 
Last edited:
#18
@smart_trade
I was having a little difficulty understanding your explanation. Your answer seems to be different from others. But I guess I have grasped your idea.

So can I make the following generalization - "In order matching 3 factors come to play - 1.price priority, 2. recent order price advantage, and then 3. time priority" ??
 
Last edited:

onlinegtrash

Well-Known Member
#19
Its easy if you visualize with a market price ladder... (google image search for market price ladder to see for yourself)

Its like two snakes (bid and ask snakes) always trying to eat each other, if a happy overlap possible we have a match and the snakes eat each other.

If not we say there is huge spread between bid and ask and the market is illiquid.
In that case snakes stop eating each other.

If your order is limit order, its guaranteed, your order will not be fitted infront of the snake but will stay put at the specified price box.

When some one places a market order, now the snake can go ahead and eat as much as size of the order.
------
or think market price ladder as small Tettris game (the famous falling brick game).
On one side we have bid train and other side ask train... when an overlap happens... (blink, blink bricks vanish and you get a score in Tettris) you get a match and the matched orders are gone from the queue.
and this tettris goes on for ever or stalls based on the incoming bricks on either side of the ladder.
 
Last edited:
#20
@smart_trade
I was having a little difficulty understanding your explanation. Your answer seems to be different from others. But I guess I have grasped your idea.

So can I make the following generalization - "In order matching 3 factors come to play - 1.price priority, 2. recent order price advantage, and then 3. time priority" ??
Yes very true.

ST
 

Similar threads