Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("=============");
            Console.WriteLine("This is for evaluating new QF/n builds and features.");
            Console.WriteLine("It's designed to communicate with PilotAcceptor44.");
            Console.WriteLine("=============");

            if (args.Length != 1)
            {
                System.Console.WriteLine("usage: PilotInitiator44.exe CONFIG_FILENAME");
                System.Environment.Exit(2);
            }

            string file = args[0];

            try
            {
                QuickFix.SessionSettings settings = new QuickFix.SessionSettings(file);
                PilotInit44App myApp = new PilotInit44App();
                QuickFix.IMessageStoreFactory storeFactory = new QuickFix.FileStoreFactory(settings);
                QuickFix.ILogFactory logFactory = new QuickFix.FileLogFactory(settings);
                QuickFix.Transport.SocketInitiator initiator = new QuickFix.Transport.SocketInitiator(myApp, storeFactory, settings, logFactory);

                initiator.Start();
                myApp.Run();
                initiator.Stop();
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            //SessionSettings settings = new SessionSettings("config.txt");
            SessionSettings settings = new SessionSettings();

            settings.Set(defaults);
            settings.Set(new SessionID("FIX.4.4", Guid.NewGuid().ToString(), "DERIBITSERVER"), new Dictionary("SESSION", new System.Collections.Generic.Dictionary <string, string>()
            {
                { "BeginString", "FIX.4.4" },
                //  {"SenderCompID",Guid.NewGuid().ToString() },
                //  {"ConnectionType","initiator" }
            }));
            // settings.Set(session);

            DerbitFixClient application = new DerbitFixClient();

            IMessageStoreFactory storeFactory = new FileStoreFactory(settings);
            ILogFactory          logFactory   = new FileLogFactory(settings);

            QuickFix.Transport.SocketInitiator initiator = new QuickFix.Transport.SocketInitiator(application, storeFactory, settings, logFactory);

            // this is a developer-test kludge.  do not emulate.
            application.MyInitiator = initiator;

            initiator.Start();
            //application.QuerySecurityListRequest();
            application.Run();
            initiator.Stop();
        }
Exemplo n.º 3
0
    private void btn_start_fix_Click(object sender, EventArgs e)
    {
        BTCCFIXClientApp     app          = new BTCCFIXClientApp();
        string               sessionFile  = Environment.CurrentDirectory + @"\session_client.txt";
        SessionSettings      settings     = new SessionSettings(sessionFile);
        IMessageStoreFactory storeFactory = new FileStoreFactory(settings);
        ILogFactory          logFactory   = new FileLogFactory(settings);

        QuickFix.Transport.SocketInitiator initiator = new QuickFix.Transport.SocketInitiator(app, storeFactory, settings, logFactory);
        initiator.Start();

        BTCCMarketDataRequest btccDataRequest = new BTCCMarketDataRequest();

        System.Threading.Thread.Sleep(5000);
        //request full snapshot
        MarketDataRequest dataRequest = btccDataRequest.marketDataFullSnapRequest("BTCCNY");
        bool ret = Session.SendToTarget(dataRequest, app.m_sessionID);

        Console.WriteLine("SendToTarget ret={0}", ret);

        //			dataRequest = btccDataRequest.marketDataFullSnapRequest("LTCCNY");
        //			ret = Session.SendToTarget(dataRequest, app.m_sessionID);
        //			Console.WriteLine("SendToTarget ret={0}", ret);

        //			dataRequest = btccDataRequest.marketDataFullSnapRequest("LTCBTC");
        //			ret = Session.SendToTarget(dataRequest, app.m_sessionID);
        //			Console.WriteLine("SendToTarget ret={0}", ret);

        System.Threading.Thread.Sleep(15000);
        //request incremental request
        dataRequest = btccDataRequest.marketDataIncrementalRequest("BTCCNY");
        ret         = Session.SendToTarget(dataRequest, app.m_sessionID);
        Console.WriteLine("SendToTarget ret={0}", ret);

        //			dataRequest = btccDataRequest.marketDataIncrementalRequest("LTCCNY");
        //			ret = Session.SendToTarget(dataRequest, app.m_sessionID);
        //			Console.WriteLine("SendToTarget ret={0}", ret);

        //			dataRequest = btccDataRequest.marketDataIncrementalRequest("LTCBTC");
        //			ret = Session.SendToTarget(dataRequest, app.m_sessionID);
        //			Console.WriteLine("SendToTarget ret={0}", ret);

        System.Threading.Thread.Sleep(40000);
        //unsubscribe incremental request
        dataRequest = btccDataRequest.unsubscribeIncrementalRequest("BTCCNY");
        ret         = Session.SendToTarget(dataRequest, app.m_sessionID);
        Console.WriteLine("SendToTarget ret={0}", ret);

        //			dataRequest = btccDataRequest.unsubscribeIncrementalRequest("LTCCNY");
        //			ret = Session.SendToTarget(dataRequest, app.m_sessionID);
        //			Console.WriteLine("SendToTarget ret={0}", ret);

        //			dataRequest = btccDataRequest.unsubscribeIncrementalRequest("LTCBTC");
        //			ret = Session.SendToTarget(dataRequest, app.m_sessionID);
        //			Console.WriteLine("SendToTarget ret={0}", ret);
    }
