示例#1
0
        // added override to kill warning
        public override Dictionary <string, int> SetFromBloomberg(ref BBCOMM.Element myElement, Dictionary <string, int> skipFields)
        {
            if (skipFields[CLEAN_PX_BID] < MAX_RETRY)
            {
                SetCleanPxBid(ref myElement, ref skipFields);
            }
            ;
            if (skipFields[CLEAN_PX_ASK] < MAX_RETRY)
            {
                SetCleanPxAsk(ref myElement, ref skipFields);
            }
            ;
            if (skipFields[CLEAN_PX_MID] < MAX_RETRY)
            {
                SetCleanPxMid(ref myElement, ref skipFields);
            }
            ;

            if (skipFields[DIRTY_PX_BID] < MAX_RETRY)
            {
                SetDirtyPxBid(ref myElement, ref skipFields);
            }
            ;
            if (skipFields[DIRTY_PX_ASK] < MAX_RETRY)
            {
                SetDirtyPxAsk(ref myElement, ref skipFields);
            }
            ;
            if (skipFields[DIRTY_PX_MID] < MAX_RETRY)
            {
                SetDirtyPxMid(ref myElement, ref skipFields);
            }
            ;

            if (skipFields[YTM_BID] < MAX_RETRY)
            {
                SetYTMBid(ref myElement, ref skipFields);
            }
            ;
            if (skipFields[YTM_ASK] < MAX_RETRY)
            {
                SetYTMAsk(ref myElement, ref skipFields);
            }
            ;
            if (skipFields[YTM_MID] < MAX_RETRY)
            {
                SetYTMMid(ref myElement, ref skipFields);
            }
            ;

            //if (skipFields[ASW_SPREAD_BID] < MAX_RETRY) { SetAssetSwapSpreadBid(ref myElement, ref skipFields); };
            //if (skipFields[ASW_SPREAD_ASK] < MAX_RETRY) { SetAssetSwapSpreadAsk(ref myElement, ref skipFields); };
            if (skipFields[ASW_SPREAD_MID] < MAX_RETRY)
            {
                SetAssetSwapSpreadMid(ref myElement, ref skipFields);
            }
            ;

            return(skipFields);
        }
示例#2
0
        private void ProcessHistoricalDataResponse(Bloomberglp.Blpapi.Message argvMessage)
        {
            Bloomberglp.Blpapi.Element tElementMsg = argvMessage.AsElement;
            string[] tTargetAttributes             = mHistoricalDataResponseDefaultAttributes;
            if (mHistoricalDataRequestByCorrelationId.ContainsKey(argvMessage.CorrelationID.Value))
            {
                tTargetAttributes = mHistoricalDataRequestByCorrelationId[argvMessage.CorrelationID.Value].GetFieldList();
            }
            else
            {
                InterfaceEventArgs tArgs = new InterfaceEventArgs(InterfaceEventArgs.xBbgMsgType.Error);
                tArgs.mMsg = "Unknown historical data response. Correlation ID: " + argvMessage.CorrelationID.Value + ". Will use default attributes to parse the message.";
                mBbgMsgEvent(this, tArgs);
            }

            string[] tFullAttributes = new string[tTargetAttributes.Length + 2];
            tFullAttributes[0] = "security";
            tFullAttributes[1] = "date";
            Array.Copy(tTargetAttributes, 0, tFullAttributes, 2, tTargetAttributes.Length);

            System.Data.DataTable tExtractedValues = this.ExtractValueByName(tElementMsg, tFullAttributes);
            mOutput.PrintDataTable(tExtractedValues);
            InterfaceEventArgs tEventArgvs = new InterfaceEventArgs(InterfaceEventArgs.xBbgMsgType.HistoricalDataResponse);

            tEventArgvs.mData = tExtractedValues;
            mBbgMsgEvent(this, tEventArgvs);
        }
