Commit Graph

1381 Commits (6825ad4804e2cdad8333a5b5863e5940032c90b8)

Author SHA1 Message Date
Tyler Goodlet d38a6bf032 Create alloc instance in factory body, template out defaults loading 2021-09-07 08:38:24 -04:00
Tyler Goodlet 214c622328 Move allocator components to clearing sub-pkg 2021-09-06 22:05:42 -04:00
Tyler Goodlet 343cb4b0ae Port order mode setup to new pp apis; reduces implicit update logic 2021-09-06 21:36:30 -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 15025d6047 Move config module to top level 2021-09-06 21:26:28 -04:00
Tyler Goodlet 85fd0a7a30 Avoid "n" as name since it conflicts with pdb 2021-09-06 13:46:07 -04:00
Tyler Goodlet b9ee0997a7 Only do tracker update if pp msg is received for sym 2021-09-06 12:42:25 -04:00
Tyler Goodlet 3713831070 Fix fsp pane width to exactly the same as OHLC chart 2021-09-06 09:28:11 -04:00
Tyler Goodlet 37719efe37 Scale status bar labels to actual bar height 2021-09-06 09:28:11 -04:00
Tyler Goodlet 28047c523d Drop cruft from before pane-per-chart was added 2021-09-06 09:28:11 -04:00
Tyler Goodlet c26161ed7e Make config acounts loading more explicit. 2021-09-06 09:28:11 -04:00
Tyler Goodlet c86c4218ce Allow blank accounts config 2021-09-06 09:28:11 -04:00
Tyler Goodlet c5191d66cb Use new method name in order mode 2021-09-06 09:28: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 171832cfb8 Tweak account label 2021-09-06 09:28:11 -04:00
Tyler Goodlet 35fe26cb95 Assign unique shm keys for duplicate fsps to avoid array clobbering 2021-09-06 09:28:11 -04:00
Tyler Goodlet 709288d034 Sway fixes that avoid weird window resizing 2021-09-06 09:28:11 -04:00
Tyler Goodlet e95589e5b0 Ignore ohlc step stream subs lookup errors 2021-09-06 09:28:11 -04:00
Tyler Goodlet 9c4437b179 Scale pp pane to chart height
Acts as a fix for lodpi and better sizing logic for the pp status bar.
Drop all the redundant passing of the form to its child layouts during
instantiating (since they're all added as layouts to the tree). Comment
out the feed status label for now since it's not hooked up to the
backend and we'll get it going in a new PR.

Down the road we probably want to do all the pp pane component-widget
sizing *after* the `pyqtgraph` chart is up; it's going to take some
reworking of the charting api tho.
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 dc7fcbe792 Tweak mouse rate limits per sway experiments; size line dot to dpi font 2021-09-06 09:28:11 -04:00
Tyler Goodlet 34d4d098d2 Add silver futes 2021-09-06 09:28:11 -04:00
Tyler Goodlet a0258d8be1 Configure alloc to asset type *before* setting pp labels 2021-09-06 09:28:11 -04:00
Tyler Goodlet 1d8767d548 Make `order_line()` configurable for a pp line
We were re-implementing a few things order lines already support.
All we really needed was to not add a pp size label if one is provided.
Use `.hide_label()` in the mouse hover handler.
2021-09-06 09:28:11 -04:00
Tyler Goodlet 77e014daa3 No longer feed specific 2021-09-06 09:28:11 -04:00
Tyler Goodlet 28b6882725 Slapp in exchange suffix position msg key; avoid symbol aliasing on `in` check 2021-09-06 09:28:11 -04:00
Tyler Goodlet fa88d91b8d Add breakpoint on bcast lag for testing 2021-09-06 09:28:11 -04:00
Tyler Goodlet 32f72dd3e8 Drop unused ref 2021-09-06 09:28:10 -04:00
Tyler Goodlet a0c03a8b6b Format pnl label with % type 2021-09-06 09:28:10 -04:00
Tyler Goodlet 30dfcc4530 Use pnl calc in order mode (i.e. no x100%) 2021-09-06 09:28:10 -04:00
Tyler Goodlet 4247f28e04 Round slots proportion instead of ceiling-ing them 2021-09-06 09:28:10 -04:00
Tyler Goodlet 60a6016e73 Break up the pnl calc from the percent part 2021-09-06 09:28:10 -04:00
Tyler Goodlet f90be981b0 Form font size must be set before adding widgets 2021-09-06 09:28:10 -04:00
Tyler Goodlet e78a03d988 Fix import from wrong namespace, again. 2021-09-06 09:28:10 -04:00
Tyler Goodlet 55ae007233 Pixel cache our label type 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 39d2cac3a6 Handle race with order-request-ack msg 2021-09-06 09:28:10 -04:00
Tyler Goodlet 423fc8332c Allocate pnl calc subtask inside order mode machinery 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 03c38a1163 It's a map of symbols to first quote dicts 2021-09-06 09:28:10 -04:00
Tyler Goodlet 8c7e4c0ce9 Add real-time pnl calc and display in status pane 2021-09-06 09:28:10 -04:00
Tyler Goodlet fb4354d629 Add type annots to calcs 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 dfe4ca948a Flip to `open_order_mode()` as ctx mngr
We need a subtask to compute the current pp PnL in real-time but really
only if a pp exists - a spawnable subtask would be ideal for this. Stage
a tick streaming task using a stream bcaster; no actual pnl calc yet.

Since we're going to need subtasks anyway might as well stick the order
mode UI processing loop in a task as well and then just give the whole
thing a ctx mngr api. This'll probably be handy for when we have
auto-strats that need to dynamically use the mode's api as well.

Oh, and move the time -> index mapper to a chart method for now.
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 942cbc2743 `x:` seems clean enough for a "step symbol" 2021-09-06 09:28:10 -04:00
Tyler Goodlet 91fb451696 Fix marker-off-screen-placement for down arrows 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 5103204853 Trigger order allocation at stage/creation time 2021-09-06 09:28:10 -04:00
Tyler Goodlet d9d65bd71a Pass in labl fields as kwargs 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 a28c3f9eba Handle status-group-closed-too-soon bug 2021-09-06 09:28:10 -04:00
Tyler Goodlet b11b8be11e Use consistent digits throughout `humanize()` 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 0589c3c5b7 Validate symbol inputs using pydantic 2021-09-06 09:28:10 -04:00
Tyler Goodlet 3c7bf4310c Just simple update on a slots setting change 2021-09-06 09:28:10 -04:00
Tyler Goodlet a006ffce80 Update pane status on position updates from ems
Turned out to be pretty simple, on every pp update just recompute
the proportion of slots used based on the limit size units.
Don't assign the allocator callback method for alert lines since
there's no size to generate. Move from-existing-pp calculations
into the order pane itself.
2021-09-06 09:28:10 -04:00
Tyler Goodlet 37f5648883 Clarify comment 2021-09-06 09:28:10 -04:00
Tyler Goodlet c4add92422 Move widget-style "format label" to our label mod
Might as well group similar components..
Drop form widget user input update logic, instead expect caller to
provide an async handler.
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 80b01ed8cf Create a formattable label, increase fill bar label sizes 2021-09-06 09:28:10 -04:00
Tyler Goodlet c4d5ca008e Add a `ChartnPane` composite for every symbol 2021-09-06 09:28:10 -04:00
Tyler Goodlet 206af0d575 Port to order pane apis 2021-09-06 09:28:10 -04:00
Tyler Goodlet bc2f4186fd Turn off debug prints 2021-09-06 09:28:10 -04:00
Tyler Goodlet 15fc66f0a9 Add config account loader 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 2b8c3f69b1 Return quick on unmatched event type 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 6be6f25797 Add "crypto" type to binance and kraken symbols 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 6744f59c58 Add numberline hotkeys for slots config 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 17fbe6a6ab Start drafting out alloctor settings per asset type 2021-09-06 09:28:10 -04:00
Tyler Goodlet be956c4031 Move fill status bar to module level, draft out order pane composite 2021-09-06 09:28:10 -04:00
Tyler Goodlet 7192264818 Position pane UI improvements
- pass label text and field widget key separately
- fix fill status bar slot sizing logic (once and for all) and
  create a new type that allows generating / resizing the bar's
  size / values with a `.set_slots()` method
- pull account names from allocator attr
- set `.fill_bar` as the fill status bar on the form for now
2021-09-06 09:28:10 -04:00
Tyler Goodlet 87bd6046e5 Not sure how this worked before but, pass reqid from existing live order 2021-09-06 09:28:10 -04:00
Tyler Goodlet a1d4e61fc2 Port chart code to new subsys apis
- make `GodWidget.load_symbol()` async
- track loaded feeds with a private `._feeds` dict
- add methods to pause/resume all feeds when chart is (un)focussed
- add some commented test code for 2nd feed consumer task and rsi2 fsp
- load async signal handler for view clicking
2021-09-06 09:28:10 -04:00
Tyler Goodlet 1cb311602c Revert commenting bounding rect fix.. 2021-09-06 09:28:10 -04:00
Tyler Goodlet 873d531521 Vastly simplify order mode line management
- generate lines from staged `Order` msgs
- apply level update callback to each order that dynamically
  updates the order size from the allocator calcs
- pass order msg instances to the ems client for submission
- update order size on line moves
- add `Order` msg and `Symbol` refs to each dialog
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 69a1f5e8a8 Add line copy func, drop old markers cruft 2021-09-06 09:28:10 -04:00
Tyler Goodlet 68e23fc567 Simplify line editor to track lines instead of create them 2021-09-06 09:28:10 -04:00
Tyler Goodlet 97ebd03508 Avoid position resets on label paint 2021-09-06 09:28:10 -04:00
Tyler Goodlet c1379001e5 Expect `Order` msg instance to ems client `.send()` 2021-09-06 09:28:10 -04:00
Tyler Goodlet 374967dc6f Support temp `Symbol` and non-copied model refs on `Order` msg 2021-09-06 09:28:10 -04:00
Tyler Goodlet 92d6b19777 Rejig order line creation / config
In an effort to simplify line creation and management from an order
mode here's a slew of changes:
- use our new ``LevelMarker`` for order lines and fully drop usage
 of the original marker implementation stuff from `pg.InfiniteLine`
- add a left side label which shows the instrument's "units" value
  - the most fundamental unit for the "size" of the order
- allow passing in an optional `marker_size: str` so that `action: str`
  doesn't necessarily have to be passed (eg. when copying from an
  existing line)