Exemplo n.º 4
0
        public void Connect(IApplication application)
        {
            var settings = new SessionSettings("session.config");
            var myApp = application;
            var storeFactory = new FileStoreFactory(settings);
            var logFactory = new FileLogFactory(settings);

            initiator = new SocketInitiator(myApp, storeFactory, settings, logFactory);

            initiator.Start();
        }
Exemplo n.º 5
0
    private void btn_start_fix_Click(object sender, EventArgs e)
    {
        BTCCFIXClientApp app = new BTCCFIXClientApp();
        string sessionFile = Environment.CurrentDirectory + @"\session_client.txt";
        SessionSettings settings = new SessionSettings(sessionFile);
        IMessageStoreFactory storeFactory = new FileStoreFactory(settings);
        ILogFactory logFactory = new FileLogFactory(settings);
        QuickFix.Transport.SocketInitiator initiator = new QuickFix.Transport.SocketInitiator(app, storeFactory, settings, logFactory);
        initiator.Start();

        BTCCMarketDataRequest btccDataRequest = new BTCCMarketDataRequest();

        System.Threading.Thread.Sleep(5000);
        //request full snapshot
        MarketDataRequest dataRequest = btccDataRequest.marketDataFullSnapRequest("BTCCNY");
        bool ret = Session.SendToTarget(dataRequest, app.m_sessionID);
        Console.WriteLine("SendToTarget ret={0}", ret);

        //			dataRequest = btccDataRequest.marketDataFullSnapRequest("LTCCNY");
        //			ret = Session.SendToTarget(dataRequest, app.m_sessionID);
        //			Console.WriteLine("SendToTarget ret={0}", ret);

        //			dataRequest = btccDataRequest.marketDataFullSnapRequest("LTCBTC");
        //			ret = Session.SendToTarget(dataRequest, app.m_sessionID);
        //			Console.WriteLine("SendToTarget ret={0}", ret);

        System.Threading.Thread.Sleep(15000);
        //request incremental request
        dataRequest = btccDataRequest.marketDataIncrementalRequest("BTCCNY");
        ret = Session.SendToTarget(dataRequest, app.m_sessionID);
        Console.WriteLine("SendToTarget ret={0}", ret);

        //			dataRequest = btccDataRequest.marketDataIncrementalRequest("LTCCNY");
        //			ret = Session.SendToTarget(dataRequest, app.m_sessionID);
        //			Console.WriteLine("SendToTarget ret={0}", ret);

        //			dataRequest = btccDataRequest.marketDataIncrementalRequest("LTCBTC");
        //			ret = Session.SendToTarget(dataRequest, app.m_sessionID);
        //			Console.WriteLine("SendToTarget ret={0}", ret);

        System.Threading.Thread.Sleep(40000);
        //unsubscribe incremental request
        dataRequest = btccDataRequest.unsubscribeIncrementalRequest("BTCCNY");
        ret = Session.SendToTarget(dataRequest, app.m_sessionID);
        Console.WriteLine("SendToTarget ret={0}", ret);

        //			dataRequest = btccDataRequest.unsubscribeIncrementalRequest("LTCCNY");
        //			ret = Session.SendToTarget(dataRequest, app.m_sessionID);
        //			Console.WriteLine("SendToTarget ret={0}", ret);

        //			dataRequest = btccDataRequest.unsubscribeIncrementalRequest("LTCBTC");
        //			ret = Session.SendToTarget(dataRequest, app.m_sessionID);
        //			Console.WriteLine("SendToTarget ret={0}", ret);
    }
Exemplo n.º 6
0
        void StartEngine(bool initiator)
        {
            TestApplication application = new TestApplication(LogonCallback, LogoffCallback);
            IMessageStoreFactory storeFactory = new MemoryStoreFactory();
            ILogFactory logFactory = new ScreenLogFactory(false, false, false);
            SessionSettings settings = new SessionSettings();

            if (initiator)
            {
                Dictionary defaults = new Dictionary();
                defaults.SetString(SessionSettings.RECONNECT_INTERVAL, "1");
                settings.Set(defaults);
                settings.Set(CreateSessionID(StaticInitiatorCompID), CreateSessionConfig(StaticInitiatorCompID, true));
                _initiator = new SocketInitiator(application, storeFactory, settings, logFactory);
                _initiator.Start();
            }
            else
            {
                settings.Set(CreateSessionID(StaticAcceptorCompID), CreateSessionConfig(StaticAcceptorCompID, false));
                _acceptor = new ThreadedSocketAcceptor(application, storeFactory, settings, logFactory);
                _acceptor.Start();
            }
        }