示例#3
0
        private string processBulkData(BB.Element data)
        {
            string ret = null;

            try {
                if (data.NumValues > 0)
                {
                    for (int index = 0; index < data.NumValues; index++)
                    {
                        BB.Element bulk = data.GetValueAsElement(index);

                        if (bulk.NumElements > 1)
                        {
                            ret += "{";
                        }
                        foreach (BB.Element item in bulk.Elements)
                        {
                            ret += item.GetValueAsString() + arrayDelimiter;
                        }
                        if (bulk.NumElements > 1)
                        {
                            ret += "}";
                        }
                    }
                }
            } catch (Exception ex) {
                UpdateStatus("Error occurred processing array field : " + ex.Message);
                ret = null;
            }
            return(ret);
        }
示例#4
0
    /*****************************************************************************
    *  Function    : processSubscriptionStatus
    *  Description : Processes subscription status messages returned from Bloomberg
    *  Arguments   : Event, Session
    *  Returns     : void
    *****************************************************************************/
    private void processSubscriptionStatus(Event eventObj, Session session)
    {
        System.Console.WriteLine("Processing SUBSCRIPTION_STATUS");
        foreach (Message msg in eventObj)
        {
            string topic = (string)msg.CorrelationID.Object;
            System.Console.WriteLine(System.DateTime.Now.ToString("s") +
                                     ": " + topic + " - " + msg.MessageType);

            if (msg.HasElement(REASON))
            {
                // This occurs if a bad security is subscribed to
                Element reason = msg.GetElement(REASON);
                System.Console.WriteLine("\t" +
                                         reason.GetElement(CATEGORY).GetValueAsString() +
                                         ": " + reason.GetElement(DESCRIPTION).GetValueAsString());
            }

            if (msg.HasElement(EXCEPTIONS))
            {
                // This can occur on SubscriptionStarted if an
                // invalid field is passed in
                Element exceptions = msg.GetElement(EXCEPTIONS);
                for (int i = 0; i < exceptions.NumValues; ++i)
                {
                    Element exInfo  = exceptions.GetValueAsElement(i);
                    Element fieldId = exInfo.GetElement(FIELD_ID);
                    Element reason  = exInfo.GetElement(REASON);
                    System.Console.WriteLine("\t" + fieldId.GetValueAsString() +
                                             ": " + reason.GetElement(CATEGORY).GetValueAsString());
                }
            }
            System.Console.WriteLine("");
        }
    }
示例#5
0
        /// <summary>
        /// Process a list of curves in a response from the BLP API.
        /// Not fully implemented yet - does not collect results
        /// </summary>
        /// <param name="msg"></param>
        private void ProcessCurveListResponse(Message msg)
        {
            Element results    = msg.GetElement(RESULTS_ELEMENT);
            int     numResults = results.NumValues;

            Console.WriteLine("Processing " + numResults + " results:");
            for (int i = 0; i < numResults; ++i)
            {
                Element       result = results.GetValueAsElement(i);
                StringBuilder sb     = new StringBuilder();
                foreach (Name n in CURVE_RESPONSE_ELEMENTS)
                {
                    if (sb.Length != 0)
                    {
                        sb.Append(" ");
                    }
                    sb.Append(n).Append("=").Append(result.GetElementAsString(n));
                }
                Console.WriteLine(
                    "\t{0} {1} - {2} '{3}'",
                    i + 1,
                    result.GetElementAsString(CURVE_ELEMENT),
                    result.GetElementAsString(DESCRIPTION_ELEMENT),
                    sb.ToString());
            }
        }
