From 4d06502bc881899e1f46b639004ae12eb239bfe5 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 16 Sep 2021 11:49:22 -0400 Subject: [PATCH] Accept humanized str input for order settings --- piker/ui/_position.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/piker/ui/_position.py b/piker/ui/_position.py index 9bc51c3d..9208fbd1 100644 --- a/piker/ui/_position.py +++ b/piker/ui/_position.py @@ -36,7 +36,7 @@ from ._anchors import ( pp_tight_and_right, # wanna keep it straight in the long run gpath_pin, ) -from ..calc import humanize, pnl +from ..calc import humanize, pnl, puterize from ..clearing._allocate import Allocator, Position from ..data._normalize import iterticks from ..data.feed import Feed @@ -209,16 +209,14 @@ class SettingsPane: # WRITE any settings to current pp's allocator try: + value = puterize(value) if key == 'limit': - if size_unit == 'currency': - # old = alloc.currency_limit - alloc.currency_limit = float(value) - else: - # old = alloc.units_limit - alloc.units_limit = float(value) + if size_unit == 'currency': + alloc.currency_limit = value + else: + alloc.units_limit = value elif key == 'slots': - # old = alloc.slots alloc.slots = int(value) elif key == 'size_unit': @@ -226,7 +224,7 @@ class SettingsPane: # the current settings in the new units alloc.size_unit = value - elif key != 'account': + else: raise ValueError(f'Unknown setting {key}') log.info(f'settings change: {key}: {value}')