Commit Graph

2096 Commits (75d0bf315274752d25384b4883483be1b2258812)

Author SHA1 Message Date
Tyler Goodlet bb06deef73 Add our own `FastAppendCurve.clear()`, try mem reso
In an effort to try and make `QPainterPath.reserve()` work, add internal
logic to use the same object without de-allocating memory from
a previous path write/creation.

Note this required the addition of a `._redraw` flag (to be used in
`.clear()` and a small patch to `pyqtgraph.functions.arrayToQPath` to
allow passing in an existing path (thus reusing the same underlying mem
alloc) which will likely be first pushed to our fork.
2022-04-13 08:11:33 -04:00
Tyler Goodlet 96da64a0d4 Add optional uppx log scaling to m4 sampler
We were previously ad-hoc scaling up the px count/width to get more
detail at lower uppx values. Add a log scaling sigmoid that range scales
between 1 < px_width < 16.

Add in a flag to use the mxmn OH tracer in `ohlc_flatten()` if desired.
2022-04-13 08:11:33 -04:00
Tyler Goodlet 7bb1ae39fb Delegate to m4 ohlc helper for curve, only ds on uppx steps > 2 2022-04-13 08:11:33 -04:00
Tyler Goodlet adc38af3f5 Add OHLC to m4 line converters
Helpers to quickly convert ohlc struct-array sequences into lines
for consumption by the m4 downsampler. Strip trailing zero entries
from the `ds_m4()` output if found (avoids lines back to origin).
2022-04-13 08:11:33 -04:00
Tyler Goodlet 541e3182ac M4 workin bishhhhh 2022-04-13 08:11:33 -04:00
Tyler Goodlet b1d3f18808 Call default view on symbol switch 2022-04-13 08:11:33 -04:00
Tyler Goodlet 0394a9d235 Make a derivs intrustment type table for alloc config checks 2022-04-13 08:11:33 -04:00
Tyler Goodlet 48257f0a0c Even more correct "default view" snap-to-pp-marker
This makes the `'r'` hotkey snap the last bar to the middle of the pp
line arrow marker no matter the zoom level. Now we also boot with
approximately the most number of x units on screen that keep the bars
graphics drawn in full (just before downsampling to a line).

Moved some internals around to get this all in place,
- drop `_anchors.marker_right_points()` and move it to a chart method.
- change `.pre_l1_x()` -> `.pre_l1_xs()` and just have it return the
  two view-mapped x values from the former method.
2022-04-13 08:11:33 -04:00
Tyler Goodlet 8b181930a1 Make `ChartPlotWidget.default_view()` pin to L1
Instead of using a guess about how many x-indexes to reset the last
datum in-view to, calculate and shift the latest index such that it's
just before any L1 spread labels on the y-axis. This makes the view
placement "widget aware" and gives a much more cross-display UX.

Summary:
- add `ChartPlotWidget.pre_l1_x()` which returns a `tuple` of
  x view-coord points for the absolute x-pos and length of any L1
  line/labels
- make `.default_view()` only shift to see the xlast just outside
  the l1 but keep whatever view range xfirst as the first datum in view
- drop `LevelLine.right_point()` since this is now just a
  `.pre_l1_x()` call and can be retrieved from the line's internal chart
  ref
- drop `._style.bars_from/to_..` vars since we aren't using hard coded
  offsets any more
2022-04-13 08:11:33 -04:00
Tyler Goodlet 3187413b77 Pass in fqsn from chart UI components 2022-04-13 08:11:33 -04:00
Tyler Goodlet 3f060ac53a Pass in fqsn from fsp admin apis 2022-04-13 08:11:33 -04:00
Tyler Goodlet bc9ea7773f Use units by default for continuous futes 2022-04-13 08:11:33 -04:00
Tyler Goodlet 8e01568c78 WIP add non-working m4 ds code to ohlc graphic 2022-04-13 08:11:33 -04:00
Tyler Goodlet d3cd49e0b6 Use service cancel method for graceful teardown 2022-04-13 08:11:33 -04:00
Tyler Goodlet 20bfb0016b Add curve px width getter
`ChartPlotWidget.curve_width_pxs()` now can be used to get the total
horizontal (x) pixels on screen that are occupied by the current curve
graphics for a given chart. This will be used for downsampling large
data sets to the pixel domain using M4.
2022-04-13 08:11:33 -04:00
Tyler Goodlet 3441d3a196 Add display loop profiling
Probably the best place to root the profiler since we can get a better
top down view of bottlenecks in the graphics stack.

More,
- add in draft M4 downsampling code (commented) after getting it mostly
  working; next step is to move this processing into an FSP subactor.
- always update the vlm chart last y-axis sticky
- set call `.default_view()` just before inf sleep on startup
2022-04-13 08:11:33 -04:00
Tyler Goodlet 5c1c7ac32e Profiler format, code stretch 2022-04-13 08:11:33 -04:00
Tyler Goodlet 9ed1ed7c41 Fix x-range -> # of frames calculation
Obviously determining the x-range from indices was wrong and was the
reason for the incorrect (downsampled) output size XD. Instead correctly
determine the x range and start value from the *values of* the input
x-array. Pretty sure this makes the implementation nearly production
ready.

Relates to #109
2022-04-13 08:11:33 -04:00
Tyler Goodlet 052a75b59b Add `ChartPlotWidget.in_view()` shm-compatible array slicer 2022-04-13 08:11:33 -04:00
Tyler Goodlet ae36d2cecf Add (ostensibly) working first attempt at M4 algo
All the refs are in the comments and original sample code from infinite
has been reworked to expect the input x/y arrays to already be sliced
(though we can later support passing in the start-end indexes if
desired).

The new routines are `ds_m4()` the python top level API and `_m4()` the
fast `numba` implementation.
2022-04-13 08:11:33 -04:00
Tyler Goodlet 638caada4e Array diff lengths must be int 2022-04-13 08:11:33 -04:00
Tyler Goodlet fa28a15cbb Limit real-time chart updates in "big data" cases
- the chart's uppx (units-per-pixel) is > 4 (i.e. zoomed out a lot)
- don't shift the chart (to keep the most recent step in view) if the
  last datum isn't in view (aka the user is probably looking at history)
2022-04-13 08:11:33 -04:00
Tyler Goodlet bc2805d14e Only trigger downsampling on manual changes, add a uppx method 2022-04-13 08:11:33 -04:00
Tyler Goodlet 8c9ffb2c22 Add for a `BarItems` to display a line on high uppx
When a bars graphic is zoomed out enough you get a high uppx, datum
units-per-pixel, and there is no point in drawing the 6-lines in each
bar element-graphic if you can't see them on the screen/display device.

Instead here we offer converting to a `FastAppendCurve` which traces
the high-low outline and instead display that when it's impossible to see the
details of bars - approximately when the uppx >= 2.

There is also some draft-commented code in here for downsampling the
outlines as zoom level increases but it's not fully working and should
likely be factored out into a higher level api anyway.
2022-04-13 08:11:33 -04:00
Tyler Goodlet 35fd39d769 Original index offset was right 2022-04-13 08:11:33 -04:00
Tyler Goodlet d7c41ef406 Add an ohlcv high/low tracer with optional downsampling 2022-04-13 08:11:33 -04:00
Tyler Goodlet 08b11bc049 Pass linked charts into `BarItems` so that graphics can be cycled on downsample 2022-04-13 08:11:33 -04:00
Tyler Goodlet e222f5817f Move graphics compression routines to new module 2022-04-13 08:11:33 -04:00
Tyler Goodlet b4f6d645bb Use 12Hz as default fps throttle 2022-04-13 08:11:33 -04:00
Tyler Goodlet 1ba9569ca8 Add comment on how to enable `pyqtgraph` profiling 2022-04-13 08:11:33 -04:00
Tyler Goodlet 0b9d5cb018 Add basic optional polyline support, draft out downsampling routine 2022-04-13 08:11:33 -04:00
Tyler Goodlet 6a644d2f45 Add a downsampled line-curve support to `BarItems`
In effort to start getting some graphics speedups as detailed in #109,
this adds a `FastAppendCurve`to every `BarItems` as a `._ds_line` which
is only displayed (instead of the normal mult-line bars curve) when the
"width" of a bar is indistinguishable on screen from a line -> so once
the view coordinates map to > 2 pixels on the display device.
`BarItems.maybe_paint_line()` takes care of this scaling detection logic and is
called by the associated view's `.sigXRangeChanged` signal handler.
2022-04-13 08:11:33 -04:00
Tyler Goodlet ff8b17f492 Use a `DisplayState` in the graphics update loop
The graphics update loop is much easier to grok when all the UI
components which potentially need to be updated on a cycle are arranged
together in a high-level composite namespace, thus this new
`DisplayState` addition. Create and set this state on each
`LinkedSplits` chart set and add a new method `.graphics_cycle()` which
let's a caller trigger a graphics loop update manually. Use this method
in the fsp graphics manager such that a chain can update new history
output even if there is no real-time feed driving the display loop (eg.
when a market is "closed").
2022-04-13 08:11:33 -04:00
Tyler Goodlet eb0d3dc26e Facepalm**2: only update on special "update" msg 2022-04-13 08:11:33 -04:00
Tyler Goodlet f35e85ddaf Facepalm: display state must be linked charts specific 2022-04-13 08:11:33 -04:00
Tyler Goodlet d5f293d43d Add detailed `.addItem()`` comment 2022-04-13 08:11:33 -04:00
Tyler Goodlet 3635778be0 Manually trigger graphics loops updates on msgs from the fsp chain 2022-04-13 08:11:33 -04:00
Tyler Goodlet c709b31887 Always fire a "step/update message" on every fsp history update 2022-04-13 08:11:33 -04:00
Tyler Goodlet f1ef6c3cc7 Factor sync part of graphics update into func, add `trigger_update()`` 2022-04-13 08:11:33 -04:00
Tyler Goodlet 56451c42fd Add guard for real-time-not-active last line is `None` case 2022-04-13 08:11:33 -04:00
goodboy fbabfb78e0
Merge pull request #294 from pikers/broker_bumpz
Broker bumpz
2022-04-13 08:10:44 -04:00
Tyler Goodlet 4d23f6e4d7 Drop need for `ib_insync.IB.qualifyContractsAsync()' mod
As per https://github.com/erdewit/ib_insync/pull/454 the more correct
way to do this is with `.reqContractDetailsAsync()` which we wrap with
`Client.con_deats()` and which works just as well. Further drop all the
`dict`-ifying that was being done in that method and instead always
return `ContractDetails` object in an fqsn-like explicitly keyed `dict`.
2022-04-13 00:39:15 -04:00
Tyler Goodlet 8b1c521ae9 Ignore symbol-not-found errors 2022-04-13 00:39:15 -04:00
Tyler Goodlet 7586e20ab4 Use new unpacker helper name 2022-04-13 00:39:15 -04:00
Tyler Goodlet 80d70216f7 Drop back down ohlc bars request count to not trigger feed hack 2022-04-13 00:39:15 -04:00
Tyler Goodlet d1f45b0883 Add `ShmArray.last()` docstr 2022-04-13 00:39:15 -04:00
Tyler Goodlet 00a7f20292 Up the shm size to 10d of 1s ohlc 2022-04-13 00:39:15 -04:00
Tyler Goodlet 0178fcd26f Increase shm size to days of 1s steps 2022-04-13 00:39:15 -04:00
Tyler Goodlet 24fa1b8ff7 Support an array field map to `ShmArray.push()`, start index 3days in 2022-04-13 00:39:15 -04:00
Tyler Goodlet 66ea74c6d5 Put back more bars iters in loop to handle no-data in range cases 2022-04-13 00:39:15 -04:00