Пример #1
0
 protected XApiClient(XProvider provider, ConnectionInfo info, IXSpi spi = null)
 {
     Info     = info;
     Provider = provider;
     User     = provider.GetUserInfo(info.User);
     Server   = provider.GetServerInfo(info.Server, info.UseType);
     Logger   = LogManager.GetLogger($"{provider.Name}.{info.LogPrefix}.{User.UserID}");
     Api      = provider.CreateXApi(info);
     if (spi != null)
     {
         Api.RegisterSpi(spi);
     }
     Api.ErrorHappened           += OnErrorHappened;
     Api.StatusChanged           += OnStatusChanged;
     Api.InvestorReceived        += OnInvestorReceived;
     Api.AccountReceived         += OnRspQryAccount;
     Api.PositionReceived        += OnRspQryPositions;
     Api.OrderReturn             += OnRtnOrder;
     Api.TradeReturn             += OnRtnTrade;
     Api.InstrumentReceived      += OnInstrumentReceived;
     Api.MarketDataReceived      += OnMarketDataReceived;
     Api.OrderReceived           += OnOrderReceived;
     Api.TradeReceived           += OnTradeReceived;
     Api.InstrumentStatusChanged += OnInstrumentStatusChanged;
 }
Пример #2
0
 public BaseApi(string path)
     : this()
 {
     LibPath   = path;
     Server    = new ServerInfoField();
     User      = new UserInfoField();
     UserLogin = new RspUserLoginField();
 }
Пример #3
0
        public void Connect(ServerInfoField server, UserInfoField user)
        {
            if (_api == IntPtr.Zero)
            {
                _api = _proxy.XRequest(RequestType.Create);
                _proxy.XRequest(RequestType.Register, _api, IntPtr.Zero, 0, 0, Marshal.GetFunctionPointerForDelegate(_callback), 0, IntPtr.Zero, 0, IntPtr.Zero, 0);

                Server    = server;
                User      = user;
                UserLogin = null;
                _proxy.XRequest(RequestType.Connect, _api, IntPtr.Zero, 0, 0,
                                new UnmanagedPtr <ServerInfoField>(server), 0,
                                new UnmanagedPtr <UserInfoField>(User), 0,
                                Marshal.StringToHGlobalAnsi(Path.GetTempPath()), 0);
            }
        }
Пример #4
0
        public ServerInfoField Get()
        {
            var field = new ServerInfoField {
                IsUsingUdp  = IsUsingUdp,
                IsMulticast = IsMulticast,
                TopicId     = TopicId,
                Port        = Port,
                MarketDataTopicResumeType = MarketDataTopicResumeType,
                PrivateTopicResumeType    = PrivateTopicResumeType,
                PublicTopicResumeType     = PublicTopicResumeType,
                UserTopicResumeType       = UserTopicResumeType,
                BrokerID        = BrokerID,
                UserProductInfo = UserProductInfo,
                AuthCode        = AuthCode,
                Address         = Address
            };

            return(field);
        }
Пример #5
0
        public ServerInfoField ToStruct()
        {
            ServerInfoField field = new ServerInfoField();

            field.IsUsingUdp  = this.IsUsingUdp;
            field.IsMulticast = this.IsMulticast;
            field.TopicId     = this.TopicId;
            field.Port        = this.Port;
            field.MarketDataTopicResumeType = this.MarketDataTopicResumeType;
            field.PrivateTopicResumeType    = this.PrivateTopicResumeType;
            field.PublicTopicResumeType     = this.PublicTopicResumeType;
            field.UserTopicResumeType       = this.UserTopicResumeType;
            field.BrokerID        = this.BrokerID;
            field.UserProductInfo = this.UserProductInfo;
            field.AuthCode        = this.AuthCode;
            field.Address         = this.Address;
            field.ConfigPath      = this.ConfigPath;
            field.ExtInfoChar128  = this.ExtInfoChar128;

            return(field);
        }