From 60751acf85528ed008edea9b2c3689d2db43a6a3 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 3 Aug 2023 16:57:02 -0400 Subject: [PATCH] Officially drop `Position.size` --- piker/accounting/README.rst | 16 ++++++++++++++++ piker/accounting/_pos.py | 8 +++----- 2 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 piker/accounting/README.rst diff --git a/piker/accounting/README.rst b/piker/accounting/README.rst new file mode 100644 index 00000000..5214d7a2 --- /dev/null +++ b/piker/accounting/README.rst @@ -0,0 +1,16 @@ +.accounting +----------- +A subsystem for transaction processing, storage and historical +measurement. + + +.pnl +---- +BEP, the break even price: the price at which liquidating +a remaining position results in a zero PnL since the position was +"opened" in the destination asset. + +PPU: price-per-unit: the "average cost" (in cumulative mean terms) +of the "entry" transactions which "make a position larger"; taking +a profit relative to this price means that you will "make more +profit then made prior" since the position was opened. diff --git a/piker/accounting/_pos.py b/piker/accounting/_pos.py index 40a654bd..87c36d24 100644 --- a/piker/accounting/_pos.py +++ b/piker/accounting/_pos.py @@ -38,6 +38,7 @@ from pendulum import ( datetime, now, ) +import polars as pl import tomlkit from ._ledger import ( @@ -143,6 +144,8 @@ class Position(Struct): # trade was opened.? # def bep() -> float: # ... + def clears_df(self) -> pl.DataFrame: + ... def clearsitems(self) -> list[(str, dict)]: return ppu( @@ -436,11 +439,6 @@ class Position(Struct): ndigits=self.mkt.size_tick_digits, ) - @property - def size(self) -> float: - log.warning('`Position.size` is deprecated, use `.cumsize`') - return self.cumsize - # TODO: once we have an `.events` table with diff # mkt event types..? # def suggest_split(self) -> float: