/// <summary> /// The method tries to connect to remote server and returns list of valid connection strings. /// </summary> /// <param name="address">host name or IP address; can not benull</param> /// <param name="ports">list of ports, which should be checked; can be null in this case list of predefined ports will be checked</param> /// <param name="timeoutInMs">timeout in ms of connection establishing; can be zero or negative in this case default timeout will be used</param> /// <returns>list of valid connection strings</returns> public static ConnectionStringBuilder[] TestConnections(string address, IEnumerable <int> ports = null, int timeoutInMs = 0) { CheckConnectionParameters(address, string.Empty, string.Empty); var testers = new List <ConnectionTester>(); FixConnectionStringBuilder.PrepareConnectionTesters(address, string.Empty, string.Empty, ports, testers); LrpConnectionStringBuilder.PrepareConnectionTesters(address, string.Empty, string.Empty, ports, testers); var result = TestConnections <ConnectionStringBuilder>(testers, timeoutInMs); return(result); }
/// <summary> /// The method tries to connect to remote server and returns list of valid connection strings. /// </summary> /// <param name="username">a valid username</param> /// <param name="password">a valid password</param> /// <param name="address">host name or IP address; can not benull</param> /// <param name="ports">list of ports, which should be checked; can be null in this case list of predefined ports will be checked</param> /// <param name="timeoutInMs">timeout in ms of connection establishing; can be zero or negative in this case default timeout will be used</param> /// <returns>list of valid connection strings</returns> public static ConnectionStringBuilder[] TestTradeConnections(string address, string username, string password, IEnumerable <int> ports = null, int timeoutInMs = 0) { CheckConnectionParameters(address, username, password); var testers = new List <ConnectionTester>(); FixConnectionStringBuilder.PrepareTradeConnectionTesters(address, username, password, ports, testers); LrpConnectionStringBuilder.PrepareTradeConnectionTesters(address, username, password, ports, testers); var result = TestTradeConnections <ConnectionStringBuilder>(testers, timeoutInMs); return(result); }
static DataFeed CreateDataFeed() { var builder = new FixConnectionStringBuilder { SecureConnection = true, Port = 5003, Address = Settings.Default.DataSources_FDK_Server, Username = Settings.Default.DataSources_FDK_Username, Password = Settings.Default.DataSources_FDK_Password, }; var dataFeed = new DataFeed(builder.ToString()); return dataFeed; }
static FixConnectionStringBuilder CreateBuilder(string addres, string login, string password) { var builder = new FixConnectionStringBuilder(); builder.ProtocolVersion = FixProtocolVersion.TheLatestVersion.ToString(); builder.Address = addres; builder.Port = 5004; builder.SecureConnection = true; builder.Username = login; builder.Password = password; builder.TargetCompId = "EXECUTOR"; builder.DecodeLogFixMessages = true; builder.FixLogDirectory = LogPath; builder.FixEventsFileName = $"{login}.trade.events.log"; builder.FixMessagesFileName = $"{login}.trade.messages.log"; return builder; }
static ConnectionStringBuilder CreateFixConnectionStringBuilder(string address, string username, string password, string logDirectory) { var result = new FixConnectionStringBuilder { SecureConnection = true, Port = 5003, //ExcludeMessagesFromLogs = "W" Address = address, FixLogDirectory = logDirectory, FixEventsFileName = string.Format("FIX_{0}.feed.events.log", username), FixMessagesFileName = string.Format("FIX_{0}.feed.messages.log", username), Username = username, Password = password }; return result; }
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(); }
static string CreateTradeConnectionString(string address, string username, string password, string logsLocation) { var builder = new FixConnectionStringBuilder { TargetCompId = "EXECUTOR", ProtocolVersion = FixProtocolVersion.TheLatestVersion.ToString(), Address = address, Username = username, Password = password, SecureConnection = true, Port = 5004, DecodeLogFixMessages = true, FixLogDirectory = logsLocation, }; return builder.ToString(); }
internal void SetupBuilder(string address, string username, string password, string logPath) { // 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) }; Builder = builder; }
public FdkConnectLogic(string address, string username, string password) { Address = address; Username = username; Password = password; // create and initialize fix connection string builder Builder = new FixConnectionStringBuilder { TargetCompId = "EXECUTOR", ProtocolVersion = FixProtocolVersion.TheLatestVersion.ToString(), SecureConnection = false, Port = 5001, DecodeLogFixMessages = true, Address = address, Username = username, Password = password, FixEventsFileName = string.Format("{0}.trade.events.log", username), FixMessagesFileName = string.Format("{0}.trade.messages.log", username), }; TradeWrapper = new FdkTradeWrapper(); //this.Builder.ExcludeMessagesFromLogs = "W"; }
internal static void PrepareConnectionTesters(string address, string username, string password, IEnumerable <int> ports, ICollection <ConnectionTester> testers) { if (ports == null) { ports = Ports; } foreach (var element in ports) { var builder = new FixConnectionStringBuilder { Address = address, SecureConnection = true, Port = element, Username = username, Password = password }; var tester = new ConnectionTester(builder); testers.Add(tester); } foreach (var element in ports) { var builder = new FixConnectionStringBuilder { Address = address, SecureConnection = false, Port = element, Username = username, Password = password }; var tester = new ConnectionTester(builder); testers.Add(tester); } }
static FixConnectionStringBuilder CreateFixConnectionStringBuilder(AccountType type, FixProtocolVersion protocolVersion) { var result = new FixConnectionStringBuilder { FixVersion = "FIX.4.4", Address = "ttdemo.fxopen.com", TargetCompId = "EXECUTOR" }; if (type == AccountType.Gross) { result.Username = "******"; result.Password = "******"; } else if (type == AccountType.Net) { result.Username = "******"; result.Password = "******"; } else if (type == AccountType.Cash) { result.Address = "crypto.ttdemo.fxopen.com"; result.Username = "******"; result.Password = "******"; } result.ProtocolVersion = protocolVersion.ToString(); #if DEBUG result.DecodeLogFixMessages = true; result.FixLogDirectory = @"C:\Temporary\Logs"; #endif return result; }
internal static void PrepareConnectionTesters(string address, string username, string password, IEnumerable<int> ports, ICollection<ConnectionTester> testers) { if (ports == null) ports = Ports; foreach(var element in ports) { var builder = new FixConnectionStringBuilder { Address = address, SecureConnection = true, Port = element, Username = username, Password = password }; var tester = new ConnectionTester(builder); testers.Add(tester); } foreach (var element in ports) { var builder = new FixConnectionStringBuilder { Address = address, SecureConnection = false, Port = element, Username = username, Password = password }; var tester = new ConnectionTester(builder); testers.Add(tester); } }