Exemplo n.º 7
0
        void StartEngine(bool initiator)
        {
            TestApplication application = new TestApplication(LogonCallback, LogoffCallback);
            IMessageStoreFactory storeFactory = new MemoryStoreFactory();
            SessionSettings settings = new SessionSettings();
            Dictionary defaults = new Dictionary();
            defaults.SetString(QuickFix.SessionSettings.FILE_LOG_PATH, LogPath);

            // Put IP endpoint settings into default section to verify that that defaults get merged into
            // session-specific settings not only for static sessions, but also for dynamic ones
            defaults.SetString(SessionSettings.SOCKET_CONNECT_HOST, Host);
            defaults.SetString(SessionSettings.SOCKET_CONNECT_PORT, ConnectPort.ToString());
            defaults.SetString(SessionSettings.SOCKET_ACCEPT_HOST, Host);
            defaults.SetString(SessionSettings.SOCKET_ACCEPT_PORT, AcceptPort.ToString());

            settings.Set(defaults);
            ILogFactory logFactory = new FileLogFactory(settings);

            if (initiator)
            {
                defaults.SetString(SessionSettings.RECONNECT_INTERVAL, "1");
                settings.Set(CreateSessionID(StaticInitiatorCompID), CreateSessionConfig(StaticInitiatorCompID, true));
                _initiator = new SocketInitiator(application, storeFactory, settings, logFactory);
                _initiator.Start();
            }
            else
            {
                settings.Set(CreateSessionID(StaticAcceptorCompID), CreateSessionConfig(StaticAcceptorCompID, false));
                _acceptor = new ThreadedSocketAcceptor(application, storeFactory, settings, logFactory);
                _acceptor.Start();
            }
        }
Exemplo n.º 8
0
        public void Start()
        {
            try
            {
                logger.Info("FixInitiatorDropCopy Start(): Iniciando FixInitiatorDropCopy....");
                _running = true;


                // Buscar Application Path para compor diretorios de dicionario e afins(Substring(6) para retirar 'file:\')
                string path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(FixInitiatorDropCopy)).CodeBase).Substring(6);
                //logger.Info("Application Path: " + path);

                // Cria sessao que será usada para mandar as mensagens
                _session = new SessionID(_config.BeginString, _config.SenderCompID, _config.TargetCompID);

                // Cria dicionario da configuracao
                Dictionary mainDic = new Dictionary();

                mainDic.SetLong("SocketConnectPort", _config.SocketPort);
                mainDic.SetLong("HeartBtInt", _config.HeartBtInt);
                mainDic.SetLong("ReconnectInterval", _config.ReconnectInterval);

                mainDic.SetBool("ResetOnLogon", _config.ResetSeqNum);
                mainDic.SetBool("PersistMessages", _config.PersistMessages);

                // Ver
                // ret.setString("ConnectionType", ConnectionType.ToLower());
                mainDic.SetString("ConnectionType", _config.ConnectionType.ToLower());
                mainDic.SetString("SocketConnectHost", _config.Host);
                mainDic.SetString("FileStorePath", path + Path.DirectorySeparatorChar + _config.FileStorePath);

                //string  = path + Path.DirectorySeparatorChar + info.DataDictionary;

                logger.Debug("FileLogPath: " + path + Path.DirectorySeparatorChar + _config.FileLogPath);
                mainDic.SetString("FileLogPath", path + Path.DirectorySeparatorChar + _config.FileLogPath);
                mainDic.SetString("DebugFileLogPath", path + Path.DirectorySeparatorChar + _config.DebugFileLogPath);
                mainDic.SetString("StartTime", _config.StartTime);
                mainDic.SetString("EndTime", _config.EndTime);
                mainDic.SetString("ConnectionType", "initiator");

                Dictionary sessDic = new Dictionary();

                sessDic.SetString("BeginString", _config.BeginString);
                sessDic.SetString("SenderCompID", _config.SenderCompID);
                sessDic.SetString("TargetCompID", _config.TargetCompID);
                sessDic.SetString("DataDictionary", path + Path.DirectorySeparatorChar + _config.DataDictionary);
                sessDic.SetBool("UseDataDictionary", _config.UseDataDictionary);

                // Configure the session settings
                SessionSettings settings = new SessionSettings();

                settings.Set(mainDic);
                settings.Set(_session, sessDic);

                //FileStoreFactory store = new FileStoreFactory(settings);
                MemoryStoreFactory store = new MemoryStoreFactory();
                FileLogFactory     logs  = new FileLogFactory(settings);
                IMessageFactory    msgs  = new DefaultMessageFactory();
                logger.InfoFormat("Iniciando ThreadedSocketInitiator...  SenderCompID: [{0}] TargetCompID: [{1}] SocketConnectHost:[{2}] SocketConnectPort:[{3}]",
                                  _config.SenderCompID, _config.TargetCompID, _config.Host, _config.SocketPort);
                _socketInitiator = new SocketInitiator(this, store, settings, logs, msgs);
                _socketInitiator.Start();

                // Thread para receber as mensagens de acceptors
                _thToDb = new Thread(new ThreadStart(this._sendtoDb));
                _thToDb.Start();

                logger.Info("FixInitiatorDropCopy Start(): Fim de inicializacao FixInitiator....");
            }

            catch (Exception ex)
            {
                logger.Error("Erro ao inicializar Fix Initiator DropCopy", ex);
                throw ex;
            }
        }