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; }
public BaseApi(string path) : this() { LibPath = path; Server = new ServerInfoField(); User = new UserInfoField(); UserLogin = new RspUserLoginField(); }
public UserInfoField Get() { var field = new UserInfoField { UserID = UserId, Password = Password }; return(field); }
public UserInfoField ToStruct() { UserInfoField field = new UserInfoField(); field.UserID = this.UserID; field.Password = this.Password; field.ExtInfoChar64 = this.ExtInfoChar64; field.ExtInfoInt32 = this.ExtInfoInt32; return(field); }
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); } }