Beispiel #1
0
        private void ParseResponse()
        {
            foreach (var securityData in response.Securities)
            {
                try
                {
                    double   bid  = default(double);
                    double   ask  = default(double);
                    DateTime?time = null;

                    string       sec                      = securityData.Key;
                    SecurityData requestedData            = securityData.Value;
                    Dictionary <string, FieldData> fields = requestedData.Fields;

                    if (fields.ContainsKey(Settings.Default.Bloomberg_Field_Bid))
                    {
                        FieldData bidField = fields[Settings.Default.Bloomberg_Field_Bid];
                        if ((bidField != null) && (bidField.HasValue))
                        {
                            bid = bidField.GetValueAsDouble();
                        }
                    }

                    if (fields.ContainsKey(Settings.Default.Bloomberg_Field_Ask))
                    {
                        FieldData askField = fields[Settings.Default.Bloomberg_Field_Ask];
                        if ((askField != null) && (askField.HasValue))
                        {
                            ask = askField.GetValueAsDouble();
                        }
                    }

                    if (fields.ContainsKey(Settings.Default.Bloomberg_Field_Time))
                    {
                        FieldData timeField = fields[Settings.Default.Bloomberg_Field_Time];
                        if ((timeField != null) && (timeField.HasValue))
                        {
                            time = timeField.GetValueAsDateTime();
                        }
                    }
                    if (time == null)
                    {
                        time = new DateTime(1900, 1, 1);
                    }
                    tickerPriceCollection.Add(sec, new PriceInfo(bid, ask, time, time));
                }
                catch (Exception ex)
                {
                    Console.WriteLine("ParseResponse() " + ex);
                    HasError = true;
                }
            }
        }