public async Task <StockScore> GetBidAndAskScore(ViewStock stock) { var score = new StockScore(); var perfectScore = _settingRepository.GetSettingValue <decimal>(SettingNames.Score_AskAndBid); var askAndBids = await _investagramsApiService.GetAskAndBidByStockId(stock.StockInfo.StockId); var buyers = askAndBids.Buyers.OrderByDescending(x => x.Volume).ToList(); var sellers = askAndBids.Sellers.OrderByDescending(x => x.Volume).ToList(); //Nobody wants to sell because there is a breakout. //There must be some good news with this stock or this is being hyped if (buyers.Count > 0 && sellers.Count == 0) { score.AddReason(perfectScore, "No one is selling the stock", isSignificant: true); } else if (buyers.Count == 0 && sellers.Count > 0) { //ideally this shouldn't happen score.AddReason(perfectScore, "No one is buying the stock", StockTrend.Bearish, true); } else { var highestVolumeOfBuyers = buyers.Any()? buyers.First() : new Buyer(); var highestVolumeOfSellers = sellers.Any()? sellers.First() : new Seller(); //My Own metrics. //Inverse law of supply and demand //if sellers is greater than the buyers then it must be going up. (must be backed up with volume) if (highestVolumeOfSellers.Volume > highestVolumeOfBuyers.Volume) { var percentage = (highestVolumeOfSellers.Volume - highestVolumeOfBuyers.Volume) / highestVolumeOfSellers.Volume; var reason = $"Sellers are {percentage * 100}% higher than the buyers"; //if sellers are 15-30% higher than buyers give half score if (percentage >= 0.15m && percentage <= 0.3m) { score.AddReason(perfectScore / 2, reason); } //if sellers are 50-30% higher than the buyers give the perfect score else if (percentage >= 0.3m) { score.AddReason(perfectScore, reason); } } } return(score); }