static LiveTickCollectorManager()
        {
            try
            {

                Cel = new CQGCEL();
                Cel.APIConfiguration.CollectionsThrowException = false;
                Cel.APIConfiguration.ReadyStatusCheck = eReadyStatusCheck.rscOff;
                Cel.APIConfiguration.TimeZoneCode = eTimeZone.tzGMT;
                Cel.APIConfiguration.DefaultInstrumentSubscriptionLevel = eDataSubscriptionLevel.dsQuotesAndDOM;
                Cel.APIConfiguration.DOMUpdatesMode = eDOMUpdatesMode.domUMDynamic;

                Cel.DataConnectionStatusChanged += _cel_DataConnectionStatusChanged;
                _cel_DataConnectionStatusChanged(eConnectionStatus.csConnectionDown);

                Cel.InstrumentSubscribed += _cel_InstrumentSubscribed;

                Cel.DataError += _cel_DataError;
                Cel.IncorrectSymbol += _cel_IncorrectSymbol;
                Cel.InstrumentChanged += Cel_InstrumentChanged;
                Cel.InstrumentDOMChanged += Cel_InstrumentDOMChanged;
                Cel.Startup();

                _timerScheduler.Tick += _timerScheduler_Tick;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Exemplo n.º 2
0
        static CQGDataCollectorManager()
        {
            try
            {

                Cel = new CQGCEL();
                Cel.APIConfiguration.TimeZoneCode = eTimeZone.tzGMT;
                Cel.APIConfiguration.ReadyStatusCheck = eReadyStatusCheck.rscOff;
                Cel.APIConfiguration.CollectionsThrowException = false;
                Cel.APIConfiguration.LogSeverity = eLogSeverity.lsDebug;
                Cel.APIConfiguration.MessageProcessingTimeout = 30000;

                Cel.DataConnectionStatusChanged += _cel_DataConnectionStatusChanged;
                _cel_DataConnectionStatusChanged(eConnectionStatus.csConnectionDown);

                Cel.InstrumentSubscribed += _cel_InstrumentSubscribed;

                Cel.DataError += _cel_DataError;
                Cel.IncorrectSymbol += _cel_IncorrectSymbol;

                Cel.TimedBarsResolved += _cel_TimedBarsResolved;
                Cel.TicksResolved += _cel_TicksResolved;

                Cel.HistoricalSessionsResolved += _cel_HistoricalSessionsResolved;

                Cel.Startup();

                _timerScheduler.Tick += _timerScheduler_Tick;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Exemplo n.º 3
0
        internal void initializeCQGAndCallbacks(Object obj)
        {
            try
            {
                // Create real CQGCEL object and put it into the dictionary
                // Remark: we do not use "m_CEL = new CQG.CQGCEL();" to facilitate further reflection on this COM object
                string typeName = "CQG.CQGCELClass";
                m_CEL = (CQGCEL)CQGAssm.CreateInstance(typeName);

                m_CEL_key = FakeCQG.Internal.Core.CreateUniqueKey();
                FakeCQG.Internal.ServerDictionaries.PutObjectToTheDictionary(m_CEL_key, m_CEL);
                QueryHandler.UsedObjs.Add(m_CEL_key, m_CEL);

                m_CEL_CELDataConnectionChg(eConnectionStatus.csConnectionDown);

                m_CEL.DataConnectionStatusChanged += new _ICQGCELEvents_DataConnectionStatusChangedEventHandler(m_CEL_CELDataConnectionChg);

                m_CEL.DataError += new _ICQGCELEvents_DataErrorEventHandler(m_CEL_DataError);

                m_CEL.APIConfiguration.ReadyStatusCheck = eReadyStatusCheck.rscOff;

                m_CEL.APIConfiguration.CollectionsThrowException = false;

                m_CEL.APIConfiguration.TimeZoneCode = eTimeZone.tzPacific;

                connectCQG();
            }
            catch (Exception ex)
            {
                TSErrorCatch.errorCatchOut(Convert.ToString(this), ex);
            }
        }
Exemplo n.º 4
0
        static LiveTickCollectorManager()
        {
            try
            {
                Cel = new CQGCEL();
                Cel.APIConfiguration.CollectionsThrowException = false;
                Cel.APIConfiguration.ReadyStatusCheck          = eReadyStatusCheck.rscOff;
                Cel.APIConfiguration.TimeZoneCode = eTimeZone.tzGMT;
                Cel.APIConfiguration.DefaultInstrumentSubscriptionLevel = eDataSubscriptionLevel.dsQuotesAndDOM;
                Cel.APIConfiguration.DOMUpdatesMode = eDOMUpdatesMode.domUMDynamic;

                Cel.DataConnectionStatusChanged += _cel_DataConnectionStatusChanged;
                _cel_DataConnectionStatusChanged(eConnectionStatus.csConnectionDown);

                Cel.InstrumentSubscribed += _cel_InstrumentSubscribed;

                Cel.DataError            += _cel_DataError;
                Cel.IncorrectSymbol      += _cel_IncorrectSymbol;
                Cel.InstrumentChanged    += Cel_InstrumentChanged;
                Cel.InstrumentDOMChanged += Cel_InstrumentDOMChanged;
                Cel.Startup();


                _timerScheduler.Tick += _timerScheduler_Tick;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Exemplo n.º 5
0
 public void attachCQG_Interface(CQGCEL cqgCell)
 {
     if (cqgCell == null)
     {
         throw new Exception("Not initialized CQG interface attached.");
     }
     _cel = cqgCell;
 }
Exemplo n.º 6
0
        public void StartMissingBar(List <string> symbols, CQGCEL cel, bool isAuto, int maxCount)
        {
            if (!symbols.Any() || _shouldStop || !cel.IsStarted)
            {
                OnFinished();
                return;
            }

            MissingBarRequest(cel, symbols, maxCount, isAuto);
            OnProgress(0);
        }
Exemplo n.º 7
0
 public CQGFrm()
 {
     try
     {
         InitializeComponent();
         m_Log = log4net.LogManager.GetLogger("Kaitrade");
         //m_RegisterSubject = new RegisterSubject(this.doRegisterSubject);
         m_ProcessMessage = new ProcessMessage(this.doProcessMessage);
         // Start connection to CQG
         m_CQG = null;
         //m_CQG = new CQGCEL();
     }
     catch (Exception myE)
     {
     }
 }
Exemplo n.º 8
0
        //*** UI


        private void MissingBarRequest(CQGCEL cel, List <string> symbols, int maxCount, bool isAuto = false)
        {
            if (_shouldStop)
            {
                return;
            }
            _maxBarsLookBack = Math.Abs(maxCount);
            _symbolState.Clear();

            ClientDatabaseManager.CreateMissingBarExceptionTable();
            ClientDatabaseManager.CreateSessionHolidayTimesTable();
            ClientDatabaseManager.CreateFullReportTable();

            _semaphoreGettingSessionData = new Semaphore(0, 1);


            foreach (string smb in symbols)
            {
                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();
        }
Exemplo n.º 9
0
        public static void Init()
        {
            if (_inited) return;
            _inited = true;

            _cqgVar=new CQGCEL();
            _cqgVar.DataConnectionStatusChanged += _cel_DataConnectionStatusChanged;
            _cel_DataConnectionStatusChanged(eConnectionStatus.csConnectionDown);

            _cqgVar.InstrumentSubscribed += _cel_InstrumentSubscribed;
            _cqgVar.IncorrectSymbol += _cel_IncorrectSymbol;
            _cqgVar.InstrumentChanged += CQG_var_InstrumentChanged;
            _cqgVar.APIConfiguration.CollectionsThrowException = false;
            _cqgVar.APIConfiguration.ReadyStatusCheck = eReadyStatusCheck.rscOff;
            _cqgVar.APIConfiguration.TimeZoneCode = eTimeZone.tzCentral;

            _cqgVar.Startup();
        }
Exemplo n.º 10
0
        public CQGConnector()
        {
            _cel = new CQGCEL();
            _cel.APIConfiguration.CollectionsThrowException = false;
            _cel.APIConfiguration.ReadyStatusCheck = eReadyStatusCheck.rscOff;
            _cel.APIConfiguration.TimeZoneCode = eTimeZone.tzGMT;
            _cel.APIConfiguration.DefaultInstrumentSubscriptionLevel = eDataSubscriptionLevel.dsQuotesAndBBA;
            _cel.APIConfiguration.DOMUpdatesMode = eDOMUpdatesMode.domUMDynamic;

            if (_cel.IsStarted)
            {
                _cel.Shutdown();
            }

            if (!_cel.IsStarted)
            {
                _cel.Startup();
            }
        }
Exemplo n.º 11
0
        public CQGConnector()
        {
            _cel = new CQGCEL();
            _cel.APIConfiguration.CollectionsThrowException = false;
            _cel.APIConfiguration.ReadyStatusCheck          = eReadyStatusCheck.rscOff;
            _cel.APIConfiguration.TimeZoneCode = eTimeZone.tzGMT;
            _cel.APIConfiguration.DefaultInstrumentSubscriptionLevel = eDataSubscriptionLevel.dsQuotesAndBBA;
            _cel.APIConfiguration.DOMUpdatesMode = eDOMUpdatesMode.domUMDynamic;


            if (_cel.IsStarted)
            {
                _cel.Shutdown();
            }

            if (!_cel.IsStarted)
            {
                _cel.Startup();
            }
        }
Exemplo n.º 12
0
        public static void Init()
        {
            if (_inited)
            {
                return;
            }
            _inited = true;

            _cqgVar = new CQGCEL();
            _cqgVar.DataConnectionStatusChanged += _cel_DataConnectionStatusChanged;
            _cel_DataConnectionStatusChanged(eConnectionStatus.csConnectionDown);

            _cqgVar.InstrumentSubscribed += _cel_InstrumentSubscribed;
            _cqgVar.IncorrectSymbol      += _cel_IncorrectSymbol;
            _cqgVar.InstrumentChanged    += CQG_var_InstrumentChanged;
            _cqgVar.APIConfiguration.CollectionsThrowException = false;
            _cqgVar.APIConfiguration.ReadyStatusCheck          = eReadyStatusCheck.rscOff;
            _cqgVar.APIConfiguration.TimeZoneCode = eTimeZone.tzCentral;

            _cqgVar.Startup();
        }
        public void CreateConnection(CQGCEL CEL)
        {
            try
            {
                // Creates the CQGCEL object
                CEL = new CQGCEL();
                CEL.DataError += new CQG._ICQGCELEvents_DataErrorEventHandler(CEL_DataError);
                CEL.DataConnectionStatusChanged += new CQG._ICQGCELEvents_DataConnectionStatusChangedEventHandler(CEL_DataConnectionStatusChanged);
                CEL.APIConfiguration.ReadyStatusCheck = eReadyStatusCheck.rscOff;
                CEL.APIConfiguration.CollectionsThrowException = false;
                CEL.APIConfiguration.TimeZoneCode = eTimeZone.tzGreenwich;
                // Disables the controls
                CEL_DataConnectionStatusChanged(eConnectionStatus.csConnectionDown);
                // Starts up the CQGCEL
                CEL.Startup();

             }
            catch (Exception ex)
            {
                modErrorHandler.ShowError("CQGConnection.cs", "CreateConnection", ex);
            }
        }
Exemplo n.º 14
0
        private void StartAsyncGetingSessionsData(CQGCEL cel, List <string> symbols)
        {
            for (int i = 0; i < symbols.Count(); i++)
            {
                var symbol = symbols[i];

                var progress = (i * (50 / symbols.Count()));
                OnProgress(progress);

                _aSemaphoreHolidays = new Semaphore(0, 1);
                _aSemaphoreSessions = new Semaphore(0, 1);

                List <DateTime> aResultDateTimes = ClientDatabaseManager.GetAllDateTimes(ClientDatabaseManager.GetTableFromSymbol(symbol));

                if (aResultDateTimes == null || aResultDateTimes.Count == 0)
                {
                    continue;
                }

                var rangeBegin = aResultDateTimes.First();
                var rangeEnd   = aResultDateTimes.Last();
                var req        = cel.CreateHistoricalSessionsRequest();


                req.Type       = eHistoricalSessionsRequestType.hsrtTimeRange;
                req.Symbol     = symbol;
                req.RangeStart = rangeBegin;
                req.RangeEnd   = rangeEnd;

                cel.RequestHistoricalSessions(req);
                _aSemaphoreHolidays.WaitOne(20000);// wait


                cel.NewInstrument(symbol);
                _aSemaphoreSessions.WaitOne(20000);// wait
            }
        }
Exemplo n.º 15
0
        public SymbolDataWriter(CQGConnector connector, string userName, int standardDepth, bool useMoreInfo)
        {
            _userName      = userName;
            _isMoreInfo    = useMoreInfo;
            _standardDepth = standardDepth;

            _allowedSymbols.Clear();

            if (connector == null)
            {
                throw new Exception("Not initialized CQG connector attached.");
            }
            _symbolsTable = new Dictionary <string, SymbolData>();
            _tickTable    = new Dictionary <string, TickData>();
            _cel          = connector.ICEL;

            connector.addIncorrectSymbolListener(CEL_IncorrectSymbol);
            connector.addInstrumentSubscribedListener(CEL_InstrumentSubscribed);
            connector.addInstrumentChanged(CQG_InstrumentChanged);
            connector.addInstrumentDOMChangedListene(CEL_InstrumentDOMChanged);
            connector.addStartedListener(CEL_CELStarted);

            _addSybolsList = new Dictionary <string, Control>();
        }
Exemplo n.º 16
0
        static CQGDataCollectorManager()
        {
            try
            {
                Cel = new CQGCEL();
                Cel.APIConfiguration.TimeZoneCode              = eTimeZone.tzGMT;
                Cel.APIConfiguration.ReadyStatusCheck          = eReadyStatusCheck.rscOff;
                Cel.APIConfiguration.CollectionsThrowException = false;
                Cel.APIConfiguration.LogSeverity = eLogSeverity.lsDebug;
                Cel.APIConfiguration.MessageProcessingTimeout = 30000;

                Cel.DataConnectionStatusChanged += _cel_DataConnectionStatusChanged;
                _cel_DataConnectionStatusChanged(eConnectionStatus.csConnectionDown);

                Cel.InstrumentSubscribed += _cel_InstrumentSubscribed;

                Cel.DataError       += _cel_DataError;
                Cel.IncorrectSymbol += _cel_IncorrectSymbol;

                Cel.TimedBarsResolved += _cel_TimedBarsResolved;
                Cel.TicksResolved     += _cel_TicksResolved;

                Cel.HistoricalSessionsResolved += _cel_HistoricalSessionsResolved;

                Cel.Startup();


                _timerScheduler.Tick += _timerScheduler_Tick;
                //_timerTimeout.Tick += _timerTimeout_Tick;
                _timerTimeout.Elapsed += _timerTimeout_Elapsed;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Exemplo n.º 17
0
        public SymbolDataWriter(CQGConnector connector, string userName, int standardDepth, bool useMoreInfo)
        {
            _userName = userName;
            _isMoreInfo = useMoreInfo;
            _standardDepth = standardDepth;

            _allowedSymbols.Clear();

            if (connector == null)
            {
                throw new Exception("Not initialized CQG connector attached.");
            }
            _symbolsTable = new Dictionary<string, SymbolData>();
            _tickTable = new Dictionary<string, TickData>();
            _cel = connector.ICEL;

            connector.addIncorrectSymbolListener(CEL_IncorrectSymbol);
            connector.addInstrumentSubscribedListener(CEL_InstrumentSubscribed);
            connector.addInstrumentChanged(CQG_InstrumentChanged);
            connector.addInstrumentDOMChangedListene(CEL_InstrumentDOMChanged);
            connector.addStartedListener(CEL_CELStarted);

            _addSybolsList = new Dictionary<string, Control>();
        }
Exemplo n.º 18
0
        public void StartCollectingSymbols(List<string> symbols, CQGCEL cel, bool isBars, DateTime rangeDateStart, DateTime rangeDateEnd, int sessionFilter, string historicalPeriod, string continuationType, int rangeStart, int rangeEnd)
        {
            if (!symbols.Any() || _shouldStop || !cel.IsStarted)
            {
                OnFinished();
                return;
            }

            if (isBars)
            {

                BarRequest(cel, symbols, rangeStart, rangeEnd, sessionFilter, historicalPeriod, continuationType);
            }
            else
            {
                TickRequest(cel, symbols, rangeDateStart, rangeDateEnd, continuationType);
            }
        }
Exemplo n.º 19
0
        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);
            }
        }
Exemplo n.º 20
0
        private void StartAsyncGetingSessionsData(CQGCEL cel, IEnumerable<string> symbols)
        {
            foreach (string symbol in symbols)
            {
                _aSemaphoreHolidays = new Semaphore(0, 1);
                _aSemaphoreSessions = new Semaphore(0, 1);

                List<DateTime> aResultDateTimes = DatabaseManager.GetAllDateTimes(DatabaseManager.GetTableFromSymbol(symbol));

                if (aResultDateTimes == null || aResultDateTimes.Count == 0)
                    continue;

                var rangeBegin = aResultDateTimes.First();
                var rangeEnd = aResultDateTimes.Last();
                var req = cel.CreateHistoricalSessionsRequest();

                req.Type = eHistoricalSessionsRequestType.hsrtTimeRange;
                req.Symbol = symbol;
                req.RangeStart = rangeBegin;
                req.RangeEnd = rangeEnd;

                cel.RequestHistoricalSessions(req);
                _aSemaphoreHolidays.WaitOne(20000);// wait

                cel.NewInstrument(symbol);
                _aSemaphoreSessions.WaitOne(20000);// wait
            }
        }
Exemplo n.º 21
0
		/// <summary>
		/// Send message.
		/// </summary>
		/// <param name="message">Message.</param>
		protected override void OnSendInMessage(Message message)
		{
			switch (message.Type)
			{
				case MessageTypes.Reset:
				{
					if (_session != null)
					{
						try
						{
							DisposeSession();
						}
						catch (Exception ex)
						{
							SendOutError(ex);
						}

						_session = null;
					}

					SendOutMessage(new ResetMessage());

					break;
				}

				case MessageTypes.Connect:
				{
					if (_session != null)
						throw new InvalidOperationException(LocalizedStrings.Str1619);

					_session = new CQGCELClass();
					_session.CELStarted += SessionOnCelStarted;
					_session.DataError += SessionOnDataError;

					_session.AccountChanged += SessionOnAccountChanged;
					_session.AlgorithmicOrderPlaced += SessionOnAlgorithmicOrderPlaced;
					_session.AlgorithmicOrderRegistrationComplete += SessionOnAlgorithmicOrderRegistrationComplete;
					_session.OrderChanged += SessionOnOrderChanged;
					_session.PositionsStatementResolved += SessionOnPositionsStatementResolved;

					_session.InstrumentDOMChanged += SessionOnInstrumentDomChanged;
					_session.InstrumentChanged += SessionOnInstrumentChanged;
					_session.TicksAdded += SessionOnTicksAdded;
					_session.IncorrectSymbol += SessionOnIncorrectSymbol;
					_session.InstrumentSubscribed += SessionOnInstrumentSubscribed;
					_session.ConstantVolumeBarsAdded += SessionOnConstantVolumeBarsAdded;
					_session.ConstantVolumeBarsUpdated += SessionOnConstantVolumeBarsUpdated;
					_session.PointAndFigureBarsAdded += SessionOnPointAndFigureBarsAdded;
					_session.PointAndFigureBarsUpdated += SessionOnPointAndFigureBarsUpdated;
					_session.TimedBarsAdded += SessionOnTimedBarsAdded;
					_session.TimedBarsUpdated += SessionOnTimedBarsUpdated;
					_session.TFlowBarsAdded += SessionOnFlowBarsAdded;
					_session.TFlowBarsUpdated += SessionOnFlowBarsUpdated;

					_session.Startup();

					break;
				}

				case MessageTypes.Disconnect:
				{
					if (_session == null)
						throw new InvalidOperationException(LocalizedStrings.Str1856);

					DisposeSession();
					_session = null;

					SendOutMessage(new DisconnectMessage());

					break;
				}

				case MessageTypes.MarketData:
				{
					var mdMsg = (MarketDataMessage)message;

					switch (mdMsg.DataType)
					{
						case MarketDataTypes.Level1:
						{
							var instrument = _instruments.TryGetValue(mdMsg.SecurityId.SecurityCode);
							//SessionHolder.Session.CreateInstrumentRequest().;

							break;
						}
						case MarketDataTypes.MarketDepth:
							break;
						case MarketDataTypes.Trades:
							break;
						case MarketDataTypes.OrderLog:
							break;
						case MarketDataTypes.CandleTimeFrame:
							break;
						default:
						{
							SendOutMarketDataNotSupported(mdMsg.TransactionId);
							return;
						}
					}

					var reply = (MarketDataMessage)mdMsg.Clone();
					reply.OriginalTransactionId = mdMsg.TransactionId;
					SendOutMessage(reply);

					break;
				}

				case MessageTypes.OrderRegister:
				{
					var regMsg = (OrderRegisterMessage)message;
					var instrument = _instruments.TryGetValue(regMsg.SecurityId.SecurityCode);

					if (instrument == null)
						throw new InvalidOperationException(LocalizedStrings.Str3792Params.Put(regMsg.SecurityId.SecurityCode));

					var account = _accounts.TryGetValue(regMsg.PortfolioName);

					if (account == null)
						throw new InvalidOperationException(LocalizedStrings.Str3793Params.Put(regMsg.PortfolioName));

					var stopPrice = regMsg.OrderType == OrderTypes.Conditional
						? ((CQGOrderCondition)regMsg.Condition).StopPrice
						: null;

					var order = _session.CreateOrder(regMsg.OrderType.ToCQG(stopPrice), instrument, account, (int)regMsg.Volume, regMsg.Side.ToCQG(), (double)regMsg.Price, (double)(stopPrice ?? 0));
					_orders.Add(regMsg.TransactionId, order);
					order.Place();
					break;
				}

				case MessageTypes.OrderCancel:
				{
					var cancelMsg = (OrderCancelMessage)message;
					var order = _orders.TryGetValue(cancelMsg.OrderTransactionId);

					if (order == null)
						throw new InvalidOperationException(LocalizedStrings.Str3794Params.Put(cancelMsg.OrderTransactionId));
					else
						order.Cancel();

					break;
				}

				case MessageTypes.OrderReplace:
				{
					var replaceMsg = (OrderReplaceMessage)message;
					var order = _orders.TryGetValue(replaceMsg.OldTransactionId);

					if (order == null)
					{
						throw new InvalidOperationException(LocalizedStrings.Str3794Params.Put(replaceMsg.OldTransactionId));
					}
					else
					{
						var modify = order.PrepareModify();
						modify.Properties[eOrderProperty.opLimitPrice].Value = replaceMsg.Price;
						modify.Properties[eOrderProperty.opQuantity].Value = replaceMsg.Volume;
						order.Modify(modify);
					}

					break;
				}
			}
		}
Exemplo n.º 22
0
        //*** 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();
        }
Exemplo n.º 23
0
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                DataNetClientDataManager.ConnectionStatusChanged += ClientDataManager_ConnectionStatusChanged;

                if (Settings.Default.L.X < 0 || Settings.Default.L.Y < 0) Settings.Default.L = new Point(0, 0);
                if (Settings.Default.S.Width < 0 || Settings.Default.S.Height < 0) Settings.Default.S = new Size(800, 500);

                Size = Settings.Default.S;
                Location = Settings.Default.L;

                UpdateControlsSizeAndLocation();

                _logger = Logger.GetInstance(listViewLogger);
                _logger.LogAdd("Application Start", Category.Information);
                _dataCollector = new DataCollector(_logger);
                _dataCollector.SymbolCollectStart += DataCollector_SymbolCollectStart;
                _dataCollector.SymbolCollectEnd += DataCollector_SymbolCollectEnd;

                _dataCollector.MissingBarStart += DataCollector_MissingBarStart;
                _dataCollector.MissingBarEnd += DataCollector_MissingBarEnd;

                _dataCollector.Finished += DataCollector_Finished;

                ui_home_textBoxX_db.Text = Settings.Default.DB;
                ui_home_textBoxX_db_bar.Text = Settings.Default.dbBar;
                ui_home_textBoxX_db_historical.Text = Settings.Default.dbHistorical;
                ui_home_textBoxX_uid.Text = Settings.Default.User;
                ui_home_textBoxX_pwd.Text = Settings.Default.Password;
                ui_home_textBoxX_host.Text = Settings.Default.Host;
                nudEndBar.Value = Settings.Default.valFinish;
                ui_checkBoxAuto_CheckForMissedBars.Value = Settings.Default.AutoMissingBarReport;
                checkBoxX1.Checked = Settings.Default.SavePass;
                //**
                metroShell1.SelectedTab = metroTabItem1;

                cmbContinuationType.Items.Clear();
                cmbContinuationType.Items.Add(eTimeSeriesContinuationType.tsctNoContinuation);
                cmbContinuationType.Items.Add(eTimeSeriesContinuationType.tsctStandard);
                cmbContinuationType.Items.Add(eTimeSeriesContinuationType.tsctStandardByMonth);
                cmbContinuationType.Items.Add(eTimeSeriesContinuationType.tsctActive);
                cmbContinuationType.Items.Add(eTimeSeriesContinuationType.tsctActiveByMonth);
                cmbContinuationType.Items.Add(eTimeSeriesContinuationType.tsctAdjusted);
                cmbContinuationType.Items.Add(eTimeSeriesContinuationType.tsctAdjustedByMonth);
                cmbContinuationType.SelectedIndex = 0;
                cmbHistoricalPeriod.SelectedIndex = 0;

                ResetColorMarks();
                // todo
                _cel = new CQGCEL();
                _cel.APIConfiguration.TimeZoneCode = eTimeZone.tzGMT;
                _cel.APIConfiguration.ReadyStatusCheck = eReadyStatusCheck.rscOff;
                _cel.APIConfiguration.CollectionsThrowException = false;
                _cel.APIConfiguration.LogSeverity = eLogSeverity.lsDebug;
                _cel.APIConfiguration.MessageProcessingTimeout = 30000;

                _cel.DataConnectionStatusChanged += CEL_DataConnectionStatusChanged;
                CEL_DataConnectionStatusChanged(eConnectionStatus.csConnectionDown);
                _cel.DataError += CEL_DataError;
                _cel.TimedBarsResolved += CEL_TimedBarsResolved;
                _cel.IncorrectSymbol += CEL_IncorrectSymbol;
                _cel.HistoricalSessionsResolved += CEL_HistoricalSessionsResolved;
                _cel.TicksResolved += CQG_TicksResolved;
                _cel.InstrumentSubscribed += CEL_InstrumentSubscribed;

                _cel.Startup();

                //todo

                //currStatus = DEFAULT_STATUS;
                dateTimeInputStart.Value = DateTime.Now.AddDays(-1);
                dateTimeInputEnd.Value = DateTime.Now;
                ui_listBox_symbols.DrawItem += listBox1_DrawItem;

                _pingTimer = new Timer();
                _pingTimer.Tick += TimerTick;
                _pingTimer.Interval = 1000;
                _pingTimer.Enabled = true;
                _onlineServerSymbol = _startControl.uiServerOnlineFakeSymbol.Symbol;
                _offlineServerSymbol = _startControl.uiOfflineFakeSymbol.Symbol;

                //todo
                styledListControl1.ItemStateChanged += styledListControl1_ItemStateChanged;
                CQGDataCollectorManager.ItemStateChanged += CQGDataCollectorManager_ItemStateChanged;
                CQGDataCollectorManager.CollectedSymbolCountChanged += CQGDataCollectorManager_CollectedSymbolCountChanged;
                CQGDataCollectorManager.RunnedStateChanged += CQGDataCollectorManager_RunnedStateChanged;
                CQGDataCollectorManager.StartTimeChanged += CQGDataCollectorManager_StartTimeChanged;
                CQGDataCollectorManager.CQGStatusChanged += CQGDataCollectorManager_CQGStatusChanged;
                //todo

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                _logger.LogAdd("Error in loading. " + ex.Message, Category.Error);
                Close();
            }
        }
Exemplo n.º 24
0
        protected void MMbtnStart_Click(object who, EventArgs e)
        {
            //Tick tick = new Tick();
            string p = Form.ActiveForm.Name.ToString();
            string s = p.Substring(3, 1);
            int w = Convert.ToInt32(s);

            foreach (Control ct in Form.ActiveForm.Controls)
            {
                //MessageBox.Show(ct.ToString());
                if (ct is TextBox)
                {
                   //tick.CEL_IncorrectSymbol(((TextBox)(ct)).Text);

                    m_selectedSym = ((TextBox)(ct)).Text;
                    //Tick tick = new Tick(m_selectedSym);
                }
            }

            m_CEL = new CQGCEL();

            // m_CEL.CELStarted += new _ICQGCELEvents_CELStartedEventHandler(CEL_CELStarted);
            m_CEL.DataConnectionStatusChanged += new _ICQGCELEvents_DataConnectionStatusChangedEventHandler(CEL_DataConnectionStatusChanged);
        }
Exemplo n.º 25
0
        /// <summary>
        /// Send message.
        /// </summary>
        /// <param name="message">Message.</param>
        protected override void OnSendInMessage(Message message)
        {
            switch (message.Type)
            {
            case MessageTypes.Reset:
            {
                if (_session != null)
                {
                    try
                    {
                        DisposeSession();
                    }
                    catch (Exception ex)
                    {
                        SendOutError(ex);
                    }

                    _session = null;
                }

                SendOutMessage(new ResetMessage());

                break;
            }

            case MessageTypes.Connect:
            {
                if (_session != null)
                {
                    throw new InvalidOperationException(LocalizedStrings.Str1619);
                }

                _session             = new CQGCELClass();
                _session.CELStarted += SessionOnCelStarted;
                _session.DataError  += SessionOnDataError;

                _session.AccountChanged         += SessionOnAccountChanged;
                _session.AlgorithmicOrderPlaced += SessionOnAlgorithmicOrderPlaced;
                _session.AlgorithmicOrderRegistrationComplete += SessionOnAlgorithmicOrderRegistrationComplete;
                _session.OrderChanged += SessionOnOrderChanged;
                _session.PositionsStatementResolved += SessionOnPositionsStatementResolved;

                _session.InstrumentDOMChanged      += SessionOnInstrumentDomChanged;
                _session.InstrumentChanged         += SessionOnInstrumentChanged;
                _session.TicksAdded                += SessionOnTicksAdded;
                _session.IncorrectSymbol           += SessionOnIncorrectSymbol;
                _session.InstrumentSubscribed      += SessionOnInstrumentSubscribed;
                _session.ConstantVolumeBarsAdded   += SessionOnConstantVolumeBarsAdded;
                _session.ConstantVolumeBarsUpdated += SessionOnConstantVolumeBarsUpdated;
                _session.PointAndFigureBarsAdded   += SessionOnPointAndFigureBarsAdded;
                _session.PointAndFigureBarsUpdated += SessionOnPointAndFigureBarsUpdated;
                _session.TimedBarsAdded            += SessionOnTimedBarsAdded;
                _session.TimedBarsUpdated          += SessionOnTimedBarsUpdated;
                _session.TFlowBarsAdded            += SessionOnFlowBarsAdded;
                _session.TFlowBarsUpdated          += SessionOnFlowBarsUpdated;

                _session.Startup();

                break;
            }

            case MessageTypes.Disconnect:
            {
                if (_session == null)
                {
                    throw new InvalidOperationException(LocalizedStrings.Str1856);
                }

                DisposeSession();
                _session = null;

                SendOutMessage(new DisconnectMessage());

                break;
            }

            case MessageTypes.MarketData:
            {
                var mdMsg = (MarketDataMessage)message;

                switch (mdMsg.DataType)
                {
                case MarketDataTypes.Level1:
                {
                    var instrument = _instruments.TryGetValue(mdMsg.SecurityId.SecurityCode);
                    //SessionHolder.Session.CreateInstrumentRequest().;

                    break;
                }

                case MarketDataTypes.MarketDepth:
                    break;

                case MarketDataTypes.Trades:
                    break;

                case MarketDataTypes.OrderLog:
                    break;

                case MarketDataTypes.CandleTimeFrame:
                    break;

                default:
                {
                    SendOutMarketDataNotSupported(mdMsg.TransactionId);
                    return;
                }
                }

                var reply = (MarketDataMessage)mdMsg.Clone();
                reply.OriginalTransactionId = mdMsg.TransactionId;
                SendOutMessage(reply);

                break;
            }

            case MessageTypes.OrderRegister:
            {
                var regMsg     = (OrderRegisterMessage)message;
                var instrument = _instruments.TryGetValue(regMsg.SecurityId.SecurityCode);

                if (instrument == null)
                {
                    throw new InvalidOperationException(LocalizedStrings.Str3792Params.Put(regMsg.SecurityId.SecurityCode));
                }

                var account = _accounts.TryGetValue(regMsg.PortfolioName);

                if (account == null)
                {
                    throw new InvalidOperationException(LocalizedStrings.Str3793Params.Put(regMsg.PortfolioName));
                }

                if (regMsg.OrderType == null)
                {
                    throw new InvalidOperationException();
                }

                var stopPrice = regMsg.OrderType == OrderTypes.Conditional
                                                ? ((CQGOrderCondition)regMsg.Condition).StopPrice
                                                : null;

                var order = _session.CreateOrder(regMsg.OrderType.Value.ToCQG(stopPrice), instrument, account, (int)regMsg.Volume, regMsg.Side.ToCQG(), (double)regMsg.Price, (double)(stopPrice ?? 0));
                _orders.Add(regMsg.TransactionId, order);
                order.Place();
                break;
            }

            case MessageTypes.OrderCancel:
            {
                var cancelMsg = (OrderCancelMessage)message;
                var order     = _orders.TryGetValue(cancelMsg.OrderTransactionId);

                if (order == null)
                {
                    throw new InvalidOperationException(LocalizedStrings.Str3794Params.Put(cancelMsg.OrderTransactionId));
                }
                else
                {
                    order.Cancel();
                }

                break;
            }

            case MessageTypes.OrderReplace:
            {
                var replaceMsg = (OrderReplaceMessage)message;
                var order      = _orders.TryGetValue(replaceMsg.OldTransactionId);

                if (order == null)
                {
                    throw new InvalidOperationException(LocalizedStrings.Str3794Params.Put(replaceMsg.OldTransactionId));
                }
                else
                {
                    var modify = order.PrepareModify();
                    modify.Properties[eOrderProperty.opLimitPrice].Value = replaceMsg.Price;
                    modify.Properties[eOrderProperty.opQuantity].Value   = replaceMsg.Volume;
                    order.Modify(modify);
                }

                break;
            }
            }
        }
Exemplo n.º 26
0
 public void attachCQG_Interface(CQGCEL cqgCell)
 {
     if (cqgCell == null)
     {
         throw new Exception("Not initialized CQG interface attached.");
     }
     _cel = cqgCell;
 }
Exemplo n.º 27
0
        private void CQGFrm_FormClosed(object sender, FormClosedEventArgs e)
        {
            try
            {
                m_Log.Info("CQGFrm_FormClosed");
                m_Adapter = null;
                m_CQG = null;
                m_ProcessMessage = null;
                m_RegisterSubject = null;

            }
            catch (Exception myE)
            {

            }
        }
Exemplo n.º 28
0
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                slidePanelSymbols.IsOpen = false;
                ClientDatabaseManager.ConnectionStatusChanged += ClientDataManager_ConnectionStatusChanged;

                if (Settings.Default.L.X < 0 || Settings.Default.L.Y < 0) Settings.Default.L = new Point(0, 0);
                if (Settings.Default.S.Width < 0 || Settings.Default.S.Height < 0)
                    Settings.Default.S = new Size(800, 500);

                Size = Settings.Default.S;
                Location = Settings.Default.L;
                checkBox_emailMe.Checked = Settings.Default.IsSendReports;
                UpdateControlsSizeAndLocation();

                _logger = Logger.GetInstance(listViewLogger);
                _logger.LogAdd("Application Start", Category.Information);
                _missingBarManager = new MissingBarManager(_logger);

                _missingBarManager.MissingBarStart += DataCollector_MissingBarStart;
                _missingBarManager.MissingBarEnd += DataCollector_MissingBarEnd;

                _missingBarManager.Finished += DataCollector_Finished;
                _missingBarManager.Progress += _missingBarManager_Progress;

                ui_home_textBoxX_db.Text = Settings.Default.MainDB;
                ui_home_textBoxX_db_bar.Text = Settings.Default.dbBar;
                ui_home_textBoxX_db_historical.Text = Settings.Default.dbHistorical;
                ui_home_textBoxX_uid.Text = Settings.Default.User;
                ui_home_textBoxX_pwd.Text = Settings.Default.Password;
                ui_home_textBoxX_host.Text = Settings.Default.Host;
                nudEndBar.Value = Settings.Default.valFinish;
                ui_checkBoxAuto_CheckForMissedBars.Value = Settings.Default.AutoMissingBarReport;
                checkBoxX1.Checked = Settings.Default.SavePass;
                //**
                metroShell1.SelectedTab = metroTabItem1;

                cmbContinuationType.Items.Clear();
                cmbContinuationType.Items.Add(eTimeSeriesContinuationType.tsctNoContinuation);
                cmbContinuationType.Items.Add(eTimeSeriesContinuationType.tsctStandard);
                //cmbContinuationType.Items.Add(eTimeSeriesContinuationType.tsctStandardByMonth);
                //cmbContinuationType.Items.Add(eTimeSeriesContinuationType.tsctActive);
                //cmbContinuationType.Items.Add(eTimeSeriesContinuationType.tsctActiveByMonth);
                //cmbContinuationType.Items.Add(eTimeSeriesContinuationType.tsctAdjusted);
                //cmbContinuationType.Items.Add(eTimeSeriesContinuationType.tsctAdjustedByMonth);
                cmbContinuationType.SelectedIndex = 1;
                cmbHistoricalPeriod.SelectedIndex = 0;

                ResetColorMarks();
                // todo
                _cel = new CQGCEL();
                _cel.APIConfiguration.TimeZoneCode = eTimeZone.tzGMT;
                _cel.APIConfiguration.ReadyStatusCheck = eReadyStatusCheck.rscOff;
                _cel.APIConfiguration.CollectionsThrowException = false;
                _cel.APIConfiguration.LogSeverity = eLogSeverity.lsDebug;
                _cel.APIConfiguration.MessageProcessingTimeout = 30000;

                _cel.DataConnectionStatusChanged += CEL_DataConnectionStatusChanged;
                CEL_DataConnectionStatusChanged(eConnectionStatus.csConnectionDown);
                _cel.DataError += CEL_DataError;
                _cel.IncorrectSymbol += CEL_IncorrectSymbol;
                _cel.HistoricalSessionsResolved += CEL_HistoricalSessionsResolved;
                _cel.InstrumentSubscribed += CEL_InstrumentSubscribed;

                //todo

                //currStatus = DEFAULT_STATUS;
                dateTimeInputStart.Value = DateTime.Now.AddDays(-1);
                dateTimeInputEnd.Value = DateTime.Now;

                _pingTimer = new Timer();
                _pingTimer.Tick += TimerTick;
                _pingTimer.Interval = 1000;
                _pingTimer.Enabled = true;
                _onlineServerSymbol = _startControl.uiServerOnlineFakeSymbol.Symbol;
                _offlineServerSymbol = _startControl.uiOfflineFakeSymbol.Symbol;

                //todo
                groupList4.ItemStateChanged +=groupList4_ItemStateChanged;
                CQGDataCollectorManager.ItemStateChanged += CQGDataCollectorManager_ItemStateChanged;
                CQGDataCollectorManager.CollectedSymbolCountChanged +=
                    CQGDataCollectorManager_CollectedSymbolCountChanged;
                CQGDataCollectorManager.RunnedStateChanged += CQGDataCollectorManager_RunnedStateChanged;
                CQGDataCollectorManager.StartTimeChanged += CQGDataCollectorManager_StartTimeChanged;
                CQGDataCollectorManager.CQGStatusChanged += CQGDataCollectorManager_CQGStatusChanged;

                CQGDataCollectorManager.UnsuccessfulSymbol += CQGDataCollectorManager_UnsuccessfulSymbol;
                CQGDataCollectorManager.TickInsertingStarted += CQGDataCollectorManager_TickInsertingStarted;
                CQGDataCollectorManager.ProgressBarChanged += CQGDataCollectorManager_ProgressBarChanched;

                CQGDataCollectorManager.SendReport += CQGDataCollectorManager_SendReport;
                //todo
                Thread.Sleep(1000); // Fixed bug with closeing while starting//do not remove this
                _cel.Startup();

                //Restarting after crashing
                if (Settings.Default.IsCrashed)
                {
                    LoginToServer(Settings.Default.scUser1, Settings.Default.scPassword, Settings.Default.scHostSlave,
                        _nowIsMaster);

                }

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                _logger.LogAdd("Error in loading. " + ex.Message, Category.Error);
                Close();
            }
        }
Exemplo n.º 29
0
        public void StartMissingBar(List<string> symbols, CQGCEL cel, bool isAuto, int maxCount)
        {
            if (!symbols.Any() || _shouldStop || !cel.IsStarted)
            {
                OnFinished();
                return;
            }

            MissingBarRequest(cel, symbols, maxCount, isAuto);
        }
Exemplo n.º 30
0
        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);
            }
        }
