public EntityResponse <List <OptionQuotation> > GetOptionQuotes(List <string> optionNumbers) { EntityResponse <List <OptionQuotation> > results = GetOptionQuotesByOptionNumbers(optionNumbers); if (!results.IsSuccess) { return(results); } foreach (OptionQuotation quote in results.Entity) { EntityResponse <OptionBasicInformation> basic = GetOptionInformation(quote.OptionNumber); if (basic.IsSuccess) { quote.SecurityCode = basic.Entity.OptionUnderlyingCode; decimal?stockPrice; double daysToMaturity = _marketWorkTimeService.GetNumberOfDaysLeftUntilExpiry(basic.Entity.ExpireDate).TotalNumberOfDaysUntilExpiry; if (!MemoryCache.IsStockQuoteInfoCacheExpired(quote.SecurityCode)) { stockPrice = MemoryCache.StockQuoteInfoCache[quote.SecurityCode].StockQuoteInfos.LastPrice; } else { var stockQuoteInfo = GetStockQuote(basic.Entity.OptionUnderlyingCode).Entity; stockPrice = stockQuoteInfo.LastPrice; MemoryCache.AddOrUpdateStockQuoteInfoCache(quote.SecurityCode, stockQuoteInfo); } //decimal? stockPrice = GetStockQuote(basic.Entity.OptionUnderlyingCode).Entity.LastPrice; double spotPrice = 0; if (stockPrice != null) { spotPrice = (double)stockPrice; } quote.Greeks = MarketMath.GetGreeks(daysToMaturity, (double)basic.Entity.StrikePrice, _riskFreeRateProvider.GetRiskFreeRate(), spotPrice, quote.Ask, quote.Bid, quote.LatestTradedPrice, basic.Entity.OptionType == OptionType.Call ? LegType.Call : LegType.Put); } } return(results); }