//extremely slow, does not work public static bool AnalyzeStock(Stock stk) { try { AnalyticInfo indics = stk.indicators; List <string> allDates = stk.MarketDatas.Keys.OrderBy(o => o).ToList(); for (int i = 0; i < allDates.Count; i++) { try { decimal SMAShort, SMALong, EMAShort, EMALong, accDist, RSI, AroonOsc, Macd, Roc; //produce indicators for that date try { SMAShort = SimpleMovingAvg(stk, indics.SMAPeriodShort, allDates[i]); } catch (Exception) { SMAShort = 0; } try { SMALong = SimpleMovingAvg(stk, indics.SMAPeriodLong, allDates[i]); } catch (Exception) { SMALong = 0; } try { EMAShort = ExponentialMovingAvg(stk, indics.EMAPeriodShort, allDates[i]); } catch (Exception) { EMAShort = 0; } try { EMALong = ExponentialMovingAvg(stk, indics.EMAPeriodLong, allDates[i]); } catch (Exception) { EMALong = 0; } try { accDist = AccumulationDistribution(stk, allDates[i]); } catch (Exception) { accDist = 0; } try { RSI = RelativeStrenghtIndex(stk, indics.RSIPeriod, allDates[i]); } catch (Exception) { RSI = 0; } try { AroonOsc = AroonOscillator(stk, indics.AroonOscPeriod, allDates[i]); } catch (Exception) { AroonOsc = 0; } try { Macd = MACD(stk, indics.MACDPeriodShort, indics.MACDPeriodLong, indics.MACDPeriodSignal, allDates[i]); } catch (Exception) { Macd = 0; } try { Roc = RateOfChange(stk, indics.ROCPeriod, allDates[i]); } catch (Exception) { Roc = 0; } //add indicators to the Analytic info of the stock object indics.SMAShort.Add(allDates[i], SMAShort); indics.SMALong.Add(allDates[i], SMALong); indics.EMAShort.Add(allDates[i], EMAShort); indics.EMALong.Add(allDates[i], EMALong); indics.AccDist.Add(allDates[i], accDist); indics.RSI.Add(allDates[i], RSI); indics.AroonOsc.Add(allDates[i], AroonOsc); indics.MACD.Add(allDates[i], Macd); indics.ROC.Add(allDates[i], Roc); } catch (Exception) { } } } catch { return(false); } return(true); }
public Stock() { MarketDatas = new Dictionary <string, MarketData>(); indicators = new AnalyticInfo(this); }