public Indicator AnalyzeData(DataState state) { List <double> closePrices = _analyseRepo.LoadClosePriceBySymbol(state.Symbol, true).ToList(); RSIPredict value = new RSIPredict(); value.Symbol = state.Symbol; value.Date = state.Last.Value; value.PredictRsi30Price = RSICalculator.PredictPrice(RSICalculator.Period, 30, closePrices); value.PredictRsi50Price = RSICalculator.PredictPrice(RSICalculator.Period, 50, closePrices); value.PredictRsi70Price = RSICalculator.PredictPrice(RSICalculator.Period, 70, closePrices); return(value.ToIndicator()); }
public void CanSerializeToXml_RSIPredict() { var source = new RSIPredict { Symbol = "A", Date = DateTime.Today, PredictRsi30Price = 1.0, PredictRsi50Price = 2.0, PredictRsi70Price = 3.0, }; var i = source.ToIndicator(); var target = EntityHelper.DeserializeFromXml <RSIPredict>(i.Data); Assert.IsTrue(source.Symbol == target.Symbol); Assert.IsTrue(source.Date == target.Date); Assert.IsTrue(source.PredictRsi30Price == target.PredictRsi30Price); Assert.IsTrue(source.PredictRsi50Price == target.PredictRsi50Price); Assert.IsTrue(source.PredictRsi70Price == target.PredictRsi70Price); }
private PriceAlert ScanObject(Stock monitorObject) { //get current price double curPrice = InternetReader.ReadCurrentPrice(monitorObject.Symbol); if (curPrice == -1) { return(null); } //load current 30/70 price. RSIPredict predict = _monitorRepo.LoadRSIPredict(monitorObject.Symbol); if (predict == null) { return(null); } if (monitorObject.InPossession && curPrice >= predict.PredictRsi70Price) { return(new PriceAlert { Symbol = monitorObject.Symbol, Price = curPrice, TargetPrice = predict.PredictRsi70Price, Buy = false }); } if (!monitorObject.InPossession && curPrice <= predict.PredictRsi30Price) { return(new PriceAlert { Symbol = monitorObject.Symbol, Price = curPrice, TargetPrice = predict.PredictRsi30Price, Buy = true }); } return(null); }