- change a couple of internal line config options to be public attrs
  which can now be configured dynamically in real-time (since they're
  all `bool` anyway):
  * `hl_on_hover` -> `highlight_on_hover`
  * `_always_show_labels` -> `always_show_labels`
- `LevelLine.set_level()` now only sets the position if it was **not**
  called from the position changed signal (which would be redundant)
2021-09-06 09:28:10 -04:00
Tyler Goodlet c37ce664f5 Uggh, don't override click handler on view; pg has it's own mouse events.. 2021-09-06 09:28:10 -04:00
Tyler Goodlet f2376f90ad Support "next to be focussed" args to async form handlers 2021-09-06 09:28:10 -04:00
Tyler Goodlet ac35e26d9a Make completer view click handler async 2021-09-06 09:28:10 -04:00
Tyler Goodlet 4f4f9f66b4 Move view mode mouse click into async handler 2021-09-06 09:28:10 -04:00
Tyler Goodlet 5ce6dcf3cb Properly capture graphics scene mouse events 2021-09-06 09:28:10 -04:00
Tyler Goodlet 3ddd4bc2c2 Add a private level change cb, fix marker hidingn 2021-09-06 09:28:10 -04:00
Tyler Goodlet 7fc7f72643 Add mouse event and signal proxying support 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 1d7300577e Drop godwidget ref to `FieldsForm` 2021-09-06 09:28:10 -04:00
Tyler Goodlet 7295ceb51a Pass labels to form builder, toy with broadcast consumer task 2021-09-06 09:28:10 -04:00
Tyler Goodlet a40205728f Position tracker is passed at init 2021-09-06 09:28:10 -04:00
Tyler Goodlet 4ddfea654b Lol, initial size calcs on order line update 2021-09-06 09:28:10 -04:00
Tyler Goodlet 5528e80c22 Basic allocator state updates from pp sidepane 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 a7920689b6 Add reference gist for Qt guest mode stuff 2021-09-06 09:28:10 -04:00
Tyler Goodlet a3d1a71017 Unpack keyboard events into an explicit msg model 2021-09-06 09:28:10 -04:00
Tyler Goodlet b302707bf3 Order mode docs/comments updates 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 2d1deb7ab7 Drop uneeded `typing` types for py3.9+ 2021-09-06 09:28:10 -04:00
Tyler Goodlet b79b9c8c41 "last" and "current" are better names 2021-09-06 09:28:10 -04:00
Tyler Goodlet deedcb2c4a Flip to view mode on field exit key combos 2021-09-06 09:28:10 -04:00
Tyler Goodlet 5f7c9a16fb Make god widget focus to chart / "view mode" 2021-09-06 09:28:10 -04:00
Tyler Goodlet 70a283e336 Call god what it is 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 8eaf2a1afe Allocate minority to OHLC chart since 2 fsps by default is likely 2021-09-06 09:28:10 -04:00
Tyler Goodlet 75f50f4b7e "bracket"-ify fills bar + labels and try to evenly space the pane sections 2021-09-06 09:28:10 -04:00
Tyler Goodlet 1fc9047746 Drop old pp config widget inserts; use new pane layout func 2021-09-06 09:28:10 -04:00
Tyler Goodlet 3e237124ec Break health bar and pane layout into separate routines 2021-09-06 09:28:10 -04:00
Tyler Goodlet b0ab240f9e Match search bar margins to pp pane 2021-09-06 09:28:10 -04:00
Tyler Goodlet 41b79d0f9a Fix pp pane to show on symbol switches 2021-09-06 09:28:10 -04:00
Tyler Goodlet e005c8b345 Use `QFormLayout` instead of rolling our own; add pp and feed status sections 2021-09-06 09:28:10 -04:00
Tyler Goodlet 318f3b45c5 Just always use a lambda ; it's innocuous 2021-09-06 09:28:10 -04:00
Tyler Goodlet b6c68e381d Move status back to gunmetal 2021-09-06 09:28:10 -04:00
Tyler Goodlet 0ffbb15bc7 Add a "health bar" factor B) 2021-09-06 09:28:10 -04:00
Tyler Goodlet 63138ccbf4 WIP add a lambda-QFrame to get per chart sidpanes for each linkedsplits row 2021-09-06 09:28:10 -04:00
Tyler Goodlet 825680b8c6 Support (sub)plot names separate from data array keys 2021-09-06 09:28:10 -04:00
Tyler Goodlet 65158b8c64 Add position status (health) bar math for sizing and styling 2021-09-06 09:28:10 -04:00
Tyler Goodlet 3eabe93d54 Always hide contents labels at startup 2021-09-06 09:28:10 -04:00
Tyler Goodlet 21d1e17c6a Better search label styling 2021-09-06 09:28:10 -04:00
Tyler Goodlet 30ac32da55 Add ctrl-p as "pane toggle" 2021-09-06 09:28:10 -04:00
Tyler Goodlet 0ce356f5d9 Make field form a vertical layout, add formatted style sheets 2021-09-06 09:28:10 -04:00
Tyler Goodlet 1ae39c963a Allocate pp config form alongside god widget as a side-pane 2021-09-06 09:28:10 -04:00
Tyler Goodlet d022a105bb Start using a small schema for generating forms 2021-09-06 09:28:10 -04:00
Tyler Goodlet 011f36fc3c WIP add input handler for each widget in the form 2021-09-06 09:28:10 -04:00
Tyler Goodlet 43b769a136 Support opening a handler on a collection of widgets 2021-09-06 09:28:10 -04:00
Tyler Goodlet d1244608bd Use font scaled delegate from forms module 2021-09-06 09:28:10 -04:00
Tyler Goodlet 5ec00ee762 Size view delegate from monkey patched parent 2021-09-06 09:28:10 -04:00
Tyler Goodlet 940aafe1be OMG Qt view item sizing is sooo dumb.. 2021-09-06 09:28:10 -04:00
Tyler Goodlet 29ea91553d Use "slots" as name for "number of entries" 2021-09-06 09:28:10 -04:00
Tyler Goodlet c18cf4f0bf Mock up initial selection field and progress bar 2021-09-06 09:28:10 -04:00
Tyler Goodlet 7e2e316cbf "Forms" is a better module name 2021-09-06 09:28:10 -04:00
Tyler Goodlet a2b61a67b5 Allocate pp config with new actory, drop old line update method 2021-09-06 09:28:10 -04:00
Tyler Goodlet e8e9e20124 Use mode name setter throughout 2021-09-06 09:28:10 -04:00
Tyler Goodlet 00ff0e96cd Add mode name setter 2021-09-06 09:28:10 -04:00
Tyler Goodlet 97f4d9bc2d Drop stale anchors 2021-09-06 09:28:10 -04:00
Tyler Goodlet 1ed7be7c00 Move font-aware line edit to "text entry" mod 2021-09-06 09:28:10 -04:00
Tyler Goodlet 8d65a55f9e Toggle pp config widget on order mode active 2021-09-06 09:28:10 -04:00
Tyler Goodlet 64ccc79a33 Change order label format to color:count 2021-09-06 09:28:10 -04:00
Tyler Goodlet 0f176425b1 First WIP of pp config entry widget on status bar 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 4d5afc2e25 Add dpi font scale getter 2021-09-06 09:28:10 -04:00
Tyler Goodlet 4ce6edae70 Skip line stage when chart not yet initialized 2021-09-06 09:28:10 -04:00