private void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (m_portfolio != null)
         {
             m_portfolio.Dispose();
             m_portfolio = null;
         }
         if (m_indices != null)
         {
             m_indices.Dispose();
             m_indices = null;
         }
         if (m_messageUtilities1 != null)
         {
             m_messageUtilities1.Dispose();
             m_messageUtilities1 = null;
         }
         if (m_messageUtilities2 != null)
         {
             m_messageUtilities2.Dispose();
             m_messageUtilities2 = null;
         }
         PositionMonitorUtilities.Info(Name + " disposed");
     }
 }
Ejemplo n.º 2
0
        private List <Position> BuildPositions(string acctName, HugoDataSet.PortfolioDataTable portfolio, List <Index> indices, Index totalRow, AccountData accountData, bool bPositionsForAllAccounts, ref int unsubscribedSymbols)
        {
            List <Position> positions = new List <Position>();

            try
            {
                unsubscribedSymbols += BuildPositionsForAccount(portfolio, indices, totalRow, accountData, positions);

                if (bPositionsForAllAccounts)
                {
                    foreach (AccountPortfolio account in m_positionMonitor.GetAllAccountPortfolios())
                    {
                        if (account.AccountName != acctName)
                        {
                            unsubscribedSymbols += BuildPositionsForAccount(account.Portfolio, null, null, null, positions);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ReportError("Error building positions", ex);
            }
            return(positions);
        }
Ejemplo n.º 3
0
        private int BuildPositionsForAccount(HugoDataSet.PortfolioDataTable portfolio, List <Index> indices, Index totalRow, AccountData accountData, List <Position> positions)
        {
            int unsubscribedSymbols = 0;

            try
            {
                foreach (HugoDataSet.PortfolioRow portfolioRow in portfolio)
                {
                    Position newRow          = new Position();
                    Index    indexRow        = null;
                    double   underlyingPrice = 0;

                    if (!portfolioRow.IsUnderlyingSymbolNull())
                    {
                        if (indices != null)
                        {
                            indexRow = GetIndexData(indices, portfolioRow.UnderlyingSymbol);
                        }
                        if (indexRow != null)
                        {
                            underlyingPrice = indexRow.LastPrice.HasValue ? indexRow.LastPrice.Value : 0;
                        }
                        else
                        {
                            HugoDataSet.PortfolioRow underlyingRow = portfolio.FindByAcctNameSymbol(portfolioRow.AcctName, portfolioRow.UnderlyingSymbol);
                            if (underlyingRow != null)
                            {
                                underlyingPrice = underlyingRow.CurrentPrice;
                            }
                        }
                    }

                    BuildPositionRow(portfolioRow, accountData, newRow, underlyingPrice);

                    // accountData is null only if we are not interested in calculating totals for this account
                    if (accountData != null)
                    {
                        AggregateAccountTotals(accountData, newRow, underlyingPrice);

                        if (newRow.IsOption)
                        {
                            AggregateIndexTotals(newRow, indexRow, totalRow);
                        }
                    }

                    if ((newRow.SubscriptionStatus != "Subscribed") && ((newRow.CurrentPosition != 0) || (newRow.SODPosition != 0) || newRow.IsStock))
                    {
                        unsubscribedSymbols++;
                    }
                    newRow.UpdateTime = portfolioRow.IsUpdateTimeNull() ? new System.Nullable <TimeSpan>() : portfolioRow.UpdateTime;

                    positions.Add(newRow);
                }
            }
            catch (Exception ex)
            {
                ReportError("Error building positions for account", ex);
            }

            return(unsubscribedSymbols);
        }