protected virtual void Init()
 {
     this.application     = new QuickFIX42Application();
     this.sessionSettings = new SessionSettings(BeAEwTZGlZaeOmY5cm.J00weU3cM6(1776));
     this.storeFactory    = (MessageStoreFactory) new FileStoreFactory(this.sessionSettings);
     this.logFactory      = (LogFactory) new FileLogFactory(this.sessionSettings);
     this.messageFactory  = (MessageFactory) new DefaultMessageFactory();
 }
        public void ValidateWithRepeatingGroupTest()
        {
            QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary("../../../spec/fix/FIX42.xml");
            QuickFix.FIX42.MessageFactory          f  = new QuickFix.FIX42.MessageFactory();

            string nul    = Message.SOH;
            string msgStr = "8=FIX.4.2" + nul + "9=87" + nul + "35=B" + nul + "34=3" + nul + "49=CLIENT1" + nul
                            + "52=20111012-22:15:55.474" + nul + "56=EXECUTOR" + nul + "148=AAAAAAA" + nul
                            + "33=2" + nul + "58=L1" + nul + "58=L2" + nul + "10=016" + nul;

            QuickFix.Fields.MsgType msgType = Message.IdentifyType(msgStr);
            string beginString = Message.ExtractBeginString(msgStr);

            Message message = f.Create(beginString, msgType.Obj);

            message.FromString(msgStr, true, dd, dd, f);

            dd.Validate(message, beginString, msgType.Obj);
        }
        [Test] // Issue #282
        public void ValidateTagSpecifiedWithoutAValue()
        {
            QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary();
            dd.LoadFIXSpec("FIX42");
            QuickFix.FIX42.MessageFactory f = new QuickFix.FIX42.MessageFactory();

            string[] msgFields = { "8=FIX.4.2", "9=70", "35=B", "34=3", "49=sender", "52=20110909-09:09:09.999", "56=target",
                                   "358=",      "148=", "33=0", "10=150" };
            string   msgStr = String.Join(Message.SOH, msgFields) + Message.SOH;

            string msgType     = "B";
            string beginString = "FIX.4.2";

            Message message = f.Create(beginString, msgType);

            message.FromString(msgStr, true, dd, dd);

            dd.CheckFieldsHaveValues = true;
            Assert.Throws <QuickFix.NoTagValue>(delegate { dd.Validate(message, beginString, msgType); });

            dd.CheckFieldsHaveValues = false;
            Assert.DoesNotThrow(delegate { dd.Validate(message, beginString, msgType); });
        }
        public void ValidateWithRepeatingGroupTest()
        {
            QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary("../../../spec/fix/FIX42.xml");
            QuickFix.FIX42.MessageFactory f = new QuickFix.FIX42.MessageFactory();

            string nul = Message.SOH;
            string msgStr = "8=FIX.4.2" + nul + "9=87" + nul + "35=B" + nul + "34=3" + nul + "49=CLIENT1" + nul
                + "52=20111012-22:15:55.474" + nul + "56=EXECUTOR" + nul + "148=AAAAAAA" + nul
                + "33=2" + nul + "58=L1" + nul + "58=L2" + nul + "10=016" + nul;

            QuickFix.Fields.MsgType msgType = Message.IdentifyType(msgStr);
            string beginString = Message.ExtractBeginString(msgStr);

            Message message = f.Create(beginString, msgType.Obj);
            message.FromString(
                msgStr,
                true,
                dd,
                dd);

            // Session.Next(message)

            dd.Validate(message, beginString, msgType.Obj);
        }
