Skip to content

Introduce NetPnL in Position and Trades. #1278

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

Closed
wants to merge 2 commits into from

Conversation

abhirathmahipal
Copy link
Contributor

It's a good idea to maintain pl and net_pl separately. Reasons being

  • commission is directly deducted from cash once a trade is entered.
  • Clients can use pl and net_pl as per their use case.

If you're on the same page, will make similar changes for pl_pct.

@kernc
Copy link
Owner

kernc commented May 28, 2025

Actually I'm not on the same page. I prefer smaller and well-documented APIs as I believe they are easier to work with, and, importantly, smaller API surfaces requires less maintaining.

If the user is made aware that PnL stats account for (or ignore) Commissions, they can simply do the remaining desired arithmetic themselves. As opposed to never being sure what attribute/accessor to call in a deluge of those ...

@abhirathmahipal
Copy link
Contributor Author

I was thinking along your lines earlier.

Reasoning for the above approach

  • Trade._commission is set only after the Trade is closed. If the Strategy were use Trade.pl, it wouldn't reflect the commission.

Have raised a new pull request based on your inputs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants