示例#1
0
        static void Main(string[] args)
        {
            AppLogger = new PerDayFileLogSource(Directory.GetCurrentDirectory() + "\\Log", Directory.GetCurrentDirectory() + "\\Log\\Backup")
            {
                FilePattern = "Log.{0:yyyy-MM-dd}.log",
                DeleteDays  = 20
            };

            string path = ConfigurationManager.AppSettings["InitiatorPath"];

            SessionSettings  = new SessionSettings(path);
            FileStoreFactory = new FileStoreFactory(SessionSettings);
            ScreenLogFactory = new ScreenLogFactory(SessionSettings);
            MessageFactory   = new QuickFix.FIX44.MessageFactory();

            Program myProgram = new Program();

            Initiator = new SocketInitiator(myProgram, FileStoreFactory, SessionSettings, ScreenLogFactory);

            Initiator.Start();


            Console.WriteLine("Initiator successfully started...");
            Console.ReadKey();
        }
示例#2
0
        static void Main()
        {
            try
            {
                ClientInitiator      app            = new ClientInitiator();
                SessionSettings      settings       = new SessionSettings(@"C:\Users\anhtv\Desktop\QuickFix\QuickFix\initiator.cfg");
                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);
                System.Collections.ArrayList list = initiator.getSessions();
                SessionID sessionID = (SessionID)list[0];
                Console.WriteLine("Press any key: ");
                string x = Console.ReadLine();
                QuickFix42.NewOrderSingle order = new QuickFix42.NewOrderSingle(new ClOrdID("Hello"), new HandlInst(HandlInst.AUTOMATED_EXECUTION_ORDER_PRIVATE), new Symbol("ABC"), new Side(Side.SELL), new TransactTime(DateTime.Now), new OrdType(OrdType.MARKET));
                bool sent = Session.sendToTarget(order, sessionID);
                Console.ReadLine();
                initiator.stop();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Console.ReadLine();
            }
        }
示例#3
0
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.WriteLine("usage: Executor CONFIG_FILENAME");
                System.Environment.Exit(2);
            }

            try
            {
                SessionSettings        settings     = new SessionSettings(args[0]);
                Application            executorApp  = new Executor();
                MessageStoreFactory    storeFactory = new FileStoreFactory(settings);
                LogFactory             logFactory   = new ScreenLogFactory(settings);
                ThreadedSocketAcceptor acceptor     = new ThreadedSocketAcceptor(executorApp, storeFactory, settings, logFactory);

                acceptor.Start();
                Console.WriteLine("press <enter> to quit");
                Console.Read();
                acceptor.Stop();
            }
            catch (System.Exception e)
            {
                Console.WriteLine("FATAL ERROR: " + e.Message);
                Console.WriteLine(e.ToString());
            }
        }
示例#4
0
        public OKCMarketFIXAPI(string keyfile, string symbol, bool orderbook, bool livetrade)
        {
            SessionSettings settings     = new SessionSettings("config/quickfix-client.cfg");
            var             storeFactory = new FileStoreFactory(settings);
            var             logFactory   = new ScreenLogFactory(settings);

            Initiator = new QuickFix.Transport.SocketInitiator(this, storeFactory, settings, logFactory);
            Initiator.Start();

            OrderCancelCallback = null;
            OrderSubmitCallback = null;

            AccountUtil.ReadKeyFile(keyfile);
            TradeSymbolString               = symbol;
            TradeSymbol                     = new Symbol(symbol);
            OKTradingRequest.TradeSymbol    = TradeSymbol;
            OKMarketDataRequest.TradeSymbol = TradeSymbol;
            CurrentOrders                   = new List <Order>();
            if (orderbook)
            {
                CurrentOrderBook = new OrderBook();
            }

            LastTrade      = null;
            TrackOrderBook = orderbook;
            TrackLiveTrade = livetrade;
        }
