Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Profit calculation at position or trade closing

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Profit calculation at position or trade closing

    Hello

    I would like to calculate the profit when a position is closed on the event OnExecutionUpdate (in the instrument currency).

    I cannot use the account profits information before and after the trade because because the account information is common to all strategies running for the same account..

    Looking at execution object, the order associated with the execution has the exit price but not the average opening price to make the calculation.

    One idea that I had is to store the strategy position information about average price for this instrument when the trade is opened and make the calcutions when it is closed.

    Is there a simpler approach? Would this one provide the right information?

    Also, I would like so Sync the position with the account on startup of the strategy. In this case, the information in the strategy position would be consistent?

    Regards

    Zulok

    #2
    Hi zulok, thanks for your post.

    You can get the average entry price at time of entry and use that in the PnL calculation, that would probably be the most straight forward way of doing that. You can also monitor the OnPositionUpdate event.

    The Adopt Account Position startup behavior would be the one to use to do this. Make sure to enable IsAdoptAccountPositionAware and that the strategies order objects are hendled properly. I attached an example strategy to this post.

    Please let me know if I can assist any further.
    Attached Files

    Comment


      #3
      Thanks CrisL

      As an alternative could TRADES collection be used?

      thanks

      zulok

      Comment


        #4
        Hi zulok, thanks for your reply.

        The Trade collection would only contain closed trades, so I don't think you would want to use this if you need to calculate PnL before the position is closed.

        Comment


          #5
          Hi Chris L

          Then it is what I was looking for. I want to calculate the profit as the position closes.

          Thanks

          Zulok

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Mindset, 04-21-2026, 06:46 AM
          0 responses
          87 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by M4ndoo, 04-20-2026, 05:21 PM
          0 responses
          128 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by M4ndoo, 04-19-2026, 05:54 PM
          0 responses
          65 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by cmoran13, 04-16-2026, 01:02 PM
          0 responses
          117 views
          0 likes
          Last Post cmoran13  
          Started by PaulMohn, 04-10-2026, 11:11 AM
          0 responses
          67 views
          0 likes
          Last Post PaulMohn  
          Working...
          X