ScalABM / auctions

A functional API for auction simulations
Apache License 2.0
13 stars 1 forks source link

How to identify divisible multi-unit orders in an order book #24

Open davidrpugh opened 7 years ago

davidrpugh commented 7 years ago

@bherd-rb @rafabap @DavoudTaghawiNejad @prauwolf Gents! I have a simple design question for auctions/markets to which I have yet to develop a satisfactory answer. Perhaps you can help me sort this out.

What is the best way to identify a particular divisible multi-unit order in an order book? Suppose that an auction participant submits the following order.

val order1 = multiunit.LimitAskOrder(issuer, Price(10), Quantity(100), google)

During the clearing process this order might need to be divided into multiple smaller orders some of which will be filled during the clearing process and some of which will remain on the book. Suppose that there exists a split function that takes an order and some desired residual quantity and creates two separate orders with the same issuer, limit and tradable as the original order but with different quantities. Something like the following.

val (filled, residual) = split(order1, Quantity(45))

Now suppose that the issuer wants to cancel the residual order. If the issuer had a ref to the residual order than it could just call some remove/cancel method and pass this reference as an argument and then that would solve the problem (this is the solution used at present with single unit orders).

I think a better solution would be to store the orders inside the order book using a unique identifier that is unchanged during the splitting process. The auction participant would keep a listing of the unique identifiers for all of its orders and could then call some cancel/remove method and pass this unique order identifier. Something like the following.

val existingOrders: immutable.Map[UUID, Order]

A simpler version of this idea would be to impose the restriction that a market participant can only ever have a single active order in an order book at a time. This would allow us to use the auction participant's unique identifier as the UUID key to identify its order in existingOrders. This last approach is taken by Wurman et al (1998) and Wurman et al (2001).

Thoughts? Opinions? Request for clarification?

DavoudTaghawiNejad commented 7 years ago

In contracts we have a similar problem. Effectively contracts must have an option to split them into parts.

davidrpugh commented 7 years ago

@DavoudTaghawiNejad Is there an open issue for that discussion somewhere? I have thoughts but I do not want to share them here.