Exemple #1
0
        private string GetStringValue(object value)
        {
            string ret      = "";
            string dataType = value.GetType().ToString();

            try
            {
                switch (dataType)
                {
                case "Bloomberglp.Blpapi.Datetime":
                    DateTime d = DateTime.Parse(value.ToString());
                    ret = d.ToString("yyyyMMdd HH:mm:ss");
                    break;

                case "System.String":
                case "System.Char":
                case "System.Double":
                case "System.Int32":
                    ret = value.ToString();
                    break;

                default:
                    ret = value.ToString();
                    Static.Email("Missing data type in BBfieldValueRetriever", "The GetStringValue in the Bloomberg.cs needs to be altered " +
                                 "to include an unhandled Bloomberg data type of " + dataType + " in the Switch statement.");
                    break;
                }
            }
            catch
            {
                Static.Email("Missing data type in BBfieldValueRetriever", "The GetStringValue in the Bloomberg.cs needs to be altered " +
                             "to include an unhandled Bloomberg data type of " + dataType + " in the Switch statement.");
            }
            return(ret);
        }
Exemple #2
0
        public int CalcHits(List <BloombergDataInstrument> bbdis)
        {
            int ret = 0;

            foreach (BloombergDataInstrument bdi in bbdis)
            {
                switch (bdi.RequestType)
                {
                case BloombergDataInstrument.eRequestType.Reference:
                case BloombergDataInstrument.eRequestType.Historic:
                    foreach (string fld in bdi.BBFields.Keys)
                    {
                        ret++;
                    }
                    break;

                case BloombergDataInstrument.eRequestType.IntraDayBar:
                    ret++;       // We believe this is just one, being the eventType field
                    //foreach (string fld in bdi.BBFields.Keys) {
                    //    ret++;
                    //}
                    break;

                default:
                    Static.Email("CalcHits switch default", string.Format("Unhandled RequestType of [{0}] in CalcHits.", bdi.RequestType));
                    break;
                }
            }

            return(ret);
        }
Exemple #3
0
        private void bbd_ProcessCompleted(List <BloombergDataInstrument> instruments)
        {
            try
            {
                RaiseMessageEvent("Retrieving results");
                AddResultsToRequestItems(instruments);

                RaiseMessageEvent("Saving to db");
                Db.SaveValues(_requestItems);
                CostReportUserAttribution(_requestItems);
                RaiseMessageEvent(string.Format("Completed {0} items.", _requestItems.Count));
            }
            catch (Exception ex)
            {
                RaiseMessageEvent("Error: " + ex);
                Static.Email("Error encountered in BBFieldValueRetriever in bbd_ProcessCompleted", ex.ToString());
            }
            finally
            {
                Completed.Set();
                // Set var so that the next process can start
            }
        }
Exemple #4
0
        private bool HitsExceeded()
        {
            bool ret = false;

            _totalHitsToday += _newHits;
            ReportHits(_hitsWarningLevel, _hitsLimit, _totalHitsToday);

            if (_totalHitsToday >= _hitsWarningLevel)
            {
                if (_warningEmailSent != DateTime.Now.Date)
                {
                    string msg = string.Format("Total Bloomberg hits today on {0} is now at {1}. The warning level is {2} " +
                                               "and the hit limit for {0} is {3}", Environment.MachineName, _totalHitsToday, _hitsWarningLevel, _hitsLimit);
                    Static.Email(string.Format("BB Hits warning on {0}", Environment.MachineName), msg);
                    NLogger.Instance.Info("BB Hits warning on {0}", Environment.MachineName);
                    _warningEmailSent = DateTime.Now.Date;
                }
            }

            if (_totalHitsToday >= _hitsLimit)
            {
                ret = true;

                if (_limitEmailSent != DateTime.Now.Date)
                {
                    string msg = string.Format("Total Bloomberg hits today on {0} would exceed the hit limit of {1}. No more Bloomberg requests " +
                                               "will be made today on {0} by the BBfieldValueRetriever", Environment.MachineName, _hitsLimit);
                    Static.Email(string.Format("BB Hits warning on {0}", Environment.MachineName), msg);
                    NLogger.Instance.Info("BB Hits warning on {0}", Environment.MachineName);

                    _limitEmailSent = DateTime.Now.Date;
                }
            }

            return(ret);
        }