示例#6
0
        private void GetData(BloombergDataInstrument instrument, BB.Element fields, BB.Element secData)
        {
            #region security errors
            if (secData.HasElement(SECURITY_ERROR))
            {
                instrument.IsSecurityValid = false;
                BB.Element error = secData.GetElement(SECURITY_ERROR);
                UpdateStatus(string.Format("Security error for ticker {0} : {1}", instrument.Ticker, error.GetElementAsString(MESSAGE)));
                instrument.SecurityErrors += (error.GetElementAsString(MESSAGE) + "; ");
            }
            #endregion

            #region field errors
            if (secData.HasElement(FIELD_EXCEPTIONS))
            {
                instrument.HasFieldErrors = true;
                // process error
                BB.Element error = secData.GetElement(FIELD_EXCEPTIONS);
                for (int errorIndex = 0; errorIndex < error.NumValues; errorIndex++)
                {
                    BB.Element errorException = error.GetValueAsElement(errorIndex);
                    BB.Element errorInfo      = errorException.GetElement(ERROR_INFO);

                    instrument.BBFields[errorException.GetElementAsString(FIELD_ID)].Error = errorInfo.GetElementAsString(MESSAGE);
                    instrument.HasFieldErrors = true;
                    string msg = string.Format("Field error for ticker {0} : Field {1}: {2}",
                                               instrument.Ticker,
                                               errorException.GetElementAsString(FIELD_ID),
                                               errorInfo.GetElementAsString(MESSAGE));
                    UpdateStatus(msg);
                }
            }
            #endregion

            #region get the data
            if (instrument.BBFields != null)
            {
                lock (lockObject) {
                    foreach (string bbField in instrument.BBFields.Keys.ToList())
                    {
                        if (fields.HasElement(bbField))
                        {
                            BB.Element item = fields.GetElement(bbField);
                            if (item.IsArray)
                            {
                                instrument.BBFields[bbField].Value = processBulkData(item);
                            }
                            else
                            {
                                // set the value in the instrument field item
                                instrument.BBFields[bbField].Value = item.GetValue();
                            }
                        }
                    }
                }
            }
            #endregion
        }
示例#7
0
        /// <summary>
        /// Process a list of instruments in a response from the BLP API.
        /// </summary>
        /// <param name="msg"></param>
        private void ProcessInstrumentListResponse(Message msg)
        {
            Element results = msg.GetElement(RESULTS_ELEMENT);

            for (int i = 0; i < results.NumValues; i++)
            {
                instrument_results.Add(results.GetValueAsElement(i).GetElementAsString(SECURITY_ELEMENT));
            }
        }
示例#8
0
        protected void SetClose(ref BBCOMM.Element myElement, ref Dictionary <string, int> skipFields)
        {
            try
            {
                Close = (double)myElement.GetElementAsFloat64(CLOSE);
            }

            catch
            {
                // Some log ?
                skipFields[CLOSE] += 1;
                Close              = Double.NaN;
            }
        }
示例#9
0
        protected void SetCleanPxMid(ref BBCOMM.Element myElement, ref Dictionary <string, int> skipFields)
        {
            try
            {
                CleanPriceMid = (double)myElement.GetElementAsFloat64(CLEAN_PX_MID);
            }

            catch
            {
                // Some log ?
                skipFields[CLEAN_PX_MID] += 1;
                CleanPriceMid             = Double.NaN;
            }
        }
示例#10
0
        protected void SetAdjClose(ref BBCOMM.Element myElement, ref Dictionary <string, int> skipFields)
        {
            try
            {
                Volume = (double)myElement.GetElementAsFloat64(VOLUME);
            }

            catch
            {
                // Some log ?
                skipFields[ADJCLOSE] += 1;
                Volume = Double.NaN;
            }
        }
示例#11
0
        protected void SetDirtyPxMid(ref BBCOMM.Element myElement, ref Dictionary <string, int> skipFields)
        {
            try
            {
                DirtyPriceMid = (double)myElement.GetElementAsFloat64(DIRTY_PX_MID);
            }

            catch
            {
                // Some log ?
                skipFields[DIRTY_PX_MID] += 1;
                DirtyPriceMid             = Double.NaN;
            }
        }
