public object GetSyrahSentiments(string stockCode) { List <HistoricalQuote> historicalQuotes2YearsResponse = _marketDataService.GetHistoricalQuotes(stockCode, "2y"); List <Signal> syrahShortTermSignals; List <Signal> syrahLongTermSignals; int?sentimentShortTermValue = null; int?sentimentLongTermValue = null; int?technicalRank = null; SupportAndResistance supportAndResistance = null; string sentence = string.Empty; Tuple <List <Signal>, List <Signal> > signals = _signalHelpers.GetSentiments(historicalQuotes2YearsResponse); syrahShortTermSignals = signals.Item1; syrahLongTermSignals = signals.Item2; Tuple <int?, int?> sentimentTermValues = _signalHelpers.GetSentimentTermValues(syrahShortTermSignals, syrahLongTermSignals); sentimentShortTermValue = sentimentTermValues.Item1; sentimentLongTermValue = sentimentTermValues.Item2; DateTime yearAgo = DateTime.UtcNow.Date.AddYears(-1); List <HistoricalQuote> historicalQuotes1Year = historicalQuotes2YearsResponse.Where(h => h.TradeDate >= yearAgo).ToList(); HistoricalData historicalData1Year = null; if (!historicalQuotes1Year.IsNullOrEmpty()) { historicalData1Year = new HistoricalData(historicalQuotes1Year); } StockQuoteInfo quote = _marketDataService.GetStockQuote(stockCode); technicalRank = _signalHelpers.GetTechnicalRank(historicalData1Year); var last = 0d; if (quote.LastPrice != null) { last = (double)quote.LastPrice.Value; } SupportAndResistanceMath srCalc = new SupportAndResistanceMath(historicalData1Year); supportAndResistance = srCalc.GetSupportAndResistance(); return(new { quote = quote, technicalRank = technicalRank, supportAndResistance = supportAndResistance, sentimentShortTermValue = sentimentShortTermValue, sentimentLongTermValue = sentimentLongTermValue, syrahShortTermSignals = syrahShortTermSignals, syrahLongTermSignals = syrahLongTermSignals, historicalQuotes2Years = historicalQuotes2YearsResponse }); }
//todo: not sure if we need entity response here public async Task <EntityResponse <SupportAndResistance> > GetSupportAndResistance(string symbol, string timeFrame = null) { if (timeFrame == null) { timeFrame = AppConfigManager.SupportAndResistanceDefaultTimeFrame; } StockQuoteInfo expandedQuote = MarketDataService.GetStockQuote(symbol); List <HistoricalQuote> historicalQuotes = MarketDataService.GetHistoricalQuotes(symbol, timeFrame); SupportAndResistance supportAndResistance = new SupportAndResistanceMath(new HistoricalData(historicalQuotes)).GetSupportAndResistance(); return(supportAndResistance); }
public SupportAndResistance GetSupportAndResistance(HistoricalData data, double lastPrice) { SupportAndResistance supportAndResistance = new SupportAndResistanceMath(data).GetSupportAndResistance(lastPrice); return(supportAndResistance); }