From c6efa2641b081fc0e0caec4bfe8b78d01213a19d Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 23 Jun 2022 16:11:50 -0400 Subject: [PATCH] Cost part of position breakeven calc is direction dependent --- piker/pp.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/piker/pp.py b/piker/pp.py index bdd2fae0..1bf3580e 100644 --- a/piker/pp.py +++ b/piker/pp.py @@ -25,6 +25,7 @@ from contextlib import contextmanager as cm # from pprint import pformat import os from os import path +from math import copysign import re import time from typing import ( @@ -264,7 +265,7 @@ class Position(Struct): self.be_price = ( abs(size) * price # weight of current exec + - cost # transaction cost + copysign(1, size)*cost # transaction cost + self.be_price * abs(self.size) # weight of previous pp ) / abs(new_size)