Commit Graph

52 Commits (c27ce637c82770e8a7a006f1ae946e0f31fd4706)

Author SHA1 Message Date
Tyler Goodlet 16b9e39e11 Dis-allow an allocator limit less then the current pp size 2022-03-02 10:05:33 -05:00
Tyler Goodlet de0cc6d81a Expect accounts as tuple, don't start rt pnl on no live pp 2021-11-05 10:05:11 -04:00
Tyler Goodlet 75fddb249c Avoid value error on puterizing unit name 2021-11-05 10:05:11 -04:00
Tyler Goodlet 7cbcfc5525 Update pp size label on settings changes
Resolves #232
2021-11-05 10:05:11 -04:00
Tyler Goodlet 4d06502bc8 Accept humanized str input for order settings 2021-09-21 15:48:40 -04:00
Tyler Goodlet da8bccf788 Just log error on invalid order mode settings 2021-09-21 15:48:40 -04:00
Tyler Goodlet aa91055a16 Fix logic to display pnl in status label immediately 2021-09-14 18:31:49 -04:00
Tyler Goodlet f4740da6a2 Drop `.accounts` field from allocator 2021-09-14 13:10:39 -04:00
Tyler Goodlet 9c60aa1928 Add account icon updater method to sidepane 2021-09-14 12:26:06 -04:00
Tyler Goodlet 9e15401ddc Add an accounts list setter 2021-09-14 10:36:44 -04:00
Tyler Goodlet 335e72bf32 Move icons generatino to new module 2021-09-13 18:40:12 -04:00
Tyler Goodlet 66199bfe6f Implement the pixmap mask hack for long/short pp icons 2021-09-13 17:40:14 -04:00
Tyler Goodlet bbcdb88263 Add account icon setter method 2021-09-13 08:47:06 -04:00
Tyler Goodlet ef6594cfc4 Re-factor pnl display logic into settings pane 2021-09-12 12:40:27 -04:00
Tyler Goodlet 1fe29dc86b Revert "Drop extra method"
This reverts commit 6fa8958acf.

We actually do need it since the selection widget of course won't tell
you its "key" that we assign and further we'd have to use a (value, key)
style invocation which isn't super pythonic.
2021-09-11 13:21:19 -04:00
Tyler Goodlet f81d47efc4 Detail some comments 2021-09-11 13:10:20 -04:00
Tyler Goodlet 6fa8958acf Drop extra method 2021-09-11 10:56:03 -04:00
Tyler Goodlet 8886f11c62 Don't allow selecting accounts that haven't been loaded 2021-09-11 10:41:52 -04:00
Tyler Goodlet b6b3ca15c5 Activate pnl updates from order mode method on account switches 2021-09-10 14:59:42 -04:00
Tyler Goodlet f16591612e Support real-time account switch and status update
Make a pp tracker per account and load on order mode boot.
Only show details on the pp tracker for the selected account.
Make the settings pane assign a `.current_pp` state on the order mode
instance (for the charted symbol) on account selection switches and no
longer keep a ref to a single pp tracker and allocator in the pane.