Exemplo n.º 31
0
        private void StartAsyncGetingSessionsData(CQGCEL cel, List<string> symbols)
        {
            for (int i = 0; i < symbols.Count(); i++)
            {
                var symbol = symbols[i];

                var progress = (i * (50 / symbols.Count()));
                OnProgress(progress);

                _aSemaphoreHolidays = new Semaphore(0, 1);
                _aSemaphoreSessions = new Semaphore(0, 1);

                List<DateTime> aResultDateTimes = ClientDatabaseManager.GetAllDateTimes(ClientDatabaseManager.GetTableFromSymbol(symbol));

                if (aResultDateTimes == null || aResultDateTimes.Count == 0)
                    continue;

                var rangeBegin = aResultDateTimes.First();
                var rangeEnd = aResultDateTimes.Last();
                var req = cel.CreateHistoricalSessionsRequest();

                req.Type = eHistoricalSessionsRequestType.hsrtTimeRange;
                req.Symbol = symbol;
                req.RangeStart = rangeBegin;
                req.RangeEnd = rangeEnd;

                cel.RequestHistoricalSessions(req);
                _aSemaphoreHolidays.WaitOne(20000);// wait

                cel.NewInstrument(symbol);
                _aSemaphoreSessions.WaitOne(20000);// wait
            }
        }