Exemple #5
0
        public static Solution Open(string file, BackgroundWorker worker, DataDictionary dd)
        {
            var sol = new Solution()
            {
                FileName = file
            };

            var             s                  = File.ReadAllText(file);
            var             r                  = new Regex("\0\0", RegexOptions.IgnoreCase);
            var             entries            = r.Split(s);
            int             i                  = 0;
            double          progress           = 0;
            double          count              = entries.Length;
            IMessageFactory _defaultMsgFactory = new QuickFix.FIX42.MessageFactory();

            sol.DataDictionary = dd;
            Entry e = null;

            foreach (var sFM in entries)
            {
                progress = (i / count) * 100;
                worker.ReportProgress((int)progress);

                DateTimeOffset dt = DateTimeOffset.MaxValue;



                if (!sFM.Contains("| Fix"))
                {
                    sol.OtherEntries.Add(new OtherEntry()
                    {
                        Content = sFM, Index = i, RawLogLine = sFM, Kind = EntryType.Data, Direction = sFM.Contains("| IN") ? Direction.IN : Direction.OUT
                    });
                    i++;
                    continue;
                }
                else if (!sFM.Contains("| Fix"))
                {
                    i++;
                    continue;
                }

                dt = DateTimeOffset.Parse(sFM.Substring(sFM.IndexOf("2016/"), sFM.IndexOf('|') - 2));
                var FM = sFM.Remove(0, sFM.IndexOf('[') + 1);
                FM = FM.Substring(0, FM.LastIndexOf(']'));
                try
                {
                    int         pos      = 0;
                    StringField protocol = Message.ExtractField(FM, ref pos);
                    StringField t        = Message.ExtractField(FM, ref pos);
                    StringField type     = Message.ExtractField(FM, ref pos);
                    var         m        = _defaultMsgFactory.Create(protocol.getValue(), type.getValue());

                    m.FromString(FM, true, dd, dd, _defaultMsgFactory);
                    e = new Entry()
                    {
                        DateTime   = dt,
                        Kind       = EntryType.Fix,
                        Index      = i,
                        Message    = m,
                        Content    = FM,
                        RawLogLine = sFM,
                        Direction  = sFM.Contains("| IN") ? Direction.IN : Direction.OUT
                    };
                }
                catch (Exception ex)
                {
                    e = new Entry()
                    {
                        DateTime = dt,
                        Index    = i,
                        Content  = FM,
                        Error    = new Error()
                        {
                            Exception     = ex,
                            Index         = i,
                            Content       = FM,
                            ErrorType     = ex is InvalidMessage ? ErrorType.Invalid : ErrorType.Syntax,
                            Message       = ex.Message,
                            ParsedMessage = sol.TryParseMessage(FM, _defaultMsgFactory, dd)
                        },
                        RawLogLine = sFM,
                        Direction  = sFM.Contains("| IN") ? Direction.IN : Direction.OUT
                    };
                }
                finally
                {
                    sol.Entries.Add(e);
                    sol.AssignEntryToBroker(e);
                }
                i++;
            }

            return(sol);
        }
Exemple #6
0
		protected virtual void Init()
		{
			this.application = new QuickFIX42Application();
			this.sessionSettings = new SessionSettings(BeAEwTZGlZaeOmY5cm.J00weU3cM6(1776));
			this.storeFactory = (MessageStoreFactory)new FileStoreFactory(this.sessionSettings);
			this.logFactory = (LogFactory)new FileLogFactory(this.sessionSettings);
			this.messageFactory = (MessageFactory)new DefaultMessageFactory();
		}
        /// <summary>
        /// Initiate a connection through QuickFix to the TT Fix Adapter
        /// </summary>
        /// <param name="cfg">configuration file name</param>
        /// <param name="p">password</param>
        /// <param name="r">reset sequence numbers - always true for this application</param>
        /// <param name="c">the mainForm control</param>
        public void initiate(string cfg, string p, bool r, Control c)
        {
            log.CreateLog(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), null);

            try
            {
                _password = p;
                _resetSession = r;
                _control = c;

                _settings = new QuickFix.SessionSettings(cfg);
                _storeFactory = new QuickFix.FileStoreFactory(_settings);
                _logFactory = new QuickFix.FileLogFactory(_settings);
                _messageFactory = new QuickFix.FIX42.MessageFactory();

                _initiator = new QuickFix.Transport.SocketInitiator(this,
                    _storeFactory,
                    _settings,
                    _logFactory,
                    _messageFactory);

                _initiator.Start();
            }
            catch (Exception ex)
            {
                updateDisplay("QuickFIX Error");
                log.WriteLog(ex.ToString());
            }
        }