示例#12
0
        protected void SetBid(ref BBCOMM.Element myElement, ref Dictionary <string, int> skipFields)
        {
            try
            {
                Bid = (double)myElement.GetElementAsFloat64(BID);
            }

            catch
            {
                // Some log ?
                skipFields[BID] += 1;
                Bid              = Double.NaN;
            }
        }
示例#13
0
        protected void SetHigh(ref BBCOMM.Element myElement, ref Dictionary <string, int> skipFields)
        {
            try
            {
                High = (double)myElement.GetElementAsFloat64(HIGH);
            }

            catch
            {
                // Some log ?
                skipFields[HIGH] += 1;
                High              = Double.NaN;
            }
        }
示例#14
0
        protected void SetLow(ref BBCOMM.Element myElement, ref Dictionary <string, int> skipFields)
        {
            try
            {
                Low = (double)myElement.GetElementAsFloat64(LOW);
            }

            catch
            {
                // Some log ?
                skipFields[LOW] += 1;
                Low              = Double.NaN;
            }
        }
示例#15
0
        protected void SetOpen(ref BBCOMM.Element myElement, ref Dictionary <string, int> skipFields)
        {
            try
            {
                Open = (double)myElement.GetElementAsFloat64(OPEN);
            }

            catch
            {
                // Some log ?
                skipFields[OPEN] += 1;
                Open              = Double.NaN;
            }
        }
示例#16
0
        protected void SetYTMMid(ref BBCOMM.Element myElement, ref Dictionary <string, int> skipFields)
        {
            try
            {
                YieldToMaturityMid = (double)myElement.GetElementAsFloat64(YTM_MID);
            }

            catch
            {
                // Some log ?
                skipFields[YTM_MID] += 1;
                YieldToMaturityMid   = Double.NaN;
            }
        }
示例#17
0
        // SET METHODS FOR YTM

        /*
         #region Set for CDS levels
         *
         * protected void SetCDS1Y(ref BBCOMM.Element myElement, ref Dictionary<string, int> skipFields)
         * {
         *  try
         *  {
         *      CDS1Y = (double)myElement.GetElementAsFloat64(CDS_1Y);
         *  }
         *
         *  catch
         *  {
         *      // Some log ?
         *      skipFields[CDS_1Y] += 1;
         *      CDS1Y = Double.NaN;
         *  }
         *
         * }
         * protected void SetCDS3Y(ref BBCOMM.Element myElement, ref Dictionary<string, int> skipFields)
         * {
         *  try
         *  {
         *      CDS3Y = (double)myElement.GetElementAsFloat64(CDS_3Y);
         *  }
         *
         *  catch
         *  {
         *      // Some log ?
         *      skipFields[CDS_3Y] += 1;
         *      CDS3Y = Double.NaN;
         *  }
         *
         * }
         * protected void SetCDS5Y(ref BBCOMM.Element myElement, ref Dictionary<string, int> skipFields)
         * {
         *  try
         *  {
         *      CDS5Y = (double)myElement.GetElementAsFloat64(CDS_5Y);
         *  }
         *
         *  catch
         *  {
         *      // Some log ?
         *      skipFields[CDS_5Y] += 1;
         *      CDS5Y = Double.NaN;
         *  }
         *
         * }
         * protected void SetCDS7Y(ref BBCOMM.Element myElement, ref Dictionary<string, int> skipFields)
         * {
         *  try
         *  {
         *      CDS7Y = (double)myElement.GetElementAsFloat64(CDS_7Y);
         *  }
         *
         *  catch
         *  {
         *      // Some log ?
         *      skipFields[CDS_7Y] += 1;
         *      CDS7Y = Double.NaN;
         *  }
         *
         * }
         * protected void SetCDS10Y(ref BBCOMM.Element myElement, ref Dictionary<string, int> skipFields)
         * {
         *  try
         *  {
         *      CDS10Y = (double)myElement.GetElementAsFloat64(CDS_10Y);
         *  }
         *
         *  catch
         *  {
         *      // Some log ?
         *      skipFields[CDS_10Y] += 1;
         *      CDS10Y = Double.NaN;
         *  }
         *
         * }
         *
         #endregion
         */


        // SET METHODS FOR ASSET SWAP SPREAD

        #region Set for CDS levels

        /*
         * protected void SetAssetSwapSpreadBid(ref BBCOMM.Element myElement, ref Dictionary<string, int> skipFields)
         * {
         *  try
         *  {
         *      AssetSwapSpreadBid = (double)myElement.GetElementAsFloat64(ASW_SPREAD_BID);
         *  }
         *
         *  catch
         *  {
         *      // Some log ?
         *      skipFields[ASW_SPREAD_BID] += 1;
         *      AssetSwapSpreadBid = Double.NaN;
         *  }
         *
         * }
         *
         *
         * protected void SetAssetSwapSpreadAsk(ref BBCOMM.Element myElement, ref Dictionary<string, int> skipFields)
         * {
         *  try
         *  {
         *      AssetSwapSpreadAsk = (double)myElement.GetElementAsFloat64(ASW_SPREAD_ASK);
         *  }
         *
         *  catch
         *  {
         *      // Some log ?
         *      skipFields[ASW_SPREAD_ASK] += 1;
         *      AssetSwapSpreadAsk = Double.NaN;
         *  }
         *
         * }
         *
         */

        protected void SetAssetSwapSpreadMid(ref BBCOMM.Element myElement, ref Dictionary <string, int> skipFields)
        {
            try
            {
                AssetSwapSpreadMid = (double)myElement.GetElementAsFloat64(ASW_SPREAD_MID);
            }

            catch
            {
                // Some log ?
                skipFields[ASW_SPREAD_MID] += 1;
                AssetSwapSpreadMid          = Double.NaN;
            }
        }
示例#18
0
        private void ProcessReferenceDataResponse(Bloomberglp.Blpapi.Message argvMessage)
        {
            Bloomberglp.Blpapi.Element tElementMsg  = argvMessage.AsElement;
            string[] tTargetAttributes              = mOtherRequestByCorrelationId[argvMessage.CorrelationID.Value].GetFieldList();
            System.Data.DataTable  tExtractedValues = this.ExtractValueByName(tElementMsg, tTargetAttributes);
            System.Data.DataColumn tNewColumn       = new System.Data.DataColumn("SECURITY");
            tNewColumn.DefaultValue = mOtherRequestByCorrelationId[argvMessage.CorrelationID.Value].mTicker;
            tExtractedValues.Columns.Add(tNewColumn);
            tNewColumn.SetOrdinal(0);
            InterfaceEventArgs tRetData = new InterfaceEventArgs(InterfaceEventArgs.xBbgMsgType.ReferenceDataResponse);

            tRetData.mData = tExtractedValues;
            mBbgMsgEvent(this, tRetData);
        }
示例#19
0
        protected void SetAsk(ref BBCOMM.Element myElement, ref Dictionary <string, int> skipFields)
        {
            try
            {
                Ask = (double)myElement.GetElementAsFloat64(ASK);
            }

            catch
            {
                // Some log ?
                skipFields[ASK] += 1;
                Ask              = Double.NaN;
            }
        }
示例#20
0
        protected void SetLast(ref BBCOMM.Element myElement, ref Dictionary <string, int> skipFields)
        {
            try
            {
                // Warning : Bloomberg displays interest rates in percentage terms
                Last = 0.01 * (double)myElement.GetElementAsFloat64(LAST);
            }

            catch
            {
                // Some log ?
                skipFields[LAST] += 1;
                Last              = 0.0;
            }
        }
