Commit Graph

1751 Commits (296863348df159bf689ec39e47599dbe006cb72f)

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