示例#1
0
        internal static FixConnectionStringBuilder LoadConnectionSettings()
        {
            string path = ConfirugationPath;
            FixConnectionStringBuilder result = TryLoadFixConnectionStringBuilder(path);

            return(result);
        }
示例#2
0
        internal static void UpdateConnectionSettings(FixConnectionStringBuilder builder)
        {
            DataFeedImpl dataFeedImpl = Create();

            lock (s_synchronizer)
            {
                dataFeedImpl.Intialize(builder.ToString());
                string path = ConfirugationPath;
                TrySaveFixConnectionStringBuilder(path, builder);
            }
        }
示例#3
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);
            }
        }
示例#4
0
        private void OnOK(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
            FixConnectionStringBuilder builder = new FixConnectionStringBuilder();

            builder.TradingPlatformAddress = m_address.Text;
            builder.TradingPlatformPort    = int.Parse(m_port.Text);
            builder.Username         = m_username.Text;
            builder.Password         = m_password.Text;
            builder.SecureConnection = m_ssl.Checked;

            DataFeedImpl.UpdateConnectionSettings(builder);
        }
示例#5
0
 private static void TrySaveFixConnectionStringBuilder(string path, FixConnectionStringBuilder builder)
 {
     try
     {
         XmlSerializer serializer = new XmlSerializer(typeof(FixConnectionStringBuilder));
         using (StreamWriter stream = new StreamWriter(path))
         {
             serializer.Serialize(stream, builder);
         }
     }
     catch (System.Exception)
     {
     }
 }
        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);
        }
示例#7
0
        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);
        }
示例#8
0
 private static FixConnectionStringBuilder TryLoadFixConnectionStringBuilder(string path)
 {
     try
     {
         XmlSerializer serializer = new XmlSerializer(typeof(FixConnectionStringBuilder));
         using (StreamReader stream = new StreamReader(path))
         {
             object obj = serializer.Deserialize(stream);
             FixConnectionStringBuilder result = (FixConnectionStringBuilder)obj;
             return(result);
         }
     }
     catch (System.Exception)
     {
         return(null);
     }
 }
示例#9
0
        public static ConnectionStringBuilder[] ConnectionBuilders(AccountType type, ConnectionType connType)
        {
            var builders = new List <ConnectionStringBuilder>();

            FixConnectionStringBuilder result = CreateFixConnectionStringBuilder(type, FixProtocolVersion.TheLatestVersion);

            result.SecureConnection = true;
            result.Port             = connType == ConnectionType.Trade ? 5004 : 5003;
            builders.Add(result);

            result = CreateFixConnectionStringBuilder(type, FixProtocolVersion.TheLatestVersion);
            result.SecureConnection = false;
            result.Port             = connType == ConnectionType.Trade ? 5002 : 5001;
            builders.Add(result);

            return(builders.ToArray());
        }
示例#10
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();
        }
示例#11
0
 internal static DataFeedImpl Create()
 {
     lock (s_synchronizer)
     {
         if (null == s_impl)
         {
             s_impl = new DataFeedImpl();
             FixConnectionStringBuilder builder = LoadConnectionSettings();
             if (null != builder)
             {
                 string connectionString = builder.ToString();
                 s_impl.Intialize(connectionString);
             }
         }
         s_counter++;
         return(s_impl);
     }
 }
示例#12
0
文件: Example.cs 项目: hombrevrc/FDK
        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);
        }
示例#13
0
        public ConnectionsSettingsDialog()
        {
            InitializeComponent();
            FixConnectionStringBuilder builder = DataFeedImpl.LoadConnectionSettings();

            if (null == builder)
            {
                builder = new FixConnectionStringBuilder();
                builder.TradingPlatformPort = 5003;
                builder.SecureConnection    = true;
            }
            m_address.Text     = builder.TradingPlatformAddress;
            m_port.Text        = builder.TradingPlatformPort.ToString();
            m_ssl.Checked      = builder.SecureConnection;
            m_username.Text    = builder.Username;
            m_password.Text    = builder.Password;
            m_port.Validating += OnPortValidating;
        }
示例#14
0
        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;
        }
示例#15
0
        public QuotesDownloader()
        {
            if (this.fixConnectionStringBuilder == null)
            {
                this.fixConnectionStringBuilder = new FixConnectionStringBuilder();
            }
            this.InitializeComponent();

            this.Text = string.Format("{0} (FDK {1})", this.Text, Library.Version);

            foreach (var element in StorageProvider.Providers)
            {
                this.m_storageType.Items.Add(element.Key);
            }
            this.m_storageType.SelectedIndex = 0;

            var path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            path = Path.Combine(path, "Quotes");
            Directory.CreateDirectory(path);
            this.m_location.Text            = path;
            this.m_quotesType.SelectedIndex = 0;

            this.m_address.Text  = this.fixConnectionStringBuilder.Address;
            this.m_username.Text = this.fixConnectionStringBuilder.Username;
            this.m_password.Text = this.fixConnectionStringBuilder.Password;
            this.m_port.Text     = this.fixConnectionStringBuilder.Port.ToString();
            this.m_ssl.Checked   = this.fixConnectionStringBuilder.SecureConnection;


            var utcNow = DateTime.UtcNow;
            var to     = new DateTime(utcNow.Year, utcNow.Month, utcNow.Day);

            to = to.AddDays(-7);
            var from = to.AddDays(-7);

            this.m_dateAndTimeFrom.Value = from;
            this.m_dateAndTimeTo.Value   = to;
            this.ApplyDisconnectedState();
        }
示例#16
0
 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";
 }
示例#17
0
        internal void SetupBuilder(string address, string username, string password, string logPath)
        {
            // Create builder
            ConnectionStringBuilder builder = null;

            if (!FdkHelper.UseLrp)
            {
                var fixBuilder = new FixConnectionStringBuilder();
                fixBuilder.TargetCompId            = "EXECUTOR";
                fixBuilder.ProtocolVersion         = FixProtocolVersion.TheLatestVersion.ToString();
                fixBuilder.SecureConnection        = true;
                fixBuilder.Port                    = 5004;
                fixBuilder.ExcludeMessagesFromLogs = "W";
                fixBuilder.DecodeLogFixMessages    = false;
                fixBuilder.Address                 = address;
                fixBuilder.Username                = username;
                fixBuilder.Password                = password;
                fixBuilder.FixLogDirectory         = logPath;
                fixBuilder.FixEventsFileName       = string.Format("{0}.trade.events.log", username);
                fixBuilder.FixMessagesFileName     = string.Format("{0}.trade.messages.log", username);
                builder = fixBuilder;
            }
            else
            {
                var fixBuilder = new LrpConnectionStringBuilder();
                fixBuilder.SecureConnection    = true;
                fixBuilder.Port                = 5004; ////ExcludeMessagesFromLogs = "W",
                fixBuilder.Address             = address;
                fixBuilder.Username            = username;
                fixBuilder.Password            = password;
                fixBuilder.MessagesLogFileName = string.Format("{0}.trade.events.log", username);
                builder = fixBuilder;
            }


            Builder = builder;
        }
示例#18
0
        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);
        }