コード例 #1
0
        private GreenField.DAL.GF_SECURITY_BASEVIEW GetSecurityDataForSelectedSecurity(EntitySelectionData entitySelectionData)
        {
            DimensionEntities entity = DimensionEntity;

            /*bool isServiceUp;
             * isServiceUp = CheckServiceAvailability.ServiceAvailability();
             *
             * if (!isServiceUp)
             *  throw new Exception("Services are not available");*/
            //Retrieving data from security view
            GreenField.DAL.GF_SECURITY_BASEVIEW data = entity.GF_SECURITY_BASEVIEW
                                                       .Where(record => record.TICKER == entitySelectionData.ShortName &&
                                                              record.ISSUE_NAME == entitySelectionData.LongName &&
                                                              record.ASEC_SEC_SHORT_NAME == entitySelectionData.InstrumentID &&
                                                              record.SECURITY_TYPE == entitySelectionData.SecurityType)
                                                       .FirstOrDefault();

            if (data == null)
            {
                return(null);
            }
            else
            {
                return(data);
            }
        }
コード例 #2
0
        public List <FreeCashFlowsData> RetrieveFreeCashFlowsData(EntitySelectionData entitySelectionData)
        {
            try
            {
                List <FreeCashFlowsData>       result            = new List <FreeCashFlowsData>();
                List <GetFreeCashFlows_Result> resultDB          = new List <GetFreeCashFlows_Result>();
                ExternalResearchEntities       dcf_FreeCashFlows = new ExternalResearchEntities();

                if (entitySelectionData == null)
                {
                    return(null);
                }

                DimensionEntities entity = DimensionEntity;

                /*  bool isServiceUp;
                 * isServiceUp = CheckServiceAvailability.ServiceAvailability();
                 *
                 * if (!isServiceUp)
                 *    throw new Exception("Services are not available");*/

                //Retrieving data from security view
                GreenField.DAL.GF_SECURITY_BASEVIEW data = entity.GF_SECURITY_BASEVIEW
                                                           .Where(record => record.TICKER == entitySelectionData.ShortName &&
                                                                  record.ISSUE_NAME == entitySelectionData.LongName &&
                                                                  record.ASEC_SEC_SHORT_NAME == entitySelectionData.InstrumentID &&
                                                                  record.SECURITY_TYPE == entitySelectionData.SecurityType)
                                                           .FirstOrDefault();

                if (data == null)
                {
                    return(null);
                }
                ////Retrieving data from Period Financials table
                resultDB = dcf_FreeCashFlows.ExecuteStoreQuery <GetFreeCashFlows_Result>("exec GetFreeCashFlows @IssuerID={0}", data.ISSUER_ID).ToList();

                foreach (GetFreeCashFlows_Result record in resultDB)
                {
                    FreeCashFlowsData item = new FreeCashFlowsData();
                    item.FieldName  = record.FIELD_NAME;
                    item.PeriodYear = record.PERIOD_YEAR;
                    item.Amount     = record.AMOUNT;
                    result.Add(item);
                }
                return(result);
            }
            catch (Exception ex)
            {
                ExceptionTrace.LogException(ex);
                string networkFaultMessage = ServiceFaultResourceManager.GetString("NetworkFault").ToString();
                throw new FaultException <ServiceFault>(new ServiceFault(networkFaultMessage), new FaultReason(ex.Message));
            }
        }
        /// <summary>
        /// Gets return value for a preference between two specific dates
        /// </summary>
        /// <param name="entity">dimension service instance</param>
        /// <param name="preference">MarketSnapshotPreference object</param>
        /// <param name="fromDate">start date</param>
        /// <param name="toDate">end date</param>
        /// <returns>security return value</returns>
        private static Decimal?GetReturn(DimensionEntities entity, MarketSnapshotPreference preference, DateTime fromDate, DateTime toDate)
        {
            try
            {
                List <GreenField.DAL.GF_PRICING_BASEVIEW> datedRecords = entity.GF_PRICING_BASEVIEW
                                                                         .Where(record => record.INSTRUMENT_ID == preference.EntityId &&
                                                                                record.TYPE == preference.EntityType &&
                                                                                record.ISSUE_NAME == preference.EntityName &&
                                                                                record.FROMDATE >= fromDate &&
                                                                                record.FROMDATE <= toDate)
                                                                         .ToList();

                Decimal result = -1;
                foreach (GreenField.DAL.GF_PRICING_BASEVIEW record in datedRecords)
                {
                    Decimal?returnValue = preference.EntityReturnType == "Price"
                    ? (record.DAILY_PRICE_RETURN != null ? record.DAILY_PRICE_RETURN : 0)
                    : (record.DAILY_GROSS_RETURN != null ? record.DAILY_GROSS_RETURN : 0);

                    if (result == -1)
                    {
                        result = (1 + ((returnValue == null ? 0 : Convert.ToDecimal(returnValue)) / 100));
                    }
                    else
                    {
                        result = result * (1 + ((returnValue == null ? 0 : Convert.ToDecimal(returnValue)) / 100));
                    }
                }

                if (result == -1)
                {
                    return(null);
                }

                return((result - 1) * 100);
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #4
0
 public List <MacroDatabaseKeyAnnualReportData> RetrieveMacroDatabaseKeyAnnualReportDataEMSummary(String countryNameVal, List <String> countryValues)
 {
     try
     {
         /*bool isServiceUp;
          * isServiceUp = CheckServiceAvailability.ServiceAvailability();
          * if (!isServiceUp)
          * {
          *  throw new Exception();
          * }*/
         List <MacroDatabaseKeyAnnualReportData> result      = new List <MacroDatabaseKeyAnnualReportData>();
         List <MacroDatabaseKeyAnnualReportData> finalResult = new List <MacroDatabaseKeyAnnualReportData>();
         DimensionEntities entity   = DimensionEntity;
         ResearchEntities  research = new ResearchEntities();
         foreach (String c in countryValues)
         {
             result = research.ExecuteStoreQuery <MacroDatabaseKeyAnnualReportData>
                          ("exec RetrieveEMSummaryDataReportPerCountry @country={0}", c).ToList();
             if (result != null && result.Count != 0)
             {
                 foreach (MacroDatabaseKeyAnnualReportData r in result)
                 {
                     finalResult.Add(r);
                 }
             }
         }
         if (finalResult.Count == 0 || finalResult == null)
         {
             return(finalResult);
         }
         return(finalResult);
     }
     catch (Exception ex)
     {
         ExceptionTrace.LogException(ex);
         string networkFaultMessage = ServiceFaultResourceManager.GetString("NetworkFault").ToString();
         throw new FaultException <ServiceFault>(new ServiceFault(networkFaultMessage), new FaultReason(ex.Message));
     }
 }
コード例 #5
0
 public List <MacroDatabaseKeyAnnualReportData> RetrieveMacroDatabaseKeyAnnualReportData(String countryNameVal)
 {
     try
     {
         /*   bool isServiceUp;
          * isServiceUp = CheckServiceAvailability.ServiceAvailability();
          * if (!isServiceUp)
          * {
          *     throw new Exception();
          * }*/
         List <MacroDatabaseKeyAnnualReportData> result = new List <MacroDatabaseKeyAnnualReportData>();
         DimensionEntities entity   = DimensionEntity;
         ResearchEntities  research = new ResearchEntities();
         result = research.ExecuteStoreQuery <MacroDatabaseKeyAnnualReportData>
                      ("exec RetrieveCTYSUMMARYDataReportPerCountry @country={0}", countryNameVal).ToList();
         return(result);
     }
     catch (Exception ex)
     {
         ExceptionTrace.LogException(ex);
         string networkFaultMessage = ServiceFaultResourceManager.GetString("NetworkFault").ToString();
         throw new FaultException <ServiceFault>(new ServiceFault(networkFaultMessage), new FaultReason(ex.Message));
     }
 }
        /// <summary>
        /// Gets performance data for a specific snapshot preference where entity type is benchmark
        /// </summary>
        /// <param name="entity">Dimension service entity instance</param>
        /// <param name="preference">MarketSnapshotPreference object</param>
        /// <returns>MarketSnapshotPerformanceData</returns>
        public static MarketSnapshotPerformanceData GetBenchmarkPerformanceData(DimensionEntities entity, MarketSnapshotPreference preference)
        {
            MarketSnapshotPerformanceData result = new MarketSnapshotPerformanceData();

            try
            {
                List <GreenField.DAL.GF_PERF_DAILY_ATTRIBUTION> benchmarkRecords = entity.GF_PERF_DAILY_ATTRIBUTION
                                                                                   .Where(record => record.NODE_NAME == (preference.EntityNodeType == "Country" ? "Country" : "GICS Level 1") &&
                                                                                          record.AGG_LVL_1 == (preference.EntityNodeType == null ? "Undefined" : preference.EntityNodeValueCode) &&
                                                                                          record.AGG_LVL_1_LONG_NAME == (preference.EntityNodeType == null ? "-" : preference.EntityNodeValueName) &&
                                                                                          record.BM == preference.EntityId.ToUpper() &&
                                                                                          record.BMNAME == preference.EntityName &&
                                                                                          record.TO_DATE != null &&
                                                                                          record.POR_INCEPTION_DATE != null)
                                                                                   .OrderByDescending(record => record.TO_DATE).ToList();

                GreenField.DAL.GF_PERF_DAILY_ATTRIBUTION lastRecord = benchmarkRecords.FirstOrDefault();

                GreenField.DAL.GF_PERF_DAILY_ATTRIBUTION benchmarkRecord = lastRecord != null?GetMinInceptionDateRecord <GreenField.DAL.GF_PERF_DAILY_ATTRIBUTION>(benchmarkRecords
                                                                                                                                                                   .Where(record => record.TO_DATE == lastRecord.TO_DATE).ToList()) : null;

                result.DateToDateReturn = benchmarkRecord != null ? (preference.EntityNodeType == null
                    ? benchmarkRecord.BM1_TOP_RC_TWR_1D * Convert.ToDecimal(100) : benchmarkRecord.BM1_RC_TWR_1D * Convert.ToDecimal(100)) : null;
                result.WeekToDateReturn = benchmarkRecord != null ? (preference.EntityNodeType == null
                    ? benchmarkRecord.BM1_TOP_RC_TWR_1W * Convert.ToDecimal(100) : benchmarkRecord.BM1_RC_TWR_1W * Convert.ToDecimal(100)) : null;
                result.MonthToDateReturn = benchmarkRecord != null ? (preference.EntityNodeType == null
                    ? benchmarkRecord.BM1_TOP_RC_TWR_MTD * Convert.ToDecimal(100) : benchmarkRecord.BM1_RC_TWR_MTD * Convert.ToDecimal(100)) : null;
                result.QuarterToDateReturn = benchmarkRecord != null ? (preference.EntityNodeType == null
                    ? benchmarkRecord.BM1_TOP_RC_TWR_QTD * Convert.ToDecimal(100) : benchmarkRecord.BM1_RC_TWR_QTD * Convert.ToDecimal(100)) : null;
                result.YearToDateReturn = benchmarkRecord != null ? (preference.EntityNodeType == null
                    ? benchmarkRecord.BM1_TOP_RC_TWR_YTD * Convert.ToDecimal(100) : benchmarkRecord.BM1_RC_TWR_YTD * Convert.ToDecimal(100)) : null;

                if (preference.EntityNodeType == null)
                {
                    GreenField.DAL.GF_PERF_TOPLEVELYEAR benchmarkLastYearRecord = GetMinInceptionDateRecord <GreenField.DAL.GF_PERF_TOPLEVELYEAR>(entity.GF_PERF_TOPLEVELYEAR
                                                                                                                                                  .Where(g => g.CURRENCY.ToUpper() == "USD" &&
                                                                                                                                                         g.RETURN_TYPE.ToUpper() == "NET" &&
                                                                                                                                                         g.TO_DATE == "31/12/" + (DateTime.Today.Year - 1).ToString() &&
                                                                                                                                                         g.BM1ID.ToUpper() == preference.EntityId.ToUpper() &&
                                                                                                                                                         g.BM1NAME.ToUpper() == preference.EntityName.ToUpper() &&
                                                                                                                                                         g.POR_INCEPTION_DATE != null)
                                                                                                                                                  .ToList());

                    result.LastYearReturn = preference.EntityNodeType == null ? (benchmarkLastYearRecord != null
                        ? benchmarkLastYearRecord.BM1_RC_TWR_YTD * Convert.ToDecimal(100) : null) : null;

                    GreenField.DAL.GF_PERF_TOPLEVELYEAR benchmarkSecondLastYearRecord = GetMinInceptionDateRecord <GreenField.DAL.GF_PERF_TOPLEVELYEAR>(entity.GF_PERF_TOPLEVELYEAR
                                                                                                                                                        .Where(g => g.CURRENCY.ToUpper() == "USD" &&
                                                                                                                                                               g.RETURN_TYPE.ToUpper() == "NET" &&
                                                                                                                                                               g.TO_DATE == "31/12/" + (DateTime.Today.Year - 2).ToString() &&
                                                                                                                                                               g.BM1ID.ToUpper() == preference.EntityId.ToUpper() &&
                                                                                                                                                               g.BM1NAME.ToUpper() == preference.EntityName.ToUpper() &&
                                                                                                                                                               g.POR_INCEPTION_DATE != null)
                                                                                                                                                        .ToList());

                    result.SecondLastYearReturn = preference.EntityNodeType == null ? (benchmarkSecondLastYearRecord != null
                        ? benchmarkSecondLastYearRecord.BM1_RC_TWR_YTD * Convert.ToDecimal(100) : null) : null;

                    GreenField.DAL.GF_PERF_TOPLEVELYEAR benchmarkThirdLastYearRecord = GetMinInceptionDateRecord <GreenField.DAL.GF_PERF_TOPLEVELYEAR>(entity.GF_PERF_TOPLEVELYEAR
                                                                                                                                                       .Where(g => g.CURRENCY.ToUpper() == "USD" &&
                                                                                                                                                              g.RETURN_TYPE.ToUpper() == "NET" &&
                                                                                                                                                              g.TO_DATE == "31/12/" + (DateTime.Today.Year - 3).ToString() &&
                                                                                                                                                              g.BM1ID.ToUpper() == preference.EntityId.ToUpper() &&
                                                                                                                                                              g.BM1NAME.ToUpper() == preference.EntityName.ToUpper() &&
                                                                                                                                                              g.POR_INCEPTION_DATE != null)
                                                                                                                                                       .ToList());

                    result.ThirdLastYearReturn = preference.EntityNodeType == null ? (benchmarkThirdLastYearRecord != null
                        ? benchmarkThirdLastYearRecord.BM1_RC_TWR_YTD * Convert.ToDecimal(100) : null) : null;
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(result);
        }
        /// <summary>
        /// Gets performance data for a specific snapshot preference where entity type is security, index or commodity
        /// </summary>
        /// <param name="entity">Dimension service entity instance</param>
        /// <param name="preference">MarketSnapshotPreference object</param>
        /// <returns>MarketSnapshotPerformanceData</returns>
        public static MarketSnapshotPerformanceData GetSecurityCommodityIndexPerformanceData(DimensionEntities entity, MarketSnapshotPreference preference)
        {
            MarketSnapshotPerformanceData result = new MarketSnapshotPerformanceData();

            try
            {
                DateTime TrackDate = DateTime.Today;

                GreenField.DAL.GF_PRICING_BASEVIEW lastDateToDateRecord = entity.GF_PRICING_BASEVIEW
                                                                          .Where(record => record.INSTRUMENT_ID == preference.EntityId &&
                                                                                 record.TYPE == preference.EntityType &&
                                                                                 record.ISSUE_NAME == preference.EntityName &&
                                                                                 record.FROMDATE != null)
                                                                          .OrderByDescending(record => record.FROMDATE)
                                                                          .Take(1).FirstOrDefault();

                if (lastDateToDateRecord == null)
                {
                    return(result);
                }

                GreenField.DAL.GF_PRICING_BASEVIEW firstRecord = entity.GF_PRICING_BASEVIEW
                                                                 .Where(record => record.INSTRUMENT_ID == preference.EntityId &&
                                                                        record.TYPE == preference.EntityType &&
                                                                        record.ISSUE_NAME == preference.EntityName &&
                                                                        record.FROMDATE != null)
                                                                 .OrderBy(record => record.FROMDATE)
                                                                 .Take(1).FirstOrDefault();

                DateTime firstRecordDateTime = DateTime.Today.AddYears(-5);
                if (firstRecord != null)
                {
                    firstRecordDateTime = Convert.ToDateTime(firstRecord.FROMDATE);
                }

                DateTime lastBusinessDateTime = TrackDate = Convert.ToDateTime(lastDateToDateRecord.FROMDATE);
                result.DateToDateReturn = lastDateToDateRecord != null ? (preference.EntityReturnType == "Price"
                    ? lastDateToDateRecord.DAILY_PRICE_RETURN != null ? lastDateToDateRecord.DAILY_PRICE_RETURN : 0
                    : lastDateToDateRecord.DAILY_GROSS_RETURN != null ? lastDateToDateRecord.DAILY_GROSS_RETURN : 0) : null;

                result.WeekToDateReturn = GetReturn(entity, preference, lastBusinessDateTime.AddDays(-6) > firstRecordDateTime
                    ? lastBusinessDateTime.AddDays(-6) : firstRecordDateTime, lastBusinessDateTime);
                result.MonthToDateReturn = GetReturn(entity, preference, new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1) > firstRecordDateTime
                    ? new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1) : firstRecordDateTime, lastBusinessDateTime);
                result.QuarterToDateReturn = GetReturn(entity, preference
                                                       , new DateTime(DateTime.Today.Year, (DateTime.Today.Month - ((DateTime.Today.Month - 1) % 3)), 1) > firstRecordDateTime
                    ? new DateTime(DateTime.Today.Year, (DateTime.Today.Month - ((DateTime.Today.Month - 1) % 3)), 1) : firstRecordDateTime, lastBusinessDateTime);
                result.YearToDateReturn = GetReturn(entity, preference, new DateTime(DateTime.Today.Year, 1, 1) > firstRecordDateTime
                    ? new DateTime(DateTime.Today.Year, 1, 1) : firstRecordDateTime, lastBusinessDateTime);
                result.LastYearReturn = GetReturn(entity, preference, new DateTime(DateTime.Today.Year - 1, 1, 1) > firstRecordDateTime
                    ? new DateTime(DateTime.Today.Year - 1, 1, 1) : firstRecordDateTime, new DateTime(DateTime.Today.Year - 1, 12, 31));
                result.SecondLastYearReturn = GetReturn(entity, preference, new DateTime(DateTime.Today.Year - 2, 1, 1) > firstRecordDateTime
                    ? new DateTime(DateTime.Today.Year - 2, 1, 1) : firstRecordDateTime, new DateTime(DateTime.Today.Year - 2, 12, 31));
                result.ThirdLastYearReturn = GetReturn(entity, preference, new DateTime(DateTime.Today.Year - 3, 1, 1) > firstRecordDateTime
                    ? new DateTime(DateTime.Today.Year - 3, 1, 1) : firstRecordDateTime, new DateTime(DateTime.Today.Year - 3, 12, 31));
            }
            catch (Exception)
            {
                throw;
            }
            return(result);
        }
コード例 #8
0
        public List <FXCommodityData> RetrieveCommodityData(string selectedCommodityID)
        {
            try
            {
                /*  bool isServiceUp;
                 * isServiceUp = CheckServiceAvailability.ServiceAvailability();
                 *
                 * if (!isServiceUp)
                 *    throw new Exception();*/

                List <CommodityResult> resultDB             = new List <CommodityResult>();
                List <FXCommodityData> calculatedViewResult = new List <FXCommodityData>();
                List <FXCommodityData> result   = new List <FXCommodityData>();
                ResearchEntities       research = new ResearchEntities();

                DimensionEntities entity = DimensionEntity;
                List <GreenField.DAL.GF_PRICING_BASEVIEW>   dimSvcPricingViewData   = null;
                List <GreenField.DAL.GF_SELECTION_BASEVIEW> dimSvcSelectionViewData = null;

                if (entity.GF_SELECTION_BASEVIEW == null && entity.GF_SELECTION_BASEVIEW.Count() == 0)
                {
                    return(null);
                }

                if (entity.GF_PRICING_BASEVIEW == null && entity.GF_PRICING_BASEVIEW.Count() == 0)
                {
                    return(null);
                }

                //Retrieving data from database
                if (String.IsNullOrEmpty(selectedCommodityID))
                {
                    selectedCommodityID = GreenfieldConstants.COMMODITY_ALL;
                    resultDB            = research.ExecuteStoreQuery <CommodityResult>("exec GetCOMMODITY_FORECASTS @commodityID={0}", selectedCommodityID).ToList();
                }
                else
                {
                    resultDB = research.ExecuteStoreQuery <CommodityResult>("exec GetCOMMODITY_FORECASTS @commodityID={0}", selectedCommodityID).ToList();
                }

                //Retrieving Data from Views
                DateTime CurrentDate     = System.DateTime.Now;
                DateTime Date1DayBack    = Convert.ToDateTime(FXCommodityCalculations.GetPreviousDate(CurrentDate));
                DateTime DateLastYearEnd = CurrentDate.AddYears(-1).AddMonths(-(CurrentDate.Month) + 12).AddDays(-(CurrentDate.Day) + 31);
                DateLastYearEnd = Convert.ToDateTime(FXCommodityCalculations.CheckBusinessDay(DateLastYearEnd));
                DateTime Date12MonthsAgo = CurrentDate.AddYears(-1);
                Date12MonthsAgo = Convert.ToDateTime(FXCommodityCalculations.CheckBusinessDay(Date12MonthsAgo));
                DateTime Date36MonthsAgo = CurrentDate.AddYears(-3);
                Date36MonthsAgo = Convert.ToDateTime(FXCommodityCalculations.CheckBusinessDay(Date36MonthsAgo));


                if (selectedCommodityID != null && selectedCommodityID != string.Empty)
                {
                    if (selectedCommodityID.ToUpper() != GreenfieldConstants.COMMODITY_ALL)
                    {
                        dimSvcSelectionViewData = entity.GF_SELECTION_BASEVIEW
                                                  .Where(g => (g.AIMS_COMMODITY_ID != null) && (g.AIMS_COMMODITY_ID.ToUpper() == selectedCommodityID.ToUpper()))
                                                  .ToList();
                    }
                    else
                    {
                        dimSvcSelectionViewData = entity.GF_SELECTION_BASEVIEW
                                                  .Where(g => g.AIMS_COMMODITY_ID != null)
                                                  .ToList();
                    }
                }

                if (dimSvcSelectionViewData != null && dimSvcSelectionViewData.Count > 0)
                {
                    List <GreenField.DAL.GF_PRICING_BASEVIEW> queryResultSet = new List <GreenField.DAL.GF_PRICING_BASEVIEW>();

                    Expression <Func <GreenField.DAL.GF_PRICING_BASEVIEW, bool> > searchPredicate1 = p => p.FROMDATE == Convert.ToDateTime(Date1DayBack.ToString()).Date;
                    searchPredicate1 = Utility.Or <GreenField.DAL.GF_PRICING_BASEVIEW>(searchPredicate1, g => g.FROMDATE == Convert.ToDateTime(DateLastYearEnd.ToString()).Date);
                    searchPredicate1 = Utility.Or <GreenField.DAL.GF_PRICING_BASEVIEW>(searchPredicate1, g => g.FROMDATE == Convert.ToDateTime(Date12MonthsAgo.ToString()).Date);
                    searchPredicate1 = Utility.Or <GreenField.DAL.GF_PRICING_BASEVIEW>(searchPredicate1, g => g.FROMDATE == Convert.ToDateTime(Date36MonthsAgo.ToString()).Date);

                    int recursionLimit = 10;

                    for (int j = 0; j < dimSvcSelectionViewData.Count(); j = j + recursionLimit)
                    {
                        Expression <Func <GreenField.DAL.GF_PRICING_BASEVIEW, bool> > searchPredicate2 = p => p.INSTRUMENT_ID.ToUpper() == dimSvcSelectionViewData[j].INSTRUMENT_ID.ToUpper();
                        for (int i = j + 1; i < j + recursionLimit && i < dimSvcSelectionViewData.Count(); i++)
                        {
                            if (dimSvcSelectionViewData[i].INSTRUMENT_ID == null)
                            {
                                continue;
                            }
                            string comparisonInstrumentId = dimSvcSelectionViewData[i].INSTRUMENT_ID.ToUpper();
                            searchPredicate2 = Utility.Or <GreenField.DAL.GF_PRICING_BASEVIEW>(searchPredicate2, p => p.INSTRUMENT_ID.ToUpper() == comparisonInstrumentId);
                        }

                        Expression <Func <GreenField.DAL.GF_PRICING_BASEVIEW, bool> > searchPredicate = Utility.And <GreenField.DAL.GF_PRICING_BASEVIEW>(searchPredicate1, searchPredicate2);
                        queryResultSet.AddRange(entity.GF_PRICING_BASEVIEW.Where(searchPredicate));
                    }

                    foreach (GreenField.DAL.GF_SELECTION_BASEVIEW item in dimSvcSelectionViewData)
                    {
                        if (item.INSTRUMENT_ID != null && item.INSTRUMENT_ID != string.Empty)
                        {
                            dimSvcPricingViewData = queryResultSet.Where(g => (g.INSTRUMENT_ID.ToUpper() == item.INSTRUMENT_ID.ToUpper())).ToList();
                            if (dimSvcPricingViewData != null && dimSvcPricingViewData.Count > 0)
                            {
                                List <FXCommodityData> resultView = new List <FXCommodityData>();
                                foreach (GreenField.DAL.GF_PRICING_BASEVIEW itemPricing in dimSvcPricingViewData)
                                {
                                    FXCommodityData data = new FXCommodityData();

                                    // Assigning Commodity ID from above list
                                    data.CommodityId       = item.AIMS_COMMODITY_ID;
                                    data.FromDate          = itemPricing.FROMDATE;
                                    data.DailyClosingPrice = itemPricing.DAILY_CLOSING_PRICE;

                                    //Assigning Instrument Id from above list
                                    data.InstrumentId = item.INSTRUMENT_ID;

                                    resultView.Add(data);
                                }
                                FXCommodityData calculatedData = new FXCommodityData();

                                //calling method to perform calculations
                                FXCommodityData calculatedDataForCommodity = FXCommodityCalculations.CalculateCommodityData(resultView, Date1DayBack.Date, DateLastYearEnd.Date, Date12MonthsAgo.Date, Date36MonthsAgo.Date);
                                calculatedData.CommodityId  = calculatedDataForCommodity.CommodityId;
                                calculatedData.InstrumentId = calculatedDataForCommodity.InstrumentId;
                                calculatedData.YTD          = calculatedDataForCommodity.YTD;
                                calculatedData.Year1        = calculatedDataForCommodity.Year1;
                                calculatedData.Year3        = calculatedDataForCommodity.Year3;

                                calculatedViewResult.Add(calculatedData);
                            }
                        }
                    }
                }
                for (int _index = 0; _index < resultDB.Count; _index++)
                {
                    foreach (FXCommodityData item in calculatedViewResult)
                    {
                        if (resultDB[_index].COMMODITY_ID == item.CommodityId)
                        {
                            FXCommodityData commodityData = new FXCommodityData();

                            commodityData.CommodityId = resultDB[_index].COMMODITY_ID;

                            //Columns coming from Commodity table
                            commodityData.CurrentYearEnd = Convert.ToDecimal(resultDB[_index].CURRENT_YEAR_END);
                            commodityData.LongTerm       = Convert.ToDecimal(resultDB[_index].LONG_TERM);
                            commodityData.NextYearEnd    = Convert.ToDecimal(resultDB[_index].NEXT_YEAR_END);

                            //Columns coming from Pricing View
                            commodityData.YTD   = item.YTD;
                            commodityData.Year1 = item.Year1;
                            commodityData.Year3 = item.Year3;

                            result.Add(commodityData);
                        }
                    }
                }

                return(result);
            }
            catch (Exception ex)
            {
                ExceptionTrace.LogException(ex);
                string networkFaultMessage = ServiceFaultResourceManager.GetString("NetworkFault").ToString();
                throw new FaultException <ServiceFault>(new ServiceFault(networkFaultMessage), new FaultReason(ex.Message));
            }
        }