Commit Graph

3292 Commits (47bf45f30e0fa1ea21bd093b6bd90775d7c880cd)

Author SHA1 Message Date
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