From 2583706b35d2b6307803c060655c6912607eaa25 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Tue, 14 Mar 2023 20:58:55 -0400 Subject: [PATCH] Port `accounting._pos` to new `Symbol` simplifications --- piker/accounting/_pos.py | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/piker/accounting/_pos.py b/piker/accounting/_pos.py index 204e7a8e..43f62ed9 100644 --- a/piker/accounting/_pos.py +++ b/piker/accounting/_pos.py @@ -45,6 +45,7 @@ from ._ledger import ( ) from ._mktinfo import ( Symbol, + # MktPair, unpack_fqsn, ) from .. import config @@ -62,7 +63,7 @@ class Position(Struct): transaction history. ''' - symbol: Symbol + symbol: Symbol # | MktPair # can be +ve or -ve for long/short size: float @@ -113,7 +114,7 @@ class Position(Struct): # it via the trades ledger.. # drop symbol obj in serialized form s = d.pop('symbol') - fqsn = s.front_fqsn() + fqsn = s.fqme broker, key, suffix = unpack_fqsn(fqsn) sym_info = s.broker_info[broker] @@ -157,7 +158,6 @@ class Position(Struct): inline_table['tid'] = tid toml_clears_list.append(inline_table) - d['clears'] = toml_clears_list return fqsn, d @@ -218,19 +218,14 @@ class Position(Struct): symbol = self.symbol lot_size_digits = symbol.lot_size_digits - ppu, size = ( - round( - msg['avg_price'], - ndigits=symbol.tick_size_digits - ), - round( - msg['size'], - ndigits=lot_size_digits - ), + self.ppu = round( + msg['avg_price'], + ndigits=symbol.tick_size_digits, + ) + self.size = round( + msg['size'], + ndigits=lot_size_digits, ) - - self.ppu = ppu - self.size = size @property def dsize(self) -> float: @@ -406,7 +401,7 @@ class Position(Struct): size = round(size * self.split_ratio) return float( - self.symbol.quantize_size(size), + self.symbol.quantize(size), ) def minimize_clears( @@ -466,8 +461,8 @@ class Position(Struct): return clear - def sugest_split(self) -> float: - ... + # def sugest_split(self) -> float: + # ... class PpTable(Struct):