Developing Own pnl & pnlcomm calculation
Hi all. I want to ask how to develop my own pnl & pnlcomm calculation. Should I inheritance the Trade class and override the "update" method, or there is other way to do so? And after I developed my own calculation how to apply this to the platform?
Please give me some hints, thank you!
The calculation of profit/loss and commissions is not in the
Trade. This simply uses the reported values to update itself.
How profit/loss and comissions are calculated is controlled by commission schemes. You can supply your own (for all assets or for assets individually) See
See also this independent blog:
Hi backtrader, I'm just reading docs/code to understand your answer to Michael as I have similar question.. I think this is correct.
Ok, so the code he'd need to override is here:
I'd like to use R multiples in the pnl instead or raw values. ( If this needs a separate post let me know. But I'm guessing I'd be in the same boat as Micheal?)
Thanks for all your dedication.
Yes, that would be it. You later add it with:
Noneto be the default for all assets.
If the name matches the name of an asset it will be specifically applied to that asset.
See: Docs - Broker for the reference