Commit Graph

3549 Commits (8891da2ff3ee1bd28bf4374a15d070b0544aa48b)

Author SHA1 Message Date
Tyler Goodlet 8891da2ff3 Explicitly decode tick sizes as decimal for symbol loading in `Flume` 2023-04-14 15:57:48 -04:00
Tyler Goodlet 068f5d8eab Cast back to float from decimal for cursor y-increment 2023-04-14 15:57:48 -04:00
Tyler Goodlet 4b57235bd0 Pass old fields in sym info init msg section 2023-04-14 15:57:48 -04:00
Tyler Goodlet 42f7aa994a Ensure `Symbol` tick sizes are decoded as `Decimal`.. 2023-04-14 15:57:48 -04:00
Tyler Goodlet 28f52dae93 `kraken`: use `Client.mkt_info()` in quotes feed init msg 2023-04-14 15:57:48 -04:00
Tyler Goodlet d6634e9b02 Add `MktPair._atype` for back-compat, always `str(.dst)` 2023-04-14 15:57:48 -04:00
Tyler Goodlet 94cb8fa1b1 `kraken`: use `MktPair` in trasactions 2023-04-14 15:57:48 -04:00
Tyler Goodlet 204f9c49d2 `kraken`: add `Client.mkt_info()`
Allows building a `MktPair` from the backend specific `Pair` for
eventual use in the data feed layer. Also adds `Pair.price/tick_size` to
get to the expected tick precision info format.
2023-04-14 15:57:48 -04:00
Tyler Goodlet 3fccd8a67a Drop shm logging levels to debug over warning 2023-04-14 15:57:17 -04:00
Tyler Goodlet 3ead16c47c Flip to `.bs_mktid` in `ib` and `kraken` 2023-04-14 15:57:17 -04:00
Tyler Goodlet b4ab1675fc Handle read and write of `pps.toml` using `MktPair`
Add a logic branch for now that switches on an instance check.
Generally swap over all `Position.symbol` and `Transaction.sym` refs to
`MktPair`. Do a wholesale rename of all `.bsuid` var names to
`.bs_mktid`.
2023-04-14 15:57:17 -04:00
Tyler Goodlet 9ab196d778 Prep for dropping `Transaction.sym`
Instead let's name it `.sys` for "system", the thing we use to conduct
the "transactions" ..

Also rename `.bsuid` -> `.bs_mktid` for "backend system market id`
which is more explicit, easier to remember and read.
2023-04-14 15:57:17 -04:00
Tyler Goodlet e5eb317b47 Further refinement and shimming of `MktPair`
Prepping to entirely replace `Symbol`; this adds a buncha docs/comments,
better implementation for representing and parsing the FQME: "fully
qualified market endpoint".

Deatz:
- make `.src` an optional field until we figure out how we're going
  to support loading source assets from all backends sensibly..
- implement `MktPair.fqme: str` (what was previously called `fqsn`)
  using a new util func: `maybe_cons_tokens()`.
- `Symbol.brokers` and expect only `.broker` usage.
- remap anything with `fqsn` in the name to `fqme` with aliases from the
  old name.
- implement `unpack_fqme()` with `match:` syntax B)
- add `MktPair.tick_size_digits`, `.lot_size_digits`, `.fqsn`, `.key` for
  backward compat.
- make all fqme generation related fields empty `str`s by default.
- add `MktPair.resolved: bool` a flag indicating whether or not `.dst`
  is an `Asset` instance or just a string and, `.bs_mktid` the field
  to hold the "backend system market id" per broker.
2023-04-14 15:57:17 -04:00
Tyler Goodlet 2485bc803b Drop use of `mk_fqsn()` 2023-04-14 15:57:17 -04:00
Tyler Goodlet 9e336f0fc3 Drop use of `Symbol.brokers` everywhere 2023-04-14 15:57:17 -04:00
Tyler Goodlet ee4138ae01 Start to prep `Transaction` for `MktPair`.. 2023-04-14 15:56:48 -04:00
Tyler Goodlet ef915273ea Port `accounting._pos` to new `Symbol` simplifications 2023-04-14 15:56:48 -04:00
Tyler Goodlet b74c41cb77 Delegate to new `.accounting._mktinfo._derivs` from `ui._positioning` 2023-04-14 15:56:48 -04:00
Tyler Goodlet 786372618c `kraken`: write `pps.toml` on updates for now 2023-04-14 15:56:48 -04:00
Tyler Goodlet 4a2696f0ab `kraken`: pack `Asset` into local client cache
Try out using our new internal type for storing info about kraken's asset
infos now stored in the `Client.assets: dict[str, Asset]` table. Handle
a server error when requesting such info msgs.
2023-04-14 15:56:48 -04:00
Tyler Goodlet 8b7563488a `ib`: adjust to new simplified `Symbol`
Drop usage of removed methods and attrs and only pass in the
`.tick_size: Decimal` value during construction.
2023-04-14 15:56:48 -04:00
Tyler Goodlet 04a2ccc42c Drop `Symbol.front_fqsn()` usage from chart, fsp and clearing stuff 2023-04-14 15:56:48 -04:00
Tyler Goodlet 141d6ede9c Drop `Symbol.front_feed()` usage from order mode 2023-04-14 15:56:48 -04:00
Tyler Goodlet e9cedc6613 Simplify `Symbol` extend `MktPair`, add `Asset`
Drop everything we can in terms of methods and attrs from `Symbol`:
- kill `.tokens()`, `.front_feed()`, `.tokens()`, `.nearest_tick()`,
  `.front_fqsn()`, instead moving logic from these methods into
  dependents (and obviously removing any usage from rest of code base,
  coming in follow up commits).
