Beispiel #1
0
 protected virtual void OnReplyError(SerialEventArgs info)
 {
     if (ReplyError != null)
     {
         Task.Run(() => ReplyError?.Invoke(this, info));
     }
 }
Beispiel #2
0
 // Receptor ConfigError
 // Ocurrio un error iniciando DbHandler o cargando configuracion, informar y cerrar.
 static private void ModuleStartError(ReplyError reply)
 {
     //Builder.Output("Error: " + reply.Message, System.Diagnostics.TraceEventType.Error);
     Detenerse = true;
     _errMsg   = reply.Message;
     _areEsperaOperacion.Set();
 }
Beispiel #3
0
        protected virtual void OnReplyError(SerialEventArgs info)
        {
            WriteLastCommandReplyType(EReplyType.ReplyError);

            if (ReplyError != null)
            {
                Task.Run(() => ReplyError?.Invoke(this, info));
            }
        }
Beispiel #4
0
        private Dictionary <string, BasicQuotation> BuildProviderResultsIndex(Reply reply)
        {
            // build the provider result set
            DateTime dtNow = DateTime.Now;
            //InformationSource informationSource = ;
            // key = provider instrument id / field name
            var results = new Dictionary <string, BasicQuotation>();
            SecuritiesDataCollection securityColl = reply.GetSecurityDataItems();

            foreach (SecurityDataItem security in securityColl)
            {
                string instrName = security.Security.Name;
                //int fieldCount = security.FieldsData.Count;
                //BasicAssetValuation quote = new BasicAssetValuation() { objectReference = new AnyAssetReference() { href = instrName } };
                //quote.quote = new BasicQuotation[fieldCount];
                int fieldNum = 0;
                foreach (FieldDataItem dataNodeList in security.FieldsData)
                {
                    string fieldName        = dataNodeList.Field.Mnemonic;
                    string providerQuoteKey = FormatProviderQuoteKey(instrName, fieldName);
                    var    providerQuote    = new BasicQuotation();
                    // field value
                    object value = null;
                    string measureTypeAsString = AssetMeasureEnum.Undefined.ToString();
                    string quoteUnitsAsString  = PriceQuoteUnitsEnum.Undefined.ToString();
                    try
                    {
                        DataPoint point = dataNodeList.DataPoints[0];
                        value = point.Value;
                        if (point.IsError)
                        {
                            // bloomberg error
                            ReplyError replyError = point.ReplyError;
                            Logger.LogDebug("ReplyError: {0}/{1}={2}/{3}/{4}",
                                            instrName, fieldName, replyError.Code, replyError.DisplayName, replyError.Description);
                            quoteUnitsAsString = String.Format("{0}:{1}", replyError.Code, replyError.DisplayName);
                        }
                        else if (value == null)
                        {
                            // value mia
                            Logger.LogDebug("DataNullMissing: {0}/{1}='{2}'", instrName, fieldName);
                            quoteUnitsAsString = "DataNullMissing";
                        }
                        else if (value.GetType() == typeof(ReplyError))
                        {
                            // bloomberg error
                            var replyError = (ReplyError)value;
                            Logger.LogDebug("ReplyError: {0}/{1}={2}/{3}/{4}",
                                            instrName, fieldName, replyError.Code, replyError.DisplayName, replyError.Description);
                            quoteUnitsAsString = $"{replyError.Code}:{replyError.DisplayName}";
                        }
                        else if ((value is string) && (value.ToString().ToLower() == "n.a."))
                        {
                            // not available?
                            Logger.LogDebug("DataNotAvailable: {0}/{1}='{2}'", instrName, fieldName, value.ToString());
                            quoteUnitsAsString = "DataNotAvailable";
                        }
                        else
                        {
                            providerQuote.value          = Convert.ToDecimal(value);
                            providerQuote.valueSpecified = true;
                            // When the quote was computed (FpML definition) i.e. when the provider published it
                            providerQuote.valuationDateSpecified = true;
                            providerQuote.valuationDate          = point.Time;
                        }
                    }
                    catch (Exception e)
                    {
                        Logger.LogDebug("Exception: {0}/{1}='{2}' {3}", instrName, fieldName, value, e);
                        quoteUnitsAsString = $"{e.GetType().Name}:{e.Message}";
                    }
                    providerQuote.measureType = new AssetMeasureType {
                        Value = measureTypeAsString
                    };
                    providerQuote.quoteUnits = new PriceQuoteUnits {
                        Value = quoteUnitsAsString
                    };
                    providerQuote.informationSource = new[]
                    {
                        new InformationSource
                        {
                            rateSource = new InformationProvider {
                                Value = ProviderId.ToString()
                            },
                            rateSourcePage = new RateSourcePage {
                                Value = instrName + "/" + fieldName
                            }
                        }
                    };
                    // When the quote was observed or derived (FpML definition) i.e. now.
                    providerQuote.timeSpecified = true;
                    providerQuote.time          = dtNow;
                    results[providerQuoteKey]   = providerQuote;
                    // next field
                    fieldNum++;
                } // foreach field
            }     // foreach instr
            return(results);
        }