`SettingsPane.update_status_ui()` now expects an explicit tracker
reference as input. Still need to figure out the pnl update task logic
despite the intermittent account changes.
2021-09-10 11:50:24 -04:00
Tyler Goodlet c9eb0b5afb Show account name on pp line 2021-09-09 10:34:48 -04:00
Tyler Goodlet b5c1120ad0 Set account in ui handler 2021-09-07 12:54:10 -04:00
Tyler Goodlet 7b86b6ae20 Add account settings change support 2021-09-07 09:22:24 -04:00
Tyler Goodlet 214c622328 Move allocator components to clearing sub-pkg 2021-09-06 22:05:42 -04:00
Tyler Goodlet 5333d25bf6 Better separation of UI vs. allocator settings
Get rid of `PositionTracker.init_status_ui()` and instead make
a helper func `mk_allocator()` which takes in the alloc and adjusts
default settings on the allocator alone (which is expected to be
passed in). Expect a `Position` instance to be passed into the tracker
which will be looked up for UI updates. Move *update-from-position-msg*
ops into a `Position.update_from_msg()` method.
2021-09-06 21:35:11 -04:00
Tyler Goodlet 27f10293bd Fix pp line label update logic
We weren't updating the LHS size labels on creation and we now use the
lot size digits to do so. Change `PositionTracker.update()` to
`.update_from_pp_msg()`.
2021-09-06 09:28:11 -04:00
Tyler Goodlet cf9de5cd50 Use ``order_line()`` factor for pp tracker 2021-09-06 09:28:11 -04:00
Tyler Goodlet 4247f28e04 Round slots proportion instead of ceiling-ing them 2021-09-06 09:28:10 -04:00
Tyler Goodlet 32f8931d79 Show "slots used" aka proportion "x" on order lines 2021-09-06 09:28:10 -04:00
Tyler Goodlet 09fccdf8e5 Add fiat size to each order line label 2021-09-06 09:28:10 -04:00
Tyler Goodlet fd982df7a9 Add `Allocator.slots_used()` helper calc method 2021-09-06 09:28:10 -04:00
Tyler Goodlet abc5c382ae Use a better exit slot heuristic
When exiting a pp toward net-zero, we may sometimes run into the issue
of having a "fractional slot" worth of units in allocator limit terms.
This is further nuanced by live orders which are submitted above the
current clearing price which get allocated a size (based on that staged
but non-cleared price) according to their limit size unit which can be
calculated to be less then the size that would have been allocated at
the actual clearing price. In the short term cope with this discrepancy
by simply using a "slot and a half" as the decision point of whether to
exit a slot's worth or the remaining pp's worth of units. In other words
if you can exit 1.5x a slot's worth or less, exit the remaining pp,
otherwise exit a slot's worth. This is a stop gap until we have a better
solution to limiting staged orders to (some range around) the currently
computed clear-able price.
2021-09-06 09:28:10 -04:00
Tyler Goodlet 3dd98ff56a Fix inverval logic, lel 2021-09-06 09:28:10 -04:00
Tyler Goodlet ee377e6d6b "Back load" exits, always abs the order size, `SettingsPane` is better name 2021-09-06 09:28:10 -04:00
Tyler Goodlet 1ab23dcba3 Solve the short pps issue with nice `abs()` 2021-09-06 09:28:10 -04:00
Tyler Goodlet 07aafac106 Breakout position line method to module func 2021-09-06 09:28:10 -04:00
Tyler Goodlet 5b923ae577 Update status UI in `.on_ui_settings_change()`
Use this method to go through writing all allocator parameters and then
reading all changes back into the order mode pane including updating the
limit and step labels by the fill bar.

Machinery changes:
- add `.limit()` and `.step_sizes()` methods to the allocator to
  provide the appropriate data depending on the pp limit size unit (eg.
  currency vs. units)
- humanize the label display text such that you have nice suffixes and
  a fixed precision
- tweak the fill bar labels to be simpler since the values are now
  humanized
- expect `.on_ui_settings_change()` to be called for every slots hotkey
  tweak
2021-09-06 09:28:10 -04:00
Tyler Goodlet 16c1f727c7 Finally, correct "next size" allocation logic
Handling the edge cases in this was "fun", namely:
- entering with less then a slot's worth of units to purchase
  before hitting the pp limit or, less then a slots worth when exiting
  toward a net-zero position.
- round pp msg updates using the symbol tick and lot size digits to
  avoid super small (1e-30 lel) positions lingering in the ems (happens
  moreso with the paper engine).
- don't expect the next size method to be called for alert level changes
2021-09-06 09:28:10 -04:00
Tyler Goodlet b09d0d7129 Add an a pane composite and throw ui update methods on it 2021-09-06 09:28:10 -04:00
Tyler Goodlet 58afe07a88 Move `Allocator` to module level, `OrderPane` over to pp mod 2021-09-06 09:28:10 -04:00
Tyler Goodlet dfb9c55944 Compute symbol digits at creation time
Add a new factory func `mk_symbol()` to create the initial
instance at feed creation time.
2021-09-06 09:28:10 -04:00
Tyler Goodlet 07b20a5e68 Fill out allocator calcs for $size and #units, draft pp ui tracking 2021-09-06 09:28:10 -04:00
Tyler Goodlet ccad7cfc2a Allocate order size using lots digits calc 2021-09-06 09:28:10 -04:00
Tyler Goodlet cebfe9dca3 Split up form creation and input handling, require a `.model` 2021-09-06 09:28:10 -04:00
Tyler Goodlet ce7eb75ada Validate allocator assignments with pydantic 2021-09-06 09:28:10 -04:00
Tyler Goodlet c982634839 Add draft `pydantic`-`QWidget` ORM system
Move all the ``pydantic`` finagling to an `_orm.py` and
just keep an `Allocator` as the backing model for our pp controls
in the position module. This all needs to be tied together in some sane
with with facility for multiple symbols/streams per chart for when we
get to charting-trading aggregate feeds.
2021-09-06 09:28:10 -04:00
Tyler Goodlet d1f9273418 Use lightest default for pp line 2021-09-06 09:28:10 -04:00
Tyler Goodlet 97f4d9bc2d Drop stale anchors 2021-09-06 09:28:10 -04:00
Tyler Goodlet c4a9d53306 Use one marker, drop old anchors, add graphics update on marker paint 2021-09-06 09:28:10 -04:00
Tyler Goodlet 568dd488b5 Move level marker to annotate module 2021-09-06 09:28:10 -04:00