task: to get the data of the excess intraday margin at the closing of a position
used:
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]
}
}
ps.
The difference between the expected and actual margin in executionUpdate(..) is different.
What does it mean and How to resolve it?

Comment