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. -
Thank you guys @Richard O'Regan @backtrader !
-
Yes, that would be it. You later add it with:
addcommissioninfo(comminfo, name)
wherename
defaults toNone
to 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
-
@backtrader ahh got it, thanks for adding that. @Michael-Scofield no problem mate:)