- rename `.quantize_size()` -> `.quantize()`.
- re-implement `.brokers`, `.lot_size_digits`, `.tick_size_digits` as
  `@property` methods; for the latter two, allows us to minimize to only
  accepting min tick decimal values on alternative constructor class
  methods and to drop the equivalent instance vars.
- map `_fqsn` related variable names to new and preferred `_fqme`.

We also juggle around some utility functions, moving limited precision
related `decimal.Decimal` routines to the top of module and soon-to-be
legacy `fqsn` related routines to the bottom.

`MktPair` draft type extensions:
- drop requirements for `src_type`, and offer the optional `.dst_type`
  field as either a `str` or (new `typing.Literal`) `AssetTypeName`.
- define an equivalent `.quantize()` as (re)defined in `Symbol` but with
  `quantity_type: str` field which specifies whether to use the price or
  the size precision.
- add a lot more docs, a `.key` property for the "symbol" name, draft
  property for a `.fqme: str`
- allow `.src` and `.dst` to be of type `str | Asset`

Add a new `Asset` to capture "things which can be used in markets and/or
transactions" XD
- defines a `.name`, `.atype: AssetTypeName` a financial category tag, `tx_tick:
  Decimal` the precision limit for transactions and of course
  a `.quantime()` method for doing accounting arithmetic on a given tech
  stack.
- define the `atype: AssetTypeName` type as a finite set of `str`s
  expected to be used in various ways for default settings in other
  parts of the data and order control layers..
2023-04-14 15:56:48 -04:00
Tyler Goodlet c0a3c6dff7 Move all fqsn parsing and `Symbol` to new `accounting._mktinfo 2023-04-14 15:56:48 -04:00
Tyler Goodlet 33ee647224 (u)Limit the fd allocation for java 8 runtime..
Can't believe this was actually the issue..seriously i don't envy
jvm users.

See following issues:
- https://stackoverflow.com/a/56895801
- https://bugs.openjdk.org/browse/JDK-8150460
2023-04-14 15:56:48 -04:00
Tyler Goodlet 6a935344ca `ib`: (cukcit) just presume a stonk if we can read type from existing ledger.. 2023-04-14 15:56:48 -04:00
Tyler Goodlet a0a19a952f Break out old `.pp` components into submods: `._ledger` and `._pos` 2023-04-14 15:56:48 -04:00
Tyler Goodlet 6cb80abfc0 Start a new `.accounting` subpkg, move `.pp` contents there 2023-04-14 15:56:48 -04:00
Tyler Goodlet 3a5e788afc '`kraken`: fix pos loading using `digits_to_dec()` to pair info
Our issue was not having the correct value set on each
`Symbol.lot_tick_size`.. and then doing PPU calcs with the default set
for legacy mkts..

Also,
- actually write `pps.toml` on broker mode exit.
- drop `get_likely_pair()` and import from pp module.
2023-04-14 15:56:48 -04:00
Tyler Goodlet 24fe44fb96 Add an inverse of `float_digits()`: `digits_to_dec() 2023-04-14 15:56:48 -04:00
Tyler Goodlet b982505b43 Ensure clearing table entries are time-sorted..
Not sure how this worked before but, the PPU calculation critically
requires that the order of clearing transactions are in the correct
chronological order! Fix this by sorting `trans: dict[str, Transaction]`
in the `PpTable.update_from_trans()` method.

