public Sentiment?GetSentimentForWidgets(HistoricalData historicalData)
        {
            Tuple <int?, int?> sentimentValues = GetSyrahSentimentTermValues(historicalData);
            Sentiment?         sentiment       = SyrahSentiment.MakeInterpretationInTermsOfSentiment(sentimentValues);

            return(sentiment);
        }
        public Tuple <int?, int?> GetSyrahSentimentTermValues(HistoricalData historicalData)
        {
            if (historicalData == null)
            {
                return(Tuple.Create((int?)null, (int?)null));
            }

            const int last = 1;

            SyrahSentiment    syrahLongTerm  = new SyrahSentiment(SyrahSentiment.TermValue.LongTerm);
            SyrahSentiment    syrahShortTerm = new SyrahSentiment(SyrahSentiment.TermValue.ShortTerm);
            List <IIndicator> indicators     = new List <IIndicator>
            {
                syrahShortTerm,
                syrahLongTerm
            };

            List <Signal> signals = GetSignalsFromDbAndViaCalculation(historicalData, indicators, last);

            int?shortTermValue = GetTermValue(signals, syrahShortTerm);
            int?longTermValue  = GetTermValue(signals, syrahLongTerm);

            Tuple <int?, int?> result = new Tuple <int?, int?>(shortTermValue, longTermValue);

            return(result);
        }
        private static int?GetTermValue(IEnumerable <Signal> signals, SyrahSentiment syrahSentiment)
        {
            Signal longTermSignal = signals.LatestForIndicator(syrahSentiment);
            int?   termValue      = longTermSignal != null
                                ? (int?)longTermSignal.Value
                                : null;

            return(termValue);
        }
        public Tuple <SignalInterpretation, SignalInterpretation> MakeInterpretationOfSyrahSentiments(Tuple <int?, int?> sentiments)
        {
            SignalInterpretation longTermInterpretation  = null;
            SignalInterpretation shortTermInterpretation = null;

            SyrahSentiment syrahLongTerm  = new SyrahSentiment(SyrahSentiment.TermValue.LongTerm);
            SyrahSentiment syrahShortTerm = new SyrahSentiment(SyrahSentiment.TermValue.ShortTerm);

            if (sentiments.Item2.HasValue)
            {
                longTermInterpretation = SyrahSentiment.MakeInterpretationBasedOnValue(syrahLongTerm, sentiments.Item2.Value);
            }

            if (sentiments.Item1.HasValue)
            {
                shortTermInterpretation = SyrahSentiment.MakeInterpretationBasedOnValue(syrahShortTerm, sentiments.Item1.Value);
            }

            return(Tuple.Create(shortTermInterpretation, longTermInterpretation));
        }