示例#1
0
        /// <summary>
        /// Steps the manager forward in time, accepting new state information and potentialy newly generated alphas
        /// </summary>
        /// <param name="frontierTimeUtc">The frontier time of the alpha analysis</param>
        /// <param name="securityValuesCollection">Snap shot of the securities at the frontier time</param>
        /// <param name="generatedAlphas">Any alpha generated by the algorithm at the frontier time</param>
        public void Step(DateTime frontierTimeUtc, ReadOnlySecurityValuesCollection securityValuesCollection, AlphaCollection generatedAlphas)
        {
            if (generatedAlphas != null && generatedAlphas.Alphas.Count > 0)
            {
                foreach (var alpha in generatedAlphas.Alphas)
                {
                    // save initial security values and deterine analysis period
                    var initialValues  = securityValuesCollection[alpha.Symbol];
                    var analysisPeriod = alpha.Period + TimeSpan.FromTicks((long)(_extraAnalysisPeriodRatio * alpha.Period.Ticks));

                    // set this as an open analysis context
                    var context = new AlphaAnalysisContext(alpha, initialValues, analysisPeriod);
                    _openAlphaContexts.Add(context);

                    // let everyone know we've received alpha
                    OnAlphaReceived(context);
                }
            }

            UpdateScores(securityValuesCollection);

            foreach (var extension in _extensions)
            {
                extension.Step(frontierTimeUtc);
            }
        }
示例#2
0
        /// <summary>
        /// Add alphas to the manager from the collection
        /// </summary>
        /// <param name="collection">The alpha collection emitted from <see cref="IAlgorithm.AlphasGenerated"/></param>
        public void AddAlphas(AlphaCollection collection)
        {
            foreach (var alpha in collection.Alphas)
            {
                // save initial security values and deterine analysis period
                var initialValues  = _securityValuesProvider.GetValues(alpha.Symbol);
                var analysisPeriod = alpha.Period + TimeSpan.FromTicks((long)(_extraAnalysisPeriodRatio * alpha.Period.Ticks));

                // set this as an open analysis context
                var context = new AlphaAnalysisContext(alpha, initialValues, analysisPeriod);
                _openAlphaContexts[alpha.Id] = context;

                // let everyone know we've received alpha
                OnAlphaReceived(context);
            }
        }
示例#3
0
 /// <summary>
 /// Event invocator for the <see cref="AlphaReceived"/> event
 /// </summary>
 /// <param name="context">The context whose alpha was generated this time step</param>
 protected virtual void OnAlphaReceived(AlphaAnalysisContext context)
 {
     AlphaReceived?.Invoke(this, context);
 }
示例#4
0
 /// <summary>
 /// Event invocator for the <see cref="AlphaAnalysisCompleted"/> event
 /// </summary>
 /// <param name="context">The context whose analysis period and scoring has finalized</param>
 protected virtual void OnAlphaScoringFinalzed(AlphaAnalysisContext context)
 {
     AlphaAnalysisCompleted?.Invoke(this, context);
 }
示例#5
0
 /// <summary>
 /// Event invocator for the <see cref="AlphaClosed"/> event
 /// </summary>
 /// <param name="context">The context whose alpha period has closed</param>
 protected virtual void OnAlphaPeriodCompleted(AlphaAnalysisContext context)
 {
     AlphaClosed?.Invoke(this, context);
 }
示例#6
0
 /// <summary>
 /// Event invocator for the <see cref="AlphaReceived"/> event
 /// </summary>
 /// <param name="context">The context whose alpha was generated this time step</param>
 protected virtual void OnAlphaReceived(AlphaAnalysisContext context)
 {
     _extensions.ForEach(e => e.OnAlphaGenerated(context));
 }
示例#7
0
 /// <summary>
 /// Event invocator for the <see cref="AlphaAnalysisCompleted"/> event
 /// </summary>
 /// <param name="context">The context whose analysis period and scoring has finalized</param>
 protected virtual void OnAlphaAnalysisCompleted(AlphaAnalysisContext context)
 {
     _extensions.ForEach(e => e.OnAlphaAnalysisCompleted(context));
 }