decimal_prices_thru_ems: yeah, just suck it up and do Order.price: Decimal for now.. #44

Merged
goodboy merged 3 commits from decimal_prices_thru_ems into main 2026-01-07 03:25:28 +00:00

Until we find a (better) fixed point numeric type that’s msgspec compat I’m just flipping to decimal.Decimal e2e for the .clearing subsys.

For now this resolves a variety of of order-mode-(chart)-UI to backend-exposed-market-precision issues which can edge-case occur when using plain ol’ floats..

Meat of patch is in,

  • cf976ff1 implementing the actual Decimal passthru in the clearing engine.
  • 838ddd6 ensures re-float-ifying at the UI side.
Until we find a (better) fixed point numeric type that's `msgspec` compat I'm just flipping to `decimal.Decimal` e2e for the `.clearing` subsys. For now this resolves a variety of of order-mode-(chart)-UI to backend-exposed-market-precision issues which can edge-case occur when using plain ol' `floats`.. Meat of patch is in, - cf976ff1 implementing the actual `Decimal` passthru in the clearing engine. - 838ddd6 ensures re-`float`-ifying at the UI side.
goodboy added 12 commits 2025-04-24 16:20:25 +00:00
ec71dc2018 Mk `Brokerd[Order].price` avoid `float`-errs
By re-typing to a `.price: Decimal` field on both legs of the EMS.

It seems we must do it ourselves since,
- these msg's (fields) are relayed through the clearing engine to each
  `brokerd` backend and,
- bc many (if not all) of those backends `.broker`-clients (nor their
  encapsulated "brokerage services") **are not** doing any
  precision-truncation themselves.

So, for now, instead we opt to expect rounding at the source. This means
we will explicitly require casting to/from `float` at the line-graphics
interface to the order-clearing-engine (as implemented throughout
`.ui.order_mode.OrderMode`); and this is coming shortly.
cbbf674737 Finally drop `Symbol`
It was replaced by `MktPair` long ago in,
https://github.com/pikers/piker/pull/489

with follow up for final removal in,
https://github.com/pikers/piker/issues/517

Resolves #517
84ad34f51e Cast to `float` as needed from order-mode and ems
Since we're not quite yet using automatic typed msging from
`tractor`/`msgspec` (i.e. still manually decoding order ctl msgs from
built-in types..`dict`s still not `msgspec.Struct`) this adds the
appropriate typecasting ops to ensure the required precision is attained
prior to processing and/or submission to a brokerd backend service.

For the `.clearing._ems`,
- flip all `trigger_price` previously presumed to be `float` to just
  the field-identical `price: Decimal` and ensure we cast to `float`
  for any `trigger_price` usage, like before passing to `mk_check()`.

For `.ui.order_mode.OrderMode`,
- add a new `.curr_mkt: MktPair` convenience property to get the
  chart-active value.
- ensure we always use the `.curr_mkt.quantize() -> Decimal` before
  setting any IPC-msg's `.price` field!
- always cast `float(Order.price)` before use in setting line-levels.
- don't bother setting `Order.symbol` to a (now fully removed) `Symbol`
  instance since it's not really required-for-use anywhere; leaving it
  a `str` (per the type-annot) is fine for now?
2a24d1d50c `.kraken`: add masked pauses for order req debug
Such that the next time i inevitably must debug the some order-request
error status or precision discrepancy, i have the mkt-symbol branch
ready to go. Also, switch to `'action': 'buy'|'sell' as action,` style
`case` matching instead of the post-`if` predicate style.
705f0e86ac Drop variable regex from `ruff.toml`
Same as in other projects, seems to be not parsing and causing `ruff` to
crash?!?
3ff0a86741 Gracefully close on EoCs thrown in quote throttler
Since `tractor.MsgStream.send()` now also raises `trio.EndOfChannel`
when the stream was gracefully `Stop`ped by the peer side, also handle
that case in `.data._sampling.uniform_rate_send()`.
35cb538a69 Update `binance` spot pairs with `amendAllowed`
As per API updates,
https://developers.binance.com/docs/binance-spot-api-docs
https://developers.binance.com/docs/binance-spot-api-docs/faqs/order_amend_keep_priority

I also slightly tweaked the filed mismatch exception note to include the
`repr(pair_type)` so the dev can know which pair types should be
changed.
goodboy added 1 commit 2025-04-24 16:53:44 +00:00
goodboy added 5 commits 2025-06-09 14:33:54 +00:00
goodboy force-pushed decimal_prices_thru_ems from 94caa248e7 to b61145ec5a 2026-01-01 20:17:11 +00:00 Compare
goodboy force-pushed decimal_prices_thru_ems from b61145ec5a to 871bb2620e 2026-01-05 18:32:58 +00:00 Compare
goodboy force-pushed decimal_prices_thru_ems from 871bb2620e to 838ddd6e79 2026-01-07 02:44:06 +00:00 Compare
goodboy changed title from decimal_prices_thru_ems: yeah, just suck it up and do `Order.price: Decimal` for now.. to decimal_prices_thru_ems: yeah, just suck it up and do `Order.price: Decimal` for now.. 2026-01-07 03:22:37 +00:00
goodboy changed target branch from mp_fomo_polish to main 2026-01-07 03:22:37 +00:00
goodboy changed title from decimal_prices_thru_ems: yeah, just suck it up and do `Order.price: Decimal` for now.. to decimal_prices_thru_ems: yeah, just suck it up and do `Order.price: Decimal` for now.. 2026-01-07 03:23:06 +00:00
goodboy merged commit 8a17a75ba2 into main 2026-01-07 03:25:28 +00:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: pikers/piker#44
There is no content yet.