Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backward compat support for Transaction.sym: Symbol #477

Merged

Conversation

goodboy
Copy link
Contributor

@goodboy goodboy commented Mar 3, 2023

Like it sounds makes #470 still work on existing pps.toml files in the wild 😉

Further this ports the kraken and ib backends to correctly provide the precision info for transaction sizes where possible by pulling the info from the market info available either from ledger or API records.


Additionally, this includes a draft implementation for a .data._source.Symbol replacement: MktPair.

It's not used at all but gives us a guide for how we could majorly simplify the interface and provide a much clearer defined market addressing system especially as it pertains to refining our schema as documented in #467.

In order to support existing `pps.toml` files in the wild which don't
have the `asset_type, price_tick_size, lot_tick_size` fields, we need to
only optionally read them and instead expect that backends will write
the fields going forward (coming in follow patches).

Further this makes some small asset-size (vlm accounting) quantization
related adjustments:
- rename `Symbol.decimal_quant()` -> `.quantize_size()` since that is
  explicitly what this method is doing.
- and expect an input `size: float` which we cast to decimal instead of
  doing it inside the `.calc_size()` caller code.
- drop `Symbol.iterfqsns()` which wasn't being used anywhere at all..

Additionally, this drafts out a new replacement market-trading-pair data
type to eventually replace `.data._source.Symbol` -> `MktPair` which we
aren't using yet, but serves as the documentation-driven motivator ;)
and, it relates to #467.
Also includes a retyping of `Client._pair: dict[str, Pair]` to look up
pair structs and map all alt-key-name-sets to each for easy precision
info lookup to set the `.sym` field for each transaction including for
on-chain transfers which kraken provides as an "asset decimals" field,
presumably pulled from the particular block-token's limitation info.
@@ -127,6 +134,56 @@ def unpack_fqsn(fqsn: str) -> tuple[str, str, str]:
)


class MktPair(Struct, frozen=True):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrt this, i think if we want to have multiple endpoint brokers addressable eventually we can have type that maybe groups this type into some sort of address collection of sorts?

@guilledk guilledk merged commit d4ac897 into decimalization_take_2 Mar 3, 2023
@guilledk guilledk deleted the backward_compat_trans_with_symbolinfo branch March 3, 2023 02:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants