コード例 #1
0
ファイル: Executor.cs プロジェクト: guojianli/fixfeed
  static void Main( string[] args )
  {
    if ( args.Length != 1 )
    {
      Console.WriteLine( "usage: executor_csharp FILE." );
      return ;
    }

    try
    {
      SessionSettings settings = new SessionSettings( args[ 0 ] );
      Application application = new Application();
      FileStoreFactory storeFactory = new FileStoreFactory( settings );
      ScreenLogFactory logFactory = new ScreenLogFactory( settings );
      MessageFactory messageFactory = new DefaultMessageFactory();
      SocketAcceptor acceptor
        = new SocketAcceptor( application, storeFactory, settings, logFactory, messageFactory );

      acceptor.start();
      Console.WriteLine("press <enter> to quit");
      Console.Read();
      acceptor.stop();
    }
    catch ( Exception e )
    {
      Console.WriteLine( e );
    }
  }
コード例 #2
0
        public void GroupCreateTest()
        {
            DefaultMessageFactory dmf = new DefaultMessageFactory();

            Group g44 = dmf.Create("FIX.4.4", "B", 33);
            Assert.IsInstanceOf<QuickFix.FIX44.News.LinesOfTextGroup>(g44);

            Group g50 = dmf.Create("FIXT.1.1", "B", 33);
            Assert.IsInstanceOf<QuickFix.FIX50.News.NoLinesOfTextGroup>(g50);
        }
コード例 #3
0
ファイル: InitiatorTests.cs プロジェクト: sw00/algo-poc
        public void ReadInput()
        {
            var file = File.ReadLines("03.JSE_Indices_recv_log.txt").ToList();
            var line = file.FirstOrDefault();

            var dd = new QuickFix.DataDictionary.DataDictionary();

            var log = line.Split(' ');

            line = log[1];

            var factory = new QuickFix.DefaultMessageFactory();

            var msgType = Message.IdentifyType(line);

            Message msg = factory.Create("", msgType.getValue());

            msg.FromString(line, true, dd, dd, factory);

            Assert.AreEqual("0", msgType.Obj);
        }
