Example #1
0
        /// <summary>
        /// Entry point for console result handler thread.
        /// </summary>
        public void Run()
        {
            try
            {
                while (!_exitTriggered || Messages.Count > 0)
                {
                    Thread.Sleep(100);

                    var now = DateTime.UtcNow;
                    if (now > _updateTime)
                    {
                        _updateTime = now.AddSeconds(5);
                        _algorithmNode.LogAlgorithmStatus(_lastSampledTimed);
                    }
                }

                // Write Equity and EquityPerformance files in charts directory
                foreach (var fileName in _equityResults.Keys)
                {
                    File.WriteAllLines(fileName, _equityResults[fileName]);
                }
            }
            catch (Exception err)
            {
                // unexpected error, we need to close down shop
                Log.Error(err);
                // quit the algorithm due to error
                _algorithm.RunTimeError = err;
            }

            Log.Trace("ConsoleResultHandler: Ending Thread...");
            _isActive = false;
        }
        /********************************************************
         * PUBLIC METHODS
         *********************************************************/
        /// <summary>
        /// Entry point for console result handler thread.
        /// </summary>
        public void Run()
        {
            while (!_exitTriggered || Messages.Count > 0)
            {
                Thread.Sleep(100);

                if (DateTime.Now > _updateTime)
                {
                    _updateTime = DateTime.Now.AddSeconds(5);
                    _algorithmNode.LogAlgorithmStatus(_lastSampledTimed);
                }
            }

            Log.Trace("ConsoleResultHandler: Ending Thread...");
            _isActive = false;
        }
        /********************************************************
         * PUBLIC METHODS
         *********************************************************/
        /// <summary>
        /// Entry point for console result handler thread.
        /// </summary>
        public void Run()
        {
            while (!_exitTriggered || Messages.Count > 0)
            {
                while (Messages.Count > 0)
                {
                    Packet packet;
                    if (!Messages.TryDequeue(out packet))
                    {
                        continue;
                    }

                    switch (packet.Type)
                    {
                    case PacketType.Log:
                        var log = packet as LogPacket;
                        Log.Trace("Log Message >> " + log.Message);
                        break;

                    case PacketType.Debug:
                        var debug = packet as DebugPacket;
                        Log.Trace("Debug Message >> " + debug.Message);
                        break;

                    case PacketType.HandledError:
                        var error = packet as HandledErrorPacket;
                        Log.Error("Error Message >> " + error.Message);
                        break;
                    }
                }
                Thread.Sleep(100);

                if (DateTime.Now > _updateTime)
                {
                    _updateTime = DateTime.Now.AddSeconds(5);
                    _algorithmNode.LogAlgorithmStatus(_lastSampledTimed);
                }
            }

            Log.Trace("ConsoleResultHandler: Ending Thread...");
            _isActive = false;
        }
Example #4
0
        /// <summary>
        /// Entry point for console result handler thread.
        /// </summary>
        public void Run()
        {
            while (!_exitTriggered || Messages.Count > 0)
            {
                Thread.Sleep(100);

                var now = DateTime.UtcNow;
                if (now > _updateTime)
                {
                    _updateTime = now.AddSeconds(5);
                    _algorithmNode.LogAlgorithmStatus(_lastSampledTimed);
                }
            }

            // Write Equity and EquityPerformance files in charts directory
            foreach (var fileName in _equityResults.Keys)
            {
                File.WriteAllLines(fileName, _equityResults[fileName]);
            }

            Log.Trace("ConsoleResultHandler: Ending Thread...");
            _isActive = false;
        }