2. Order - ArjunVachhani/order-matcher GitHub Wiki
Order fields
IsBuy
true if buy/bid, false if sale/ask
OrderId
Unique number assigned to each order. uniquely identifies each order.
UserId
UserId of order. UserId is used for self match prevention.
OpenQuantity
Quantity user is willing to buy/sell. MatchingEngine will reduce OpenQuantity after each match.
Price
Limit price of the order, in case of buy maximum price buyer willing to pay for one unit/quantity of the asset. In case of sale minimum price seller is willing to accept for one unit/quantity of the asset. In the case of market order it must be 0.
StopPrice
trigger price for stop order.
CancelOn
Seconds from 1 Jan 1970(UTC) after which order should be cancelled. This should be set for only good till date order. for good till cancel orders it must be set to 0.
OrderCondition
Represents order condition, it could be one of the following
- Immediate or cancel - Order must be filled immediately, if order is not filled then cancel the remaining open order. it allows partial fills.
- Fill or kill - only fill order in full immediately or cancel the order.
- Book or cancel - Order must not be match with any open order while placing order. it must be added to order book. it can not be matched with resting orders in book. if order can be matched resting order in book then cancel the order.
SefMatchAction
SelfMatchAction represents action needs to be take when self match / self trade happens. There are 4 Options,
- Match - Allows match to happen.
- CanceNewest - Cancels incoming order or newer order. in the case of stop order, trigger time is used to indetify newer order.
- CancelOlder - Cancels resting order in the book or older oder. in the case of stop order, trigger is used to identify older order.
- Decrement - Canceles smaller order and decrement quantity of larger order. quantity of larger order is reduced by quantity of smaller order. Smaller order is cancelled fully.
TipQuantity
Tip quantity for each tip added into order book. This must be set for iceberg orders. for other orders it must be set to 0.
TotalQuantity
Total quantity of iceberg order. This must be set for iceberg orders. for other orders it must be set to 0.
OrderAmount
OrderAmount can be specified for market buy and stop market buy. instead of providing OpenQuantity we could provide amount. for example for market buy bitcoin worth of 2000 USD. it means buy any quantity of bitcoin at any price but amount should not exceed 2000 USD.
FeeId
represents fee to be charged for this order.
Fee
for order matcher internal user. order matcher calculates fee on order.
Sequnce
for order matcher internal use. Sequence is used to find priority of order. Lower sequence has higher priority.
Cost
for order matcher internal use. order matcher tracks cost of the order. it is sum of matched quantity * match rate of all the matches.