From 85a38d057b20a9bc06406cc7dfc4009dda6c74bc Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Mon, 7 Aug 2023 10:13:31 -0400 Subject: [PATCH] Factor cumsize sign to var --- piker/accounting/calc.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/piker/accounting/calc.py b/piker/accounting/calc.py index 6ab89d2b..ef0179e4 100644 --- a/piker/accounting/calc.py +++ b/piker/accounting/calc.py @@ -649,11 +649,12 @@ def ledger_to_dfs( if ( abs(cumsize) > 0 # non-exit-to-zero position txn ): + cumsize_sign: float = copysign(1, cumsize) ledger_bep: float = ( ( (ppu * cumsize) - - (last_ledger_pnl * copysign(1, cumsize)) + (last_ledger_pnl * cumsize_sign) ) / cumsize ) @@ -671,7 +672,7 @@ def ledger_to_dfs( ( (ppu * cumsize) - - (last_pos_pnl * copysign(1, cumsize)) + (last_pos_pnl * cumsize_sign) ) / cumsize )