コード例 #4
0
        private FixProxyServer()
        {
            quoteRequest = new QuoteRequest();
            FileStoreFactory mesStoreFact;
            DefaultMessageFactory mesFact;

            SessionSettings sets;
            try
            {
                sets = new SessionSettings(string.Format("{0}\\{1}",
                                                         ExecutablePath.ExecPath,
                                                         SessionSettingsParser.SessionSettingsFileName));
                SessionSettingsParser.Init(string.Format("{0}\\{1}",
                                                         ExecutablePath.ExecPath,
                                                         SessionSettingsParser.SessionSettingsFileName));
                app = new FixApplication();
                app.processMessageFromBroker += MessageDispatcher.ProcessMessageFromBroker;
                mesStoreFact = new FileStoreFactory(string.Format("{0}\\log",
                                                         ExecutablePath.ExecPath));
                mesFact = new DefaultMessageFactory();

                app.OnSessionLogon += AppOnSessionLogon;
            }
            catch (Exception ex)
            {
                Logger.Error("SocketInitiator pre-create error", ex);
                throw;
            }

            try
            {
                initiator = new SocketInitiator(app, mesStoreFact, sets, mesFact);
            }
            catch (Exception ex)
            {
                Logger.Error("SocketInitiator create error", ex);
                throw;
            }
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: benofben/implier
        static void Main(string[] args)
        {
            String configFile = "SchneiderBen.cfg";

            try
            {
                SessionSettings settings = new SessionSettings(configFile);
                FixApplication application = new FixApplication();
                FileStoreFactory storeFactory = new FileStoreFactory(settings);
                ScreenLogFactory logFactory = new ScreenLogFactory(settings);
                MessageFactory messageFactory = new DefaultMessageFactory();
                SocketInitiator initiator = new SocketInitiator(application, storeFactory, settings, logFactory, messageFactory);

                initiator.start();

                Console.WriteLine("press <enter> to quit");
                Console.Read();
                initiator.stop();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
コード例 #6
0
        public Session Create(SessionID sessionID, QuickFix.Dictionary settings)
        {
            string connectionType = settings.GetString(SessionSettings.CONNECTION_TYPE);

            if (!"acceptor".Equals(connectionType) && !"initiator".Equals(connectionType))
            {
                throw new ConfigError("Invalid ConnectionType");
            }

            if ("acceptor".Equals(connectionType) && settings.Has(SessionSettings.SESSION_QUALIFIER))
            {
                throw new ConfigError("SessionQualifier cannot be used with acceptor.");
            }

            bool useDataDictionary = true;

            if (settings.Has(SessionSettings.USE_DATA_DICTIONARY))
            {
                useDataDictionary = settings.GetBool(SessionSettings.USE_DATA_DICTIONARY);
            }

            QuickFix.Fields.ApplVerID defaultApplVerID  = null;
            IMessageFactory           sessionMsgFactory = messageFactory_;

            if (sessionID.IsFIXT)
            {
                if (!settings.Has(SessionSettings.DEFAULT_APPLVERID))
                {
                    throw new ConfigError("ApplVerID is required for FIXT transport");
                }
                string rawDefaultApplVerIdSetting = settings.GetString(SessionSettings.DEFAULT_APPLVERID);

                defaultApplVerID = Message.GetApplVerID(rawDefaultApplVerIdSetting);

                // DefaultMessageFactory as created in the SessionFactory ctor cannot
                // tell the difference between FIX50 versions (same BeginString, unknown defaultApplVerId).
                // But we have the real session settings here, so we can fix that.
                // This is, of course, kind of a hack, and it should be reworked in V2 (TODO!).
                if (messageFactory_ is DefaultMessageFactory)
                {
                    sessionMsgFactory = new DefaultMessageFactory(
                        FixValues.ApplVerID.FromBeginString(rawDefaultApplVerIdSetting));
                }
            }

            DataDictionaryProvider dd = new DataDictionaryProvider();

            if (useDataDictionary)
            {
                if (sessionID.IsFIXT)
                {
                    ProcessFixTDataDictionaries(sessionID, settings, dd);
                }
                else
                {
                    ProcessFixDataDictionary(sessionID, settings, dd);
                }
            }

            int heartBtInt = 0;

            if (connectionType == "initiator")
            {
                heartBtInt = System.Convert.ToInt32(settings.GetLong(SessionSettings.HEARTBTINT));
                if (heartBtInt <= 0)
                {
                    throw new ConfigError("Heartbeat must be greater than zero");
                }
            }
            string senderDefaultApplVerId = "";

            if (defaultApplVerID != null)
            {
                senderDefaultApplVerId = defaultApplVerID.Obj;
            }

            Session session = new Session(
                application_,
                messageStoreFactory_,
                sessionID,
                dd,
                new SessionSchedule(settings),
                heartBtInt,
                logFactory_,
                sessionMsgFactory,
                senderDefaultApplVerId);

            if (settings.Has(SessionSettings.SEND_REDUNDANT_RESENDREQUESTS))
            {
                session.SendRedundantResendRequests = settings.GetBool(SessionSettings.SEND_REDUNDANT_RESENDREQUESTS);
            }
            if (settings.Has(SessionSettings.RESEND_SESSION_LEVEL_REJECTS))
            {
                session.ResendSessionLevelRejects = settings.GetBool(SessionSettings.RESEND_SESSION_LEVEL_REJECTS);
            }

            /* FIXME - implement optional settings
             * if (settings.Has(SessionSettings.CHECK_COMPID))
             *  session.SetCheckCompId(settings.GetBool(SessionSettings.CHECK_COMPID));
             */
            if (settings.Has(SessionSettings.CHECK_LATENCY))
            {
                session.CheckLatency = settings.GetBool(SessionSettings.CHECK_LATENCY);
            }
            if (settings.Has(SessionSettings.MAX_LATENCY))
            {
                session.MaxLatency = settings.GetInt(SessionSettings.MAX_LATENCY);
            }
            if (settings.Has(SessionSettings.LOGON_TIMEOUT))
            {
                session.LogonTimeout = settings.GetInt(SessionSettings.LOGON_TIMEOUT);
            }
            if (settings.Has(SessionSettings.LOGOUT_TIMEOUT))
            {
                session.LogoutTimeout = settings.GetInt(SessionSettings.LOGOUT_TIMEOUT);
            }
            if (settings.Has(SessionSettings.RESET_ON_LOGON))
            {
                session.ResetOnLogon = settings.GetBool(SessionSettings.RESET_ON_LOGON);
            }
            if (settings.Has(SessionSettings.RESET_ON_LOGOUT))
            {
                session.ResetOnLogout = settings.GetBool(SessionSettings.RESET_ON_LOGOUT);
            }
            if (settings.Has(SessionSettings.RESET_ON_DISCONNECT))
            {
                session.ResetOnDisconnect = settings.GetBool(SessionSettings.RESET_ON_DISCONNECT);
            }
            if (settings.Has(SessionSettings.REFRESH_ON_LOGON))
            {
                session.RefreshOnLogon = settings.GetBool(SessionSettings.REFRESH_ON_LOGON);
            }
            if (settings.Has(SessionSettings.PERSIST_MESSAGES))
            {
                session.PersistMessages = settings.GetBool(SessionSettings.PERSIST_MESSAGES);
            }
            if (settings.Has(SessionSettings.MILLISECONDS_IN_TIMESTAMP))
            {
                session.MillisecondsInTimeStamp = settings.GetBool(SessionSettings.MILLISECONDS_IN_TIMESTAMP);
            }
            if (settings.Has(SessionSettings.TIMESTAMP_PRECISION))
            {
                session.TimeStampPrecision = settings.GetTimeStampPrecision(SessionSettings.TIMESTAMP_PRECISION);
            }
            if (settings.Has(SessionSettings.ENABLE_LAST_MSG_SEQ_NUM_PROCESSED))
            {
                session.EnableLastMsgSeqNumProcessed = settings.GetBool(SessionSettings.ENABLE_LAST_MSG_SEQ_NUM_PROCESSED);
            }
            if (settings.Has(SessionSettings.MAX_MESSAGES_IN_RESEND_REQUEST))
            {
                session.MaxMessagesInResendRequest = settings.GetInt(SessionSettings.MAX_MESSAGES_IN_RESEND_REQUEST);
            }
            if (settings.Has(SessionSettings.SEND_LOGOUT_BEFORE_TIMEOUT_DISCONNECT))
            {
                session.SendLogoutBeforeTimeoutDisconnect = settings.GetBool(SessionSettings.SEND_LOGOUT_BEFORE_TIMEOUT_DISCONNECT);
            }
            if (settings.Has(SessionSettings.IGNORE_POSSDUP_RESEND_REQUESTS))
            {
                session.IgnorePossDupResendRequests = settings.GetBool(SessionSettings.IGNORE_POSSDUP_RESEND_REQUESTS);
            }
            if (settings.Has(SessionSettings.VALIDATE_LENGTH_AND_CHECKSUM))
            {
                session.ValidateLengthAndChecksum = settings.GetBool(SessionSettings.VALIDATE_LENGTH_AND_CHECKSUM);
            }
            if (settings.Has(SessionSettings.RESETSEQUENCE_MESSAGE_REQUIRES_ORIGSENDINGTIME))
            {
                session.RequiresOrigSendingTime = settings.GetBool(SessionSettings.RESETSEQUENCE_MESSAGE_REQUIRES_ORIGSENDINGTIME);
            }

            return(session);
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: qualityking/javacommon
        static SocketInitiator StartSocketInitiator(String configFile)
        {
            ClientInitiator app = new ClientInitiator();
            SessionSettings settings = new SessionSettings(configFile);
            QuickFix.Application application = new ClientInitiator();
            FileStoreFactory storeFactory = new FileStoreFactory(settings);
            ScreenLogFactory logFactory = new ScreenLogFactory(settings);
            MessageFactory messageFactory = new DefaultMessageFactory();

            SocketInitiator initiator = new SocketInitiator(application, storeFactory, settings, logFactory, messageFactory);
            initiator.start();
            Thread.Sleep(3000);
            return initiator;
        }
コード例 #8
0
ファイル: ServerQuickFix.cs プロジェクト: bluejack2000/core
 public bool Start(string user, string pw)
 {
     try
     {
         SessionSettings settings = new SessionSettings(_setpath);
         Application application = this;
         FileStoreFactory storeFactory = new FileStoreFactory(settings);
         FileLogFactory logFactory = new FileLogFactory(settings);
         MessageFactory messageFactory = new DefaultMessageFactory();
         acceptor = new SocketAcceptor
           (application, storeFactory, settings, logFactory /*optional*/, messageFactory);
         acceptor.start();
         _val = true;
         return true;
     }
     catch (Exception ex)
     {
         debug("exception starting server: " + ex.Message + ex.StackTrace);
         _val = false;
     }
     return false;
 }