示例#21
0
        /// <summary>
        /// Process a list of Govt instances in a response from the BLP API.
        /// Not fully implemented yet - does not collect results
        /// </summary>
        /// <param name="msg"></param>
        private void ProcessGovtListResponse(Message msg)
        {
            Element results    = msg.GetElement(RESULTS_ELEMENT);
            int     numResults = results.NumValues;

            Console.WriteLine("Processing " + numResults + " results:");
            for (int i = 0; i < numResults; ++i)
            {
                Element result = results.GetValueAsElement(i);
                Console.WriteLine(
                    "\t{0} {1}, {2} - {3}",
                    i + 1,
                    result.GetElementAsString(PARSEKY_ELEMENT),
                    result.GetElementAsString(NAME_ELEMENT),
                    result.GetElementAsString(TICKER_ELEMENT));
            }
        }
示例#22
0
        private List <T> ParseEvent_OLD(BbergAPI.Event response, List <T> outputContainer)
        {
            foreach (BbergAPI.Message message in response.GetMessages())
            {
                // Extract security
                BbergAPI.Element security   = message.GetElement(SECURITY_DATA);
                string           currentSec = (string)security.GetElementAsString(TICKER);

                // Extract fields
                BbergAPI.Element fields = security.GetElement(FIELD_DATA);

                int sequenceNumber = security.GetElementAsInt32(SEQUENCE_NUMBER);

                Dictionary <string, int> skipFields = this.initializeSkipFields();

                // Loop through all observation dates
                for (int i = 0; i < fields.NumValues; i++)
                {
                    // Determine type of <T> and create instance
                    var Ttype    = typeof(T);
                    var thisLine = (T)Activator.CreateInstance(Ttype);

                    // extract all field data for a single observation date
                    BbergAPI.Element observationDateFields = fields.GetValueAsElement(i);

                    string   currentStringDate = observationDateFields.GetElementAsString(DATE);
                    DateTime currentDate       = DateTime.ParseExact(currentStringDate, "yyyy-MM-dd", CultureInfo.CurrentCulture);

                    // Determine type of <T> and create instance
                    thisLine.SetDate(currentDate);
                    thisLine.SetDBID(dbid);

                    // Fill the line
                    skipFields = thisLine.SetFromBloomberg(ref observationDateFields, skipFields);

                    // Add to output container
                    outputContainer.Add(thisLine);
                }
            }

            // This kills the data inside the response object...
            this.CloseConnection();

            return(outputContainer);
        }
示例#23
0
        // added override to kill warning
        public override Dictionary <string, int> SetFromBloomberg(ref BBCOMM.Element myElement, Dictionary <string, int> skipFields)
        {
            if (skipFields[OPEN] < MAX_RETRY)
            {
                SetOpen(ref myElement, ref skipFields);
            }
            ;
            if (skipFields[HIGH] < MAX_RETRY)
            {
                SetHigh(ref myElement, ref skipFields);
            }
            ;
            if (skipFields[LOW] < MAX_RETRY)
            {
                SetLow(ref myElement, ref skipFields);
            }
            ;
            if (skipFields[CLOSE] < MAX_RETRY)
            {
                SetClose(ref myElement, ref skipFields);
            }
            ;
            if (skipFields[BID] < MAX_RETRY)
            {
                SetBid(ref myElement, ref skipFields);
            }
            ;
            if (skipFields[ASK] < MAX_RETRY)
            {
                SetAsk(ref myElement, ref skipFields);
            }
            ;
            if (skipFields[VOLUME] < MAX_RETRY)
            {
                SetVolume(ref myElement, ref skipFields);
            }
            ;
            if (skipFields[ADJCLOSE] < MAX_RETRY)
            {
                SetAdjClose(ref myElement, ref skipFields);
            }
            ;

            return(skipFields);
        }
示例#24
0
        private List <Bloomberglp.Blpapi.Element> ConvertElementArrayToList(Bloomberglp.Blpapi.Element argvElement)
        {
            List <Bloomberglp.Blpapi.Element> tReturnValue = new List <Element>();

            if (argvElement.IsArray)
            {
                for (int i = 0; i < argvElement.NumValues; i++)
                {
                    tReturnValue.Add(argvElement.GetValueAsElement(i));
                }
            }
            else
            {
                tReturnValue.Add(argvElement);
            }

            return(tReturnValue);
        }
