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