'Returns the duration in open state.
:rtype: datetime.timedelta.
.. note::
* If the position is open, then the difference between the entry datetime and the datetime of the last bar is returned.
* If the position is closed, then the difference between the entry datetime and the exit datetime is returned.'

def getAge(self):

    ret = datetime.timedelta()
    if (self.__entryDateTime is not None):
        if (self.__exitDateTime is not None):
            last = self.__exitDateTime
        else:
            last = self.__strategy.getCurrentDateTime()
        ret = (last - self.__entryDateTime)
    return ret
