Exemplo n.º 1
0
        public void SerializesAlphaStreamInsightWithScore()
        {
            var jObject = JObject.Parse(jsonWithScore);
            var insight = AlphaStreamInsight.FromSerializedAlphaStreamInsight(new SerializedAlphaStreamInsight
            {
                Id                  = jObject["id"].Value <string>(),
                SourceModel         = jObject["source-model"].Value <string>(),
                GroupId             = jObject["group-id"]?.Value <string>(),
                CreatedTime         = jObject["created-time"].Value <double>(),
                CloseTime           = jObject["close-time"].Value <double>(),
                Symbol              = jObject["symbol"].Value <string>(),
                Ticker              = jObject["ticker"].Value <string>(),
                Type                = (InsightType)Enum.Parse(typeof(InsightType), jObject["type"].Value <string>(), true),
                ReferenceValue      = jObject["reference"].Value <decimal>(),
                Direction           = (InsightDirection)Enum.Parse(typeof(InsightDirection), jObject["direction"].Value <string>(), true),
                Period              = jObject["period"].Value <double>(),
                Magnitude           = jObject["magnitude"].Value <double>(),
                ScoreIsFinal        = jObject["score-final"].Value <bool>(),
                ScoreMagnitude      = jObject["score-magnitude"].Value <double>(),
                ScoreDirection      = jObject["score-direction"].Value <double>(),
                EstimatedValue      = jObject["estimated-value"].Value <decimal>(),
                ReferenceValueFinal = jObject["reference-final"].Value <decimal>()
            });
            var result = JsonConvert.SerializeObject(insight, Formatting.None);

            Assert.AreEqual(jsonWithScore, result);
        }
Exemplo n.º 2
0
        public void SerializesOldAlphaStreamInsightWithMissingCreatedTime()
        {
            var serializedInsight = JsonConvert.DeserializeObject <SerializedAlphaStreamInsight>(jsonWithMissingCreatedTime);
            var insight           = AlphaStreamInsight.FromSerializedAlphaStreamInsight(serializedInsight);
            var result            = JsonConvert.SerializeObject(insight, Formatting.None);

            Assert.AreEqual(serializedInsight.CreatedTime, serializedInsight.GeneratedTime);
            Assert.AreEqual(jsonWithExpectedOutputFromMissingCreatedTimeValue, result);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InsightReceivedEventArgs"/> class
 /// </summary>
 /// <param name="alphaId">The alpha id tht produced the insight</param>
 /// <param name="insight">The insight</param>
 public InsightReceivedEventArgs(string alphaId, AlphaStreamInsight insight)
 {
     AlphaId = alphaId;
     Insight = insight;
 }
Exemplo n.º 4
0
 public SerializedAlphaStreamInsight(AlphaStreamInsight insight) : base(insight)
 {
     Source = insight.Source;
 }