From 35b097469b8e4921f55785c90db522f1e8435878 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 12 Jan 2023 01:32:30 -0500 Subject: [PATCH] Round spread (slap) offset to min tick digits --- piker/clearing/_ems.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/piker/clearing/_ems.py b/piker/clearing/_ems.py index ad512c08..01de9822 100644 --- a/piker/clearing/_ems.py +++ b/piker/clearing/_ems.py @@ -46,6 +46,7 @@ from ..data._normalize import iterticks from ..data._source import ( unpack_fqsn, mk_fqsn, + float_digits, ) from ..data.feed import ( Feed, @@ -1249,6 +1250,7 @@ async def process_client_order_cmds( spread_slap: float = 5 min_tick = flume.symbol.tick_size + min_tick_digits = float_digits(min_tick) if action == 'buy': tickfilter = ('ask', 'last', 'trade') @@ -1257,12 +1259,18 @@ async def process_client_order_cmds( # TODO: we probably need to scale this based # on some near term historical spread # measure? - abs_diff_away = spread_slap * min_tick + abs_diff_away = round( + spread_slap * min_tick, + ndigits=min_tick_digits, + ) elif action == 'sell': tickfilter = ('bid', 'last', 'trade') percent_away = -0.005 - abs_diff_away = -spread_slap * min_tick + abs_diff_away = round( + -spread_slap * min_tick, + ndigits=min_tick_digits, + ) else: # alert tickfilter = ('trade', 'utrade', 'last')