public void Connect(string frontAddress, int port, string userID, string password) { this.userID = userID; this.password = password; //this._instance = EsunnyWrapper.CreateTradeApi(); this._instance = (IntPtr)EsunnyWrapper.InvokeAPI(IntPtr.Zero, EsunnyWrapperAction.CreateTradeApi, null); //监听器 _listener = new EsunnyTraderListener(); _listener.trader = this; EsunnyWrapper.InvokeAPI(this._instance, EsunnyWrapperAction.TradeSetSpi, this._listener.Instance); TEsAddressField addr = new TEsAddressField(); addr.Ip = frontAddress; addr.Port = port; EsunnyWrapper.InvokeAPI(this._instance, EsunnyWrapperAction.TradeOpen, addr); }
public void Connect(string frontAddress, int port) { this.frontAddress = frontAddress; this.port = port; //创建实例 this._instance = (IntPtr)EsunnyWrapper.InvokeAPI(IntPtr.Zero, EsunnyWrapperAction.CreateQuoteApi, null); //创建监听器 _listener = new EsunnyQuoteListener(); _listener._esunnyQuote = this; EsunnyWrapper.InvokeAPI(this._instance, EsunnyWrapperAction.QuoteSetSpi, this._listener.Instance); //设置行情服务器地址 TEsAddressField addr = new TEsAddressField(); addr.Ip = frontAddress; addr.Port = port; //开始建立连接 EsunnyWrapper.InvokeAPI(this._instance, EsunnyWrapperAction.QuoteOpen, addr); }