Esempio n. 1
0
        public override void updatePortfolio(Contract contract, int position, double marketPrice, double marketValue,
                                             double averageCost, double unrealizedPNL, double realizedPNL, string accountName)
        {
            try
            {
                var posLine = new PositionLine
                              (
                    accountName,
                    contract.SecType,
                    contract.Symbol,
                    contract.Expiry,
                    position,
                    (decimal)marketPrice + Zero00,
                    (decimal)marketValue + Zero00,
                    (decimal)averageCost + Zero00,
                    (decimal)unrealizedPNL + Zero00,
                    (decimal)realizedPNL + Zero00
                              );

                var subj = _portfolioSubj;
                if (subj != null)
                {
                    subj.OnNext(new AccountData(posLine));
                }
            }
            catch (Exception ex)
            {
                _twsErrorsSubj.OnError(ex);
            }
        }
Esempio n. 2
0
 public AccountData(PositionLine positionLine)
 {
     PositionLine = positionLine;
     AccountName  = positionLine.AccountName;
     Key          = positionLine.Symbol;
     Value        = positionLine.Position.ToString();
     Currency     = positionLine.SecType;
 }