-
Notifications
You must be signed in to change notification settings - Fork 17
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
Change Position.clears
-> .events
#510
Labels
accounting
prolly positioning: the accounting of "what/when (is) owned"
clearing
auction and mm tech: EMS, OMS, algo-trading
ledger
trade, accounts and other user focal event history tracking, management and storage
Comments
goodboy
added
clearing
auction and mm tech: EMS, OMS, algo-trading
ledger
trade, accounts and other user focal event history tracking, management and storage
accounting
prolly positioning: the accounting of "what/when (is) owned"
labels
May 23, 2023
This was referenced May 23, 2023
Closed
goodboy
added a commit
that referenced
this issue
Jul 5, 2023
We're probably going to move to implementing all accounting using `polars.DataFrame` and friends and thus this rejig preps for a much more "stateless" implementation of our `Position` type and its internal pos-accounting metrics: `ppu` and `cumsize`. Summary: - wrt to `._pos.Position`: - rename `.size`/`.accum_size` to `.cumsize` to be more in line with `polars.DataFrame.cumsum()`. - make `Position.expiry` delegate to the underlying `.mkt: MktPair` handling (hopefully) all edge cases.. - change over to a new `._events: dict[str, Transaction]` in prep for #510 (and friends) and enforce a new `Transaction.etype: str` which is by default `clear`. - add `.iter_by_type()` which iterates, filters and sorts the entries in `._events` from above. - add `Position.clearsdict()` which returns the dict-ified and datetime-sorted table which can more-or-less be stored in the toml account file. - add `.minimized_clears()` a new (and close) version of the old method which always grabs at least one clear before a position-side-polarity-change. - mask-drop `.ensure_state()` since there is no more `.size`/`.price` state vars (per say) as we always re-calc the ppu and cumsize from the clears records on every read. - `.add_clear` no longer does bisec insorting since all sorting is done on position properties *reads*. - move the PPU (price per unit) calculator to a new `.accounting.calcs` as well as add in the `iter_by_dt()` clearing transaction sorted iterator. - also make some fixes to this to handle both lists of `Transaction` as well as `dict`s as before. - start rename of `PpTable` -> `Account` and make a note about adding a `.balances` table. - always `float()` the transaction size/price values since it seems if they get processed as `tomlkit.Integer` there's some suuper weird double negative on read-then-write to the clears table? - something like `cumsize = -1` -> `cumsize = --1` !?!? - make `load_pps_from_ledger()` work again but now includes some very very first draft `polars` df processing from a transaction ledger. - use this from the `accounting.cli.disect` subcmd which is also in *super early draft* mode ;) - obviously as mentioned in the `Position` section, add the new `.calcs` module with a `.ppu()` calculator func B)
goodboy
added a commit
that referenced
this issue
Jul 14, 2023
We're probably going to move to implementing all accounting using `polars.DataFrame` and friends and thus this rejig preps for a much more "stateless" implementation of our `Position` type and its internal pos-accounting metrics: `ppu` and `cumsize`. Summary: - wrt to `._pos.Position`: - rename `.size`/`.accum_size` to `.cumsize` to be more in line with `polars.DataFrame.cumsum()`. - make `Position.expiry` delegate to the underlying `.mkt: MktPair` handling (hopefully) all edge cases.. - change over to a new `._events: dict[str, Transaction]` in prep for #510 (and friends) and enforce a new `Transaction.etype: str` which is by default `clear`. - add `.iter_by_type()` which iterates, filters and sorts the entries in `._events` from above. - add `Position.clearsdict()` which returns the dict-ified and datetime-sorted table which can more-or-less be stored in the toml account file. - add `.minimized_clears()` a new (and close) version of the old method which always grabs at least one clear before a position-side-polarity-change. - mask-drop `.ensure_state()` since there is no more `.size`/`.price` state vars (per say) as we always re-calc the ppu and cumsize from the clears records on every read. - `.add_clear` no longer does bisec insorting since all sorting is done on position properties *reads*. - move the PPU (price per unit) calculator to a new `.accounting.calcs` as well as add in the `iter_by_dt()` clearing transaction sorted iterator. - also make some fixes to this to handle both lists of `Transaction` as well as `dict`s as before. - start rename of `PpTable` -> `Account` and make a note about adding a `.balances` table. - always `float()` the transaction size/price values since it seems if they get processed as `tomlkit.Integer` there's some suuper weird double negative on read-then-write to the clears table? - something like `cumsize = -1` -> `cumsize = --1` !?!? - make `load_pps_from_ledger()` work again but now includes some very very first draft `polars` df processing from a transaction ledger. - use this from the `accounting.cli.disect` subcmd which is also in *super early draft* mode ;) - obviously as mentioned in the `Position` section, add the new `.calcs` module with a `.ppu()` calculator func B)
goodboy
added a commit
that referenced
this issue
Jul 17, 2023
Start working out the set of possible "txn types" we want to define in a simple set. Relates to #510
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
accounting
prolly positioning: the accounting of "what/when (is) owned"
clearing
auction and mm tech: EMS, OMS, algo-trading
ledger
trade, accounts and other user focal event history tracking, management and storage
As per related requirements in #345 and a bit of tasking in #489, it
probably makes sense to make this change for flexibility for things in
legacy markets like splits, renames and in modern (crypto) ones
things like transfers, forks, etc..
Please also see #478 for an older issue prior to #489 which describes
this task set in the past where appropriate content has been movied
here.
Note that this issue is a highlevel section of the grander parent
milestone in #515.
Of course the current schema records would just be flipped to
{'type': 'clear', ...}
.There's a TODO in the respective
.accounting._pos
module:TODO:
change
.clears
->.events
and adding a'type': 'clear'
fieldto each entry to also allow supporting transaction or market structure
change events:
'split'
: for stocks which change their float by reducing orincreasing the number of units in circulation.
'rename'
: for any asset that is renamed by it's venue/provider.'transfer'
: for both fiat and crypto where it pertains to simplymoving an amount of asset to some other account or wallet and the
user desires that this affect the size of the position: eg.
xferring btc to pay for something in a target fiat which the user
wishes to view as a "sell-for-profit".
'removal'
: for assets that get discontinued by theirvenue/provider: eg. a shit coin or penny stock that finally is
deleted from exchange.
the above set of market-event types can also be mapped to
a set of distinct (graphical) icons when displayed on chart:
removal of obsoleted top levels fields: eg.
split_ratio
add nice-to-have summary stats to the top level?
bep
break even priceduration
showing time span since last net-zero position?src_fiat
to allow defining which mkts the user chooses to projectto particular "user fiat": the asset-money-tech of choice that the
user wants to "price the position in terms of"
add a top level
balances
table per account which shows thehistory of asset holdings per every single clear and transfer allowing
for avoiding non-trading (non clearing) transactions to be filtered
in position-pnl calcs?
Further preferred adjustments to actual data schema and surrounding
operating machinery:
Better
TOML
libs ->tomlkit
for style,tomli(-w)
for speed #496 final refinements and hopefully avoiding carrying our ownfork!
finer grained file update update system
.write_config()
to.accounting._ledger.TransactionLedger
and thePpTable
in Rekt pps? problem? =>piker.accounting
#489high-level multi-account
PpTable
api that would avoid all theexit stacks as is currently implemented in the
ib.broker.trades_dialogue()
backend.Avoid
Position.size
being a state var and instead alwayscomputed from an
[e for e in Position.events if e['type'] in {'clear', 'transfer'}]
using
.calc_size()
The text was updated successfully, but these errors were encountered: