Skip to content

More clarity on trade pct calculation #1254

Open
@ironhak

Description

@ironhak

Hello.

The stats._trades has a column called ReturnPct. By reading the docs and the source code it's not clear if the return in percentage is calculated relative to the starting capital, the current equity, or the trade volume. By reading the code:

    @property
    def pl(self):
        """Trade profit (positive) or loss (negative) in cash units."""
        price = self.__exit_price or self.__broker.last_price
        return self.__size * (price - self.__entry_price)

    @property
    def pl_pct(self):
        """Trade profit (positive) or loss (negative) in percent."""
        price = self.__exit_price or self.__broker.last_price
        return copysign(1, self.__size) * (price / self.__entry_price - 1)

it's clear that the return Pct comes from the trade volume. So it would be useful to let the user know this in the docs:

"""Trade profit (positive) or loss (negative) in percent relative to trade size.""" 

Thank's :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions