Exemple #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");
            }
        }
Exemple #2
0
        private void RefreshNoncriticalTables(RefreshEventArgs args)
        {
            try
            {
                HugoDataSet.PortfolioSnapshotIdsDataTable snapshotIds = GetSnapshotIds(null, ref m_snapshotIdsUpdateTime);
                HugoDataSet.TradesDataTable trades = GetTrades(null, null, ref m_tradesUpdateTime);

                lock (m_tableLock)
                {
                    // if there are no changes, an empty table is returned by the above methods
                    if ((snapshotIds.Count > 0) || (m_snapshotIds == null))
                    {
                        m_snapshotIds           = snapshotIds;
                        args.SnapshotIdsUpdated = true;
                    }
                    if ((trades.Count > 0) || (m_trades == null))
                    {
                        m_trades           = trades;
                        args.TradesUpdated = true;
                    }
                }
            }
            catch (Exception ex)
            {
                Error("Unable to refresh non-critical data tables", ex);
            }
        }
Exemple #3
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);
        }
Exemple #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");
            }
        }