Round spread (slap) offset to min tick digits

pre_viz_calls
Tyler Goodlet 2023-01-12 01:32:30 -05:00
parent 577935951d
commit a4e6014247
1 changed files with 10 additions and 2 deletions

View File

@ -46,6 +46,7 @@ from ..data._normalize import iterticks
from ..data._source import (
unpack_fqsn,
mk_fqsn,
float_digits,
)
from ..data.feed import (
Feed,
@ -1250,6 +1251,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')
@ -1258,12 +1260,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')