示例#5
0
        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);
            }
        }
        public bool StartSession(string strHostName, int nPort, string strSenderCompID, string strTargetCompID, string strPassword)
        {
            try
            {
                if (!IsPortOpen(strHostName, nPort, new TimeSpan(0, 0, 10)))
                {
                    return(false);
                }

                string strAppDirPath = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);

                QuickFix.Dictionary dicConfig = new QuickFix.Dictionary();
                dicConfig.SetString("ConnectionType", "initiator");
                dicConfig.SetDay("StartDay", DayOfWeek.Sunday);
                dicConfig.SetString("StartTime", "00:00:00");
                dicConfig.SetDay("EndDay", DayOfWeek.Saturday);
                dicConfig.SetString("EndTime", "00:00:00");
                dicConfig.SetDouble("HeartBtInt", 20);
                dicConfig.SetDouble("ReconnectInterval", 10);
                dicConfig.SetBool("ResetOnLogout", true);
                dicConfig.SetBool("ResetOnLogon", true);
                dicConfig.SetBool("ResetOnDisconnect", true);
                dicConfig.SetBool("ResetSeqNumFlag", true);
                dicConfig.SetDouble("EncryptMethod", 0);
                dicConfig.SetBool("CheckLatency", false);
                dicConfig.SetString("FileStorePath", strAppDirPath + "/Store/Ctrader_Price");
                dicConfig.SetString("FileLogPath", strAppDirPath + "/Log");
                dicConfig.SetBool("UseDataDictionary", true);
                dicConfig.SetString("DataDictionary", strAppDirPath + "/Settings/FIX44-OneZero.xml");
                dicConfig.SetBool("ScreenLogShowIncoming", false);
                dicConfig.SetBool("ScreenLogShowOutgoing", false);
                dicConfig.SetString("Password", strPassword);

                SessionID           quoteSessionID  = new SessionID("FIX.4.4", strSenderCompID, strTargetCompID);
                QuickFix.Dictionary dicQuoteSession = new QuickFix.Dictionary();
                dicQuoteSession.SetString("SocketConnectHost", strHostName);
                dicQuoteSession.SetDouble("SocketConnectPort", nPort);

                settings = new SessionSettings();
                settings.Set(dicConfig);
                settings.Set(quoteSessionID, dicQuoteSession);

                FileStoreFactory storeFactory = new FileStoreFactory(settings);
                ScreenLogFactory logFactory   = new ScreenLogFactory(settings);
                initiator = new SocketInitiator(this, storeFactory, settings, logFactory);
                initiator.Start();
                return(true);
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e.Message);
                return(false);
            }
        }
        static void Main(string[] args)
        {
            SessionSettings settings = new SessionSettings(@"C:\acceptor.cfg");
            Startup application = new Startup();

            FileStoreFactory storeFactory = new FileStoreFactory(settings);
            ScreenLogFactory logFactory = new ScreenLogFactory(settings);
            IMessageFactory messageFactory = new DefaultMessageFactory();
            ThreadedSocketAcceptor server = new ThreadedSocketAcceptor(application, storeFactory, settings, logFactory, messageFactory);

            server.Start();
            Console.WriteLine("####### Server Socket Fix Start ...press <enter> to quit");

            Console.Read();
            server.Stop();
        }
示例#8
0
        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);
        }
示例#9
0
        public override bool Initialize(OnMessageReceived pOnPublishMessage, OnLogMessage pOnLogMsg, string configFile)
        {
            try
            {
                this.ModuleConfigFile  = configFile;
                this.DoPublishMessage += pOnPublishMessage;
                this.OnLogMsg         += pOnLogMsg;

                if (LoadConfig(configFile))
                {
                    SentOrders     = new Dictionary <string, string>();
                    SendersDict    = new Dictionary <int, string>();
                    KeysDict       = new Dictionary <int, string>();
                    TestingModules = new Dictionary <string, ICommunicationModule>();

                    FIXMessageCreator = new FIXMessageCreator();

                    string path = Configuration.InitiatorCfg;
                    TestingModulesInitialized = false;

                    SessionSettings  = new SessionSettings(path);
                    FileStoreFactory = new FileStoreFactory(SessionSettings);
                    ScreenLogFactory = new ScreenLogFactory(SessionSettings);
                    MessageFactory   = new QuickFix.FIX44.MessageFactory();

                    Initiator = new SocketInitiator(this, FileStoreFactory, SessionSettings, ScreenLogFactory);

                    Initiator.Start();

                    return(true);
                }
                else
                {
                    DoLog("Error initializing config file " + configFile, Constants.MessageType.Error);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                DoLog("Critic error initializing " + configFile + ":" + ex.Message, Constants.MessageType.Error);
                return(false);
            }
        }
示例#10
0
        static void Main(string[] args)
        {
            try
            {
                SessionSettings      settings       = new SessionSettings(@"C:\Users\anhtv\Desktop\QuickFix\QuickFix\acceptor1.cfg");
                FixServerApplication application    = new FixServerApplication();
                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.ToString());
            }
        }
示例#11
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();
            }
        }
示例#12
0
        //private static ILogger l = LionFire.Logging.Log.Get();

        //static string BrokerUID = "cServer";

        static void Main(string[] args)
        {
            //l.Info($"----- {typeof(Program).FullName}.Main() -----");

            //SessionSettings settings = new SessionSettings(args[0]);

            var configFile = "config.demo.price.ini";

            SessionSettings settings = new SessionSettings(configFile);

            MyQuickFixApp        myApp            = new MyQuickFixApp();
            IMessageStoreFactory storeFactory     = new FileStoreFactory(settings);
            ILogFactory          fileLogFactory   = new FileLogFactory(settings);
            ILogFactory          screenLogFactory = new ScreenLogFactory(settings);
            var socketInitiator = new SocketInitiator(myApp, storeFactory, settings, screenLogFactory);

            myApp.Initiator = socketInitiator;

            myApp.Run();

            //new Session(myApp, storeFactory,
            //new SocketInitiatorThread(socketInitiator,

            //ThreadedSocketAcceptor acceptor = new ThreadedSocketAcceptor(
            //    myApp,
            //    storeFactory,
            //    settings,
            //    logFactory);

            //acceptor.Start();


            //acceptor.Stop();

            //l.Info($"----- {typeof(Program).FullName}.Main() end -----");
        }