Commit Graph

2192 Commits (3bbbc21d2b05c21eb6cb20f680fe07a8afa11016)

Author SHA1 Message Date
Tyler Goodlet 9d9929fb89 Drop old `wrapt` cruft, add `Fsp.name` 2022-01-28 07:18:14 -05:00
Tyler Goodlet cc5390376c Use `Fsp` abstration layer through engine and UI
Instead of referencing the remote processing funcs by a `str` name start
embracing the new `@fsp`/`Fsp` API such that wrapped processing
functions are first class APIs.

Summary of the changeset:
- move and load the fsp built-in set in the new `.fsp._api` module
- handle processors ("fsps") which want to yield multiple keyed-values
  (interleaved in time) by expecting both history that is keyed and
  assigned to the appropriate struct-array field, *and* real-time
  `yield`ed value in tuples of the form `tuple[str, float]` such that
  any one (async) processing function can deliver multiple outputs from
  the same base calculation.
- drop `maybe_mk_fsp_shm()` from UI module
- expect and manage `Fsp` instances (`@fsp` decorated funcs) throughout
  the UI code, particularly the `FspAdmin` layer.
2022-01-27 18:57:16 -05:00
Tyler Goodlet 72f4474273 Use new decorator on volume fsp routines 2022-01-27 09:08:03 -05:00
Tyler Goodlet c6a3c66e7e WIP start a `@piker.fsp` API for registering processors 2022-01-26 14:38:49 -05:00
Tyler Goodlet 13b8807f1f Print dark trades to console for the moment 2022-01-26 13:48:21 -05:00
Tyler Goodlet 55cfe6082b Re-key ib's 'unreportable trades' (tick 48) as 2022-01-26 13:48:21 -05:00
goodboy 8fe2bd6614
Merge pull request #259 from pikers/overlayed_dvlm
Overlayed $vlm
2022-01-26 13:47:52 -05:00
Tyler Goodlet d351fe14a8 Annoying doc string(s) 2022-01-25 08:30:00 -05:00
Tyler Goodlet 4e884aec6c Fix bottom axis check logic for overlays, try out some px perfection 2022-01-25 08:30:00 -05:00
Tyler Goodlet 7b21ddd27f Allow passing in parent to `Label` 2022-01-25 08:30:00 -05:00
Tyler Goodlet fd31b843b9 Hide the unit vlm after the $vlm is up
Since more curves costs more processing and since the vlm and $vlm
curves are normally very close to the same (graphically) we hide the
unit volume curve once the dollar volume is up (after the fsp daemon-task is
spawned) and just expect the user to understand the diff in axes units.
Also, use the new `title=` api to `.overlay_plotitem()`.
2022-01-25 08:30:00 -05:00
Tyler Goodlet 7f4546b71f Use overlay api to access multi-axes by name 2022-01-25 08:30:00 -05:00
Tyler Goodlet f5eb34c4d7 Make axes labels more pixel perfect 2022-01-25 08:30:00 -05:00
Tyler Goodlet c7a588cf25 Pop vlm chart from subplots to avoid double render 2022-01-25 08:30:00 -05:00
Tyler Goodlet 5c2d3125b4 Add vlm axis titles and humanized $vlm y-range 2022-01-25 08:30:00 -05:00
Tyler Goodlet f011234285 Type annot and docs updates in anchors mod 2022-01-25 08:30:00 -05:00
Tyler Goodlet ce7c174059 Add `Axis.set_title()` for hipper labelling
Use our internal `Label` with much better dpi based sizing of text and
placement below the y-axis ticks area for more minimalism and less
clutter.

Play around with `lru_cache` on axis label bounding rects and for now
just hack sizing by subtracting half the text height (not sure why) from
the width to avoid over-extension / overlap with any adjacent axis.
2022-01-25 08:30:00 -05:00
Tyler Goodlet 94b6f370a9 Allow axis kwargs passthrough 2022-01-25 08:30:00 -05:00
Tyler Goodlet 349040dbf0 Revert cursor rate limit settings 2022-01-25 08:30:00 -05:00
Tyler Goodlet 80079105fc Add custom `.formatter` support to our `PriceAxis`
Allow passing in a formatter function for processing tick values on an
axis. This makes it easy to for example, `piker.calc.humanize()` dollar
volume on a subchart.

Factor `set_min_tick()` into the `PriceAxis` since it's not used on any
x-axis data thus far.
2022-01-25 08:30:00 -05:00
Tyler Goodlet 8911c3c8ed Add support for "humanized" axes tick values 2022-01-25 08:30:00 -05:00
goodboy a40e949940
Merge pull request #258 from pikers/fsp_ui_mod
Fsp UI mod
2022-01-25 08:29:27 -05:00
Tyler Goodlet 9813cf4169 Add a symbol "front feed" helper 2022-01-25 08:24:55 -05:00
Tyler Goodlet c3c1e14cf4 Start vlm and other fsps as separate tasks 2022-01-25 08:24:55 -05:00
Tyler Goodlet 404f5d6d23 Factor (sub-)chart spawning into a admin method
Adds `FspAdmin.open_fsp_chart()` which allows adding a real time graphics
display of an fsp's output with different options for where (which chart
or make a new one) to place it.

