Example #1
0
        /// <summary>
        /// Write latest economic data points for each ticker to string.
        /// </summary>
        /// <returns></returns>
        private string WriteLatestDataToString()
        {
            EconomicDataSeries dataSeries;
            StringBuilder      stringBuilder = new StringBuilder();

            // Loop to find latest economic data point in the dictionary.
            foreach (string ticker in m_EconomicDataManager.EconomicDataSeriesByTicker.Keys)
            {
                m_EconomicDataManager.EconomicDataSeriesByTicker.TryGetValue(ticker, out dataSeries);
                EconomicDataPoint economicDataPoint = dataSeries.LatestEconomicPoint;
                if (economicDataPoint != null)
                {
                    stringBuilder.AppendLine(economicDataPoint.WriteDetaToString());
                }
            }

            return(stringBuilder.ToString());
        }
        /// <summary>
        /// Record future economic data information.
        /// </summary>
        /// <param name="eventObj"></param>
        private void RecordFutureEconomicData(Event eventObj)
        {
            StringBuilder stringBuilder = new StringBuilder();

            foreach (Message message in eventObj)
            {
                stringBuilder.AppendLine(message.ToString());
                Element response = message.AsElement;
                if (response.HasElement("responseError"))
                {
                    string errorInfo = string.Format("FutureDataListener_RecordFutureEconomicData:There is response error here!The message content is {0}.", message.ToString());
                    Console.WriteLine(errorInfo);
                    Logging.WriteErrorLog(errorInfo);
                    continue;
                }

                if (!response.HasElement("securityData"))
                {
                    string errorInfo = string.Format("FutureDataListener_RecordFutureEconomicData:There is no securityData here!The message content is {0}.", message.ToString());
                    Console.WriteLine(errorInfo);
                    Logging.WriteErrorLog(errorInfo);
                    continue;
                }

                Element securityDataArray = response.GetElement("securityData");
                int numberOfSecurityData = securityDataArray.NumValues;

                if (numberOfSecurityData == 0)
                {
                    string errorInfo = string.Format("FutureDataListener_RecordFutureEconomicData:There is no data for any securities here!The message content is {0}.", message.ToString());
                    Console.WriteLine(errorInfo);
                    Logging.WriteErrorLog(errorInfo);
                    continue;
                }

                for (int i = 0; i < numberOfSecurityData; ++i)
                {
                    Element securityData = securityDataArray.GetValueAsElement(i);
                    string ticker = string.Empty;
                    if (securityData.HasElement("security"))
                        ticker = securityData.GetElementAsString("security");
                    else
                    {
                        string errorInfo = string.Format("FutureDataListener_RecordFutureEconomicData:There is no ticker!The message content is {0}.", message.ToString());
                        Console.WriteLine(errorInfo);
                        Logging.WriteErrorLog(errorInfo);
                        continue;
                    }

                    if (securityData.HasElement("securityError"))
                    {
                        string errorInfo = string.Format("FutureDataListener_RecordFutureEconomicData:There is securityError!The error ticker is {0}.", ticker);
                        Console.WriteLine(errorInfo);
                        Logging.WriteErrorLog(errorInfo);
                        continue;
                    }

                    if (securityData.HasElement("fieldException"))
                    {
                        string errorInfo = string.Format("FutureDataListener_RecordFutureEconomicData:There is field exception!The error ticker is {0}.", ticker);
                        Console.WriteLine(errorInfo);
                        Logging.WriteErrorLog(errorInfo);
                        continue;
                    }

                    if (!securityData.HasElement("fieldData"))
                    {
                        string errorInfo = string.Format("FutureDataListener_RecordFutureEconomicData:There is no field data!The error ticker is {0}.", ticker);
                        Console.WriteLine(errorInfo);
                        Logging.WriteErrorLog(errorInfo);
                        continue;
                    }
                    else
                    {
                        Element fields = securityData.GetElement("fieldData");
                        int numberOfFields = fields.NumElements;
                        if (numberOfFields == 0)
                        {
                            string errorInfo = string.Format("FutureDataListener_RecordFutureEconomicData:There is no field for this security here!The error ticker is {0}.", ticker);
                            Console.WriteLine(errorInfo);
                            Logging.WriteErrorLog(errorInfo);
                            continue;
                        }
                        else
                        {
                            int numberOfField = fields.NumElements;

                            if (numberOfField == 0)
                            {
                                string errorInfo = string.Format("FutureDataListener_RecordFutureEconomicData:There is no field for this security here!The error ticker is {0}.", ticker);
                                Console.WriteLine(errorInfo);
                                Logging.WriteErrorLog(errorInfo);
                                m_EconomicDataManager.m_BadTickerList.Add(ticker);
                                continue;
                            }
                            else
                            {
                                Element field = fields.GetElement(0);

                                if (field.NumValues > 0)
                                {
                                    for (int k = 0; k < field.NumValues; k++)
                                    {
                                        Element temp = field.GetValueAsElement(k);
                                        Element temptemp = temp.GetElement(0);
                                        string accurateTime = temptemp.GetValueAsString();
                                        string futureReleaseDate = TransformDateStringFormat(accurateTime);
                                        string futureReleaseTime = TransformTimeStringFormat(accurateTime);

                                        EconomicDataPoint economicDataPoint = new EconomicDataPoint();
                                        economicDataPoint.CreateFutureEconomicPoint(
                                            ticker,
                                            futureReleaseDate,
                                            futureReleaseTime
                                            );
                                        m_EconomicDataManager.AddFutureEconomicPoint(economicDataPoint);
                                        m_EconomicDataManager.m_RowCount++;
                                        string text = string.Format("FutureDataListener_RecordFutureEconomicData:Bloomberg gave {0} rows already. Message:{1}",
                                            m_EconomicDataManager.m_RowCount, economicDataPoint.WriteDetaToString());
                                        stringBuilder.AppendLine(text);
                                        Console.WriteLine(text);
                                    }
                                }
                                else
                                {
                                    string errorInfo = string.Format("FutureDataListener_RecordFutureEconomicData:The array returned has 0 dimension. The error ticker is {0}.", ticker);
                                    Console.WriteLine(errorInfo);
                                    Logging.WriteErrorLog(errorInfo);
                                    m_EconomicDataManager.m_BadTickerList.Add(ticker);
                                    continue;
                                }
                            }
                        }
                    }
                }
            }

            // Write to log all the message details.
            Logging.WriteLog(stringBuilder.ToString());
        }
        /// <summary>
        /// Record historical economic data information.
        /// </summary>
        /// <param name="eventObj"></param>
        private void RecordHistoricalEconomicData(Event eventObj)
        {
            StringBuilder stringBuilder = new StringBuilder();

            foreach (Message message in eventObj)
            {
                stringBuilder.AppendLine(message.ToString());
                Element response = message.AsElement;
                if (response.HasElement("responseError"))
                {
                    string errorInfo = string.Format("HistoricalDataListener_RecordHistoricalEconomicData:There is response error here!The message content is {0}.", message.ToString());
                    Console.WriteLine(errorInfo);
                    Logging.WriteErrorLog(errorInfo);
                    continue;
                }

                if (!response.HasElement("securityData"))
                {
                    string errorInfo = string.Format("HistoricalDataListener_RecordHistoricalEconomicData:There is no securityData here!The message content is {0}.", message.ToString());
                    Console.WriteLine(errorInfo);
                    Logging.WriteErrorLog(errorInfo);
                    continue;
                }

                Element securityData = response.GetElement("securityData");

                if (securityData.HasElement("securityError"))
                {
                    string errorInfo = string.Format("HistoricalDataListener_RecordHistoricalEconomicData:There is security error here!The message content is {0}.", message.ToString());
                    Console.WriteLine(errorInfo);
                    Logging.WriteErrorLog(errorInfo);
                    continue;
                }

                if (securityData.HasElement("fieldException"))
                {
                    string errorInfo = string.Format("HistoricalDataListener_RecordHistoricalEconomicData:There is field exception here!The message content is {0}.", message.ToString());
                    Console.WriteLine(errorInfo);
                    Logging.WriteErrorLog(errorInfo);
                    continue;
                }

                string ticker = string.Empty;
                if (securityData.HasElement("security"))
                {
                    ticker = securityData.GetElementAsString("security");
                }
                else
                {
                    string errorInfo = string.Format("HistoricalDataListener_RecordHistoricalEconomicData:There is no ticker!The message content is {0}.", message.ToString());
                    Console.WriteLine(errorInfo);
                    Logging.WriteErrorLog(errorInfo);
                    continue;
                }

                if (!securityData.HasElement("fieldData"))
                {
                    string errorInfo = string.Format("HistoricalDataListener_RecordHistoricalEconomicData:There is no field data!The error ticker is {0}.", ticker);
                    Console.WriteLine(errorInfo);
                    Logging.WriteErrorLog(errorInfo);
                    continue;
                }
                else
                {
                    Element fieldDataArray    = securityData.GetElement("fieldData");
                    int     numberOfFieldRows = fieldDataArray.NumValues;
                    if (numberOfFieldRows == 0)
                    {
                        string errorInfo = string.Format("HistoricalDataListener_RecordHistoricalEconomicData:There is no field data history! The error ticker name is {0}.", ticker);
                        Console.WriteLine(errorInfo);
                        Logging.WriteErrorLog(errorInfo);
                        continue;
                    }
                    else
                    {
                        EconomicDataSeries economicDataSeries;
                        m_EconomicDataManager.EconomicDataSeriesByTicker.TryGetValue(ticker, out economicDataSeries);

                        if (economicDataSeries != null)
                        {
                            EconomicDataPoint latestEconomicDataPoint = economicDataSeries.LatestEconomicPoint;

                            if (latestEconomicDataPoint == null)
                            {
                                string text = string.Format("HistoricalDataListener_RecordHistoricalEconomicData:There is no latest economic data point for this ticker:{0}.", ticker);
                                Console.WriteLine(text);
                                Logging.WriteErrorLog(text);
                                continue;
                            }

                            if (numberOfFieldRows > 0)
                            {
                                for (int i = 0; i < numberOfFieldRows; ++i)
                                {
                                    Element fieldData               = fieldDataArray.GetValueAsElement(i);
                                    string  releaseDate             = m_EmptySign;
                                    string  surveyActualRelease     = m_EmptySign;
                                    string  surveyHigh              = m_EmptySign;
                                    string  surveyLow               = m_EmptySign;
                                    string  surveyMedian            = m_EmptySign;
                                    string  surveyAverage           = m_EmptySign;
                                    string  surveyObservations      = m_EmptySign;
                                    string  futureStandardDeviation = m_EmptySign;

                                    if (fieldData.HasElement(m_EcoDateString))
                                    {
                                        releaseDate = fieldData.GetElementAsString(m_EcoDateString);
                                    }
                                    else
                                    {
                                        string text = string.Format("HistoricalDataListener_RecordHistoricalEconomicData:Ticker:{0} does not have field {1}.", ticker, m_EcoDateString);
                                        Console.WriteLine(text);
                                        Logging.WriteErrorLog(text);
                                    }
                                    if (fieldData.HasElement(m_SurveyActualRelease))
                                    {
                                        surveyActualRelease = fieldData.GetElementAsString(m_SurveyActualRelease);
                                    }
                                    else
                                    {
                                        string text = string.Format("HistoricalDataListener_RecordHistoricalEconomicData:Ticker:{0} does not have field {1}.", ticker, m_SurveyActualRelease);
                                        Console.WriteLine(text);
                                        Logging.WriteErrorLog(text);
                                    }
                                    if (fieldData.HasElement(m_SurveyHighString))
                                    {
                                        surveyHigh = fieldData.GetElementAsString(m_SurveyHighString);
                                    }
                                    else
                                    {
                                        string text = string.Format("HistoricalDataListener_RecordHistoricalEconomicData:Ticker:{0} does not have field {1}.", ticker, m_SurveyHighString);
                                        Console.WriteLine(text);
                                        Logging.WriteErrorLog(text);
                                    }
                                    if (fieldData.HasElement(m_SurveyLowString))
                                    {
                                        surveyLow = fieldData.GetElementAsString(m_SurveyLowString);
                                    }
                                    else
                                    {
                                        string text = string.Format("HistoricalDataListener_RecordHistoricalEconomicData:Ticker:{0} does not have field {1}.", ticker, m_SurveyLowString);
                                        Console.WriteLine(text);
                                        Logging.WriteErrorLog(text);
                                    }
                                    if (fieldData.HasElement(m_SurveyMedianString))
                                    {
                                        surveyMedian = fieldData.GetElementAsString(m_SurveyMedianString);
                                    }
                                    else
                                    {
                                        string text = string.Format("HistoricalDataListener_RecordHistoricalEconomicData:Ticker:{0} does not have field {1}.", ticker, m_SurveyMedianString);
                                        Console.WriteLine(text);
                                        Logging.WriteErrorLog(text);
                                    }
                                    if (fieldData.HasElement(m_SurveyAverageString))
                                    {
                                        surveyAverage = fieldData.GetElementAsString(m_SurveyAverageString);
                                    }
                                    else
                                    {
                                        string text = string.Format("HistoricalDataListener_RecordHistoricalEconomicData:Ticker:{0} does not have field {1}.", ticker, m_SurveyAverageString);
                                        Console.WriteLine(text);
                                        Logging.WriteErrorLog(text);
                                    }
                                    if (fieldData.HasElement(m_SurveyObservationsString))
                                    {
                                        surveyObservations = fieldData.GetElementAsString(m_SurveyObservationsString);
                                    }
                                    else
                                    {
                                        string text = string.Format("HistoricalDataListener_RecordHistoricalEconomicData:Ticker:{0} does not have field {1}.", ticker, m_SurveyObservationsString);
                                        Console.WriteLine(text);
                                        Logging.WriteErrorLog(text);
                                    }
                                    if (fieldData.HasElement(m_FutureStandardDeviationString))
                                    {
                                        futureStandardDeviation = fieldData.GetElementAsString(m_FutureStandardDeviationString);
                                    }
                                    else
                                    {
                                        string text = string.Format("HistoricalDataListener_RecordHistoricalEconomicData:Ticker:{0} does not have field {1}.", ticker, m_FutureStandardDeviationString);
                                        Console.WriteLine(text);
                                        Logging.WriteErrorLog(text);
                                    }

                                    EconomicDataPoint economicDataPoint = new EconomicDataPoint();
                                    economicDataPoint.CreateHistoricalEconomicPoint(
                                        latestEconomicDataPoint,
                                        releaseDate,
                                        surveyActualRelease,
                                        surveyHigh,
                                        surveyLow,
                                        surveyMedian,
                                        surveyAverage,
                                        surveyObservations,
                                        futureStandardDeviation
                                        );
                                    m_EconomicDataManager.AddHistoricalEconomicPoint(economicDataPoint);
                                    m_EconomicDataManager.m_RowCount++;

                                    // Append message that we record.
                                    string textMessage = string.Format("HistoricalDataListener_RecordHistoricalEconomicData:Bloomberg gave {0} rows already. Message:{1}"
                                                                       , m_EconomicDataManager.m_RowCount, economicDataPoint.WriteDetaToString());
                                    stringBuilder.AppendLine(textMessage);
                                    Console.WriteLine(textMessage);
                                }
                            }
                            else
                            {
                                string errorInfo = string.Format("HistoricalDataListener_RecordHistoricalEconomicData:The returned array dimension is 0. The error ticker name is {0}.", ticker);
                                Console.WriteLine(errorInfo);
                                Logging.WriteErrorLog(errorInfo);
                                continue;
                            }
                        }
                        else
                        {
                            string errorInfo = string.Format("HistoricalDataListener_RecordHistoricalEconomicData:There is no economic series for this ticker here! The error ticker is {0}.", ticker);
                            Console.WriteLine(errorInfo);
                            Logging.WriteErrorLog(errorInfo);
                            continue;
                        }
                    }
                }
            }

            // Write to log all the message details.
            Logging.WriteLog(stringBuilder.ToString());
        }