Exemplo n.º 32
0
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                ClientDatabaseManager.ConnectionStatusChanged += ClientDataManager_ConnectionStatusChanged;

                if (Settings.Default.L.X < 0 || Settings.Default.L.Y < 0) Settings.Default.L = new Point(0, 0);
                if (Settings.Default.S.Width < 0 || Settings.Default.S.Height < 0)
                    Settings.Default.S = new Size(800, 500);

                Size = Settings.Default.S;
                Location = Settings.Default.L;
                _emeilAfterFinishing= Settings.Default.IsSendReports;
                UpdateControlsSizeAndLocation();

                _logger = Logger.GetInstance(listViewLogger);
                _logger.LogAdd("Application Start", Category.Information);
                _missingBarManager = new MissingBarManager(_logger);

                _missingBarManager.MissingBarStart += DataCollector_MissingBarStart;
                _missingBarManager.MissingBarEnd += DataCollector_MissingBarEnd;

                _missingBarManager.Finished += DataCollector_Finished;
                _missingBarManager.Progress += _missingBarManager_Progress;

                ui_home_textBoxX_db.Text = Settings.Default.MainDB;
                ui_home_textBoxX_db_bar.Text = Settings.Default.dbBar;
                ui_home_textBoxX_db_historical.Text = Settings.Default.dbHistorical;
                ui_home_textBoxX_uid.Text = Settings.Default.User;
                ui_home_textBoxX_pwd.Text = Settings.Default.Password;
                ui_home_textBoxX_host.Text = Settings.Default.Host;
                //nudEndBar.Value = Settings.Default.valFinish;
                checkBoxX1.Checked = Settings.Default.SavePass;
                //**
                metroShell1.SelectedTab = metroTabItem1;

                ResetColorMarks();
                // todo
                _cel = new CQGCEL();
                _cel.APIConfiguration.TimeZoneCode = eTimeZone.tzGMT;
                _cel.APIConfiguration.ReadyStatusCheck = eReadyStatusCheck.rscOff;
                _cel.APIConfiguration.CollectionsThrowException = false;
                _cel.APIConfiguration.LogSeverity = eLogSeverity.lsDebug;
                _cel.APIConfiguration.MessageProcessingTimeout = 30000;

                _cel.DataConnectionStatusChanged += CEL_DataConnectionStatusChanged;
                CEL_DataConnectionStatusChanged(eConnectionStatus.csConnectionDown);
                _cel.DataError += CEL_DataError;
                _cel.IncorrectSymbol += CEL_IncorrectSymbol;
                _cel.HistoricalSessionsResolved += CEL_HistoricalSessionsResolved;
                _cel.InstrumentSubscribed += CEL_InstrumentSubscribed;

                FormAddSymbolsGroups.RefreshSYmbolsGroups += RefreshGridSymbolsGroups;
                FormAutocollect.RefreshGroups += RefreshGridGroups;

                //todo

                _pingTimer = new Timer();
                _pingTimer.Tick += TimerTick;
                _pingTimer.Interval = 1000;
                _pingTimer.Enabled = true;
                _onlineServerSymbol = _startControl.uiServerOnlineFakeSymbol.Symbol;
                _offlineServerSymbol = _startControl.uiOfflineFakeSymbol.Symbol;

                //todo
                //groupList4.ItemStateChanged +=groupList4_ItemStateChanged;

                //todo subscribe

                FormSettings.EmeilAfterFinishing += EmailChange;
                FormSettings.IsAutocollect += AutocollectChange;
                FormSettings.BarEnd += barEndChange;

                CQGDataCollectorManager.ItemStateChanged += CQGDataCollectorManager_ItemStateChanged;
                CQGDataCollectorManager.CollectedSymbolCountChanged +=
                    CQGDataCollectorManager_CollectedSymbolCountChanged;
                CQGDataCollectorManager.RunnedStateChanged += CQGDataCollectorManager_RunnedStateChanged;
                CQGDataCollectorManager.StartTimeChanged += CQGDataCollectorManager_StartTimeChanged;
                CQGDataCollectorManager.CQGStatusChanged += CQGDataCollectorManager_CQGStatusChanged;

                CQGDataCollectorManager.UnsuccessfulSymbol += CQGDataCollectorManager_UnsuccessfulSymbol;
                CQGDataCollectorManager.TickInsertingStarted += CQGDataCollectorManager_TickInsertingStarted;
                CQGDataCollectorManager.ProgressBarChanged += CQGDataCollectorManager_ProgressBarChanched;

                CQGDataCollectorManager.SendReport += CQGDataCollectorManager_SendReport;
                //todo
                Thread.Sleep(1000); // Fixed bug with closeing while starting//do not remove this
                _cel.Startup();

                //Restarting after crashing
                if (Settings.Default.IsCrashed)
                {
                    LoginToServer(Settings.Default.scUser1, Settings.Default.scPassword, Settings.Default.scHostSlave,
                        _nowIsMaster);

                }
                dataSet.Relations.Add("1", dataSet.Tables["my_tbl"].Columns["ID"],
                                        dataSet.Tables["tbl_sym"].Columns["ID"], false);
                //superGridControl1.DefaultVisualStyles.RowStyles.SelectedMouseOver.Background.Color1 = Color.Red;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                _logger.LogAdd("Error in loading. " + ex.Message, Category.Error);
                Close();
            }
        }
