Commit Graph

817 Commits (f072e2551b7af38ff1f8eac78582eea7ebbb126a)

Author SHA1 Message Date
Tyler Goodlet 58b2e7e395 Refer to main chart's data for date axis 2020-10-02 12:13:28 -04:00
Tyler Goodlet f46fa99a6e Add "contents" labels to charts
Add a default "contents label" (eg. OHLC values for bar charts) to each
chart and update on crosshair interaction.

Few technical changes to make this happen:
- adjust bar graphics to have the HL line be in the "middle" of the
  underlying arrays' "index range" in the containing view.
- add a label dict each chart's graphics name to a label + update routine
- use symbol names instead of this "main" identifier crap for referring to
  particular price curves/graphics
2020-10-02 12:13:28 -04:00
Tyler Goodlet 61e460a422 Start brokers.api module 2020-10-02 12:13:28 -04:00
Tyler Goodlet fd21f4b0fe WIP initial draft of FSP subsystem
This is a first attempt at a financial signal processing subsystem which
utilizes async generators for streaming frames of numpy array data
between actors. In this initial attempt the focus is on processing price
data and relaying it to the chart app for real-time display. So far this
seems to work (with decent latency) but much more work is likely needed
around improving the data model for even better latency and less data
duplication.

Surprisingly (or not?) a lot of simplifications to the charting code
came out of this in terms of conducting graphics updates in streaming
tasks instead of hiding them inside the obfuscated mess that is the
Qt-style-inheritance-OO-90s-trash. The goal from here on wards will be
to enforce strict semantics around reading and writing of data such that
state is kept outside "object trees" as much as possible and streaming
function semantics guide our flow model. Unsurprisingly, this reduction
in "instance state" is happening wherever we use `trio` ;)

A little summary on the technical changes:
- not going to explain the fsp system yet; it's too nascent and
  probably going to get some heavy editing.
- drop any "update" methods from the `LinkedCharts` type since each
  sub-chart will have it's own update task and thus a separate update
  loop; further individual graphics (per chart) may eventually require
  this same design.
- delete `ChartView`; moved into separate mod.
- add "stream from fsp" task to start our foray into real-time actor
  processed numpy streaming.
2020-10-02 12:13:28 -04:00
Tyler Goodlet edb32e8c2b Drop weird chart type enum 2020-10-02 12:13:28 -04:00
Tyler Goodlet 04e21a96da Use partial, pass kwargs to `tractor._main()` 2020-10-02 12:13:28 -04:00
Tyler Goodlet a29b7d9be5 Start "interaction" module 2020-10-02 12:13:28 -04:00
Tyler Goodlet 8a46f8d6ed Port monitor to normalized streams 2020-10-02 12:13:28 -04:00
Tyler Goodlet 241b2374e8 Port `DataFeed` api to broker specific normalizer routine 2020-10-02 12:13:28 -04:00
Tyler Goodlet 9bbf0e0d7a Add a normalizer routine which emits quote differentials/ticks 2020-10-02 12:13:28 -04:00
Tyler Goodlet 81fb327fe1 Add `services` cmd for monitoring actors 2020-10-02 12:13:28 -04:00
Tyler Goodlet 65fb92eaff Flatten out chart tasks 2020-10-02 12:13:28 -04:00
Tyler Goodlet 6b572eb0ef Add ravel() reference link 2020-10-02 12:13:28 -04:00
Tyler Goodlet 971b871647 Handle "mouse-not-on-plot" edge cases 2020-10-02 12:13:28 -04:00
Tyler Goodlet b2506b04f6 Attempt more reliable chart startup
Wait for a first actual real-time quote before starting graphics update
tasks. Use the new normalized tick format brokers are expected to emit
as a `quotes['ticks']` list. Auto detect time frame from historical
bars.
2020-10-02 12:13:28 -04:00
Tyler Goodlet d81f6620f5 Passthrough loglevel from qtractor 2020-10-02 12:13:28 -04:00
Tyler Goodlet 2eea946e5b Drop forkserver usage.
We've got the sweet and realable `trio` spawner now :)
2020-10-02 12:13:28 -04:00
Tyler Goodlet 1a143f6b16 Pass piker log level through to tractor for chart app 2020-10-02 12:13:28 -04:00
Tyler Goodlet 7a78c3a1c7 Add a couple more deps 2020-10-02 12:13:28 -04:00
Tyler Goodlet dc919fa676 Set tractor loglevel in cli config 2020-10-02 12:13:28 -04:00
Tyler Goodlet ec4f7476c5 Drop "pipfiles"; pipenv is getting the hard boot 2020-10-02 12:13:28 -04:00
Tyler Goodlet cb8215c203 Also log the payload 2020-10-02 12:13:28 -04:00
Tyler Goodlet 46c804db0b Support the `stream_quotes()` api in questrade backend 2020-10-02 12:13:28 -04:00
Tyler Goodlet ad519c10a9 Always just look up the current plot on mouse handling 2020-10-02 12:13:28 -04:00
Tyler Goodlet bbe02570b3 Allow for dynamically added plots
Add `ChartPlotWidget.add_plot()` to add sub charts for indicators which
can be updated independently. Clean up rt bar update code and drop some
legacy ohlc loading cruft.
2020-10-02 12:13:28 -04:00
Tyler Goodlet b4f1ec7960 Massively simplify the cross-hair monstrosity
Stop with all this "main chart" special treatment.
Manage all lines in the same way across all referenced plots.
Add `CrossHair.add_plot()` for adding new plots dynamically.

