Xud: Market order call returns remainingOrder

Created on 16 Aug 2018  路  8Comments  路  Source: ExchangeUnion/xud

I have not investigated this yet, but I'm logging the output here so as to not forget about it. Unfortunately I forgot to check whether the market order was actually added to the orderbook. Noticed this in some testing with @kilrau.

  1. Receive a peer order
xucli getorders BTC/LTC
{
  "peerOrders": {
    "buyOrdersList": [
      {
        "price": 100,
        "quantity": 1,
        "pairId": "BTC/LTC",
        "peerPubKey": "03d2fc7499fa9ee64290acdd12cd653e2c63963d660642422903c3c66c5dc98931",
        "id": "a9f1e570-a178-11e8-8822-81f39cd0b447",
        "localId": "",
        "createdAt": 1534440152964,
        "invoice": "dummyInvoice",
        "canceled": false
      }
    ],
    "sellOrdersList": []
  },
  "ownOrders": {
    "buyOrdersList": [],
    "sellOrdersList": []
  }
}
  1. Attempt to fill it with a market order, but accidentally do a market buy instead of a market sell: xucli marketorder BTC/LTC 1 1

  2. Observe a remainingOrder with max price, instead returning a null value for remaining order to indicate it has been discarded and not added to the orderbook (also doublecheck nothing gets added).

{
  "matchesList": [],
  "remainingOrder": {
    "price": 1.7976931348623157e+308,
    "quantity": 1,
    "pairId": "BTC/LTC",
    "peerPubKey": "",
    "id": "64655f40-a179-11e8-909c-8985afb322c4",
    "localId": "1",
    "createdAt": 1534440338228,
    "invoice": "",
    "canceled": false
  }
}
bug

All 8 comments

The market order doesn't get added to the orderbook as you said and remainingOrder is showing the order that wasn't matched. The difference between a market and limit order is that the remainingOrder of a limit order gets added to the orderbook.

I think the bug is that market orders don't return a remainingOrder when there is a match.

I would think that remainingOrder should always be null for market orders, because any remaining portion gets discarded. Maybe this is not exactly a bug then, but a behavior change.

From the proto file, the comment suggests that the remaining order is entering the orderbook too, so we need to change the behavior or change the comment (I'd prefer the former).

// The remaining portion of the order, after matches, that enters the order book
Order remaining_order = 2 [json_name= "remaining_order"];

Agree to change the behavior (remainingOrder always returning null for market orders). remainingOrder shows what's left in my orderbook to be matched and not what was discarded/not matched. Anything else doesn't make much sense to me.

Feel free to take over @michael1011

Yeah makes sense to remove remainingOrder for market orders. But it would be nice to know how much quantity of the market order wasn't matched without having to sum the quantity of all matches. What about an unmatchedQuantity field?

I feel like that would be a bit unnecessary still, considering it would be on every response and most of the time would just be 0 since in practice I'd expect most market orders to get filled, and when it's a limit order it's redundant to the remainingOrder quantity. I'm not aware of unmatched quantity being displayed for market orders on any exchanges. I think what we could maybe do for tools like the cli is calculate any unmatched quantity and display it, but I don't think it needs to be a field on the actual grpc response.

Yeah you are right it is just kind of useful in an edge case and redundant in every other situation.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

moshababo picture moshababo  路  5Comments

kilrau picture kilrau  路  6Comments

erkarl picture erkarl  路  6Comments

moshababo picture moshababo  路  3Comments

kilrau picture kilrau  路  5Comments