Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

[ad-hoc] [3](3) Rounding issues in mirror strategy causing offers to not be placed #541

Closed
4 tasks done
nikhilsaraf opened this issue Oct 17, 2020 · 0 comments
Closed
4 tasks done
Assignees
Labels
bug Something isn't working
Milestone

Comments

@nikhilsaraf
Copy link
Contributor

nikhilsaraf commented Oct 17, 2020

bids are not placed in most situations.

See line below, when dividing by price we may round up to get the normalizedPrimaryUnits and when we eventually multiply again to get back into the quote asset it ends up in a larger number because of this rounding. We want to round down in this case to be conservative, and to take a calculation that has a larger precision output, maybe even consider big.Rat temporarily

normalizedPrimaryUnits = normalizedPrimaryUnits.Divide(*price)

this causes the oversell statement to be triggered, and we don't retry in the mirror strategy yet

  • add a test case for checkBalance with the rounding issue using a good volume and price (TDD)
    • name: negative rounding oversell (link this bug in comment)
    • primary quote balance is 646.1
    • backing base balance is 2
    • price is 368
    • zero case
  • MultiplyRoundDown + TestMath update
  • DivideRoundDown + TestMath update
  • use a larger precision for internal calculations and eventually round down in checkBalance

Related to #524

@nikhilsaraf nikhilsaraf added the bug Something isn't working label Oct 17, 2020
@nikhilsaraf nikhilsaraf added this to the v1.10.0 milestone Oct 17, 2020
@nikhilsaraf nikhilsaraf self-assigned this Oct 17, 2020
@nikhilsaraf nikhilsaraf changed the title Rounding issues in mirror strategy causing offers to not be placed [ad-hoc] [2] Rounding issues in mirror strategy causing offers to not be placed Oct 17, 2020
@nikhilsaraf nikhilsaraf changed the title [ad-hoc] [2] Rounding issues in mirror strategy causing offers to not be placed [ad-hoc] [3] Rounding issues in mirror strategy causing offers to not be placed Oct 17, 2020
@nikhilsaraf nikhilsaraf changed the title [ad-hoc] [3] Rounding issues in mirror strategy causing offers to not be placed [ad-hoc] [3](3) Rounding issues in mirror strategy causing offers to not be placed Oct 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant