/// <summary> /// 整个应用的终止 /// </summary> public static void ShutDown() { if (_windAPI != null) { log.Debug("正在关闭Wind API..."); if (_windAPI.isconnected()) { _windAPI.stop(); } } log.Info("------ Platform已关闭. ------"); }
/// <summary> /// 获取可立即使用的WindAPI,如果处于未连接状态自动开启 /// </summary> /// <returns></returns> public static WindAPI GetWindAPI() { if (_windAPI == null) { _windAPI = new WindAPI(); } if (!_windAPI.isconnected()) { _windAPI.start(); } return(_windAPI); }
public static WindAPI getAPI() { if (api == null || !api.isconnected()) { api = new WindAPI(); try { int result = (int)api.start(); if (result == 0) { Console.WriteLine(" Wind API 登录成功!"); } else { Console.WriteLine(" Wind API 登录失败: " + api.getErrorMsg(result)); } } catch (Exception e) { Console.WriteLine(e); } } return(api); }
//启动、登录 public static bool Login() { if (null == windHandle) { windHandle = new WindAPI(); } int nStatus = 0; if (!windHandle.isconnected()) { nStatus = windHandle.start(); } if (0 != nStatus) { return(false); } return(true); }
//启动、登录 private bool start() { if (null == m_w) { m_w = new WindAPI(); } int nStatus = 0; if (!m_w.isconnected()) { nStatus = m_w.start(); } if (0 != nStatus) { return(false); } return(true); }
/// <summary> /// 处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDeal_Click(object sender, EventArgs e) { //接口初始化 WindAPI w = new WindAPI(); //在接口操作前,用户首先要登录并启动C#插件,即使用w.start()命令。其中,返回值0表示登陆成功,负数表示登陆失败,可通过w.getErrorMsg()函数获取错误信息。 w.start(); //当需要判断是否连接c#接口时,可以使用w.isconnected()命令。返回值True表示处于连接状态,反之False表示连接断开。 if (w.isconnected()) { WindData wd = w.wss("000001.SZ,000002.SZ", "open,low,close,volume", "tradeDate=20180809;priceAdj=U;cycle=D"); //返回的数据转化为便于使用的数据结构, object[,] getData = (object[, ])wd.getDataByFunc("wss", false); MessageBox.Show("连接成功"); } //当需要停止使用C#接口时,可以使用w.stop()命令,由于程序退出时会自动执行w.stop()命令,用户一般并不需要执行。 w.stop(); }