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 NullPointStrategies, Today, 05:17 AM
          0 responses
          52 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          130 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          70 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          44 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          49 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X