Example #4
0
        /// <summary>
        /// Record latest economic data information.
        /// </summary>
        /// <param name="eventObj"></param>
        private void RecordLatestEconomicData(Event eventObj)
        {
            StringBuilder stringBuilder = new StringBuilder();

            foreach (Message message in eventObj)
            {
                stringBuilder.AppendLine(message.ToString());
                Element response = message.AsElement;
                if (response.HasElement("responseError"))
                {
                    string errorInfo = string.Format("LatestDataListener_RecordLatestEconomicData:There is response error here!The message content is {0}.", message.ToString());
                    Console.WriteLine(errorInfo);
                    Logging.WriteErrorLog(errorInfo);
                    continue;
                }

                if (!response.HasElement("securityData"))
                {
                    string errorInfo = string.Format("LatestDataListener_RecordLatestEconomicData:There is no securityData here!The message content is {0}.", message.ToString());
                    Console.WriteLine(errorInfo);
                    Logging.WriteErrorLog(errorInfo);
                    continue;
                }

                Element securityDataArray    = response.GetElement("securityData");
                int     numberOfSecurityData = securityDataArray.NumValues;

                if (numberOfSecurityData == 0)
                {
                    string errorInfo = string.Format("LatestDataListener_RecordLatestEconomicData:There is no data for any securities here! The message content is {0}.", message.ToString());
                    Console.WriteLine(errorInfo);
                    Logging.WriteErrorLog(errorInfo);
                    continue;
                }

                for (int i = 0; i < numberOfSecurityData; ++i)
                {
                    Element securityData = securityDataArray.GetValueAsElement(i);
                    string  ticker       = string.Empty;
                    if (securityData.HasElement("security"))
                    {
                        ticker = securityData.GetElementAsString("security");
                    }
                    else
                    {
                        string errorInfo = string.Format("LatestDataListener_RecordLatestEconomicData:There is no ticker! The message content is {0}.", message.ToString());
                        Console.WriteLine(errorInfo);
                        Logging.WriteErrorLog(errorInfo);
                        continue;
                    }

                    if (securityData.HasElement("securityError"))
                    {
                        string errorInfo = string.Format("LatestDataListener_RecordLatestEconomicData:There is securityError!The error ticker is {0}.", ticker);
                        Console.WriteLine(errorInfo);
                        Logging.WriteErrorLog(errorInfo);
                        continue;
                    }

                    if (securityData.HasElement("fieldException"))
                    {
                        string errorInfo = string.Format("LatestDataListener_RecordLatestEconomicData:There is field exception!The error ticker is {0}.", ticker);
                        Console.WriteLine(errorInfo);
                        Logging.WriteErrorLog(errorInfo);
                        continue;
                    }

                    if (!securityData.HasElement("fieldData"))
                    {
                        string errorInfo = string.Format("LatestDataListener_RecordLatestEconomicData:There is no field data!The error ticker is {0}.", ticker);
                        Console.WriteLine(errorInfo);
                        Logging.WriteErrorLog(errorInfo);
                        continue;
                    }
                    else
                    {
                        Element fields         = securityData.GetElement("fieldData");
                        int     numberOfFields = fields.NumElements;
                        if (numberOfFields == 0)
                        {
                            string errorInfo = string.Format("LatestDataListener_RecordLatestEconomicData:There is no field for this security here!The error ticker is {0}.", ticker);
                            Console.WriteLine(errorInfo);
                            Logging.WriteErrorLog(errorInfo);
                            continue;
                        }
                        else
                        {
                            string countryID               = m_EmptySign;
                            string ecoDate                 = m_EmptySign;
                            string ecoTime                 = m_EmptySign;
                            string eventName               = m_EmptySign;
                            string shortName               = m_EmptySign;
                            string securityName            = m_EmptySign;
                            string surveyLast              = m_EmptySign;
                            string surveyHigh              = m_EmptySign;
                            string surveyLow               = m_EmptySign;
                            string surveyMedian            = m_EmptySign;
                            string surveyAverage           = m_EmptySign;
                            string surveyObservations      = m_EmptySign;
                            string futureStandardDeviation = m_EmptySign;
                            string indexUpdateFrequency    = m_EmptySign;
                            string relevanceValue          = m_EmptySign;
                            string timeZoneCode            = m_EmptySign;
                            string observationPeriod       = m_EmptySign;

                            if (fields.HasElement(m_CountryCodeString))
                            {
                                countryID = fields.GetElementAsString(m_CountryCodeString);
                            }
                            else
                            {
                                string text = string.Format("LatestDataListener_RecordLatestEconomicData:Ticker:{0} does not have field {1}.", ticker, m_CountryCodeString);
                                Console.WriteLine(text);
                                Logging.WriteErrorLog(text);
                            }
                            if (fields.HasElement(m_EcoDateString))
                            {
                                ecoDate = fields.GetElementAsString(m_EcoDateString);
                            }
                            else
                            {
                                string text = string.Format("LatestDataListener_RecordLatestEconomicData:For the ticker:{0}, the Bloomberg does not know field {1}.", ticker, m_EcoDateString);
                                Console.WriteLine(text);
                                Logging.WriteErrorLog(text);
                            }
                            if (fields.HasElement(m_EcoTimeString))
                            {
                                ecoTime = fields.GetElementAsString(m_EcoTimeString);
                            }
                            else
                            {
                                string text = string.Format("LatestDataListener_RecordLatestEconomicData:For the ticker:{0}, the Bloomberg does not know field {1}.", ticker, m_EcoTimeString);
                                Console.WriteLine(text);
                                Logging.WriteErrorLog(text);
                            }
                            if (fields.HasElement(m_EventNameString))
                            {
                                eventName = fields.GetElementAsString(m_EventNameString);
                            }
                            else
                            {
                                string text = string.Format("LatestDataListener_RecordLatestEconomicData:Ticker:{0} does not have field {1}.", ticker, m_EventNameString);
                                Console.WriteLine(text);
                                Logging.WriteErrorLog(text);
                            }
                            if (fields.HasElement(m_LongCompNameString))
                            {
                                string longCompName = fields.GetElementAsString(m_LongCompNameString);
                                if (longCompName != null && longCompName != "" && longCompName != string.Empty)
                                {
                                    eventName = longCompName;
                                }
                            }
                            else
                            {
                                string text = string.Format("LatestDataListener_RecordLatestEconomicData:Ticker:{0} does not have field {1}.", ticker, m_LongCompNameString);
                                Console.WriteLine(text);
                                Logging.WriteErrorLog(text);
                            }
                            if (fields.HasElement(m_ShortNameString))
                            {
                                shortName = fields.GetElementAsString(m_ShortNameString);
                            }
                            else
                            {
                                string text = string.Format("LatestDataListener_RecordLatestEconomicData:Ticker:{0} does not have field {1}.", ticker, m_ShortNameString);
                                Console.WriteLine(text);
                                Logging.WriteErrorLog(text);
                            }
                            if (fields.HasElement(m_SecurityNameString))
                            {
                                securityName = fields.GetElementAsString(m_SecurityNameString);
                            }
                            else
                            {
                                string text = string.Format("LatestDataListener_RecordLatestEconomicData:Ticker:{0} does not have field {1}.", ticker, m_SecurityNameString);
                                Console.WriteLine(text);
                                Logging.WriteErrorLog(text);
                            }
                            if (fields.HasElement(m_SurveyLastPriceString))
                            {
                                surveyLast = fields.GetElementAsString(m_SurveyLastPriceString);
                            }
                            else
                            {
                                string text = string.Format("LatestDataListener_RecordLatestEconomicData:Ticker:{0} does not have field {1}.", ticker, m_SurveyLastPriceString);
                                Console.WriteLine(text);
                                Logging.WriteErrorLog(text);
                            }
                            if (fields.HasElement(m_SurveyHighString))
                            {
                                surveyHigh = fields.GetElementAsString(m_SurveyHighString);
                            }
                            else
                            {
                                string text = string.Format("LatestDataListener_RecordLatestEconomicData:Ticker:{0} does not have field {1}.", ticker, m_SurveyHighString);
                                Console.WriteLine(text);
                                Logging.WriteErrorLog(text);
                            }
                            if (fields.HasElement(m_SurveyLowString))
                            {
                                surveyLow = fields.GetElementAsString(m_SurveyLowString);
                            }
                            else
                            {
                                string text = string.Format("LatestDataListener_RecordLatestEconomicData:Ticker:{0} does not have field {1}.", ticker, m_SurveyLowString);
                                Console.WriteLine(text);
                                Logging.WriteErrorLog(text);
                            }
                            if (fields.HasElement(m_SurveyMedianString))
                            {
                                surveyMedian = fields.GetElementAsString(m_SurveyMedianString);
                            }
                            else
                            {
                                string text = string.Format("LatestDataListener_RecordLatestEconomicData:Ticker:{0} does not have field {1}.", ticker, m_SurveyMedianString);
                                Console.WriteLine(text);
                                Logging.WriteErrorLog(text);
                            }
                            if (fields.HasElement(m_SurveyAverageString))
                            {
                                surveyAverage = fields.GetElementAsString(m_SurveyAverageString);
                            }
                            else
                            {
                                string text = string.Format("LatestDataListener_RecordLatestEconomicData:Ticker:{0} does not have field {1}.", ticker, m_SurveyAverageString);
                                Console.WriteLine(text);
                                Logging.WriteErrorLog(text);
                            }
                            if (fields.HasElement(m_SurveyObservationsString))
                            {
                                surveyObservations = fields.GetElementAsString(m_SurveyObservationsString);
                            }
                            else
                            {
                                string text = string.Format("LatestDataListener_RecordLatestEconomicData:Ticker:{0} does not have field {1}.", ticker, m_SurveyObservationsString);
                                Console.WriteLine(text);
                                Logging.WriteErrorLog(text);
                            }
                            if (fields.HasElement(m_FutureStandardDeviationString))
                            {
                                futureStandardDeviation = fields.GetElementAsString(m_FutureStandardDeviationString);
                            }
                            else
                            {
                                string text = string.Format("LatestDataListener_RecordLatestEconomicData;Ticker:{0} does not have field {1}.", ticker, m_FutureStandardDeviationString);
                                Console.WriteLine(text);
                                Logging.WriteErrorLog(text);
                            }
                            if (fields.HasElement(m_IndexUpdateFrequencyString))
                            {
                                indexUpdateFrequency = fields.GetElementAsString(m_IndexUpdateFrequencyString);
                            }
                            else
                            {
                                string text = string.Format("LatestDataListener_RecordLatestEconomicData:Ticker:{0} does not have field {1}.", ticker, m_IndexUpdateFrequencyString);
                                Console.WriteLine(text);
                                Logging.WriteErrorLog(text);
                            }
                            if (fields.HasElement(m_RelevanceValueString))
                            {
                                relevanceValue = fields.GetElementAsString(m_RelevanceValueString);
                            }
                            else
                            {
                                string text = string.Format("LatestDataListener_RecordLatestEconomicData:Ticker:{0} does not have field {1}.", ticker, m_RelevanceValueString);
                                Console.WriteLine(text);
                                Logging.WriteErrorLog(text);
                            }
                            if (fields.HasElement(m_TimeZoneCodeString))
                            {
                                timeZoneCode = fields.GetElementAsString(m_TimeZoneCodeString);
                            }
                            else
                            {
                                string text = string.Format("LatestDataListener_RecordLatestEconomicData:Ticker:{0} does not have field {1}.", ticker, m_TimeZoneCodeString);
                                Console.WriteLine(text);
                                Logging.WriteErrorLog(text);
                            }
                            if (fields.HasElement(m_ObservationPeriodString))
                            {
                                observationPeriod = fields.GetElementAsString(m_ObservationPeriodString);
                            }
                            else
                            {
                                string text = string.Format("LatestDataListener_RecordLatestEconomicData:Ticker:{0} does not have field {1}.", ticker, m_ObservationPeriodString);
                                Console.WriteLine(text);
                                Logging.WriteErrorLog(text);
                            }

                            ecoDate = TransformDateStringFormat(ecoDate);
                            EconomicDataPoint economicDataPoint = new EconomicDataPoint();
                            economicDataPoint.CreateLatestEconomicPoint(
                                countryID,
                                ticker,
                                ecoDate,
                                ecoTime,
                                eventName,
                                shortName,
                                securityName,
                                surveyLast,
                                surveyHigh,
                                surveyLow,
                                surveyMedian,
                                surveyAverage,
                                surveyObservations,
                                futureStandardDeviation,
                                indexUpdateFrequency,
                                relevanceValue,
                                timeZoneCode,
                                observationPeriod
                                );
                            m_EconomicDataManager.AddLatestEconomicPoint(economicDataPoint);
                            m_EconomicDataManager.m_RowCount++;
                            string textMessage = string.Format("LatestDataListener_RecordLatestEconomicData:Bloomberg gave {0} rows already. Message:{1}"
                                                               , m_EconomicDataManager.m_RowCount, economicDataPoint.WriteDetaToString());
                            stringBuilder.AppendLine(textMessage);
                            Console.WriteLine(textMessage);
                        }
                    }
                }
            }

            // Write to log all the message details.
            Logging.WriteLog(stringBuilder.ToString());
        }