'Return the PnL that would result if closing the position a the given price.
Note that this will be different if commissions are used when the trade is executed.'

def getPnL(self, price=None, includeCommissions=True):

    ret = self.__pnl
    if price:
        ret += ((price - self.__avgPrice) * self.__position)
    if includeCommissions:
        ret -= self.__commissions
    return ret