Exemplo n.º 33
0
        private void Start_CEL()
        {
            try
             {
               // m_InitializingCEL = true;

            m_CEL = new CQGCEL();

            m_CEL.CELStarted += new _ICQGCELEvents_CELStartedEventHandler(CEL_CELStarted);
            m_CEL.DataConnectionStatusChanged += new _ICQGCELEvents_DataConnectionStatusChangedEventHandler(CEL_DataConnectionStatusChanged);
            //m_CEL.DataError += new _ICQGCELEvents_DataErrorEventHandler(CEL_DataError);

            m_CEL.IncorrectSymbol += new _ICQGCELEvents_IncorrectSymbolEventHandler(CEL_IncorrectSymbol);
            m_CEL.InstrumentSubscribed += new _ICQGCELEvents_InstrumentSubscribedEventHandler(CEL_InstrumentSubscribed);
            //m_CEL.InstrumentChanged += new _ICQGCELEvents_InstrumentChangedEventHandler(CEL_InstrumentChanged);
            //m_CEL.InstrumentDOMChanged += new _ICQGCELEvents_InstrumentDOMChangedEventHandler(CEL_InstrumentDOMChanged);

            m_CEL.APIConfiguration.CollectionsThrowException = false;
            m_CEL.APIConfiguration.ReadyStatusCheck = eReadyStatusCheck.rscOff;
            m_CEL.APIConfiguration.TimeZoneCode = eTimeZone.tzCentral;
            m_CEL.APIConfiguration.DefaultInstrumentSubscriptionLevel = eDataSubscriptionLevel.dsQuotesAndBBA;
            //m_CEL.APIConfiguration.SnapshotPeriod = Convert.ToInt32(txtSnapshotPeriod.Text);
            //m_CEL.APIConfiguration.DOMUpdatesMode = m_DOMUpdatesMode;
            //m_CEL.APIConfiguration.DOMUpdatesPeriod = Convert.ToInt32(txtDOMUpdatePeriod.Text);

            //m_CEL.Startup();
             }
             catch (Exception ex)
             {
             modErrorHandler.ShowError("ticknet", "Start_CEL", ex);
             }
        }