Further,
- change some method naming, namely the other fsp engine task methods to
  `.open_chain()` and `.start_engine_task()`.
- make `run_fsp_ui()` a lone task function for now with the default
  config parsing and chart setup logic (and it still includes a buncha
  commented out stuff for doing graphics update which is now done in the
  main loop to avoid task switching overhead).
- move all vlm related fsp config entries into the `open_vlm_displays()`
  task for dedicated setup with the fsp admin api such as special
  auto-yrange handling and graph overlays.
- `start_fsp_displays()` is now just a small loop through config entries
  with synced startup status messages.
2022-01-25 08:24:55 -05:00
Tyler Goodlet e22a652852 Move plotitem overlaying into a `.overlay_plotitem()` 2022-01-25 08:24:55 -05:00
Tyler Goodlet 09fc901b0d Handle left axis case for x-axis label placement
For wtv cucked reason all the viewbox/scene coordinate calcs do **not**
include a left axis in the geo (likely because it's a hacked in widget
+ layout thing managed by `PlotItem`). Detect if there's a left axis and
if so use it in the label placement scene coords calc. ToDo: probably
make this a non-move calc and only recompute any time the axis changes.

Other:
- rate limit mouse events down to the 60 (ish) Hz for now
- change one last lingering `'ohlc'` array lookup
- fix `.mouseMoved()` "event" type annot
2022-01-25 08:24:55 -05:00
Tyler Goodlet e69af9e291 Show unit vlm on LHS for now 2022-01-25 08:24:55 -05:00
Tyler Goodlet 06fe2bd1be Support "volume" and "dollar volume" on same chart
This is a huge commit which moves a bunch of code around in order to
simplify some of our UI modules as well as support our first official
mult-axis chart: overlaid volume and "dollar volume". A good deal of
this change set is to make startup fast such that volume data which is
often shipped alongside OHLC history is loaded and shown asap and FSPs
are loaded in an actor cluster with their graphics overlayed
concurrently as each responsible worker generates plottable output.

For everything to work this commit requires use of a draft `pyqtgraph`
PR: https://github.com/pyqtgraph/pyqtgraph/pull/2162

Change summary:
- move remaining FSP actor cluster helpers into `.ui._fsp` mod as well
  as fsp specific UI managers (`maybe_open_vlm_display()`,
  `start_fsp_displays()`).
- add an `FspAdmin` API for starting fsp chains on the cluster
  concurrently allowing for future work toward reload/unloading.
- bring FSP config dict into `start_fsp_displays()` and `.started()`-deliver
  both the fsp admin and any volume chart back up to the calling display
  loop code.

ToDo:
- repair `ChartView` click-drag interactions
- auto-range on $ vlm needs to use `ChartPlotWidget._set_yrange()`
- a lot better styling for the $_vlm overlay XD
2022-01-25 08:24:55 -05:00
Tyler Goodlet 7a41c83f84 Move FSP related graphics management into new mod 2022-01-25 08:24:55 -05:00
Tyler Goodlet b7f27f201f Add `try_read()` to shm mod 2022-01-25 08:24:55 -05:00
goodboy 05b8e3a199
Merge pull request #257 from pikers/plotitem_overlays
`PlotItem` overlays
2022-01-25 08:24:23 -05:00
Tyler Goodlet 0ae79d6418 Drop `pyqtgraph` import 2022-01-25 07:59:08 -05:00
Tyler Goodlet d170132eb5 Use view for auto-yrange in display loop 2022-01-25 07:59:08 -05:00
Tyler Goodlet ced310c194 Add `ChartPlotWidget.maxmin()` to calc in-view hi/lo y-values
As part of factoring `._set_yrange()` into the lower level view box,
move the y-range calculations into a new method. These calcs should
eventually be completely separate (as they are for the real-time version
in the graphics display update loop) and likely part of some kind of
graphics-related lower level management API. Draft such an API as an
`ArrayScene` (commented for now) as a sketch toward factoring array
tracking **out of** the chart widget. Drop the `'ohlc'` array name and
instead always use whatever `.name` was assigned to the chart widget
to lookup its "main" / source data array for now.

