Example #1
0
        private void SummarizeData(Stock stock)
        {
            Eod lastEod = _summaryRepository.GetLastEod(stock.Symbol);

            if (lastEod == null)
            {
                return;
            }
            DailySummary lastSummary = _summaryRepository.GetLastSummary(stock.Symbol);

            if (lastSummary != null && lastEod.Date <= lastSummary.Date)
            {
                return;
            }

            //when extend, change code to DailyV002, DailyV003 and so on.
            var daily = new DailyV001();

            daily.Symbol = stock.Symbol;
            daily.Date   = lastEod.Date;
            var adx = _summaryRepository.GetADX(daily.Symbol, daily.Date);

            if (adx == null)
            {
                return;
            }
            daily.ADX14 = adx.ADX14;

            var sma = _summaryRepository.GetSMA(daily.Symbol, daily.Date);

            if (sma == null)
            {
                return;
            }
            daily.SMAShortTerm = sma.SMA5;
            daily.SMAMidTerm   = sma.SMA10;
            daily.SMALongTerm  = sma.SMA20;

            var rsi = _summaryRepository.GetRSI(daily.Symbol, daily.Date);

            if (rsi == null)
            {
                return;
            }
            daily.RSI14 = rsi.LastRSI;

            var rsiPredict = _summaryRepository.GetRSIPredict(daily.Symbol, daily.Date);

            if (rsiPredict == null)
            {
                return;
            }
            daily.R30Price = rsiPredict.PredictRsi30Price;
            daily.R70Price = rsiPredict.PredictRsi70Price;

            //todo
            daily.VolumePercentAgainstAvg = 0;

            _summaryRepository.SaveDailySummary(daily.ToDailySummary());
        }