bell notificationshomepageloginNewPostedit profiledmBox

Hoots : How does cash accounting work in an exchange? Edit: I'm trying to create an order matching engine for options trading. I'd like to ask my question by creating a situation: Amy has a short position in a single (1) call - freshhoot.com

10% popularity   0 Reactions

How does cash accounting work in an exchange?
Edit: I'm trying to create an order matching engine for options trading.

I'd like to ask my question by creating a situation:

Amy has a short position in a single (1) call option on AAPL. Let's assume she shorted the call at a price of .

The price of the option is now .

Amy now wants to cover this short. She does so by placing a limit buy order at a price of . The limit order system sees she has an existing short and removes this position that she can further trade (basically locks it down so only a market order or cancel order can mutate it).

Now Amy(who's getting paranoid about her losses) puts in another limit buy order at . But the limit order system does not see any more free options in her account and assumes this is an outright purchase and freezes from her account.

Along comes a market order that sells Amy a call option at the price of . But Amy doesn't lose the frozen . She instead covers her short. She now has a net 0 position in the aforementioned call. And are (still)frozen from her cash account.

Along comes another market order which triggers the limit buy at . This time the exchange realizes that the order is an outright buy and transfers a call option in her positions and removes from her of frozen cash.

Now Amy is net long 1 call option but still frozen.

Amy should actually have 0 dollars frozen but my analogy isn't seeing how. I know exchanges currently handle this easily (I think). But how? I'm trying to implement correct accounting but can't seem to be able to it figure out.

Any help would be great! Thanks a lot. Please let me know if you have questions in the comments. I can edit this post to be more clear.


Load Full (2)

Login to follow hoots

2 Comments

Sorted by latest first Latest Oldest Best

10% popularity   0 Reactions

I'm not sure what a freeze is (buying power tied up?) or what locking a limit order down means or what mutating an orders is. I also have no idea where you're trading (no tag) so I'm going to describe what happens in the US in such a situation (commissions ignored).

Amy sells an AAPL short call at . She then places a BTC order for one contract at and then another buy order for one contract at which is BTO. That restricts of her buying power which is now dedicated to these two potential purchases.

The option exchanges don't know and don't care what's going on with Amy. All that occurs there is that there are two buy orders that have been forwarded to them by Amy's broker and they are now on the order book(s).

What's relevant is what's happening in Amy's brokerage account. When the first fill occurs, is removed from her account along with the short contract that she has now covered. What now remains is a BTO order at and of buying power is tied up. When that order is filled, is removed from her account and she is now long 1 contract with the same terms as the one that was originally sold.

It's that simple.


10% popularity   0 Reactions

This is not the situation in the US

Although AAPL is cited as the security (a ticker symbol for a US security):

Options Exchanges in the US do not consider the available margin in this way. All options are cleared through the Options Clearing Corporation who have their own rules for calculating margin requirements using a risk based model. It is up to the clearing members to ensure that their customers' accounts stay within the rules. Most of these types of checks are performed by the broker handling the customer orders and not the exchange.
All stock options in the US must be traded on an Exchange (registered with the Securities and Exchange commission). This is something to do with the fact that listing a new series is like issuing a new security - something that only exchanges can do.

This is an allocation problem

A similar scenario is buying and selling stock. If you have a small (long) position and send in a bunch of sell orders for more than your position, some will have to be marked as long and some marked as short. If you modify the price of the orders, moving them around in the order book, there will potentially be situations when you will be selling short although you have a long position and vice versa.

The way to handle this is to apply a consistent approach. One way is simply to allocate (as you describe) in a first-in, first out approach. You take from a pool of stock (long or short) when you send in the order, and replenish that pool when the order is modified or cancelled. If you send in an order (even if you have a long position), but that long position is already allocated to other orders, you should mark it as short.

You could make your allocation model more sophisticated, such as re-arranging the allocations from the pool based on likelihood of execution (e.g. price level in the order book). This creates more complexity, but could result in a better outcome.


Back to top Use Dark theme