Ejemplo n.º 1
0
        private void ProcessAccount(OEC.API.Account account, OEC.API.Currency currency)
        {
            if (account == null)
            {
                throw new ArgumentNullException(nameof(account));
            }

            var balance = currency == null ? account.TotalBalance : account.Balances[currency];

            var commission = account.AvgPositions
                             .Where(pos => balance == account.TotalBalance || pos.Contract.Currency.ID == balance.Currency.ID)
                             .Sum(pos => pos.RealizedCommissions.ToDecimal() + pos.OpenCommissions.ToDecimal());

            var msg = this.CreatePortfolioChangeMessage(account.Name)
                      .TryAdd(PositionChangeTypes.BeginValue, balance.Cash.ToDecimal())
                      .TryAdd(PositionChangeTypes.RealizedPnL, balance.RealizedPnL.ToDecimal())
                      .TryAdd(PositionChangeTypes.UnrealizedPnL, balance.OpenPnL.ToDecimal())
                      .TryAdd(PositionChangeTypes.CurrentValue, balance.NetLiquidatingValue.ToDecimal())
                      .TryAdd(PositionChangeTypes.Commission, commission);

            SendOutMessage(msg);
        }
Ejemplo n.º 2
0
 private void SessionOnDetailedPositionChanged(OEC.API.Account account, OEC.API.Position position)
 {
     ProcessPosition(position);
 }
Ejemplo n.º 3
0
 private void SessionOnPortfolioMarginChanged(OEC.API.Account account)
 {
     ProcessAccount(account, null);
 }
Ejemplo n.º 4
0
 private void SessionOnAccountRiskLimitChanged(OEC.API.Account account)
 {
     ProcessAccount(account, null);
 }
Ejemplo n.º 5
0
 private void SessionOnAccountSummaryChanged(OEC.API.Account account, OEC.API.Currency currency)
 {
     ProcessAccount(account, currency);
 }
Ejemplo n.º 6
0
 private void SessionOnBalanceChanged(OEC.API.Account account, OEC.API.Currency currency)
 {
     ProcessAccount(account, currency);
 }