private void wsq_Click(object sender, EventArgs e) { if (!start()) { return; } //查询一次 WindData wd = m_w.wsq("AAL.L,ABF.L", "rt_time,rt_pre_close,rt_open,rt_last,rt_latest,rt_chg", ""); string s = WindDataMethod.WindDataToString(wd, "wsq"); ShowInRichText(s); }
/// <summary> /// 获取期权和50ETF实时快照数据 /// </summary> /// <param name="optionList"></param> /// <param name="etfPrice"></param> /// <returns></returns> private Dictionary <string, OptionGreek> getOptionPrice(List <OptionInfo> optionList, ref double etfPrice) { Dictionary <string, OptionGreek> option = new Dictionary <string, OptionGreek>(); string code = "510050.SH"; for (int i = 0; i < optionList.Count(); i++) { OptionGreek greek = new OptionGreek(); greek.code = optionList[i].optionCode; greek.duration = DateUtils.GetSpanOfTradeDays(today, optionList[i].endDate); option.Add(greek.code, greek); code += "," + greek.code; } WindData wd = w.wsq(code, "rt_last,rt_ask1,rt_asize1,rt_bid1,rt_bsize1,rt_delta,rt_gamma,rt_vega,rt_theta,rt_imp_volatility", ""); if (wd.data is double[]) { double[] dataList = (double[])wd.data; int length = dataList.Length / 10; etfPrice = dataList[0]; for (int i = 1; i < length; i++) { string optionCode = optionList[i - 1].optionCode; double strike = optionList[i - 1].strike; OptionGreek greek = option[optionCode]; greek.lastPrice = dataList[i * 10 + 0]; greek.ask = dataList[i * 10 + 1]; greek.askv = dataList[i * 10 + 2]; greek.bid = dataList[i * 10 + 3]; greek.bidv = dataList[i * 10 + 4]; greek.delta = dataList[i * 10 + 5]; greek.gamma = dataList[i * 10 + 6]; greek.vega = dataList[i * 10 + 7]; greek.theta = dataList[i * 10 + 8]; greek.impv = dataList[i * 10 + 9]; greek.coordinate = Math.Round(1000 * Math.Log(strike / etfPrice), 0) + 500; option[optionCode] = greek; } } return(option); }
public static double getLastPrice(string inst) { if (Login()) { WindData wd = windHandle.wsq(inst, "rt_bid1,rt_ask1", ""); object getData = wd.getDataByFunc("wsq", false); if (checkError(wd) != 0) { return(0); } if (getData is object[, ])//转化为2维数组 { object[,] odata = (object[, ])getData; double bid1 = double.Parse(odata[0, 0].ToString()); double ask1 = double.Parse(odata[0, 1].ToString()); return((bid1 + ask1) / 2); } } return(0); }
public static ulong Start(string code, DataHandler handler) { string fields = "rt_last,rt_vol,rt_time"; //for (int i = 1; i <= 5; i++) // fields += // ",rt_ask" + i.ToString() + // ",rt_asize" + i.ToString() + // ",rt_bid" + i.ToString() + // ",rt_bsize" + i.ToString(); int errCode = 0; ulong id; lock (_threadLock) { id = _api.wsq(ref errCode, code, fields, "", wrapper, true); _dict.Add(id, handler); } return(id); }
private void doRequest(string windCode) { if (windCode == rwCode) { return; } else { rid = w.wsq(windCode, "rt_last", "", myCallback); rwCode = windCode; } }
/// <summary> /// 万德的查询函数 /// </summary> /// <param name="code">查询对象代码</param> private void Execute(List <string> code) { WindAPI w = new WindAPI(); w.start(); int errorId = 0; string codeList = ""; foreach (var item in code) { codeList += item + ","; dataList.Add(item, new Level1Data()); } codeList.Remove(codeList.Length - 1, 1); ulong reqId = w.wsq(ref errorId, codeList, "rt_ask1,rt_asize1,rt_bid1,rt_bsize1,rt_latest,rt_time", "", myCallback); }