Пример #1
0
        static void Main(string[] args)
        {
            if (args.Length != 3)
            {
                Console.WriteLine("Usage: AccountInfo.exe address login password");
                return;
            }

            try
            {
                if (!Directory.Exists(LogPath))
                {
                    Directory.CreateDirectory(LogPath);
                }

                string address  = args[0];
                string login    = args[1];
                string password = args[2];

                // Create data trade interface
                var trade = new DataTrade {
                    SynchOperationTimeout = 30000
                };

                // Create connection string
                FixConnectionStringBuilder builder = CreateBuilder(address, login, password);
                var connectionString = builder.ToString();

                // Initialize data trade interface
                trade.Initialize(connectionString);

                // Subscribe to data trade events
                trade.Logon       += OnLogon;
                trade.Logout      += OnLogout;
                trade.AccountInfo += OnAccountInfo;

                // Start data trade
                trade.Start();
                Console.WriteLine("DataTrade started!");
                Console.WriteLine("Please wait for login status...");

                // Wait for exit
                Console.ReadKey();

                // Stop data trade
                trade.Stop();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Пример #2
0
        public void TestDataTradeIsolation()
        {
            const string address  = "tpdemo.fxopen.com";
            const string username = "******";
            const string password = "******";

            EnsureDirectoriesCreated();

            // Create builder
            var builder = new FixConnectionStringBuilder
            {
                TargetCompId     = "EXECUTOR",
                ProtocolVersion  = FixProtocolVersion.TheLatestVersion.ToString(),
                SecureConnection = true,
                Port             = 5004,
                //ExcludeMessagesFromLogs = "W",
                DecodeLogFixMessages = true,

                Address  = address,
                Username = username,
                Password = password,

                FixLogDirectory     = LogPath,
                FixEventsFileName   = string.Format("{0}.trade.events.log", username),
                FixMessagesFileName = string.Format("{0}.trade.messages.log", username)
            };
            var trade = new DataTrade
            {
                SynchOperationTimeout = 30000
            };
            var connectionString = builder.ToString();

            trade.Initialize(connectionString);
            trade.Logon += OnLogon;
            trade.Start();
            var timeoutInMilliseconds = trade.SynchOperationTimeout;

            if (!_syncEvent.WaitOne(timeoutInMilliseconds))
            {
                throw new TimeoutException("Timeout of logon waiting has been reached");
            }
            RunExample(trade);

            trade.Dispose();
        }
Пример #3
0
        public void Connect(string address, string username, string password, string logPath)
        {
            EnsureDirectoriesCreated(logPath);

            // Create builder
            SetupBuilder(address, username, password, logPath);
            var connectionString = Builder.ToString();

            Trade = new DataTrade();
            Trade.Initialize(connectionString);
            var isConnected = Trade.Start(30000);

            if (!isConnected)
            {
                Trade.Stop();
                throw new TimeoutException();
            }
        }
Пример #4
0
        public void Connect(string address, string username, string password, string logPath)
        {
            EnsureDirectoriesCreated(logPath);

            // Create builder
            SetupBuilder(address, username, password, logPath);
            Trade = new DataTrade
            {
                SynchOperationTimeout = 300000
            };
            var connectionString = Builder.ToString();

            Trade.Initialize(connectionString);
            Trade.Logon += OnLogon;
            Trade.Start();
            var timeoutInMilliseconds = Trade.SynchOperationTimeout;

            if (!_syncEvent.WaitOne(timeoutInMilliseconds))
            {
                throw new TimeoutException("Timeout of logon waiting has been reached");
            }
        }