Пример #1
0
        private bool BuildAccountPortfolios()
        {
            try
            {
                // make sure we have no legacies
                foreach (AccountPortfolio account in m_accountList.Values)
                {
                    account.Stop();
                }
                m_accountList.Clear();

                // build a portfolio for each account in AccountData table
                foreach (HugoDataSet.AccountDataRow row in m_accountData)
                {
                    Info("Building portfolio for account " + row.AcctName);
                    AccountPortfolio account = new AccountPortfolio(this, row);
                    m_accountList.Add(row.AcctName, account);
                }
            }
            catch (Exception ex)
            {
                Error("Error building account portfolios", ex);
                return(false);
            }
            return(true);
        }
Пример #2
0
        public double?GetCurrentPrice(string acctName, string symbol)
        {
            double?currentPrice = null;

            try
            {
                AccountPortfolio account = GetAccountPortfolio(acctName);
                if (account != null)
                {
                    var row = account.Portfolio.FindByAcctNameSymbol(acctName, symbol);
                    if (row != null)
                    {
                        currentPrice = row.CurrentPrice;
                    }
                }
            }
            catch (Exception e)
            {
                Error("Error in GetCurrentPrice", e);
            }
            return(currentPrice);
        }
Пример #3
0
        public AccountPortfolio GetAccountPortfolio(string acctName)
        {
            AccountPortfolio account = null;

            try
            {
                if (IsMonitoring)
                {
                    if (!m_accountList.TryGetValue(acctName, out account))
                    {
                        Info(String.Format("Account {0] not found", acctName));
                    }
                }
                else
                {
                    Info("Error - monitor not started");
                }
            }
            catch (Exception e)
            {
                Error("Error in GetAccountPortfolio", e);
            }
            return(account);
        }