Also, move the `get_likely_pair()` parser from the `kraken` backend here
for future use particularly when we revamp the asset-transaction
processing layer.
2023-04-14 15:56:48 -04:00
goodboy 70db20b07c
Merge pull request #473 from pikers/binance_ws_ep_update
`binance`: use built-in `anext()` add note about new ws ep URL, fix agen streaming within `NoBsWs` usage
2023-04-12 19:53:53 -04:00
Tyler Goodlet 609b91e848 Try out `@trio_util.async_generator` for streaming
Apparently it will likely fix our `trio`-cancel-scopes-corrupted crash
when we try to let our `._web_bs.NoBsWs` do reconnect logic around
the asyn-generator implemented data-feed streaming routines in `binance`
and `kraken`.  See the project docs for deatz; obvs we add the lib as
a dep.
2023-03-20 12:54:48 -04:00
Tyler Goodlet 78eb784091 Stick `try:` outside all `xdotool` subproc calls 2023-03-13 15:36:45 -04:00
Tyler Goodlet 973e4b5f44 `binance`: wrap streamer async-gen in `aclosing()` 2023-03-13 15:36:29 -04:00
Tyler Goodlet 9197e6decb `binance`: use built-in `anext()` add note about new ws ep URL 2023-03-13 15:36:29 -04:00
goodboy f3b04f27e6
Merge pull request #490 from pikers/log_linearized_curve_overlays
Log linearized curve overlays
2023-03-13 15:32:42 -04:00
Tyler Goodlet 889e920796 Short-circuit rendering on no 1d-data; avoid m4 layer crash 2023-03-13 12:18:54 -04:00
Tyler Goodlet 1aab9f1f81 Actually yes, we need to handle empty in-view range.. 2023-03-10 18:20:22 -05:00
Tyler Goodlet 5c697de58e Presume never handling not-in-view case for minor curves 2023-03-10 18:20:22 -05:00
Tyler Goodlet 3066b1541e Handle (shorter supported) minor-curve not-in-view
Solve this by always scaling the y-range for the major/target curve
*before* the final overlay scaling loop; this implicitly always solve
the case where the major series is the only one in view.

Tidy up debug print formatting and add some loop-end demarcation comment
lines.
2023-03-10 18:20:22 -05:00
Tyler Goodlet 32339cb41a Always show a minimum bars during startup
This is particularly more "good looking" when we boot with a pair that
doesn't have historical 1s OHLC and thus the fast chart is empty from
outset. In this case it's a lot nicer to be already zoomed to
a comfortable preset number of "datums in view" even when the history
isn't yet filled in.

Adjusts the chart display `Viz.default_view()` startup to explicitly
ensure this happens via the `do_min_bars=True` flag B)
2023-03-10 18:20:22 -05:00
Tyler Goodlet 12e196a6f7 Catch `KeyError` on bcast errors which pop the sub
Not sure how i missed this (and left in handling of `list.remove()` and
it ever worked for that?) after the `samplerd` impl in 5ec1a72 but, this
adjusts the remove-broken-subscriber loop to catch the correct
`set.remove()` exception type on a missing (likely already removed)
subscription entry.
2023-03-10 18:20:22 -05:00
Tyler Goodlet 8a87e5f390 Remove leftover debug print in cache reset meth 2023-03-10 18:20:22 -05:00
Tyler Goodlet 5958acebe1 Add (commented) draft 1min OHLC time index logging
For the purposes of eventually trying to resolve last-step indexing
synchronization (an intermittent but still existing) issue(s) that can
happen due to races during history frame query and shm writing during
startup. In fact, here we drop all `hist_viz` info queries from the main
display loop for now anticipating that this code will either be removed
or improved later.
2023-03-10 18:20:22 -05:00
Tyler Goodlet 8d1c713a5a Always pass step to `slice_from_time()` in view mode
Again, as per the signature change, never expect implicit time step
calcs from overlay processing/machinery code. Also, extend the debug
printing (yet again) to include better details around
"rescale-due-to-minor-range-out-of-view" cases and a detailed msg for
the transform/scaling calculation (inputs/outputs), particularly for the
cases when one of the curves has a lesser support.
2023-03-10 18:20:22 -05:00
Tyler Goodlet 32926747c6 Always pass `step` to `slice_from_time()` in the `Viz`
As per the change to `slice_from_time()` this ensures this `Viz` always
passes its self-calculated time indexing step size to the time slicing
routine(s).

Further this contains a slight impl tweak to `.scalars_from_index()` to
slice the actual view range from `xref` to `Viz.ViewState.xrange[1]` and
then reading the corresponding `yref` from the first entry in that
array; this should be no slower in theory and makes way for further
caching of x-read-range to `ViewState` opportunities later.
2023-03-10 18:20:22 -05:00
Tyler Goodlet 712f1a47a0 Require `step: float` input to `slice_from_time()`
There's been way too many issues when trying to calculate this
dynamically from the input array, so just expect the caller to know what
it's doing and don't bother with ever hitting the error case of
calculating and incorrect value internally.
2023-03-10 18:20:22 -05:00
Tyler Goodlet 51f3733487 Handle "target-is-shorter-then-pinned" case
When the target pinning curve (by default, the dispersion major) is
shorter then the pinned curve, we need to make sure we find still find
the x-intersect for computing returns scalars! Use `Viz.i_from_t()` to
accomplish this as well and, augment that method with a `return_y: bool`
to allow the caller to also retrieve the equivalent y-value at the
requested input time `t: float` for convenience.

Also tweak a few more internals around the 'loglin_ref_to_curve'
method:
- only solve / adjust for the above case when the major's xref is
  detected as being "earlier" in time the current minor's.
- pop the major viz entry from the overlay table ahead of time to avoid
  a needless iteration and simplify the transform calc phase loop to
  avoid handling that needless cycle B)
- add much better "organized" debug printing with more clear headers
  around which "phase"/loop the message pertains and well as more
  explicit details in terms of x and y-range values on each cycle of
  each loop.
2023-03-10 18:20:22 -05:00