Enable auto-yranging on overlayed plotitems by enabling on its viewbox
and, for now, assign an ad-hoc `._maxmin()` since the widget version
from this commit has no easy way to know which internal array to use. If
an FSP (`dolla_vlm` in this case) is overlayed on an existing chart
without also having a full widget (which it doesn't in this case since
we're using an overlayed `PlotItem` instead of a full `ChartPlotWidget`)
we need some way to define the `.maxmin()` for the overlayed
data/graphics. This likely means the `.maxmin()` will eventually get
factored into wtv lowlevel `ArrayScene` API mentioned above.
2022-01-25 07:59:08 -05:00
Tyler Goodlet fbb765e1d8 Import overlay from new internal module 2022-01-25 07:59:08 -05:00
Tyler Goodlet 80d16886cb Add auto-yrange handler to our `ChartView`
Calculations for auto-yaxis ranging are both signalled and drawn by our
`ViewBox` so we might as well factor this handler down from the chart
widget into the view type. This makes it much easier (and clearer) that
`PlotItem` and other lower level overlayed `GraphicsObject`s can utilize
*size-to-data* style view modes easily without widget-level coupling.

Further changes,
- support a `._maxmin()` internal callable (temporarily) for allowing
  a viewed graphics object to define it's own y-range max/min calc.
- add `._static_range` var (though usage hasn't been moved from the
  chart plot widget yet
- drop y-axis click-drag zoom instead reverting back to default viewbox
  behaviour with wheel-zoom and click-drag-pan on the axis.
2022-01-25 07:59:08 -05:00
Tyler Goodlet e66b3792bb Add overlay relay signals and attr to our `ChartView` 2022-01-25 07:59:08 -05:00
Tyler Goodlet 4b89f7197a Move multi-view overlay components in from `pyqtgraph` PR
This brings in the WIP components developed as part of
https://github.com/pyqtgraph/pyqtgraph/pull/2162.

Most of the history can be understood from that issue and effort but the
TL;DR is,

- add an event handler wrapper system which can be used to
  wrap `ViewBox` methods such that multiple views can be overlayed and
  a single event stream broadcast from one "main" view to others which
  are overlaid with it.
- add in 2 relay `Signal` attrs to our `ViewBox` subtype (`Chartview`)
  to accomplish per event `MouseEvent.emit()` style broadcasting to
  multiple (sub-)views.
- Add a `PlotItemOverlay` api which does all the work of overlaying the
  actual chart graphics and arranging multiple-axes without collision as
  well as tying together all the event/signalling so that only a single
  "focussed" view relays to all overlays.
2022-01-25 07:59:08 -05:00
Tyler Goodlet 637c9c65e9 Drop old grid-based overlay cruft 2022-01-25 07:59:08 -05:00
Tyler Goodlet 12e04d57f8 Add a "composed" layout for arbitrary multi-axes
Each `pyqtgraph.PlotItem` uses a `QGraphicsGridLayout` to place its view
box, axes and titles in the traditional graph format. With multiple
overlayed charts we need those axes to not collide with one another and
further allow for an "order" specified by the user. We accomplish this
by adding `QGraphicsLinearLayout`s for each axis "side": `{'left',
'right', 'top', 'bottom'}` such that plot axes can be inserted and moved
easily without having to constantly re-stack/order a grid layout (which
does not have a linked-list style API).

The new type is called `ComposedGridLayout` for now and offers a basic
list-like API with `.insert()`, `.append()`, and eventually a dict-style
`.pop()`. We probably want to also eventually offer a `.focus()` to
allow user switching of *which* main graphics object (aka chart) is "in
use".
2022-01-25 07:59:08 -05:00
Tyler Goodlet 6f07c5e255 Drop 'ohlc' array usage from UI components 2022-01-25 07:59:08 -05:00
Tyler Goodlet 65c3cc5f5f Don't use separate axes by default, force empty default axes set 2022-01-25 07:59:08 -05:00
Tyler Goodlet 3225f254f4 Explicitly accept interaction events in our chart view 2022-01-25 07:59:08 -05:00
Tyler Goodlet 1ccff37677 Only update x-axis cursor if chart has a 'bottom' axis 2022-01-25 07:59:08 -05:00
Tyler Goodlet 9e18afe0d7 WIP `PlotItemOverlay` support to get multi-yaxes
This syncs with a dev branch in our `pyqtgraph` fork:
https://github.com/pyqtgraph/pyqtgraph/pull/2162

The main idea is to get mult-yaxis display fully functional with
multiple view boxes running in a "relay mode" where some focussed view
relays signals to overlaid views which may have independent axes. This
preps us for both displaying independent codomain-set FSP output as well
as so called "aggregate" feeds of multiple fins underlyings on the same
chart (eg. options and futures over top of ETFs and underlying stocks).
The eventual desired UX is to support fast switching of instruments for
order mode trading without requiring entirely separate charts as well as
simple real-time anal of associated instruments.

The first effort here is to display vlm and $_vlm alongside each other
as a built-in FSP subchart.
2022-01-25 07:59:08 -05:00
goodboy 0131160896
Merge pull request #256 from pikers/misc_backend_fixes
Misc backend fixes
2022-01-25 07:58:30 -05:00
Tyler Goodlet 8e390278f5 Handle logging against IPC stream vs. throttled channel on overruns 2022-01-25 07:57:01 -05:00
Tyler Goodlet 47d0c81a2d Only warn if trigger predicate was already popped 2022-01-25 07:57:01 -05:00
Tyler Goodlet 0744eb78a6 Lul, adhere to returning `str`s in `humanize()` 2022-01-25 07:57:01 -05:00