From dc78994dcf2d9165dd66ebd3c772ac4b92b2895b Mon Sep 17 00:00:00 2001 From: Guillermo Rodriguez Date: Mon, 27 Feb 2023 16:47:02 -0300 Subject: [PATCH] Fixed float dust bug on zero position case --- piker/pp.py | 4 +++- tests/test_paper.py | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/piker/pp.py b/piker/pp.py index b4ab2d0c..1e4cd014 100644 --- a/piker/pp.py +++ b/piker/pp.py @@ -22,6 +22,7 @@ that doesn't try to cuk most humans who prefer to not lose their moneys.. ''' from __future__ import annotations from contextlib import contextmanager as cm +from decimal import Decimal, ROUND_HALF_EVEN from pprint import pformat import os from os import path @@ -466,7 +467,8 @@ class Position(Struct): if self.split_ratio is not None: size = round(size * self.split_ratio) - return size + return float(Decimal(size).quantize( + Decimal('1.0000'), rounding=ROUND_HALF_EVEN)) def minimize_clears( self, diff --git a/tests/test_paper.py b/tests/test_paper.py index 3339db6c..f8a7fd24 100644 --- a/tests/test_paper.py +++ b/tests/test_paper.py @@ -206,8 +206,6 @@ def test_sell( ), ) - -@pytest.mark.xfail(reason='Due to precision issues, this test will currently fail') def test_multi_sell( open_test_pikerd_and_ems: AsyncContextManager, delete_testing_dir