public QuickFix.FixMessageDescriptor GetDescriptor() { try { QuickFix.Message msg = new QuickFix.Message(); msg.FromString(_message, false, null, null); string beginString = msg.Header.GetField(QuickFix.Fields.Tags.BeginString); QuickFix.DataDictionary.DataDictionary dict = _dicSource.GetDictionaryForBeginString(beginString); QuickFix.Message theMsg = new QuickFix.Message(); theMsg.FixMessageDescriptorEnabled = true; theMsg.FromString(_message, true, dict, dict); return theMsg.GetDescriptor(); } catch (Exception ex) { Trace.TraceError("{0}: Error while parsing fix message: {1}", this, ex); return null; } }
public IList<FixMesageValidationErrorDescriptor> GetValidationErrors() { try { QuickFix.Message msg = new QuickFix.Message(); msg.FromString(_message, false, null, null); string beginString = msg.Header.GetField(QuickFix.Fields.Tags.BeginString); string msgType = msgType = msg.Header.GetField(QuickFix.Fields.Tags.MsgType); QuickFix.DataDictionary.DataDictionary dict = _dicSource.GetDictionaryForBeginString(beginString); dict.Validate(msg, beginString, msgType); return null; } catch (Exception ex) { //TODO: create a validation method on fix dictionary that retuns a list of errors instead of just throwing on the first one FixMesageValidationErrorDescriptor descr = new FixMesageValidationErrorDescriptor(); descr.Message = ex.Message; return new List<FixMesageValidationErrorDescriptor>(new FixMesageValidationErrorDescriptor[] { descr }); } }
public QuickFix.FixMessageDescriptor GetDescriptor() { try { QuickFix.Message msg = new QuickFix.Message(); msg.FromString(_message, false, null, null); string beginString = msg.Header.GetField(QuickFix.Fields.Tags.BeginString); QuickFix.DataDictionary.DataDictionary dict = _dicSource.GetDictionaryForBeginString(beginString); QuickFix.Message theMsg = new QuickFix.Message(); theMsg.FixMessageDescriptorEnabled = true; theMsg.FromString(_message, true, dict, dict); return(theMsg.GetDescriptor()); } catch (Exception ex) { Trace.TraceError("{0}: Error while parsing fix message: {1}", this, ex); return(null); } }
public IList <FixMesageValidationErrorDescriptor> GetValidationErrors() { try { QuickFix.Message msg = new QuickFix.Message(); msg.FromString(_message, false, null, null); string beginString = msg.Header.GetField(QuickFix.Fields.Tags.BeginString); string msgType = msgType = msg.Header.GetField(QuickFix.Fields.Tags.MsgType); QuickFix.DataDictionary.DataDictionary dict = _dicSource.GetDictionaryForBeginString(beginString); dict.Validate(msg, beginString, msgType); return(null); } catch (Exception ex) { //TODO: create a validation method on fix dictionary that retuns a list of errors instead of just throwing on the first one FixMesageValidationErrorDescriptor descr = new FixMesageValidationErrorDescriptor(); descr.Message = ex.Message; return(new List <FixMesageValidationErrorDescriptor>(new FixMesageValidationErrorDescriptor[] { descr })); } }
public bool Send(string msgStr) { QuickFix.Fields.MsgType msgType = QuickFix.Message.IdentifyType(msgStr); string beginString = QuickFix.Message.ExtractBeginString(msgStr); QuickFix.Message message = messageFactory.Create(beginString, msgType.Obj); QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary(); message.FromString(msgStr, false, dd, dd, _defaultMsgFactory); if (!msgLookup.ContainsKey(msgType.getValue())) { msgLookup.Add(msgType.getValue(), new Queue <QuickFix.Message>()); } msgLookup[msgType.getValue()].Enqueue(message); QuickFix.Fields.PossDupFlag possDup = new QuickFix.Fields.PossDupFlag(false); if (message.Header.IsSetField(possDup)) { message.Header.GetField(possDup); } if (possDup.getValue() && msgType.getValue() != QuickFix.Fields.MsgType.SEQUENCE_RESET) { dups.Enqueue(message); } return(true); }
public QuickFix.Message ReadNewOrderMultilegBytes() { var msg = new QuickFix.Message(); msg.FromString(newOrderMultilegBytes, true, dataDictionary, dataDictionary, msgFactory); return(msg); }
public QuickFix.Message ReadQuoteStatusRequestWithNestedGrp() { var msg = new QuickFix.Message(); msg.FromString(quoteStatusRequestWithNestedGrpsBytes, true, dataDictionary, dataDictionary, msgFactory); return(msg); }
public QuickFix.Message ReadMarketDataRequest() { var msg = new QuickFix.Message(); msg.FromString(marketDataRequestBytes, true, dataDictionary, dataDictionary, msgFactory); return(msg); }
public string BuildJSONFromString(string s, bool validateMsg = false, bool correctChks = true) { DateTime?logTimeStamp = null; int fixStart = s.IndexOf("8=FIX"); if (fixStart > 0) { string dateString = s.Substring(0, fixStart - 1); dateString = dateString.TrimEnd('\x01', ':', ' '); string format = "yyyyMMdd-HH:mm:ss.fff"; DateTime dateTime; if (DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime)) { logTimeStamp = dateTime; } s = s.Substring(fixStart); } var msg = new QuickFix.Message(); var chksTuple = new Tuple <string, string>(string.Empty, string.Empty); string sOrigChks = null; if (correctChks) { if (!Utils.VerifyChecksum(ref s, out chksTuple, fixChecksum: true)) { sOrigChks = chksTuple.Item1; } } //--------------------------------------------------------------------------------------- msg.FromString(s, validateMsg, sessionDataDictionary, dataDictionary, messageFactory); //--------------------------------------------------------------------------------------- MsgType msgType = QuickFix.Message.IdentifyType(s); //Very inefficient. Need to rewrite to build JSON myself. XElement xElem = BuildXML(msg, msgType, logTimeStamp, sOrigChks); string jsonText = JsonConvert.SerializeXmlNode(xElem.GetXmlNode()); //================================================================= return(jsonText); //JTokenWriter writer = new JTokenWriter(); //writer.WriteStartObject(); //writer.WritePropertyName("name1"); //writer.WriteValue("value1"); //writer.WritePropertyName("name2"); //writer.WriteStartArray(); //writer.WriteValue(1); //writer.WriteValue(2); //writer.WriteEndArray(); //writer.WriteEndObject(); //JObject o = (JObject)writer.Token; //return o.ToString(); }