コード例 #1
0
 /// <summary>
 /// ...
 /// </summary>
 public HistoryPort(IQFeedDataQueueUniverseProvider symbolUniverse)
     : base(80)
 {
     _symbolUniverse         = symbolUniverse;
     _requestDataByRequestId = new ConcurrentDictionary <string, HistoryRequest>();
     _currentRequest         = new ConcurrentDictionary <string, List <BaseData> >();
 }
コード例 #2
0
        public Level1Port(BlockingCollection <BaseData> dataQueue, IQFeedDataQueueUniverseProvider symbolUniverse)
            : base(80)
        {
            start          = DateTime.Now;
            _prices        = new ConcurrentDictionary <string, double>();
            _openInterests = new ConcurrentDictionary <string, int>();

            _dataQueue                     = dataQueue;
            _symbolUniverse                = symbolUniverse;
            Level1SummaryUpdateEvent      += OnLevel1SummaryUpdateEvent;
            Level1TimerEvent              += OnLevel1TimerEvent;
            Level1ServerDisconnectedEvent += OnLevel1ServerDisconnected;
            Level1ServerReconnectFailed   += OnLevel1ServerReconnectFailed;
            Level1UnknownEvent            += OnLevel1UnknownEvent;
            Level1FundamentalEvent        += OnLevel1FundamentalEvent;

            _timer           = new Timer(1000);
            _timer.Enabled   = false;
            _timer.AutoReset = true;
            _timer.Elapsed  += (sender, args) =>
            {
                var ticksPerSecond = count / (DateTime.Now - start).TotalSeconds;
                if (ticksPerSecond > 1000 || _dataQueue.Count > 31)
                {
                    Log.Trace($"IQFeed.OnSecond(): Ticks/sec: {ticksPerSecond.ToStringInvariant("0000.00")} " +
                              $"Engine.Ticks.Count: {_dataQueue.Count} CPU%: {OS.CpuUsage.ToStringInvariant("0.0") + "%"}"
                              );
                }

                count = 0;
                start = DateTime.Now;
            };

            _timer.Enabled = true;
        }
コード例 #3
0
        /// <summary>
        /// Connect to the IQ Feed using supplied username and password information.
        /// </summary>
        private void Connect()
        {
            try
            {
                // Launch the IQ Feed Application:
                Log.Trace("IQFeed.Connect(): Launching client...");

                if (OS.IsWindows)
                {
                    // IQConnect is only supported on Windows
                    var connector = new IQConnect(Config.Get("iqfeed-productName"), "1.0");
                    connector.Launch();
                }

                // Initialise one admin port
                Log.Trace("IQFeed.Connect(): Connecting to admin...");
                _adminPort = new AdminPort();
                _adminPort.Connect();
                _adminPort.SetAutoconnect();
                _adminPort.SetClientStats(false);
                _adminPort.SetClientName("Admin");

                _adminPort.DisconnectedEvent += AdminPortOnDisconnectedEvent;
                _adminPort.ConnectedEvent    += AdminPortOnConnectedEvent;

                _symbolUniverse = new IQFeedDataQueueUniverseProvider();

                Log.Trace("IQFeed.Connect(): Connecting to L1 data...");
                _level1Port = new Level1Port(_aggregator, _symbolUniverse);
                _level1Port.Connect();
                _level1Port.SetClientName("Level1");

                Log.Trace("IQFeed.Connect(): Connecting to Historical data...");
                _historyPort = new HistoryPort(_symbolUniverse);
                _historyPort.Connect();
                _historyPort.SetClientName("History");

                _isConnected = true;
            }
            catch (Exception err)
            {
                Log.Error("IQFeed.Connect(): Error Connecting to IQFeed: " + err.Message);
                _isConnected = false;
            }
        }
コード例 #4
0
 /// <summary>
 /// ...
 /// </summary>
 public HistoryPort(IQFeedDataQueueUniverseProvider symbolUniverse, int maxDataPoints, int dataPointsPerSend)
     : this(symbolUniverse)
 {
     MaxDataPoints     = maxDataPoints;
     DataPointsPerSend = dataPointsPerSend;
 }