Commit Graph

719 Commits (c8537d59a85e0adad7034e2d5a5034f734e8727a)

Author SHA1 Message Date
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
Tyler Goodlet 5e8e48c7b7 Support updating bars graphics from array
This makes a OHLC graphics "sequence" update very similar (actually API
compatible) with `pg.PlotCurveItem.setData()`. The difference here is
that only latest OHLC datum is used to update the charts last bar.
2020-10-02 12:13:28 -04:00
Tyler Goodlet 048a13dd0e Drop disk caching of quotes 2020-10-02 12:13:28 -04:00
Tyler Goodlet 6ba0692851 Revert weird bad .time access 2020-10-02 12:13:28 -04:00
Tyler Goodlet d993147f78 Factor signalling api into new module 2020-10-02 12:13:28 -04:00
Tyler Goodlet cc4b51cb17 Rip out all usage of `quantdom.bases.Quotes` smh. 2020-10-02 12:13:28 -04:00
Tyler Goodlet 14bff66ec5 Add a sane pandas.DataFrame to recarray converter 2020-10-02 12:13:28 -04:00
Tyler Goodlet 0b5af4b590 Move all Qt components into top level ui module 2020-10-02 12:13:28 -04:00
Tyler Goodlet 82a5daf91b Move all kivy ui components to subpackage 2020-10-02 12:13:28 -04:00
Tyler Goodlet 9d6dffe5ec Cleanup yrange auto-update callback
This was a mess before with a weird loop using the parent split charts
to update all "indicators". Instead just have each plot do its own
yrange updates since the signals are being handled just fine per plot.
Handle both the OHLC and plane line chart cases with a hacky `try:,
except IndexError:` for now.

Oh, and move the main entry point for the chart app to the relevant
module. I added some WIP bar update code for the moment.
2020-10-02 12:13:28 -04:00
Tyler Goodlet 36ac26cdcf Add zeroed ohlc array constructor 2020-10-02 12:13:28 -04:00
Tyler Goodlet 51f302191a Add update method for last bars graphic 2020-10-02 12:13:28 -04:00
Tyler Goodlet b82587f665 Use a single array for all lines
Speed up the lines array creation using proper slice assignment.
This gives another 10% speedup to the historical price rendering.
Drop ``_tina_mode`` support for now since we're not testing it.
2020-10-02 12:13:28 -04:00
Tyler Goodlet 45906c2729 Render plots from provided input sequence(s)
Previously graphics were loaded and rendered implicitly during the
import and creation of certain objects. Remove all this and instead
expect client code to pass in the OHLC sequence to plot. Speed up
the bars graphics rendering by simplifying to a single iteration of
the input array; gives about a 2x speedup.
2020-10-02 12:13:28 -04:00
Tyler Goodlet f77a39ceb7 Add symbol-info command 2020-10-02 12:13:28 -04:00
Tyler Goodlet 613564b0f5 Add ui package mod 2020-10-02 12:13:28 -04:00
Tyler Goodlet 507368a13a Don't scroll right after max zoom 2020-10-02 12:13:28 -04:00
Tyler Goodlet 6fa173a1c1 Factor components into more suitably named modules 2020-10-02 12:13:28 -04:00
Tyler Goodlet ac389c30d9 Move drawing and resize behavior into chart widget 2020-10-02 12:13:28 -04:00
Tyler Goodlet d8ca799504 Start grouping interactions into a ``ViewBox``
Move chart resize code into our ``ViewBox`` subtype (a ``ChartView``)
in an effort to start organizing interaction behaviour closer to the
appropriate underlying objects. Add some docs for all this and do some
renaming.
2020-10-02 12:13:28 -04:00
Tyler Goodlet fbce0334ad Lol I guess we probably need this 2020-10-02 12:13:28 -04:00
Tyler Goodlet a7fe18cba9 Factor common chart configuration 2020-10-02 12:13:28 -04:00
Tyler Goodlet 730241bb8a Add scrolling from right and cross-hair
Modify the default ``ViewBox`` scroll to zoom behaviour such that
whatever right-most point is visible is used as the "center" for
zooming. Add a "traditional" cross-hair cursor.
2020-10-02 12:13:28 -04:00
Tyler Goodlet c8afdb0adc Styling, start re-org, commenting
- Move out equity plotting to new module.
- Make axis margins and fonts look good on i3.
- Adjust axis labels colors to gray.
- Start commenting a lot of the code after figuring out what it all does
  when cross referencing with ``pyqtgraph``.
- Add option to move date axis to middle.
2020-10-02 12:13:27 -04:00
Tyler Goodlet 2ad3b6f080 Add piker chart command 2020-10-02 12:13:27 -04:00
Tyler Goodlet b670af484c Move UI spawning cmds to new module 2020-10-02 12:13:27 -04:00
Tyler Goodlet eddd8aacab Add charting components from `Quantdom`
Hand select necessary components to get real-time charting with
`pyqtgraph` from the `Quantdom` projects:
https://github.com/constverum/Quantdom