Just, smh.
2020-10-02 12:13:28 -04:00
Tyler Goodlet c56aee6347 Use array of names for lookup 2020-10-02 12:13:28 -04:00
Tyler Goodlet 788771bd75 Change name to qtractor 2020-10-02 12:13:28 -04:00
Tyler Goodlet 3aebeb5801 Standardize ohlc dtype 2020-10-02 12:13:28 -04:00
Tyler Goodlet e5bca1e089 Fix import error 2020-10-02 12:13:28 -04:00
Tyler Goodlet 88fb7a8951 Handle overloaded arg 2020-10-02 12:13:28 -04:00
Tyler Goodlet 1a1e768126 Port to new data apis 2020-10-02 12:13:28 -04:00
Tyler Goodlet 6802675637 Add kraken to backend list 2020-10-02 12:13:28 -04:00
Tyler Goodlet f9084b8650 Store lines graphics in struct array to simplify indexing 2020-10-02 12:13:28 -04:00
Tyler Goodlet 4ceffdd83f Drop kivy stuff from docs 2020-10-02 12:13:28 -04:00
Tyler Goodlet 2dd596ec6c Deps bump 2020-10-02 12:13:28 -04:00
Tyler Goodlet b9224cd396 Add WIP real-time 5s bar charting 2020-10-02 12:13:28 -04:00
Tyler Goodlet 4c5bc19ec7 Always convert to posix time 2020-10-02 12:13:28 -04:00
Tyler Goodlet 5f89a2bf08 Make run_qtrio invoke tractor at top level 2020-10-02 12:13:28 -04:00
Tyler Goodlet 2dec32e41f Move bar generation into func; support bar appends
There's really nothing coupling it to the graphics class (which frankly
also seems like it doesn't need to be a class.. Qt).

Add support to `.update_from_array()` for diffing with the input array
and creating additional bar-lines where necessary. Note, there are still
issues with the "correctness" here in terms of bucketing open/close
values in the time frame / bar range. Also, this jamming of each bar's 3
lines into a homogeneous array seems like it could be better done with
struct arrays and avoid all this "index + 3" stuff.
2020-10-02 12:13:28 -04:00
Tyler Goodlet 3c55f7c6e2 Use structure array indexing syntax 2020-10-02 12:13:28 -04:00
Tyler Goodlet 9c1d64413e Handle flat bar updates
Flat bars have a rendering issue we work around by hacking values in `QLineF`
but we have to revert those on any last bar that is being updated in
real-time. Comment out candle implementations for now; we can get back
to it if/when the tinas unite. Oh, and make bars have a little space
between them.
2020-10-02 12:13:28 -04:00
Tyler Goodlet 6b1bdbe3ea Docs the ui pkg mod 2020-10-02 12:13:28 -04:00
Tyler Goodlet 013c0fef15 Fix a bunch of scrolling / panning logic
Don't allow zooming to less then a min number of data points. Allow
panning "outside" the data set (i.e. moving one of the sequence "ends"
to the middle of the view. Start adding logging.
2020-10-02 12:13:28 -04:00
Tyler Goodlet 4c753b5ee6 Add ib 2020-10-02 12:13:28 -04:00
Tyler Goodlet ecfa6d33aa Use msgpack-numpy 2020-10-02 12:13:28 -04:00
Tyler Goodlet 16e2e27cb8 Handle high = low bars
For whatever reason if the `QLineF` high/low values are the same a weird
little rectangle is drawn (my guess is a `float` precision error of some
sort). Instead, if they're the same just use one of the values.
Also, store local vars to avoid so many lookups.
2020-10-02 12:13:28 -04:00
Tyler Goodlet 7a660b335d Make search work with ib backend 2020-10-02 12:13:28 -04:00
Tyler Goodlet 99c18abfea Add symbol search to broker api 2020-10-02 12:13:28 -04:00
Tyler Goodlet 2f1fdaf9e5 Rework charting internals for real-time plotting
`pg.PlotCurveItem.setData()` is normally used for real-time updates to
curves and takes in a whole new array of data to graphics.
It makes sense to stick with this interface especially if
the current datum graphic will originally be drawn from tick quotes and
later filled in when bars data is available (eg. IB has this option in
TWS charts for volume). Additionally, having a data feed api where the push
process/task can write to shared memory and the UI task(s) can read from
that space is ideal. It allows for indicator and algo calculations to be
run in parallel (via actors) with initial price draw instructions
such that plotting of downstream metrics can be "pipelined" into the
chart UI's render loop. This essentially makes the chart UI async
programmable from multiple remote processes (or at least that's the
goal).

Some details:
- Only store a single ref to the source array data on the
  `LinkedSplitCharts`.  There should only be one reference since the main
  relation is **that** x-time aligned sequence.
- Add `LinkedSplitCharts.update_from_quote()` which takes in a quote
  dict and updates the OHLC array from it's contents.
- Add `ChartPlotWidget.update_from_array()` method to trigger graphics
  updates per chart with consideration for overlay curves.
2020-10-02 12:13:28 -04:00