Skip to content

Fixed-point math #227

@bitphage

Description

@bitphage

The library currently uses lots of floating-point math which leads to rounding errors, which is unacceptable for financial applications.

Here is some suggestions:

  • Amount class should present asset amount as Decimal
  • Price class should use Fraction for self["price"]
  • Internal conversions in Price class (.invert() should not use floating-point math
  • More general, all API objects exposed to library users should present prices as Fraction, and all amounts in Decimal
  • Market.buy() and Market.sell() methods should be refactored to use Decimal for amounts and Fraction for price
  • Add additional method to Market class to place an order with any amount of BASE and QUOTE, like place_raw_order(amount_to_sell: Amount, min_to_receive: Amount)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions