Exemplo n.º 1
0
        private static void Dispose(bool disposing)
        {
            if (disposing)
            {
                StopMonitor();

                if (s_tableAdapters != null)
                {
                    foreach (IHugoTableAdapter tableAdapter in s_tableAdapters)
                    {
                        if (tableAdapter != null)
                        {
                            tableAdapter.Dispose();
                        }
                    }
                    s_tableAdapters = null;
                }

                if (s_currentPositions != null)
                {
                    s_currentPositions.Dispose();
                    s_currentPositions = null;
                }
                if (s_trades != null)
                {
                    s_trades.Dispose();
                    s_trades = null;
                }
                Info("PositionMonitorUtilities disposed");
            }
        }
Exemplo n.º 2
0
        // returns false if no changes were made to the tables
        private static bool RefreshTables()
        {
            bool changesMade = false;

            try
            {
                HugoDataSet.AccountDataDataTable      accountData      = GetAccountData();
                HugoDataSet.CurrentPositionsDataTable currentPositions = GetCurrentPositions();;
                HugoDataSet.TradesDataTable           trades           = GetTrades();
                lock (s_tableLock)
                {
                    // if there are no changes, an empty table is returned by the above methods
                    if (accountData.Count > 0)
                    {
                        s_accountData = accountData;
                    }
                    if (currentPositions.Count > 0)
                    {
                        s_currentPositions = currentPositions;
                    }
                    if (trades.Count > 0)
                    {
                        s_trades = trades;
                    }
                }
                changesMade = (accountData.Count + currentPositions.Count + trades.Count > 0);
            }
            catch (Exception ex)
            {
                Error("Unable to refresh data tables", ex);
                return(false);
            }
            return(changesMade);
        }
Exemplo n.º 3
0
        private void RefreshCriticalTables(RefreshEventArgs args)
        {
            try
            {
                HugoDataSet.AccountDataDataTable      accountData      = GetAccountData(ref m_accountsUpdateTime);
                HugoDataSet.CurrentPositionsDataTable currentPositions = GetCurrentPositions();;
                HugoDataSet.IndexWeightsDataTable     indexWeights     = GetIndexWeights();
                HugoDataSet.TradingScheduleDataTable  tradingSchedule  = GetTradingSchedule();

                lock (m_tableLock)
                {
                    // if there are no changes, an empty table is returned by the above methods
                    if (accountData.Count > 0)
                    {
                        if (AccountLimit > 0)
                        {
                            for (int i = accountData.Count - 1; i >= AccountLimit; i--)
                            {
                                accountData.Rows.RemoveAt(i);
                            }
                        }
                        m_accountData        = accountData;
                        args.AccountsUpdated = true;
                    }
                    if (currentPositions.Count > 0)
                    {
                        m_currentPositions    = currentPositions;
                        args.PositionsUpdated = true;
                    }
                    if ((indexWeights.Count > 0) || (m_indexWeights == null))
                    {
                        m_indexWeights           = indexWeights;
                        args.IndexWeightsUpdated = true;
                    }
                    if ((tradingSchedule.Count > 0) || (m_tradingSchedule == null))
                    {
                        m_tradingSchedule           = tradingSchedule;
                        args.TradingScheduleUpdated = true;
                    }
                }
            }
            catch (Exception ex)
            {
                Error("Unable to refresh critical data tables", ex);
            }
        }
Exemplo n.º 4
0
        private void Dispose(bool disposing)
        {
            if (disposing)
            {
                StopMonitor();

                if (m_tableAdapters != null)
                {
                    foreach (IHugoTableAdapter tableAdapter in m_tableAdapters)
                    {
                        if (tableAdapter != null)
                        {
                            tableAdapter.Dispose();
                        }
                    }
                    m_tableAdapters = null;
                }

                if (m_currentPositions != null)
                {
                    m_currentPositions.Dispose();
                    m_currentPositions = null;
                }
                if (m_trades != null)
                {
                    m_trades.Dispose();
                    m_trades = null;
                }
                if (m_accountData != null)
                {
                    m_accountData.Dispose();
                    m_accountData = null;
                }
                if (m_indexWeights != null)
                {
                    m_indexWeights.Dispose();
                    m_indexWeights = null;
                }
                if (m_tradingSchedule != null)
                {
                    m_tradingSchedule.Dispose();
                    m_tradingSchedule = null;
                }
                Info("PositionMonitorUtilities disposed");
            }
        }