// 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); }
public string[] GetAllAccountNames() { try { if (IsMonitoring) { return(m_accountList.Keys.ToArray()); } else { DateTime?updateTime = null; HugoDataSet.AccountDataDataTable accountData = GetAccountData(ref updateTime); var accountNameRows = accountData.Select() as HugoDataSet.AccountDataRow[]; List <string> accountNames = new List <string>(); foreach (var accountNameRow in accountNameRows) { accountNames.Add(accountNameRow.AcctName); } return(accountNames.ToArray()); } } catch (Exception e) { Error("Error in GetAllAccountNames", e); return(null); } }
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); } }
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"); } }