Commit Graph

2103 Commits (531989a9e52a323c213efd5309de504f677fa139)

Author SHA1 Message Date
Tyler Goodlet 9e4786e62f Initial dynamic option chain UI draft
There's still a ton to polish (and some bugs to fix) but this is a first
working draft of a real-time option chain!

Insights and todos:
- `kivy` widgets need to be cached and reused (eg. rows, cells, etc.)
  for speed since it seems creating new ones constantly is quite taxing
  on the CPU
- the chain will tear down and re-setup the option data feed stream each
  time a different contract expiry button set is clicked
- there's still some weird bug with row highlighting where it seems rows
  added from a new expiry set (which weren't previously rendered) aren't
  being highlighted reliably
2018-12-13 13:04:05 -05:00
Tyler Goodlet 1d1be9dd77 Include option stream subscription change in test 2018-12-11 17:10:36 -05:00
Tyler Goodlet 743ca6bfe3 Log quotes even without caching 2018-12-11 17:09:59 -05:00
Tyler Goodlet 7b5c73bb45 Use pythonic sequence splitting with `zip()` 2018-12-11 17:09:36 -05:00
Tyler Goodlet e1be80e9e0 Subscription teardown is done server side on disconnect now 2018-12-11 15:22:34 -05:00
Tyler Goodlet e7378538f6 Limit option chain to 1 rps 2018-12-11 15:21:45 -05:00
Tyler Goodlet 66ecb4c0cb Use a `trio.Event` to guarantee respawning of data feed task 2018-12-11 15:21:12 -05:00
Tyler Goodlet 01c0551a7f Don't display greeks besides delta for now 2018-12-11 15:20:24 -05:00
Tyler Goodlet 201919eef7 Initial option chain UI
Spin it up with `piker optschain`.
Still lots of polishing and features to add but it's a start!
2018-12-10 02:00:10 -05:00
Tyler Goodlet 8647216b75 Tabular kivy UI improvements
`Row`:
- `no_cell`: support a list of keys for which no cells will be created
- allow passing in a `cell_type` at instantiation

`TickerTable`:
- keep track of rendered rows via a private `_rendered` set
- don't create rows inside `append_row()` expect caller to do it
- never render already rendered widgets in `render_rows()`

Miscellaneous:
- generalize `update_quotes()` to not be tied to specific quote fields
  and allow passing in a quote `formatter()` func
- don't bother creating a nursery block until necessary in main
- more commenting
2018-12-10 01:51:49 -05:00
Tyler Goodlet 20778b02b5 Format numerical option fields 2018-12-10 01:50:00 -05:00
Tyler Goodlet 54261ecc4c Refer to async exit stack via feed 2018-12-10 01:49:19 -05:00
Tyler Goodlet fb47ea2e5a Define option field structure
Add some extra fields to each quote that QT should already be
providing (instead of hiding them in the symbol and request contract
info); namely, the expiry and contact type (i.e. put or call).
Define the base set of fields to be displayed in an option chain
UI and add a quote formatter.
2018-12-09 13:40:26 -05:00
Tyler Goodlet 9c7ca84fef Include strike and expiry in option quotes 2018-12-09 13:40:26 -05:00
Tyler Goodlet 9f3a316ccf Improve CPU usage using a clock trigger and deque
Copy out `kivy.clock.triggered` from version 1.10.1 since it isn't yet
available in the `trio`/async branch and use it to throttle the callback
rate. Use a `collections.deque` to LIFO iterate widgets each call
using the heuristic that it's more likely the mouse is still within the
currently highlighted (or it's adjacent neighbors) widget as opposed
to some far away widget (the case when the mouse is moved very
drastically across the window).
2018-12-09 13:39:38 -05:00
Tyler Goodlet b8815cde4a Set statespace defaults in `get_cached_feed()` 2018-12-09 13:30:34 -05:00
Tyler Goodlet eee19048f0 Support "mouse over" groups
Add a type factory func which returns mixin-able types for creating
mutex highlight-able groups of widgets.
2018-12-01 19:01:36 -05:00
Tyler Goodlet fd94a24d84 Rename to `mouse_over` 2018-12-01 18:43:44 -05:00
Tyler Goodlet 5c070b1c43 Faster highlighting via single loop and callback
Thanks yet again to @tshirtman for suggesting this.

Instead of defining a `on_mouse_pos()` on every widget simply
register and track each widget and loop through them all once (or as much
as is necessary) in a single callback. The assumption here is that we
get a performance boost by looping widgets instead of having `kivy` loop
and call back each widget thus avoiding costly python function calls.
2018-12-01 18:39:01 -05:00
goodboy 0fbab8b831
Merge pull request #60 from pikers/options_streaming
Options streaming
2018-12-01 18:35:28 -05:00
Tyler Goodlet 42f7a1092b Update deps 2018-12-01 17:10:59 -05:00
Tyler Goodlet 12d5627860 Aggregate streaming tests and test stocks + options together 2018-12-01 16:14:33 -05:00
Tyler Goodlet 2df5c76828 Adjust cli tests for new quotes list output 2018-12-01 16:13:15 -05:00
Tyler Goodlet 7378a16b90 s/tickers/symbols 2018-12-01 16:12:46 -05:00
Tyler Goodlet 2915e83324 Warn about missing symbols at CLI level 2018-12-01 16:11:38 -05:00
Tyler Goodlet 61294c6c44 Adhere to the same non-found-symbol behaviour as QT 2018-12-01 16:09:41 -05:00
Tyler Goodlet f35671cc88 Handle bad symbol names 2018-12-01 16:08:03 -05:00
Tyler Goodlet 15dec65ba1 Add an options streaming test 2018-11-30 08:18:54 -05:00
Tyler Goodlet 48a9c389c5 Add loglevel support to tests 2018-11-30 08:18:13 -05:00
Tyler Goodlet 288ea604af Call start_quote_stream() from monitor main 2018-11-30 08:17:54 -05:00
Tyler Goodlet c2ec4800d6 Port cli to new options api 2018-11-30 08:16:31 -05:00
Tyler Goodlet cabc616b85 Port option api to new backend broker api 2018-11-30 08:14:36 -05:00
Tyler Goodlet c7cf0cde9c Add options streaming
Well that was a doozy; had to rejig pretty much all of it.

The deats:
- Track broker components in a new `DataFeed` namedtuple
- port to new list based batch quotes (not dicts any more)
- lock access to cached broker-client / data-feed instantiation
- respawn tasks that fail due to the network
2018-11-30 08:13:30 -05:00
Tyler Goodlet cd7d8d024d Add option quoter support for streaming
So much changed to get this working for both stocks and options:
- Index contracts by a new `ContractsKey` named tuple
- Move to pushing lists of quotes instead of dicts since option
  subscriptions are often not identified by their "symbol" key and
  this makes it difficult at fan out time to know how a quote should
  be indexed and delivered. Instead add a special `key` entry to each
  quote dict which is the quote's subscription key.
2018-11-30 00:33:40 -05:00
Tyler Goodlet 75d22c6058 An explicit name is prolly better 2018-11-25 19:23:07 -05:00
Tyler Goodlet 714c203c3e Cache symbol ids where possible
Cache both in the client and at the function call level inside the
quoter context using a `@afifo_cache`.
2018-11-25 15:00:08 -05:00
Tyler Goodlet af464b45ff Add an async function cache with a LIFO policy
Relates to #59
2018-11-25 14:55:55 -05:00
goodboy 84f357b7eb
Merge pull request #58 from pikers/monitor_polish
Monitor polish
2018-11-24 17:52:42 -05:00
Tyler Goodlet a8a5e836b9 Use static instruction for highlighted row
Instead of all this adding/removing of canvas instructions nonsense
simple add a static "highlighted" rectangle to each row and make its
size very small when there's no mouse over.

Mad props to @tshirtman for showing me the light :D
2018-11-24 16:17:06 -05:00
Tyler Goodlet 488bdb34be Add mouse-over row highlighting 2018-11-23 22:21:53 -05:00
Tyler Goodlet 3ea28f04a4 Mention 3.7 in Readme 2018-11-23 11:22:44 -05:00
Tyler Goodlet a7f3008d34 Match the author's general apparel
It's still a bit of a shit show, and I've left a lot of commented tweaks
that need to be further played with, but I think this is a much
better look for what I'm considering to be one of the main "entry point"
apps for `piker`. To get any more serious fine tuning the way I want
I may have to talk to some kivy experts as I'm having some headaches
with button borders, padding, and the header row height..

Some of the new changes include:
- port to the new `brokers.data` module
- much darker theme with a stronger terminal vibe
- last trade price and volume amount flash on each trade
- fixed the symbol search bar to be a static height; before it was
  getting squashed oddly when using stacked windows
- make all the cells transparent (for now) such that I can just use
  a row color (relates to cell padding/spacing - can't seem to ditch it)
- start adding type annotations
2018-11-23 10:50:40 -05:00
Tyler Goodlet 0f3faec35d Reduce the scroll boundary bounce 2018-11-22 19:39:40 -05:00
goodboy 0f53cbbd95
Merge pull request #56 from pikers/options_chain
Options chain (backend support)
2018-11-22 19:24:54 -05:00
Tyler Goodlet e1d6edb3ee Skip qt tests on missing brokers.ini entry 2018-11-22 19:12:14 -05:00
Tyler Goodlet eaa2a9b05d Port streaming test to new `data` module 2018-11-22 16:31:53 -05:00
Tyler Goodlet d102b82566 Don't add more then one stderr handler 2018-11-22 16:31:01 -05:00
Tyler Goodlet b9a9b7a9a3 Add options query and data feed recording commands
Add `contracts` and `optsquote` commands for querying option contracts
info and market quotes respectively. Add a `record` command for
streaming real-time data feed quotes to disk. Port `monitor` to the
new `piker.brokers.data` module. Forward loglevel flags through to
`tractor` for relevant commands.
2018-11-22 16:21:15 -05:00
Tyler Goodlet c23982393d Allow recording data feeds to disk
Add a couple functions for storing and retrieving live json data feed
recordings to disk using a very rudimentary character + newline delimited
format.

Also, split out the pub-sub logic from `stream_quotes()` into a new
func, `fan_out_to_chans()`. Eventually I want to formalize this pattern
into a decorator exposed through `tractor`.
2018-11-22 15:56:02 -05:00
Tyler Goodlet f038fdd42f Add a `contracts()` query
Makes it easy to request all the option contracts for a particular symbol.
Also, let `option_chain()` accept a `date` arg which can be used to only
retrieve quotes for a single expiry date (much faster then getting all
of them).
2018-11-22 15:53:00 -05:00