Always apply at least the pos size as the limit
parent
25ac6e6665
commit
2cf1742999
|
@ -93,6 +93,9 @@ class Allocator(Struct):
|
||||||
else:
|
else:
|
||||||
return self.units_limit
|
return self.units_limit
|
||||||
|
|
||||||
|
def limit_info(self) -> tuple[str, float]:
|
||||||
|
return self.size_unit, self.limit()
|
||||||
|
|
||||||
def next_order_info(
|
def next_order_info(
|
||||||
self,
|
self,
|
||||||
|
|
||||||
|
|
|
@ -184,7 +184,7 @@ class SettingsPane:
|
||||||
|
|
||||||
'''
|
'''
|
||||||
self.apply_setting(key, value)
|
self.apply_setting(key, value)
|
||||||
self.update_status_ui(pp=self.order_mode.current_pp)
|
self.update_status_ui(self.order_mode.current_pp)
|
||||||
|
|
||||||
def apply_setting(
|
def apply_setting(
|
||||||
self,
|
self,
|
||||||
|
@ -262,6 +262,8 @@ class SettingsPane:
|
||||||
log.error(
|
log.error(
|
||||||
f'limit must > then current pp: {dsize}'
|
f'limit must > then current pp: {dsize}'
|
||||||
)
|
)
|
||||||
|
# reset position size value
|
||||||
|
alloc.currency_limit = dsize
|
||||||
return False
|
return False
|
||||||
|
|
||||||
alloc.currency_limit = value
|
alloc.currency_limit = value
|
||||||
|
@ -299,22 +301,29 @@ class SettingsPane:
|
||||||
|
|
||||||
def update_status_ui(
|
def update_status_ui(
|
||||||
self,
|
self,
|
||||||
pp: PositionTracker,
|
tracker: PositionTracker,
|
||||||
|
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
||||||
alloc = pp.alloc
|
alloc = tracker.alloc
|
||||||
slots = alloc.slots
|
slots = alloc.slots
|
||||||
used = alloc.slots_used(pp.live_pp)
|
used = alloc.slots_used(tracker.live_pp)
|
||||||
|
size = tracker.live_pp.size
|
||||||
|
dsize = tracker.live_pp.dsize
|
||||||
|
|
||||||
# READ out settings and update the status UI / settings widgets
|
# READ out settings and update the status UI / settings widgets
|
||||||
suffix = {'currency': ' $', 'units': ' u'}[alloc.size_unit]
|
suffix = {'currency': ' $', 'units': ' u'}[alloc.size_unit]
|
||||||
limit = alloc.limit()
|
size_unit, limit = alloc.limit_info()
|
||||||
|
|
||||||
step_size, currency_per_slot = alloc.step_sizes()
|
step_size, currency_per_slot = alloc.step_sizes()
|
||||||
|
|
||||||
if alloc.size_unit == 'currency':
|
if alloc.size_unit == 'currency':
|
||||||
step_size = currency_per_slot
|
step_size = currency_per_slot
|
||||||
|
if dsize >= limit:
|
||||||
|
self.apply_setting('limit', limit)
|
||||||
|
|
||||||
|
elif size >= limit:
|
||||||
|
self.apply_setting('limit', limit)
|
||||||
|
|
||||||
self.step_label.format(
|
self.step_label.format(
|
||||||
step_size=str(humanize(step_size)) + suffix
|
step_size=str(humanize(step_size)) + suffix
|
||||||
|
@ -331,7 +340,7 @@ class SettingsPane:
|
||||||
self.form.fields['limit'].setText(str(limit))
|
self.form.fields['limit'].setText(str(limit))
|
||||||
|
|
||||||
# update of level marker size label based on any new settings
|
# update of level marker size label based on any new settings
|
||||||
pp.update_from_pp()
|
tracker.update_from_pp()
|
||||||
|
|
||||||
# calculate proportion of position size limit
|
# calculate proportion of position size limit
|
||||||
# that exists and display in fill bar
|
# that exists and display in fill bar
|
||||||
|
@ -343,7 +352,7 @@ class SettingsPane:
|
||||||
# min(round(prop * slots), slots)
|
# min(round(prop * slots), slots)
|
||||||
min(used, slots)
|
min(used, slots)
|
||||||
)
|
)
|
||||||
self.update_account_icons({alloc.account: pp.live_pp})
|
self.update_account_icons({alloc.account: tracker.live_pp})
|
||||||
|
|
||||||
def update_account_icons(
|
def update_account_icons(
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -491,7 +491,8 @@ class OrderMode:
|
||||||
'''
|
'''
|
||||||
dialog = self.dialogs[uuid]
|
dialog = self.dialogs[uuid]
|
||||||
lines = dialog.lines
|
lines = dialog.lines
|
||||||
assert len(lines) == 2
|
# XXX: seems to fail on certain types of races?
|
||||||
|
# assert len(lines) == 2
|
||||||
if lines:
|
if lines:
|
||||||
_, _, ratio = self.feed.get_ds_info()
|
_, _, ratio = self.feed.get_ds_info()
|
||||||
for i, chart in [
|
for i, chart in [
|
||||||
|
@ -843,8 +844,7 @@ async def open_order_mode(
|
||||||
)
|
)
|
||||||
|
|
||||||
# make fill bar and positioning snapshot
|
# make fill bar and positioning snapshot
|
||||||
order_pane.on_ui_settings_change('limit', tracker.alloc.limit())
|
order_pane.update_status_ui(tracker)
|
||||||
order_pane.update_status_ui(pp=tracker)
|
|
||||||
|
|
||||||
# TODO: create a mode "manager" of sorts?
|
# TODO: create a mode "manager" of sorts?
|
||||||
# -> probably just call it "UxModes" err sumthin?
|
# -> probably just call it "UxModes" err sumthin?
|
||||||
|
|
Loading…
Reference in New Issue