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()); }
public static string ToCsv(this Eod value) { return(string.Format("{0},{1},{2:0.00},{3:0.00},{4:0.00},{5:0.00},{6}", value.Symbol, value.Date.ToString("yyyy-MM-dd"), value.Open, value.High, value.Low, value.Close, value.Volume)); }