Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PortfolioStatistics WinRate Definition #8268

Open
4 tasks done
AlexCatarino opened this issue Aug 21, 2024 · 0 comments
Open
4 tasks done

PortfolioStatistics WinRate Definition #8268

AlexCatarino opened this issue Aug 21, 2024 · 0 comments

Comments

@AlexCatarino
Copy link
Member

AlexCatarino commented Aug 21, 2024

Expected Behavior

WinRate is defined as "The ratio of the number of winning days to the total number of days" or use the definition of winning aording to a close trade.

Actual Behavior

WinRate is defined as "The ratio of the number of winning trades to the total number of trades"
which is misleading because it is calculated as follows:

foreach (var pair in profitLoss)
{
    var tradeProfitLoss = pair.Value;

    if (tradeProfitLoss > 0)
    {
        totalProfit += tradeProfitLoss / runningCapital;
        totalWins++;
    }
    else
    {
        totalLoss += tradeProfitLoss / runningCapital;
        totalLosses++;
    }

    runningCapital += tradeProfitLoss;
}

var totalTrades = totalWins + totalLosses;
WinRate = totalTrades == 0 ? 0 : (decimal) totalWins / totalTrades;

Potential Solution

We can fix the docs or use WinRate, as defined in the TradeStatistics class, which takes into account closed trades (exit and entry).

EDIT: We see the same issue for LossRate, AverageWinRate and AverageLossRate.

Reproducing the Problem

N/A

Checklist

  • I have completely filled out this template
  • I have confirmed that this issue exists on the current master branch
  • I have confirmed that this is not a duplicate issue by searching issues
  • I have provided detailed steps to reproduce the issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant