Exemple #1
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;
            }
        }
Exemple #2
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;
            }
        }
Exemple #3
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;
            }
        }
Exemple #4
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;
            }
        }
Exemple #5
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;
            }
        }
Exemple #6
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;
            }
        }
Exemple #7
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;
            }
        }
Exemple #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;
            }
        }
Exemple #9
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;
            }
        }
Exemple #10
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;
            }
        }
Exemple #11
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;
            }
        }
        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;
            }
        }
Exemple #13
0
        private List <T> ParseEvent(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);

                // 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);

                    // Set the date and DBID to identify the line
                    thisLine.SetDate(currentDate);
                    thisLine.SetDBID(dbid);

                    // Fill the line with data
                    foreach (string localKey in this.fieldNames.Keys)
                    {
                        if (skip[localKey] < 10000)
                        {
                            try
                            {
                                // Warning : Bloomberg displays interest rates in percentage terms
                                thisLine[localKey] = scaling[localKey] * (double)observationDateFields.GetElementAsFloat64(fieldNames[localKey]);
                            }

                            catch
                            {
                                // Some log ?
                                skip[localKey] += 1;
                                // thisLine[localKey] = System.DBNull.Value;
                                thisLine[localKey] = null;
                                //thisLine[localKey] = 0.0;
                            }
                        }
                    }

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

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

            return(outputContainer);
        }