Ejemplo n.º 1
0
        /// <summary>
        /// Initializes this alpha handler to accept insights from the specified algorithm
        /// </summary>
        /// <param name="job">The algorithm job</param>
        /// <param name="algorithm">The algorithm instance</param>
        /// <param name="messagingHandler">Handler used for sending insights</param>
        /// <param name="api">Api instance</param>
        public virtual void Initialize(AlgorithmNodePacket job, IAlgorithm algorithm, IMessagingHandler messagingHandler, IApi api)
        {
            // initializing these properties just in case, doens't hurt to have them populated
            Job              = job;
            Algorithm        = algorithm;
            MessagingHandler = messagingHandler;

            _fitnessScore           = new FitnessScoreManager();
            _securityValuesProvider = new AlgorithmSecurityValuesProvider(algorithm);

            InsightManager = CreateInsightManager();

            // send scored insights to messaging handler
            InsightManager.AddExtension(CreateAlphaResultPacketSender());

            var statistics = new StatisticsInsightManagerExtension(algorithm);

            RuntimeStatistics = statistics.Statistics;
            InsightManager.AddExtension(statistics);
            _charting = new ChartingInsightManagerExtension(algorithm, statistics);
            InsightManager.AddExtension(_charting);

            // when insight is generated, take snapshot of securities and place in queue for insight manager to process on alpha thread
            algorithm.InsightsGenerated += (algo, collection) => InsightManager.Step(collection.DateTimeUtc, CreateSecurityValuesSnapshot(), collection);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes this alpha handler to accept insights from the specified algorithm
        /// </summary>
        /// <param name="job">The algorithm job</param>
        /// <param name="algorithm">The algorithm instance</param>
        /// <param name="messagingHandler">Handler used for sending insights</param>
        /// <param name="api">Api instance</param>
        public virtual void Initialize(AlgorithmNodePacket job, IAlgorithm algorithm, IMessagingHandler messagingHandler, IApi api)
        {
            // initializing these properties just in case, doens't hurt to have them populated
            Job                      = job;
            Algorithm                = algorithm;
            _messagingHandler        = messagingHandler;
            _isNotFrameworkAlgorithm = !algorithm.IsFrameworkAlgorithm;
            if (_isNotFrameworkAlgorithm)
            {
                return;
            }


            _securityValuesProvider = new AlgorithmSecurityValuesProvider(algorithm);

            InsightManager = CreateInsightManager();

            var statistics = new StatisticsInsightManagerExtension();

            RuntimeStatistics = statistics.Statistics;
            InsightManager.AddExtension(statistics);
            _charting = new ChartingInsightManagerExtension(algorithm, statistics);
            InsightManager.AddExtension(_charting);

            // when insight is generated, take snapshot of securities and place in queue for insight manager to process on alpha thread
            algorithm.InsightsGenerated += (algo, collection) => _insightQueue.Enqueue(new InsightQueueItem(collection.DateTimeUtc, CreateSecurityValuesSnapshot(), collection));
        }