We've offered to collaborate with the author but have received no
response and the project has not been updated in over a year.
Given this, we are moving forward with taking the required components to
make further improvements upon especially since the `pyqtgraph` project
is now being actively maintained again.

If the author comes back we will be more then happy to contribute
modified components upstream:
https://github.com/constverum/Quantdom/issues/18

Relates to #80
2020-10-02 12:13:27 -04:00
Tyler Goodlet 9c84e3c45d Add initial Qt-trio integration
Use the new "guest mode" available on trio master branch.  Add
entrypoint for `pyqtgraph` based charting based on the `Quantdom`
project.
2020-10-02 12:13:27 -04:00
Tyler Goodlet bb81d7881c Use qt5 and trio guest mode 2020-10-02 12:13:27 -04:00
Tyler Goodlet 503aa8a64a Use darkstyle pkg 2020-10-02 12:13:27 -04:00
Tyler Goodlet 2774611617 Blind stab at a basic chart 2020-10-02 12:13:27 -04:00
goodboy a122acf807
Merge pull request #110 from pikers/ib_backend
Ib backend bbys
2020-10-02 12:11:17 -04:00
Tyler Goodlet 934de1d40a Switch to asyncio support branch in tractor 2020-10-02 10:40:50 -04:00
Tyler Goodlet a526008a95 Add github actions CI; thanks @guilledk! 2020-10-02 10:40:25 -04:00
Tyler Goodlet 2f8737af6a Fix PURE contracts lookup... 2020-09-29 17:06:28 -04:00
Tyler Goodlet 5bb11826f3 Drop unmarketable trades for now 2020-09-29 17:06:28 -04:00
Tyler Goodlet aad9cb2dd0 Support forex pair lookup on ib 2020-09-29 17:06:28 -04:00
Tyler Goodlet b499631d62 Drop to 1k bars on init load 2020-09-29 17:06:28 -04:00
Tyler Goodlet ad08cb7a66 Try to find cad stocks 2020-09-29 17:06:28 -04:00
Tyler Goodlet 103014aa58 Properly teardown data feed on cancel 2020-09-29 17:06:28 -04:00
Tyler Goodlet b7c924046a Begin to use `@tractor.msg.pub` throughout streaming API
Since the new FSP system will require time aligned data amongst actors,
it makes sense to share broker data feeds as much as possible on a local
system. There doesn't seem to be downside to this approach either since
if not fanning-out in our code, the broker (server) has to do it anyway
(and who knows how junk their implementation is) though with more
clients, sockets etc. in memory on our end. It also preps the code for
introducing a more "serious" pub-sub systems like zeromq/nanomessage.
2020-09-29 17:06:28 -04:00
Tyler Goodlet 0bf265a96f Future todo 2020-09-29 17:06:28 -04:00
Tyler Goodlet 482dc510fa Add normalization step for ticks
Start a draft normalization format for (sampled) tick data.
Ideally we move toward the dense tick format (DFT) enforced by
techtonicDB, but for now let's just get a dict of something simple
going: `{'type': 'trade', 'price': <price}` kind of thing. This
gets us started being able to real-time chart from all data feed
back-ends. Oh, and hack in support for XAUUSD..and get subactor
logging workin.
2020-09-29 17:06:28 -04:00
Tyler Goodlet aeb58c03e2 Add startup logic to handle market closure 2020-09-29 17:06:28 -04:00
Tyler Goodlet 4ce99e62e0 Override annoying stuff in ib_insync 2020-09-29 17:06:28 -04:00
Tyler Goodlet 41c6517a23 Port to new streaming api, yield whole tickers 2020-09-29 17:06:28 -04:00
Tyler Goodlet 450a39ce1c Add better contract search/lookup
Add a `Client.find_contract()` which internally takes
a <symbol>.<exchange> str as input and uses `IB.qualifyContractsAsync()`
internally to try and validate the most likely contract. Make the module
script call this using `asyncio.run()` for console testing.
2020-09-29 17:06:28 -04:00
Tyler Goodlet b8209cd506 Add a mostly actor aware API to IB backend
Infected `asyncio` support is being added to `tractor` in
goodboy/tractor#121 so delegate to all that new machinery.

Start building out an "actor-aware" api which takes care of all the
`trio`-`asyncio` interaction for data streaming and request handling.
Add a little (shudder) method proxy system which can be used to invoke
client methods from another actor. Start on a streaming api in
preparation for real-time charting.
2020-09-29 17:06:28 -04:00
Tyler Goodlet 1abadeb506 Add initial IB broker backend using ib_insync
Start working towards meeting the backend client api.
Infect `asyncio` using `trio`'s new guest mode and demonstrate
real-time ticker streaming to console.
2020-09-29 17:06:28 -04:00