XRPL-Labs / XRPL-Orderbook-Reader

Parse XRPL Order Book results into effective liquidity based exchange prices
MIT License
5 stars 6 forks source link

Expired orders #12

Closed shortthefomo closed 12 months ago

shortthefomo commented 12 months ago

Looks like you're not taking into account expired orders here.

Had a read through the parser and did not see any checks on the expiration of the order.

Market Makers commonly use the expired field on their orders.

This will change the results of the data quite some.

WietseWind commented 12 months ago

That's a very good point! Yes, this will need addressing.

The easiest way to implement this, is to use the existing logic for unfunded offers; https://github.com/XRPL-Labs/XRPL-Orderbook-Reader/blob/master/src/parser/LiquidityParser.ts#L109

By simply saying: "if expired, unfunded amount equals offer amount" all existing logic will apply.

Will work on this later today.

shortthefomo commented 12 months ago

if ('Expiration' in offer && offer.Expiration < this.ledgerEpoch()) { continue } is what I do when iterating over the book orders.

WietseWind commented 12 months ago

Fixed & Published 0.4.0 :) Thank you!