Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

The data of intraday margin in ExecutionUpdate(..) not correct.

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

    The data of intraday margin in ExecutionUpdate(..) not correct.

    Hi.

    task: to get the data of the excess intraday margin at the closing of a position
    used:

    Code:
    if(state == default) balance = 0.0;
    if([B]state == history[/B])
    {
            lock (Cbi.Account.All) myAccount = Cbi.Account.All.FirstOrDefault(a => a.Name == name);
            balance = myAccount.Get(AccountItem.ExcessIntradayMargin, Currency.UsDollar);
            Print("INIT::" + balance); //[B] when a strategy is started i get correct data.[/B]
    }
    override void [B]onBarUpdate[/B](...)
    {
    
                 balance = myAccount.Get(AccountItem.ExcessIntradayMargin, Currency.UsDollar);
                 Print("TICK::" + balance); // [B]on each tick i get correct data.[/B]
    }
    override void [B]onExecutionUpdate[/B](...)
    {
           if(Position.MarketPosition == MarketPosition[B].Flat[/B])
          {  
                balance = myAccount.Get(AccountItem.ExcessIntradayMargin, Currency.UsDollar);
                Print("EXEC::" + balance);// [B]here i get not correct data[/B]
         }
    }
    I am not getting the same data Excess intraday margin.
    ps.
    The difference between the expected and actual margin in executionUpdate(..) is different.
    What does it mean and How to resolve it?

    Click image for larger version  Name:	Q8.png Views:	0 Size:	32.2 KB ID:	1214130
    Attached Files
    Last edited by Danila; 09-02-2022, 07:55 AM.

    #2
    Hello Danila,

    Thank you for your inquiry.

    Execution events are different from Account events, so it is likely that OnExecutionUpdate() may not update at the same time as an Account Item update. That being said, there is a method, OnAccountItemUpdate(), that is called for each AccountItem update for the account the strategy is running on:


    This method is also mentioned in the Tip from the AccountItem page in the help guide:


    I recommend using OnAccountItemUpdate() to get the updated AccountItem.ExcessIntradayMargin value.

    Please let us know if we may be of further assistance.

    Comment


      #3
      Hi Emily.
      Thanks for your answer. It helped to optimize my code.
      Last edited by Danila; 09-03-2022, 12:27 AM.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      65 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      139 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      75 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      45 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      50 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X