예제 #1
0
        public void Init(ServerInfoField server, UserInfoField user)
        {
            if (Api != null)
            {
                return;
            }
            if (!CheckSettings(server, user))
            {
                return;
            }
            _queryManager = new CtpQueryManager(this);
            _processor    = new CtpDealProcessor(this);
            User          = user;
            Server        = server;
            Api           = new CtpTraderApi(GetFlowPath(server, user));
            InitHandler();
            var items = server.Address.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var item in items)
            {
                Api.RegisterFront(item);
            }
            Api.SubscribePrivateTopic(CtpConvert.GetCtpResumeType(server.PrivateTopicResumeType));
            Api.SubscribePublicTopic(CtpConvert.GetCtpResumeType(server.PublicTopicResumeType));
            _publisher.Post(ConnectionStatus.Connecting);
            Api.Init();
        }
예제 #2
0
 private bool CheckSettings(ServerInfoField server, UserInfoField user)
 {
     if (string.IsNullOrEmpty(server.Address))
     {
         SendError("没有设置 Address");
         _publisher.Post(ConnectionStatus.Disconnected);
         return(false);
     }
     if (string.IsNullOrEmpty(server.BrokerID))
     {
         SendError("没有设置 BrokerID");
         _publisher.Post(ConnectionStatus.Disconnected);
         return(false);
     }
     if (string.IsNullOrEmpty(user.UserID) || string.IsNullOrEmpty(user.Password))
     {
         SendError("没有设置用户名和密码");
         _publisher.Post(ConnectionStatus.Disconnected);
         return(false);
     }
     #region 设置天风认证码
     //连接实盘系统
     if (string.IsNullOrEmpty(server.ExtInfoChar128))
     {
         server.AuthCode       = ThanfAuthCode;
         server.ExtInfoChar128 = OpenQuantAppId;
     }
     #endregion
     return(true);
 }
예제 #3
0
        private static string GetFlowPath(ServerInfoField server, UserInfoField user)
        {
            var path = Path.Combine(Path.GetTempPath(), "XAPI", "T", $"{server.BrokerID}_{user.UserID}_{Rand.Next()}");

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            return(path + Path.DirectorySeparatorChar);
        }
예제 #4
0
        public void Init(ServerInfoField server, UserInfoField user)
        {
            if (_api != null)
            {
                return;
            }
            User      = user;
            Server    = server;
            UserLogin = null;
            _api      = new CtpMdApi(GetFlowPath(server, user));
            InitHandler();
            var items = server.Address.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var item in items)
            {
                _api.RegisterFront(item);
            }
            _publisher.Post(ConnectionStatus.Connecting);
            _api.Init();
        }
예제 #5
0
 private bool CheckSettings(ServerInfoField server, UserInfoField user)
 {
     if (string.IsNullOrEmpty(server.Address))
     {
         SendError("没有设置 Address");
         _publisher.Post(ConnectionStatus.Disconnected);
         return(false);
     }
     if (string.IsNullOrEmpty(server.BrokerID))
     {
         SendError("没有设置 BrokerID");
         _publisher.Post(ConnectionStatus.Disconnected);
         return(false);
     }
     if (string.IsNullOrEmpty(user.UserID) || string.IsNullOrEmpty(user.Password))
     {
         SendError("没有设置用户名和密码");
         _publisher.Post(ConnectionStatus.Disconnected);
         return(false);
     }
     return(true);
 }
예제 #6
0
 public void Connect(ServerInfoField server, UserInfoField user)
 {
     _client?.Init(server, user);
 }
예제 #7
0
 public void Connect(ServerInfoField server, UserInfoField user)
 {
     _api.Connect(server, user);
 }