New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit Order FOK / IOC #622

Open
offerm opened this Issue Oct 31, 2018 · 10 comments

Comments

Projects
None yet
5 participants
@offerm
Contributor

offerm commented Oct 31, 2018

I suggest to support FOK & IOC with limit orders.

Use case:

with getorders I see a peer order that I wish to take.
since I never use market orders :-) I issued a limit order targeting the peer order.

The matching with the peer order failed for some reason (peer order does not exists anymore, swap failed, etc), As a result my take order entered the book and broadcasted to all my peers. This was not my intention.
FOK - fill the order or kill it.
IOC - fill immediate or cancel

reference - http://optionstradingbeginner.blogspot.com/2009/01/fill-or-kill-fok-immediate-or-cancel.html

@kilrau

This comment has been minimized.

Contributor

kilrau commented Oct 31, 2018

... which we could take and simulate market orders if we wanted/needed to. Other thoughts? @sangaman @moshababo

@kilrau kilrau changed the title from Suggestion: limit order with FOK (fill or kill) to [Concept] Limit Order with FOK (fill or kill) Oct 31, 2018

@kilrau kilrau self-assigned this Oct 31, 2018

@kilrau kilrau added the question/tbd label Oct 31, 2018

@kilrau kilrau added this to the 1.0.0-alpha.4 milestone Oct 31, 2018

@moshababo

This comment has been minimized.

Collaborator

moshababo commented Oct 31, 2018

Sounds good to me.

@sangaman

This comment has been minimized.

Collaborator

sangaman commented Oct 31, 2018

This would be simple enough to do, it's basically a limit order (with a price) where we set discardRemaining to true. It can be an optional flag on the placeOrder request.

@kilrau

This comment has been minimized.

Contributor

kilrau commented Nov 7, 2018

Let me know what you think @offerm @moshababo @sangaman

Summary

placeOrder with flag fok (Limit Fill-or-Kill, make sure fok flag doesn't work with Market):
search order book for match of total quantity (partial matching allowed, taker uses same preimage)
if match found & swap successful
remove matched order as usual
else cancel order and return discarded remaining order

placeOrder with flag ioc (Limit Immediate-or-Cancel, make sure ioc flag doesn't work with Market):
search order book for match (partial matching allowed)
for match found & swap successful
remove matched order as usual
discard remaining quantity of failed swaps and no match found, nothing enters the order book

CLI UX Example FOK:

$ xucli buy 0.0001 LTC/BTC 1.1 fok
{
  "internalMatchesList": [],
  "swapResultsList": [],
  "remainingOrder": {
    "price": 1.1,
    "quantity": 0.0001,
    "pairId": "LTC/BTC",
    "id": "0298b691-e26f-11e8-bc86-4938fbce63e9",
    "peerPubKey": "",
    "localId": "0298b690-e26f-11e8-bc86-4938fbce63e9",
    "createdAt": 1541582704761,
    "side": 0,
    "isOwnOrder": true,
    "discarded": true
  }
}

CLI example IOC:

$ xucli buy 0.0001 LTC/BTC 1.1 ioc
{
  "internalMatchesList": [],
  "swapResultsList": [],
  "remainingOrder": {
    "price": 1.1,
    "quantity": 0.0001,
    "pairId": "LTC/BTC",
    "id": "0298b691-e26f-11e8-bc86-4938fbce63e9",
    "peerPubKey": "",
    "localId": "0298b690-e26f-11e8-bc86-4938fbce63e9",
    "createdAt": 1541582704761,
    "side": 0,
    "isOwnOrder": true,
    "discarded": true
  }
}

@kilrau kilrau removed their assignment Nov 7, 2018

@kilrau kilrau modified the milestones: 1.0.0-alpha.4, 1.0.0-alpha.5 Nov 7, 2018

@kilrau

This comment has been minimized.

Contributor

kilrau commented Nov 18, 2018

Interested? @erkarl

@kilrau kilrau changed the title from [Concept] Limit Order with FOK (fill or kill) to Limit Order with FOK (fill or kill) Nov 18, 2018

@offerm

This comment has been minimized.

Contributor

offerm commented Nov 18, 2018

@kilrau

This comment has been minimized.

Contributor

kilrau commented Nov 18, 2018

Don't see a great use case for AON for now, so FOK and IOC should be a good start.

@offerm

This comment has been minimized.

Contributor

offerm commented Nov 18, 2018

Addition to your reason: we could theoretically only support partial matches with the same taker anyways, but not with different takers since they all would need to agree on using the same pre-image which is close to impossible.

Why the same preImage can't be used for multiple makers? Should not be a problem since we have a single taker and multiple makers.

@kilrau

This comment has been minimized.

Contributor

kilrau commented Nov 18, 2018

You are right..

The taker using the same preimage for all FOK swaps and allow partial fills should work. Changed my posts.

@sangaman

This comment has been minimized.

Collaborator

sangaman commented Nov 18, 2018

Oh I didn't realize that FOK also requires the entire order to be filled - or none of it (I guess I was talking about IOC, that should be easy). That is more complicated than I'd said, but I think it can be done as offer described. I don't see a problem either with the taker using the same preimage for multiple swaps/makers - the makers won't even have to know about it. Although I think we have a check on the maker side to not allow reuse of preimages that we may need to relax.

@kilrau kilrau modified the milestones: 1.0.0-alpha.5, 1.0.0-alpha.6 Dec 5, 2018

@kilrau kilrau changed the title from Limit Order with FOK (fill or kill) to Limit Order FOK / IOC Dec 6, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment