Coder Social home page Coder Social logo

Comments (9)

fasenderos avatar fasenderos commented on September 15, 2024 1

@afshinkoohsari I have opened a PR (#341) that addresses the issue, can you double check for me?

from nodejs-order-book.

afshinkoohsari avatar afshinkoohsari commented on September 15, 2024 1

I truly appreciate your efforts. Thank you.

from nodejs-order-book.

fasenderos avatar fasenderos commented on September 15, 2024

Thanks for reporting. Instead of matching against other orders in the book, we have to raise an error. Because essentially, you are placing a limit buy ABOVE the current market price. LIMIT orders must be rejected if they would immediately match and trade as a taker.

from nodejs-order-book.

fasenderos avatar fasenderos commented on September 15, 2024

Thanks for reporting. Instead of matching against other orders in the book, we have to raise an error. Because essentially, you are placing a limit buy ABOVE the current market price. LIMIT orders must be rejected if they would immediately match and trade as a taker.

I am convinced that the correct approach is to trigger an error. But I have realized that I should modify the entire logic of the limit order. Essentially, a limit order should be accepted and placed in the order book only if it is not executed immediately.

from nodejs-order-book.

afshinkoohsari avatar afshinkoohsari commented on September 15, 2024

I'm not entirely sure, but I believe the distinction should only be in the 'isMaker' flag. If a limit order is executed immediately, it is treated as a taker, whereas if it enters the order book, it should be considered a maker. Additionally, for partial orders, the remaining portion is considered the maker.

Binance explanation

from nodejs-order-book.

fasenderos avatar fasenderos commented on September 15, 2024

You are right. I'll take a closer look

from nodejs-order-book.

afshinkoohsari avatar afshinkoohsari commented on September 15, 2024

Of course.
Another point I found in the Binance documentation is how they treat any update as a new order with a new ID, and the updated order will be appended at the end of the queue, regardless of changes in price or size. I'm not aware if there's a standard method for implementing FIFO matching engines. However, adopting this approach would simplify the implementation, as each update call would create a new order with an IProcessOrder return type.

From Binance:

You can edit an open order’s price and amount if the order hasn’t been fulfilled or is partially filled. Once you edit an order, the previous Order ID will be canceled and a new Order ID will be created.

From another page:

When an order is modified by price or quantity, it will be deemed as a new entry. Under the FIFO algorithm, or price-time-priority algorithm, orders are prioritized according to their order price and order time. Hence, the latest orders will be placed at the back of the matching order queue.

from nodejs-order-book.

fasenderos avatar fasenderos commented on September 15, 2024

Currently, the behavior is more or less like this. The old order is deleted, and a new one is created, but with the same ID
https://github.com/fasenderos/hft-limit-order-book/blob/883c13be0fccc8f457bf99ad5bf2c18430e7f9b7/src/orderside.ts#L91-L101

from nodejs-order-book.

fasenderos avatar fasenderos commented on September 15, 2024

Of course. Another point I found in the Binance documentation is how they treat any update as a new order with a new ID, and the updated order will be appended at the end of the queue, regardless of changes in price or size. I'm not aware if there's a standard method for implementing FIFO matching engines. However, adopting this approach would simplify the implementation, as each update call would create a new order with an IProcessOrder return type.

From Binance:

You can edit an open order’s price and amount if the order hasn’t been fulfilled or is partially filled. Once you edit an order, the previous Order ID will be canceled and a new Order ID will be created.

From another page:

When an order is modified by price or quantity, it will be deemed as a new entry. Under the FIFO algorithm, or price-time-priority algorithm, orders are prioritized according to their order price and order time. Hence, the latest orders will be placed at the back of the matching order queue.

Before v4.0.0, only when the price of an order was changed, the order was deleted from the orderbook and recreated. From v4.0.0 the same behaviour occurs when the size is changed. Moreover the modify function now return IProcessOrder.

Compared to the Binance's behavior, the only difference is that the modified order keeps the same ID. But this can be easily changed if it turns out to be a problem.

This issue can be closed now?

from nodejs-order-book.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.