From 60a6016e73fdb09176ace1c44231078a33efc2cd Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Mon, 30 Aug 2021 17:43:20 -0400 Subject: [PATCH] Break up the pnl calc from the percent part --- piker/calc.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/piker/calc.py b/piker/calc.py index 12fe0d79..0cf42cf8 100644 --- a/piker/calc.py +++ b/piker/calc.py @@ -49,7 +49,7 @@ def humanize( ) -def percent_change( +def pnl( init: float, new: float, @@ -62,4 +62,11 @@ def percent_change( if not (init and new): return 0 - return (new - init) / init * 100. + return (new - init) / init + + +def percent_change( + init: float, + new: float, +) -> float: + return pnl(init, new) * 100.