示例#25
0
        private void InitializeRequest()
        {
            this.appendTickers();
            this.appendFields();
            this.SetRequestDates();
            this.InitializeRequestOptions();

            // conditionally, append overrides into request object
            if (overrideFields.Count > 0)
            {
                BbergAPI.Element requestOverrides = request.GetElement(OVERRIDES);
                for (int i = 0; i < overrideFields.Count; i++)
                {
                    BbergAPI.Element requestOverride = requestOverrides.AppendElement();
                    requestOverride.SetElement(FIELD_ID, overrideFields[i]);
                    requestOverride.SetElement(VALUE, overrideValues[i]);
                }
            }
        }
示例#26
0
        public override Dictionary <string, int> SetFromBloomberg(ref BBCOMM.Element myElement, Dictionary <string, int> skipFields)
        {
            if (skipFields[BID] < MAX_RETRY)
            {
                SetBid(ref myElement, ref skipFields);
            }
            ;
            if (skipFields[ASK] < MAX_RETRY)
            {
                SetAsk(ref myElement, ref skipFields);
            }
            ;
            if (skipFields[LAST] < MAX_RETRY)
            {
                SetLast(ref myElement, ref skipFields);
            }
            ;

            return(skipFields);
        }
示例#27
0
        private void ProcessRequestResponse(Bloomberglp.Blpapi.Event argvEvent)
        {
            // Loop over all of the messages in this Event
            foreach (Bloomberglp.Blpapi.Message tMsg in argvEvent)
            {
                Bloomberglp.Blpapi.Element tElementMsg         = tMsg.AsElement;
                System.Data.DataTable      tResponseErrorTable = this.ExtractValueByName(tElementMsg, mRequestResponseErrorAttributes);

                if (tResponseErrorTable.Rows.Count > 0)
                {
                    string tErrorMsg = "Message Type: " + tMsg.MessageType.ToString() + Environment.NewLine;
                    for (int i = 0; i < tResponseErrorTable.Rows.Count; i++)
                    {
                        tErrorMsg += "Error Message: " + tResponseErrorTable.Rows[i]["MESSAGE"] + ", Category: " + tResponseErrorTable.Rows[i]["SUBCATEGORY"] + Environment.NewLine;
                    }
                    InterfaceEventArgs tEventArgvs = new InterfaceEventArgs(InterfaceEventArgs.xBbgMsgType.Error, tErrorMsg);
                    mBbgMsgEvent(this, tEventArgvs);
                }

                if (tMsg.MessageType.Equals(new Bloomberglp.Blpapi.Name("HistoricalDataResponse")))
                {
                    this.ProcessHistoricalDataResponse(tMsg);
                }
                else if (tMsg.MessageType.Equals(new Bloomberglp.Blpapi.Name("IntradayTickResponse")))
                {
                    this.ProcessIntradayTickResponse(tMsg);
                }
                else if (tMsg.MessageType.Equals(new Bloomberglp.Blpapi.Name("IntradayBarResponse")))
                {
                    this.ProcessIntradayBarResponse(tMsg);
                }
                else if (tMsg.MessageType.Equals(new Bloomberglp.Blpapi.Name("ReferenceDataResponse")))
                {
                    this.ProcessReferenceDataResponse(tMsg);
                }
                else
                {
                    mBbgMsgEvent(this, new InterfaceEventArgs(InterfaceEventArgs.xBbgMsgType.Print, tMsg.ToString()));
                }
            }
        }
        public List <String> SearchTicker(String ticker)
        {
            List <String> listTicker = new List <string>();

            // request.AsElement.SetElement("partialMatch", true);
            request.AsElement.SetElement("query", ticker);// this plus the previous line permits to retrieve all the thicker that begins with T
            request.AsElement.SetElement("languageOverride", "LANG_OVERRIDE_NONE");
            request.AsElement.SetElement("maxResults", 10);
            session.SendRequest(request, null);

            bool done = false;

            while (!done)
            {
                // Grab the next Event object
                Event eventObject = session.NextEvent();
                // If this event type is Response then process the messages
                if (eventObject.Type == Event.EventType.RESPONSE)
                {
                    // Loop over all of the messages in this Event
                    foreach (Message msg in eventObject.GetMessages())
                    {
                        Console.WriteLine(msg);
                        Element secDataArray = msg.GetElement("results");

                        for (int index = 0; index < secDataArray.NumValues - 1; index++)
                        {
                            Element fieldData = secDataArray.GetValueAsElement(index);
                            if (fieldData.HasElement("security"))
                            {
                                listTicker.Add(fieldData.GetElementAsString("security"));
                            }
                        }
                    }
                    done = true;
                }
            }

            return(listTicker);
        }
