private void OnInsightsGeneratedVerifier(IAlgorithm algorithm, GeneratedInsightsCollection insightsCollection) { if (insightsCollection.Insights.Count(insight => insight.Symbol == _fb) != 1 || insightsCollection.Insights.Count(insight => insight.Symbol == _spy) != 1 || insightsCollection.Insights.Count(insight => insight.Symbol == _ibm) != 1) { throw new Exception("Unexpected insights were emitted"); } }
public void CheckCloneRespectsDerivedTypes() { var insights = new List <DerivedInsight> { new DerivedInsight(Symbol.Empty, TimeSpan.Zero, InsightType.Price, InsightDirection.Flat), new DerivedInsight(Symbol.Empty, TimeSpan.Zero, InsightType.Price, InsightDirection.Flat), new DerivedInsight(Symbol.Empty, TimeSpan.Zero, InsightType.Price, InsightDirection.Flat), new DerivedInsight(Symbol.Empty, TimeSpan.Zero, InsightType.Price, InsightDirection.Flat), }; var generatedInsightsCollection = new GeneratedInsightsCollection(DateTime.UtcNow, insights, clone: true); Assert.True(generatedInsightsCollection.Insights.TrueForAll(x => x.GetType() == typeof(DerivedInsight))); }
private void OnInsightsGeneratedVerifier(IAlgorithm algorithm, GeneratedInsightsCollection insightsCollection) { _emitted = true; var insight = insightsCollection.Insights.First(); if (Math.Abs(insight.Confidence.Value - _expectedConfidence) > 0.02) { throw new Exception($"Unexpected insight Confidence: {insight.Confidence.Value}." + $" Expected: {_expectedConfidence}. Step {_step}"); } if (insight.Direction != _expectedInsightDirection) { throw new Exception($"Unexpected insight Direction: {insight.Direction}." + $" Expected: {_expectedInsightDirection}. Step {_step}"); } _insights.Add(insight); }
/// <summary> /// Steps the manager forward in time, accepting new state information and potentialy newly generated insights /// </summary> /// <param name="frontierTimeUtc">The frontier time of the insight analysis</param> /// <param name="securityValuesCollection">Snap shot of the securities at the frontier time</param> /// <param name="generatedInsights">Any insight generated by the algorithm at the frontier time</param> public void Step(DateTime frontierTimeUtc, ReadOnlySecurityValuesCollection securityValuesCollection, GeneratedInsightsCollection generatedInsights) { lock (_lock) { if (generatedInsights != null && generatedInsights.Insights.Count > 0) { foreach (var insight in generatedInsights.Insights) { // save initial security values and deterine analysis period var initialValues = securityValuesCollection[insight.Symbol]; var analysisPeriod = insight.Period + TimeSpan.FromTicks((long)(_extraAnalysisPeriodRatio * insight.Period.Ticks)); // set this as an open analysis context var context = new InsightAnalysisContext(insight, initialValues, analysisPeriod); _openInsightContexts.Add(context); // let everyone know we've received an insight _extensions.ForEach(e => e.OnInsightGenerated(context)); } } UpdateScores(securityValuesCollection); foreach (var extension in _extensions) { extension.Step(frontierTimeUtc); } } }
private void OnInsightsGenerated(IAlgorithm algorithm, GeneratedInsightsCollection eventdata) { Log($"{Time}: {string.Join(", ", eventdata)}"); }