private void BarRequest(CQGCEL cel, IEnumerable<string> symbols, int rangeStart, int rangeEnd, int sessionFilter, string historicalPeriod, string continuationType) { if (_shouldStop) return; _aSymbolStates.Clear(); _aContinuationType = continuationType; _aHistoricalPeriod = eHistoricalPeriod.hpUndefined; TableType(historicalPeriod); _historicalPeriod = historicalPeriod; foreach (string smb in symbols) { _logger.LogAdd("Creating request for symbol:" + smb, Category.Information, true); DatabaseManager.CreateBarsTable(smb, _aTableType); CQGTimedBarsRequest request = cel.CreateTimedBarsRequest(); //LineTime = CEL.Environment.LineTime; request.RangeStart = rangeStart; request.RangeEnd = rangeEnd; request.SessionsFilter = sessionFilter; request.Symbol = smb; request.IntradayPeriod = _aIntradayPeriod; if (_aHistoricalPeriod != eHistoricalPeriod.hpUndefined) request.HistoricalPeriod = _aHistoricalPeriod; var bars = cel.RequestTimedBars(request); var curTimedBars = cel.AllTimedBars.ItemById[bars.Id]; if (curTimedBars.Status == eRequestStatus.rsInProgress) { _logger.LogAdd("Request is 'In progress' for symbol:" + smb, Category.Information, true); var ss = new SymbolState { IsCollected = false, IsSuccess = false }; if (!_aSymbolStates.ContainsKey(smb)) _aSymbolStates.Add(smb, ss); } OnSymbolCollectStart(smb); } }
//*** UI private void MissingBarRequest(CQGCEL cel, List<string> symbols, int maxCount, bool isAuto = false) { if (_shouldStop) return; _maxBarsLookBack = Math.Abs(maxCount); _aSymbolStates.Clear(); DatabaseManager.CreateMissingBarExceptionTable(); DatabaseManager.CreateSessionHolidayTimesTable(); DatabaseManager.CreateFullReportTable(); _semaphoreGettingSessionData = new Semaphore(0, 1); foreach (string smb in symbols) { var ss = new SymbolState { IsCollected = false, IsSuccess = false }; if (!_aSymbolStates.ContainsKey(smb)) { _aSymbolStates.Add(smb, ss); OnMissingBarStart(smb); } } // Store Holidays new Thread(() => { Thread.CurrentThread.Name = "AsyncGetingSessionsDataThread"; StartAsyncGetingSessionsData(cel, symbols); _semaphoreGettingSessionData.Release(); }).Start(); // Finding Missed bars new Thread(() => { Thread.CurrentThread.Name = "AsyncCheckingMissedBarsThread"; _semaphoreGettingSessionData.WaitOne(); if (isAuto) StartAsyncCheckingMissedBarsAuto(symbols, _maxBarsLookBack); else StartAsyncCheckingMissedBars(symbols); }).Start(); }
private void TickRequest(CQGCEL cel, IEnumerable<string> symbols, DateTime rangeStart, DateTime rangeEnd, string continuationType) { if (_shouldStop) return; if (rangeStart < DateTime.Now.AddDays(-Settings.Default.MaxTickDays)) rangeStart = DateTime.Now.AddDays(-Settings.Default.MaxTickDays); _aSymbolStates.Clear(); _aContinuationType = continuationType; _historicalPeriod = "tick"; foreach (string smb in symbols) { var tickRequest = cel.CreateTicksRequest(); //LineTime = CEL.Environment.LineTime; tickRequest.RangeStart = rangeStart; tickRequest.RangeEnd = rangeEnd; tickRequest.Type = eTicksRequestType.trtSinceTimeNotify; tickRequest.Symbol = smb; CQGTicks ticks = cel.RequestTicks(tickRequest); if (ticks.Status == eRequestStatus.rsInProgress) { var ss = new SymbolState { IsCollected = false, IsSuccess = false }; _aSymbolStates.Add(smb, ss); } OnSymbolCollectStart(smb); } }