Esempio n. 1
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);
        }
Esempio n. 2
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());
            }
        }
 /// <summary>
 /// Appends message.
 /// </summary>
 /// <param name="message">The message.</param>
 internal void AddMessage(Bloomberglp.Blpapi.Message message)
 {
     if (message != null)
     {
         CheckExceptions(message);
         Messages.Add(message);
     }
 }
Esempio n. 4
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));
            }
        }
Esempio n. 5
0
 /*****************************************************************************
 *  Function    : CheckAspectFields
 *  Description : Processes any field that can be contained within the market
 *               bar message.
 *  Arguments   : Message
 *  Returns     : void
 *****************************************************************************/
 private void CheckAspectFields(Message msg)
 {
     // extract data for each specific element
     // it's anticipated that an application will require this data
     // in the correct format.  this is retrieved for demonstration
     // but is not used later in the code.
     if (msg.HasElement(TIME))
     {
         Datetime time     = msg.GetElementAsDatetime(TIME);
         String   time_str = msg.GetElementAsString(TIME);
         System.Console.WriteLine("Time : " + time_str);
     }
     if (msg.HasElement(OPEN))
     {
         double open     = msg.GetElementAsFloat64(OPEN);
         String open_str = msg.GetElementAsString(OPEN);
         System.Console.WriteLine("Open : " + open_str);
     }
     if (msg.HasElement(HIGH))
     {
         double high     = msg.GetElementAsFloat64(HIGH);
         String high_str = msg.GetElementAsString(HIGH);
         System.Console.WriteLine("High : " + high_str);
     }
     if (msg.HasElement(LOW))
     {
         double low     = msg.GetElementAsFloat64(LOW);
         String low_str = msg.GetElementAsString(LOW);
         System.Console.WriteLine("Low : " + low_str);
     }
     if (msg.HasElement(CLOSE))
     {
         double close     = msg.GetElementAsFloat64(CLOSE);
         String close_str = msg.GetElementAsString(CLOSE);
         System.Console.WriteLine("Close : " + close_str);
     }
     if (msg.HasElement(NUMBER_OF_TICKS))
     {
         int    number_of_ticks     = msg.GetElementAsInt32(NUMBER_OF_TICKS);
         String number_of_ticks_str = msg.GetElementAsString(NUMBER_OF_TICKS);
         System.Console.WriteLine("Number of Ticks : " + number_of_ticks_str);
     }
     if (msg.HasElement(VOLUME))
     {
         long   volume     = msg.GetElementAsInt64(VOLUME);
         String volume_str = msg.GetElementAsString(VOLUME);
         System.Console.WriteLine("Volume : " + volume_str);
     }
     System.Console.WriteLine("\n");
 }
Esempio n. 6
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);
        }
Esempio n. 7
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));
            }
        }
Esempio n. 8
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);
            }
        }