Fix sub-slot-remains limiting for -ve sizes
In the short case (-ve size) we had a bug where the last sub-slots worth of exit size would never be limited to zero once the allocator limit pos size was hit (i.e. you could keep going more -ve on the pos, exponentially per slot over the limit). It's a simple fix, just a `max()` around the `l_sub_pp` var used in the next-step-size calc. Resolves #392size_in_shm_token
parent
5c8c5d8fbf
commit
46d3fe88ca
|
@ -96,7 +96,7 @@ class Allocator(Struct):
|
||||||
def next_order_info(
|
def next_order_info(
|
||||||
self,
|
self,
|
||||||
|
|
||||||
# we only need a startup size for exit calcs, we can the
|
# we only need a startup size for exit calcs, we can then
|
||||||
# determine how large slots should be if the initial pp size was
|
# determine how large slots should be if the initial pp size was
|
||||||
# larger then the current live one, and the live one is smaller
|
# larger then the current live one, and the live one is smaller
|
||||||
# then the initial config settings.
|
# then the initial config settings.
|
||||||
|
@ -137,12 +137,14 @@ class Allocator(Struct):
|
||||||
|
|
||||||
# an entry (adding-to or starting a pp)
|
# an entry (adding-to or starting a pp)
|
||||||
if (
|
if (
|
||||||
action == 'buy' and live_size > 0 or
|
|
||||||
action == 'sell' and live_size < 0 or
|
|
||||||
live_size == 0
|
live_size == 0
|
||||||
|
or (action == 'buy' and live_size > 0)
|
||||||
|
or action == 'sell' and live_size < 0
|
||||||
):
|
):
|
||||||
|
order_size = min(
|
||||||
order_size = min(slot_size, l_sub_pp)
|
slot_size,
|
||||||
|
max(l_sub_pp, 0),
|
||||||
|
)
|
||||||
|
|
||||||
# an exit (removing-from or going to net-zero pp)
|
# an exit (removing-from or going to net-zero pp)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue