Cost part of position breakeven calc is direction dependent

lifo_pps_ib
Tyler Goodlet 2022-06-23 16:11:50 -04:00
parent 8a7e391b4e
commit c6efa2641b
1 changed files with 2 additions and 1 deletions

View File

@ -25,6 +25,7 @@ from contextlib import contextmanager as cm
# from pprint import pformat # from pprint import pformat
import os import os
from os import path from os import path
from math import copysign
import re import re
import time import time
from typing import ( from typing import (
@ -264,7 +265,7 @@ class Position(Struct):
self.be_price = ( self.be_price = (
abs(size) * price # weight of current exec 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 self.be_price * abs(self.size) # weight of previous pp
) / abs(new_size) ) / abs(new_size)