示例#29
0
        private void ProcessSubscriptionData(Bloomberglp.Blpapi.Event argEvent)
        {
            foreach (Bloomberglp.Blpapi.Message tMsg in argEvent)
            {
                Bloomberglp.Blpapi.Element tElementMsg  = tMsg.AsElement;
                string[] tTargetAttributes              = mSubscriptionByCorrelationId[tMsg.CorrelationID.Value].GetFieldList();
                System.Data.DataTable  tExtractedValues = this.ExtractValueByName(tElementMsg, tTargetAttributes);
                System.Data.DataColumn tNewColumn       = new System.Data.DataColumn("SECURITY");
                tNewColumn.DefaultValue = tMsg.TopicName;
                tExtractedValues.Columns.Add(tNewColumn);
                tNewColumn.SetOrdinal(0);
                //mOutput.PrintDataTable(tExtractedValues);

                if (tExtractedValues.Rows.Count == 1)
                {
                    mMarketData[tMsg.CorrelationID.Value].UpdateMarketData(tExtractedValues);
                    InterfaceEventArgs tArgs = new InterfaceEventArgs(InterfaceEventArgs.xBbgMsgType.SubscriptionResponse);
                    tArgs.mCorrelationId = tMsg.CorrelationID.Value;
                    tArgs.mData          = tExtractedValues;
                    mBbgMsgEvent(this, tArgs);
                }
            }
        }
示例#30
0
        private void ProcessIntradayBarResponse(Bloomberglp.Blpapi.Message argvMessage)
        {
            if (mIntradayBarRequestByCorrelationId.ContainsKey(argvMessage.CorrelationID.Value))
            {
                string tTicker = mIntradayBarRequestByCorrelationId[argvMessage.CorrelationID.Value].mTicker;
                Bloomberglp.Blpapi.Element tElementMsg      = argvMessage.AsElement;
                System.Data.DataTable      tExtractedValues = this.ExtractValueByName(tElementMsg, mIntradayBarResponseDefaultAttributes);
                System.Data.DataColumn     tNewColumn       = new System.Data.DataColumn("SECURITY");
                tNewColumn.DefaultValue = tTicker;
                tExtractedValues.Columns.Add(tNewColumn);
                tNewColumn.SetOrdinal(0);
                mOutput.PrintDataTable(tExtractedValues);

                InterfaceEventArgs tEventArgvs = new InterfaceEventArgs(InterfaceEventArgs.xBbgMsgType.IntradayBarResponse);
                tEventArgvs.mData = tExtractedValues;
                mBbgMsgEvent(this, tEventArgvs);
            }
            else
            {
                InterfaceEventArgs tArgs = new InterfaceEventArgs(InterfaceEventArgs.xBbgMsgType.Error);
                tArgs.mMsg = "Unknown intraday bar response. Correlation ID: " + argvMessage.CorrelationID.Value + ". Won't parse the message.";
                mBbgMsgEvent(this, tArgs);
            }
        }