From 8f70398d88b84e760842cea92b42dbebf2ab21bf Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Wed, 6 Oct 2021 12:59:36 -0400 Subject: [PATCH] Fix exit-slot-edge-case when only one discrete unit remains --- piker/clearing/_allocate.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/piker/clearing/_allocate.py b/piker/clearing/_allocate.py index c14b92d5..35c79e08 100644 --- a/piker/clearing/_allocate.py +++ b/piker/clearing/_allocate.py @@ -204,7 +204,14 @@ class Allocator(BaseModel): # **without** going past a net-zero pp. if the pp is # > 1.5x a slot size, then front load: exit a slot's and # expect net-zero to be acquired on the final exit. - slot_size < pp_size < round((1.5*slot_size), ndigits=ld) + slot_size < pp_size < round((1.5*slot_size), ndigits=ld) or + + # underlying requires discrete (int) units (eg. stocks) + # and thus our slot size (based on our limit) would + # exit a fractional unit's worth so, presuming we aren't + # supporting a fractional-units-style broker, we need + # exit the final unit. + ld == 0 and abs_live_size == 1 ): order_size = abs_live_size